@enbox/dwn-sdk-js 0.4.3 → 0.4.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 +15 -15
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/generated/precompiled-validators.js +5406 -2200
- package/dist/esm/generated/precompiled-validators.js.map +1 -1
- package/dist/esm/json-schemas/definitions.json +18 -0
- package/dist/esm/src/core/constants.js +3 -3
- package/dist/esm/src/core/constants.js.map +1 -1
- package/dist/esm/src/core/dwn-error.js +29 -1
- package/dist/esm/src/core/dwn-error.js.map +1 -1
- package/dist/esm/src/core/messages-grant-authorization.js +20 -0
- package/dist/esm/src/core/messages-grant-authorization.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization-validation.js +80 -3
- package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -1
- package/dist/esm/src/core/recording-validation-state-reader.js +5 -0
- package/dist/esm/src/core/recording-validation-state-reader.js.map +1 -1
- package/dist/esm/src/core/replication-apply.js +163 -7
- package/dist/esm/src/core/replication-apply.js.map +1 -1
- package/dist/esm/src/core/validation-state-reader.js +20 -0
- package/dist/esm/src/core/validation-state-reader.js.map +1 -1
- package/dist/esm/src/dwn.js +19 -2
- package/dist/esm/src/dwn.js.map +1 -1
- package/dist/esm/src/handlers/messages-query.js +3 -5
- package/dist/esm/src/handlers/messages-query.js.map +1 -1
- package/dist/esm/src/handlers/protocols-configure.js +10 -4
- package/dist/esm/src/handlers/protocols-configure.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 +2 -1
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-configure.js +23 -10
- package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
- package/dist/esm/src/interfaces/records-write-signing.js +2 -8
- package/dist/esm/src/interfaces/records-write-signing.js.map +1 -1
- package/dist/esm/src/interfaces/records-write.js +43 -65
- package/dist/esm/src/interfaces/records-write.js.map +1 -1
- package/dist/esm/src/protocols/encryption.js +411 -0
- package/dist/esm/src/protocols/encryption.js.map +1 -0
- package/dist/esm/src/protocols/permission-grant.js +3 -3
- package/dist/esm/src/protocols/permission-grant.js.map +1 -1
- package/dist/esm/src/protocols/permissions.js +1 -0
- package/dist/esm/src/protocols/permissions.js.map +1 -1
- package/dist/esm/src/types/message-types.js.map +1 -1
- package/dist/esm/src/types/permission-types.js.map +1 -1
- package/dist/esm/src/types/protocols-types.js.map +1 -1
- package/dist/esm/src/utils/encryption.js +135 -187
- package/dist/esm/src/utils/encryption.js.map +1 -1
- package/dist/esm/src/utils/hd-key.js +0 -1
- package/dist/esm/src/utils/hd-key.js.map +1 -1
- package/dist/esm/src/utils/permission-scope.js +9 -6
- package/dist/esm/src/utils/permission-scope.js.map +1 -1
- package/dist/esm/src/utils/protocols.js +12 -9
- package/dist/esm/src/utils/protocols.js.map +1 -1
- package/dist/esm/src/utils/records.js +54 -56
- package/dist/esm/src/utils/records.js.map +1 -1
- package/dist/esm/src/utils/replication.js +27 -4
- package/dist/esm/src/utils/replication.js.map +1 -1
- package/dist/esm/tests/core/replication-apply.spec.js +141 -1
- package/dist/esm/tests/core/replication-apply.spec.js.map +1 -1
- package/dist/esm/tests/core/replication-replay-property.spec.js +1 -0
- package/dist/esm/tests/core/replication-replay-property.spec.js.map +1 -1
- package/dist/esm/tests/core/validation-read-closure.spec.js +111 -0
- package/dist/esm/tests/core/validation-read-closure.spec.js.map +1 -1
- package/dist/esm/tests/core/validation-state-reader.spec.js +89 -0
- package/dist/esm/tests/core/validation-state-reader.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-composition.spec.js +30 -31
- package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
- package/dist/esm/tests/fuzz/encryption.fuzz.spec.js +29 -121
- package/dist/esm/tests/fuzz/encryption.fuzz.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-query.spec.js +71 -3
- package/dist/esm/tests/handlers/messages-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-read.spec.js +2 -2
- package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-read.spec.js +9 -135
- package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-write.spec.js +279 -19
- package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/protocols-configure.spec.js +17 -22
- package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-write.spec.js +170 -150
- package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
- package/dist/esm/tests/protocols/encryption.spec.js +914 -0
- package/dist/esm/tests/protocols/encryption.spec.js.map +1 -0
- package/dist/esm/tests/protocols/permission-grant.spec.js +55 -0
- package/dist/esm/tests/protocols/permission-grant.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +100 -100
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
- package/dist/esm/tests/store/message-store-level.spec.js +20 -2
- package/dist/esm/tests/store/message-store-level.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption-callbacks.spec.js +88 -125
- package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption.spec.js +125 -255
- package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
- package/dist/esm/tests/utils/permission-scope.spec.js +5 -1
- package/dist/esm/tests/utils/permission-scope.spec.js.map +1 -1
- package/dist/esm/tests/utils/records.spec.js +15 -5
- package/dist/esm/tests/utils/records.spec.js.map +1 -1
- package/dist/esm/tests/utils/test-data-generator.js +7 -44
- package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/encryption/grant-key.spec.js +63 -0
- package/dist/esm/tests/validation/json-schemas/encryption/grant-key.spec.js.map +1 -0
- package/dist/types/generated/precompiled-validators.d.ts +140 -92
- package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
- package/dist/types/src/core/constants.d.ts +2 -2
- package/dist/types/src/core/constants.d.ts.map +1 -1
- package/dist/types/src/core/core-protocol.d.ts +1 -1
- package/dist/types/src/core/core-protocol.d.ts.map +1 -1
- package/dist/types/src/core/dwn-error.d.ts +29 -1
- package/dist/types/src/core/dwn-error.d.ts.map +1 -1
- package/dist/types/src/core/messages-grant-authorization.d.ts +2 -0
- package/dist/types/src/core/messages-grant-authorization.d.ts.map +1 -1
- package/dist/types/src/core/protocol-authorization-validation.d.ts +2 -2
- package/dist/types/src/core/protocol-authorization-validation.d.ts.map +1 -1
- package/dist/types/src/core/recording-validation-state-reader.d.ts +9 -0
- package/dist/types/src/core/recording-validation-state-reader.d.ts.map +1 -1
- package/dist/types/src/core/replication-apply.d.ts +4 -3
- package/dist/types/src/core/replication-apply.d.ts.map +1 -1
- package/dist/types/src/core/validation-state-reader.d.ts +9 -0
- package/dist/types/src/core/validation-state-reader.d.ts.map +1 -1
- package/dist/types/src/dwn.d.ts +1 -0
- package/dist/types/src/dwn.d.ts.map +1 -1
- package/dist/types/src/handlers/messages-query.d.ts.map +1 -1
- package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +6 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/interfaces/protocols-configure.d.ts +1 -1
- package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-write-signing.d.ts +4 -8
- package/dist/types/src/interfaces/records-write-signing.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-write.d.ts +10 -26
- package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
- package/dist/types/src/protocols/encryption.d.ts +43 -0
- package/dist/types/src/protocols/encryption.d.ts.map +1 -0
- package/dist/types/src/protocols/permission-grant.d.ts +3 -6
- package/dist/types/src/protocols/permission-grant.d.ts.map +1 -1
- package/dist/types/src/protocols/permissions.d.ts +2 -1
- package/dist/types/src/protocols/permissions.d.ts.map +1 -1
- package/dist/types/src/types/encryption-types.d.ts +5 -38
- package/dist/types/src/types/encryption-types.d.ts.map +1 -1
- package/dist/types/src/types/message-types.d.ts +0 -13
- package/dist/types/src/types/message-types.d.ts.map +1 -1
- package/dist/types/src/types/permission-types.d.ts +44 -9
- package/dist/types/src/types/permission-types.d.ts.map +1 -1
- package/dist/types/src/types/protocols-types.d.ts +9 -14
- package/dist/types/src/types/protocols-types.d.ts.map +1 -1
- package/dist/types/src/types/records-types.d.ts +3 -3
- package/dist/types/src/types/records-types.d.ts.map +1 -1
- package/dist/types/src/types/validation-state-reader.d.ts +12 -0
- package/dist/types/src/types/validation-state-reader.d.ts.map +1 -1
- package/dist/types/src/utils/encryption.d.ts +54 -145
- package/dist/types/src/utils/encryption.d.ts.map +1 -1
- package/dist/types/src/utils/hd-key.d.ts +1 -1
- package/dist/types/src/utils/hd-key.d.ts.map +1 -1
- package/dist/types/src/utils/permission-scope.d.ts +4 -3
- package/dist/types/src/utils/permission-scope.d.ts.map +1 -1
- package/dist/types/src/utils/protocols.d.ts +3 -5
- package/dist/types/src/utils/protocols.d.ts.map +1 -1
- package/dist/types/src/utils/records.d.ts +5 -13
- package/dist/types/src/utils/records.d.ts.map +1 -1
- package/dist/types/src/utils/replication.d.ts +3 -0
- package/dist/types/src/utils/replication.d.ts.map +1 -1
- package/dist/types/tests/features/protocol-composition.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/messages-query.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-write.spec.d.ts.map +1 -1
- package/dist/types/tests/protocols/encryption.spec.d.ts +2 -0
- package/dist/types/tests/protocols/encryption.spec.d.ts.map +1 -0
- package/dist/types/tests/scenarios/end-to-end-tests.spec.d.ts.map +1 -1
- package/dist/types/tests/utils/test-data-generator.d.ts +0 -5
- package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -1
- package/dist/types/tests/validation/json-schemas/encryption/grant-key.spec.d.ts +2 -0
- package/dist/types/tests/validation/json-schemas/encryption/grant-key.spec.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/core/constants.ts +3 -3
- package/src/core/core-protocol.ts +1 -1
- package/src/core/dwn-error.ts +29 -1
- package/src/core/messages-grant-authorization.ts +27 -0
- package/src/core/protocol-authorization-validation.ts +145 -6
- package/src/core/recording-validation-state-reader.ts +13 -0
- package/src/core/replication-apply.ts +222 -8
- package/src/core/validation-state-reader.ts +30 -0
- package/src/dwn.ts +24 -2
- package/src/handlers/messages-query.ts +6 -5
- package/src/handlers/protocols-configure.ts +19 -3
- package/src/handlers/records-write.ts +1 -1
- package/src/index.ts +15 -5
- package/src/interfaces/protocols-configure.ts +39 -12
- package/src/interfaces/records-write-signing.ts +5 -12
- package/src/interfaces/records-write.ts +75 -92
- package/src/protocols/encryption.ts +649 -0
- package/src/protocols/permission-grant.ts +4 -5
- package/src/protocols/permissions.ts +8 -6
- package/src/types/encryption-types.ts +9 -38
- package/src/types/message-types.ts +0 -13
- package/src/types/permission-types.ts +57 -9
- package/src/types/protocols-types.ts +9 -16
- package/src/types/records-types.ts +3 -3
- package/src/types/validation-state-reader.ts +13 -0
- package/src/utils/encryption.ts +213 -283
- package/src/utils/hd-key.ts +1 -1
- package/src/utils/permission-scope.ts +10 -6
- package/src/utils/protocols.ts +16 -15
- package/src/utils/records.ts +86 -71
- package/src/utils/replication.ts +30 -4
- package/dist/esm/tests/vectors/protocol-definitions/chat.json +0 -70
|
@@ -3,9 +3,9 @@ import type { MessagesFilter } from '../types/messages-types.js';
|
|
|
3
3
|
import type { MessageSigner } from '../types/signer.js';
|
|
4
4
|
import type { ProtocolDefinition } from '../types/protocols-types.js';
|
|
5
5
|
import type { ValidationStateReader } from '../types/validation-state-reader.js';
|
|
6
|
+
import type { ConnectSessionMetadata, PermissionConditions, PermissionGrantData, PermissionRequestData, PermissionRevocationData, PermissionScope, RecordsPermissionScope } from '../types/permission-types.js';
|
|
6
7
|
import type { CoreProtocol, CoreProtocolStores } from '../core/core-protocol.js';
|
|
7
8
|
import type { DataEncodedRecordsWriteMessage, RecordsWriteMessage } from '../types/records-types.js';
|
|
8
|
-
import type { PermissionConditions, PermissionGrantData, PermissionRequestData, PermissionRevocationData, PermissionScope, RecordsPermissionScope } from '../types/permission-types.js';
|
|
9
9
|
|
|
10
10
|
import { DwnConstant } from '../core/dwn-constant.js';
|
|
11
11
|
import { DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
@@ -63,6 +63,7 @@ export type PermissionGrantCreateOptions = {
|
|
|
63
63
|
delegated?: boolean;
|
|
64
64
|
scope: PermissionScope;
|
|
65
65
|
conditions?: PermissionConditions;
|
|
66
|
+
connectSession?: ConnectSessionMetadata;
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -422,12 +423,13 @@ export class PermissionsProtocol implements CoreProtocol {
|
|
|
422
423
|
const scope = PermissionsProtocol.normalizePermissionScope(options.scope);
|
|
423
424
|
|
|
424
425
|
const permissionGrantData: PermissionGrantData = {
|
|
425
|
-
dateExpires
|
|
426
|
-
requestId
|
|
427
|
-
description
|
|
428
|
-
delegated
|
|
426
|
+
dateExpires : options.dateExpires,
|
|
427
|
+
requestId : options.requestId,
|
|
428
|
+
description : options.description,
|
|
429
|
+
delegated : options.delegated,
|
|
429
430
|
scope,
|
|
430
|
-
conditions
|
|
431
|
+
conditions : options.conditions,
|
|
432
|
+
connectSession : options.connectSession,
|
|
431
433
|
};
|
|
432
434
|
|
|
433
435
|
// If the grant is scoped to a protocol, the protocol tag must be included with the record.
|
|
@@ -1,53 +1,24 @@
|
|
|
1
|
-
import type { JweKeyUnwrapPayload } from '../utils/encryption.js';
|
|
2
1
|
import type { KeyDerivationScheme } from '../utils/hd-key.js';
|
|
2
|
+
import type { KeyUnwrapPayload } from '../utils/encryption.js';
|
|
3
3
|
import type { PublicKeyJwk } from './jose-types.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* The implementor performs HKDF key derivation and public key computation
|
|
8
|
-
* internally — the private key never leaves the implementation boundary.
|
|
9
|
-
*
|
|
10
|
-
* Analogous to `MessageSigner` for signing operations.
|
|
11
|
-
*/
|
|
5
|
+
export type KeyDecrypterDerivationScheme = KeyDerivationScheme | 'roleAudience';
|
|
6
|
+
|
|
12
7
|
export interface EncryptionKeyDeriver {
|
|
13
|
-
/** Fully qualified key ID (e.g. did:example:alice#enc) */
|
|
14
8
|
rootKeyId: string;
|
|
15
|
-
/** The derivation scheme (e.g. KeyDerivationScheme.ProtocolPath) */
|
|
16
9
|
derivationScheme: KeyDerivationScheme;
|
|
17
|
-
|
|
18
|
-
* Derives an HD child public key for the given full derivation path.
|
|
19
|
-
* The private key material stays within the implementor's boundary.
|
|
20
|
-
*
|
|
21
|
-
* @param fullDerivationPath - The complete HKDF path segments
|
|
22
|
-
* (e.g. ['protocolPath', 'https://chat.example', 'thread', 'message'])
|
|
23
|
-
* @returns The derived child public key as a JWK
|
|
24
|
-
*/
|
|
10
|
+
|
|
25
11
|
derivePublicKey(fullDerivationPath: string[]): Promise<PublicKeyJwk>;
|
|
26
12
|
}
|
|
27
13
|
|
|
28
|
-
/**
|
|
29
|
-
* A callback interface for decrypting JWE-wrapped Content Encryption Keys (CEKs).
|
|
30
|
-
* The implementor performs HKDF key derivation, ECDH-ES key agreement, and AES Key Unwrap
|
|
31
|
-
* internally — the private key never leaves the implementation boundary.
|
|
32
|
-
*
|
|
33
|
-
* Analogous to `MessageSigner` for signing operations.
|
|
34
|
-
*/
|
|
35
14
|
export interface KeyDecrypter {
|
|
36
|
-
/** Fully qualified key ID (e.g. did:example:alice#enc) */
|
|
37
15
|
rootKeyId: string;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* leaf decryption key via HKDF through the given derivation path, then
|
|
43
|
-
* performing ECDH-ES key agreement and AES-256 Key Unwrap.
|
|
44
|
-
*
|
|
45
|
-
* @param fullDerivationPath - The complete HKDF path to derive the leaf key
|
|
46
|
-
* @param jweKeyUnwrapPayload - The wrapped CEK and ephemeral public key from the JWE recipient
|
|
47
|
-
* @returns The unwrapped CEK bytes (typically 32 bytes for AES-256)
|
|
48
|
-
*/
|
|
16
|
+
derivationScheme: KeyDecrypterDerivationScheme;
|
|
17
|
+
|
|
18
|
+
derivePublicKey(fullDerivationPath: string[]): Promise<PublicKeyJwk>;
|
|
19
|
+
|
|
49
20
|
decrypt(
|
|
50
21
|
fullDerivationPath: string[],
|
|
51
|
-
|
|
22
|
+
keyUnwrapPayload: KeyUnwrapPayload,
|
|
52
23
|
): Promise<Uint8Array>;
|
|
53
24
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { GeneralJws } from './jws-types.js';
|
|
2
2
|
import type { ProgressToken } from './subscriptions.js';
|
|
3
|
-
import type { PublicKeyJwk } from './jose-types.js';
|
|
4
3
|
import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
5
4
|
import type { PaginationCursor, SortDirection } from './query-types.js';
|
|
6
5
|
|
|
@@ -44,18 +43,6 @@ export type AuthorizationModel = {
|
|
|
44
43
|
*/
|
|
45
44
|
ownerDelegatedGrant?: DelegatedGrantRecordsWriteMessage;
|
|
46
45
|
|
|
47
|
-
/**
|
|
48
|
-
* The author's ProtocolPath-derived public key for the key-delivery protocol's
|
|
49
|
-
* `contextKey` path. Included by external authors on cross-DWN encrypted
|
|
50
|
-
* protocol records so the DWN owner can encrypt a context key back to them
|
|
51
|
-
* without needing to query the author's DWN.
|
|
52
|
-
*/
|
|
53
|
-
authorKeyDeliveryPublicKey?: {
|
|
54
|
-
/** Fully-qualified verification method ID (e.g. `did:example:bob#enc`). */
|
|
55
|
-
rootKeyId: string;
|
|
56
|
-
/** The author's ProtocolPath-derived public key in JWK format. */
|
|
57
|
-
publicKeyJwk: PublicKeyJwk;
|
|
58
|
-
};
|
|
59
46
|
};
|
|
60
47
|
|
|
61
48
|
export type DelegatedGrantRecordsWriteMessage = {
|
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Metadata describing the connect approval session that created a permission grant.
|
|
5
|
+
*
|
|
6
|
+
* Wallets use this to group grants into user-facing app sessions and to
|
|
7
|
+
* distinguish active sessions from expired permission bundles. App and client
|
|
8
|
+
* fields are self-reported by the requester, unauthenticated, and intended for
|
|
9
|
+
* display only. Consumers must not treat them as verified app identity.
|
|
10
|
+
*/
|
|
11
|
+
export type ConnectSessionMetadata = {
|
|
12
|
+
/** Stable session ID shared by all grants created by one connect approval. */
|
|
13
|
+
id: string;
|
|
14
|
+
|
|
15
|
+
/** Human-readable app name shown during approval. Self-reported display data. */
|
|
16
|
+
appName?: string;
|
|
17
|
+
|
|
18
|
+
/** App icon URL shown during approval. Self-reported display data. */
|
|
19
|
+
appIcon?: string;
|
|
20
|
+
|
|
21
|
+
/** Origin of the requesting app, when known. Self-reported display data. */
|
|
22
|
+
origin?: string;
|
|
23
|
+
|
|
24
|
+
/** User agent string captured by the connect client, when available. Display data only. */
|
|
25
|
+
userAgent?: string;
|
|
26
|
+
|
|
27
|
+
/** Platform/device hint captured by the connect client, when available. */
|
|
28
|
+
platform?: string;
|
|
29
|
+
|
|
30
|
+
/** Primary browser language captured by the connect client, when available. */
|
|
31
|
+
language?: string;
|
|
32
|
+
|
|
33
|
+
/** Browser language preferences captured by the connect client, when available. */
|
|
34
|
+
languages?: string[];
|
|
35
|
+
|
|
36
|
+
/** IANA timezone captured by the connect client, when available. */
|
|
37
|
+
timezone?: string;
|
|
38
|
+
|
|
39
|
+
/** Connect transport that created the session. */
|
|
40
|
+
transport?: ConnectSessionTransport;
|
|
41
|
+
|
|
42
|
+
/** Timestamp when the wallet approved the connect session. */
|
|
43
|
+
createdAt: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Display timestamp for when the connect session expires.
|
|
47
|
+
*
|
|
48
|
+
* The enforcing value is the enclosing permission grant's `dateExpires`.
|
|
49
|
+
* Consumers must use `dateExpires`, not this metadata field, for any
|
|
50
|
+
* authorization or security decision.
|
|
51
|
+
*/
|
|
52
|
+
expiresAt: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Connect transport that created a connect session. */
|
|
56
|
+
export type ConnectSessionTransport = 'relay' | 'postMessage';
|
|
57
|
+
|
|
3
58
|
/**
|
|
4
59
|
* Type for the data payload of a permission request message.
|
|
5
60
|
*/
|
|
@@ -54,15 +109,8 @@ export type PermissionGrantData = {
|
|
|
54
109
|
|
|
55
110
|
conditions?: PermissionConditions;
|
|
56
111
|
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
* Contains the pre-derived ProtocolPath leaf public key that the owner uses
|
|
60
|
-
* to encrypt contextKey records addressed to the delegate.
|
|
61
|
-
*/
|
|
62
|
-
delegateKeyDelivery?: {
|
|
63
|
-
rootKeyId: string;
|
|
64
|
-
publicKeyJwk: Record<string, any>;
|
|
65
|
-
};
|
|
112
|
+
/** Optional metadata for the connect session that created this grant. */
|
|
113
|
+
connectSession?: ConnectSessionMetadata;
|
|
66
114
|
};
|
|
67
115
|
|
|
68
116
|
/**
|
|
@@ -12,6 +12,7 @@ export type ProtocolsConfigureDescriptor = {
|
|
|
12
12
|
|
|
13
13
|
export type ProtocolDefinition = {
|
|
14
14
|
protocol: string;
|
|
15
|
+
$keyAgreement?: ProtocolKeyAgreement;
|
|
15
16
|
/**
|
|
16
17
|
* Denotes if this Protocol Definition can be returned by unauthenticated or unauthorized `ProtocolsQuery`.
|
|
17
18
|
*/
|
|
@@ -132,18 +133,9 @@ export type ProtocolActionRule = {
|
|
|
132
133
|
can: (ProtocolAction | `${ProtocolAction}` | (string & {}))[];
|
|
133
134
|
};
|
|
134
135
|
/**
|
|
135
|
-
*
|
|
136
|
+
* Public key used for protocol-path content encryption.
|
|
136
137
|
*/
|
|
137
|
-
export type
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* The ID of the root key that derives the public key at this protocol path for encrypting the symmetric key used for data encryption.
|
|
141
|
-
*/
|
|
142
|
-
rootKeyId: string;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Public key for encrypting the symmetric key used for data encryption.
|
|
146
|
-
*/
|
|
138
|
+
export type ProtocolKeyAgreement = {
|
|
147
139
|
publicKeyJwk: PublicKeyJwk;
|
|
148
140
|
};
|
|
149
141
|
|
|
@@ -224,6 +216,7 @@ export type ProtocolTagSchema = {
|
|
|
224
216
|
exclusiveMaximum?: number;
|
|
225
217
|
minLength?: number;
|
|
226
218
|
maxLength?: number;
|
|
219
|
+
pattern?: string;
|
|
227
220
|
minItems?: number;
|
|
228
221
|
maxItems?: number;
|
|
229
222
|
uniqueItems?: boolean;
|
|
@@ -234,13 +227,13 @@ export type ProtocolTagSchema = {
|
|
|
234
227
|
/**
|
|
235
228
|
* Union of all value types that can appear as properties of a `ProtocolRuleSet`.
|
|
236
229
|
* This includes:
|
|
237
|
-
* - `$`-prefixed directive values (`$
|
|
230
|
+
* - `$`-prefixed directive values (`$keyAgreement`, `$actions`, `$role`, `$ref`, `$size`, `$tags`, `$delivery`)
|
|
238
231
|
* - Child `ProtocolRuleSet` entries (non-`$` keys)
|
|
239
232
|
*/
|
|
240
233
|
type ProtocolRuleSetValue =
|
|
241
234
|
| ProtocolRuleSet
|
|
242
235
|
| ProtocolActionRule[]
|
|
243
|
-
|
|
|
236
|
+
| ProtocolKeyAgreement
|
|
244
237
|
| ProtocolTagsDefinition
|
|
245
238
|
| ProtocolSizeDefinition
|
|
246
239
|
| ProtocolRecordLimitDefinition
|
|
@@ -251,9 +244,9 @@ type ProtocolRuleSetValue =
|
|
|
251
244
|
|
|
252
245
|
export type ProtocolRuleSet = {
|
|
253
246
|
/**
|
|
254
|
-
*
|
|
247
|
+
* Key agreement setting for records at this protocol path.
|
|
255
248
|
*/
|
|
256
|
-
$
|
|
249
|
+
$keyAgreement?: ProtocolKeyAgreement;
|
|
257
250
|
$actions?: ProtocolActionRule[];
|
|
258
251
|
|
|
259
252
|
/**
|
|
@@ -268,7 +261,7 @@ export type ProtocolRuleSet = {
|
|
|
268
261
|
* and `typePath` is the protocol path of the type in the external protocol's structure.
|
|
269
262
|
*
|
|
270
263
|
* A `$ref` node is a pure attachment point — it must NOT have `$actions`, `$role`, `$size`,
|
|
271
|
-
* `$tags`, or `$
|
|
264
|
+
* `$tags`, or `$keyAgreement`. Authorization for the referenced type is governed by its own
|
|
272
265
|
* protocol. Only children defined under the `$ref` node get `$actions` from the composing protocol.
|
|
273
266
|
*
|
|
274
267
|
* Example:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { DwnEncryption } from '../utils/encryption.js';
|
|
1
2
|
import type { GeneralJws } from './jws-types.js';
|
|
2
|
-
import type { JweEncryption } from '../utils/encryption.js';
|
|
3
3
|
import type { AuthorizationModel, GenericMessage, GenericMessageReply, GenericSignaturePayload, MessageSubscription, Pagination } from './message-types.js';
|
|
4
4
|
import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
5
5
|
import type { PaginationCursor, RangeCriterion, RangeFilter, StartsWithFilter } from './query-types.js';
|
|
@@ -60,7 +60,7 @@ export type InternalRecordsWriteMessage = GenericMessage & {
|
|
|
60
60
|
contextId?: string;
|
|
61
61
|
descriptor: RecordsWriteDescriptor;
|
|
62
62
|
attestation?: GeneralJws;
|
|
63
|
-
encryption?:
|
|
63
|
+
encryption?: DwnEncryption;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
export type RecordsWriteMessage = {
|
|
@@ -69,7 +69,7 @@ export type RecordsWriteMessage = {
|
|
|
69
69
|
contextId: string;
|
|
70
70
|
descriptor: RecordsWriteDescriptor;
|
|
71
71
|
attestation?: GeneralJws;
|
|
72
|
-
encryption?:
|
|
72
|
+
encryption?: DwnEncryption;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
/**
|
|
@@ -78,6 +78,19 @@ export interface ValidationStateReader {
|
|
|
78
78
|
contextIdPrefix?: string;
|
|
79
79
|
}): Promise<RecordsWriteMessage[]>;
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Queries accepted audience epoch records in the Encryption Protocol.
|
|
83
|
+
* The optional `keyId` narrows the lookup to one published audience key.
|
|
84
|
+
*/
|
|
85
|
+
queryAudienceEpochs(input: {
|
|
86
|
+
tenant: string;
|
|
87
|
+
protocol: string;
|
|
88
|
+
contextId: string;
|
|
89
|
+
role: string;
|
|
90
|
+
epoch: number;
|
|
91
|
+
keyId?: string;
|
|
92
|
+
}): Promise<RecordsWriteMessage[]>;
|
|
93
|
+
|
|
81
94
|
/**
|
|
82
95
|
* Fetches the permission grant with the given record ID, with its scope parsed from grant data.
|
|
83
96
|
* @throws {DwnError} with `GrantAuthorizationGrantMissing` when the grant does not exist.
|