shogun-core 6.2.4 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js +93 -341
  2. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js.map +1 -1
  3. package/dist/browser/shogun-core.js +138979 -146789
  4. package/dist/browser/shogun-core.js.map +1 -1
  5. package/dist/{core.js → src/core.js} +167 -107
  6. package/dist/src/crypto/asymmetric.js +168 -0
  7. package/dist/src/crypto/double-ratchet.js +908 -0
  8. package/dist/src/crypto/file-encryption.js +352 -0
  9. package/dist/src/crypto/hashing.js +160 -0
  10. package/dist/src/crypto/index.js +18 -0
  11. package/dist/{crypto → src/crypto}/mls-codec.js +24 -34
  12. package/dist/src/crypto/mls.js +734 -0
  13. package/dist/src/crypto/pgp.js +619 -0
  14. package/dist/{crypto → src/crypto}/random-generation.js +125 -103
  15. package/dist/src/crypto/sframe.js +466 -0
  16. package/dist/src/crypto/signal-protocol.js +943 -0
  17. package/dist/src/crypto/symmetric.js +165 -0
  18. package/dist/src/crypto/utils.js +220 -0
  19. package/dist/src/examples/auth-test.js +535 -0
  20. package/dist/src/examples/crypto-identity-example.js +294 -0
  21. package/dist/src/examples/crypto-working-test.js +149 -0
  22. package/dist/src/examples/double-ratchet-test.js +240 -0
  23. package/dist/src/examples/mls-3-member-test.js +183 -0
  24. package/dist/src/examples/mls-multi-member.js +439 -0
  25. package/dist/src/examples/mls-sframe-test.js +491 -0
  26. package/dist/src/examples/mls-simple-test.js +122 -0
  27. package/dist/src/examples/pgp-example.js +354 -0
  28. package/dist/src/examples/random-generation-test.js +191 -0
  29. package/dist/src/examples/shogun-core-example.js +204 -0
  30. package/dist/src/examples/signal-protocol-test.js +82 -0
  31. package/dist/src/examples/zkproof-credentials-example.js +357 -0
  32. package/dist/src/examples/zkproof-example.js +357 -0
  33. package/dist/src/gundb/crypto.js +420 -0
  34. package/dist/src/gundb/db.js +728 -0
  35. package/dist/src/gundb/derive.js +327 -0
  36. package/dist/src/gundb/errors.js +115 -0
  37. package/dist/src/gundb/gun-es.js +8 -0
  38. package/dist/src/gundb/index.js +5 -0
  39. package/dist/{gundb → src/gundb}/rxjs.js +147 -111
  40. package/dist/{gundb → src/gundb}/types.js +1 -2
  41. package/dist/src/index.js +19 -0
  42. package/dist/src/interfaces/events.js +57 -0
  43. package/dist/{interfaces → src/interfaces}/shogun.js +4 -7
  44. package/dist/src/managers/AuthManager.js +301 -0
  45. package/dist/src/managers/CoreInitializer.js +304 -0
  46. package/dist/src/managers/CryptoIdentityManager.js +230 -0
  47. package/dist/{managers → src/managers}/EventManager.js +19 -21
  48. package/dist/{managers → src/managers}/PluginManager.js +123 -89
  49. package/dist/src/plugins/base.js +90 -0
  50. package/dist/src/plugins/index.js +17 -0
  51. package/dist/src/plugins/nostr/index.js +4 -0
  52. package/dist/src/plugins/nostr/nostrConnector.js +539 -0
  53. package/dist/src/plugins/nostr/nostrConnectorPlugin.js +663 -0
  54. package/dist/src/plugins/nostr/nostrSigner.js +414 -0
  55. package/dist/src/plugins/smartwallet/index.js +2 -0
  56. package/dist/src/plugins/smartwallet/smartWalletPlugin.js +824 -0
  57. package/dist/src/plugins/web3/index.js +4 -0
  58. package/dist/src/plugins/web3/types.js +1 -0
  59. package/dist/src/plugins/web3/web3Connector.js +738 -0
  60. package/dist/src/plugins/web3/web3ConnectorPlugin.js +639 -0
  61. package/dist/src/plugins/web3/web3Signer.js +432 -0
  62. package/dist/src/plugins/webauthn/index.js +3 -0
  63. package/dist/{plugins → src/plugins}/webauthn/types.js +2 -5
  64. package/dist/src/plugins/webauthn/webauthn.js +647 -0
  65. package/dist/src/plugins/webauthn/webauthnPlugin.js +689 -0
  66. package/dist/src/plugins/webauthn/webauthnSigner.js +419 -0
  67. package/dist/{plugins → src/plugins}/zkproof/index.js +3 -10
  68. package/dist/src/plugins/zkproof/types.js +1 -0
  69. package/dist/src/plugins/zkproof/zkCredentials.js +287 -0
  70. package/dist/src/plugins/zkproof/zkProofConnector.js +267 -0
  71. package/dist/src/plugins/zkproof/zkProofPlugin.js +405 -0
  72. package/dist/src/storage/storage.js +189 -0
  73. package/dist/src/utils/errorHandler.js +339 -0
  74. package/dist/{utils → src/utils}/eventEmitter.js +26 -26
  75. package/dist/{utils → src/utils}/seedPhrase.js +23 -32
  76. package/dist/{utils → src/utils}/validation.js +14 -21
  77. package/dist/tsconfig.tsbuildinfo +1 -0
  78. package/dist/types/{crypto → src/crypto}/double-ratchet.d.ts +1 -1
  79. package/dist/types/{crypto → src/crypto}/signal-protocol.d.ts +25 -0
  80. package/dist/types/{crypto → src/crypto}/types.d.ts +3 -1
  81. package/dist/types/src/examples/crypto-working-test.d.ts +1 -0
  82. package/dist/types/src/examples/double-ratchet-test.d.ts +1 -0
  83. package/dist/types/src/examples/mls-sframe-test.d.ts +1 -0
  84. package/dist/types/src/examples/random-generation-test.d.ts +1 -0
  85. package/dist/types/src/examples/signal-protocol-test.d.ts +1 -0
  86. package/dist/types/{gundb → src/gundb}/db.d.ts +14 -1
  87. package/dist/types/src/gundb/gun-es.d.ts +8 -0
  88. package/dist/types/src/gundb/min.d.ts +3 -0
  89. package/dist/types/{index.d.ts → src/index.d.ts} +1 -0
  90. package/package.json +14 -11
  91. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js +0 -1651
  92. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js.map +0 -1
  93. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js +0 -1608
  94. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js.map +0 -1
  95. package/dist/crypto/asymmetric.js +0 -99
  96. package/dist/crypto/double-ratchet.js +0 -392
  97. package/dist/crypto/file-encryption.js +0 -213
  98. package/dist/crypto/hashing.js +0 -87
  99. package/dist/crypto/index.js +0 -34
  100. package/dist/crypto/mls.js +0 -569
  101. package/dist/crypto/pgp.js +0 -390
  102. package/dist/crypto/sframe.js +0 -352
  103. package/dist/crypto/signal-protocol.js +0 -456
  104. package/dist/crypto/symmetric.js +0 -91
  105. package/dist/crypto/types.js +0 -2
  106. package/dist/crypto/utils.js +0 -140
  107. package/dist/examples/auth-test.js +0 -453
  108. package/dist/examples/crypto-identity-example.js +0 -196
  109. package/dist/examples/crypto-working-test.js +0 -83
  110. package/dist/examples/double-ratchet-test.js +0 -155
  111. package/dist/examples/mls-3-member-test.js +0 -97
  112. package/dist/examples/mls-multi-member.js +0 -153
  113. package/dist/examples/mls-sframe-test.js +0 -307
  114. package/dist/examples/mls-simple-test.js +0 -58
  115. package/dist/examples/pgp-example.js +0 -200
  116. package/dist/examples/random-generation-test.js +0 -151
  117. package/dist/examples/shogun-core-example.js +0 -150
  118. package/dist/examples/signal-protocol-test.js +0 -38
  119. package/dist/examples/zkproof-credentials-example.js +0 -217
  120. package/dist/examples/zkproof-example.js +0 -242
  121. package/dist/gundb/crypto.js +0 -306
  122. package/dist/gundb/db.js +0 -485
  123. package/dist/gundb/derive.js +0 -232
  124. package/dist/gundb/errors.js +0 -76
  125. package/dist/gundb/gun-es.js +0 -12
  126. package/dist/gundb/index.js +0 -21
  127. package/dist/gundb/min.js +0 -10
  128. package/dist/index.esm.js +0 -22
  129. package/dist/index.js +0 -47
  130. package/dist/interfaces/common.js +0 -2
  131. package/dist/interfaces/events.js +0 -40
  132. package/dist/interfaces/plugin.js +0 -2
  133. package/dist/managers/AuthManager.js +0 -226
  134. package/dist/managers/CoreInitializer.js +0 -250
  135. package/dist/managers/CryptoIdentityManager.js +0 -138
  136. package/dist/plugins/base.js +0 -50
  137. package/dist/plugins/index.js +0 -32
  138. package/dist/plugins/nostr/index.js +0 -20
  139. package/dist/plugins/nostr/nostrConnector.js +0 -419
  140. package/dist/plugins/nostr/nostrConnectorPlugin.js +0 -453
  141. package/dist/plugins/nostr/nostrSigner.js +0 -319
  142. package/dist/plugins/nostr/types.js +0 -2
  143. package/dist/plugins/smartwallet/index.js +0 -18
  144. package/dist/plugins/smartwallet/smartWalletPlugin.js +0 -511
  145. package/dist/plugins/smartwallet/types.js +0 -2
  146. package/dist/plugins/web3/index.js +0 -20
  147. package/dist/plugins/web3/types.js +0 -2
  148. package/dist/plugins/web3/web3Connector.js +0 -533
  149. package/dist/plugins/web3/web3ConnectorPlugin.js +0 -455
  150. package/dist/plugins/web3/web3Signer.js +0 -314
  151. package/dist/plugins/webauthn/index.js +0 -19
  152. package/dist/plugins/webauthn/webauthn.js +0 -496
  153. package/dist/plugins/webauthn/webauthnPlugin.js +0 -490
  154. package/dist/plugins/webauthn/webauthnSigner.js +0 -310
  155. package/dist/plugins/zkproof/types.js +0 -2
  156. package/dist/plugins/zkproof/zkCredentials.js +0 -216
  157. package/dist/plugins/zkproof/zkProofConnector.js +0 -198
  158. package/dist/plugins/zkproof/zkProofPlugin.js +0 -272
  159. package/dist/storage/storage.js +0 -145
  160. package/dist/types/gundb/gun-es.d.ts +0 -8
  161. package/dist/utils/errorHandler.js +0 -246
  162. /package/dist/{types/examples/crypto-working-test.d.ts → src/crypto/types.js} +0 -0
  163. /package/dist/{types/gundb/min.d.ts → src/gundb/min.js} +0 -0
  164. /package/dist/{types/examples/double-ratchet-test.d.ts → src/interfaces/common.js} +0 -0
  165. /package/dist/{types/examples/mls-sframe-test.d.ts → src/interfaces/plugin.js} +0 -0
  166. /package/dist/{types/examples/random-generation-test.d.ts → src/plugins/nostr/types.js} +0 -0
  167. /package/dist/{types/examples/signal-protocol-test.d.ts → src/plugins/smartwallet/types.js} +0 -0
  168. /package/dist/types/{core.d.ts → src/core.d.ts} +0 -0
  169. /package/dist/types/{crypto → src/crypto}/asymmetric.d.ts +0 -0
  170. /package/dist/types/{crypto → src/crypto}/file-encryption.d.ts +0 -0
  171. /package/dist/types/{crypto → src/crypto}/hashing.d.ts +0 -0
  172. /package/dist/types/{crypto → src/crypto}/index.d.ts +0 -0
  173. /package/dist/types/{crypto → src/crypto}/mls-codec.d.ts +0 -0
  174. /package/dist/types/{crypto → src/crypto}/mls.d.ts +0 -0
  175. /package/dist/types/{crypto → src/crypto}/pgp.d.ts +0 -0
  176. /package/dist/types/{crypto → src/crypto}/random-generation.d.ts +0 -0
  177. /package/dist/types/{crypto → src/crypto}/sframe.d.ts +0 -0
  178. /package/dist/types/{crypto → src/crypto}/symmetric.d.ts +0 -0
  179. /package/dist/types/{crypto → src/crypto}/utils.d.ts +0 -0
  180. /package/dist/types/{examples → src/examples}/auth-test.d.ts +0 -0
  181. /package/dist/types/{examples → src/examples}/crypto-identity-example.d.ts +0 -0
  182. /package/dist/types/{examples → src/examples}/mls-3-member-test.d.ts +0 -0
  183. /package/dist/types/{examples → src/examples}/mls-multi-member.d.ts +0 -0
  184. /package/dist/types/{examples → src/examples}/mls-simple-test.d.ts +0 -0
  185. /package/dist/types/{examples → src/examples}/pgp-example.d.ts +0 -0
  186. /package/dist/types/{examples → src/examples}/shogun-core-example.d.ts +0 -0
  187. /package/dist/types/{examples → src/examples}/zkproof-credentials-example.d.ts +0 -0
  188. /package/dist/types/{examples → src/examples}/zkproof-example.d.ts +0 -0
  189. /package/dist/types/{gundb → src/gundb}/crypto.d.ts +0 -0
  190. /package/dist/types/{gundb → src/gundb}/derive.d.ts +0 -0
  191. /package/dist/types/{gundb → src/gundb}/errors.d.ts +0 -0
  192. /package/dist/types/{gundb → src/gundb}/index.d.ts +0 -0
  193. /package/dist/types/{gundb → src/gundb}/rxjs.d.ts +0 -0
  194. /package/dist/types/{gundb → src/gundb}/types.d.ts +0 -0
  195. /package/dist/types/{interfaces → src/interfaces}/common.d.ts +0 -0
  196. /package/dist/types/{interfaces → src/interfaces}/events.d.ts +0 -0
  197. /package/dist/types/{interfaces → src/interfaces}/plugin.d.ts +0 -0
  198. /package/dist/types/{interfaces → src/interfaces}/shogun.d.ts +0 -0
  199. /package/dist/types/{managers → src/managers}/AuthManager.d.ts +0 -0
  200. /package/dist/types/{managers → src/managers}/CoreInitializer.d.ts +0 -0
  201. /package/dist/types/{managers → src/managers}/CryptoIdentityManager.d.ts +0 -0
  202. /package/dist/types/{managers → src/managers}/EventManager.d.ts +0 -0
  203. /package/dist/types/{managers → src/managers}/PluginManager.d.ts +0 -0
  204. /package/dist/types/{plugins → src/plugins}/base.d.ts +0 -0
  205. /package/dist/types/{plugins → src/plugins}/index.d.ts +0 -0
  206. /package/dist/types/{plugins → src/plugins}/nostr/index.d.ts +0 -0
  207. /package/dist/types/{plugins → src/plugins}/nostr/nostrConnector.d.ts +0 -0
  208. /package/dist/types/{plugins → src/plugins}/nostr/nostrConnectorPlugin.d.ts +0 -0
  209. /package/dist/types/{plugins → src/plugins}/nostr/nostrSigner.d.ts +0 -0
  210. /package/dist/types/{plugins → src/plugins}/nostr/types.d.ts +0 -0
  211. /package/dist/types/{plugins → src/plugins}/smartwallet/index.d.ts +0 -0
  212. /package/dist/types/{plugins → src/plugins}/smartwallet/smartWalletPlugin.d.ts +0 -0
  213. /package/dist/types/{plugins → src/plugins}/smartwallet/types.d.ts +0 -0
  214. /package/dist/types/{plugins → src/plugins}/web3/index.d.ts +0 -0
  215. /package/dist/types/{plugins → src/plugins}/web3/types.d.ts +0 -0
  216. /package/dist/types/{plugins → src/plugins}/web3/web3Connector.d.ts +0 -0
  217. /package/dist/types/{plugins → src/plugins}/web3/web3ConnectorPlugin.d.ts +0 -0
  218. /package/dist/types/{plugins → src/plugins}/web3/web3Signer.d.ts +0 -0
  219. /package/dist/types/{plugins → src/plugins}/webauthn/index.d.ts +0 -0
  220. /package/dist/types/{plugins → src/plugins}/webauthn/types.d.ts +0 -0
  221. /package/dist/types/{plugins → src/plugins}/webauthn/webauthn.d.ts +0 -0
  222. /package/dist/types/{plugins → src/plugins}/webauthn/webauthnPlugin.d.ts +0 -0
  223. /package/dist/types/{plugins → src/plugins}/webauthn/webauthnSigner.d.ts +0 -0
  224. /package/dist/types/{plugins → src/plugins}/zkproof/index.d.ts +0 -0
  225. /package/dist/types/{plugins → src/plugins}/zkproof/types.d.ts +0 -0
  226. /package/dist/types/{plugins → src/plugins}/zkproof/zkCredentials.d.ts +0 -0
  227. /package/dist/types/{plugins → src/plugins}/zkproof/zkProofConnector.d.ts +0 -0
  228. /package/dist/types/{plugins → src/plugins}/zkproof/zkProofPlugin.d.ts +0 -0
  229. /package/dist/types/{storage → src/storage}/storage.d.ts +0 -0
  230. /package/dist/types/{utils → src/utils}/errorHandler.d.ts +0 -0
  231. /package/dist/types/{utils → src/utils}/eventEmitter.d.ts +0 -0
  232. /package/dist/types/{utils → src/utils}/seedPhrase.d.ts +0 -0
  233. /package/dist/types/{utils → src/utils}/validation.d.ts +0 -0
@@ -0,0 +1,689 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
+ return new (P || (P = Promise))(function (resolve, reject) {
30
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ };
36
+ var __generator = (this && this.__generator) || function (thisArg, body) {
37
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
38
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
+ function verb(n) { return function (v) { return step([n, v]); }; }
40
+ function step(op) {
41
+ if (f) throw new TypeError("Generator is already executing.");
42
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
43
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44
+ if (y = 0, t) op = [op[0] & 2, t.value];
45
+ switch (op[0]) {
46
+ case 0: case 1: t = op; break;
47
+ case 4: _.label++; return { value: op[1], done: false };
48
+ case 5: _.label++; y = op[1]; op = [0]; continue;
49
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
50
+ default:
51
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55
+ if (t[2]) _.ops.pop();
56
+ _.trys.pop(); continue;
57
+ }
58
+ op = body.call(thisArg, _);
59
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61
+ }
62
+ };
63
+ var __read = (this && this.__read) || function (o, n) {
64
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
65
+ if (!m) return o;
66
+ var i = m.call(o), r, ar = [], e;
67
+ try {
68
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
69
+ }
70
+ catch (error) { e = { error: error }; }
71
+ finally {
72
+ try {
73
+ if (r && !r.done && (m = i["return"])) m.call(i);
74
+ }
75
+ finally { if (e) throw e.error; }
76
+ }
77
+ return ar;
78
+ };
79
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
80
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
81
+ if (ar || !(i in from)) {
82
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
83
+ ar[i] = from[i];
84
+ }
85
+ }
86
+ return to.concat(ar || Array.prototype.slice.call(from));
87
+ };
88
+ import { BasePlugin } from "../base.js";
89
+ import { Webauthn } from "./webauthn.js";
90
+ import { WebAuthnSigner } from "./webauthnSigner.js";
91
+ import { ErrorHandler, ErrorType } from "../../utils/errorHandler.js";
92
+ import { generateSeedPhrase, deriveCredentialsFromMnemonic, validateSeedPhrase, normalizeSeedPhrase, } from "../../utils/seedPhrase.js";
93
+ import { deriveWebauthnKeys } from "./webauthn.js";
94
+ /**
95
+ * Plugin per la gestione delle funzionalità WebAuthn in ShogunCore
96
+ */
97
+ var WebauthnPlugin = /** @class */ (function (_super) {
98
+ __extends(WebauthnPlugin, _super);
99
+ function WebauthnPlugin() {
100
+ var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
101
+ _this.name = "webauthn";
102
+ _this.version = "1.0.0";
103
+ _this.description = "Provides WebAuthn authentication functionality for ShogunCore";
104
+ _this.webauthn = null;
105
+ _this.signer = null;
106
+ return _this;
107
+ }
108
+ /**
109
+ * @inheritdoc
110
+ */
111
+ WebauthnPlugin.prototype.initialize = function (core) {
112
+ _super.prototype.initialize.call(this, core);
113
+ // Verifica se siamo in ambiente browser
114
+ if (typeof window === "undefined") {
115
+ console.warn("[webauthnPlugin] WebAuthn plugin disabled - not in browser environment");
116
+ return;
117
+ }
118
+ // Verifica se WebAuthn è supportato
119
+ if (!this.isSupported()) {
120
+ console.warn("[webauthnPlugin] WebAuthn not supported in this environment");
121
+ return;
122
+ }
123
+ // Inizializziamo il modulo WebAuthn
124
+ this.webauthn = new Webauthn(core.gun);
125
+ this.signer = new WebAuthnSigner(this.webauthn);
126
+ console.log("[webauthnPlugin] WebAuthn plugin initialized with signer support");
127
+ };
128
+ /**
129
+ * @inheritdoc
130
+ */
131
+ WebauthnPlugin.prototype.destroy = function () {
132
+ this.webauthn = null;
133
+ this.signer = null;
134
+ _super.prototype.destroy.call(this);
135
+ console.log("[webauthnPlugin] WebAuthn plugin destroyed");
136
+ };
137
+ /**
138
+ * Assicura che il modulo Webauthn sia inizializzato
139
+ * @private
140
+ */
141
+ WebauthnPlugin.prototype.assertWebauthn = function () {
142
+ this.assertInitialized();
143
+ if (!this.webauthn) {
144
+ throw new Error("WebAuthn module not initialized");
145
+ }
146
+ return this.webauthn;
147
+ };
148
+ /**
149
+ * Assicura che il signer sia inizializzato
150
+ * @private
151
+ */
152
+ WebauthnPlugin.prototype.assertSigner = function () {
153
+ this.assertInitialized();
154
+ if (!this.signer) {
155
+ throw new Error("WebAuthn signer not initialized");
156
+ }
157
+ return this.signer;
158
+ };
159
+ /**
160
+ * Genera un pair SEA dalle credenziali WebAuthn
161
+ * @private
162
+ */
163
+ WebauthnPlugin.prototype.generatePairFromCredentials = function (credentials) {
164
+ return __awaiter(this, void 0, void 0, function () {
165
+ var pair, error_1;
166
+ return __generator(this, function (_a) {
167
+ switch (_a.label) {
168
+ case 0:
169
+ _a.trys.push([0, 2, , 3]);
170
+ return [4 /*yield*/, this.assertSigner().createDerivedKeyPair(credentials.credentialId, credentials.username)];
171
+ case 1:
172
+ pair = _a.sent();
173
+ return [2 /*return*/, pair];
174
+ case 2:
175
+ error_1 = _a.sent();
176
+ console.error("Error generating pair from WebAuthn credentials:", error_1);
177
+ return [2 /*return*/, null];
178
+ case 3: return [2 /*return*/];
179
+ }
180
+ });
181
+ });
182
+ };
183
+ /**
184
+ * @inheritdoc
185
+ */
186
+ WebauthnPlugin.prototype.isSupported = function () {
187
+ // Verifica se siamo in ambiente browser
188
+ if (typeof window === "undefined") {
189
+ return false;
190
+ }
191
+ // Check if PublicKeyCredential is available
192
+ if (typeof window.PublicKeyCredential === "undefined") {
193
+ return false;
194
+ }
195
+ // In test environment, allow initialization if window.PublicKeyCredential is mocked
196
+ if (process.env.NODE_ENV === "test") {
197
+ return typeof window.PublicKeyCredential !== "undefined";
198
+ }
199
+ // Se il plugin non è stato inizializzato, verifica direttamente il supporto
200
+ if (!this.webauthn) {
201
+ return typeof window.PublicKeyCredential !== "undefined";
202
+ }
203
+ return this.webauthn.isSupported();
204
+ };
205
+ /**
206
+ * @inheritdoc
207
+ */
208
+ WebauthnPlugin.prototype.generateCredentials = function (username_1, existingCredential_1) {
209
+ return __awaiter(this, arguments, void 0, function (username, existingCredential, isLogin) {
210
+ if (isLogin === void 0) { isLogin = false; }
211
+ return __generator(this, function (_a) {
212
+ return [2 /*return*/, this.assertWebauthn().generateCredentials(username, existingCredential, isLogin)];
213
+ });
214
+ });
215
+ };
216
+ /**
217
+ * @inheritdoc
218
+ */
219
+ WebauthnPlugin.prototype.createAccount = function (username_1, credentials_1) {
220
+ return __awaiter(this, arguments, void 0, function (username, credentials, isNewDevice) {
221
+ if (isNewDevice === void 0) { isNewDevice = false; }
222
+ return __generator(this, function (_a) {
223
+ return [2 /*return*/, this.assertWebauthn().createAccount(username, credentials, isNewDevice)];
224
+ });
225
+ });
226
+ };
227
+ /**
228
+ * @inheritdoc
229
+ */
230
+ WebauthnPlugin.prototype.authenticateUser = function (username, salt, options) {
231
+ return __awaiter(this, void 0, void 0, function () {
232
+ return __generator(this, function (_a) {
233
+ return [2 /*return*/, this.assertWebauthn().authenticateUser(username, salt, options)];
234
+ });
235
+ });
236
+ };
237
+ /**
238
+ * @inheritdoc
239
+ */
240
+ WebauthnPlugin.prototype.abortAuthentication = function () {
241
+ this.assertWebauthn().abortAuthentication();
242
+ };
243
+ /**
244
+ * @inheritdoc
245
+ */
246
+ WebauthnPlugin.prototype.removeDevice = function (username, credentialId, credentials) {
247
+ return __awaiter(this, void 0, void 0, function () {
248
+ return __generator(this, function (_a) {
249
+ return [2 /*return*/, this.assertWebauthn().removeDevice(username, credentialId, credentials)];
250
+ });
251
+ });
252
+ };
253
+ /**
254
+ * @inheritdoc
255
+ */
256
+ WebauthnPlugin.prototype.createSigningCredential = function (username) {
257
+ return __awaiter(this, void 0, void 0, function () {
258
+ var wa, error_2;
259
+ return __generator(this, function (_a) {
260
+ switch (_a.label) {
261
+ case 0:
262
+ _a.trys.push([0, 4, , 5]);
263
+ wa = this.assertWebauthn();
264
+ if (!(typeof wa.createSigningCredential === "function")) return [3 /*break*/, 2];
265
+ return [4 /*yield*/, wa.createSigningCredential(username)];
266
+ case 1: return [2 /*return*/, _a.sent()];
267
+ case 2: return [4 /*yield*/, this.assertSigner().createSigningCredential(username)];
268
+ case 3:
269
+ // Fallback to signer implementation if available
270
+ return [2 /*return*/, _a.sent()];
271
+ case 4:
272
+ error_2 = _a.sent();
273
+ console.error("Error creating signing credential: ".concat(error_2.message));
274
+ throw error_2;
275
+ case 5: return [2 /*return*/];
276
+ }
277
+ });
278
+ });
279
+ };
280
+ /**
281
+ * @inheritdoc
282
+ */
283
+ WebauthnPlugin.prototype.createAuthenticator = function (credentialId) {
284
+ try {
285
+ var wa = this.assertWebauthn();
286
+ if (typeof wa.createAuthenticator === "function") {
287
+ return wa.createAuthenticator(credentialId);
288
+ }
289
+ return this.assertSigner().createAuthenticator(credentialId);
290
+ }
291
+ catch (error) {
292
+ console.error("Error creating authenticator: ".concat(error.message));
293
+ throw error;
294
+ }
295
+ };
296
+ /**
297
+ * @inheritdoc
298
+ */
299
+ WebauthnPlugin.prototype.createDerivedKeyPair = function (credentialId, username, extra) {
300
+ return __awaiter(this, void 0, void 0, function () {
301
+ var wa, error_3;
302
+ return __generator(this, function (_a) {
303
+ switch (_a.label) {
304
+ case 0:
305
+ _a.trys.push([0, 4, , 5]);
306
+ wa = this.assertWebauthn();
307
+ if (!(typeof wa.createDerivedKeyPair === "function")) return [3 /*break*/, 2];
308
+ return [4 /*yield*/, wa.createDerivedKeyPair(credentialId, username, extra)];
309
+ case 1: return [2 /*return*/, _a.sent()];
310
+ case 2: return [4 /*yield*/, this.assertSigner().createDerivedKeyPair(credentialId, username, extra)];
311
+ case 3: return [2 /*return*/, _a.sent()];
312
+ case 4:
313
+ error_3 = _a.sent();
314
+ console.error("Error creating derived key pair: ".concat(error_3.message));
315
+ throw error_3;
316
+ case 5: return [2 /*return*/];
317
+ }
318
+ });
319
+ });
320
+ };
321
+ /**
322
+ * @inheritdoc
323
+ */
324
+ WebauthnPlugin.prototype.signWithDerivedKeys = function (data, credentialId, username, extra) {
325
+ return __awaiter(this, void 0, void 0, function () {
326
+ var wa, error_4;
327
+ return __generator(this, function (_a) {
328
+ switch (_a.label) {
329
+ case 0:
330
+ _a.trys.push([0, 4, , 5]);
331
+ wa = this.assertWebauthn();
332
+ if (!(typeof wa.signWithDerivedKeys === "function")) return [3 /*break*/, 2];
333
+ return [4 /*yield*/, wa.signWithDerivedKeys(data, credentialId, username, extra)];
334
+ case 1: return [2 /*return*/, _a.sent()];
335
+ case 2: return [4 /*yield*/, this.assertSigner().signWithDerivedKeys(data, credentialId, username, extra)];
336
+ case 3: return [2 /*return*/, _a.sent()];
337
+ case 4:
338
+ error_4 = _a.sent();
339
+ console.error("Error signing with derived keys: ".concat(error_4.message));
340
+ throw error_4;
341
+ case 5: return [2 /*return*/];
342
+ }
343
+ });
344
+ });
345
+ };
346
+ /**
347
+ * @inheritdoc
348
+ */
349
+ WebauthnPlugin.prototype.getSigningCredential = function (credentialId) {
350
+ var wa = this.assertWebauthn();
351
+ if (typeof wa.getSigningCredential === "function") {
352
+ return wa.getSigningCredential(credentialId);
353
+ }
354
+ return this.assertSigner().getCredential(credentialId);
355
+ };
356
+ /**
357
+ * @inheritdoc
358
+ */
359
+ WebauthnPlugin.prototype.listSigningCredentials = function () {
360
+ var wa = this.assertWebauthn();
361
+ if (typeof wa.listSigningCredentials === "function") {
362
+ return wa.listSigningCredentials();
363
+ }
364
+ return this.assertSigner().listCredentials();
365
+ };
366
+ /**
367
+ * @inheritdoc
368
+ */
369
+ WebauthnPlugin.prototype.removeSigningCredential = function (credentialId) {
370
+ var wa = this.assertWebauthn();
371
+ if (typeof wa.removeSigningCredential === "function") {
372
+ return wa.removeSigningCredential(credentialId);
373
+ }
374
+ return this.assertSigner().removeCredential(credentialId);
375
+ };
376
+ // === CONSISTENCY METHODS ===
377
+ /**
378
+ * Creates a Gun user from WebAuthn signing credential
379
+ * This ensures the SAME user is created as with normal approach
380
+ */
381
+ WebauthnPlugin.prototype.createGunUserFromSigningCredential = function (credentialId, username) {
382
+ return __awaiter(this, void 0, void 0, function () {
383
+ var wa, core, error_5;
384
+ return __generator(this, function (_a) {
385
+ switch (_a.label) {
386
+ case 0:
387
+ _a.trys.push([0, 4, , 5]);
388
+ wa = this.assertWebauthn();
389
+ if (!(typeof wa.createGunUserFromSigningCredential === "function")) return [3 /*break*/, 2];
390
+ return [4 /*yield*/, wa.createGunUserFromSigningCredential(credentialId, username)];
391
+ case 1: return [2 /*return*/, _a.sent()];
392
+ case 2:
393
+ core = this.assertInitialized();
394
+ return [4 /*yield*/, this.assertSigner().createGunUser(credentialId, username, core.gun)];
395
+ case 3: return [2 /*return*/, _a.sent()];
396
+ case 4:
397
+ error_5 = _a.sent();
398
+ console.error("Error creating Gun user from signing credential: ".concat(error_5.message));
399
+ throw error_5;
400
+ case 5: return [2 /*return*/];
401
+ }
402
+ });
403
+ });
404
+ };
405
+ /**
406
+ * Get the Gun user public key for a signing credential
407
+ */
408
+ WebauthnPlugin.prototype.getGunUserPubFromSigningCredential = function (credentialId) {
409
+ var wa = this.assertWebauthn();
410
+ if (typeof wa.getGunUserPubFromSigningCredential === "function") {
411
+ return wa.getGunUserPubFromSigningCredential(credentialId);
412
+ }
413
+ return this.assertSigner().getGunUserPub(credentialId);
414
+ };
415
+ /**
416
+ * Get the hashed credential ID (for consistency checking)
417
+ */
418
+ WebauthnPlugin.prototype.getHashedCredentialId = function (credentialId) {
419
+ var wa = this.assertWebauthn();
420
+ if (typeof wa.getHashedCredentialId === "function") {
421
+ return wa.getHashedCredentialId(credentialId);
422
+ }
423
+ return this.assertSigner().getHashedCredentialId(credentialId);
424
+ };
425
+ /**
426
+ * Verify consistency between oneshot and normal approaches
427
+ * This ensures both approaches create the same Gun user
428
+ */
429
+ WebauthnPlugin.prototype.verifyConsistency = function (credentialId, username, expectedUserPub) {
430
+ return __awaiter(this, void 0, void 0, function () {
431
+ var wa, error_6;
432
+ return __generator(this, function (_a) {
433
+ switch (_a.label) {
434
+ case 0:
435
+ _a.trys.push([0, 4, , 5]);
436
+ wa = this.assertWebauthn();
437
+ if (!(typeof wa.verifyConsistency === "function")) return [3 /*break*/, 2];
438
+ return [4 /*yield*/, wa.verifyConsistency(credentialId, username, expectedUserPub)];
439
+ case 1: return [2 /*return*/, _a.sent()];
440
+ case 2: return [4 /*yield*/, this.assertSigner().verifyConsistency(credentialId, username, expectedUserPub)];
441
+ case 3: return [2 /*return*/, _a.sent()];
442
+ case 4:
443
+ error_6 = _a.sent();
444
+ console.error("Error verifying consistency: ".concat(error_6.message));
445
+ return [2 /*return*/, { consistent: false }];
446
+ case 5: return [2 /*return*/];
447
+ }
448
+ });
449
+ });
450
+ };
451
+ /**
452
+ * Complete oneshot workflow that creates the SAME Gun user as normal approach
453
+ * This is the recommended method for oneshot signing with full consistency
454
+ */
455
+ WebauthnPlugin.prototype.setupConsistentOneshotSigning = function (username) {
456
+ return __awaiter(this, void 0, void 0, function () {
457
+ var wa, credential, authenticator, gunUser, error_7;
458
+ return __generator(this, function (_a) {
459
+ switch (_a.label) {
460
+ case 0:
461
+ _a.trys.push([0, 5, , 6]);
462
+ wa = this.assertWebauthn();
463
+ if (!(typeof wa.setupConsistentOneshotSigning === "function")) return [3 /*break*/, 2];
464
+ return [4 /*yield*/, wa.setupConsistentOneshotSigning(username)];
465
+ case 1: return [2 /*return*/, _a.sent()];
466
+ case 2: return [4 /*yield*/, this.createSigningCredential(username)];
467
+ case 3:
468
+ credential = _a.sent();
469
+ authenticator = this.createAuthenticator(credential.id);
470
+ return [4 /*yield*/, this.createGunUserFromSigningCredential(credential.id, username)];
471
+ case 4:
472
+ gunUser = _a.sent();
473
+ return [2 /*return*/, {
474
+ credential: credential,
475
+ authenticator: authenticator,
476
+ gunUser: gunUser,
477
+ pub: credential.pub,
478
+ hashedCredentialId: credential.hashedCredentialId,
479
+ }];
480
+ case 5:
481
+ error_7 = _a.sent();
482
+ console.error("Error setting up consistent oneshot signing: ".concat(error_7.message));
483
+ throw error_7;
484
+ case 6: return [2 /*return*/];
485
+ }
486
+ });
487
+ });
488
+ };
489
+ /**
490
+ * Login with WebAuthn
491
+ * This is the recommended method for WebAuthn authentication
492
+ * @param username - Username
493
+ * @returns {Promise<AuthResult>} Authentication result
494
+ * @description Authenticates user using WebAuthn credentials.
495
+ * Requires browser support for WebAuthn and existing credentials.
496
+ */
497
+ WebauthnPlugin.prototype.login = function (username) {
498
+ return __awaiter(this, void 0, void 0, function () {
499
+ var core, _a, authenticator, pub, credentials, error_8;
500
+ return __generator(this, function (_b) {
501
+ switch (_b.label) {
502
+ case 0:
503
+ _b.trys.push([0, 6, , 7]);
504
+ core = this.assertInitialized();
505
+ if (!username) {
506
+ throw new Error("Username required for WebAuthn login");
507
+ }
508
+ if (!this.isSupported()) {
509
+ throw new Error("WebAuthn is not supported by this browser");
510
+ }
511
+ return [4 /*yield*/, this.setupConsistentOneshotSigning(username)];
512
+ case 1:
513
+ _a = (_b.sent()), authenticator = _a.authenticator, pub = _a.pub;
514
+ if (!core.authenticate) return [3 /*break*/, 3];
515
+ return [4 /*yield*/, core.authenticate(username, authenticator, pub)];
516
+ case 2: return [2 /*return*/, _b.sent()];
517
+ case 3: return [4 /*yield*/, this.generateCredentials(username, null, true)];
518
+ case 4:
519
+ credentials = _b.sent();
520
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.success)) {
521
+ throw new Error((credentials === null || credentials === void 0 ? void 0 : credentials.error) || "WebAuthn verification failed");
522
+ }
523
+ core.setAuthMethod("webauthn");
524
+ return [4 /*yield*/, core.login(username, "", credentials.key)];
525
+ case 5: return [2 /*return*/, _b.sent()];
526
+ case 6:
527
+ error_8 = _b.sent();
528
+ console.error("Error during WebAuthn login: ".concat(error_8));
529
+ // Log but do not depend on handler return value
530
+ ErrorHandler.handle(ErrorType.WEBAUTHN, "WEBAUTHN_LOGIN_ERROR", error_8.message || "Error during WebAuthn login", error_8);
531
+ return [2 /*return*/, {
532
+ success: false,
533
+ error: error_8.message || "Error during WebAuthn login",
534
+ }];
535
+ case 7: return [2 /*return*/];
536
+ }
537
+ });
538
+ });
539
+ };
540
+ /**
541
+ * Register new user with WebAuthn
542
+ * This is the recommended method for WebAuthn registration
543
+ * @param username - Username
544
+ * @param options - Optional signup options (seed phrase support)
545
+ * @returns {Promise<SignUpResult>} Registration result with optional seed phrase
546
+ * @description Creates a new user account using WebAuthn credentials.
547
+ * Requires browser support for WebAuthn.
548
+ * If generateSeedPhrase is true, returns a BIP39 mnemonic for multi-device support.
549
+ */
550
+ WebauthnPlugin.prototype.signUp = function (username, options) {
551
+ return __awaiter(this, void 0, void 0, function () {
552
+ var core, seedPhrase, shouldGenerateSeed, pair, password, derivedKeys, credentials, result, error_9;
553
+ return __generator(this, function (_a) {
554
+ switch (_a.label) {
555
+ case 0:
556
+ _a.trys.push([0, 6, , 7]);
557
+ core = this.assertInitialized();
558
+ if (!username) {
559
+ throw new Error("Username required for WebAuthn registration");
560
+ }
561
+ if (!this.isSupported()) {
562
+ throw new Error("WebAuthn is not supported by this browser");
563
+ }
564
+ seedPhrase = void 0;
565
+ shouldGenerateSeed = (options === null || options === void 0 ? void 0 : options.generateSeedPhrase) !== false;
566
+ if (options === null || options === void 0 ? void 0 : options.seedPhrase) {
567
+ // Use provided seed phrase
568
+ if (!validateSeedPhrase(options.seedPhrase)) {
569
+ throw new Error("Invalid seed phrase provided");
570
+ }
571
+ seedPhrase = options.seedPhrase;
572
+ }
573
+ else if (shouldGenerateSeed) {
574
+ // Generate new seed phrase for multi-device support
575
+ seedPhrase = generateSeedPhrase();
576
+ console.log("[webauthnPlugin] Generated seed phrase for multi-device support");
577
+ }
578
+ pair = void 0;
579
+ if (!seedPhrase) return [3 /*break*/, 2];
580
+ password = deriveCredentialsFromMnemonic(seedPhrase, username).password;
581
+ return [4 /*yield*/, deriveWebauthnKeys(username, seedPhrase, true)];
582
+ case 1:
583
+ derivedKeys = _a.sent();
584
+ pair = {
585
+ pub: derivedKeys.pub,
586
+ priv: derivedKeys.priv,
587
+ epub: derivedKeys.epub,
588
+ epriv: derivedKeys.epriv,
589
+ };
590
+ return [3 /*break*/, 4];
591
+ case 2: return [4 /*yield*/, this.generateCredentials(username, null, false)];
592
+ case 3:
593
+ credentials = _a.sent();
594
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.success)) {
595
+ throw new Error((credentials === null || credentials === void 0 ? void 0 : credentials.error) || "Unable to generate WebAuthn credentials");
596
+ }
597
+ // Use the key directly from credentials instead of calling generatePairFromCredentials
598
+ // since generateCredentials already returns the derived key pair
599
+ if (!credentials.key) {
600
+ throw new Error("Failed to generate SEA pair from WebAuthn credentials");
601
+ }
602
+ pair = credentials.key;
603
+ _a.label = 4;
604
+ case 4:
605
+ core.setAuthMethod("webauthn");
606
+ return [4 /*yield*/, core.signUp(username, undefined, pair)];
607
+ case 5:
608
+ result = _a.sent();
609
+ // Add seed phrase to result if generated
610
+ if (seedPhrase && shouldGenerateSeed) {
611
+ return [2 /*return*/, __assign(__assign({}, result), { message: seedPhrase
612
+ ? "🔑 IMPORTANT: Save your 12-word seed phrase to access your account from other devices!"
613
+ : result.message, seedPhrase: seedPhrase })];
614
+ }
615
+ return [2 /*return*/, result];
616
+ case 6:
617
+ error_9 = _a.sent();
618
+ console.error("Error during WebAuthn registration: ".concat(error_9));
619
+ ErrorHandler.handle(ErrorType.WEBAUTHN, "WEBAUTHN_SIGNUP_ERROR", error_9.message || "Error during WebAuthn registration", error_9);
620
+ return [2 /*return*/, {
621
+ success: false,
622
+ error: error_9.message || "Error during WebAuthn registration",
623
+ }];
624
+ case 7: return [2 /*return*/];
625
+ }
626
+ });
627
+ });
628
+ };
629
+ /**
630
+ * Import existing account from seed phrase
631
+ * Allows accessing the same account across multiple devices
632
+ * @param username - Username
633
+ * @param seedPhrase - 12-word BIP39 mnemonic seed phrase
634
+ * @returns {Promise<SignUpResult>} Registration result
635
+ */
636
+ WebauthnPlugin.prototype.importFromSeed = function (username, seedPhrase) {
637
+ return __awaiter(this, void 0, void 0, function () {
638
+ var normalizedSeed, error_10;
639
+ return __generator(this, function (_a) {
640
+ switch (_a.label) {
641
+ case 0:
642
+ _a.trys.push([0, 2, , 3]);
643
+ if (!username) {
644
+ throw new Error("Username required");
645
+ }
646
+ normalizedSeed = normalizeSeedPhrase(seedPhrase);
647
+ if (!validateSeedPhrase(normalizedSeed)) {
648
+ throw new Error("Invalid seed phrase. Please check and try again.");
649
+ }
650
+ console.log("[webauthnPlugin] Importing account from seed phrase");
651
+ return [4 /*yield*/, this.signUp(username, {
652
+ seedPhrase: normalizedSeed,
653
+ generateSeedPhrase: false, // Don't generate new seed
654
+ })];
655
+ case 1:
656
+ // Use signUp with existing seed phrase
657
+ return [2 /*return*/, _a.sent()];
658
+ case 2:
659
+ error_10 = _a.sent();
660
+ console.error("Error importing from seed: ".concat(error_10.message));
661
+ ErrorHandler.handle(ErrorType.WEBAUTHN, "WEBAUTHN_IMPORT_ERROR", error_10.message || "Error importing from seed phrase", error_10);
662
+ return [2 /*return*/, {
663
+ success: false,
664
+ error: error_10.message || "Error importing from seed phrase",
665
+ }];
666
+ case 3: return [2 /*return*/];
667
+ }
668
+ });
669
+ });
670
+ };
671
+ /**
672
+ * Get seed phrase for current user (if stored)
673
+ * Note: Seed phrases are NOT stored by default for security
674
+ * Users should save their seed phrase during registration
675
+ * @param username - Username
676
+ * @returns {Promise<string | null>} Seed phrase or null
677
+ */
678
+ WebauthnPlugin.prototype.getSeedPhrase = function (username) {
679
+ return __awaiter(this, void 0, void 0, function () {
680
+ return __generator(this, function (_a) {
681
+ console.warn("[webauthnPlugin] Seed phrases are not stored for security reasons");
682
+ console.warn("[webauthnPlugin] Users must save their seed phrase during registration");
683
+ return [2 /*return*/, null];
684
+ });
685
+ });
686
+ };
687
+ return WebauthnPlugin;
688
+ }(BasePlugin));
689
+ export { WebauthnPlugin };