@sphereon/ssi-sdk-ext.mnemonic-seed-manager 0.28.1-feature.oyd.cmsm.improv.20 → 0.28.1-next.53

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 (45) hide show
  1. package/dist/index.cjs +746 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/{types/IMnemonicSeedManager.d.ts → index.d.cts} +73 -14
  4. package/dist/index.d.ts +169 -9
  5. package/dist/index.js +716 -37
  6. package/dist/index.js.map +1 -1
  7. package/package.json +27 -12
  8. package/src/entities/MnemonicEntity.ts +10 -15
  9. package/src/index.ts +1 -0
  10. package/dist/agent/MnemonicSeedManager.d.ts +0 -26
  11. package/dist/agent/MnemonicSeedManager.d.ts.map +0 -1
  12. package/dist/agent/MnemonicSeedManager.js +0 -209
  13. package/dist/agent/MnemonicSeedManager.js.map +0 -1
  14. package/dist/entities/MnemonicEntity.d.ts +0 -9
  15. package/dist/entities/MnemonicEntity.d.ts.map +0 -1
  16. package/dist/entities/MnemonicEntity.js +0 -50
  17. package/dist/entities/MnemonicEntity.js.map +0 -1
  18. package/dist/index.d.ts.map +0 -1
  19. package/dist/migrations/generic/1-CreateMnemonics.d.ts +0 -7
  20. package/dist/migrations/generic/1-CreateMnemonics.d.ts.map +0 -1
  21. package/dist/migrations/generic/1-CreateMnemonics.js +0 -72
  22. package/dist/migrations/generic/1-CreateMnemonics.js.map +0 -1
  23. package/dist/migrations/generic/index.d.ts +0 -10
  24. package/dist/migrations/generic/index.d.ts.map +0 -1
  25. package/dist/migrations/generic/index.js +0 -13
  26. package/dist/migrations/generic/index.js.map +0 -1
  27. package/dist/migrations/index.d.ts +0 -2
  28. package/dist/migrations/index.d.ts.map +0 -1
  29. package/dist/migrations/index.js +0 -6
  30. package/dist/migrations/index.js.map +0 -1
  31. package/dist/migrations/internal-migrations-ormconfig.d.ts +0 -7
  32. package/dist/migrations/internal-migrations-ormconfig.d.ts.map +0 -1
  33. package/dist/migrations/internal-migrations-ormconfig.js +0 -29
  34. package/dist/migrations/internal-migrations-ormconfig.js.map +0 -1
  35. package/dist/migrations/postgres/1659566636105-CreateMnemonics.d.ts +0 -7
  36. package/dist/migrations/postgres/1659566636105-CreateMnemonics.d.ts.map +0 -1
  37. package/dist/migrations/postgres/1659566636105-CreateMnemonics.js +0 -29
  38. package/dist/migrations/postgres/1659566636105-CreateMnemonics.js.map +0 -1
  39. package/dist/migrations/sqlite/1659566622817-CreateMnemonics.d.ts +0 -7
  40. package/dist/migrations/sqlite/1659566622817-CreateMnemonics.d.ts.map +0 -1
  41. package/dist/migrations/sqlite/1659566622817-CreateMnemonics.js +0 -29
  42. package/dist/migrations/sqlite/1659566622817-CreateMnemonics.js.map +0 -1
  43. package/dist/types/IMnemonicSeedManager.d.ts.map +0 -1
  44. package/dist/types/IMnemonicSeedManager.js +0 -3
  45. package/dist/types/IMnemonicSeedManager.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,39 +1,718 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __commonJS = (cb, mod) => function __require() {
5
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
+ };
7
+
8
+ // plugin.schema.json
9
+ var require_plugin_schema = __commonJS({
10
+ "plugin.schema.json"(exports, module) {
11
+ module.exports = {
12
+ IMnemonicSeedManager: {
13
+ components: {
14
+ schemas: {
15
+ IMnemonicInfoStoreArgs: {
16
+ type: "object",
17
+ properties: {
18
+ id: {
19
+ type: "string"
20
+ },
21
+ hash: {
22
+ type: "string"
23
+ },
24
+ mnemonic: {
25
+ type: "array",
26
+ items: {
27
+ type: "string"
28
+ }
29
+ },
30
+ masterKey: {
31
+ type: "string"
32
+ },
33
+ chainCode: {
34
+ type: "string"
35
+ },
36
+ kms: {
37
+ type: "string"
38
+ },
39
+ path: {
40
+ type: "string"
41
+ },
42
+ withZeroBytes: {
43
+ type: "boolean"
44
+ },
45
+ type: {
46
+ type: "string",
47
+ enum: [
48
+ "Ed25519",
49
+ "Secp256k1"
50
+ ]
51
+ },
52
+ persist: {
53
+ type: "boolean"
54
+ }
55
+ }
56
+ },
57
+ DeleteResult: {
58
+ type: "object",
59
+ properties: {
60
+ raw: {},
61
+ affected: {
62
+ type: [
63
+ "number",
64
+ "null"
65
+ ]
66
+ }
67
+ },
68
+ required: [
69
+ "raw"
70
+ ]
71
+ },
72
+ ManagedKeyInfo: {
73
+ type: "object",
74
+ properties: {
75
+ kid: {
76
+ type: "string",
77
+ description: "Key ID"
78
+ },
79
+ kms: {
80
+ type: "string",
81
+ description: "Key Management System"
82
+ },
83
+ type: {
84
+ $ref: "#/components/schemas/TKeyType",
85
+ description: "Key type"
86
+ },
87
+ publicKeyHex: {
88
+ type: "string",
89
+ description: "Public key"
90
+ },
91
+ meta: {
92
+ anyOf: [
93
+ {
94
+ $ref: "#/components/schemas/KeyMetadata"
95
+ },
96
+ {
97
+ type: "null"
98
+ }
99
+ ],
100
+ description: "Optional. Key metadata. This should be used to determine which algorithms are supported."
101
+ }
102
+ },
103
+ required: [
104
+ "kid",
105
+ "kms",
106
+ "type",
107
+ "publicKeyHex"
108
+ ],
109
+ description: "Represents information about a managed key. Private or secret key material is NOT present."
110
+ },
111
+ TKeyType: {
112
+ type: "string",
113
+ enum: [
114
+ "Ed25519",
115
+ "Secp256k1",
116
+ "Secp256r1",
117
+ "X25519",
118
+ "Bls12381G1",
119
+ "Bls12381G2",
120
+ "RSA"
121
+ ],
122
+ description: "Cryptographic key type."
123
+ },
124
+ KeyMetadata: {
125
+ type: "object",
126
+ properties: {
127
+ algorithms: {
128
+ type: "array",
129
+ items: {
130
+ type: "string"
131
+ }
132
+ }
133
+ },
134
+ description: "This encapsulates data about a key.\n\nImplementations of {@link @veramo/key-manager#AbstractKeyManagementSystem | AbstractKeyManagementSystem } should populate this object, for each key, with the algorithms that can be performed using it.\n\nThis can also be used to add various tags to the keys under management."
135
+ },
136
+ IMnemonicInfoKeyResult: {
137
+ type: "object",
138
+ properties: {
139
+ masterKey: {
140
+ type: "string"
141
+ },
142
+ chainCode: {
143
+ type: "string"
144
+ }
145
+ }
146
+ },
147
+ IMnemonicGeneratorArgs: {
148
+ type: "object",
149
+ properties: {
150
+ bits: {
151
+ type: "number",
152
+ enum: [
153
+ 128,
154
+ 160,
155
+ 192,
156
+ 224,
157
+ 256
158
+ ]
159
+ },
160
+ id: {
161
+ type: "string"
162
+ },
163
+ persist: {
164
+ type: "boolean"
165
+ }
166
+ },
167
+ required: [
168
+ "bits"
169
+ ]
170
+ },
171
+ IMnemonicInfoResult: {
172
+ type: "object",
173
+ properties: {
174
+ id: {
175
+ type: "string"
176
+ },
177
+ hash: {
178
+ type: "string"
179
+ },
180
+ mnemonic: {
181
+ type: "array",
182
+ items: {
183
+ type: "string"
184
+ }
185
+ },
186
+ masterKey: {
187
+ type: "string"
188
+ },
189
+ chainCode: {
190
+ type: "string"
191
+ },
192
+ kms: {
193
+ type: "string"
194
+ },
195
+ path: {
196
+ type: "string"
197
+ },
198
+ withZeroBytes: {
199
+ type: "boolean"
200
+ },
201
+ type: {
202
+ type: "string",
203
+ enum: [
204
+ "Ed25519",
205
+ "Secp256k1"
206
+ ]
207
+ },
208
+ persist: {
209
+ type: "boolean"
210
+ },
211
+ succeeded: {
212
+ type: "boolean"
213
+ },
214
+ seed: {
215
+ type: "string"
216
+ }
217
+ }
218
+ },
219
+ ISeedGeneratorArgs: {
220
+ type: "object",
221
+ properties: {
222
+ mnemonic: {
223
+ type: "array",
224
+ items: {
225
+ type: "string"
226
+ }
227
+ }
228
+ },
229
+ required: [
230
+ "mnemonic"
231
+ ]
232
+ },
233
+ IMnemonicVerificationArgs: {
234
+ type: "object",
235
+ properties: {
236
+ id: {
237
+ type: "string"
238
+ },
239
+ hash: {
240
+ type: "string"
241
+ },
242
+ wordList: {
243
+ type: "array",
244
+ items: {
245
+ type: "string"
246
+ }
247
+ }
248
+ },
249
+ required: [
250
+ "wordList"
251
+ ]
252
+ },
253
+ IPartialMnemonicVerificationArgs: {
254
+ type: "object",
255
+ properties: {
256
+ id: {
257
+ type: "string"
258
+ },
259
+ hash: {
260
+ type: "string"
261
+ },
262
+ indexedWordList: {
263
+ type: "array",
264
+ items: {
265
+ type: "array",
266
+ minItems: 2,
267
+ items: [
268
+ {
269
+ type: "number"
270
+ },
271
+ {
272
+ type: "string"
273
+ }
274
+ ],
275
+ maxItems: 2
276
+ }
277
+ }
278
+ },
279
+ required: [
280
+ "indexedWordList"
281
+ ]
282
+ }
283
+ },
284
+ methods: {
285
+ deleteMnemonicInfo: {
286
+ description: "",
287
+ arguments: {
288
+ $ref: "#/components/schemas/IMnemonicInfoStoreArgs"
289
+ },
290
+ returnType: {
291
+ $ref: "#/components/schemas/DeleteResult"
292
+ }
293
+ },
294
+ generateKeysFromMnemonic: {
295
+ description: "",
296
+ arguments: {
297
+ $ref: "#/components/schemas/IMnemonicInfoStoreArgs"
298
+ },
299
+ returnType: {
300
+ $ref: "#/components/schemas/ManagedKeyInfo"
301
+ }
302
+ },
303
+ generateMasterKey: {
304
+ description: "",
305
+ arguments: {
306
+ $ref: "#/components/schemas/IMnemonicInfoStoreArgs"
307
+ },
308
+ returnType: {
309
+ $ref: "#/components/schemas/IMnemonicInfoKeyResult"
310
+ }
311
+ },
312
+ generateMnemonic: {
313
+ description: "",
314
+ arguments: {
315
+ $ref: "#/components/schemas/IMnemonicGeneratorArgs"
316
+ },
317
+ returnType: {
318
+ $ref: "#/components/schemas/IMnemonicInfoResult"
319
+ }
320
+ },
321
+ generateSeed: {
322
+ description: "",
323
+ arguments: {
324
+ $ref: "#/components/schemas/ISeedGeneratorArgs"
325
+ },
326
+ returnType: {
327
+ $ref: "#/components/schemas/IMnemonicInfoResult"
328
+ }
329
+ },
330
+ getMnemonicInfo: {
331
+ description: "",
332
+ arguments: {
333
+ $ref: "#/components/schemas/IMnemonicInfoStoreArgs"
334
+ },
335
+ returnType: {
336
+ $ref: "#/components/schemas/IMnemonicInfoResult"
337
+ }
338
+ },
339
+ saveMnemonicInfo: {
340
+ description: "",
341
+ arguments: {
342
+ $ref: "#/components/schemas/IMnemonicInfoStoreArgs"
343
+ },
344
+ returnType: {
345
+ $ref: "#/components/schemas/IMnemonicInfoResult"
346
+ }
347
+ },
348
+ verifyMnemonic: {
349
+ description: "",
350
+ arguments: {
351
+ $ref: "#/components/schemas/IMnemonicVerificationArgs"
352
+ },
353
+ returnType: {
354
+ $ref: "#/components/schemas/IMnemonicInfoResult"
355
+ }
356
+ },
357
+ verifyPartialMnemonic: {
358
+ description: "",
359
+ arguments: {
360
+ $ref: "#/components/schemas/IPartialMnemonicVerificationArgs"
361
+ },
362
+ returnType: {
363
+ $ref: "#/components/schemas/IMnemonicInfoResult"
364
+ }
365
+ }
366
+ }
367
+ }
368
+ }
369
+ };
370
+ }
371
+ });
372
+
373
+ // src/index.ts
374
+ import "reflect-metadata";
375
+
376
+ // src/entities/MnemonicEntity.ts
377
+ import { Column, Entity, BaseEntity, PrimaryColumn } from "typeorm";
378
+ function _ts_decorate(decorators, target, key, desc) {
379
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
380
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
381
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
382
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
383
+ }
384
+ __name(_ts_decorate, "_ts_decorate");
385
+ function _ts_metadata(k, v) {
386
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
387
+ }
388
+ __name(_ts_metadata, "_ts_metadata");
389
+ var MnemonicEntity = class extends BaseEntity {
390
+ static {
391
+ __name(this, "MnemonicEntity");
392
+ }
393
+ id;
394
+ hash;
395
+ mnemonic;
396
+ masterKey;
397
+ chainCode;
398
+ };
399
+ _ts_decorate([
400
+ PrimaryColumn({
401
+ name: "id",
402
+ type: "varchar"
403
+ }),
404
+ _ts_metadata("design:type", String)
405
+ ], MnemonicEntity.prototype, "id", void 0);
406
+ _ts_decorate([
407
+ Column({
408
+ name: "hash",
409
+ unique: true,
410
+ type: "varchar"
411
+ }),
412
+ _ts_metadata("design:type", String)
413
+ ], MnemonicEntity.prototype, "hash", void 0);
414
+ _ts_decorate([
415
+ Column({
416
+ name: "mnemonic",
417
+ unique: true,
418
+ type: "varchar"
419
+ }),
420
+ _ts_metadata("design:type", String)
421
+ ], MnemonicEntity.prototype, "mnemonic", void 0);
422
+ _ts_decorate([
423
+ Column({
424
+ name: "master_key",
425
+ default: null,
426
+ type: "varchar"
427
+ }),
428
+ _ts_metadata("design:type", String)
429
+ ], MnemonicEntity.prototype, "masterKey", void 0);
430
+ _ts_decorate([
431
+ Column({
432
+ name: "chain_code",
433
+ default: null,
434
+ type: "varchar"
435
+ }),
436
+ _ts_metadata("design:type", String)
437
+ ], MnemonicEntity.prototype, "chainCode", void 0);
438
+ MnemonicEntity = _ts_decorate([
439
+ Entity("Mnemonic")
440
+ ], MnemonicEntity);
441
+
442
+ // src/agent/MnemonicSeedManager.ts
443
+ import { bytesToHex } from "@noble/hashes/utils";
444
+ import { shaHasher } from "@sphereon/ssi-sdk-ext.key-utils";
445
+ import { derivePath, getMasterKeyFromSeed, getPublicKey } from "ed25519-hd-key";
446
+ import * as bip39 from "bip39";
447
+ var MnemonicSeedManager = class {
448
+ static {
449
+ __name(this, "MnemonicSeedManager");
450
+ }
451
+ dbConnection;
452
+ secretBox;
453
+ schema;
454
+ methods;
455
+ constructor(dbConnection, secretBox) {
456
+ this.dbConnection = dbConnection;
457
+ this.secretBox = secretBox;
458
+ this.schema = schema.IMnemonicInfoGenerator;
459
+ this.methods = {
460
+ generateMnemonic: this.generateMnemonic.bind(this),
461
+ generateSeed: this.generateSeed.bind(this),
462
+ verifyMnemonic: this.verifyMnemonic.bind(this),
463
+ verifyPartialMnemonic: this.verifyPartialMnemonic.bind(this),
464
+ saveMnemonicInfo: this.saveMnemonicInfo.bind(this),
465
+ getMnemonicInfo: this.getMnemonicInfo.bind(this),
466
+ deleteMnemonicInfo: this.deleteMnemonicInfo.bind(this),
467
+ generateMasterKey: this.generateMasterKey.bind(this),
468
+ generateKeysFromMnemonic: this.generateKeysFromMnemonic.bind(this)
469
+ };
470
+ if (!secretBox) {
471
+ console.warn("Please provide SecretBox to the KeyStore");
472
+ }
473
+ }
474
+ async generateMnemonic(args) {
475
+ const mnemonic = bip39.generateMnemonic(args.bits);
476
+ if (args.persist) {
477
+ return await this.saveMnemonicInfo({
478
+ id: args.id,
479
+ mnemonic: mnemonic.split(" ")
480
+ });
481
+ }
482
+ return {
483
+ mnemonic: mnemonic.split(" ")
484
+ };
485
+ }
486
+ async verifyMnemonic(args) {
487
+ const mnemonicInfo = await this.getMnemonicInfo({
488
+ id: args.id,
489
+ hash: args.hash
490
+ });
491
+ if (mnemonicInfo?.mnemonic) {
492
+ return {
493
+ succeeded: mnemonicInfo.mnemonic.join(" ") === args.wordList?.join(" ")
494
+ };
495
+ }
496
+ throw new Error("Mnemonic not found");
497
+ }
498
+ async verifyPartialMnemonic(args) {
499
+ const mnemonicInfo = await this.getMnemonicInfo({
500
+ id: args.id,
501
+ hash: args.hash
502
+ });
503
+ if (mnemonicInfo?.mnemonic) {
504
+ return {
505
+ succeeded: args.indexedWordList.every((indexedWord) => mnemonicInfo.mnemonic?.indexOf(indexedWord[1]) === indexedWord[0])
506
+ };
507
+ }
508
+ throw new Error("Mnemonic not found");
509
+ }
510
+ async generateSeed(args) {
511
+ return Promise.resolve({
512
+ seed: (await bip39.mnemonicToSeed(args.mnemonic.join(" "))).toString("hex")
513
+ });
514
+ }
515
+ async saveMnemonicInfo(args) {
516
+ if (args.mnemonic && this.secretBox) {
517
+ const mnemonic = args.mnemonic.join(" ");
518
+ const hash = bytesToHex(shaHasher(mnemonic, "sha256"));
519
+ const mnemonicInfo = new MnemonicEntity();
520
+ mnemonicInfo.id = args.id ? args.id : hash;
521
+ mnemonicInfo.hash = hash;
522
+ mnemonicInfo.mnemonic = await this.secretBox.encrypt(mnemonic);
523
+ const result = await (await this.dbConnection).getRepository(MnemonicEntity).save(mnemonicInfo);
524
+ return Promise.resolve({
525
+ id: result.id,
526
+ hash: result.hash,
527
+ mnemonic: args.mnemonic
528
+ });
529
+ } else {
530
+ throw new Error("Mnemonic needs to be provided.");
531
+ }
532
+ }
533
+ async getMnemonicInfo(args) {
534
+ const mnemonicInfo = await (await this.dbConnection).getRepository(MnemonicEntity).createQueryBuilder().where("id = :id", {
535
+ id: args.id
536
+ }).orWhere("hash = :hash", {
537
+ hash: args.hash
538
+ }).getOne();
539
+ if (mnemonicInfo?.mnemonic) {
540
+ const mnemonicStr = await this.secretBox?.decrypt(mnemonicInfo.mnemonic);
541
+ return {
542
+ id: mnemonicInfo.id,
543
+ hash: mnemonicInfo.hash,
544
+ mnemonic: mnemonicStr?.split(" ")
545
+ };
546
+ }
547
+ return {};
548
+ }
549
+ async deleteMnemonicInfo(args) {
550
+ return (await this.dbConnection).createQueryBuilder().delete().from(MnemonicEntity).where("id = :id", {
551
+ id: args.id
552
+ }).orWhere("hash = :hash", {
553
+ hash: args.hash
554
+ }).execute();
555
+ }
556
+ async saveMasterKey(args) {
557
+ if (args.masterKey) {
558
+ return (await this.dbConnection).createQueryBuilder().update(MnemonicEntity).set({
559
+ masterKey: args.masterKey
560
+ }).where("id = :id", {
561
+ id: args.id
562
+ }).orWhere("hash = :hash", {
563
+ hash: args.hash
564
+ }).execute();
565
+ }
566
+ throw new Error("Master Key needs to be provided.");
567
+ }
568
+ async generateMasterKey(args) {
569
+ const mnemonic = (await this.getMnemonicInfo({
570
+ id: args.id,
571
+ hash: args.hash
572
+ })).mnemonic;
573
+ if (mnemonic) {
574
+ const mnemonicInfo = await this.generateSeed({
575
+ mnemonic
576
+ });
577
+ if (mnemonicInfo.seed) {
578
+ if (args.type === "Ed25519") {
579
+ const { key, chainCode } = getMasterKeyFromSeed(mnemonicInfo.seed);
580
+ await this.saveMasterKey({
581
+ masterKey: key.toString("hex"),
582
+ chainCode: chainCode.toString("hex")
583
+ });
584
+ return {
585
+ masterKey: key.toString("hex"),
586
+ chainCode: chainCode.toString("hex")
587
+ };
588
+ } else {
589
+ throw new Error("Secp256k1 keys are not supported yet");
590
+ }
591
+ }
592
+ }
593
+ throw new Error("Mnemonic not found");
594
+ }
595
+ async generateKeysFromMnemonic(args, context) {
596
+ const mnemonic = (await this.getMnemonicInfo({
597
+ id: args.id,
598
+ hash: args.hash
599
+ })).mnemonic;
600
+ if (mnemonic && context) {
601
+ if (args.path && args.kms) {
602
+ const seed = (await this.generateSeed({
603
+ mnemonic
604
+ })).seed;
605
+ const { key, chainCode } = derivePath(args.path, seed);
606
+ const extPrivateKey = Buffer.concat([
607
+ key,
608
+ chainCode
609
+ ]);
610
+ const publicKey = getPublicKey(key, args.withZeroBytes);
611
+ return await context.agent.keyManagerImport({
612
+ privateKeyHex: extPrivateKey.toString("hex"),
613
+ publicKeyHex: publicKey.toString("hex"),
614
+ type: "Ed25519",
615
+ kms: args.kms
616
+ });
617
+ }
618
+ throw new Error("Please provide kms and derivation path");
619
+ }
620
+ throw new Error("Master Key not found");
621
+ }
622
+ };
623
+
624
+ // src/migrations/generic/1-CreateMnemonics.ts
625
+ import Debug from "debug";
626
+
627
+ // src/migrations/postgres/1659566636105-CreateMnemonics.ts
628
+ var CreateMnemonics1659566636105 = class {
629
+ static {
630
+ __name(this, "CreateMnemonics1659566636105");
631
+ }
632
+ name = "CreateMnemonics1659566636105";
633
+ async up(queryRunner) {
634
+ await queryRunner.query(`CREATE TABLE "Mnemonic" ("id" character varying NOT NULL, "hash" character varying NOT NULL, "mnemonic" character varying NOT NULL, "master_key" character varying, "chain_code" character varying, CONSTRAINT "UQ_hash" UNIQUE ("hash"), CONSTRAINT "UQ_mnemonic" UNIQUE ("mnemonic"), CONSTRAINT "PK_mnemonic_id" PRIMARY KEY ("id"))`);
635
+ }
636
+ async down(queryRunner) {
637
+ await queryRunner.query(`DROP TABLE "Mnemonic"`);
638
+ }
639
+ };
640
+
641
+ // src/migrations/sqlite/1659566622817-CreateMnemonics.ts
642
+ var CreateMnemonics1659566622817 = class {
643
+ static {
644
+ __name(this, "CreateMnemonics1659566622817");
645
+ }
646
+ name = "CreateMnemonics1659566622817";
647
+ async up(queryRunner) {
648
+ await queryRunner.query(`CREATE TABLE "Mnemonic" ("id" varchar PRIMARY KEY NOT NULL, "hash" varchar NOT NULL, "mnemonic" varchar NOT NULL, "master_key" varchar, "chain_code" varchar, CONSTRAINT "UQ_hash" UNIQUE ("hash"), CONSTRAINT "UQ_mnemonic" UNIQUE ("mnemonic"))`);
649
+ }
650
+ async down(queryRunner) {
651
+ await queryRunner.query(`DROP TABLE "Mnemonic"`);
652
+ }
653
+ };
654
+
655
+ // src/migrations/generic/1-CreateMnemonics.ts
656
+ var debug = Debug("sphereon:ssi-sdk:migrations");
657
+ var CreateMnemonics1659567079429 = class {
658
+ static {
659
+ __name(this, "CreateMnemonics1659567079429");
660
+ }
661
+ name = "CreateMnemonics1659567079429";
662
+ async up(queryRunner) {
663
+ debug("migration: creating mnemonic tables");
664
+ const dbType = queryRunner.connection.driver.options.type;
665
+ if (dbType === "postgres") {
666
+ debug("using postgres migration file");
667
+ const mig = new CreateMnemonics1659566636105();
668
+ const up = await mig.up(queryRunner);
669
+ debug("Migration statements executed");
670
+ return up;
671
+ } else if (dbType === "sqlite" || "react-native") {
672
+ debug("using sqlite/react-native migration file");
673
+ const mig = new CreateMnemonics1659566622817();
674
+ const up = await mig.up(queryRunner);
675
+ debug("Migration statements executed");
676
+ return up;
677
+ } else {
678
+ return Promise.reject("Migrations are currently only supported for sqlite, react-native and postgres. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now");
679
+ }
680
+ }
681
+ async down(queryRunner) {
682
+ debug("reverting mnemonic tables");
683
+ const dbType = queryRunner.connection.driver.options.type;
684
+ if (dbType === "postgres") {
685
+ debug("using postgres migration file");
686
+ const mig = new CreateMnemonics1659566636105();
687
+ const down = await mig.down(queryRunner);
688
+ debug("Migration statements executed");
689
+ return down;
690
+ } else if (dbType === "sqlite" || "react-native") {
691
+ debug("using sqlite/react-native migration file");
692
+ const mig = new CreateMnemonics1659566622817();
693
+ const down = await mig.down(queryRunner);
694
+ debug("Migration statements executed");
695
+ return down;
696
+ } else {
697
+ return Promise.reject("Migrations are currently only supported for sqlite, react-native and postgres. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now");
698
+ }
699
+ }
700
+ };
701
+
702
+ // src/migrations/generic/index.ts
703
+ var MnemonicSeedManagerMigrations = [
704
+ CreateMnemonics1659567079429
705
+ ];
706
+
707
+ // src/index.ts
708
+ var schema = require_plugin_schema();
709
+ var MnemonicSeedManagerEntities = [
710
+ MnemonicEntity
711
+ ];
712
+ export {
713
+ MnemonicSeedManager,
714
+ MnemonicSeedManagerEntities,
715
+ MnemonicSeedManagerMigrations,
716
+ schema
15
717
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MnemonicSeedManagerMigrations = exports.MnemonicSeedManagerEntities = exports.MnemonicSeedManager = exports.schema = void 0;
18
- const MnemonicEntity_1 = require("./entities/MnemonicEntity");
19
- /**
20
- * @internal
21
- */
22
- const schema = require('../plugin.schema.json');
23
- exports.schema = schema;
24
- /**
25
- * @public
26
- */
27
- var MnemonicSeedManager_1 = require("./agent/MnemonicSeedManager");
28
- Object.defineProperty(exports, "MnemonicSeedManager", { enumerable: true, get: function () { return MnemonicSeedManager_1.MnemonicSeedManager; } });
29
- __exportStar(require("./types/IMnemonicSeedManager"), exports);
30
- /**
31
- * @internal
32
- */
33
- exports.MnemonicSeedManagerEntities = [MnemonicEntity_1.MnemonicEntity];
34
- /**
35
- * @internal
36
- */
37
- var migrations_1 = require("./migrations");
38
- Object.defineProperty(exports, "MnemonicSeedManagerMigrations", { enumerable: true, get: function () { return migrations_1.MnemonicSeedManagerMigrations; } });
39
718
  //# sourceMappingURL=index.js.map