a3130333f729d4566725a94c77e6c67380eec49a18a82b3c1fe22e86f7ef9915.json raw

   1  {"ast":null,"code":"import _asyncToGenerator from \"/home/mleku/src/orly.dev/next/signer/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { inject } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { LoggerService, NavComponent, NostrHelper, ProfileMetadataService, PubkeyComponent, ToastComponent, VisualNip05Pipe, validateNip05 } from '@common';\nimport * as i0 from \"@angular/core\";\nfunction IdentityComponent_Conditional_5_Template(rf, ctx) {\n  if (rf & 1) {\n    const _r2 = i0.ɵɵgetCurrentView();\n    i0.ɵɵelementStart(0, \"button\", 20);\n    i0.ɵɵlistener(\"click\", function IdentityComponent_Conditional_5_Template_button_click_0_listener() {\n      i0.ɵɵrestoreView(_r2);\n      const ctx_r2 = i0.ɵɵnextContext();\n      return i0.ɵɵresetView(ctx_r2.onTestPrompt());\n    });\n    i0.ɵɵelementStart(1, \"span\", 4);\n    i0.ɵɵtext(2, \"\\u2728\");\n    i0.ɵɵelementEnd()();\n  }\n}\nfunction IdentityComponent_Conditional_20_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"span\", 15);\n    i0.ɵɵtext(1);\n    i0.ɵɵelementEnd();\n  }\n  if (rf & 2) {\n    const ctx_r2 = i0.ɵɵnextContext();\n    i0.ɵɵadvance();\n    i0.ɵɵtextInterpolate1(\" \", ctx_r2.username, \" \");\n  }\n}\nfunction IdentityComponent_Conditional_21_Conditional_1_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelement(0, \"i\", 21);\n  }\n}\nfunction IdentityComponent_Conditional_21_Conditional_2_Conditional_0_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelement(0, \"i\", 23);\n  }\n}\nfunction IdentityComponent_Conditional_21_Conditional_2_Conditional_1_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelement(0, \"i\", 24);\n  }\n}\nfunction IdentityComponent_Conditional_21_Conditional_2_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵtemplate(0, IdentityComponent_Conditional_21_Conditional_2_Conditional_0_Template, 1, 0, \"i\", 23)(1, IdentityComponent_Conditional_21_Conditional_2_Conditional_1_Template, 1, 0, \"i\", 24);\n  }\n  if (rf & 2) {\n    const ctx_r2 = i0.ɵɵnextContext(2);\n    i0.ɵɵconditional(ctx_r2.nip05isValidated ? 0 : 1);\n  }\n}\nfunction IdentityComponent_Conditional_21_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 16);\n    i0.ɵɵtemplate(1, IdentityComponent_Conditional_21_Conditional_1_Template, 1, 0, \"i\", 21)(2, IdentityComponent_Conditional_21_Conditional_2_Template, 2, 1);\n    i0.ɵɵelementStart(3, \"span\", 22);\n    i0.ɵɵtext(4);\n    i0.ɵɵpipe(5, \"visualNip05\");\n    i0.ɵɵelementEnd()();\n  }\n  if (rf & 2) {\n    const ctx_r2 = i0.ɵɵnextContext();\n    i0.ɵɵadvance();\n    i0.ɵɵconditional(ctx_r2.validating ? 1 : 2);\n    i0.ɵɵadvance(3);\n    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(5, 2, ctx_r2.profile == null ? null : ctx_r2.profile.nip05));\n  }\n}\nfunction IdentityComponent_Conditional_24_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 19)(1, \"div\", 25);\n    i0.ɵɵtext(2, \"About\");\n    i0.ɵɵelementEnd();\n    i0.ɵɵelementStart(3, \"div\", 26);\n    i0.ɵɵtext(4);\n    i0.ɵɵelementEnd()();\n  }\n  if (rf & 2) {\n    const ctx_r2 = i0.ɵɵnextContext();\n    i0.ɵɵadvance(4);\n    i0.ɵɵtextInterpolate(ctx_r2.aboutText);\n  }\n}\nexport let IdentityComponent = /*#__PURE__*/(() => {\n  class IdentityComponent extends NavComponent {\n    selectedIdentity;\n    selectedIdentityNpub;\n    profile = null;\n    nip05isValidated;\n    validating = false;\n    loading = true;\n    #router = inject(Router);\n    #profileMetadata = inject(ProfileMetadataService);\n    #logger = inject(LoggerService);\n    ngOnInit() {\n      this.#loadData();\n    }\n    get displayName() {\n      return this.#profileMetadata.getDisplayName(this.profile);\n    }\n    get username() {\n      return this.#profileMetadata.getUsername(this.profile);\n    }\n    get avatarUrl() {\n      return this.profile?.picture;\n    }\n    get bannerUrl() {\n      return this.profile?.banner;\n    }\n    get aboutText() {\n      return this.profile?.about;\n    }\n    copyToClipboard(pubkey) {\n      if (!pubkey) {\n        return;\n      }\n      navigator.clipboard.writeText(pubkey);\n    }\n    onClickShowDetails() {\n      if (!this.selectedIdentity) {\n        return;\n      }\n      this.#router.navigateByUrl(`/edit-identity/${this.selectedIdentity.id}/home`);\n    }\n    onClickEditProfile() {\n      if (!this.selectedIdentity) {\n        return;\n      }\n      this.#router.navigateByUrl('/profile-edit');\n    }\n    onClickLock() {\n      var _this = this;\n      return _asyncToGenerator(function* () {\n        _this.#logger.logVaultLock();\n        yield _this.storage.lockVault();\n        _this.#router.navigateByUrl('/vault-login');\n      })();\n    }\n    #loadData() {\n      var _this2 = this;\n      return _asyncToGenerator(function* () {\n        try {\n          const selectedIdentityId = _this2.storage.getBrowserSessionHandler().browserSessionData?.selectedIdentityId ?? null;\n          const identity = _this2.storage.getBrowserSessionHandler().browserSessionData?.identities.find(x => x.id === selectedIdentityId);\n          if (!identity) {\n            _this2.loading = false;\n            return;\n          }\n          _this2.selectedIdentity = identity;\n          const pubkey = NostrHelper.pubkeyFromPrivkey(identity.privkey);\n          _this2.selectedIdentityNpub = NostrHelper.pubkey2npub(pubkey);\n          // Initialize the profile metadata service (loads cache from storage)\n          yield _this2.#profileMetadata.initialize();\n          // Check if we have cached profile data\n          const cachedProfile = _this2.#profileMetadata.getCachedProfile(pubkey);\n          if (cachedProfile) {\n            _this2.profile = cachedProfile;\n            _this2.loading = false;\n            // Validate NIP-05 if present (in background)\n            if (cachedProfile.nip05) {\n              _this2.#validateNip05(pubkey, cachedProfile.nip05);\n            }\n            return; // Use cached data, don't fetch again\n          }\n          // No cached data, fetch from relays\n          _this2.loading = true;\n          const fetchedProfile = yield _this2.#profileMetadata.fetchProfile(pubkey);\n          if (fetchedProfile) {\n            _this2.profile = fetchedProfile;\n            // Validate NIP-05 if present\n            if (fetchedProfile.nip05) {\n              _this2.#validateNip05(pubkey, fetchedProfile.nip05);\n            }\n          }\n          _this2.loading = false;\n        } catch (error) {\n          console.error(error);\n          _this2.loading = false;\n        }\n      })();\n    }\n    #validateNip05(pubkey, nip05) {\n      var _this3 = this;\n      return _asyncToGenerator(function* () {\n        try {\n          _this3.validating = true;\n          // Direct NIP-05 validation - fetches .well-known/nostr.json directly\n          const result = yield validateNip05(nip05, pubkey);\n          _this3.nip05isValidated = result.valid;\n          if (result.valid) {\n            _this3.#logger.logNip05ValidationSuccess(nip05, pubkey);\n          } else {\n            _this3.#logger.logNip05ValidationError(nip05, result.error ?? 'Unknown error');\n          }\n          _this3.validating = false;\n        } catch (error) {\n          const errorMsg = error instanceof Error ? error.message : 'Unknown error';\n          _this3.#logger.logNip05ValidationError(nip05, errorMsg);\n          _this3.nip05isValidated = false;\n          _this3.validating = false;\n        }\n      })();\n    }\n    static ɵfac = /*@__PURE__*/(() => {\n      let ɵIdentityComponent_BaseFactory;\n      return function IdentityComponent_Factory(__ngFactoryType__) {\n        return (ɵIdentityComponent_BaseFactory || (ɵIdentityComponent_BaseFactory = i0.ɵɵgetInheritedFactory(IdentityComponent)))(__ngFactoryType__ || IdentityComponent);\n      };\n    })();\n    static ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n      type: IdentityComponent,\n      selectors: [[\"app-identity\"]],\n      features: [i0.ɵɵInheritDefinitionFeature],\n      decls: 27,\n      vars: 13,\n      consts: [[\"toast\", \"\"], [1, \"sam-text-header\"], [1, \"header-buttons\"], [\"title\", \"Lock\", 1, \"header-btn\", 3, \"click\"], [1, \"emoji\"], [\"title\", \"Test Permission Prompt\", 1, \"header-btn\"], [\"title\", \"Edit profile\", 1, \"edit-btn\", 3, \"click\"], [1, \"identity-container\"], [1, \"banner-background\"], [1, \"banner-overlay\"], [1, \"profile-content\"], [1, \"avatar-frame\"], [\"alt\", \"\", 1, \"avatar-image\", 3, \"src\"], [1, \"name-badge-container\", 3, \"click\"], [1, \"display-name\"], [1, \"username\"], [1, \"nip05-row\"], [1, \"npub-wrapper\"], [3, \"click\", \"value\", \"first\", \"last\"], [1, \"about-section\"], [\"title\", \"Test Permission Prompt\", 1, \"header-btn\", 3, \"click\"], [1, \"bi\", \"bi-circle\", \"color-activity\"], [1, \"nip05-badge\"], [1, \"bi\", \"bi-patch-check\", \"sam-color-primary\"], [1, \"bi\", \"bi-exclamation-octagon-fill\", \"sam-color-danger\"], [1, \"about-header\"], [1, \"about-content\"]],\n      template: function IdentityComponent_Template(rf, ctx) {\n        if (rf & 1) {\n          const _r1 = i0.ɵɵgetCurrentView();\n          i0.ɵɵelementStart(0, \"div\", 1)(1, \"div\", 2)(2, \"button\", 3);\n          i0.ɵɵlistener(\"click\", function IdentityComponent_Template_button_click_2_listener() {\n            i0.ɵɵrestoreView(_r1);\n            return i0.ɵɵresetView(ctx.onClickLock());\n          });\n          i0.ɵɵelementStart(3, \"span\", 4);\n          i0.ɵɵtext(4, \"\\uD83D\\uDD12\");\n          i0.ɵɵelementEnd()();\n          i0.ɵɵtemplate(5, IdentityComponent_Conditional_5_Template, 3, 0, \"button\", 5);\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(6, \"span\");\n          i0.ɵɵtext(7, \"You\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(8, \"button\", 6);\n          i0.ɵɵlistener(\"click\", function IdentityComponent_Template_button_click_8_listener() {\n            i0.ɵɵrestoreView(_r1);\n            return i0.ɵɵresetView(ctx.onClickEditProfile());\n          });\n          i0.ɵɵelementStart(9, \"span\", 4);\n          i0.ɵɵtext(10, \"\\uD83D\\uDCDD\");\n          i0.ɵɵelementEnd()()();\n          i0.ɵɵelementStart(11, \"div\", 7)(12, \"div\", 8);\n          i0.ɵɵelement(13, \"div\", 9);\n          i0.ɵɵelementStart(14, \"div\", 10)(15, \"div\", 11);\n          i0.ɵɵelement(16, \"img\", 12);\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(17, \"div\", 13);\n          i0.ɵɵlistener(\"click\", function IdentityComponent_Template_div_click_17_listener() {\n            i0.ɵɵrestoreView(_r1);\n            return i0.ɵɵresetView(ctx.onClickShowDetails());\n          });\n          i0.ɵɵelementStart(18, \"span\", 14);\n          i0.ɵɵtext(19);\n          i0.ɵɵelementEnd();\n          i0.ɵɵtemplate(20, IdentityComponent_Conditional_20_Template, 2, 1, \"span\", 15);\n          i0.ɵɵelementEnd();\n          i0.ɵɵtemplate(21, IdentityComponent_Conditional_21_Template, 6, 4, \"div\", 16);\n          i0.ɵɵelementStart(22, \"div\", 17)(23, \"lib-pubkey\", 18);\n          i0.ɵɵlistener(\"click\", function IdentityComponent_Template_lib_pubkey_click_23_listener() {\n            i0.ɵɵrestoreView(_r1);\n            const toast_r4 = i0.ɵɵreference(26);\n            ctx.copyToClipboard(ctx.selectedIdentityNpub);\n            return i0.ɵɵresetView(toast_r4.show(\"Copied to clipboard\"));\n          });\n          i0.ɵɵelementEnd()()()()();\n          i0.ɵɵtemplate(24, IdentityComponent_Conditional_24_Template, 5, 1, \"div\", 19);\n          i0.ɵɵelement(25, \"lib-toast\", null, 0);\n        }\n        if (rf & 2) {\n          let tmp_8_0;\n          i0.ɵɵadvance(5);\n          i0.ɵɵconditional(ctx.devMode ? 5 : -1);\n          i0.ɵɵadvance(7);\n          i0.ɵɵstyleProp(\"background-image\", ctx.bannerUrl ? \"url(\" + ctx.bannerUrl + \")\" : \"none\");\n          i0.ɵɵadvance(3);\n          i0.ɵɵclassProp(\"has-image\", ctx.avatarUrl);\n          i0.ɵɵadvance();\n          i0.ɵɵproperty(\"src\", ctx.avatarUrl || \"person-fill.svg\", i0.ɵɵsanitizeUrl);\n          i0.ɵɵadvance(3);\n          i0.ɵɵtextInterpolate1(\" \", ctx.displayName || (ctx.selectedIdentity == null ? null : ctx.selectedIdentity.nick) || \"Unknown\", \" \");\n          i0.ɵɵadvance();\n          i0.ɵɵconditional(ctx.username ? 20 : -1);\n          i0.ɵɵadvance();\n          i0.ɵɵconditional((ctx.profile == null ? null : ctx.profile.nip05) ? 21 : -1);\n          i0.ɵɵadvance(2);\n          i0.ɵɵproperty(\"value\", (tmp_8_0 = ctx.selectedIdentityNpub) !== null && tmp_8_0 !== undefined ? tmp_8_0 : \"na\")(\"first\", 14)(\"last\", 8);\n          i0.ɵɵadvance();\n          i0.ɵɵconditional(ctx.aboutText ? 24 : -1);\n        }\n      },\n      dependencies: [PubkeyComponent, VisualNip05Pipe, ToastComponent],\n      styles: [\"[_nghost-%COMP%] {\\n  height: 100%;\\n  display: flex;\\n  flex-direction: column;\\n}\\n[_nghost-%COMP%]   .sam-text-header[_ngcontent-%COMP%]   .edit-btn[_ngcontent-%COMP%] {\\n  position: absolute;\\n  right: 0;\\n  background: transparent;\\n  border: none;\\n  padding: 8px;\\n  cursor: pointer;\\n  display: flex;\\n  align-items: center;\\n  justify-content: center;\\n  border-radius: 4px;\\n  transition: background-color 0.2s;\\n}\\n[_nghost-%COMP%]   .sam-text-header[_ngcontent-%COMP%]   .edit-btn[_ngcontent-%COMP%]:hover {\\n  background-color: var(--background-light);\\n}\\n[_nghost-%COMP%]   .sam-text-header[_ngcontent-%COMP%]   .edit-btn[_ngcontent-%COMP%]   .emoji[_ngcontent-%COMP%] {\\n  font-size: 20px;\\n}\\n[_nghost-%COMP%]   .identity-container[_ngcontent-%COMP%] {\\n  flex: 1;\\n  display: flex;\\n  flex-direction: column;\\n  overflow: hidden;\\n}\\n[_nghost-%COMP%]   .banner-background[_ngcontent-%COMP%] {\\n  flex: 1;\\n  display: flex;\\n  flex-direction: column;\\n  justify-content: center;\\n  align-items: center;\\n  position: relative;\\n  background-size: cover;\\n  background-position: center;\\n  background-color: var(--background-light);\\n}\\n[_nghost-%COMP%]   .banner-background[_ngcontent-%COMP%]::before {\\n  content: \\\"\\\";\\n  position: absolute;\\n  top: 0;\\n  left: 0;\\n  right: 0;\\n  bottom: 0;\\n  background: inherit;\\n  background-size: cover;\\n  background-position: center center;\\n}\\n[_nghost-%COMP%]   .banner-overlay[_ngcontent-%COMP%] {\\n  position: absolute;\\n  top: 0;\\n  left: 0;\\n  right: 0;\\n  bottom: 0;\\n  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.5) 50%, rgba(0, 0, 0, 0.3) 100%);\\n  z-index: 1;\\n}\\n[_nghost-%COMP%]   .profile-content[_ngcontent-%COMP%] {\\n  position: relative;\\n  z-index: 2;\\n  display: flex;\\n  flex-direction: column;\\n  align-items: center;\\n  gap: 12px;\\n  padding: 20px;\\n}\\n[_nghost-%COMP%]   .avatar-frame[_ngcontent-%COMP%] {\\n  height: 120px;\\n  width: 120px;\\n  border: 3px solid rgba(255, 255, 255, 0.9);\\n  border-radius: 100%;\\n  background: var(--background);\\n  padding: 12px;\\n  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);\\n}\\n[_nghost-%COMP%]   .avatar-frame.has-image[_ngcontent-%COMP%] {\\n  padding: 0;\\n}\\n[_nghost-%COMP%]   .avatar-frame[_ngcontent-%COMP%]   .avatar-image[_ngcontent-%COMP%] {\\n  border-radius: 100%;\\n  width: 100%;\\n  height: 100%;\\n  object-fit: cover;\\n}\\n[_nghost-%COMP%]   .npub-wrapper[_ngcontent-%COMP%], [_nghost-%COMP%]   .nip05-row[_ngcontent-%COMP%], [_nghost-%COMP%]   .name-badge-container[_ngcontent-%COMP%] {\\n  background-color: rgba(0, 0, 0, 0.75);\\n  padding: 6px 14px;\\n  border-radius: 6px;\\n  max-width: 300px;\\n  overflow: hidden;\\n  text-overflow: ellipsis;\\n  white-space: nowrap;\\n  backdrop-filter: blur(4px);\\n}\\n[_nghost-%COMP%]   .name-badge-container[_ngcontent-%COMP%] {\\n  display: flex;\\n  flex-direction: column;\\n  align-items: center;\\n  gap: 4px;\\n  cursor: pointer;\\n  white-space: normal;\\n  text-align: center;\\n}\\n[_nghost-%COMP%]   .name-badge-container[_ngcontent-%COMP%]:hover {\\n  background-color: rgba(0, 0, 0, 0.85);\\n}\\n[_nghost-%COMP%]   .name-badge-container[_ngcontent-%COMP%]   .display-name[_ngcontent-%COMP%] {\\n  font-family: var(--font-heading);\\n  font-size: 22px;\\n  font-weight: 700;\\n  letter-spacing: 0.05rem;\\n  color: #ffffff;\\n}\\n[_nghost-%COMP%]   .name-badge-container[_ngcontent-%COMP%]   .username[_ngcontent-%COMP%] {\\n  font-size: 13px;\\n  font-weight: 400;\\n  color: rgba(255, 255, 255, 0.85);\\n}\\n[_nghost-%COMP%]   .nip05-row[_ngcontent-%COMP%] {\\n  display: flex;\\n  flex-direction: row;\\n  align-items: center;\\n  gap: 8px;\\n}\\n[_nghost-%COMP%]   .nip05-row[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\\n  font-size: 16px;\\n}\\n[_nghost-%COMP%]   .nip05-badge[_ngcontent-%COMP%] {\\n  font-size: 13px;\\n  color: var(--primary);\\n}\\n[_nghost-%COMP%]   .npub-wrapper[_ngcontent-%COMP%] {\\n  padding: 8px 14px;\\n}\\n[_nghost-%COMP%]   .npub-wrapper[_ngcontent-%COMP%]   lib-pubkey[_ngcontent-%COMP%] {\\n  cursor: pointer;\\n}\\n[_nghost-%COMP%]   .color-activity[_ngcontent-%COMP%] {\\n  color: var(--muted-foreground);\\n  animation: _ngcontent-%COMP%_pulse 1.5s infinite;\\n}\\n@keyframes _ngcontent-%COMP%_pulse {\\n  0%, 100% {\\n    opacity: 0.4;\\n  }\\n  50% {\\n    opacity: 1;\\n  }\\n}\\n[_nghost-%COMP%]   .about-section[_ngcontent-%COMP%] {\\n  margin: var(--size);\\n  margin-top: 0;\\n  flex-shrink: 0;\\n  max-height: 150px;\\n  display: flex;\\n  flex-direction: column;\\n}\\n[_nghost-%COMP%]   .about-section[_ngcontent-%COMP%]   .about-header[_ngcontent-%COMP%] {\\n  font-size: 0.85rem;\\n  font-weight: 600;\\n  color: var(--muted-foreground);\\n  margin-bottom: var(--size-h);\\n}\\n[_nghost-%COMP%]   .about-section[_ngcontent-%COMP%]   .about-content[_ngcontent-%COMP%] {\\n  flex: 1;\\n  overflow-y: auto;\\n  font-size: 0.9rem;\\n  line-height: 1.5;\\n  color: var(--foreground);\\n  background: var(--background-light);\\n  border-radius: var(--radius-sm);\\n  padding: var(--size);\\n  white-space: pre-wrap;\\n  word-break: break-word;\\n}\"]\n    });\n  }\n  return IdentityComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}