@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.
- package/dist/cjs/src/access/access-fetch.js +155 -0
- package/dist/cjs/src/access/access-rpc.js +131 -0
- package/dist/cjs/src/access.js +81 -107
- package/dist/cjs/src/auth/oidc.js +2 -2
- package/dist/cjs/src/nanotdf/Client.js +17 -13
- package/dist/cjs/src/nanotdf/models/Header.js +2 -2
- package/dist/cjs/src/nanotdf-crypto/keyAgreement.js +2 -2
- package/dist/cjs/src/opentdf.js +43 -9
- package/dist/cjs/src/platform/authorization/authorization_pb.js +138 -0
- package/dist/cjs/src/platform/buf/validate/validate_pb.js +410 -0
- package/dist/cjs/src/platform/common/common_pb.js +79 -0
- package/dist/cjs/src/platform/entityresolution/entity_resolution_pb.js +49 -0
- package/dist/cjs/src/platform/google/api/annotations_pb.js +30 -0
- package/dist/cjs/src/platform/google/api/http_pb.js +37 -0
- package/dist/cjs/src/platform/kas/kas_pb.js +96 -0
- package/dist/cjs/src/platform/policy/actions/actions_pb.js +70 -0
- package/dist/cjs/src/platform/policy/attributes/attributes_pb.js +240 -0
- package/dist/cjs/src/platform/policy/kasregistry/key_access_server_registry_pb.js +236 -0
- package/dist/cjs/src/platform/policy/keymanagement/key_management_pb.js +70 -0
- package/dist/cjs/src/platform/policy/namespaces/namespaces_pb.js +121 -0
- package/dist/cjs/src/platform/policy/objects_pb.js +395 -0
- package/dist/cjs/src/platform/policy/registeredresources/registered_resources_pb.js +132 -0
- package/dist/cjs/src/platform/policy/resourcemapping/resource_mapping_pb.js +139 -0
- package/dist/cjs/src/platform/policy/selectors_pb.js +67 -0
- package/dist/cjs/src/platform/policy/subjectmapping/subject_mapping_pb.js +146 -0
- package/dist/cjs/src/platform/policy/unsafe/unsafe_pb.js +124 -0
- package/dist/cjs/src/platform/protoc-gen-openapiv2/options/annotations_pb.js +68 -0
- package/dist/cjs/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.js +307 -0
- package/dist/cjs/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +33 -0
- package/dist/cjs/src/platform.js +124 -0
- package/dist/cjs/src/policy/api.js +21 -38
- package/dist/cjs/src/policy/attributes.js +4 -1
- package/dist/cjs/src/policy/granter.js +9 -9
- package/dist/cjs/src/utils.js +31 -1
- package/dist/cjs/src/version.js +2 -2
- package/dist/cjs/tdf3/src/assertions.js +5 -5
- package/dist/cjs/tdf3/src/client/index.js +24 -18
- package/dist/cjs/tdf3/src/tdf.js +16 -10
- package/dist/types/src/access/access-fetch.d.ts +21 -0
- package/dist/types/src/access/access-fetch.d.ts.map +1 -0
- package/dist/types/src/access/access-rpc.d.ts +22 -0
- package/dist/types/src/access/access-rpc.d.ts.map +1 -0
- package/dist/types/src/access.d.ts +19 -11
- package/dist/types/src/access.d.ts.map +1 -1
- package/dist/types/src/nanotdf/Client.d.ts +3 -1
- package/dist/types/src/nanotdf/Client.d.ts.map +1 -1
- package/dist/types/src/opentdf.d.ts +5 -1
- package/dist/types/src/opentdf.d.ts.map +1 -1
- package/dist/types/src/platform/authorization/authorization_pb.d.ts +609 -0
- package/dist/types/src/platform/authorization/authorization_pb.d.ts.map +1 -0
- package/dist/types/src/platform/buf/validate/validate_pb.d.ts +4466 -0
- package/dist/types/src/platform/buf/validate/validate_pb.d.ts.map +1 -0
- package/dist/types/src/platform/common/common_pb.d.ts +112 -0
- package/dist/types/src/platform/common/common_pb.d.ts.map +1 -0
- package/dist/types/src/platform/entityresolution/entity_resolution_pb.d.ts +199 -0
- package/dist/types/src/platform/entityresolution/entity_resolution_pb.d.ts.map +1 -0
- package/dist/types/src/platform/google/api/annotations_pb.d.ts +14 -0
- package/dist/types/src/platform/google/api/annotations_pb.d.ts.map +1 -0
- package/dist/types/src/platform/google/api/http_pb.d.ts +441 -0
- package/dist/types/src/platform/google/api/http_pb.d.ts.map +1 -0
- package/dist/types/src/platform/kas/kas_pb.d.ts +404 -0
- package/dist/types/src/platform/kas/kas_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/actions/actions_pb.d.ts +265 -0
- package/dist/types/src/platform/policy/actions/actions_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/attributes/attributes_pb.d.ts +1022 -0
- package/dist/types/src/platform/policy/attributes/attributes_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +1306 -0
- package/dist/types/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/keymanagement/key_management_pb.d.ts +269 -0
- package/dist/types/src/platform/policy/keymanagement/key_management_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/namespaces/namespaces_pb.d.ts +448 -0
- package/dist/types/src/platform/policy/namespaces/namespaces_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/objects_pb.d.ts +1112 -0
- package/dist/types/src/platform/policy/objects_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/registeredresources/registered_resources_pb.d.ts +539 -0
- package/dist/types/src/platform/policy/registeredresources/registered_resources_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +558 -0
- package/dist/types/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/selectors_pb.d.ts +221 -0
- package/dist/types/src/platform/policy/selectors_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +582 -0
- package/dist/types/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts.map +1 -0
- package/dist/types/src/platform/policy/unsafe/unsafe_pb.d.ts +513 -0
- package/dist/types/src/platform/policy/unsafe/unsafe_pb.d.ts.map +1 -0
- package/dist/types/src/platform/protoc-gen-openapiv2/options/annotations_pb.d.ts +62 -0
- package/dist/types/src/platform/protoc-gen-openapiv2/options/annotations_pb.d.ts.map +1 -0
- package/dist/types/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.d.ts +1441 -0
- package/dist/types/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.d.ts.map +1 -0
- package/dist/types/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +59 -0
- package/dist/types/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts.map +1 -0
- package/dist/types/src/platform.d.ts +49 -0
- package/dist/types/src/platform.d.ts.map +1 -0
- package/dist/types/src/policy/api.d.ts +1 -1
- package/dist/types/src/policy/api.d.ts.map +1 -1
- package/dist/types/src/policy/attributes.d.ts +10 -87
- package/dist/types/src/policy/attributes.d.ts.map +1 -1
- package/dist/types/src/policy/granter.d.ts.map +1 -1
- package/dist/types/src/utils.d.ts +10 -0
- package/dist/types/src/utils.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/tdf3/src/assertions.d.ts +1 -1
- package/dist/types/tdf3/src/assertions.d.ts.map +1 -1
- package/dist/types/tdf3/src/client/index.d.ts +8 -3
- package/dist/types/tdf3/src/client/index.d.ts.map +1 -1
- package/dist/types/tdf3/src/models/manifest.d.ts +1 -1
- package/dist/types/tdf3/src/models/manifest.d.ts.map +1 -1
- package/dist/types/tdf3/src/tdf.d.ts.map +1 -1
- package/dist/web/src/access/access-fetch.js +150 -0
- package/dist/web/src/access/access-rpc.js +125 -0
- package/dist/web/src/access.js +82 -110
- package/dist/web/src/auth/oidc.js +2 -2
- package/dist/web/src/nanotdf/Client.js +18 -14
- package/dist/web/src/nanotdf/models/Header.js +2 -2
- package/dist/web/src/nanotdf-crypto/keyAgreement.js +2 -2
- package/dist/web/src/opentdf.js +44 -10
- package/dist/web/src/platform/authorization/authorization_pb.js +135 -0
- package/dist/web/src/platform/buf/validate/validate_pb.js +407 -0
- package/dist/web/src/platform/common/common_pb.js +76 -0
- package/dist/web/src/platform/entityresolution/entity_resolution_pb.js +46 -0
- package/dist/web/src/platform/google/api/annotations_pb.js +27 -0
- package/dist/web/src/platform/google/api/http_pb.js +34 -0
- package/dist/web/src/platform/kas/kas_pb.js +93 -0
- package/dist/web/src/platform/policy/actions/actions_pb.js +67 -0
- package/dist/web/src/platform/policy/attributes/attributes_pb.js +237 -0
- package/dist/web/src/platform/policy/kasregistry/key_access_server_registry_pb.js +233 -0
- package/dist/web/src/platform/policy/keymanagement/key_management_pb.js +67 -0
- package/dist/web/src/platform/policy/namespaces/namespaces_pb.js +118 -0
- package/dist/web/src/platform/policy/objects_pb.js +392 -0
- package/dist/web/src/platform/policy/registeredresources/registered_resources_pb.js +129 -0
- package/dist/web/src/platform/policy/resourcemapping/resource_mapping_pb.js +136 -0
- package/dist/web/src/platform/policy/selectors_pb.js +64 -0
- package/dist/web/src/platform/policy/subjectmapping/subject_mapping_pb.js +143 -0
- package/dist/web/src/platform/policy/unsafe/unsafe_pb.js +121 -0
- package/dist/web/src/platform/protoc-gen-openapiv2/options/annotations_pb.js +65 -0
- package/dist/web/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.js +304 -0
- package/dist/web/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +30 -0
- package/dist/web/src/platform.js +87 -0
- package/dist/web/src/policy/api.js +23 -40
- package/dist/web/src/policy/attributes.js +3 -2
- package/dist/web/src/policy/granter.js +9 -9
- package/dist/web/src/utils.js +29 -1
- package/dist/web/src/version.js +2 -2
- package/dist/web/tdf3/src/assertions.js +5 -5
- package/dist/web/tdf3/src/client/index.js +26 -20
- package/dist/web/tdf3/src/tdf.js +16 -10
- package/package.json +17 -1
- package/src/access/access-fetch.ts +202 -0
- package/src/access/access-rpc.ts +175 -0
- package/src/access.ts +113 -138
- package/src/auth/oidc.ts +1 -1
- package/src/nanotdf/Client.ts +28 -18
- package/src/nanotdf/models/Header.ts +1 -1
- package/src/nanotdf-crypto/keyAgreement.ts +1 -1
- package/src/opentdf.ts +67 -11
- package/src/platform/authorization/authorization_pb.ts +689 -0
- package/src/platform/buf/validate/validate_pb.ts +4626 -0
- package/src/platform/common/common_pb.ts +135 -0
- package/src/platform/entityresolution/entity_resolution_pb.ts +233 -0
- package/src/platform/google/api/annotations_pb.ts +39 -0
- package/src/platform/google/api/http_pb.ts +474 -0
- package/src/platform/kas/kas_pb.ts +484 -0
- package/src/platform/policy/actions/actions_pb.ts +312 -0
- package/src/platform/policy/attributes/attributes_pb.ts +1181 -0
- package/src/platform/policy/kasregistry/key_access_server_registry_pb.ts +1482 -0
- package/src/platform/policy/keymanagement/key_management_pb.ts +316 -0
- package/src/platform/policy/namespaces/namespaces_pb.ts +528 -0
- package/src/platform/policy/objects_pb.ts +1319 -0
- package/src/platform/policy/registeredresources/registered_resources_pb.ts +623 -0
- package/src/platform/policy/resourcemapping/resource_mapping_pb.ts +658 -0
- package/src/platform/policy/selectors_pb.ts +277 -0
- package/src/platform/policy/subjectmapping/subject_mapping_pb.ts +687 -0
- package/src/platform/policy/unsafe/unsafe_pb.ts +593 -0
- package/src/platform/protoc-gen-openapiv2/options/annotations_pb.ts +83 -0
- package/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.ts +1615 -0
- package/src/platform/wellknownconfiguration/wellknown_configuration_pb.ts +78 -0
- package/src/platform.ts +122 -0
- package/src/policy/api.ts +29 -42
- package/src/policy/attributes.ts +12 -108
- package/src/policy/granter.ts +7 -8
- package/src/utils.ts +30 -0
- package/src/version.ts +1 -1
- package/tdf3/src/assertions.ts +4 -4
- package/tdf3/src/client/index.ts +42 -19
- package/tdf3/src/models/manifest.ts +2 -1
- package/tdf3/src/tdf.ts +25 -16
- package/src/platform/authorization/authorization_connect.d.ts +0 -44
- package/src/platform/authorization/authorization_connect.js +0 -44
- package/src/platform/authorization/authorization_pb.d.ts +0 -707
- package/src/platform/authorization/authorization_pb.js +0 -372
- package/src/platform/common/common_pb.d.ts +0 -129
- package/src/platform/common/common_pb.js +0 -58
- package/src/platform/entityresolution/entity_resolution_connect.d.ts +0 -35
- package/src/platform/entityresolution/entity_resolution_connect.js +0 -35
- package/src/platform/entityresolution/entity_resolution_pb.d.ts +0 -242
- package/src/platform/entityresolution/entity_resolution_pb.js +0 -139
- package/src/platform/kas/kas_connect.d.ts +0 -59
- package/src/platform/kas/kas_connect.js +0 -59
- package/src/platform/kas/kas_pb.d.ts +0 -200
- package/src/platform/kas/kas_pb.js +0 -84
- package/src/platform/policy/attributes/attributes_connect.d.ts +0 -168
- package/src/platform/policy/attributes/attributes_connect.js +0 -168
- package/src/platform/policy/attributes/attributes_pb.d.ts +0 -929
- package/src/platform/policy/attributes/attributes_pb.js +0 -363
- package/src/platform/policy/kasregistry/key_access_server_registry_connect.d.ts +0 -62
- package/src/platform/policy/kasregistry/key_access_server_registry_connect.js +0 -62
- package/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +0 -283
- package/src/platform/policy/kasregistry/key_access_server_registry_pb.js +0 -113
- package/src/platform/policy/namespaces/namespaces_connect.d.ts +0 -62
- package/src/platform/policy/namespaces/namespaces_connect.js +0 -62
- package/src/platform/policy/namespaces/namespaces_pb.d.ts +0 -270
- package/src/platform/policy/namespaces/namespaces_pb.js +0 -110
- package/src/platform/policy/objects_pb.d.ts +0 -725
- package/src/platform/policy/objects_pb.js +0 -288
- package/src/platform/policy/resourcemapping/resource_mapping_connect.d.ts +0 -259
- package/src/platform/policy/resourcemapping/resource_mapping_connect.js +0 -259
- package/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +0 -314
- package/src/platform/policy/resourcemapping/resource_mapping_pb.js +0 -142
- package/src/platform/policy/selectors_pb.d.ts +0 -269
- package/src/platform/policy/selectors_pb.js +0 -110
- package/src/platform/policy/subjectmapping/subject_mapping_connect.d.ts +0 -118
- package/src/platform/policy/subjectmapping/subject_mapping_connect.js +0 -118
- package/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +0 -672
- package/src/platform/policy/subjectmapping/subject_mapping_pb.js +0 -260
- package/src/platform/wellknownconfiguration/wellknown_configuration_connect.d.ts +0 -26
- package/src/platform/wellknownconfiguration/wellknown_configuration_connect.js +0 -26
- package/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +0 -75
- package/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +0 -35
package/tdf3/src/client/index.ts
CHANGED
|
@@ -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 {
|
|
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
|
|
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
|
|
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 `[
|
|
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
|
|
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 =
|
|
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 (!
|
|
303
|
-
|
|
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}]
|
|
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
|
-
|
|
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
|
-
|
|
430
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
291
|
-
targetSpecVersion
|
|
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
|
-
|
|
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
|
-
|
|
310
|
-
|
|
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
|
|
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(
|
|
535
|
-
|
|
536
|
-
|
|
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
|
-
|
|
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 =
|
|
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.
|
|
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
|
-
|