gdc-common-utils-ts 2.5.15 → 2.5.17

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.
@@ -242,9 +242,24 @@ export class CryptographyService {
242
242
  throw new Error("Invalid Detached JWS format");
243
243
  const protectedHeaderB64Url = parts[0];
244
244
  const signatureB64Url = parts[1];
245
- const payloadB64Url = Content.bytesToRawBase64UrlSafe(payloadBytes);
246
- const signingInput = `${protectedHeaderB64Url}.${payloadB64Url}`;
247
- const signingInputBytes = Content.stringToBytesUTF8(signingInput);
245
+ const protectedHeader = Content.base64UrlSafeToJSON(protectedHeaderB64Url);
246
+ if (protectedHeader.b64 !== undefined && typeof protectedHeader.b64 !== 'boolean') {
247
+ throw new Error("Detached JWS protected header 'b64' must be boolean.");
248
+ }
249
+ if (protectedHeader.b64 === false
250
+ && (!Array.isArray(protectedHeader.crit) || !protectedHeader.crit.includes('b64'))) {
251
+ throw new Error("RFC 7797 detached JWS with 'b64=false' must mark 'b64' critical.");
252
+ }
253
+ let signingInputBytes;
254
+ if (protectedHeader.b64 === false) {
255
+ const prefix = Content.stringToBytesUTF8(`${protectedHeaderB64Url}.`);
256
+ signingInputBytes = new Uint8Array(prefix.length + payloadBytes.length);
257
+ signingInputBytes.set(prefix);
258
+ signingInputBytes.set(payloadBytes, prefix.length);
259
+ }
260
+ else {
261
+ signingInputBytes = Content.stringToBytesUTF8(`${protectedHeaderB64Url}.${Content.bytesToRawBase64UrlSafe(payloadBytes)}`);
262
+ }
248
263
  const signatureBytes = Content.base64ToBytes(signatureB64Url);
249
264
  return this.verifyBytes(signatureBytes, signingInputBytes, publicJWKey);
250
265
  }
@@ -1 +1,2 @@
1
+ export declare const EXAMPLE_LEGAL_ORGANIZATION_SERVICE_TYPE: string;
1
2
  export declare const EXAMPLE_LEGAL_ORGANIZATION_VERIFICATION_TRANSACTION_BUNDLE: import("..").BundleJsonApi<import("..").ErrorEntry | import("..").BundleEntry>;
@@ -30,6 +30,15 @@ const exampleControllerBinding = {
30
30
  }
31
31
  : {}),
32
32
  };
33
+ /** Canonical capabilities reused by organization-onboarding editor tests. */
34
+ const exampleLegalOrganizationServiceType = serializeServiceCapabilityTokens([
35
+ ServiceCapability.IndexProvider,
36
+ ServiceCapability.DigitalTwinReader,
37
+ ]);
38
+ if (!exampleLegalOrganizationServiceType) {
39
+ throw new Error('Canonical legal-organization example capabilities must not be empty.');
40
+ }
41
+ export const EXAMPLE_LEGAL_ORGANIZATION_SERVICE_TYPE = exampleLegalOrganizationServiceType;
33
42
  export const EXAMPLE_LEGAL_ORGANIZATION_VERIFICATION_TRANSACTION_BUNDLE = buildLegalOrganizationVerificationTransactionBundle({
34
43
  claims: {
35
44
  '@context': 'org.schema',
@@ -42,10 +51,7 @@ export const EXAMPLE_LEGAL_ORGANIZATION_VERIFICATION_TRANSACTION_BUNDLE = buildL
42
51
  [ClaimsServiceSchemaorg.category]: EXAMPLE_SECTOR,
43
52
  [ClaimsServiceSchemaorg.identifier]: EXAMPLE_TENANT_SERVICE_DID,
44
53
  [ClaimsServiceSchemaorg.url]: `https://operator.example.net/acme/cds-${String(EXAMPLE_JURISDICTION).toLowerCase()}/v1/${EXAMPLE_SECTOR}`,
45
- [ClaimsServiceSchemaorg.serviceType]: serializeServiceCapabilityTokens([
46
- ServiceCapability.IndexProvider,
47
- ServiceCapability.DigitalTwinReader,
48
- ]),
54
+ [ClaimsServiceSchemaorg.serviceType]: EXAMPLE_LEGAL_ORGANIZATION_SERVICE_TYPE,
49
55
  },
50
56
  controller: exampleControllerBinding,
51
57
  organization: {
@@ -132,6 +132,7 @@ export interface ICryptography {
132
132
  * @param publicJWKey The signer's public key (JWK) to use for verification.
133
133
  * @returns A boolean indicating if the signature is valid.
134
134
  */
135
+ /** Verifies encoded detached JWS and RFC 7797 `b64=false` detached payloads. */
135
136
  verifyDetachedJws(payloadBytes: Uint8Array, detachedJws: string, publicJWKey: PublicJwk): Promise<boolean>;
136
137
  /**
137
138
  * Converts a JWS Object (with decoded headers and payload) into Compact Serialization format.
@@ -10,6 +10,8 @@ export type LegalOrganizationFormTemplateFields = Readonly<{
10
10
  controllerRole?: string;
11
11
  serviceCategory?: string;
12
12
  serviceIdentifier?: string;
13
+ /** Canonical CSV of capabilities stored in `org.schema.Service.serviceType`. */
14
+ serviceType?: string;
13
15
  serviceUrl?: string;
14
16
  tenantAlias?: string;
15
17
  }>;
@@ -90,6 +92,8 @@ export interface LegalOrganizationOnboardingFacade {
90
92
  getServiceCategory(fields: LegalOrganizationFormTemplateFields): string | undefined;
91
93
  setServiceIdentifier(fields: LegalOrganizationFormTemplateFields, value: string): LegalOrganizationFormTemplateFields;
92
94
  getServiceIdentifier(fields: LegalOrganizationFormTemplateFields): string | undefined;
95
+ setServiceType(fields: LegalOrganizationFormTemplateFields, value: string): LegalOrganizationFormTemplateFields;
96
+ getServiceType(fields: LegalOrganizationFormTemplateFields): string | undefined;
93
97
  setServiceUrl(fields: LegalOrganizationFormTemplateFields, value: string): LegalOrganizationFormTemplateFields;
94
98
  getServiceUrl(fields: LegalOrganizationFormTemplateFields): string | undefined;
95
99
  /**
@@ -136,6 +140,8 @@ export interface LegalOrganizationOnboardingEditor {
136
140
  getServiceCategory(): string | undefined;
137
141
  setServiceIdentifier(value: string): LegalOrganizationOnboardingEditor;
138
142
  getServiceIdentifier(): string | undefined;
143
+ setServiceType(value: string): LegalOrganizationOnboardingEditor;
144
+ getServiceType(): string | undefined;
139
145
  setServiceUrl(value: string): LegalOrganizationOnboardingEditor;
140
146
  getServiceUrl(): string | undefined;
141
147
  setTenantAlias(value: string): LegalOrganizationOnboardingEditor;
@@ -51,6 +51,8 @@ function createEditorFromFacade(facade, initial) {
51
51
  getServiceCategory() { return facade.getServiceCategory(formFields); },
52
52
  setServiceIdentifier(value) { formFields = facade.setServiceIdentifier(formFields, value); return editor; },
53
53
  getServiceIdentifier() { return facade.getServiceIdentifier(formFields); },
54
+ setServiceType(value) { formFields = facade.setServiceType(formFields, value); return editor; },
55
+ getServiceType() { return facade.getServiceType(formFields); },
54
56
  setServiceUrl(value) { formFields = facade.setServiceUrl(formFields, value); return editor; },
55
57
  getServiceUrl() { return facade.getServiceUrl(formFields); },
56
58
  setTenantAlias(value) { formFields = facade.setTenantAlias(formFields, value); return editor; },
@@ -133,6 +135,12 @@ export function createLegalOrganizationOnboardingFacade() {
133
135
  getServiceIdentifier(fields) {
134
136
  return normalizeOptionalText(fields.serviceIdentifier);
135
137
  },
138
+ setServiceType(fields, value) {
139
+ return patchFields(fields, { serviceType: normalizeText(value) });
140
+ },
141
+ getServiceType(fields) {
142
+ return normalizeOptionalText(fields.serviceType);
143
+ },
136
144
  setServiceUrl(fields, value) {
137
145
  return patchFields(fields, { serviceUrl: normalizeText(value) });
138
146
  },
@@ -176,6 +184,9 @@ export function createLegalOrganizationOnboardingFacade() {
176
184
  if (normalizeOptionalText(fields.serviceIdentifier)) {
177
185
  claims[ClaimsServiceSchemaorg.identifier] = normalizeText(fields.serviceIdentifier);
178
186
  }
187
+ if (normalizeOptionalText(fields.serviceType)) {
188
+ claims[ClaimsServiceSchemaorg.serviceType] = normalizeText(fields.serviceType);
189
+ }
179
190
  if (normalizeOptionalText(fields.serviceUrl)) {
180
191
  claims[ClaimsServiceSchemaorg.url] = normalizeText(fields.serviceUrl);
181
192
  }
@@ -236,6 +247,14 @@ export function createLegalOrganizationOnboardingFacade() {
236
247
  field: 'serviceCategory',
237
248
  });
238
249
  }
250
+ if (!normalizeOptionalText(fields.serviceType)) {
251
+ issues.push({
252
+ severity: 'error',
253
+ code: 'missing-service-type',
254
+ message: 'serviceType is required because GW authorizes activation capabilities from it.',
255
+ field: 'serviceType',
256
+ });
257
+ }
239
258
  if (!normalizeOptionalText(fields.controllerRole)) {
240
259
  issues.push({
241
260
  severity: 'warning',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-common-utils-ts",
3
- "version": "2.5.15",
3
+ "version": "2.5.17",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },