@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,121 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.VaultDataMessage = void 0;
53
+ var core_1 = require("@credo-ts/core");
54
+ var class_transformer_1 = require("class-transformer");
55
+ var class_validator_1 = require("class-validator");
56
+ /**
57
+ * Return vault data in response to retrieve request
58
+ *
59
+ * @see https://didcomm.org/vaults/1.0/vault-data
60
+ */
61
+ var VaultDataMessage = function () {
62
+ var _a;
63
+ var _classSuper = core_1.AgentMessage;
64
+ var _instanceExtraInitializers = [];
65
+ var _type_decorators;
66
+ var _type_initializers = [];
67
+ var _vaultId_decorators;
68
+ var _vaultId_initializers = [];
69
+ var _docId_decorators;
70
+ var _docId_initializers = [];
71
+ var _header_decorators;
72
+ var _header_initializers = [];
73
+ var _ciphertext_decorators;
74
+ var _ciphertext_initializers = [];
75
+ var _storageMetadata_decorators;
76
+ var _storageMetadata_initializers = [];
77
+ return _a = /** @class */ (function (_super) {
78
+ __extends(VaultDataMessage, _super);
79
+ function VaultDataMessage(options) {
80
+ var _b;
81
+ var _this = _super.call(this) || this;
82
+ _this.type = (__runInitializers(_this, _instanceExtraInitializers), __runInitializers(_this, _type_initializers, _a.type.messageTypeUri));
83
+ _this.vaultId = __runInitializers(_this, _vaultId_initializers, void 0);
84
+ _this.docId = __runInitializers(_this, _docId_initializers, void 0);
85
+ _this.header = __runInitializers(_this, _header_initializers, void 0);
86
+ _this.ciphertext = __runInitializers(_this, _ciphertext_initializers, void 0);
87
+ _this.storageMetadata = __runInitializers(_this, _storageMetadata_initializers, void 0);
88
+ if (options) {
89
+ _this.id = (_b = options.id) !== null && _b !== void 0 ? _b : _this.generateId();
90
+ _this.setThread({ threadId: options.threadId });
91
+ _this.vaultId = options.vaultId;
92
+ _this.docId = options.docId;
93
+ _this.header = options.header;
94
+ _this.ciphertext = options.ciphertext;
95
+ _this.storageMetadata = options.storageMetadata;
96
+ }
97
+ return _this;
98
+ }
99
+ return VaultDataMessage;
100
+ }(_classSuper)),
101
+ (function () {
102
+ var _b;
103
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
104
+ _type_decorators = [(0, core_1.IsValidMessageType)(VaultDataMessage.type)];
105
+ _vaultId_decorators = [(0, class_transformer_1.Expose)({ name: 'vault_id' }), (0, class_validator_1.IsString)()];
106
+ _docId_decorators = [(0, class_transformer_1.Expose)({ name: 'doc_id' }), (0, class_validator_1.IsString)()];
107
+ _header_decorators = [(0, class_transformer_1.Expose)(), (0, class_validator_1.IsObject)(), (0, class_validator_1.ValidateNested)(), (0, class_transformer_1.Type)(function () { return Object; })];
108
+ _ciphertext_decorators = [(0, class_transformer_1.Expose)(), (0, class_validator_1.IsString)()];
109
+ _storageMetadata_decorators = [(0, class_transformer_1.Expose)({ name: 'storage_metadata' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsObject)()];
110
+ __esDecorate(null, null, _type_decorators, { kind: "field", name: "type", static: false, private: false, access: { has: function (obj) { return "type" in obj; }, get: function (obj) { return obj.type; }, set: function (obj, value) { obj.type = value; } }, metadata: _metadata }, _type_initializers, _instanceExtraInitializers);
111
+ __esDecorate(null, null, _vaultId_decorators, { kind: "field", name: "vaultId", static: false, private: false, access: { has: function (obj) { return "vaultId" in obj; }, get: function (obj) { return obj.vaultId; }, set: function (obj, value) { obj.vaultId = value; } }, metadata: _metadata }, _vaultId_initializers, _instanceExtraInitializers);
112
+ __esDecorate(null, null, _docId_decorators, { kind: "field", name: "docId", static: false, private: false, access: { has: function (obj) { return "docId" in obj; }, get: function (obj) { return obj.docId; }, set: function (obj, value) { obj.docId = value; } }, metadata: _metadata }, _docId_initializers, _instanceExtraInitializers);
113
+ __esDecorate(null, null, _header_decorators, { kind: "field", name: "header", static: false, private: false, access: { has: function (obj) { return "header" in obj; }, get: function (obj) { return obj.header; }, set: function (obj, value) { obj.header = value; } }, metadata: _metadata }, _header_initializers, _instanceExtraInitializers);
114
+ __esDecorate(null, null, _ciphertext_decorators, { kind: "field", name: "ciphertext", static: false, private: false, access: { has: function (obj) { return "ciphertext" in obj; }, get: function (obj) { return obj.ciphertext; }, set: function (obj, value) { obj.ciphertext = value; } }, metadata: _metadata }, _ciphertext_initializers, _instanceExtraInitializers);
115
+ __esDecorate(null, null, _storageMetadata_decorators, { kind: "field", name: "storageMetadata", static: false, private: false, access: { has: function (obj) { return "storageMetadata" in obj; }, get: function (obj) { return obj.storageMetadata; }, set: function (obj, value) { obj.storageMetadata = value; } }, metadata: _metadata }, _storageMetadata_initializers, _instanceExtraInitializers);
116
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
117
+ })(),
118
+ _a.type = (0, core_1.parseMessageType)('https://didcomm.org/vaults/1.0/vault-data'),
119
+ _a;
120
+ }();
121
+ exports.VaultDataMessage = VaultDataMessage;
@@ -0,0 +1,124 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.VaultErrorCodes = exports.VaultProblemReportMessage = void 0;
53
+ var core_1 = require("@credo-ts/core");
54
+ var class_transformer_1 = require("class-transformer");
55
+ var class_validator_1 = require("class-validator");
56
+ /**
57
+ * Report errors in vault operations
58
+ *
59
+ * @see https://didcomm.org/vaults/1.0/problem-report
60
+ */
61
+ var VaultProblemReportMessage = function () {
62
+ var _a;
63
+ var _classSuper = core_1.AgentMessage;
64
+ var _instanceExtraInitializers = [];
65
+ var _type_decorators;
66
+ var _type_initializers = [];
67
+ var _vaultId_decorators;
68
+ var _vaultId_initializers = [];
69
+ var _errorCode_decorators;
70
+ var _errorCode_initializers = [];
71
+ var _description_decorators;
72
+ var _description_initializers = [];
73
+ var _details_decorators;
74
+ var _details_initializers = [];
75
+ return _a = /** @class */ (function (_super) {
76
+ __extends(VaultProblemReportMessage, _super);
77
+ function VaultProblemReportMessage(options) {
78
+ var _b;
79
+ var _this = _super.call(this) || this;
80
+ _this.type = (__runInitializers(_this, _instanceExtraInitializers), __runInitializers(_this, _type_initializers, _a.type.messageTypeUri));
81
+ _this.vaultId = __runInitializers(_this, _vaultId_initializers, void 0);
82
+ _this.errorCode = __runInitializers(_this, _errorCode_initializers, void 0);
83
+ _this.description = __runInitializers(_this, _description_initializers, void 0);
84
+ _this.details = __runInitializers(_this, _details_initializers, void 0);
85
+ if (options) {
86
+ _this.id = (_b = options.id) !== null && _b !== void 0 ? _b : _this.generateId();
87
+ _this.vaultId = options.vaultId;
88
+ _this.errorCode = options.errorCode;
89
+ _this.description = options.description;
90
+ _this.details = options.details;
91
+ }
92
+ return _this;
93
+ }
94
+ return VaultProblemReportMessage;
95
+ }(_classSuper)),
96
+ (function () {
97
+ var _b;
98
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
99
+ _type_decorators = [(0, core_1.IsValidMessageType)(VaultProblemReportMessage.type)];
100
+ _vaultId_decorators = [(0, class_transformer_1.Expose)({ name: 'vault_id' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)()];
101
+ _errorCode_decorators = [(0, class_transformer_1.Expose)({ name: 'error_code' }), (0, class_validator_1.IsString)()];
102
+ _description_decorators = [(0, class_transformer_1.Expose)(), (0, class_validator_1.IsString)()];
103
+ _details_decorators = [(0, class_transformer_1.Expose)(), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsObject)()];
104
+ __esDecorate(null, null, _type_decorators, { kind: "field", name: "type", static: false, private: false, access: { has: function (obj) { return "type" in obj; }, get: function (obj) { return obj.type; }, set: function (obj, value) { obj.type = value; } }, metadata: _metadata }, _type_initializers, _instanceExtraInitializers);
105
+ __esDecorate(null, null, _vaultId_decorators, { kind: "field", name: "vaultId", static: false, private: false, access: { has: function (obj) { return "vaultId" in obj; }, get: function (obj) { return obj.vaultId; }, set: function (obj, value) { obj.vaultId = value; } }, metadata: _metadata }, _vaultId_initializers, _instanceExtraInitializers);
106
+ __esDecorate(null, null, _errorCode_decorators, { kind: "field", name: "errorCode", static: false, private: false, access: { has: function (obj) { return "errorCode" in obj; }, get: function (obj) { return obj.errorCode; }, set: function (obj, value) { obj.errorCode = value; } }, metadata: _metadata }, _errorCode_initializers, _instanceExtraInitializers);
107
+ __esDecorate(null, null, _description_decorators, { kind: "field", name: "description", static: false, private: false, access: { has: function (obj) { return "description" in obj; }, get: function (obj) { return obj.description; }, set: function (obj, value) { obj.description = value; } }, metadata: _metadata }, _description_initializers, _instanceExtraInitializers);
108
+ __esDecorate(null, null, _details_decorators, { kind: "field", name: "details", static: false, private: false, access: { has: function (obj) { return "details" in obj; }, get: function (obj) { return obj.details; }, set: function (obj, value) { obj.details = value; } }, metadata: _metadata }, _details_initializers, _instanceExtraInitializers);
109
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
110
+ })(),
111
+ _a.type = (0, core_1.parseMessageType)('https://didcomm.org/vaults/1.0/problem-report'),
112
+ _a;
113
+ }();
114
+ exports.VaultProblemReportMessage = VaultProblemReportMessage;
115
+ // Common error codes
116
+ exports.VaultErrorCodes = {
117
+ NOT_FOUND: 'not-found',
118
+ ACCESS_DENIED: 'access-denied',
119
+ INVALID_POLICY: 'invalid-policy',
120
+ DECRYPTION_FAILED: 'decryption-failed',
121
+ THRESHOLD_NOT_MET: 'threshold-not-met',
122
+ EXPIRED: 'expired',
123
+ STORAGE_ERROR: 'storage-error',
124
+ };
@@ -0,0 +1,115 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.VaultStoredAckMessage = void 0;
53
+ var core_1 = require("@credo-ts/core");
54
+ var class_transformer_1 = require("class-transformer");
55
+ var class_validator_1 = require("class-validator");
56
+ /**
57
+ * Acknowledge vault storage completion
58
+ *
59
+ * @see https://didcomm.org/vaults/1.0/vault-stored-ack
60
+ */
61
+ var VaultStoredAckMessage = function () {
62
+ var _a;
63
+ var _classSuper = core_1.AgentMessage;
64
+ var _instanceExtraInitializers = [];
65
+ var _type_decorators;
66
+ var _type_initializers = [];
67
+ var _vaultId_decorators;
68
+ var _vaultId_initializers = [];
69
+ var _docId_decorators;
70
+ var _docId_initializers = [];
71
+ var _storageLocation_decorators;
72
+ var _storageLocation_initializers = [];
73
+ var _storageMetadata_decorators;
74
+ var _storageMetadata_initializers = [];
75
+ return _a = /** @class */ (function (_super) {
76
+ __extends(VaultStoredAckMessage, _super);
77
+ function VaultStoredAckMessage(options) {
78
+ var _b;
79
+ var _this = _super.call(this) || this;
80
+ _this.type = (__runInitializers(_this, _instanceExtraInitializers), __runInitializers(_this, _type_initializers, _a.type.messageTypeUri));
81
+ _this.vaultId = __runInitializers(_this, _vaultId_initializers, void 0);
82
+ _this.docId = __runInitializers(_this, _docId_initializers, void 0);
83
+ _this.storageLocation = __runInitializers(_this, _storageLocation_initializers, void 0);
84
+ _this.storageMetadata = __runInitializers(_this, _storageMetadata_initializers, void 0);
85
+ if (options) {
86
+ _this.id = (_b = options.id) !== null && _b !== void 0 ? _b : _this.generateId();
87
+ _this.setThread({ threadId: options.threadId });
88
+ _this.vaultId = options.vaultId;
89
+ _this.docId = options.docId;
90
+ _this.storageLocation = options.storageLocation;
91
+ _this.storageMetadata = options.storageMetadata;
92
+ }
93
+ return _this;
94
+ }
95
+ return VaultStoredAckMessage;
96
+ }(_classSuper)),
97
+ (function () {
98
+ var _b;
99
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
100
+ _type_decorators = [(0, core_1.IsValidMessageType)(VaultStoredAckMessage.type)];
101
+ _vaultId_decorators = [(0, class_transformer_1.Expose)({ name: 'vault_id' }), (0, class_validator_1.IsString)()];
102
+ _docId_decorators = [(0, class_transformer_1.Expose)({ name: 'doc_id' }), (0, class_validator_1.IsString)()];
103
+ _storageLocation_decorators = [(0, class_transformer_1.Expose)({ name: 'storage_location' }), (0, class_validator_1.IsString)()];
104
+ _storageMetadata_decorators = [(0, class_transformer_1.Expose)({ name: 'storage_metadata' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsObject)()];
105
+ __esDecorate(null, null, _type_decorators, { kind: "field", name: "type", static: false, private: false, access: { has: function (obj) { return "type" in obj; }, get: function (obj) { return obj.type; }, set: function (obj, value) { obj.type = value; } }, metadata: _metadata }, _type_initializers, _instanceExtraInitializers);
106
+ __esDecorate(null, null, _vaultId_decorators, { kind: "field", name: "vaultId", static: false, private: false, access: { has: function (obj) { return "vaultId" in obj; }, get: function (obj) { return obj.vaultId; }, set: function (obj, value) { obj.vaultId = value; } }, metadata: _metadata }, _vaultId_initializers, _instanceExtraInitializers);
107
+ __esDecorate(null, null, _docId_decorators, { kind: "field", name: "docId", static: false, private: false, access: { has: function (obj) { return "docId" in obj; }, get: function (obj) { return obj.docId; }, set: function (obj, value) { obj.docId = value; } }, metadata: _metadata }, _docId_initializers, _instanceExtraInitializers);
108
+ __esDecorate(null, null, _storageLocation_decorators, { kind: "field", name: "storageLocation", static: false, private: false, access: { has: function (obj) { return "storageLocation" in obj; }, get: function (obj) { return obj.storageLocation; }, set: function (obj, value) { obj.storageLocation = value; } }, metadata: _metadata }, _storageLocation_initializers, _instanceExtraInitializers);
109
+ __esDecorate(null, null, _storageMetadata_decorators, { kind: "field", name: "storageMetadata", static: false, private: false, access: { has: function (obj) { return "storageMetadata" in obj; }, get: function (obj) { return obj.storageMetadata; }, set: function (obj, value) { obj.storageMetadata = value; } }, metadata: _metadata }, _storageMetadata_initializers, _instanceExtraInitializers);
110
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
111
+ })(),
112
+ _a.type = (0, core_1.parseMessageType)('https://didcomm.org/vaults/1.0/vault-stored-ack'),
113
+ _a;
114
+ }();
115
+ exports.VaultStoredAckMessage = VaultStoredAckMessage;
@@ -0,0 +1,36 @@
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);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Lifecycle messages
18
+ __exportStar(require("./CreateVaultMessage"), exports);
19
+ __exportStar(require("./VaultCreatedAckMessage"), exports);
20
+ __exportStar(require("./UpdateVaultMessage"), exports);
21
+ __exportStar(require("./DeleteVaultMessage"), exports);
22
+ // Access control messages
23
+ __exportStar(require("./RequestAccessMessage"), exports);
24
+ __exportStar(require("./GrantAccessMessage"), exports);
25
+ __exportStar(require("./DenyAccessMessage"), exports);
26
+ // Threshold messages
27
+ __exportStar(require("./RequestShareMessage"), exports);
28
+ __exportStar(require("./ProvideShareMessage"), exports);
29
+ __exportStar(require("./DenyShareMessage"), exports);
30
+ // Storage service messages
31
+ __exportStar(require("./StoreVaultMessage"), exports);
32
+ __exportStar(require("./VaultStoredAckMessage"), exports);
33
+ __exportStar(require("./RetrieveVaultMessage"), exports);
34
+ __exportStar(require("./VaultDataMessage"), exports);
35
+ // Error messages
36
+ __exportStar(require("./VaultProblemReportMessage"), exports);
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * Threshold Session Model
4
+ *
5
+ * Tracks multi-party threshold reconstruction sessions
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.isSessionExpired = exports.hasMetThreshold = void 0;
9
+ /**
10
+ * Check if session has met threshold
11
+ */
12
+ function hasMetThreshold(session) {
13
+ return session.shares.length >= session.threshold;
14
+ }
15
+ exports.hasMetThreshold = hasMetThreshold;
16
+ /**
17
+ * Check if session is expired
18
+ */
19
+ function isSessionExpired(session) {
20
+ if (!session.expiresAt)
21
+ return false;
22
+ return new Date() > session.expiresAt;
23
+ }
24
+ exports.isSessionExpired = isSessionExpired;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Vault Document Model
4
+ *
5
+ * Represents a complete vault: header + ciphertext
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.vaultDocumentFromJson = exports.vaultDocumentToJson = void 0;
9
+ /**
10
+ * Serialize vault document to JSON
11
+ */
12
+ function vaultDocumentToJson(document) {
13
+ return {
14
+ header: document.header,
15
+ ciphertext: Buffer.from(document.ciphertext).toString('base64url'),
16
+ };
17
+ }
18
+ exports.vaultDocumentToJson = vaultDocumentToJson;
19
+ /**
20
+ * Deserialize vault document from JSON
21
+ */
22
+ function vaultDocumentFromJson(json) {
23
+ return {
24
+ header: json.header,
25
+ ciphertext: Buffer.from(json.ciphertext, 'base64url'),
26
+ };
27
+ }
28
+ exports.vaultDocumentFromJson = vaultDocumentFromJson;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Vault Header Model
4
+ *
5
+ * Based on ZK-Vault spec §5.1
6
+ * Simplified for S3 suite (passphrase-based) initially
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.isThresholdVault = exports.isAllOfVault = exports.isAnyOfVault = exports.isPassphraseVault = void 0;
10
+ /**
11
+ * Type guards
12
+ */
13
+ function isPassphraseVault(header) {
14
+ return header.suite === 'S3' && !!header.salt && !!header.argon2;
15
+ }
16
+ exports.isPassphraseVault = isPassphraseVault;
17
+ function isAnyOfVault(header) {
18
+ var _a;
19
+ return ((_a = header.policy) === null || _a === void 0 ? void 0 : _a.mode) === 'any-of' && !!header.recipients;
20
+ }
21
+ exports.isAnyOfVault = isAnyOfVault;
22
+ function isAllOfVault(header) {
23
+ var _a;
24
+ return ((_a = header.policy) === null || _a === void 0 ? void 0 : _a.mode) === 'all-of' && !!header.wrap_all;
25
+ }
26
+ exports.isAllOfVault = isAllOfVault;
27
+ function isThresholdVault(header) {
28
+ var _a;
29
+ return ((_a = header.policy) === null || _a === void 0 ? void 0 : _a.mode) === 'threshold' && !!header.shares;
30
+ }
31
+ exports.isThresholdVault = isThresholdVault;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * Vault Policy Models
4
+ *
5
+ * Describes access policies for vaults
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.validatePolicy = void 0;
9
+ /**
10
+ * Policy validation
11
+ */
12
+ function validatePolicy(policy) {
13
+ switch (policy.mode) {
14
+ case 'passphrase':
15
+ return policy.passphrase === true;
16
+ case 'any-of':
17
+ return !!policy.participants && policy.participants.length > 0;
18
+ case 'all-of':
19
+ return !!policy.allParticipants && policy.allParticipants.length > 0;
20
+ case 'threshold':
21
+ return (!!policy.threshold &&
22
+ !!policy.totalShares &&
23
+ policy.threshold > 0 &&
24
+ policy.threshold <= policy.totalShares);
25
+ default:
26
+ return false;
27
+ }
28
+ }
29
+ exports.validatePolicy = validatePolicy;
@@ -0,0 +1,20 @@
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);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./VaultHeader"), exports);
18
+ __exportStar(require("./VaultDocument"), exports);
19
+ __exportStar(require("./VaultPolicy"), exports);
20
+ __exportStar(require("./ThresholdSession"), exports);
@@ -0,0 +1,117 @@
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.ThresholdSessionRecord = void 0;
30
+ var core_1 = require("@credo-ts/core");
31
+ /**
32
+ * Database record for a threshold share collection session
33
+ *
34
+ * Used to track the collection of Shamir secret shares
35
+ * for threshold (t-of-n) vault decryption
36
+ */
37
+ var ThresholdSessionRecord = /** @class */ (function (_super) {
38
+ __extends(ThresholdSessionRecord, _super);
39
+ function ThresholdSessionRecord(props) {
40
+ var _a, _b, _c, _d;
41
+ var _this = _super.call(this) || this;
42
+ _this.type = ThresholdSessionRecord.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.sessionId = props.sessionId;
48
+ _this.vaultId = props.vaultId;
49
+ _this.docId = props.docId;
50
+ _this.threshold = props.threshold;
51
+ _this.totalShares = props.totalShares;
52
+ _this.status = props.status;
53
+ _this.shares = (_c = props.shares) !== null && _c !== void 0 ? _c : [];
54
+ _this.reconstructedCek = props.reconstructedCek;
55
+ _this.initiatedBy = props.initiatedBy;
56
+ _this.expiresAt = props.expiresAt;
57
+ _this.purpose = props.purpose;
58
+ _this._tags = (_d = props.tags) !== null && _d !== void 0 ? _d : {};
59
+ }
60
+ return _this;
61
+ }
62
+ ThresholdSessionRecord.prototype.getTags = function () {
63
+ return __assign(__assign({}, this._tags), { sessionId: this.sessionId, vaultId: this.vaultId, docId: this.docId, status: this.status, initiatedBy: this.initiatedBy });
64
+ };
65
+ Object.defineProperty(ThresholdSessionRecord.prototype, "isThresholdMet", {
66
+ /**
67
+ * Check if threshold has been met
68
+ */
69
+ get: function () {
70
+ return this.shares.length >= this.threshold;
71
+ },
72
+ enumerable: false,
73
+ configurable: true
74
+ });
75
+ Object.defineProperty(ThresholdSessionRecord.prototype, "isExpired", {
76
+ /**
77
+ * Check if session has expired
78
+ */
79
+ get: function () {
80
+ if (!this.expiresAt)
81
+ return false;
82
+ return new Date() > this.expiresAt;
83
+ },
84
+ enumerable: false,
85
+ configurable: true
86
+ });
87
+ Object.defineProperty(ThresholdSessionRecord.prototype, "sharesNeeded", {
88
+ /**
89
+ * Get number of shares still needed
90
+ */
91
+ get: function () {
92
+ return Math.max(0, this.threshold - this.shares.length);
93
+ },
94
+ enumerable: false,
95
+ configurable: true
96
+ });
97
+ /**
98
+ * Check if a participant has already provided a share
99
+ */
100
+ ThresholdSessionRecord.prototype.hasShareFrom = function (participantDid) {
101
+ return this.shares.some(function (share) { return share.providedBy === participantDid; });
102
+ };
103
+ /**
104
+ * Add a share to the collection
105
+ */
106
+ ThresholdSessionRecord.prototype.addShare = function (share) {
107
+ // Don't add duplicate shares from same participant
108
+ if (this.hasShareFrom(share.providedBy)) {
109
+ return;
110
+ }
111
+ this.shares.push(share);
112
+ this.updatedAt = new Date();
113
+ };
114
+ ThresholdSessionRecord.type = 'ThresholdSessionRecord';
115
+ return ThresholdSessionRecord;
116
+ }(core_1.BaseRecord));
117
+ exports.ThresholdSessionRecord = ThresholdSessionRecord;