@enbox/dwn-sdk-js 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/browser.mjs +3 -3
  2. package/dist/browser.mjs.map +3 -3
  3. package/dist/esm/generated/precompiled-validators.js +1376 -2156
  4. package/dist/esm/generated/precompiled-validators.js.map +1 -1
  5. package/dist/esm/src/core/grant-authorization.js +14 -1
  6. package/dist/esm/src/core/grant-authorization.js.map +1 -1
  7. package/dist/esm/src/protocols/permission-grant.js +5 -0
  8. package/dist/esm/src/protocols/permission-grant.js.map +1 -1
  9. package/dist/esm/src/protocols/permissions.js +1 -0
  10. package/dist/esm/src/protocols/permissions.js.map +1 -1
  11. package/dist/esm/src/types/permission-types.js.map +1 -1
  12. package/dist/esm/tests/core/grant-authorization.spec.js +82 -4
  13. package/dist/esm/tests/core/grant-authorization.spec.js.map +1 -1
  14. package/dist/esm/tests/core/records-grant-authorization.spec.js +22 -5
  15. package/dist/esm/tests/core/records-grant-authorization.spec.js.map +1 -1
  16. package/dist/esm/tests/features/author-delegated-grant.spec.js +134 -10
  17. package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
  18. package/dist/esm/tests/features/permissions.spec.js +6 -6
  19. package/dist/esm/tests/features/permissions.spec.js.map +1 -1
  20. package/dist/esm/tests/handlers/records-count.spec.js +2 -2
  21. package/dist/esm/tests/handlers/records-count.spec.js.map +1 -1
  22. package/dist/esm/tests/handlers/records-query.spec.js +2 -2
  23. package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
  24. package/dist/esm/tests/handlers/records-read.spec.js +8 -2
  25. package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
  26. package/dist/esm/tests/handlers/records-subscribe.spec.js +2 -2
  27. package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
  28. package/dist/esm/tests/protocols/permission-grant.spec.js +55 -0
  29. package/dist/esm/tests/protocols/permission-grant.spec.js.map +1 -1
  30. package/dist/esm/tests/protocols/permission-request.spec.js +4 -4
  31. package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -1
  32. package/dist/esm/tests/protocols/permissions.spec.js +35 -2
  33. package/dist/esm/tests/protocols/permissions.spec.js.map +1 -1
  34. package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
  35. package/dist/types/src/core/grant-authorization.d.ts +2 -1
  36. package/dist/types/src/core/grant-authorization.d.ts.map +1 -1
  37. package/dist/types/src/protocols/permission-grant.d.ts +5 -1
  38. package/dist/types/src/protocols/permission-grant.d.ts.map +1 -1
  39. package/dist/types/src/protocols/permissions.d.ts +2 -1
  40. package/dist/types/src/protocols/permissions.d.ts.map +1 -1
  41. package/dist/types/src/types/permission-types.d.ts +48 -1
  42. package/dist/types/src/types/permission-types.d.ts.map +1 -1
  43. package/dist/types/tests/features/author-delegated-grant.spec.d.ts.map +1 -1
  44. package/dist/types/tests/handlers/records-read.spec.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/core/grant-authorization.ts +18 -1
  47. package/src/protocols/permission-grant.ts +7 -2
  48. package/src/protocols/permissions.ts +8 -6
  49. package/src/types/permission-types.ts +62 -1
@@ -1,4 +1,46 @@
1
1
  import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
2
+ /**
3
+ * Metadata describing the connect approval session that created a permission grant.
4
+ *
5
+ * Wallets use this to group grants into user-facing app sessions and to
6
+ * distinguish active sessions from expired permission bundles. App and client
7
+ * fields are self-reported by the requester, unauthenticated, and intended for
8
+ * display only. Consumers must not treat them as verified app identity.
9
+ */
10
+ export type ConnectSessionMetadata = {
11
+ /** Stable session ID shared by all grants created by one connect approval. */
12
+ id: string;
13
+ /** Human-readable app name shown during approval. Self-reported display data. */
14
+ appName?: string;
15
+ /** App icon URL shown during approval. Self-reported display data. */
16
+ appIcon?: string;
17
+ /** Origin of the requesting app, when known. Self-reported display data. */
18
+ origin?: string;
19
+ /** User agent string captured by the connect client, when available. Display data only. */
20
+ userAgent?: string;
21
+ /** Platform/device hint captured by the connect client, when available. */
22
+ platform?: string;
23
+ /** Primary browser language captured by the connect client, when available. */
24
+ language?: string;
25
+ /** Browser language preferences captured by the connect client, when available. */
26
+ languages?: string[];
27
+ /** IANA timezone captured by the connect client, when available. */
28
+ timezone?: string;
29
+ /** Connect transport that created the session. */
30
+ transport?: ConnectSessionTransport;
31
+ /** Timestamp when the wallet approved the connect session. */
32
+ createdAt: string;
33
+ /**
34
+ * Display timestamp for when the connect session expires.
35
+ *
36
+ * The enforcing value is the enclosing permission grant's `dateExpires`.
37
+ * Consumers must use `dateExpires`, not this metadata field, for any
38
+ * authorization or security decision.
39
+ */
40
+ expiresAt: string;
41
+ };
42
+ /** Connect transport that created a connect session. */
43
+ export type ConnectSessionTransport = 'relay' | 'postMessage';
2
44
  /**
3
45
  * Type for the data payload of a permission request message.
4
46
  */
@@ -51,6 +93,8 @@ export type PermissionGrantData = {
51
93
  rootKeyId: string;
52
94
  publicKeyJwk: Record<string, any>;
53
95
  };
96
+ /** Optional metadata for the connect session that created this grant. */
97
+ connectSession?: ConnectSessionMetadata;
54
98
  };
55
99
  /**
56
100
  * Type for the data payload of a permission revocation message.
@@ -87,10 +131,13 @@ export type MessagesPermissionScope = {
87
131
  };
88
132
  /**
89
133
  * The data model for a permission scope that is specific to the Records interface.
134
+ *
135
+ * `Read` is the only valid read-like Records permission scope and authorizes
136
+ * `RecordsRead`, `RecordsQuery`, `RecordsSubscribe`, and `RecordsCount` operations.
90
137
  */
91
138
  export type RecordsPermissionScope = {
92
139
  interface: DwnInterfaceName.Records;
93
- method: DwnMethodName.Count | DwnMethodName.Read | DwnMethodName.Write | DwnMethodName.Query | DwnMethodName.Subscribe | DwnMethodName.Delete;
140
+ method: DwnMethodName.Read | DwnMethodName.Write | DwnMethodName.Delete;
94
141
  protocol: string;
95
142
  /** May only be present when `protocol` is defined and `protocolPath` is undefined */
96
143
  contextId?: string;
@@ -1 +1 @@
1
- {"version":3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-grant.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/author-delegated-grant.spec.ts"],"names":[],"mappings":"AA2BA,wBAAgB,wBAAwB,IAAI,IAAI,CA0iD/C"}
1
+ {"version":3,"file":"author-delegated-grant.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/author-delegated-grant.spec.ts"],"names":[],"mappings":"AA2BA,wBAAgB,wBAAwB,IAAI,IAAI,CAurD/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"records-read.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-read.spec.ts"],"names":[],"mappings":"AAkCA,wBAAgB,sBAAsB,IAAI,IAAI,CAqnE7C"}
1
+ {"version":3,"file":"records-read.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-read.spec.ts"],"names":[],"mappings":"AAkCA,wBAAgB,sBAAsB,IAAI,IAAI,CA2nE7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/dwn-sdk-js",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "A reference implementation of https://identity.foundation/decentralized-web-node/spec/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -119,7 +119,8 @@ export class GrantAuthorization {
119
119
  * Verify that the `interface` and `method` grant scopes match the incoming message.
120
120
  *
121
121
  * For the Messages interface, a `Read` scope is treated as a unified scope that also authorizes
122
- * `Query`, `Subscribe`, and `Sync` operations.
122
+ * `Query` and `Subscribe` operations. For Records, `Read` is likewise the canonical read-like
123
+ * scope and authorizes `Read`, `Query`, `Subscribe`, and `Count` operations.
123
124
  *
124
125
  * @throws {DwnError} if the `interface` and `method` of the incoming message do not match the scope of the permission grant.
125
126
  */
@@ -155,6 +156,22 @@ export class GrantAuthorization {
155
156
  return;
156
157
  }
157
158
 
159
+ // Records.Read is the only valid read-like Records scope and covers Read, Query,
160
+ // Subscribe, and Count operations. Reject malformed Records Query/Subscribe/Count
161
+ // grants instead of treating them as compatible with the canonical Read scope.
162
+ if (dwnInterface === DwnInterfaceName.Records) {
163
+ const readLikeMethods = [DwnMethodName.Read, DwnMethodName.Query, DwnMethodName.Subscribe, DwnMethodName.Count];
164
+ if (readLikeMethods.includes(dwnMethod as DwnMethodName)) {
165
+ if (permissionGrant.scope.method !== DwnMethodName.Read) {
166
+ throw new DwnError(
167
+ DwnErrorCode.GrantAuthorizationMethodMismatch,
168
+ `records read-like permission grant must have method 'Read', got '${permissionGrant.scope.method}' for grant ${permissionGrant.id}`
169
+ );
170
+ }
171
+ return;
172
+ }
173
+ }
174
+
158
175
  if (dwnMethod !== permissionGrant.scope.method) {
159
176
  throw new DwnError(
160
177
  DwnErrorCode.GrantAuthorizationMethodMismatch,
@@ -1,5 +1,5 @@
1
1
  import type { DataEncodedRecordsWriteMessage } from '../types/records-types.js';
2
- import type { PermissionConditions, PermissionGrantData, PermissionScope } from '../types/permission-types.js';
2
+ import type { ConnectSessionMetadata, PermissionConditions, PermissionGrantData, PermissionScope } from '../types/permission-types.js';
3
3
 
4
4
  import { Encoder } from '../utils/encoder.js';
5
5
  import { Message } from '../core/message.js';
@@ -66,6 +66,11 @@ export class PermissionGrant {
66
66
  */
67
67
  public readonly delegateKeyDelivery?: { rootKeyId: string; publicKeyJwk: Record<string, any> };
68
68
 
69
+ /**
70
+ * Optional metadata describing the connect approval session that created this grant.
71
+ */
72
+ public readonly connectSession?: ConnectSessionMetadata;
73
+
69
74
  /**
70
75
  * Parses a `DataEncodedRecordsWriteMessage` into a `PermissionGrant`.
71
76
  * Validates that the message contains required structural fields:
@@ -138,6 +143,6 @@ export class PermissionGrant {
138
143
  this.scope = permissionGrant.scope;
139
144
  this.conditions = permissionGrant.conditions;
140
145
  this.delegateKeyDelivery = permissionGrant.delegateKeyDelivery;
146
+ this.connectSession = permissionGrant.connectSession;
141
147
  }
142
148
  }
143
-
@@ -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 : options.dateExpires,
426
- requestId : options.requestId,
427
- description : options.description,
428
- delegated : options.delegated,
426
+ dateExpires : options.dateExpires,
427
+ requestId : options.requestId,
428
+ description : options.description,
429
+ delegated : options.delegated,
429
430
  scope,
430
- conditions : options.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,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
  */
@@ -63,6 +118,9 @@ export type PermissionGrantData = {
63
118
  rootKeyId: string;
64
119
  publicKeyJwk: Record<string, any>;
65
120
  };
121
+
122
+ /** Optional metadata for the connect session that created this grant. */
123
+ connectSession?: ConnectSessionMetadata;
66
124
  };
67
125
 
68
126
  /**
@@ -104,10 +162,13 @@ export type MessagesPermissionScope = {
104
162
 
105
163
  /**
106
164
  * The data model for a permission scope that is specific to the Records interface.
165
+ *
166
+ * `Read` is the only valid read-like Records permission scope and authorizes
167
+ * `RecordsRead`, `RecordsQuery`, `RecordsSubscribe`, and `RecordsCount` operations.
107
168
  */
108
169
  export type RecordsPermissionScope = {
109
170
  interface: DwnInterfaceName.Records;
110
- method: DwnMethodName.Count | DwnMethodName.Read | DwnMethodName.Write | DwnMethodName.Query | DwnMethodName.Subscribe | DwnMethodName.Delete;
171
+ method: DwnMethodName.Read | DwnMethodName.Write | DwnMethodName.Delete;
111
172
  protocol: string;
112
173
  /** May only be present when `protocol` is defined and `protocolPath` is undefined */
113
174
  contextId?: string;