@opentdf/sdk 0.3.0 → 0.3.2-beta.1

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 (227) hide show
  1. package/dist/cjs/src/access/access-fetch.js +155 -0
  2. package/dist/cjs/src/access/access-rpc.js +131 -0
  3. package/dist/cjs/src/access.js +81 -107
  4. package/dist/cjs/src/auth/oidc.js +2 -2
  5. package/dist/cjs/src/nanotdf/Client.js +17 -13
  6. package/dist/cjs/src/nanotdf/models/Header.js +2 -2
  7. package/dist/cjs/src/nanotdf-crypto/keyAgreement.js +2 -2
  8. package/dist/cjs/src/opentdf.js +43 -9
  9. package/dist/cjs/src/platform/authorization/authorization_pb.js +138 -0
  10. package/dist/cjs/src/platform/buf/validate/validate_pb.js +410 -0
  11. package/dist/cjs/src/platform/common/common_pb.js +79 -0
  12. package/dist/cjs/src/platform/entityresolution/entity_resolution_pb.js +49 -0
  13. package/dist/cjs/src/platform/google/api/annotations_pb.js +30 -0
  14. package/dist/cjs/src/platform/google/api/http_pb.js +37 -0
  15. package/dist/cjs/src/platform/kas/kas_pb.js +96 -0
  16. package/dist/cjs/src/platform/policy/actions/actions_pb.js +70 -0
  17. package/dist/cjs/src/platform/policy/attributes/attributes_pb.js +240 -0
  18. package/dist/cjs/src/platform/policy/kasregistry/key_access_server_registry_pb.js +236 -0
  19. package/dist/cjs/src/platform/policy/keymanagement/key_management_pb.js +70 -0
  20. package/dist/cjs/src/platform/policy/namespaces/namespaces_pb.js +121 -0
  21. package/dist/cjs/src/platform/policy/objects_pb.js +395 -0
  22. package/dist/cjs/src/platform/policy/registeredresources/registered_resources_pb.js +132 -0
  23. package/dist/cjs/src/platform/policy/resourcemapping/resource_mapping_pb.js +139 -0
  24. package/dist/cjs/src/platform/policy/selectors_pb.js +67 -0
  25. package/dist/cjs/src/platform/policy/subjectmapping/subject_mapping_pb.js +146 -0
  26. package/dist/cjs/src/platform/policy/unsafe/unsafe_pb.js +124 -0
  27. package/dist/cjs/src/platform/protoc-gen-openapiv2/options/annotations_pb.js +68 -0
  28. package/dist/cjs/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.js +307 -0
  29. package/dist/cjs/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +33 -0
  30. package/dist/cjs/src/platform.js +124 -0
  31. package/dist/cjs/src/policy/api.js +21 -38
  32. package/dist/cjs/src/policy/attributes.js +4 -1
  33. package/dist/cjs/src/policy/granter.js +9 -9
  34. package/dist/cjs/src/utils.js +31 -1
  35. package/dist/cjs/src/version.js +2 -2
  36. package/dist/cjs/tdf3/src/assertions.js +5 -5
  37. package/dist/cjs/tdf3/src/client/index.js +24 -18
  38. package/dist/cjs/tdf3/src/tdf.js +16 -10
  39. package/dist/types/src/access/access-fetch.d.ts +21 -0
  40. package/dist/types/src/access/access-fetch.d.ts.map +1 -0
  41. package/dist/types/src/access/access-rpc.d.ts +22 -0
  42. package/dist/types/src/access/access-rpc.d.ts.map +1 -0
  43. package/dist/types/src/access.d.ts +19 -11
  44. package/dist/types/src/access.d.ts.map +1 -1
  45. package/dist/types/src/nanotdf/Client.d.ts +3 -1
  46. package/dist/types/src/nanotdf/Client.d.ts.map +1 -1
  47. package/dist/types/src/opentdf.d.ts +5 -1
  48. package/dist/types/src/opentdf.d.ts.map +1 -1
  49. package/dist/types/src/platform/authorization/authorization_pb.d.ts +609 -0
  50. package/dist/types/src/platform/authorization/authorization_pb.d.ts.map +1 -0
  51. package/dist/types/src/platform/buf/validate/validate_pb.d.ts +4466 -0
  52. package/dist/types/src/platform/buf/validate/validate_pb.d.ts.map +1 -0
  53. package/dist/types/src/platform/common/common_pb.d.ts +112 -0
  54. package/dist/types/src/platform/common/common_pb.d.ts.map +1 -0
  55. package/dist/types/src/platform/entityresolution/entity_resolution_pb.d.ts +199 -0
  56. package/dist/types/src/platform/entityresolution/entity_resolution_pb.d.ts.map +1 -0
  57. package/dist/types/src/platform/google/api/annotations_pb.d.ts +14 -0
  58. package/dist/types/src/platform/google/api/annotations_pb.d.ts.map +1 -0
  59. package/dist/types/src/platform/google/api/http_pb.d.ts +441 -0
  60. package/dist/types/src/platform/google/api/http_pb.d.ts.map +1 -0
  61. package/dist/types/src/platform/kas/kas_pb.d.ts +404 -0
  62. package/dist/types/src/platform/kas/kas_pb.d.ts.map +1 -0
  63. package/dist/types/src/platform/policy/actions/actions_pb.d.ts +265 -0
  64. package/dist/types/src/platform/policy/actions/actions_pb.d.ts.map +1 -0
  65. package/dist/types/src/platform/policy/attributes/attributes_pb.d.ts +1022 -0
  66. package/dist/types/src/platform/policy/attributes/attributes_pb.d.ts.map +1 -0
  67. package/dist/types/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +1306 -0
  68. package/dist/types/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts.map +1 -0
  69. package/dist/types/src/platform/policy/keymanagement/key_management_pb.d.ts +269 -0
  70. package/dist/types/src/platform/policy/keymanagement/key_management_pb.d.ts.map +1 -0
  71. package/dist/types/src/platform/policy/namespaces/namespaces_pb.d.ts +448 -0
  72. package/dist/types/src/platform/policy/namespaces/namespaces_pb.d.ts.map +1 -0
  73. package/dist/types/src/platform/policy/objects_pb.d.ts +1112 -0
  74. package/dist/types/src/platform/policy/objects_pb.d.ts.map +1 -0
  75. package/dist/types/src/platform/policy/registeredresources/registered_resources_pb.d.ts +539 -0
  76. package/dist/types/src/platform/policy/registeredresources/registered_resources_pb.d.ts.map +1 -0
  77. package/dist/types/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +558 -0
  78. package/dist/types/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts.map +1 -0
  79. package/dist/types/src/platform/policy/selectors_pb.d.ts +221 -0
  80. package/dist/types/src/platform/policy/selectors_pb.d.ts.map +1 -0
  81. package/dist/types/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +582 -0
  82. package/dist/types/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts.map +1 -0
  83. package/dist/types/src/platform/policy/unsafe/unsafe_pb.d.ts +513 -0
  84. package/dist/types/src/platform/policy/unsafe/unsafe_pb.d.ts.map +1 -0
  85. package/dist/types/src/platform/protoc-gen-openapiv2/options/annotations_pb.d.ts +62 -0
  86. package/dist/types/src/platform/protoc-gen-openapiv2/options/annotations_pb.d.ts.map +1 -0
  87. package/dist/types/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.d.ts +1441 -0
  88. package/dist/types/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.d.ts.map +1 -0
  89. package/dist/types/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +59 -0
  90. package/dist/types/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts.map +1 -0
  91. package/dist/types/src/platform.d.ts +49 -0
  92. package/dist/types/src/platform.d.ts.map +1 -0
  93. package/dist/types/src/policy/api.d.ts +1 -1
  94. package/dist/types/src/policy/api.d.ts.map +1 -1
  95. package/dist/types/src/policy/attributes.d.ts +10 -87
  96. package/dist/types/src/policy/attributes.d.ts.map +1 -1
  97. package/dist/types/src/policy/granter.d.ts.map +1 -1
  98. package/dist/types/src/utils.d.ts +10 -0
  99. package/dist/types/src/utils.d.ts.map +1 -1
  100. package/dist/types/src/version.d.ts +1 -1
  101. package/dist/types/tdf3/src/assertions.d.ts +1 -1
  102. package/dist/types/tdf3/src/assertions.d.ts.map +1 -1
  103. package/dist/types/tdf3/src/client/index.d.ts +8 -3
  104. package/dist/types/tdf3/src/client/index.d.ts.map +1 -1
  105. package/dist/types/tdf3/src/models/manifest.d.ts +1 -1
  106. package/dist/types/tdf3/src/models/manifest.d.ts.map +1 -1
  107. package/dist/types/tdf3/src/tdf.d.ts.map +1 -1
  108. package/dist/web/src/access/access-fetch.js +150 -0
  109. package/dist/web/src/access/access-rpc.js +125 -0
  110. package/dist/web/src/access.js +82 -110
  111. package/dist/web/src/auth/oidc.js +2 -2
  112. package/dist/web/src/nanotdf/Client.js +18 -14
  113. package/dist/web/src/nanotdf/models/Header.js +2 -2
  114. package/dist/web/src/nanotdf-crypto/keyAgreement.js +2 -2
  115. package/dist/web/src/opentdf.js +44 -10
  116. package/dist/web/src/platform/authorization/authorization_pb.js +135 -0
  117. package/dist/web/src/platform/buf/validate/validate_pb.js +407 -0
  118. package/dist/web/src/platform/common/common_pb.js +76 -0
  119. package/dist/web/src/platform/entityresolution/entity_resolution_pb.js +46 -0
  120. package/dist/web/src/platform/google/api/annotations_pb.js +27 -0
  121. package/dist/web/src/platform/google/api/http_pb.js +34 -0
  122. package/dist/web/src/platform/kas/kas_pb.js +93 -0
  123. package/dist/web/src/platform/policy/actions/actions_pb.js +67 -0
  124. package/dist/web/src/platform/policy/attributes/attributes_pb.js +237 -0
  125. package/dist/web/src/platform/policy/kasregistry/key_access_server_registry_pb.js +233 -0
  126. package/dist/web/src/platform/policy/keymanagement/key_management_pb.js +67 -0
  127. package/dist/web/src/platform/policy/namespaces/namespaces_pb.js +118 -0
  128. package/dist/web/src/platform/policy/objects_pb.js +392 -0
  129. package/dist/web/src/platform/policy/registeredresources/registered_resources_pb.js +129 -0
  130. package/dist/web/src/platform/policy/resourcemapping/resource_mapping_pb.js +136 -0
  131. package/dist/web/src/platform/policy/selectors_pb.js +64 -0
  132. package/dist/web/src/platform/policy/subjectmapping/subject_mapping_pb.js +143 -0
  133. package/dist/web/src/platform/policy/unsafe/unsafe_pb.js +121 -0
  134. package/dist/web/src/platform/protoc-gen-openapiv2/options/annotations_pb.js +65 -0
  135. package/dist/web/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.js +304 -0
  136. package/dist/web/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +30 -0
  137. package/dist/web/src/platform.js +87 -0
  138. package/dist/web/src/policy/api.js +23 -40
  139. package/dist/web/src/policy/attributes.js +3 -2
  140. package/dist/web/src/policy/granter.js +9 -9
  141. package/dist/web/src/utils.js +29 -1
  142. package/dist/web/src/version.js +2 -2
  143. package/dist/web/tdf3/src/assertions.js +5 -5
  144. package/dist/web/tdf3/src/client/index.js +26 -20
  145. package/dist/web/tdf3/src/tdf.js +16 -10
  146. package/package.json +17 -1
  147. package/src/access/access-fetch.ts +202 -0
  148. package/src/access/access-rpc.ts +175 -0
  149. package/src/access.ts +113 -138
  150. package/src/auth/oidc.ts +1 -1
  151. package/src/nanotdf/Client.ts +28 -18
  152. package/src/nanotdf/models/Header.ts +1 -1
  153. package/src/nanotdf-crypto/keyAgreement.ts +1 -1
  154. package/src/opentdf.ts +67 -11
  155. package/src/platform/authorization/authorization_pb.ts +689 -0
  156. package/src/platform/buf/validate/validate_pb.ts +4626 -0
  157. package/src/platform/common/common_pb.ts +135 -0
  158. package/src/platform/entityresolution/entity_resolution_pb.ts +233 -0
  159. package/src/platform/google/api/annotations_pb.ts +39 -0
  160. package/src/platform/google/api/http_pb.ts +474 -0
  161. package/src/platform/kas/kas_pb.ts +484 -0
  162. package/src/platform/policy/actions/actions_pb.ts +312 -0
  163. package/src/platform/policy/attributes/attributes_pb.ts +1181 -0
  164. package/src/platform/policy/kasregistry/key_access_server_registry_pb.ts +1482 -0
  165. package/src/platform/policy/keymanagement/key_management_pb.ts +316 -0
  166. package/src/platform/policy/namespaces/namespaces_pb.ts +528 -0
  167. package/src/platform/policy/objects_pb.ts +1319 -0
  168. package/src/platform/policy/registeredresources/registered_resources_pb.ts +623 -0
  169. package/src/platform/policy/resourcemapping/resource_mapping_pb.ts +658 -0
  170. package/src/platform/policy/selectors_pb.ts +277 -0
  171. package/src/platform/policy/subjectmapping/subject_mapping_pb.ts +687 -0
  172. package/src/platform/policy/unsafe/unsafe_pb.ts +593 -0
  173. package/src/platform/protoc-gen-openapiv2/options/annotations_pb.ts +83 -0
  174. package/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.ts +1615 -0
  175. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.ts +78 -0
  176. package/src/platform.ts +122 -0
  177. package/src/policy/api.ts +29 -42
  178. package/src/policy/attributes.ts +12 -108
  179. package/src/policy/granter.ts +7 -8
  180. package/src/utils.ts +30 -0
  181. package/src/version.ts +1 -1
  182. package/tdf3/src/assertions.ts +4 -4
  183. package/tdf3/src/client/index.ts +42 -19
  184. package/tdf3/src/models/manifest.ts +2 -1
  185. package/tdf3/src/tdf.ts +25 -16
  186. package/src/platform/authorization/authorization_connect.d.ts +0 -44
  187. package/src/platform/authorization/authorization_connect.js +0 -44
  188. package/src/platform/authorization/authorization_pb.d.ts +0 -707
  189. package/src/platform/authorization/authorization_pb.js +0 -372
  190. package/src/platform/common/common_pb.d.ts +0 -129
  191. package/src/platform/common/common_pb.js +0 -58
  192. package/src/platform/entityresolution/entity_resolution_connect.d.ts +0 -35
  193. package/src/platform/entityresolution/entity_resolution_connect.js +0 -35
  194. package/src/platform/entityresolution/entity_resolution_pb.d.ts +0 -242
  195. package/src/platform/entityresolution/entity_resolution_pb.js +0 -139
  196. package/src/platform/kas/kas_connect.d.ts +0 -59
  197. package/src/platform/kas/kas_connect.js +0 -59
  198. package/src/platform/kas/kas_pb.d.ts +0 -200
  199. package/src/platform/kas/kas_pb.js +0 -84
  200. package/src/platform/policy/attributes/attributes_connect.d.ts +0 -168
  201. package/src/platform/policy/attributes/attributes_connect.js +0 -168
  202. package/src/platform/policy/attributes/attributes_pb.d.ts +0 -929
  203. package/src/platform/policy/attributes/attributes_pb.js +0 -363
  204. package/src/platform/policy/kasregistry/key_access_server_registry_connect.d.ts +0 -62
  205. package/src/platform/policy/kasregistry/key_access_server_registry_connect.js +0 -62
  206. package/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +0 -283
  207. package/src/platform/policy/kasregistry/key_access_server_registry_pb.js +0 -113
  208. package/src/platform/policy/namespaces/namespaces_connect.d.ts +0 -62
  209. package/src/platform/policy/namespaces/namespaces_connect.js +0 -62
  210. package/src/platform/policy/namespaces/namespaces_pb.d.ts +0 -270
  211. package/src/platform/policy/namespaces/namespaces_pb.js +0 -110
  212. package/src/platform/policy/objects_pb.d.ts +0 -725
  213. package/src/platform/policy/objects_pb.js +0 -288
  214. package/src/platform/policy/resourcemapping/resource_mapping_connect.d.ts +0 -259
  215. package/src/platform/policy/resourcemapping/resource_mapping_connect.js +0 -259
  216. package/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +0 -314
  217. package/src/platform/policy/resourcemapping/resource_mapping_pb.js +0 -142
  218. package/src/platform/policy/selectors_pb.d.ts +0 -269
  219. package/src/platform/policy/selectors_pb.js +0 -110
  220. package/src/platform/policy/subjectmapping/subject_mapping_connect.d.ts +0 -118
  221. package/src/platform/policy/subjectmapping/subject_mapping_connect.js +0 -118
  222. package/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +0 -672
  223. package/src/platform/policy/subjectmapping/subject_mapping_pb.js +0 -260
  224. package/src/platform/wellknownconfiguration/wellknown_configuration_connect.d.ts +0 -26
  225. package/src/platform/wellknownconfiguration/wellknown_configuration_connect.js +0 -26
  226. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +0 -75
  227. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +0 -35
@@ -19,7 +19,12 @@ import { OIDCRefreshTokenProvider } from '../../../src/auth/oidc-refreshtoken-pr
19
19
  import { OIDCExternalJwtProvider } from '../../../src/auth/oidc-externaljwt-provider.js';
20
20
  import { CryptoService } from '../crypto/declarations.js';
21
21
  import { type AuthProvider, HttpRequest, withHeaders } from '../../../src/auth/auth.js';
22
- import { pemToCryptoPublicKey, rstrip, validateSecureUrl } from '../../../src/utils.js';
22
+ import {
23
+ getPlatformUrlFromKasEndpoint,
24
+ pemToCryptoPublicKey,
25
+ rstrip,
26
+ validateSecureUrl,
27
+ } from '../../../src/utils.js';
23
28
 
24
29
  import {
25
30
  type EncryptParams,
@@ -39,6 +44,7 @@ import {
39
44
  EncryptParamsBuilder,
40
45
  } from './builders.js';
41
46
  import {
47
+ fetchKeyAccessServers,
42
48
  type KasPublicKeyInfo,
43
49
  keyAlgorithmToPublicKeyAlgorithm,
44
50
  OriginAllowList,
@@ -73,7 +79,7 @@ export const resolveKasInfo = async (
73
79
  kid?: string
74
80
  ): Promise<KasPublicKeyInfo> => {
75
81
  const k: CryptoKey = await pemToCryptoPublicKey(pem);
76
- const algorithm = keyAlgorithmToPublicKeyAlgorithm(k.algorithm);
82
+ const algorithm = keyAlgorithmToPublicKeyAlgorithm(k);
77
83
  return {
78
84
  key: Promise.resolve(k),
79
85
  publicKey: pem,
@@ -125,7 +131,7 @@ export interface ClientConfig {
125
131
  clientId?: string;
126
132
  dpopEnabled?: boolean;
127
133
  dpopKeys?: Promise<CryptoKeyPair>;
128
- kasEndpoint?: string;
134
+ kasEndpoint: string;
129
135
  /**
130
136
  * Service to use to look up ABAC. Used during autoconfigure. Defaults to
131
137
  * kasEndpoint without the trailing `/kas` path segment, if present.
@@ -133,9 +139,11 @@ export interface ClientConfig {
133
139
  policyEndpoint?: string;
134
140
  /**
135
141
  * List of allowed KASes to connect to for rewrap requests.
136
- * Defaults to `[kasEndpoint]`.
142
+ * Defaults to `[]`.
137
143
  */
138
144
  allowedKases?: string[];
145
+ // Platform URL to use to lookup allowed KASes when allowedKases is empty
146
+ platformUrl?: string;
139
147
  ignoreAllowList?: boolean;
140
148
  easEndpoint?: string;
141
149
  // DEPRECATED Ignored
@@ -237,7 +245,12 @@ export class Client {
237
245
  * List of allowed KASes to connect to for rewrap requests.
238
246
  * Defaults to `[this.kasEndpoint]`.
239
247
  */
240
- readonly allowedKases: OriginAllowList;
248
+ readonly allowedKases?: OriginAllowList;
249
+
250
+ /**
251
+ * URL of the platform, required to fetch list of allowed KASes when allowedKases is empty
252
+ */
253
+ readonly platformUrl?: string;
241
254
 
242
255
  readonly kasKeys: Record<string, Promise<KasPublicKeyInfo>[]> = {};
243
256
 
@@ -287,10 +300,17 @@ export class Client {
287
300
  this.kasEndpoint = clientConfig.keyRewrapEndpoint.replace(/\/rewrap$/, '');
288
301
  }
289
302
  this.kasEndpoint = rstrip(this.kasEndpoint, '/');
303
+
304
+ if (!validateSecureUrl(this.kasEndpoint)) {
305
+ throw new ConfigurationError(`Invalid KAS endpoint [${this.kasEndpoint}]`);
306
+ }
307
+
308
+ if (config.platformUrl) {
309
+ this.platformUrl = config.platformUrl;
310
+ }
311
+
290
312
  if (clientConfig.policyEndpoint) {
291
- this.policyEndpoint = rstrip(clientConfig.policyEndpoint, '/');
292
- } else if (this.kasEndpoint.endsWith('/kas')) {
293
- this.policyEndpoint = this.kasEndpoint.slice(0, -4);
313
+ this.policyEndpoint = getPlatformUrlFromKasEndpoint(clientConfig.policyEndpoint);
294
314
  }
295
315
 
296
316
  const kasOrigin = new URL(this.kasEndpoint).origin;
@@ -299,16 +319,12 @@ export class Client {
299
319
  clientConfig.allowedKases,
300
320
  !!clientConfig.ignoreAllowList
301
321
  );
302
- if (!validateSecureUrl(this.kasEndpoint) && !this.allowedKases.allows(kasOrigin)) {
303
- throw new ConfigurationError(`Invalid KAS endpoint [${this.kasEndpoint}]`);
304
- }
305
- } else {
306
- if (!validateSecureUrl(this.kasEndpoint)) {
322
+ if (!this.allowedKases.allows(kasOrigin)) {
323
+ // TODO PR: ask if in this cases it makes more sense to add defaultKASEndpoint to the allow list if the allowList is not empty but doesn't have the defaultKas
307
324
  throw new ConfigurationError(
308
- `Invalid KAS endpoint [${this.kasEndpoint}]; to force, please list it among allowedKases`
325
+ `Invalid KAS endpoint [${this.kasEndpoint}]. When allowedKases is set, defaultKASEndpoint needs to be in the allow list`
309
326
  );
310
327
  }
311
- this.allowedKases = new OriginAllowList([kasOrigin], !!clientConfig.ignoreAllowList);
312
328
  }
313
329
 
314
330
  this.authProvider = config.authProvider;
@@ -381,7 +397,8 @@ export class Client {
381
397
  windowSize = DEFAULT_SEGMENT_SIZE,
382
398
  keyMiddleware = defaultKeyMiddleware,
383
399
  streamMiddleware = async (stream: DecoratedReadableStream) => stream,
384
- wrappingKeyAlgorithm = 'rsa:2048',
400
+ tdfSpecVersion,
401
+ wrappingKeyAlgorithm,
385
402
  } = opts;
386
403
  const scope = opts.scope ?? { attributes: [], dissem: [] };
387
404
 
@@ -426,8 +443,9 @@ export class Client {
426
443
  const detailedPlan = plan(avs);
427
444
  splitPlan = detailedPlan.map((kat) => {
428
445
  const { kas, sid } = kat;
429
- if (kas?.publicKey?.cached?.keys && !(kas.uri in this.kasKeys)) {
430
- const keys = kas.publicKey.cached.keys;
446
+ const pubKey = kas.publicKey?.publicKey;
447
+ if (pubKey?.case === 'cached' && pubKey.value.keys && !(kas.uri in this.kasKeys)) {
448
+ const keys = pubKey.value.keys;
431
449
  if (keys?.length) {
432
450
  this.kasKeys[kas.uri] = keys.map((key) => resolveKasInfo(key.pem, kas.uri, key.kid));
433
451
  }
@@ -498,6 +516,7 @@ export class Client {
498
516
  keyForEncryption,
499
517
  keyForManifest,
500
518
  assertionConfigs: opts.assertionConfigs,
519
+ tdfSpecVersion,
501
520
  };
502
521
 
503
522
  return (streamMiddleware as EncryptStreamMiddleware)(await writeStream(ecfg));
@@ -529,8 +548,12 @@ export class Client {
529
548
  throw new ConfigurationError('AuthProvider missing');
530
549
  }
531
550
  const chunker = await makeChunkable(source);
532
- if (!allowList) {
551
+ if (!allowList && this.allowedKases) {
533
552
  allowList = this.allowedKases;
553
+ } else if (this.platformUrl) {
554
+ allowList = await fetchKeyAccessServers(this.platformUrl, this.authProvider);
555
+ } else {
556
+ throw new ConfigurationError('platformUrl is required when allowedKases is empty');
534
557
  }
535
558
 
536
559
  // Await in order to catch any errors from this call.
@@ -6,7 +6,8 @@ export type Manifest = {
6
6
  payload: Payload;
7
7
  encryptionInformation: EncryptionInformation;
8
8
  assertions: Assertion[];
9
- schemaVersion: string;
9
+ // Required in later versions, optional prior to 4.3.0
10
+ schemaVersion?: string;
10
11
  // Deprecated
11
12
  tdf_spec_version?: string;
12
13
  };
package/tdf3/src/tdf.ts CHANGED
@@ -199,7 +199,7 @@ export async function fetchKasPublicKey(
199
199
  kas: string,
200
200
  algorithm?: KasPublicKeyAlgorithm
201
201
  ): Promise<KasPublicKeyInfo> {
202
- return fetchKasPubKeyV2(kas, algorithm || 'rsa:2048');
202
+ return fetchKasPubKeyV2(kas, algorithm);
203
203
  }
204
204
 
205
205
  export async function extractPemFromKeyString(
@@ -287,8 +287,8 @@ async function _generateManifest(
287
287
  keyInfo: KeyInfo,
288
288
  encryptionInformation: SplitKey,
289
289
  policy: Policy,
290
- mimeType: string | undefined,
291
- targetSpecVersion: string | undefined
290
+ mimeType?: string,
291
+ targetSpecVersion?: string
292
292
  ): Promise<Manifest> {
293
293
  // (maybe) Fields are quoted to avoid renaming
294
294
  const payload: Payload = {
@@ -301,13 +301,19 @@ async function _generateManifest(
301
301
 
302
302
  const encryptionInformationStr = await encryptionInformation.write(policy, keyInfo);
303
303
  const assertions: assertions.Assertion[] = [];
304
- return {
304
+ const partial = {
305
305
  payload,
306
306
  // generate the manifest first, then insert integrity information into it
307
307
  encryptionInformation: encryptionInformationStr,
308
308
  assertions: assertions,
309
- // when `targetSpecVersion` is provided, overrides the tdfSpecVersion
310
- schemaVersion: targetSpecVersion || tdfSpecVersion,
309
+ };
310
+ const schemaVersion = targetSpecVersion || tdfSpecVersion;
311
+ if (schemaVersion === '4.2.2') {
312
+ return partial;
313
+ }
314
+ return {
315
+ ...partial,
316
+ schemaVersion,
311
317
  };
312
318
  }
313
319
 
@@ -401,7 +407,7 @@ export async function writeStream(cfg: EncryptConfiguration): Promise<DecoratedR
401
407
  cfg.encryptionInformation,
402
408
  cfg.policy,
403
409
  cfg.mimeType,
404
- cfg.tdfSpecVersion ?? '4.3.0'
410
+ cfg.tdfSpecVersion
405
411
  );
406
412
 
407
413
  if (!manifest) {
@@ -531,10 +537,14 @@ export async function writeStream(cfg: EncryptConfiguration): Promise<DecoratedR
531
537
  alg: 'HS256',
532
538
  key: new Uint8Array(cfg.keyForEncryption.unwrappedKeyBinary.asArrayBuffer()),
533
539
  };
534
- const assertion = await assertions.CreateAssertion(aggregateHash, {
535
- ...assertionConfig,
536
- signingKey,
537
- });
540
+ const assertion = await assertions.CreateAssertion(
541
+ aggregateHash,
542
+ {
543
+ ...assertionConfig,
544
+ signingKey,
545
+ },
546
+ cfg.tdfSpecVersion
547
+ );
538
548
 
539
549
  // Add signed assertion to the signedAssertions array
540
550
  signedAssertions.push(assertion);
@@ -756,9 +766,8 @@ async function unwrapKey({
756
766
 
757
767
  const { entityWrappedKey, metadata, sessionPublicKey } = await fetchWrappedKey(
758
768
  url,
759
- { signedRequestToken },
760
- authProvider,
761
- '0.0.1'
769
+ signedRequestToken,
770
+ authProvider
762
771
  );
763
772
 
764
773
  if (wrappingKeyAlgorithm === 'ec:secp256r1') {
@@ -768,7 +777,7 @@ async function unwrapKey({
768
777
  hkdfSalt: await ztdfSalt,
769
778
  hkdfHash: 'SHA-256',
770
779
  });
771
- const wrappedKeyAndNonce = base64.decodeArrayBuffer(entityWrappedKey);
780
+ const wrappedKeyAndNonce = entityWrappedKey;
772
781
  const iv = wrappedKeyAndNonce.slice(0, 12);
773
782
  const wrappedKey = wrappedKeyAndNonce.slice(12);
774
783
 
@@ -779,7 +788,7 @@ async function unwrapKey({
779
788
  metadata,
780
789
  };
781
790
  }
782
- const key = Binary.fromString(base64.decode(entityWrappedKey));
791
+ const key = Binary.fromArrayBuffer(entityWrappedKey);
783
792
  const decryptedKeyBinary = await cryptoService.decryptWithPrivateKey(
784
793
  key,
785
794
  ephemeralEncryptionKeys.privateKey
@@ -1,44 +0,0 @@
1
- // @generated by protoc-gen-connect-es v1.4.0 with parameter "target=js+dts,import_extension=none"
2
- // @generated from file authorization/authorization.proto (package authorization, syntax proto3)
3
- /* eslint-disable */
4
- // @ts-nocheck
5
-
6
- import { GetDecisionsByTokenRequest, GetDecisionsByTokenResponse, GetDecisionsRequest, GetDecisionsResponse, GetEntitlementsRequest, GetEntitlementsResponse } from "./authorization_pb";
7
- import { MethodKind } from "@bufbuild/protobuf";
8
-
9
- /**
10
- * @generated from service authorization.AuthorizationService
11
- */
12
- export declare const AuthorizationService: {
13
- readonly typeName: "authorization.AuthorizationService",
14
- readonly methods: {
15
- /**
16
- * @generated from rpc authorization.AuthorizationService.GetDecisions
17
- */
18
- readonly getDecisions: {
19
- readonly name: "GetDecisions",
20
- readonly I: typeof GetDecisionsRequest,
21
- readonly O: typeof GetDecisionsResponse,
22
- readonly kind: MethodKind.Unary,
23
- },
24
- /**
25
- * @generated from rpc authorization.AuthorizationService.GetDecisionsByToken
26
- */
27
- readonly getDecisionsByToken: {
28
- readonly name: "GetDecisionsByToken",
29
- readonly I: typeof GetDecisionsByTokenRequest,
30
- readonly O: typeof GetDecisionsByTokenResponse,
31
- readonly kind: MethodKind.Unary,
32
- },
33
- /**
34
- * @generated from rpc authorization.AuthorizationService.GetEntitlements
35
- */
36
- readonly getEntitlements: {
37
- readonly name: "GetEntitlements",
38
- readonly I: typeof GetEntitlementsRequest,
39
- readonly O: typeof GetEntitlementsResponse,
40
- readonly kind: MethodKind.Unary,
41
- },
42
- }
43
- };
44
-
@@ -1,44 +0,0 @@
1
- // @generated by protoc-gen-connect-es v1.4.0 with parameter "target=js+dts,import_extension=none"
2
- // @generated from file authorization/authorization.proto (package authorization, syntax proto3)
3
- /* eslint-disable */
4
- // @ts-nocheck
5
-
6
- import { GetDecisionsByTokenRequest, GetDecisionsByTokenResponse, GetDecisionsRequest, GetDecisionsResponse, GetEntitlementsRequest, GetEntitlementsResponse } from "./authorization_pb";
7
- import { MethodKind } from "@bufbuild/protobuf";
8
-
9
- /**
10
- * @generated from service authorization.AuthorizationService
11
- */
12
- export const AuthorizationService = {
13
- typeName: "authorization.AuthorizationService",
14
- methods: {
15
- /**
16
- * @generated from rpc authorization.AuthorizationService.GetDecisions
17
- */
18
- getDecisions: {
19
- name: "GetDecisions",
20
- I: GetDecisionsRequest,
21
- O: GetDecisionsResponse,
22
- kind: MethodKind.Unary,
23
- },
24
- /**
25
- * @generated from rpc authorization.AuthorizationService.GetDecisionsByToken
26
- */
27
- getDecisionsByToken: {
28
- name: "GetDecisionsByToken",
29
- I: GetDecisionsByTokenRequest,
30
- O: GetDecisionsByTokenResponse,
31
- kind: MethodKind.Unary,
32
- },
33
- /**
34
- * @generated from rpc authorization.AuthorizationService.GetEntitlements
35
- */
36
- getEntitlements: {
37
- name: "GetEntitlements",
38
- I: GetEntitlementsRequest,
39
- O: GetEntitlementsResponse,
40
- kind: MethodKind.Unary,
41
- },
42
- }
43
- };
44
-