@enbox/dwn-sdk-js 0.0.3 → 0.0.5
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.
- package/dist/browser.mjs +135 -0
- package/dist/browser.mjs.map +7 -0
- package/dist/esm/generated/precompiled-validators.js +640 -510
- package/dist/esm/generated/precompiled-validators.js.map +1 -1
- package/dist/esm/src/core/auth.js +6 -1
- package/dist/esm/src/core/auth.js.map +1 -1
- package/dist/esm/src/core/dwn-error.js +3 -0
- package/dist/esm/src/core/dwn-error.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization.js +4 -0
- package/dist/esm/src/core/protocol-authorization.js.map +1 -1
- package/dist/esm/src/dwn.js +14 -0
- package/dist/esm/src/dwn.js.map +1 -1
- package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
- package/dist/esm/src/handlers/records-delete.js +13 -0
- package/dist/esm/src/handlers/records-delete.js.map +1 -1
- package/dist/esm/src/handlers/records-subscribe.js +121 -66
- package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/records-write.js +1 -1
- package/dist/esm/src/handlers/records-write.js.map +1 -1
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
- package/dist/esm/src/interfaces/records-delete.js +1 -0
- package/dist/esm/src/interfaces/records-delete.js.map +1 -1
- package/dist/esm/src/interfaces/records-subscribe.js +2 -0
- package/dist/esm/src/interfaces/records-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/records-write.js +28 -45
- package/dist/esm/src/interfaces/records-write.js.map +1 -1
- package/dist/esm/src/jose/jws/general/verifier.js +9 -1
- package/dist/esm/src/jose/jws/general/verifier.js.map +1 -1
- package/dist/esm/src/smt/smt-utils.js +1 -1
- package/dist/esm/src/smt/smt-utils.js.map +1 -1
- package/dist/esm/src/types/records-types.js.map +1 -1
- package/dist/esm/src/utils/encryption.js +221 -78
- package/dist/esm/src/utils/encryption.js.map +1 -1
- package/dist/esm/src/utils/hd-key.js +6 -7
- package/dist/esm/src/utils/hd-key.js.map +1 -1
- package/dist/esm/src/utils/protocols.js +12 -10
- package/dist/esm/src/utils/protocols.js.map +1 -1
- package/dist/esm/src/utils/records.js +33 -44
- package/dist/esm/src/utils/records.js.map +1 -1
- package/dist/esm/tests/features/protocol-composition.spec.js +26 -21
- package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
- package/dist/esm/tests/features/records-tags.spec.js +5 -5
- package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-delete.spec.js +120 -2
- package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-read.spec.js +25 -26
- package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-subscribe.spec.js +103 -0
- package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-write.spec.js +124 -10
- package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/messages-get.spec.js +3 -2
- package/dist/esm/tests/interfaces/messages-get.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-write.spec.js +43 -34
- package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +4 -4
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption-callbacks.spec.js +21 -24
- package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption.spec.js +69 -66
- package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
- package/dist/esm/tests/utils/filters.spec.js +1 -0
- package/dist/esm/tests/utils/filters.spec.js.map +1 -1
- package/dist/esm/tests/utils/test-data-generator.js +28 -7
- package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js +1 -1
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js.map +1 -1
- package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
- package/dist/types/src/core/auth.d.ts +3 -1
- package/dist/types/src/core/auth.d.ts.map +1 -1
- package/dist/types/src/core/dwn-error.d.ts +3 -0
- package/dist/types/src/core/dwn-error.d.ts.map +1 -1
- package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
- package/dist/types/src/dwn.d.ts +12 -0
- package/dist/types/src/dwn.d.ts.map +1 -1
- package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -1
- package/dist/types/src/handlers/records-delete.d.ts.map +1 -1
- package/dist/types/src/handlers/records-subscribe.d.ts +17 -28
- package/dist/types/src/handlers/records-subscribe.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +4 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-delete.d.ts +4 -0
- package/dist/types/src/interfaces/records-delete.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-subscribe.d.ts +4 -1
- package/dist/types/src/interfaces/records-subscribe.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-write.d.ts +23 -53
- package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
- package/dist/types/src/jose/jws/general/verifier.d.ts.map +1 -1
- package/dist/types/src/types/encryption-types.d.ts +9 -8
- package/dist/types/src/types/encryption-types.d.ts.map +1 -1
- package/dist/types/src/types/protocols-types.d.ts +65 -16
- package/dist/types/src/types/protocols-types.d.ts.map +1 -1
- package/dist/types/src/types/records-types.d.ts +7 -26
- package/dist/types/src/types/records-types.d.ts.map +1 -1
- package/dist/types/src/utils/encryption.d.ts +157 -28
- package/dist/types/src/utils/encryption.d.ts.map +1 -1
- package/dist/types/src/utils/hd-key.d.ts +2 -3
- package/dist/types/src/utils/hd-key.d.ts.map +1 -1
- package/dist/types/src/utils/protocols.d.ts.map +1 -1
- package/dist/types/src/utils/records.d.ts +3 -4
- package/dist/types/src/utils/records.d.ts.map +1 -1
- package/dist/types/tests/features/protocol-composition.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-delete.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-read.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-subscribe.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-write.spec.d.ts.map +1 -1
- package/dist/types/tests/utils/test-data-generator.d.ts +7 -0
- package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -1
- package/package.json +10 -21
- package/src/core/auth.ts +12 -1
- package/src/core/dwn-error.ts +3 -0
- package/src/core/protocol-authorization.ts +8 -0
- package/src/dwn.ts +15 -0
- package/src/handlers/protocols-configure.ts +4 -4
- package/src/handlers/records-delete.ts +12 -0
- package/src/handlers/records-subscribe.ts +174 -75
- package/src/handlers/records-write.ts +1 -1
- package/src/index.ts +4 -4
- package/src/interfaces/protocols-configure.ts +5 -5
- package/src/interfaces/records-delete.ts +9 -3
- package/src/interfaces/records-subscribe.ts +6 -1
- package/src/interfaces/records-write.ts +33 -105
- package/src/jose/jws/general/verifier.ts +11 -1
- package/src/smt/smt-utils.ts +1 -1
- package/src/types/encryption-types.ts +9 -8
- package/src/types/protocols-types.ts +72 -18
- package/src/types/records-types.ts +7 -29
- package/src/utils/encryption.ts +346 -88
- package/src/utils/hd-key.ts +9 -10
- package/src/utils/protocols.ts +15 -13
- package/src/utils/records.ts +47 -55
- package/dist/bundles/dwn.js +0 -151
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-types.d.ts","sourceRoot":"","sources":["../../../../src/types/records-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"records-types.d.ts","sourceRoot":"","sources":["../../../../src/types/records-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM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EAAE,OAAO,CAAA;CACf,CAAC"}
|
|
@@ -1,43 +1,172 @@
|
|
|
1
|
+
import type { Jwk } from '@enbox/crypto';
|
|
2
|
+
import type { PublicKeyJwk } from '../types/jose-types.js';
|
|
3
|
+
import { KeyDerivationScheme } from './hd-key.js';
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
5
|
+
* Content encryption algorithms supported by the DWN.
|
|
6
|
+
* Both are AEAD (Authenticated Encryption with Associated Data) ciphers.
|
|
7
|
+
*/
|
|
8
|
+
export declare enum ContentEncryptionAlgorithm {
|
|
9
|
+
/** AES-256 in Galois/Counter Mode. NIST-approved, hardware-accelerated. 96-bit nonce. */
|
|
10
|
+
A256GCM = "A256GCM",
|
|
11
|
+
/** XChaCha20-Poly1305. 192-bit nonce (safe to randomize). Constant-time. */
|
|
12
|
+
XC20P = "XC20P"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Key agreement algorithm used by the DWN.
|
|
16
|
+
* ECDH-ES with X25519 key agreement and AES-256 Key Wrap.
|
|
17
|
+
*/
|
|
18
|
+
export declare enum KeyAgreementAlgorithm {
|
|
19
|
+
EcdhEsA256kw = "ECDH-ES+A256KW"
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* JWE Protected Header for DWN encryption.
|
|
23
|
+
*/
|
|
24
|
+
export type JweProtectedHeader = {
|
|
25
|
+
alg: KeyAgreementAlgorithm;
|
|
26
|
+
enc: ContentEncryptionAlgorithm;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Per-recipient header in a JWE General JSON Serialization.
|
|
30
|
+
*/
|
|
31
|
+
export type JweRecipientHeader = {
|
|
32
|
+
/** Fully qualified key ID of the root key used in key derivation (e.g. did:example:alice#enc). */
|
|
33
|
+
kid: string;
|
|
34
|
+
/** Ephemeral X25519 public key used for ECDH key agreement. */
|
|
35
|
+
epk: PublicKeyJwk;
|
|
36
|
+
/** Key derivation scheme used to derive the recipient's key. */
|
|
37
|
+
derivationScheme: KeyDerivationScheme;
|
|
38
|
+
/** Derived public key. Present when derivationScheme is 'protocolContext'. */
|
|
39
|
+
derivedPublicKey?: PublicKeyJwk;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A single recipient entry in the JWE General JSON Serialization.
|
|
43
|
+
*/
|
|
44
|
+
export type JweRecipient = {
|
|
45
|
+
header: JweRecipientHeader;
|
|
46
|
+
encrypted_key: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* JWE-inspired structure used as the `encryption` property on RecordsWrite messages.
|
|
50
|
+
*
|
|
51
|
+
* This follows the JWE General JSON Serialization (RFC 7516 Section 7.2) with one adaptation:
|
|
52
|
+
* the `ciphertext` is NOT included here because the encrypted record data is stored separately
|
|
53
|
+
* in the DataStore (or as inline `encodedData`). Only the key wrapping metadata, IV, and
|
|
54
|
+
* authentication tag are stored in this structure.
|
|
55
|
+
*/
|
|
56
|
+
export type JweEncryption = {
|
|
57
|
+
/** Base64url-encoded JWE Protected Header. */
|
|
58
|
+
protected: string;
|
|
59
|
+
/** Base64url-encoded initialization vector for content encryption. */
|
|
60
|
+
iv: string;
|
|
61
|
+
/** Base64url-encoded authentication tag from the AEAD cipher. */
|
|
62
|
+
tag: string;
|
|
63
|
+
/** Array of recipient entries, one per recipient or derivation path. */
|
|
64
|
+
recipients: JweRecipient[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Input describing how to encrypt a key for a single recipient.
|
|
68
|
+
*/
|
|
69
|
+
export type KeyEncryptionInput = {
|
|
70
|
+
/** Fully qualified key ID of the recipient's root encryption key. */
|
|
71
|
+
publicKeyId: string;
|
|
72
|
+
/** The recipient's derived X25519 public key. */
|
|
73
|
+
publicKey: PublicKeyJwk;
|
|
74
|
+
/** Key derivation scheme. */
|
|
75
|
+
derivationScheme: KeyDerivationScheme;
|
|
76
|
+
/** Algorithm for key agreement. Defaults to ECDH-ES+A256KW. */
|
|
77
|
+
algorithm?: KeyAgreementAlgorithm;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Input describing how to encrypt record data.
|
|
81
|
+
*/
|
|
82
|
+
export type EncryptionInput = {
|
|
83
|
+
/** Content encryption algorithm. Defaults to A256GCM. */
|
|
84
|
+
algorithm?: ContentEncryptionAlgorithm;
|
|
85
|
+
/** The Content Encryption Key (CEK). Must be 32 bytes (256-bit). */
|
|
86
|
+
key: Uint8Array;
|
|
87
|
+
/** Initialization vector. 12 bytes for A256GCM, 24 bytes for XC20P. */
|
|
88
|
+
initializationVector: Uint8Array;
|
|
89
|
+
/** Authentication tag from the AEAD encryption of the record data. */
|
|
90
|
+
authenticationTag: Uint8Array;
|
|
91
|
+
/** Recipient key encryption inputs. */
|
|
92
|
+
keyEncryptionInputs: KeyEncryptionInput[];
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Payload passed to a KeyDecrypter callback for JWE-based key unwrapping.
|
|
96
|
+
*/
|
|
97
|
+
export type JweKeyUnwrapPayload = {
|
|
98
|
+
/** The wrapped CEK bytes. */
|
|
99
|
+
encryptedKey: Uint8Array;
|
|
100
|
+
/** The ephemeral X25519 public key used for ECDH. */
|
|
101
|
+
ephemeralPublicKey: PublicKeyJwk;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Utility class for DWN encryption operations using JWE (RFC 7516).
|
|
105
|
+
* Uses ECDH-ES+A256KW key agreement with X25519 and either AES-256-GCM or XChaCha20-Poly1305
|
|
106
|
+
* for authenticated content encryption.
|
|
3
107
|
*/
|
|
4
108
|
export declare class Encryption {
|
|
5
109
|
/**
|
|
6
|
-
* Encrypts
|
|
110
|
+
* Encrypts data using an AEAD cipher (A256GCM or XC20P).
|
|
111
|
+
* Returns ciphertext with the authentication tag appended.
|
|
7
112
|
*/
|
|
8
|
-
static
|
|
113
|
+
static aeadEncrypt(algorithm: ContentEncryptionAlgorithm, keyBytes: Uint8Array, iv: Uint8Array, plaintext: Uint8Array): Promise<{
|
|
114
|
+
ciphertext: Uint8Array;
|
|
115
|
+
tag: Uint8Array;
|
|
116
|
+
}>;
|
|
9
117
|
/**
|
|
10
|
-
* Decrypts
|
|
118
|
+
* Decrypts data using an AEAD cipher (A256GCM or XC20P).
|
|
119
|
+
* Expects ciphertext and tag as separate inputs.
|
|
11
120
|
*/
|
|
12
|
-
static
|
|
121
|
+
static aeadDecrypt(algorithm: ContentEncryptionAlgorithm, keyBytes: Uint8Array, iv: Uint8Array, ciphertext: Uint8Array, tag: Uint8Array): Promise<Uint8Array>;
|
|
13
122
|
/**
|
|
14
|
-
* Encrypts
|
|
15
|
-
*
|
|
16
|
-
* and
|
|
123
|
+
* Encrypts data as a ReadableStream using an AEAD cipher.
|
|
124
|
+
* Collects all chunks, encrypts, and returns a new stream of ciphertext || tag.
|
|
125
|
+
* The iv and tag are NOT embedded in the stream — they are stored in the JWE structure.
|
|
17
126
|
*/
|
|
18
|
-
static
|
|
127
|
+
static aeadEncryptStream(algorithm: ContentEncryptionAlgorithm, keyBytes: Uint8Array, iv: Uint8Array, plaintextStream: ReadableStream<Uint8Array>): Promise<{
|
|
128
|
+
ciphertextStream: ReadableStream<Uint8Array>;
|
|
129
|
+
tag: Uint8Array;
|
|
130
|
+
}>;
|
|
19
131
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* and AES-GCM for the symmetric encryption and MAC algorithms.
|
|
132
|
+
* Decrypts a ciphertext stream using an AEAD cipher.
|
|
133
|
+
* Returns a ReadableStream of plaintext.
|
|
23
134
|
*/
|
|
24
|
-
static
|
|
135
|
+
static aeadDecryptStream(algorithm: ContentEncryptionAlgorithm, keyBytes: Uint8Array, iv: Uint8Array, ciphertextStream: ReadableStream<Uint8Array>, tag: Uint8Array): Promise<ReadableStream<Uint8Array>>;
|
|
25
136
|
/**
|
|
26
|
-
*
|
|
137
|
+
* Performs ECDH-ES key agreement with X25519 and wraps the CEK using AES-256 Key Wrap.
|
|
138
|
+
*
|
|
139
|
+
* @param ephemeralPrivateKey - Ephemeral X25519 private key (JWK).
|
|
140
|
+
* @param recipientPublicKey - Recipient's X25519 public key (JWK).
|
|
141
|
+
* @param cek - The Content Encryption Key to wrap.
|
|
142
|
+
* @returns The wrapped CEK bytes.
|
|
27
143
|
*/
|
|
28
|
-
static
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
144
|
+
static ecdhEsWrapKey(ephemeralPrivateKey: Jwk, recipientPublicKey: Jwk, cek: Uint8Array): Promise<Uint8Array>;
|
|
145
|
+
/**
|
|
146
|
+
* Performs ECDH-ES key agreement with X25519 and unwraps the CEK using AES-256 Key Unwrap.
|
|
147
|
+
*
|
|
148
|
+
* @param recipientPrivateKey - Recipient's X25519 private key (JWK).
|
|
149
|
+
* @param ephemeralPublicKey - Ephemeral X25519 public key from the JWE recipient header (JWK).
|
|
150
|
+
* @param wrappedKey - The wrapped CEK bytes.
|
|
151
|
+
* @returns The unwrapped CEK bytes.
|
|
152
|
+
*/
|
|
153
|
+
static ecdhEsUnwrapKey(recipientPrivateKey: Jwk, ephemeralPublicKey: Jwk, wrappedKey: Uint8Array): Promise<Uint8Array>;
|
|
154
|
+
/**
|
|
155
|
+
* Builds a JWE encryption property structure from encryption input.
|
|
156
|
+
* The ciphertext (encrypted record data) is stored separately in the DataStore,
|
|
157
|
+
* so only the key wrapping metadata, IV, and authentication tag are included here.
|
|
158
|
+
*
|
|
159
|
+
* @param encryptionInput - Describes the CEK, IV, and recipient key encryption inputs.
|
|
160
|
+
* @param tag - The authentication tag produced by the AEAD cipher during data encryption.
|
|
161
|
+
*/
|
|
162
|
+
static buildJwe(encryptionInput: EncryptionInput, tag: Uint8Array): Promise<JweEncryption>;
|
|
163
|
+
/**
|
|
164
|
+
* Parses the JWE protected header from its base64url encoding.
|
|
165
|
+
*/
|
|
166
|
+
static parseProtectedHeader(protectedBase64url: string): JweProtectedHeader;
|
|
167
|
+
/**
|
|
168
|
+
* Reads a ReadableStream to completion and returns all bytes concatenated.
|
|
169
|
+
*/
|
|
170
|
+
private static readStream;
|
|
42
171
|
}
|
|
43
172
|
//# sourceMappingURL=encryption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../../src/utils/encryption.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../../src/utils/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD;;;GAGG;AACH,oBAAY,0BAA0B;IACpC,yFAAyF;IACzF,OAAO,YAAY;IACnB,4EAA4E;IAC5E,KAAK,UAAU;CAChB;AAED;;;GAGG;AACH,oBAAY,qBAAqB;IAC/B,YAAY,mBAAmB;CAChC;AAQD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,qBAAqB,CAAC;IAC3B,GAAG,EAAE,0BAA0B,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,kGAAkG;IAClG,GAAG,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,GAAG,EAAE,YAAY,CAAC;IAClB,gEAAgE;IAChE,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,YAAY,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,MAA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
|
|
26
|
+
* Uses X25519 keys for encryption key derivation.
|
|
27
27
|
*/
|
|
28
28
|
static derivePrivateKey(ancestorKey: DerivedPrivateJwk, subDerivationPath: string[]): Promise<DerivedPrivateJwk>;
|
|
29
29
|
/**
|
|
30
30
|
* Derives a descendant public key from an ancestor private key.
|
|
31
|
-
*
|
|
31
|
+
* Uses X25519 keys for encryption key derivation.
|
|
32
32
|
*/
|
|
33
33
|
static derivePublicKey(ancestorKey: DerivedPrivateJwk, subDerivationPath: string[]): Promise<PublicKeyJwk>;
|
|
34
34
|
/**
|
|
@@ -37,7 +37,6 @@ export declare class HdKey {
|
|
|
37
37
|
static derivePrivateKeyBytes(privateKey: Uint8Array, relativePath: string[]): Promise<Uint8Array>;
|
|
38
38
|
/**
|
|
39
39
|
* Derives a key using HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as defined in RFC 5869.
|
|
40
|
-
* TODO: Consolidate HKDF implementation and usage with web5-js - https://github.com/enboxorg/enbox/issues/742
|
|
41
40
|
*/
|
|
42
41
|
static deriveKeyUsingHkdf(params: {
|
|
43
42
|
hashAlgorithm: 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hd-key.d.ts","sourceRoot":"","sources":["../../../../src/utils/hd-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAO1E,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,WAAW,gBAAgB;IAC3B,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAE7B;;OAEG;IACH,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,EAAE,aAAa,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH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AiB9G;;OAEG;WACiB,kBAAkB,CAAC,MAAM,EAAE;QAC7C,aAAa,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;QACjD,kBAAkB,EAAE,UAAU,CAAC;QAC/B,IAAI,EAAE,UAAU,CAAC;QACjB,gBAAgB,EAAE,MAAM,CAAA;KACzB,GAAG,OAAO,CAAC,UAAU,CAAC;IAyBvB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;CAKzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../../../../src/utils/protocols.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../../../../src/utils/protocols.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAKvF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAU/E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,GAAG,eAAe,GAAG,SAAS,CAcjI;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB;;;;;;;;;;;OAWG;WACiB,mCAAmC,CACrD,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IAE9B;;;OAGG;WACiB,mCAAmC,CACrD,kBAAkB,EAAE,kBAAkB,EACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,kBAAkB,CAAC;CAkF/B"}
|
|
@@ -17,11 +17,11 @@ export declare class Records {
|
|
|
17
17
|
* Decrypts the encrypted data in a message reply.
|
|
18
18
|
*
|
|
19
19
|
* Overload 1 (callback-based): Accepts a KeyDecrypter that performs
|
|
20
|
-
* HKDF derivation +
|
|
20
|
+
* HKDF derivation + ECDH-ES key agreement + AES Key Unwrap internally.
|
|
21
21
|
*/
|
|
22
22
|
static decrypt(recordsWrite: RecordsWriteMessage, keyDecrypter: KeyDecrypter, cipherStream: ReadableStream<Uint8Array>): Promise<ReadableStream<Uint8Array>>;
|
|
23
23
|
/**
|
|
24
|
-
* Overload 2 (raw-key
|
|
24
|
+
* Overload 2 (raw-key): Takes DerivedPrivateJwk directly.
|
|
25
25
|
* @param ancestorPrivateKey Any ancestor private key in the key derivation path.
|
|
26
26
|
*/
|
|
27
27
|
static decrypt(recordsWrite: RecordsWriteMessage, ancestorPrivateKey: DerivedPrivateJwk, cipherStream: ReadableStream<Uint8Array>): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -59,8 +59,7 @@ export declare class Records {
|
|
|
59
59
|
static constructKeyDerivationPathUsingSchemasScheme(schema: string | undefined): string[];
|
|
60
60
|
/**
|
|
61
61
|
* Derives a descendant private key given an ancestor private key and the full absolute derivation path.
|
|
62
|
-
*
|
|
63
|
-
* so we will only derive SECP256K1 key without additional conditional checks
|
|
62
|
+
* Uses X25519 keys for encryption key derivation.
|
|
64
63
|
*/
|
|
65
64
|
static derivePrivateKey(ancestorPrivateKey: DerivedPrivateJwk, fullDescendantDerivationPath: string[]): Promise<Uint8Array>;
|
|
66
65
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../../src/utils/records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../../src/utils/records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACtG,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnQ,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAYrD,OAAO,EAAS,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGzD;;GAEG;AACH,qBAAa,OAAO;IAElB;;OAEG;WACW,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,IAAI,mBAAmB;IAQrF;;;;;OAKG;WACiB,OAAO,CACzB,YAAY,EAAE,mBAAmB,EACjC,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,cAAc,CAAC,UAAU,CAAC,GACvC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAEtC;;;OAGG;WACiB,OAAO,CACzB,YAAY,EAAE,mBAAmB,EACjC,kBAAkB,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AAM,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;IA0D/E;;;;;;OAMG;WACiB,0CAA0C,CAC5D,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,oBAAoB,GAAG,uBAAuB,EAC9I,sBAAsB,EAAE,uBAAuB,GAAG,SAAS,EAC3D,qBAAqB,CAAC,EAAE,uBAAuB,GAAG,SAAS,GAC1D,OAAO,CAAC,IAAI,CAAC;IAwFhB;;;;;;OAMG;WACW,eAAe,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW;IAmB/D;;OAEG;WACW,uBAAuB,CAAC,gBAAgB,EAAE,uBAAuB,GAAG,OAAO;IAIzF;;OAEG;WACW,8BAA8B,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAK5E;;OAEG;WACW,gCAAgC,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAQ9E;;OAEG;WACW,6BAA6B,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO;IAmBlJ;;;;;;OAMG;IACH,MAAM,CAAC,qCAAqC,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAQ/F;;;;;;OAMG;IACH,MAAM,CAAC,kCAAkC,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;CAO1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-composition.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/protocol-composition.spec.ts"],"names":[],"mappings":"AAyBA;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"protocol-composition.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/protocol-composition.spec.ts"],"names":[],"mappings":"AAyBA;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAo1D9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-delete.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-delete.spec.ts"],"names":[],"mappings":"AAmCA,wBAAgB,wBAAwB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"records-delete.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-delete.spec.ts"],"names":[],"mappings":"AAmCA,wBAAgB,wBAAwB,IAAI,IAAI,CAo4B/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-read.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-read.spec.ts"],"names":[],"mappings":"AAgCA,wBAAgB,sBAAsB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"records-read.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-read.spec.ts"],"names":[],"mappings":"AAgCA,wBAAgB,sBAAsB,IAAI,IAAI,CAwwE7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-subscribe.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-subscribe.spec.ts"],"names":[],"mappings":"AAwBA,wBAAgB,2BAA2B,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"records-subscribe.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-subscribe.spec.ts"],"names":[],"mappings":"AAwBA,wBAAgB,2BAA2B,IAAI,IAAI,CA+lClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-write.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-write.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"records-write.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-write.spec.ts"],"names":[],"mappings":"AAkDA,wBAAgB,uBAAuB,IAAI,IAAI,CAs4I9C"}
|
|
@@ -25,6 +25,11 @@ export type Persona = {
|
|
|
25
25
|
publicJwk: PublicKeyJwk;
|
|
26
26
|
privateJwk: PrivateKeyJwk;
|
|
27
27
|
};
|
|
28
|
+
/** X25519 key pair for encryption (key agreement). Separate from the signing key pair. */
|
|
29
|
+
encryptionKeyPair: {
|
|
30
|
+
publicJwk: PublicKeyJwk;
|
|
31
|
+
privateJwk: PrivateKeyJwk;
|
|
32
|
+
};
|
|
28
33
|
signer: MessageSigner;
|
|
29
34
|
};
|
|
30
35
|
export type GenerateProtocolsConfigureInput = {
|
|
@@ -149,6 +154,8 @@ export type GenerateRecordsSubscribeInput = {
|
|
|
149
154
|
author?: Persona;
|
|
150
155
|
messageTimestamp?: string;
|
|
151
156
|
filter?: RecordsFilter;
|
|
157
|
+
dateSort?: DateSort;
|
|
158
|
+
pagination?: Pagination;
|
|
152
159
|
protocolRole?: string;
|
|
153
160
|
};
|
|
154
161
|
export type GenerateRecordsSubscribeOutput = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-data-generator.d.ts","sourceRoot":"","sources":["../../../../tests/utils/test-data-generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAU/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACvF,OAAO,KAAK,EAAqB,eAAe,EAA2C,MAAM,uCAAuC,CAAC;AACzI,OAAO,KAAK,EAAE,8BAA8B,EAAE,QAAQ,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,aAAa,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAClM,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AACvH,OAAO,KAAK,EAAE,oBAAoB,EAAE,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B,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAmB/G;;OAEG;WACW,qBAAqB,IAAI,kBAAkB;IAMzD;;OAEG;WACW,8BAA8B,IAAI,UAAU;IAU1D;;OAEG;WACiB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAQ5D;;OAEG;WACW,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAYlD;;OAEG;WACW,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;IASrD;;OAEG;WACiB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAO1D;;;;OAIG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIzD;;;;OAIG;WACW,eAAe,CAAC,OAAO,CAAC,EAAE;QACtC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KACzI,GAAG,MAAM;IAcV;;OAEG;WACW,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB;IAiB9E;;OAEG;WACiB,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC;CAgC9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enbox/dwn-sdk-js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "A reference implementation of https://identity.foundation/decentralized-web-node/spec/",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -70,11 +70,10 @@
|
|
|
70
70
|
"@noble/curves": "1.4.2",
|
|
71
71
|
"@noble/ed25519": "2.0.0",
|
|
72
72
|
"@noble/secp256k1": "2.0.0",
|
|
73
|
-
"@enbox/crypto": "0.0.
|
|
74
|
-
"@enbox/dids": "0.0.
|
|
73
|
+
"@enbox/crypto": "0.0.3",
|
|
74
|
+
"@enbox/dids": "0.0.3",
|
|
75
75
|
"abstract-level": "1.0.3",
|
|
76
76
|
"ajv": "8.18.0",
|
|
77
|
-
"eciesjs": "0.4.5",
|
|
78
77
|
"interface-blockstore": "5.2.3",
|
|
79
78
|
"interface-store": "5.1.2",
|
|
80
79
|
"ipfs-unixfs-exporter": "13.1.5",
|
|
@@ -89,7 +88,6 @@
|
|
|
89
88
|
"devDependencies": {
|
|
90
89
|
"blockstore-core": "4.2.0",
|
|
91
90
|
"@types/flat": "^5.0.2",
|
|
92
|
-
"@types/karma": "^6.3.3",
|
|
93
91
|
"@types/lodash": "4.14.179",
|
|
94
92
|
"@types/ms": "0.7.31",
|
|
95
93
|
"@types/node": "20.14.8",
|
|
@@ -99,31 +97,22 @@
|
|
|
99
97
|
"@stylistic/eslint-plugin": "2.13.0",
|
|
100
98
|
"@typescript-eslint/eslint-plugin": "8.32.1",
|
|
101
99
|
"@typescript-eslint/parser": "8.32.1",
|
|
100
|
+
"@vitest/browser-playwright": "4.0.18",
|
|
101
|
+
"@vitest/coverage-istanbul": "4.0.18",
|
|
102
102
|
"bun-types": "^1.2.4",
|
|
103
103
|
"dependency-cruiser": "^16.3.7",
|
|
104
|
-
"esbuild": "0.16.17",
|
|
105
104
|
"eslint": "9.7.0",
|
|
106
105
|
"eslint-plugin-todo-plz": "1.3.0",
|
|
107
|
-
"istanbul-badges-readme": "1.8.1",
|
|
108
|
-
"karma": "^6.4.4",
|
|
109
|
-
"karma-chai": "0.1.0",
|
|
110
|
-
"karma-chrome-launcher": "3.1.1",
|
|
111
|
-
"karma-esbuild": "2.2.5",
|
|
112
|
-
"karma-firefox-launcher": "2.1.2",
|
|
113
|
-
"karma-mocha": "2.0.1",
|
|
114
|
-
"karma-mocha-reporter": "2.2.5",
|
|
115
|
-
"karma-webkit-launcher": "2.1.0",
|
|
116
106
|
"license-report": "6.3.0",
|
|
117
107
|
"mkdirp": "1.0.4",
|
|
118
108
|
"mockdate": "3.0.5",
|
|
119
109
|
"ms": "2.1.3",
|
|
120
|
-
"node-stdlib-browser": "1.2.0",
|
|
121
|
-
"playwright": "^1.44.0",
|
|
122
110
|
"rimraf": "^3.0.2",
|
|
123
111
|
"search-index": "3.4.0",
|
|
124
112
|
"sinon": "18.0.1",
|
|
125
113
|
"typescript": "5.5.4",
|
|
126
|
-
"uuid": "8.3.2"
|
|
114
|
+
"uuid": "8.3.2",
|
|
115
|
+
"vitest": "4.0.18"
|
|
127
116
|
},
|
|
128
117
|
"overrides": {
|
|
129
118
|
"cookie": "^0.7.1"
|
|
@@ -131,7 +120,7 @@
|
|
|
131
120
|
"scripts": {
|
|
132
121
|
"build:esm": "tsc",
|
|
133
122
|
"build": "bun run clean && bun run compile-validators && bun run build:esm && bun run bundle",
|
|
134
|
-
"bundle": "bun
|
|
123
|
+
"bundle": "rimraf dist/browser.mjs && bun ../../build/browser-bundle.js --node-shims --metafile",
|
|
135
124
|
"clean": "rimraf dist && rimraf generated/*",
|
|
136
125
|
"compile-validators": "bun ./build/compile-validators.js",
|
|
137
126
|
"lint": "eslint . --max-warnings 0",
|
|
@@ -140,8 +129,8 @@
|
|
|
140
129
|
"test:node": "bun run compile-validators && bun test .spec.ts",
|
|
141
130
|
"test:node:coverage": "bun run compile-validators && bun test --coverage --coverage-reporter=text --coverage-reporter=lcov --coverage-dir=coverage .spec.ts",
|
|
142
131
|
"test:node-grep": "bun run compile-validators && bun test .spec.ts -t $GREP",
|
|
143
|
-
"test:browser": "bun run compile-validators && bunx
|
|
144
|
-
"test:browser
|
|
132
|
+
"test:browser": "bun run compile-validators && bunx --bun vitest --config vitest.browser.config.ts --run",
|
|
133
|
+
"test:browser:coverage": "bun run compile-validators && bunx --bun vitest --config vitest.browser.config.ts --run --coverage --coverage.provider=istanbul --coverage.reportsDirectory=./coverage-browser",
|
|
145
134
|
"license-check": "license-report --only=prod > license-report.json && bun ./build/license-check.cjs",
|
|
146
135
|
"publish:unstable": "./build/publish-unstable.sh"
|
|
147
136
|
}
|
package/src/core/auth.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AuthorizationModel } from '../types/message-types.js';
|
|
2
2
|
import type { DidResolver } from '@enbox/dids';
|
|
3
|
+
import type { GeneralJws } from '../types/jws-types.js';
|
|
3
4
|
|
|
4
5
|
import { GeneralJwsVerifier } from '../jose/jws/general/verifier.js';
|
|
5
6
|
import { RecordsWrite } from '../interfaces/records-write.js';
|
|
@@ -7,10 +8,15 @@ import { DwnError, DwnErrorCode } from './dwn-error.js';
|
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Verifies all the signature(s) within the authorization property.
|
|
11
|
+
* If an attestation JWS is provided, its signatures are also cryptographically verified.
|
|
10
12
|
*
|
|
11
13
|
* @throws {Error} if fails authentication
|
|
12
14
|
*/
|
|
13
|
-
export async function authenticate(
|
|
15
|
+
export async function authenticate(
|
|
16
|
+
authorizationModel: AuthorizationModel | undefined,
|
|
17
|
+
didResolver: DidResolver,
|
|
18
|
+
attestation?: GeneralJws
|
|
19
|
+
): Promise<void> {
|
|
14
20
|
|
|
15
21
|
if (authorizationModel === undefined) {
|
|
16
22
|
throw new DwnError(DwnErrorCode.AuthenticateJwsMissing, 'Missing JWS.');
|
|
@@ -33,4 +39,9 @@ export async function authenticate(authorizationModel: AuthorizationModel | unde
|
|
|
33
39
|
const ownerDelegatedGrant = await RecordsWrite.parse(authorizationModel.ownerDelegatedGrant);
|
|
34
40
|
await GeneralJwsVerifier.verifySignatures(ownerDelegatedGrant.message.authorization.signature, didResolver);
|
|
35
41
|
}
|
|
42
|
+
|
|
43
|
+
// cryptographically verify attestation signature(s) if present
|
|
44
|
+
if (attestation !== undefined) {
|
|
45
|
+
await GeneralJwsVerifier.verifySignatures(attestation, didResolver);
|
|
46
|
+
}
|
|
36
47
|
}
|
package/src/core/dwn-error.ts
CHANGED
|
@@ -26,6 +26,8 @@ export enum DwnErrorCode {
|
|
|
26
26
|
MessagesSubscribeEventStreamUnimplemented = 'MessagesSubscribeEventStreamUnimplemented',
|
|
27
27
|
GeneralJwsVerifierGetPublicKeyNotFound = 'GeneralJwsVerifierGetPublicKeyNotFound',
|
|
28
28
|
GeneralJwsVerifierInvalidSignature = 'GeneralJwsVerifierInvalidSignature',
|
|
29
|
+
GeneralJwsVerifierMissingAlg = 'GeneralJwsVerifierMissingAlg',
|
|
30
|
+
GeneralJwsVerifierMissingKid = 'GeneralJwsVerifierMissingKid',
|
|
29
31
|
GrantAuthorizationGrantExpired = 'GrantAuthorizationGrantExpired',
|
|
30
32
|
GrantAuthorizationGrantMissing = 'GrantAuthorizationGrantMissing',
|
|
31
33
|
GrantAuthorizationGrantRevoked = 'GrantAuthorizationGrantRevoked',
|
|
@@ -75,6 +77,7 @@ export enum DwnErrorCode {
|
|
|
75
77
|
ProtocolAuthorizationIncorrectContextId = 'ProtocolAuthorizationIncorrectContextId',
|
|
76
78
|
ProtocolAuthorizationIncorrectProtocolPath = 'ProtocolAuthorizationIncorrectProtocolPath',
|
|
77
79
|
ProtocolAuthorizationDuplicateRoleRecipient = 'ProtocolAuthorizationDuplicateRoleRecipient',
|
|
80
|
+
ProtocolAuthorizationEncryptionRequired = 'ProtocolAuthorizationEncryptionRequired',
|
|
78
81
|
ProtocolAuthorizationInvalidSchema = 'ProtocolAuthorizationInvalidSchema',
|
|
79
82
|
ProtocolAuthorizationInvalidType = 'ProtocolAuthorizationInvalidType',
|
|
80
83
|
ProtocolAuthorizationMatchingRoleRecordNotFound = 'ProtocolAuthorizationMatchingRoleRecordNotFound',
|
|
@@ -674,6 +674,14 @@ export class ProtocolAuthorization {
|
|
|
674
674
|
instead has '${dataFormat}'`
|
|
675
675
|
);
|
|
676
676
|
}
|
|
677
|
+
|
|
678
|
+
// enforce encryption when the protocol type requires it
|
|
679
|
+
if (protocolType.encryptionRequired === true && inboundMessage.encryption === undefined) {
|
|
680
|
+
throw new DwnError(
|
|
681
|
+
DwnErrorCode.ProtocolAuthorizationEncryptionRequired,
|
|
682
|
+
`type '${declaredTypeName}' requires encryption but message has no encryption metadata`
|
|
683
|
+
);
|
|
684
|
+
}
|
|
677
685
|
}
|
|
678
686
|
|
|
679
687
|
/**
|
package/src/dwn.ts
CHANGED
|
@@ -161,6 +161,21 @@ export class Dwn {
|
|
|
161
161
|
await this.stateIndex.close();
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Returns the internal storage components for advanced operations that
|
|
166
|
+
* cannot be expressed through the standard `processMessage()` pipeline
|
|
167
|
+
* (e.g., owner-upgrade of externally authored encrypted records).
|
|
168
|
+
*
|
|
169
|
+
* Callers are responsible for maintaining consistency across stores.
|
|
170
|
+
*/
|
|
171
|
+
public get storage(): { messageStore: MessageStore; stateIndex: StateIndex; eventStream: EventStream | undefined } {
|
|
172
|
+
return {
|
|
173
|
+
messageStore : this.messageStore,
|
|
174
|
+
stateIndex : this.stateIndex,
|
|
175
|
+
eventStream : this.eventStream,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
164
179
|
/**
|
|
165
180
|
* Processes the given DWN message and returns with a reply.
|
|
166
181
|
* @param tenant The tenant DID to route the given message to.
|