@enbox/dwn-sdk-js 0.4.4 → 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 +5316 -2425
- 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 +0 -5
- package/dist/esm/src/protocols/permission-grant.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/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 +0 -7
- package/dist/types/src/protocols/permission-grant.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 +0 -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 +0 -6
- package/src/types/encryption-types.ts +9 -38
- package/src/types/message-types.ts +0 -13
- package/src/types/permission-types.ts +0 -10
- 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
|
@@ -87,6 +87,19 @@ export class RecordingValidationStateReader implements ValidationStateReader {
|
|
|
87
87
|
return this.inner.queryLatestRoleRecords(input);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/** @inheritdoc */
|
|
91
|
+
public async queryAudienceEpochs(input: {
|
|
92
|
+
tenant: string;
|
|
93
|
+
protocol: string;
|
|
94
|
+
contextId: string;
|
|
95
|
+
role: string;
|
|
96
|
+
epoch: number;
|
|
97
|
+
keyId?: string;
|
|
98
|
+
}): Promise<RecordsWriteMessage[]> {
|
|
99
|
+
this.recordedReads.push({ method: 'queryAudienceEpochs' });
|
|
100
|
+
return this.inner.queryAudienceEpochs(input);
|
|
101
|
+
}
|
|
102
|
+
|
|
90
103
|
/** @inheritdoc */
|
|
91
104
|
public async fetchGrant(tenant: string, permissionGrantId: string): Promise<PermissionGrant> {
|
|
92
105
|
this.recordedReads.push({ method: 'fetchGrant' });
|
|
@@ -5,7 +5,9 @@ import type { ValidationStateReader } from '../types/validation-state-reader.js'
|
|
|
5
5
|
|
|
6
6
|
import { DwnErrorCode } from './dwn-error.js';
|
|
7
7
|
import { Encoder } from '../utils/encoder.js';
|
|
8
|
+
import { EncryptionProtocol } from '../protocols/encryption.js';
|
|
8
9
|
import { Message } from './message.js';
|
|
10
|
+
import { ROLE_AUDIENCE_DERIVATION_SCHEME } from '../utils/encryption.js';
|
|
9
11
|
import { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
10
12
|
import { isCrossProtocolRef, parseCrossProtocolRef } from '../utils/protocols.js';
|
|
11
13
|
|
|
@@ -40,6 +42,14 @@ export type ReplicationApplyResultContext = {
|
|
|
40
42
|
missingAncestorRecordIds?: string[];
|
|
41
43
|
};
|
|
42
44
|
|
|
45
|
+
type AudienceDependencyTags = {
|
|
46
|
+
protocol: string;
|
|
47
|
+
contextId: string;
|
|
48
|
+
role: string;
|
|
49
|
+
epoch: number;
|
|
50
|
+
keyId: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
43
53
|
export type DependencyRef =
|
|
44
54
|
| { type: 'Protocol'; protocol: string; messageCid?: string; terminal?: boolean }
|
|
45
55
|
| { type: 'InitialWrite'; recordId: string; protocol?: string; messageCid?: string; terminal?: boolean }
|
|
@@ -47,7 +57,14 @@ export type DependencyRef =
|
|
|
47
57
|
| { type: 'Ancestor'; recordId: string; protocol?: string; messageCid?: string; terminal?: boolean }
|
|
48
58
|
| { type: 'Role'; protocol: string; protocolPath: string; recipient: string; contextPrefix?: string; messageCid?: string; terminal?: boolean }
|
|
49
59
|
| { type: 'Grant'; permissionGrantId: string; messageCid?: string; terminal?: boolean }
|
|
50
|
-
| {
|
|
60
|
+
| {
|
|
61
|
+
type: 'EncryptionProtocol';
|
|
62
|
+
protocolPath: 'audienceEpoch' | 'audienceKey' | 'grantKey';
|
|
63
|
+
tags?: Record<string, string | number>;
|
|
64
|
+
recipient?: string;
|
|
65
|
+
messageCid?: string;
|
|
66
|
+
terminal?: boolean;
|
|
67
|
+
}
|
|
51
68
|
| { type: 'CrossProtocolRef'; protocol: string; recordId: string; messageCid?: string; terminal?: boolean }
|
|
52
69
|
| { type: 'RecordData'; recordId: string; dataCid: string; protocol?: string; messageCid?: string; terminal?: boolean };
|
|
53
70
|
|
|
@@ -180,7 +197,14 @@ function dependencyRefsFromStatus(
|
|
|
180
197
|
case DwnErrorCode.GrantAuthorizationGrantMissing:
|
|
181
198
|
return toRefList(grantDependencyFromMessage(message));
|
|
182
199
|
case DwnErrorCode.ProtocolAuthorizationMatchingRoleRecordNotFound:
|
|
200
|
+
case DwnErrorCode.EncryptionProtocolValidateAudienceWriterUnauthorized:
|
|
183
201
|
return toRefList(roleDependencyFromMessage(message, context));
|
|
202
|
+
case DwnErrorCode.EncryptionProtocolValidateAudienceEpochMissing:
|
|
203
|
+
return toRefList(encryptionProtocolDependencyFromMessage(message, EncryptionProtocol.audienceEpochPath));
|
|
204
|
+
case DwnErrorCode.ProtocolAuthorizationEncryptionRoleAudienceEpochMissing:
|
|
205
|
+
return toRefList(encryptionProtocolDependencyFromRoleAudienceEntry(message, detail));
|
|
206
|
+
case DwnErrorCode.EncryptionProtocolValidateAudienceKeyRoleRecordMissing:
|
|
207
|
+
return toRefList(roleDependencyFromEncryptionAudienceRecipient(message));
|
|
184
208
|
case DwnErrorCode.RecordsWriteMissingDataInPrevious:
|
|
185
209
|
case DwnErrorCode.RecordsWriteMissingEncodedDataInPrevious:
|
|
186
210
|
return toRefList(recordDataDependencyFromMessage(message));
|
|
@@ -214,7 +238,7 @@ function protocolDependencyFromMessage(message: GenericMessage, detail: string):
|
|
|
214
238
|
return { type: 'Protocol', protocol: composedProtocol };
|
|
215
239
|
}
|
|
216
240
|
|
|
217
|
-
const protocol = (message
|
|
241
|
+
const protocol = dependencyProtocolFromMessage(message);
|
|
218
242
|
return typeof protocol === 'string' ? { type: 'Protocol', protocol } : undefined;
|
|
219
243
|
}
|
|
220
244
|
|
|
@@ -235,7 +259,7 @@ function parentDependenciesFromMessage(
|
|
|
235
259
|
return [];
|
|
236
260
|
}
|
|
237
261
|
|
|
238
|
-
const protocol = (message
|
|
262
|
+
const protocol = dependencyProtocolFromMessage(message);
|
|
239
263
|
const protocolProperty = typeof protocol === 'string' ? { protocol } : {};
|
|
240
264
|
const ancestorRefs = (context.missingAncestorRecordIds ?? [])
|
|
241
265
|
.filter((recordId): boolean => recordId !== parentRef.recordId)
|
|
@@ -248,9 +272,8 @@ function parentDependencyFromMessage(
|
|
|
248
272
|
message: GenericMessage,
|
|
249
273
|
detail: string,
|
|
250
274
|
): Extract<DependencyRef, { type: 'Parent' }> | undefined {
|
|
251
|
-
const descriptor = message.descriptor as Record<string, unknown>;
|
|
252
275
|
const parentId = parentRecordIdFromMessage(message, detail);
|
|
253
|
-
const protocol = /in protocol '([^']+)'/.exec(detail)?.[1] ??
|
|
276
|
+
const protocol = /in protocol '([^']+)'/.exec(detail)?.[1] ?? dependencyProtocolFromMessage(message);
|
|
254
277
|
|
|
255
278
|
if (parentId === undefined || typeof protocol !== 'string') {
|
|
256
279
|
return undefined;
|
|
@@ -278,7 +301,7 @@ function ancestorDependenciesFromMessage(
|
|
|
278
301
|
detail: string,
|
|
279
302
|
context: ReplicationApplyResultContext,
|
|
280
303
|
): DependencyRef[] {
|
|
281
|
-
const protocol = (message
|
|
304
|
+
const protocol = dependencyProtocolFromMessage(message);
|
|
282
305
|
const protocolProperty = typeof protocol === 'string' ? { protocol } : {};
|
|
283
306
|
|
|
284
307
|
const batchedRecordIds = context.missingAncestorRecordIds;
|
|
@@ -303,7 +326,7 @@ function initialWriteDependencyFromMessage(message: GenericMessage): DependencyR
|
|
|
303
326
|
return undefined;
|
|
304
327
|
}
|
|
305
328
|
|
|
306
|
-
const protocol = (message
|
|
329
|
+
const protocol = dependencyProtocolFromMessage(message);
|
|
307
330
|
return {
|
|
308
331
|
type : 'InitialWrite',
|
|
309
332
|
recordId : message.recordId,
|
|
@@ -312,6 +335,14 @@ function initialWriteDependencyFromMessage(message: GenericMessage): DependencyR
|
|
|
312
335
|
}
|
|
313
336
|
|
|
314
337
|
function grantDependencyFromMessage(message: GenericMessage): DependencyRef | undefined {
|
|
338
|
+
if (isEncryptionProtocolMessage(message)) {
|
|
339
|
+
const tags = (message.descriptor as Record<string, unknown>).tags;
|
|
340
|
+
const grantId = isRecordObject(tags) ? tags.grantId : undefined;
|
|
341
|
+
if (typeof grantId === 'string') {
|
|
342
|
+
return { type: 'Grant', permissionGrantId: grantId };
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
315
346
|
const descriptorGrantId = (message.descriptor as Record<string, unknown>).permissionGrantId;
|
|
316
347
|
if (typeof descriptorGrantId === 'string') {
|
|
317
348
|
return { type: 'Grant', permissionGrantId: descriptorGrantId };
|
|
@@ -330,7 +361,7 @@ function recordDataDependencyFromMessage(message: GenericMessage): DependencyRef
|
|
|
330
361
|
|
|
331
362
|
const descriptor = message.descriptor as Record<string, unknown>;
|
|
332
363
|
const dataCid = descriptor.dataCid;
|
|
333
|
-
const protocol =
|
|
364
|
+
const protocol = dependencyProtocolFromMessage(message);
|
|
334
365
|
return typeof dataCid === 'string'
|
|
335
366
|
? {
|
|
336
367
|
type : 'RecordData',
|
|
@@ -342,6 +373,11 @@ function recordDataDependencyFromMessage(message: GenericMessage): DependencyRef
|
|
|
342
373
|
}
|
|
343
374
|
|
|
344
375
|
function roleDependencyFromMessage(message: GenericMessage, context: ReplicationApplyResultContext): DependencyRef | undefined {
|
|
376
|
+
const encryptionRoleDependency = roleDependencyFromEncryptionAudienceWriter(message, context);
|
|
377
|
+
if (encryptionRoleDependency !== undefined) {
|
|
378
|
+
return encryptionRoleDependency;
|
|
379
|
+
}
|
|
380
|
+
|
|
345
381
|
const descriptor = message.descriptor as Record<string, unknown>;
|
|
346
382
|
const filter = descriptor.filter as Record<string, unknown> | undefined;
|
|
347
383
|
const protocol = descriptor.protocol ?? filter?.protocol;
|
|
@@ -383,6 +419,184 @@ function roleDependencyFromMessage(message: GenericMessage, context: Replication
|
|
|
383
419
|
};
|
|
384
420
|
}
|
|
385
421
|
|
|
422
|
+
function encryptionProtocolDependencyFromMessage(
|
|
423
|
+
message: GenericMessage,
|
|
424
|
+
protocolPath: Extract<DependencyRef, { type: 'EncryptionProtocol' }>['protocolPath'],
|
|
425
|
+
): DependencyRef | undefined {
|
|
426
|
+
const tags = encryptionAudienceTagsFromMessage(message);
|
|
427
|
+
return tags === undefined
|
|
428
|
+
? undefined
|
|
429
|
+
: { type: 'EncryptionProtocol', protocolPath, tags };
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function encryptionProtocolDependencyFromRoleAudienceEntry(
|
|
433
|
+
message: GenericMessage,
|
|
434
|
+
detail: string,
|
|
435
|
+
): DependencyRef | undefined {
|
|
436
|
+
const descriptor = message.descriptor as Record<string, unknown>;
|
|
437
|
+
const messageContextId = (message as { contextId?: unknown }).contextId;
|
|
438
|
+
const contextId = typeof messageContextId === 'string' ? messageContextId : descriptor.contextId;
|
|
439
|
+
const keyEncryption = (message as {
|
|
440
|
+
encryption?: {
|
|
441
|
+
keyEncryption?: Record<string, unknown>[];
|
|
442
|
+
};
|
|
443
|
+
}).encryption?.keyEncryption;
|
|
444
|
+
if (typeof contextId !== 'string' || !Array.isArray(keyEncryption)) {
|
|
445
|
+
return undefined;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const missingRole = /role '([^']+)'/.exec(detail)?.[1];
|
|
449
|
+
const entry = keyEncryption.find((candidate): boolean =>
|
|
450
|
+
candidate.derivationScheme === ROLE_AUDIENCE_DERIVATION_SCHEME &&
|
|
451
|
+
typeof candidate.protocol === 'string' &&
|
|
452
|
+
typeof candidate.role === 'string' &&
|
|
453
|
+
(missingRole === undefined || candidate.role === missingRole) &&
|
|
454
|
+
typeof candidate.epoch === 'number' &&
|
|
455
|
+
typeof candidate.keyId === 'string'
|
|
456
|
+
);
|
|
457
|
+
if (entry === undefined) {
|
|
458
|
+
return undefined;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const role = entry.role as string;
|
|
462
|
+
const audienceContextId = roleAudienceContextId(role, contextId);
|
|
463
|
+
if (audienceContextId === undefined) {
|
|
464
|
+
return undefined;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return {
|
|
468
|
+
type : 'EncryptionProtocol',
|
|
469
|
+
protocolPath : EncryptionProtocol.audienceEpochPath,
|
|
470
|
+
tags : {
|
|
471
|
+
protocol : entry.protocol as string,
|
|
472
|
+
contextId : audienceContextId,
|
|
473
|
+
role,
|
|
474
|
+
epoch : entry.epoch as number,
|
|
475
|
+
keyId : entry.keyId as string,
|
|
476
|
+
},
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function roleDependencyFromEncryptionAudienceRecipient(message: GenericMessage): DependencyRef | undefined {
|
|
481
|
+
const tags = encryptionAudienceTagsFromMessage(message);
|
|
482
|
+
const recipient = (message.descriptor as Record<string, unknown>).recipient;
|
|
483
|
+
if (tags === undefined || typeof recipient !== 'string') {
|
|
484
|
+
return undefined;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return {
|
|
488
|
+
type : 'Role',
|
|
489
|
+
protocol : tags.protocol,
|
|
490
|
+
protocolPath : tags.role,
|
|
491
|
+
recipient,
|
|
492
|
+
...(tags.contextId === '' ? {} : { contextPrefix: tags.contextId }),
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function roleDependencyFromEncryptionAudienceWriter(
|
|
497
|
+
message: GenericMessage,
|
|
498
|
+
context: ReplicationApplyResultContext,
|
|
499
|
+
): DependencyRef | undefined {
|
|
500
|
+
const tags = encryptionAudienceTagsFromMessage(message);
|
|
501
|
+
const protocolRole = getSignaturePayload(message)?.protocolRole;
|
|
502
|
+
const recipient = Message.getAuthor(message);
|
|
503
|
+
if (tags === undefined || typeof protocolRole !== 'string' || recipient === undefined) {
|
|
504
|
+
return undefined;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
let roleProtocol = tags.protocol;
|
|
508
|
+
let roleProtocolPath = protocolRole;
|
|
509
|
+
if (isCrossProtocolRef(protocolRole)) {
|
|
510
|
+
const parsed = parseCrossProtocolRef(protocolRole);
|
|
511
|
+
const referencedProtocol = parsed === undefined ? undefined : context.protocolDefinition?.uses?.[parsed.alias];
|
|
512
|
+
if (parsed === undefined || referencedProtocol === undefined) {
|
|
513
|
+
return undefined;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
roleProtocol = referencedProtocol;
|
|
517
|
+
roleProtocolPath = parsed.protocolPath;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
const contextPrefix = roleContextPrefix(roleProtocolPath, tags.contextId);
|
|
521
|
+
return {
|
|
522
|
+
type : 'Role',
|
|
523
|
+
protocol : roleProtocol,
|
|
524
|
+
protocolPath : roleProtocolPath,
|
|
525
|
+
recipient,
|
|
526
|
+
...(contextPrefix === undefined ? {} : { contextPrefix }),
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function encryptionAudienceTagsFromMessage(message: GenericMessage): AudienceDependencyTags | undefined {
|
|
531
|
+
if (!isEncryptionProtocolMessage(message)) {
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const tags = (message.descriptor as Record<string, unknown>).tags;
|
|
536
|
+
if (!isRecordObject(tags)) {
|
|
537
|
+
return undefined;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const { protocol, contextId, role, epoch, keyId } = tags;
|
|
541
|
+
if (
|
|
542
|
+
typeof protocol !== 'string' ||
|
|
543
|
+
typeof contextId !== 'string' ||
|
|
544
|
+
typeof role !== 'string' ||
|
|
545
|
+
typeof epoch !== 'number' ||
|
|
546
|
+
typeof keyId !== 'string'
|
|
547
|
+
) {
|
|
548
|
+
return undefined;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
return { protocol, contextId, role, epoch, keyId };
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
function dependencyProtocolFromMessage(message: GenericMessage): string | undefined {
|
|
555
|
+
if (isEncryptionProtocolMessage(message)) {
|
|
556
|
+
const tags = (message.descriptor as Record<string, unknown>).tags;
|
|
557
|
+
const protocol = isRecordObject(tags) ? tags.protocol : undefined;
|
|
558
|
+
return typeof protocol === 'string' ? protocol : undefined;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const descriptor = message.descriptor as Record<string, unknown>;
|
|
562
|
+
const filter = descriptor.filter as Record<string, unknown> | undefined;
|
|
563
|
+
const protocol = descriptor.protocol ?? filter?.protocol;
|
|
564
|
+
return typeof protocol === 'string' ? protocol : undefined;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function isEncryptionProtocolMessage(message: GenericMessage): boolean {
|
|
568
|
+
const descriptor = message.descriptor as Record<string, unknown>;
|
|
569
|
+
return descriptor.interface === DwnInterfaceName.Records &&
|
|
570
|
+
descriptor.protocol === EncryptionProtocol.uri;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function roleContextPrefix(rolePath: string, contextId: string): string | undefined {
|
|
574
|
+
const roleSegments = rolePath.split('/').length - 1;
|
|
575
|
+
if (roleSegments === 0 || contextId === '') {
|
|
576
|
+
return undefined;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
return contextId.split('/').slice(0, roleSegments).join('/');
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function roleAudienceContextId(rolePath: string, contextId: string): string | undefined {
|
|
583
|
+
const roleSegments = rolePath.split('/').length - 1;
|
|
584
|
+
if (roleSegments === 0) {
|
|
585
|
+
return '';
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const contextSegments = contextId.split('/');
|
|
589
|
+
if (contextSegments.length < roleSegments) {
|
|
590
|
+
return undefined;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return contextSegments.slice(0, roleSegments).join('/');
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function isRecordObject(value: unknown): value is Record<string, unknown> {
|
|
597
|
+
return typeof value === 'object' && value !== null;
|
|
598
|
+
}
|
|
599
|
+
|
|
386
600
|
function isRecordsWrite(message: GenericMessage): message is GenericMessage & { recordId: string } {
|
|
387
601
|
return message.descriptor.interface === DwnInterfaceName.Records &&
|
|
388
602
|
message.descriptor.method === DwnMethodName.Write &&
|
|
@@ -7,6 +7,7 @@ import type { ValidationStateReader } from '../types/validation-state-reader.js'
|
|
|
7
7
|
import type { DataEncodedRecordsWriteMessage, RecordsWriteMessage } from '../types/records-types.js';
|
|
8
8
|
import type { ProtocolDefinition, ProtocolsConfigureMessage } from '../types/protocols-types.js';
|
|
9
9
|
|
|
10
|
+
import { ENCRYPTION_PROTOCOL_URI } from './constants.js';
|
|
10
11
|
import { FilterUtility } from '../utils/filter.js';
|
|
11
12
|
import { PermissionGrant } from '../protocols/permission-grant.js';
|
|
12
13
|
import { PermissionsProtocol } from '../protocols/permissions.js';
|
|
@@ -165,6 +166,35 @@ export class StoreValidationStateReader implements ValidationStateReader {
|
|
|
165
166
|
return matchingMessages as RecordsWriteMessage[];
|
|
166
167
|
}
|
|
167
168
|
|
|
169
|
+
/** @inheritdoc */
|
|
170
|
+
public async queryAudienceEpochs(input: {
|
|
171
|
+
tenant: string;
|
|
172
|
+
protocol: string;
|
|
173
|
+
contextId: string;
|
|
174
|
+
role: string;
|
|
175
|
+
epoch: number;
|
|
176
|
+
keyId?: string;
|
|
177
|
+
}): Promise<RecordsWriteMessage[]> {
|
|
178
|
+
const filter: Filter = {
|
|
179
|
+
interface : DwnInterfaceName.Records,
|
|
180
|
+
method : DwnMethodName.Write,
|
|
181
|
+
isLatestBaseState : true,
|
|
182
|
+
protocol : ENCRYPTION_PROTOCOL_URI,
|
|
183
|
+
protocolPath : 'audienceEpoch',
|
|
184
|
+
'tag.protocol' : input.protocol,
|
|
185
|
+
'tag.contextId' : input.contextId,
|
|
186
|
+
'tag.role' : input.role,
|
|
187
|
+
'tag.epoch' : input.epoch,
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
if (input.keyId !== undefined) {
|
|
191
|
+
filter['tag.keyId'] = input.keyId;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const { messages } = await this.messageStore.query(input.tenant, [filter]);
|
|
195
|
+
return messages as RecordsWriteMessage[];
|
|
196
|
+
}
|
|
197
|
+
|
|
168
198
|
/** @inheritdoc */
|
|
169
199
|
public async fetchGrant(tenant: string, permissionGrantId: string): Promise<PermissionGrant> {
|
|
170
200
|
const grantQuery = {
|
package/src/dwn.ts
CHANGED
|
@@ -41,6 +41,7 @@ import { Cid } from './utils/cid.js';
|
|
|
41
41
|
import { CoreProtocolRegistry } from './core/core-protocol.js';
|
|
42
42
|
import { DataStream } from './utils/data-stream.js';
|
|
43
43
|
import { DwnConstant } from './core/dwn-constant.js';
|
|
44
|
+
import { EncryptionProtocol } from './protocols/encryption.js';
|
|
44
45
|
import { Message } from './core/message.js';
|
|
45
46
|
import { messageReplyFromError } from './core/message-reply.js';
|
|
46
47
|
import { MessagesQueryHandler } from './handlers/messages-query.js';
|
|
@@ -115,6 +116,7 @@ export class Dwn {
|
|
|
115
116
|
|
|
116
117
|
// Initialize the core protocol registry with built-in system protocols.
|
|
117
118
|
this._coreProtocols = new CoreProtocolRegistry();
|
|
119
|
+
this._coreProtocols.register(new EncryptionProtocol());
|
|
118
120
|
this._coreProtocols.register(new PermissionsProtocol());
|
|
119
121
|
|
|
120
122
|
// The single narrow surface through which validation logic reads state (replay-basis closure).
|
|
@@ -426,7 +428,7 @@ export class Dwn {
|
|
|
426
428
|
RecordsWrite.validateDataIntegrity(message.descriptor.dataCid, message.descriptor.dataSize, dataCid, dataBytes.length);
|
|
427
429
|
|
|
428
430
|
if (coreProtocol?.validateRecord !== undefined) {
|
|
429
|
-
coreProtocol.validateRecord(message, dataBytes);
|
|
431
|
+
await coreProtocol.validateRecord(message, dataBytes);
|
|
430
432
|
}
|
|
431
433
|
|
|
432
434
|
return;
|
|
@@ -492,7 +494,10 @@ export class Dwn {
|
|
|
492
494
|
reply: { status: { detail?: string } },
|
|
493
495
|
): Promise<ProtocolDefinition | undefined> {
|
|
494
496
|
const detail = reply.status.detail ?? '';
|
|
495
|
-
if (
|
|
497
|
+
if (
|
|
498
|
+
!detail.startsWith(`${DwnErrorCode.ProtocolAuthorizationMatchingRoleRecordNotFound}:`) &&
|
|
499
|
+
!detail.startsWith(`${DwnErrorCode.EncryptionProtocolValidateAudienceWriterUnauthorized}:`)
|
|
500
|
+
) {
|
|
496
501
|
return undefined;
|
|
497
502
|
}
|
|
498
503
|
|
|
@@ -516,6 +521,14 @@ export class Dwn {
|
|
|
516
521
|
message: GenericMessage,
|
|
517
522
|
): ReplicationApplyProtocolDefinitionLookup | undefined {
|
|
518
523
|
if (Dwn.isRecordsWriteMessage(message)) {
|
|
524
|
+
const taggedProtocol = Dwn.getEncryptionRecordTaggedProtocol(message);
|
|
525
|
+
if (taggedProtocol !== undefined) {
|
|
526
|
+
return {
|
|
527
|
+
protocol : taggedProtocol,
|
|
528
|
+
messageTimestamp : message.descriptor.messageTimestamp,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
519
532
|
return {
|
|
520
533
|
protocol : message.descriptor.protocol,
|
|
521
534
|
messageTimestamp : message.descriptor.messageTimestamp,
|
|
@@ -526,6 +539,15 @@ export class Dwn {
|
|
|
526
539
|
return protocol === undefined ? undefined : { protocol };
|
|
527
540
|
}
|
|
528
541
|
|
|
542
|
+
private static getEncryptionRecordTaggedProtocol(message: RecordsWriteMessage): string | undefined {
|
|
543
|
+
if (message.descriptor.protocol !== EncryptionProtocol.uri) {
|
|
544
|
+
return undefined;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const protocol = message.descriptor.tags?.protocol;
|
|
548
|
+
return typeof protocol === 'string' ? protocol : undefined;
|
|
549
|
+
}
|
|
550
|
+
|
|
529
551
|
private static getMessageProtocolForReplicationApply(message: GenericMessage): string | undefined {
|
|
530
552
|
const descriptor = message.descriptor as { protocol?: unknown; filter?: { protocol?: unknown } };
|
|
531
553
|
if (typeof descriptor.protocol === 'string') {
|
|
@@ -9,7 +9,6 @@ import { messageReplyFromError } from '../core/message-reply.js';
|
|
|
9
9
|
import { Messages } from '../utils/messages.js';
|
|
10
10
|
import { MessagesGrantAuthorization } from '../core/messages-grant-authorization.js';
|
|
11
11
|
import { MessagesQuery } from '../interfaces/messages-query.js';
|
|
12
|
-
import { PermissionsProtocol } from '../protocols/permissions.js';
|
|
13
12
|
import { Replication } from '../utils/replication.js';
|
|
14
13
|
import { DwnError, DwnErrorCode } from '../core/dwn-error.js';
|
|
15
14
|
|
|
@@ -187,10 +186,12 @@ export class MessagesQueryHandler implements MethodHandler {
|
|
|
187
186
|
protocols.add(filter.protocol);
|
|
188
187
|
}
|
|
189
188
|
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
const scopes: string[] = [];
|
|
190
|
+
for (const protocol of protocols) {
|
|
191
|
+
scopes.push(
|
|
192
|
+
Replication.protocolDomain(protocol),
|
|
193
|
+
...Replication.taggedCoreProtocolDomains(protocol, protocols),
|
|
194
|
+
);
|
|
194
195
|
}
|
|
195
196
|
|
|
196
197
|
return scopes;
|
|
@@ -15,7 +15,7 @@ import { RecordsWrite } from '../interfaces/records-write.js';
|
|
|
15
15
|
import { StorageController } from '../store/storage-controller.js';
|
|
16
16
|
import { DwnError, DwnErrorCode } from '../core/dwn-error.js';
|
|
17
17
|
import { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
18
|
-
import { getRuleSetAtPath, parseCrossProtocolRef } from '../utils/protocols.js';
|
|
18
|
+
import { getRuleSetAtPath, getTypeName, parseCrossProtocolRef } from '../utils/protocols.js';
|
|
19
19
|
|
|
20
20
|
type StoredInitialWriteConfigValidity = 'valid' | 'invalid' | 'unknown';
|
|
21
21
|
|
|
@@ -291,7 +291,12 @@ export class ProtocolsConfigureHandler implements MethodHandler {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
// Walk the structure and validate all $ref paths and cross-protocol role references
|
|
294
|
-
ProtocolsConfigureHandler.validateRefsAndRolesRecursively(
|
|
294
|
+
ProtocolsConfigureHandler.validateRefsAndRolesRecursively(
|
|
295
|
+
definition,
|
|
296
|
+
definition.structure as ProtocolRuleSet,
|
|
297
|
+
'',
|
|
298
|
+
referencedDefinitions,
|
|
299
|
+
);
|
|
295
300
|
}
|
|
296
301
|
|
|
297
302
|
/**
|
|
@@ -300,6 +305,7 @@ export class ProtocolsConfigureHandler implements MethodHandler {
|
|
|
300
305
|
* - Cross-protocol `role` references point to valid `$role: true` paths in the referenced protocol
|
|
301
306
|
*/
|
|
302
307
|
private static validateRefsAndRolesRecursively(
|
|
308
|
+
definition: ProtocolDefinition,
|
|
303
309
|
ruleSet: ProtocolRuleSet,
|
|
304
310
|
protocolPath: string,
|
|
305
311
|
referencedDefinitions: Map<string, ProtocolDefinition>
|
|
@@ -362,6 +368,8 @@ export class ProtocolsConfigureHandler implements MethodHandler {
|
|
|
362
368
|
|
|
363
369
|
// Validate cross-protocol references in $actions (roles and `of` paths)
|
|
364
370
|
const actionRules = childRuleSet.$actions ?? [];
|
|
371
|
+
const typeName = getTypeName(childProtocolPath);
|
|
372
|
+
const isEncryptedPath = definition.types[typeName]?.encryptionRequired === true;
|
|
365
373
|
for (const actionRule of actionRules) {
|
|
366
374
|
// Validate cross-protocol role references
|
|
367
375
|
if (actionRule.role !== undefined) {
|
|
@@ -385,6 +393,14 @@ export class ProtocolsConfigureHandler implements MethodHandler {
|
|
|
385
393
|
`does not point to a valid role ($role: true) in protocol '${refDefinition.protocol}'.`
|
|
386
394
|
);
|
|
387
395
|
}
|
|
396
|
+
|
|
397
|
+
if (isEncryptedPath && actionRule.can.includes('read') && roleRuleSet.$keyAgreement === undefined) {
|
|
398
|
+
throw new DwnError(
|
|
399
|
+
DwnErrorCode.ProtocolsConfigureInvalidEncryptedRoleMissingKeyAgreement,
|
|
400
|
+
`encrypted protocol path '${childProtocolPath}' references cross-protocol role '${actionRule.role}' ` +
|
|
401
|
+
`with no $keyAgreement.`
|
|
402
|
+
);
|
|
403
|
+
}
|
|
388
404
|
}
|
|
389
405
|
}
|
|
390
406
|
|
|
@@ -414,7 +430,7 @@ export class ProtocolsConfigureHandler implements MethodHandler {
|
|
|
414
430
|
}
|
|
415
431
|
|
|
416
432
|
// Recurse into children
|
|
417
|
-
ProtocolsConfigureHandler.validateRefsAndRolesRecursively(childRuleSet, childProtocolPath, referencedDefinitions);
|
|
433
|
+
ProtocolsConfigureHandler.validateRefsAndRolesRecursively(definition, childRuleSet, childProtocolPath, referencedDefinitions);
|
|
418
434
|
}
|
|
419
435
|
}
|
|
420
436
|
}
|
|
@@ -244,7 +244,7 @@ export class RecordsWriteHandler implements MethodHandler {
|
|
|
244
244
|
? undefined
|
|
245
245
|
: this.deps.coreProtocols?.get(message.descriptor.protocol);
|
|
246
246
|
if (coreProtocol?.validateRecord !== undefined) {
|
|
247
|
-
coreProtocol.validateRecord(message, dataBytes);
|
|
247
|
+
await coreProtocol.validateRecord(message, dataBytes);
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
messageWithOptionalEncodedData = await this.cloneAndAddEncodedData(message, dataBytes);
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { RecordedValidationRead } from './core/recording-validation-state-r
|
|
|
10
10
|
export { RecordingValidationStateReader } from './core/recording-validation-state-reader.js';
|
|
11
11
|
export type { MessagesFilter, MessagesQueryDescriptor, MessagesQueryMessage, MessagesQueryReply, MessagesQueryReplyEntry, MessagesReadMessage, MessagesReadReply, MessagesReadReplyEntry, MessagesReadDescriptor, MessagesSubscribeDescriptor, MessagesSubscribeMessage, MessagesSubscribeReply, MessagesSubscribeMessageOptions } from './types/messages-types.js';
|
|
12
12
|
export type { GT, LT, Filter, FilterValue, KeyValues, EqualFilter, OneOfFilter, RangeFilter, RangeCriterion, PaginationCursor, QueryOptions, RangeValue, StartsWithFilter } from './types/query-types.js';
|
|
13
|
-
export type { ProtocolsConfigureDescriptor, ProtocolDefinition, ProtocolTypes, ProtocolRuleSet, ProtocolsQueryFilter, ProtocolsConfigureMessage, ProtocolsQueryMessage, ProtocolsQueryReply, ProtocolActionRule, ProtocolDeliveryStrategy,
|
|
13
|
+
export type { ProtocolsConfigureDescriptor, ProtocolDefinition, ProtocolTypes, ProtocolRuleSet, ProtocolsQueryFilter, ProtocolsConfigureMessage, ProtocolsQueryMessage, ProtocolsQueryReply, ProtocolActionRule, ProtocolDeliveryStrategy, ProtocolKeyAgreement, ProtocolsQueryDescriptor, ProtocolRecordLimitDefinition, ProtocolSizeDefinition, ProtocolTagsDefinition, ProtocolTagSchema, ProtocolType, ProtocolUses } from './types/protocols-types.js';
|
|
14
14
|
export { ProtocolRecordLimitStrategy } from './types/protocols-types.js';
|
|
15
15
|
export type { DataEncodedRecordsWriteMessage, RecordsCountDescriptor, RecordsCountMessage, RecordsCountReply, RecordsDeleteMessage, RecordsFilter, RecordsQueryMessage, RecordsQueryReply, RecordsQueryReplyEntry, RecordsReadMessage, RecordsReadReply, RecordsSubscribeDescriptor, RecordsSubscribeMessage, RecordsSubscribeReply, RecordsWriteDescriptor, RecordsWriteTags, RecordsWriteTagValue, RecordsWriteMessage, RecordsWriteSignaturePayload, RecordsDeleteDescriptor, RecordsQueryDescriptor, RecordsReadDescriptor, RecordsSubscribeMessageOptions, RecordsWriteMessageOptions, InternalRecordsWriteMessage, RecordEvent, RecordsWriteTagsFilter } from './types/records-types.js';
|
|
16
16
|
export type { GeneralJws, SignatureEntry } from './types/jws-types.js';
|
|
@@ -38,10 +38,19 @@ export { DwnInterfaceName, DwnMethodName } from './enums/dwn-interface-method.js
|
|
|
38
38
|
export { Encoder } from './utils/encoder.js';
|
|
39
39
|
export { MessagesSubscribe } from './interfaces/messages-subscribe.js';
|
|
40
40
|
export type { MessagesSubscribeOptions } from './interfaces/messages-subscribe.js';
|
|
41
|
-
export { Encryption, ContentEncryptionAlgorithm, KeyAgreementAlgorithm } from './utils/encryption.js';
|
|
42
|
-
export type {
|
|
41
|
+
export { Encryption, ContentEncryptionAlgorithm, KeyAgreementAlgorithm, ROLE_AUDIENCE_DERIVATION_SCHEME } from './utils/encryption.js';
|
|
42
|
+
export type {
|
|
43
|
+
DwnEncryption,
|
|
44
|
+
KeyEncryption,
|
|
45
|
+
KeyEncryptionInput,
|
|
46
|
+
KeyUnwrapPayload,
|
|
47
|
+
ProtocolPathKeyEncryption,
|
|
48
|
+
ProtocolPathKeyEncryptionInput,
|
|
49
|
+
RoleAudienceKeyEncryption,
|
|
50
|
+
RoleAudienceKeyEncryptionInput,
|
|
51
|
+
} from './utils/encryption.js';
|
|
43
52
|
export { RecordsWrite } from './interfaces/records-write.js';
|
|
44
|
-
export type { EncryptionInput,
|
|
53
|
+
export type { EncryptionInput, RecordsWriteOptions, CreateFromOptions } from './interfaces/records-write.js';
|
|
45
54
|
export { executeUnlessAborted } from './utils/abort.js';
|
|
46
55
|
export { Jws } from './utils/jws.js';
|
|
47
56
|
export type { KeyMaterial, PrivateKeyJwk, PublicKeyJwk, Jwk } from './types/jose-types.js';
|
|
@@ -57,6 +66,7 @@ export type { MessageInterface } from './types/message-interface.js';
|
|
|
57
66
|
export { PermissionGrant } from './protocols/permission-grant.js';
|
|
58
67
|
export { PermissionRequest } from './protocols/permission-request.js';
|
|
59
68
|
export { PermissionsProtocol } from './protocols/permissions.js';
|
|
69
|
+
export { EncryptionProtocol } from './protocols/encryption.js';
|
|
60
70
|
export type { PermissionGrantCreateOptions, PermissionRequestCreateOptions, PermissionRevocationCreateOptions } from './protocols/permissions.js';
|
|
61
71
|
export { PermissionScopeMatcher } from './utils/permission-scope.js';
|
|
62
72
|
export type { ProtocolScope } from './utils/permission-scope.js';
|
|
@@ -80,7 +90,7 @@ export { Secp256r1 } from './utils/secp256r1.js';
|
|
|
80
90
|
export type { SupportedCurve } from './jose/algorithms/signing/signature-algorithms.js';
|
|
81
91
|
export type { MessageSigner } from './types/signer.js';
|
|
82
92
|
export { SortDirection } from './types/query-types.js';
|
|
83
|
-
export type { EncryptionKeyDeriver, KeyDecrypter } from './types/encryption-types.js';
|
|
93
|
+
export type { EncryptionKeyDeriver, KeyDecrypter, KeyDecrypterDerivationScheme } from './types/encryption-types.js';
|
|
84
94
|
export { Time } from './utils/time.js';
|
|
85
95
|
export * from './types/permission-types.js';
|
|
86
96
|
export * from './types/records-types.js';
|