@ajna-inc/vaults 0.1.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 (48) hide show
  1. package/LICENSE +202 -0
  2. package/build/VaultsApi.js +263 -0
  3. package/build/VaultsEvents.js +19 -0
  4. package/build/VaultsModule.js +71 -0
  5. package/build/crypto/wasm/VaultCrypto.js +70 -0
  6. package/build/errors/BadSuiteError.js +34 -0
  7. package/build/errors/DecryptAeadError.js +34 -0
  8. package/build/errors/DecryptKemError.js +34 -0
  9. package/build/errors/PolicyError.js +34 -0
  10. package/build/errors/VaultError.js +77 -0
  11. package/build/errors/index.js +16 -0
  12. package/build/index.js +119 -0
  13. package/build/messages/CreateVaultMessage.js +126 -0
  14. package/build/messages/DeleteVaultMessage.js +114 -0
  15. package/build/messages/DenyAccessMessage.js +114 -0
  16. package/build/messages/DenyShareMessage.js +120 -0
  17. package/build/messages/GrantAccessMessage.js +126 -0
  18. package/build/messages/ProvideShareMessage.js +126 -0
  19. package/build/messages/RequestAccessMessage.js +120 -0
  20. package/build/messages/RequestShareMessage.js +120 -0
  21. package/build/messages/RetrieveVaultMessage.js +108 -0
  22. package/build/messages/StoreVaultMessage.js +114 -0
  23. package/build/messages/UpdateVaultMessage.js +120 -0
  24. package/build/messages/VaultCreatedAckMessage.js +108 -0
  25. package/build/messages/VaultDataMessage.js +121 -0
  26. package/build/messages/VaultProblemReportMessage.js +124 -0
  27. package/build/messages/VaultStoredAckMessage.js +115 -0
  28. package/build/messages/index.js +36 -0
  29. package/build/models/ThresholdSession.js +24 -0
  30. package/build/models/VaultDocument.js +28 -0
  31. package/build/models/VaultHeader.js +31 -0
  32. package/build/models/VaultPolicy.js +29 -0
  33. package/build/models/index.js +20 -0
  34. package/build/repository/ThresholdSessionRecord.js +117 -0
  35. package/build/repository/ThresholdSessionRepository.js +216 -0
  36. package/build/repository/VaultRecord.js +128 -0
  37. package/build/repository/VaultRepository.js +200 -0
  38. package/build/repository/index.js +13 -0
  39. package/build/services/VaultEncryptionService.js +613 -0
  40. package/build/services/VaultService.js +398 -0
  41. package/build/services/index.js +8 -0
  42. package/package.json +45 -0
  43. package/wasm/README.md +166 -0
  44. package/wasm/package.json +16 -0
  45. package/wasm/vault_crypto.d.ts +526 -0
  46. package/wasm/vault_crypto.js +2137 -0
  47. package/wasm/vault_crypto_bg.wasm +0 -0
  48. package/wasm/vault_crypto_bg.wasm.d.ts +66 -0
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
18
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
19
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
20
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
21
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
22
+ var _, done = false;
23
+ for (var i = decorators.length - 1; i >= 0; i--) {
24
+ var context = {};
25
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
26
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
27
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
28
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
29
+ if (kind === "accessor") {
30
+ if (result === void 0) continue;
31
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
32
+ if (_ = accept(result.get)) descriptor.get = _;
33
+ if (_ = accept(result.set)) descriptor.set = _;
34
+ if (_ = accept(result.init)) initializers.unshift(_);
35
+ }
36
+ else if (_ = accept(result)) {
37
+ if (kind === "field") initializers.unshift(_);
38
+ else descriptor[key] = _;
39
+ }
40
+ }
41
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
42
+ done = true;
43
+ };
44
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
45
+ var useValue = arguments.length > 2;
46
+ for (var i = 0; i < initializers.length; i++) {
47
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
48
+ }
49
+ return useValue ? value : void 0;
50
+ };
51
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
52
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
53
+ return new (P || (P = Promise))(function (resolve, reject) {
54
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
55
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
56
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
57
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
58
+ });
59
+ };
60
+ var __generator = (this && this.__generator) || function (thisArg, body) {
61
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
62
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
63
+ function verb(n) { return function (v) { return step([n, v]); }; }
64
+ function step(op) {
65
+ if (f) throw new TypeError("Generator is already executing.");
66
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
67
+ 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;
68
+ if (y = 0, t) op = [op[0] & 2, t.value];
69
+ switch (op[0]) {
70
+ case 0: case 1: t = op; break;
71
+ case 4: _.label++; return { value: op[1], done: false };
72
+ case 5: _.label++; y = op[1]; op = [0]; continue;
73
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
74
+ default:
75
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
76
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
77
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
78
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
79
+ if (t[2]) _.ops.pop();
80
+ _.trys.pop(); continue;
81
+ }
82
+ op = body.call(thisArg, _);
83
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
84
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
85
+ }
86
+ };
87
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
88
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
89
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
90
+ };
91
+ Object.defineProperty(exports, "__esModule", { value: true });
92
+ exports.ThresholdSessionRepository = void 0;
93
+ var core_1 = require("@credo-ts/core");
94
+ var ThresholdSessionRecord_1 = require("./ThresholdSessionRecord");
95
+ var ThresholdSessionRepository = function () {
96
+ var _classDecorators = [(0, core_1.injectable)()];
97
+ var _classDescriptor;
98
+ var _classExtraInitializers = [];
99
+ var _classThis;
100
+ var _classSuper = core_1.Repository;
101
+ var ThresholdSessionRepository = _classThis = /** @class */ (function (_super) {
102
+ __extends(ThresholdSessionRepository_1, _super);
103
+ function ThresholdSessionRepository_1(storageService, eventEmitter) {
104
+ return _super.call(this, ThresholdSessionRecord_1.ThresholdSessionRecord, storageService, eventEmitter) || this;
105
+ }
106
+ /**
107
+ * Find session by session ID
108
+ */
109
+ ThresholdSessionRepository_1.prototype.findBySessionId = function (agentContext, sessionId) {
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ return __generator(this, function (_a) {
112
+ return [2 /*return*/, this.findSingleByQuery(agentContext, { sessionId: sessionId })];
113
+ });
114
+ });
115
+ };
116
+ /**
117
+ * Get session by session ID (throws if not found)
118
+ */
119
+ ThresholdSessionRepository_1.prototype.getBySessionId = function (agentContext, sessionId) {
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ return __generator(this, function (_a) {
122
+ return [2 /*return*/, this.getSingleByQuery(agentContext, { sessionId: sessionId })];
123
+ });
124
+ });
125
+ };
126
+ /**
127
+ * Find all sessions for a vault
128
+ */
129
+ ThresholdSessionRepository_1.prototype.findByVaultId = function (agentContext, vaultId) {
130
+ return __awaiter(this, void 0, void 0, function () {
131
+ return __generator(this, function (_a) {
132
+ return [2 /*return*/, this.findByQuery(agentContext, { vaultId: vaultId })];
133
+ });
134
+ });
135
+ };
136
+ /**
137
+ * Find sessions by status
138
+ */
139
+ ThresholdSessionRepository_1.prototype.findByStatus = function (agentContext, status) {
140
+ return __awaiter(this, void 0, void 0, function () {
141
+ return __generator(this, function (_a) {
142
+ return [2 /*return*/, this.findByQuery(agentContext, { status: status })];
143
+ });
144
+ });
145
+ };
146
+ /**
147
+ * Find active (pending) sessions for a vault
148
+ */
149
+ ThresholdSessionRepository_1.prototype.findActiveSessions = function (agentContext, vaultId) {
150
+ return __awaiter(this, void 0, void 0, function () {
151
+ var sessions;
152
+ return __generator(this, function (_a) {
153
+ switch (_a.label) {
154
+ case 0: return [4 /*yield*/, this.findByVaultId(agentContext, vaultId)];
155
+ case 1:
156
+ sessions = _a.sent();
157
+ return [2 /*return*/, sessions.filter(function (s) { return s.status === 'pending' && !s.isExpired; })];
158
+ }
159
+ });
160
+ });
161
+ };
162
+ /**
163
+ * Find sessions initiated by a specific DID
164
+ */
165
+ ThresholdSessionRepository_1.prototype.findByInitiator = function (agentContext, initiatedBy) {
166
+ return __awaiter(this, void 0, void 0, function () {
167
+ return __generator(this, function (_a) {
168
+ return [2 /*return*/, this.findByQuery(agentContext, { initiatedBy: initiatedBy })];
169
+ });
170
+ });
171
+ };
172
+ /**
173
+ * Delete expired sessions
174
+ */
175
+ ThresholdSessionRepository_1.prototype.deleteExpiredSessions = function (agentContext) {
176
+ return __awaiter(this, void 0, void 0, function () {
177
+ var pendingSessions, deletedCount, _i, pendingSessions_1, session;
178
+ return __generator(this, function (_a) {
179
+ switch (_a.label) {
180
+ case 0: return [4 /*yield*/, this.findByStatus(agentContext, 'pending')];
181
+ case 1:
182
+ pendingSessions = _a.sent();
183
+ deletedCount = 0;
184
+ _i = 0, pendingSessions_1 = pendingSessions;
185
+ _a.label = 2;
186
+ case 2:
187
+ if (!(_i < pendingSessions_1.length)) return [3 /*break*/, 5];
188
+ session = pendingSessions_1[_i];
189
+ if (!session.isExpired) return [3 /*break*/, 4];
190
+ return [4 /*yield*/, this.delete(agentContext, session)];
191
+ case 3:
192
+ _a.sent();
193
+ deletedCount++;
194
+ _a.label = 4;
195
+ case 4:
196
+ _i++;
197
+ return [3 /*break*/, 2];
198
+ case 5: return [2 /*return*/, deletedCount];
199
+ }
200
+ });
201
+ });
202
+ };
203
+ return ThresholdSessionRepository_1;
204
+ }(_classSuper));
205
+ __setFunctionName(_classThis, "ThresholdSessionRepository");
206
+ (function () {
207
+ var _a;
208
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
209
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
210
+ ThresholdSessionRepository = _classThis = _classDescriptor.value;
211
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
212
+ __runInitializers(_classThis, _classExtraInitializers);
213
+ })();
214
+ return ThresholdSessionRepository = _classThis;
215
+ }();
216
+ exports.ThresholdSessionRepository = ThresholdSessionRepository;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.VaultRecord = void 0;
30
+ var core_1 = require("@credo-ts/core");
31
+ /**
32
+ * Database record for an encrypted vault
33
+ *
34
+ * Stores the vault header (metadata) and ciphertext (encrypted data)
35
+ * All encryption/decryption happens client-side
36
+ */
37
+ var VaultRecord = /** @class */ (function (_super) {
38
+ __extends(VaultRecord, _super);
39
+ function VaultRecord(props) {
40
+ var _a, _b, _c;
41
+ var _this = _super.call(this) || this;
42
+ _this.type = VaultRecord.type;
43
+ if (props) {
44
+ _this.id = (_a = props.id) !== null && _a !== void 0 ? _a : core_1.utils.uuid();
45
+ _this.createdAt = (_b = props.createdAt) !== null && _b !== void 0 ? _b : new Date();
46
+ _this.updatedAt = props.updatedAt;
47
+ _this.vaultId = props.vaultId;
48
+ _this.docId = props.docId;
49
+ _this.ownerDid = props.ownerDid;
50
+ _this.header = props.header;
51
+ _this.ciphertext = props.ciphertext;
52
+ _this._tags = (_c = props.tags) !== null && _c !== void 0 ? _c : {};
53
+ }
54
+ return _this;
55
+ }
56
+ VaultRecord.prototype.getTags = function () {
57
+ var _a;
58
+ return __assign(__assign({}, this._tags), { vaultId: this.vaultId, docId: this.docId, ownerDid: this.ownerDid, policyMode: (_a = this.header.policy) === null || _a === void 0 ? void 0 : _a.mode, suite: this.header.suite, epoch: String(this.header.epoch) });
59
+ };
60
+ Object.defineProperty(VaultRecord.prototype, "policyMode", {
61
+ /**
62
+ * Get the policy mode of this vault
63
+ */
64
+ get: function () {
65
+ var _a;
66
+ return (_a = this.header.policy) === null || _a === void 0 ? void 0 : _a.mode;
67
+ },
68
+ enumerable: false,
69
+ configurable: true
70
+ });
71
+ Object.defineProperty(VaultRecord.prototype, "isPassphraseVault", {
72
+ /**
73
+ * Check if this is a passphrase-protected vault
74
+ */
75
+ get: function () {
76
+ return this.header.suite === 'S3' && !!this.header.salt && !!this.header.argon2;
77
+ },
78
+ enumerable: false,
79
+ configurable: true
80
+ });
81
+ Object.defineProperty(VaultRecord.prototype, "isAnyOfVault", {
82
+ /**
83
+ * Check if this is an any-of policy vault
84
+ */
85
+ get: function () {
86
+ var _a;
87
+ return ((_a = this.header.policy) === null || _a === void 0 ? void 0 : _a.mode) === 'any-of' && !!this.header.recipients;
88
+ },
89
+ enumerable: false,
90
+ configurable: true
91
+ });
92
+ Object.defineProperty(VaultRecord.prototype, "isThresholdVault", {
93
+ /**
94
+ * Check if this is a threshold policy vault
95
+ */
96
+ get: function () {
97
+ var _a;
98
+ return ((_a = this.header.policy) === null || _a === void 0 ? void 0 : _a.mode) === 'threshold' && !!this.header.shares;
99
+ },
100
+ enumerable: false,
101
+ configurable: true
102
+ });
103
+ Object.defineProperty(VaultRecord.prototype, "description", {
104
+ /**
105
+ * Get human-readable description if available
106
+ */
107
+ get: function () {
108
+ var _a;
109
+ return (_a = this.header.metadata) === null || _a === void 0 ? void 0 : _a.description;
110
+ },
111
+ enumerable: false,
112
+ configurable: true
113
+ });
114
+ Object.defineProperty(VaultRecord.prototype, "metadataTags", {
115
+ /**
116
+ * Get tags if available
117
+ */
118
+ get: function () {
119
+ var _a;
120
+ return (_a = this.header.metadata) === null || _a === void 0 ? void 0 : _a.tags;
121
+ },
122
+ enumerable: false,
123
+ configurable: true
124
+ });
125
+ VaultRecord.type = 'VaultRecord';
126
+ return VaultRecord;
127
+ }(core_1.BaseRecord));
128
+ exports.VaultRecord = VaultRecord;
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
18
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
19
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
20
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
21
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
22
+ var _, done = false;
23
+ for (var i = decorators.length - 1; i >= 0; i--) {
24
+ var context = {};
25
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
26
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
27
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
28
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
29
+ if (kind === "accessor") {
30
+ if (result === void 0) continue;
31
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
32
+ if (_ = accept(result.get)) descriptor.get = _;
33
+ if (_ = accept(result.set)) descriptor.set = _;
34
+ if (_ = accept(result.init)) initializers.unshift(_);
35
+ }
36
+ else if (_ = accept(result)) {
37
+ if (kind === "field") initializers.unshift(_);
38
+ else descriptor[key] = _;
39
+ }
40
+ }
41
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
42
+ done = true;
43
+ };
44
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
45
+ var useValue = arguments.length > 2;
46
+ for (var i = 0; i < initializers.length; i++) {
47
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
48
+ }
49
+ return useValue ? value : void 0;
50
+ };
51
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
52
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
53
+ return new (P || (P = Promise))(function (resolve, reject) {
54
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
55
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
56
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
57
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
58
+ });
59
+ };
60
+ var __generator = (this && this.__generator) || function (thisArg, body) {
61
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
62
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
63
+ function verb(n) { return function (v) { return step([n, v]); }; }
64
+ function step(op) {
65
+ if (f) throw new TypeError("Generator is already executing.");
66
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
67
+ 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;
68
+ if (y = 0, t) op = [op[0] & 2, t.value];
69
+ switch (op[0]) {
70
+ case 0: case 1: t = op; break;
71
+ case 4: _.label++; return { value: op[1], done: false };
72
+ case 5: _.label++; y = op[1]; op = [0]; continue;
73
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
74
+ default:
75
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
76
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
77
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
78
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
79
+ if (t[2]) _.ops.pop();
80
+ _.trys.pop(); continue;
81
+ }
82
+ op = body.call(thisArg, _);
83
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
84
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
85
+ }
86
+ };
87
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
88
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
89
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
90
+ };
91
+ Object.defineProperty(exports, "__esModule", { value: true });
92
+ exports.VaultRepository = void 0;
93
+ var core_1 = require("@credo-ts/core");
94
+ var VaultRecord_1 = require("./VaultRecord");
95
+ var VaultRepository = function () {
96
+ var _classDecorators = [(0, core_1.injectable)()];
97
+ var _classDescriptor;
98
+ var _classExtraInitializers = [];
99
+ var _classThis;
100
+ var _classSuper = core_1.Repository;
101
+ var VaultRepository = _classThis = /** @class */ (function (_super) {
102
+ __extends(VaultRepository_1, _super);
103
+ function VaultRepository_1(storageService, eventEmitter) {
104
+ return _super.call(this, VaultRecord_1.VaultRecord, storageService, eventEmitter) || this;
105
+ }
106
+ /**
107
+ * Find vault by vault ID
108
+ */
109
+ VaultRepository_1.prototype.findByVaultId = function (agentContext, vaultId) {
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ return __generator(this, function (_a) {
112
+ return [2 /*return*/, this.findSingleByQuery(agentContext, { vaultId: vaultId })];
113
+ });
114
+ });
115
+ };
116
+ /**
117
+ * Get vault by vault ID (throws if not found)
118
+ */
119
+ VaultRepository_1.prototype.getByVaultId = function (agentContext, vaultId) {
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ return __generator(this, function (_a) {
122
+ return [2 /*return*/, this.getSingleByQuery(agentContext, { vaultId: vaultId })];
123
+ });
124
+ });
125
+ };
126
+ /**
127
+ * Find vault by document ID
128
+ */
129
+ VaultRepository_1.prototype.findByDocId = function (agentContext, docId) {
130
+ return __awaiter(this, void 0, void 0, function () {
131
+ return __generator(this, function (_a) {
132
+ return [2 /*return*/, this.findSingleByQuery(agentContext, { docId: docId })];
133
+ });
134
+ });
135
+ };
136
+ /**
137
+ * Find all vaults owned by a specific DID
138
+ */
139
+ VaultRepository_1.prototype.findByOwner = function (agentContext, ownerDid) {
140
+ return __awaiter(this, void 0, void 0, function () {
141
+ return __generator(this, function (_a) {
142
+ return [2 /*return*/, this.findByQuery(agentContext, { ownerDid: ownerDid })];
143
+ });
144
+ });
145
+ };
146
+ /**
147
+ * Find all vaults with a specific policy mode
148
+ */
149
+ VaultRepository_1.prototype.findByPolicyMode = function (agentContext, policyMode) {
150
+ return __awaiter(this, void 0, void 0, function () {
151
+ return __generator(this, function (_a) {
152
+ return [2 /*return*/, this.findByQuery(agentContext, { policyMode: policyMode })];
153
+ });
154
+ });
155
+ };
156
+ /**
157
+ * Find all vaults using a specific suite
158
+ */
159
+ VaultRepository_1.prototype.findBySuite = function (agentContext, suite) {
160
+ return __awaiter(this, void 0, void 0, function () {
161
+ return __generator(this, function (_a) {
162
+ return [2 /*return*/, this.findByQuery(agentContext, { suite: suite })];
163
+ });
164
+ });
165
+ };
166
+ /**
167
+ * Delete vault by vault ID
168
+ */
169
+ VaultRepository_1.prototype.deleteByVaultId = function (agentContext, vaultId) {
170
+ return __awaiter(this, void 0, void 0, function () {
171
+ var record;
172
+ return __generator(this, function (_a) {
173
+ switch (_a.label) {
174
+ case 0: return [4 /*yield*/, this.findByVaultId(agentContext, vaultId)];
175
+ case 1:
176
+ record = _a.sent();
177
+ if (!record) return [3 /*break*/, 3];
178
+ return [4 /*yield*/, this.delete(agentContext, record)];
179
+ case 2:
180
+ _a.sent();
181
+ _a.label = 3;
182
+ case 3: return [2 /*return*/];
183
+ }
184
+ });
185
+ });
186
+ };
187
+ return VaultRepository_1;
188
+ }(_classSuper));
189
+ __setFunctionName(_classThis, "VaultRepository");
190
+ (function () {
191
+ var _a;
192
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
193
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
194
+ VaultRepository = _classThis = _classDescriptor.value;
195
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
196
+ __runInitializers(_classThis, _classExtraInitializers);
197
+ })();
198
+ return VaultRepository = _classThis;
199
+ }();
200
+ exports.VaultRepository = VaultRepository;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThresholdSessionRepository = exports.ThresholdSessionRecord = exports.VaultRepository = exports.VaultRecord = void 0;
4
+ // Vault storage
5
+ var VaultRecord_1 = require("./VaultRecord");
6
+ Object.defineProperty(exports, "VaultRecord", { enumerable: true, get: function () { return VaultRecord_1.VaultRecord; } });
7
+ var VaultRepository_1 = require("./VaultRepository");
8
+ Object.defineProperty(exports, "VaultRepository", { enumerable: true, get: function () { return VaultRepository_1.VaultRepository; } });
9
+ // Threshold session storage
10
+ var ThresholdSessionRecord_1 = require("./ThresholdSessionRecord");
11
+ Object.defineProperty(exports, "ThresholdSessionRecord", { enumerable: true, get: function () { return ThresholdSessionRecord_1.ThresholdSessionRecord; } });
12
+ var ThresholdSessionRepository_1 = require("./ThresholdSessionRepository");
13
+ Object.defineProperty(exports, "ThresholdSessionRepository", { enumerable: true, get: function () { return ThresholdSessionRepository_1.ThresholdSessionRepository; } });