@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,34 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.DecryptAeadError = void 0;
19
+ var VaultError_1 = require("./VaultError");
20
+ /**
21
+ * Error thrown when AEAD decryption fails
22
+ * Spec §11: ERR_DECRYPT_AEAD - AEAD tag failure (AAD tamper or wrong CEK)
23
+ */
24
+ var DecryptAeadError = /** @class */ (function (_super) {
25
+ __extends(DecryptAeadError, _super);
26
+ function DecryptAeadError(message) {
27
+ var _this = _super.call(this, VaultError_1.VaultErrorCode.DECRYPT_AEAD, message) || this;
28
+ _this.name = 'DecryptAeadError';
29
+ Object.setPrototypeOf(_this, DecryptAeadError.prototype);
30
+ return _this;
31
+ }
32
+ return DecryptAeadError;
33
+ }(VaultError_1.VaultError));
34
+ exports.DecryptAeadError = DecryptAeadError;
@@ -0,0 +1,34 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.DecryptKemError = void 0;
19
+ var VaultError_1 = require("./VaultError");
20
+ /**
21
+ * Error thrown when KEM decapsulation fails
22
+ * Spec §11: ERR_DECRYPT_KEM - no recipient wrap decapsulated
23
+ */
24
+ var DecryptKemError = /** @class */ (function (_super) {
25
+ __extends(DecryptKemError, _super);
26
+ function DecryptKemError(message) {
27
+ var _this = _super.call(this, VaultError_1.VaultErrorCode.DECRYPT_KEM, message) || this;
28
+ _this.name = 'DecryptKemError';
29
+ Object.setPrototypeOf(_this, DecryptKemError.prototype);
30
+ return _this;
31
+ }
32
+ return DecryptKemError;
33
+ }(VaultError_1.VaultError));
34
+ exports.DecryptKemError = DecryptKemError;
@@ -0,0 +1,34 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.PolicyError = void 0;
19
+ var VaultError_1 = require("./VaultError");
20
+ /**
21
+ * Error thrown when policy is malformed or inconsistent
22
+ * Spec §11: ERR_POLICY - header policy malformed or inconsistent
23
+ */
24
+ var PolicyError = /** @class */ (function (_super) {
25
+ __extends(PolicyError, _super);
26
+ function PolicyError(message) {
27
+ var _this = _super.call(this, VaultError_1.VaultErrorCode.POLICY, message) || this;
28
+ _this.name = 'PolicyError';
29
+ Object.setPrototypeOf(_this, PolicyError.prototype);
30
+ return _this;
31
+ }
32
+ return PolicyError;
33
+ }(VaultError_1.VaultError));
34
+ exports.PolicyError = PolicyError;
@@ -0,0 +1,77 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.VaultError = exports.VaultErrorCode = void 0;
19
+ /**
20
+ * Vault Error Codes per ZK-Vault Specification §11
21
+ */
22
+ var VaultErrorCode;
23
+ (function (VaultErrorCode) {
24
+ /** Unknown or unsupported suite */
25
+ VaultErrorCode["BAD_SUITE"] = "ERR_BAD_SUITE";
26
+ /** STARK verification failed */
27
+ VaultErrorCode["BAD_PROOF"] = "ERR_BAD_PROOF";
28
+ /** Nonce reused (replay attack detected) */
29
+ VaultErrorCode["REPLAY"] = "ERR_REPLAY";
30
+ /** Proof exceeds maxProofBytes */
31
+ VaultErrorCode["SIZE"] = "ERR_SIZE";
32
+ /** Unknown or stale context */
33
+ VaultErrorCode["CTX"] = "ERR_CTX";
34
+ /** No recipient wrap decapsulated */
35
+ VaultErrorCode["DECRYPT_KEM"] = "ERR_DECRYPT_KEM";
36
+ /** AEAD tag failure (AAD tamper or wrong CEK) */
37
+ VaultErrorCode["DECRYPT_AEAD"] = "ERR_DECRYPT_AEAD";
38
+ /** Header policy malformed or inconsistent */
39
+ VaultErrorCode["POLICY"] = "ERR_POLICY";
40
+ /** Vault not found */
41
+ VaultErrorCode["NOT_FOUND"] = "ERR_NOT_FOUND";
42
+ /** Threshold not met for reconstruction */
43
+ VaultErrorCode["THRESHOLD_NOT_MET"] = "ERR_THRESHOLD_NOT_MET";
44
+ /** Session expired */
45
+ VaultErrorCode["SESSION_EXPIRED"] = "ERR_SESSION_EXPIRED";
46
+ /** Storage operation failed */
47
+ VaultErrorCode["STORAGE"] = "ERR_STORAGE";
48
+ /** Invalid key commitment */
49
+ VaultErrorCode["KEY_COMMITMENT"] = "ERR_KEY_COMMITMENT";
50
+ })(VaultErrorCode || (exports.VaultErrorCode = VaultErrorCode = {}));
51
+ /**
52
+ * Base error class for all vault-related errors
53
+ */
54
+ var VaultError = /** @class */ (function (_super) {
55
+ __extends(VaultError, _super);
56
+ function VaultError(code, message) {
57
+ var _this = _super.call(this, message) || this;
58
+ _this.code = code;
59
+ _this.name = 'VaultError';
60
+ Object.setPrototypeOf(_this, VaultError.prototype);
61
+ return _this;
62
+ }
63
+ /**
64
+ * Check if error matches a specific code
65
+ */
66
+ VaultError.prototype.is = function (code) {
67
+ return this.code === code;
68
+ };
69
+ /**
70
+ * Create a human-readable error message
71
+ */
72
+ VaultError.prototype.toString = function () {
73
+ return "[".concat(this.code, "] ").concat(this.message);
74
+ };
75
+ return VaultError;
76
+ }(Error));
77
+ exports.VaultError = VaultError;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PolicyError = exports.DecryptAeadError = exports.DecryptKemError = exports.BadSuiteError = exports.VaultErrorCode = exports.VaultError = void 0;
4
+ // Base error and codes
5
+ var VaultError_1 = require("./VaultError");
6
+ Object.defineProperty(exports, "VaultError", { enumerable: true, get: function () { return VaultError_1.VaultError; } });
7
+ Object.defineProperty(exports, "VaultErrorCode", { enumerable: true, get: function () { return VaultError_1.VaultErrorCode; } });
8
+ // Specific error types
9
+ var BadSuiteError_1 = require("./BadSuiteError");
10
+ Object.defineProperty(exports, "BadSuiteError", { enumerable: true, get: function () { return BadSuiteError_1.BadSuiteError; } });
11
+ var DecryptKemError_1 = require("./DecryptKemError");
12
+ Object.defineProperty(exports, "DecryptKemError", { enumerable: true, get: function () { return DecryptKemError_1.DecryptKemError; } });
13
+ var DecryptAeadError_1 = require("./DecryptAeadError");
14
+ Object.defineProperty(exports, "DecryptAeadError", { enumerable: true, get: function () { return DecryptAeadError_1.DecryptAeadError; } });
15
+ var PolicyError_1 = require("./PolicyError");
16
+ Object.defineProperty(exports, "PolicyError", { enumerable: true, get: function () { return PolicyError_1.PolicyError; } });
package/build/index.js ADDED
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ /**
3
+ * @credo-ts/vaults
4
+ *
5
+ * Post-quantum encrypted vaults with DIDComm protocol for Credo-TS
6
+ *
7
+ * Features:
8
+ * - Client-side encryption (all crypto happens in the agent)
9
+ * - Passphrase-based encryption (S3 suite with Argon2id)
10
+ * - Post-quantum encryption (P1 suite with ML-KEM-768)
11
+ * - Multiple access policies: passphrase, any-of, all-of, threshold
12
+ * - Local storage via agent wallet
13
+ * - DIDComm messages for P2P vault sharing (Phase 5)
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.buildContext = exports.canonicalAad = exports.generateUuid = exports.fromHex = exports.toHex = exports.fromBase64Url = exports.toBase64Url = exports.constantTimeEq = exports.computeSummary = exports.blake2s256 = exports.sha256 = exports.verifyKeyCommitment = exports.keyCommitment = exports.generateNonceXchacha = exports.generateNonceAesGcm = exports.generateCek = exports.randomBytes = exports.shamirUnwrapAndReconstruct = exports.shamirSplitAndWrap = exports.shamirReconstruct = exports.shamirSplit = exports.deriveSymmetricKid = exports.deriveKid = exports.deriveCek = exports.hkdfJoin = exports.hkdfExpand = exports.kemUnwrapCek = exports.kemWrapCek = exports.kemDecapsulate = exports.kemEncapsulate = exports.kemGenerateKeypair = exports.xchachaDecrypt = exports.xchachaEncrypt = exports.aesGcmDecrypt = exports.aesGcmEncrypt = exports.initVaultCrypto = exports.ThresholdSessionRepository = exports.ThresholdSessionRecord = exports.VaultRepository = exports.VaultRecord = exports.VaultEncryptionService = exports.VaultService = exports.VaultEventTypes = exports.VaultsApi = exports.VaultsModule = void 0;
33
+ // ═══════════════════════════════════════════════════════════════════════════
34
+ // Module & API
35
+ // ═══════════════════════════════════════════════════════════════════════════
36
+ var VaultsModule_1 = require("./VaultsModule");
37
+ Object.defineProperty(exports, "VaultsModule", { enumerable: true, get: function () { return VaultsModule_1.VaultsModule; } });
38
+ var VaultsApi_1 = require("./VaultsApi");
39
+ Object.defineProperty(exports, "VaultsApi", { enumerable: true, get: function () { return VaultsApi_1.VaultsApi; } });
40
+ // ═══════════════════════════════════════════════════════════════════════════
41
+ // Events
42
+ // ═══════════════════════════════════════════════════════════════════════════
43
+ var VaultsEvents_1 = require("./VaultsEvents");
44
+ Object.defineProperty(exports, "VaultEventTypes", { enumerable: true, get: function () { return VaultsEvents_1.VaultEventTypes; } });
45
+ // ═══════════════════════════════════════════════════════════════════════════
46
+ // Models
47
+ // ═══════════════════════════════════════════════════════════════════════════
48
+ __exportStar(require("./models"), exports);
49
+ // ═══════════════════════════════════════════════════════════════════════════
50
+ // Messages (for P2P sharing)
51
+ // ═══════════════════════════════════════════════════════════════════════════
52
+ __exportStar(require("./messages"), exports);
53
+ // ═══════════════════════════════════════════════════════════════════════════
54
+ // Errors
55
+ // ═══════════════════════════════════════════════════════════════════════════
56
+ __exportStar(require("./errors"), exports);
57
+ // ═══════════════════════════════════════════════════════════════════════════
58
+ // Services (for advanced usage)
59
+ // ═══════════════════════════════════════════════════════════════════════════
60
+ var VaultService_1 = require("./services/VaultService");
61
+ Object.defineProperty(exports, "VaultService", { enumerable: true, get: function () { return VaultService_1.VaultService; } });
62
+ var VaultEncryptionService_1 = require("./services/VaultEncryptionService");
63
+ Object.defineProperty(exports, "VaultEncryptionService", { enumerable: true, get: function () { return VaultEncryptionService_1.VaultEncryptionService; } });
64
+ // ═══════════════════════════════════════════════════════════════════════════
65
+ // Repository (for advanced usage)
66
+ // ═══════════════════════════════════════════════════════════════════════════
67
+ var VaultRecord_1 = require("./repository/VaultRecord");
68
+ Object.defineProperty(exports, "VaultRecord", { enumerable: true, get: function () { return VaultRecord_1.VaultRecord; } });
69
+ var VaultRepository_1 = require("./repository/VaultRepository");
70
+ Object.defineProperty(exports, "VaultRepository", { enumerable: true, get: function () { return VaultRepository_1.VaultRepository; } });
71
+ var ThresholdSessionRecord_1 = require("./repository/ThresholdSessionRecord");
72
+ Object.defineProperty(exports, "ThresholdSessionRecord", { enumerable: true, get: function () { return ThresholdSessionRecord_1.ThresholdSessionRecord; } });
73
+ var ThresholdSessionRepository_1 = require("./repository/ThresholdSessionRepository");
74
+ Object.defineProperty(exports, "ThresholdSessionRepository", { enumerable: true, get: function () { return ThresholdSessionRepository_1.ThresholdSessionRepository; } });
75
+ // ═══════════════════════════════════════════════════════════════════════════
76
+ // Crypto (for advanced usage)
77
+ // ═══════════════════════════════════════════════════════════════════════════
78
+ var VaultCrypto_1 = require("./crypto/wasm/VaultCrypto");
79
+ Object.defineProperty(exports, "initVaultCrypto", { enumerable: true, get: function () { return VaultCrypto_1.initVaultCrypto; } });
80
+ // AEAD
81
+ Object.defineProperty(exports, "aesGcmEncrypt", { enumerable: true, get: function () { return VaultCrypto_1.aesGcmEncrypt; } });
82
+ Object.defineProperty(exports, "aesGcmDecrypt", { enumerable: true, get: function () { return VaultCrypto_1.aesGcmDecrypt; } });
83
+ Object.defineProperty(exports, "xchachaEncrypt", { enumerable: true, get: function () { return VaultCrypto_1.xchachaEncrypt; } });
84
+ Object.defineProperty(exports, "xchachaDecrypt", { enumerable: true, get: function () { return VaultCrypto_1.xchachaDecrypt; } });
85
+ // KEM
86
+ Object.defineProperty(exports, "kemGenerateKeypair", { enumerable: true, get: function () { return VaultCrypto_1.kemGenerateKeypair; } });
87
+ Object.defineProperty(exports, "kemEncapsulate", { enumerable: true, get: function () { return VaultCrypto_1.kemEncapsulate; } });
88
+ Object.defineProperty(exports, "kemDecapsulate", { enumerable: true, get: function () { return VaultCrypto_1.kemDecapsulate; } });
89
+ Object.defineProperty(exports, "kemWrapCek", { enumerable: true, get: function () { return VaultCrypto_1.kemWrapCek; } });
90
+ Object.defineProperty(exports, "kemUnwrapCek", { enumerable: true, get: function () { return VaultCrypto_1.kemUnwrapCek; } });
91
+ // KDF
92
+ Object.defineProperty(exports, "hkdfExpand", { enumerable: true, get: function () { return VaultCrypto_1.hkdfExpand; } });
93
+ Object.defineProperty(exports, "hkdfJoin", { enumerable: true, get: function () { return VaultCrypto_1.hkdfJoin; } });
94
+ Object.defineProperty(exports, "deriveCek", { enumerable: true, get: function () { return VaultCrypto_1.deriveCek; } });
95
+ Object.defineProperty(exports, "deriveKid", { enumerable: true, get: function () { return VaultCrypto_1.deriveKid; } });
96
+ Object.defineProperty(exports, "deriveSymmetricKid", { enumerable: true, get: function () { return VaultCrypto_1.deriveSymmetricKid; } });
97
+ // Shamir
98
+ Object.defineProperty(exports, "shamirSplit", { enumerable: true, get: function () { return VaultCrypto_1.shamirSplit; } });
99
+ Object.defineProperty(exports, "shamirReconstruct", { enumerable: true, get: function () { return VaultCrypto_1.shamirReconstruct; } });
100
+ Object.defineProperty(exports, "shamirSplitAndWrap", { enumerable: true, get: function () { return VaultCrypto_1.shamirSplitAndWrap; } });
101
+ Object.defineProperty(exports, "shamirUnwrapAndReconstruct", { enumerable: true, get: function () { return VaultCrypto_1.shamirUnwrapAndReconstruct; } });
102
+ // Utilities
103
+ Object.defineProperty(exports, "randomBytes", { enumerable: true, get: function () { return VaultCrypto_1.randomBytes; } });
104
+ Object.defineProperty(exports, "generateCek", { enumerable: true, get: function () { return VaultCrypto_1.generateCek; } });
105
+ Object.defineProperty(exports, "generateNonceAesGcm", { enumerable: true, get: function () { return VaultCrypto_1.generateNonceAesGcm; } });
106
+ Object.defineProperty(exports, "generateNonceXchacha", { enumerable: true, get: function () { return VaultCrypto_1.generateNonceXchacha; } });
107
+ Object.defineProperty(exports, "keyCommitment", { enumerable: true, get: function () { return VaultCrypto_1.keyCommitment; } });
108
+ Object.defineProperty(exports, "verifyKeyCommitment", { enumerable: true, get: function () { return VaultCrypto_1.verifyKeyCommitment; } });
109
+ Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return VaultCrypto_1.sha256; } });
110
+ Object.defineProperty(exports, "blake2s256", { enumerable: true, get: function () { return VaultCrypto_1.blake2s256; } });
111
+ Object.defineProperty(exports, "computeSummary", { enumerable: true, get: function () { return VaultCrypto_1.computeSummary; } });
112
+ Object.defineProperty(exports, "constantTimeEq", { enumerable: true, get: function () { return VaultCrypto_1.constantTimeEq; } });
113
+ Object.defineProperty(exports, "toBase64Url", { enumerable: true, get: function () { return VaultCrypto_1.toBase64Url; } });
114
+ Object.defineProperty(exports, "fromBase64Url", { enumerable: true, get: function () { return VaultCrypto_1.fromBase64Url; } });
115
+ Object.defineProperty(exports, "toHex", { enumerable: true, get: function () { return VaultCrypto_1.toHex; } });
116
+ Object.defineProperty(exports, "fromHex", { enumerable: true, get: function () { return VaultCrypto_1.fromHex; } });
117
+ Object.defineProperty(exports, "generateUuid", { enumerable: true, get: function () { return VaultCrypto_1.generateUuid; } });
118
+ Object.defineProperty(exports, "canonicalAad", { enumerable: true, get: function () { return VaultCrypto_1.canonicalAad; } });
119
+ Object.defineProperty(exports, "buildContext", { enumerable: true, get: function () { return VaultCrypto_1.buildContext; } });
@@ -0,0 +1,126 @@
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.CreateVaultMessage = 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
+ * Message to notify participants about new vault creation
58
+ *
59
+ * @see https://didcomm.org/vaults/1.0/create-vault
60
+ */
61
+ var CreateVaultMessage = 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 _policy_decorators;
74
+ var _policy_initializers = [];
75
+ var _storageLocation_decorators;
76
+ var _storageLocation_initializers = [];
77
+ var _invitation_decorators;
78
+ var _invitation_initializers = [];
79
+ return _a = /** @class */ (function (_super) {
80
+ __extends(CreateVaultMessage, _super);
81
+ function CreateVaultMessage(options) {
82
+ var _b;
83
+ var _this = _super.call(this) || this;
84
+ _this.type = (__runInitializers(_this, _instanceExtraInitializers), __runInitializers(_this, _type_initializers, _a.type.messageTypeUri));
85
+ _this.vaultId = __runInitializers(_this, _vaultId_initializers, void 0);
86
+ _this.docId = __runInitializers(_this, _docId_initializers, void 0);
87
+ _this.header = __runInitializers(_this, _header_initializers, void 0);
88
+ _this.policy = __runInitializers(_this, _policy_initializers, void 0);
89
+ _this.storageLocation = __runInitializers(_this, _storageLocation_initializers, void 0);
90
+ _this.invitation = __runInitializers(_this, _invitation_initializers, void 0);
91
+ if (options) {
92
+ _this.id = (_b = options.id) !== null && _b !== void 0 ? _b : _this.generateId();
93
+ _this.vaultId = options.vaultId;
94
+ _this.docId = options.docId;
95
+ _this.header = options.header;
96
+ _this.policy = options.policy;
97
+ _this.storageLocation = options.storageLocation;
98
+ _this.invitation = options.invitation;
99
+ }
100
+ return _this;
101
+ }
102
+ return CreateVaultMessage;
103
+ }(_classSuper)),
104
+ (function () {
105
+ var _b;
106
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
107
+ _type_decorators = [(0, core_1.IsValidMessageType)(CreateVaultMessage.type)];
108
+ _vaultId_decorators = [(0, class_transformer_1.Expose)({ name: 'vault_id' }), (0, class_validator_1.IsString)()];
109
+ _docId_decorators = [(0, class_transformer_1.Expose)({ name: 'doc_id' }), (0, class_validator_1.IsString)()];
110
+ _header_decorators = [(0, class_transformer_1.Expose)(), (0, class_validator_1.IsObject)(), (0, class_validator_1.ValidateNested)()];
111
+ _policy_decorators = [(0, class_transformer_1.Expose)(), (0, class_validator_1.IsObject)(), (0, class_validator_1.ValidateNested)()];
112
+ _storageLocation_decorators = [(0, class_transformer_1.Expose)({ name: 'storage_location' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsObject)()];
113
+ _invitation_decorators = [(0, class_transformer_1.Expose)(), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsObject)()];
114
+ __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);
115
+ __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);
116
+ __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);
117
+ __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);
118
+ __esDecorate(null, null, _policy_decorators, { kind: "field", name: "policy", static: false, private: false, access: { has: function (obj) { return "policy" in obj; }, get: function (obj) { return obj.policy; }, set: function (obj, value) { obj.policy = value; } }, metadata: _metadata }, _policy_initializers, _instanceExtraInitializers);
119
+ __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);
120
+ __esDecorate(null, null, _invitation_decorators, { kind: "field", name: "invitation", static: false, private: false, access: { has: function (obj) { return "invitation" in obj; }, get: function (obj) { return obj.invitation; }, set: function (obj, value) { obj.invitation = value; } }, metadata: _metadata }, _invitation_initializers, _instanceExtraInitializers);
121
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
122
+ })(),
123
+ _a.type = (0, core_1.parseMessageType)('https://didcomm.org/vaults/1.0/create-vault'),
124
+ _a;
125
+ }();
126
+ exports.CreateVaultMessage = CreateVaultMessage;
@@ -0,0 +1,114 @@
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.DeleteVaultMessage = 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
+ * Delete vault and notify participants
58
+ *
59
+ * @see https://didcomm.org/vaults/1.0/delete-vault
60
+ */
61
+ var DeleteVaultMessage = 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 _reason_decorators;
72
+ var _reason_initializers = [];
73
+ var _message_decorators;
74
+ var _message_initializers = [];
75
+ return _a = /** @class */ (function (_super) {
76
+ __extends(DeleteVaultMessage, _super);
77
+ function DeleteVaultMessage(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.reason = __runInitializers(_this, _reason_initializers, void 0);
84
+ _this.message = __runInitializers(_this, _message_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.docId = options.docId;
89
+ _this.reason = options.reason;
90
+ _this.message = options.message;
91
+ }
92
+ return _this;
93
+ }
94
+ return DeleteVaultMessage;
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)(DeleteVaultMessage.type)];
100
+ _vaultId_decorators = [(0, class_transformer_1.Expose)({ name: 'vault_id' }), (0, class_validator_1.IsString)()];
101
+ _docId_decorators = [(0, class_transformer_1.Expose)({ name: 'doc_id' }), (0, class_validator_1.IsString)()];
102
+ _reason_decorators = [(0, class_transformer_1.Expose)(), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsIn)(['expired', 'revoked', 'owner-request', 'policy-violation'])];
103
+ _message_decorators = [(0, class_transformer_1.Expose)(), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)()];
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, _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);
107
+ __esDecorate(null, null, _reason_decorators, { kind: "field", name: "reason", static: false, private: false, access: { has: function (obj) { return "reason" in obj; }, get: function (obj) { return obj.reason; }, set: function (obj, value) { obj.reason = value; } }, metadata: _metadata }, _reason_initializers, _instanceExtraInitializers);
108
+ __esDecorate(null, null, _message_decorators, { kind: "field", name: "message", static: false, private: false, access: { has: function (obj) { return "message" in obj; }, get: function (obj) { return obj.message; }, set: function (obj, value) { obj.message = value; } }, metadata: _metadata }, _message_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/delete-vault'),
112
+ _a;
113
+ }();
114
+ exports.DeleteVaultMessage = DeleteVaultMessage;