e2e72e25449524484fc2f471b0f8e8780b66ca27dc4c111fd2c497058646abdb.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 { ActivatedRoute } from '@angular/router';\nimport { IconButtonComponent, NavComponent, NostrHelper, StorageService, ToastComponent } from '@common';\nimport { FormsModule } from '@angular/forms';\nimport * as QRCode from 'qrcode';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"@angular/forms\";\nconst _c0 = [\"passwordInput\"];\nfunction NcryptsecComponent_Conditional_4_Template(rf, ctx) {\n  if (rf & 1) {\n    const _r2 = i0.ɵɵgetCurrentView();\n    i0.ɵɵelementStart(0, \"div\", 4)(1, \"button\", 12);\n    i0.ɵɵlistener(\"click\", function NcryptsecComponent_Conditional_4_Template_button_click_1_listener() {\n      i0.ɵɵrestoreView(_r2);\n      const ctx_r2 = i0.ɵɵnextContext();\n      const toast_r4 = i0.ɵɵreference(17);\n      ctx_r2.copyToClipboard(ctx_r2.ncryptsec);\n      return i0.ɵɵresetView(toast_r4.show(\"Copied to clipboard\"));\n    });\n    i0.ɵɵelement(2, \"img\", 13);\n    i0.ɵɵelementEnd()();\n  }\n  if (rf & 2) {\n    const ctx_r2 = i0.ɵɵnextContext();\n    i0.ɵɵadvance(2);\n    i0.ɵɵproperty(\"src\", ctx_r2.ncryptsecQr, i0.ɵɵsanitizeUrl);\n  }\n}\nfunction NcryptsecComponent_Conditional_12_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelement(0, \"span\", 14);\n    i0.ɵɵtext(1, \" Generating... \");\n  }\n}\nfunction NcryptsecComponent_Conditional_13_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵtext(0, \" Generate ncryptsec \");\n  }\n}\nexport let NcryptsecComponent = /*#__PURE__*/(() => {\n  class NcryptsecComponent extends NavComponent {\n    passwordInput;\n    privkeyHex = '';\n    ncryptsecPassword = '';\n    ncryptsec = '';\n    ncryptsecQr = '';\n    isGenerating = false;\n    #activatedRoute = inject(ActivatedRoute);\n    #storage = inject(StorageService);\n    ngOnInit() {\n      const identityId = this.#activatedRoute.parent?.snapshot.params['id'];\n      if (!identityId) {\n        return;\n      }\n      this.#initialize(identityId);\n    }\n    ngAfterViewInit() {\n      this.passwordInput.nativeElement.focus();\n    }\n    generateNcryptsec() {\n      var _this = this;\n      return _asyncToGenerator(function* () {\n        if (!_this.privkeyHex || !_this.ncryptsecPassword) {\n          return;\n        }\n        _this.isGenerating = true;\n        _this.ncryptsec = '';\n        _this.ncryptsecQr = '';\n        try {\n          _this.ncryptsec = yield NostrHelper.privkeyToNcryptsec(_this.privkeyHex, _this.ncryptsecPassword);\n          // Generate QR code\n          _this.ncryptsecQr = yield QRCode.toDataURL(_this.ncryptsec, {\n            width: 250,\n            margin: 2,\n            color: {\n              dark: '#000000',\n              light: '#ffffff'\n            }\n          });\n        } catch (error) {\n          console.error('Failed to generate ncryptsec:', error);\n        } finally {\n          _this.isGenerating = false;\n        }\n      })();\n    }\n    copyToClipboard(text) {\n      navigator.clipboard.writeText(text);\n    }\n    #initialize(identityId) {\n      const identity = this.#storage.getBrowserSessionHandler().browserSessionData?.identities.find(x => x.id === identityId);\n      if (!identity) {\n        return;\n      }\n      this.privkeyHex = identity.privkey;\n    }\n    static ɵfac = /*@__PURE__*/(() => {\n      let ɵNcryptsecComponent_BaseFactory;\n      return function NcryptsecComponent_Factory(__ngFactoryType__) {\n        return (ɵNcryptsecComponent_BaseFactory || (ɵNcryptsecComponent_BaseFactory = i0.ɵɵgetInheritedFactory(NcryptsecComponent)))(__ngFactoryType__ || NcryptsecComponent);\n      };\n    })();\n    static ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n      type: NcryptsecComponent,\n      selectors: [[\"app-ncryptsec\"]],\n      viewQuery: function NcryptsecComponent_Query(rf, ctx) {\n        if (rf & 1) {\n          i0.ɵɵviewQuery(_c0, 5);\n        }\n        if (rf & 2) {\n          let _t;\n          i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.passwordInput = _t.first);\n        }\n      },\n      features: [i0.ɵɵInheritDefinitionFeature],\n      decls: 18,\n      vars: 6,\n      consts: [[\"passwordInput\", \"\"], [\"toast\", \"\"], [1, \"header-pane\"], [\"icon\", \"chevron-left\", 3, \"click\"], [1, \"qr-container\"], [1, \"password-section\"], [\"for\", \"ncryptsecPasswordInput\"], [1, \"input-group\", \"sam-mt-h\"], [\"id\", \"ncryptsecPasswordInput\", \"type\", \"password\", \"placeholder\", \"Enter encryption password\", 1, \"form-control\", 3, \"ngModelChange\", \"keyup.enter\", \"ngModel\", \"disabled\"], [\"type\", \"button\", 1, \"btn\", \"btn-primary\", \"generate-btn\", 3, \"click\", \"disabled\"], [1, \"description\"], [3, \"bottom\"], [\"type\", \"button\", \"title\", \"Copy to clipboard\", 1, \"qr-button\", 3, \"click\"], [\"alt\", \"ncryptsec QR code\", 1, \"qr-code\", 3, \"src\"], [\"role\", \"status\", 1, \"spinner-border\", \"spinner-border-sm\"]],\n      template: function NcryptsecComponent_Template(rf, ctx) {\n        if (rf & 1) {\n          const _r1 = i0.ɵɵgetCurrentView();\n          i0.ɵɵelementStart(0, \"div\", 2)(1, \"lib-icon-button\", 3);\n          i0.ɵɵlistener(\"click\", function NcryptsecComponent_Template_lib_icon_button_click_1_listener() {\n            i0.ɵɵrestoreView(_r1);\n            return i0.ɵɵresetView(ctx.navigateBack());\n          });\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(2, \"span\");\n          i0.ɵɵtext(3, \"Get ncryptsec\");\n          i0.ɵɵelementEnd()();\n          i0.ɵɵtemplate(4, NcryptsecComponent_Conditional_4_Template, 3, 1, \"div\", 4);\n          i0.ɵɵelementStart(5, \"div\", 5)(6, \"label\", 6);\n          i0.ɵɵtext(7, \"Password\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(8, \"div\", 7)(9, \"input\", 8, 0);\n          i0.ɵɵtwoWayListener(\"ngModelChange\", function NcryptsecComponent_Template_input_ngModelChange_9_listener($event) {\n            i0.ɵɵrestoreView(_r1);\n            i0.ɵɵtwoWayBindingSet(ctx.ncryptsecPassword, $event) || (ctx.ncryptsecPassword = $event);\n            return i0.ɵɵresetView($event);\n          });\n          i0.ɵɵlistener(\"keyup.enter\", function NcryptsecComponent_Template_input_keyup_enter_9_listener() {\n            i0.ɵɵrestoreView(_r1);\n            return i0.ɵɵresetView(ctx.generateNcryptsec());\n          });\n          i0.ɵɵelementEnd()()();\n          i0.ɵɵelementStart(11, \"button\", 9);\n          i0.ɵɵlistener(\"click\", function NcryptsecComponent_Template_button_click_11_listener() {\n            i0.ɵɵrestoreView(_r1);\n            return i0.ɵɵresetView(ctx.generateNcryptsec());\n          });\n          i0.ɵɵtemplate(12, NcryptsecComponent_Conditional_12_Template, 2, 0)(13, NcryptsecComponent_Conditional_13_Template, 1, 0);\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(14, \"p\", 10);\n          i0.ɵɵtext(15, \" Enter a password to encrypt your private key. The resulting ncryptsec can be used to securely backup or transfer your key.\\n\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelement(16, \"lib-toast\", 11, 1);\n        }\n        if (rf & 2) {\n          i0.ɵɵadvance(4);\n          i0.ɵɵconditional(ctx.ncryptsec ? 4 : -1);\n          i0.ɵɵadvance(5);\n          i0.ɵɵtwoWayProperty(\"ngModel\", ctx.ncryptsecPassword);\n          i0.ɵɵproperty(\"disabled\", ctx.isGenerating);\n          i0.ɵɵadvance(2);\n          i0.ɵɵproperty(\"disabled\", !ctx.ncryptsecPassword || ctx.isGenerating);\n          i0.ɵɵadvance();\n          i0.ɵɵconditional(ctx.isGenerating ? 12 : 13);\n          i0.ɵɵadvance(4);\n          i0.ɵɵproperty(\"bottom\", 16);\n        }\n      },\n      dependencies: [IconButtonComponent, FormsModule, i1.DefaultValueAccessor, i1.NgControlStatus, i1.NgModel, ToastComponent],\n      styles: [\"[_nghost-%COMP%] {\\n  height: 100%;\\n  overflow-y: auto;\\n  display: flex;\\n  flex-direction: column;\\n  padding-left: var(--size);\\n  padding-right: var(--size);\\n}\\n[_nghost-%COMP%]   .header-pane[_ngcontent-%COMP%] {\\n  display: flex;\\n  flex-direction: row;\\n  column-gap: var(--size-h);\\n  align-items: center;\\n  padding-bottom: var(--size);\\n  background-color: var(--background);\\n  position: sticky;\\n  top: 0;\\n}\\n\\n.description[_ngcontent-%COMP%] {\\n  color: var(--text-muted);\\n  font-size: 0.9rem;\\n  margin-bottom: var(--size);\\n}\\n\\n.password-section[_ngcontent-%COMP%] {\\n  margin-bottom: var(--size);\\n}\\n.password-section[_ngcontent-%COMP%]   label[_ngcontent-%COMP%] {\\n  font-weight: 500;\\n  margin-bottom: var(--size-q);\\n}\\n\\n.generate-btn[_ngcontent-%COMP%] {\\n  width: 100%;\\n  margin-bottom: var(--size);\\n}\\n\\n.qr-container[_ngcontent-%COMP%] {\\n  display: flex;\\n  justify-content: center;\\n  align-items: center;\\n  margin-bottom: var(--size);\\n}\\n\\n.qr-button[_ngcontent-%COMP%] {\\n  background: white;\\n  padding: var(--size);\\n  border-radius: 8px;\\n  border: none;\\n  cursor: pointer;\\n  transition: transform 0.15s ease, box-shadow 0.15s ease;\\n}\\n.qr-button[_ngcontent-%COMP%]:hover {\\n  transform: scale(1.02);\\n  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\\n}\\n.qr-button[_ngcontent-%COMP%]:active {\\n  transform: scale(0.98);\\n}\\n\\n.qr-code[_ngcontent-%COMP%] {\\n  width: 250px;\\n  height: 250px;\\n  display: block;\\n}\"]\n    });\n  }\n  return NcryptsecComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}