gdc-common-utils-ts 1.9.0 → 1.10.0

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/README.md CHANGED
@@ -142,6 +142,8 @@ The canonical API contract should live in JSDoc on exported code. The README act
142
142
  - This is the preferred first scope to teach when the backend only needs subject-scoped read access.
143
143
  - [`getOrganizationCredentialFromVpToken(...)`, `getLegalRepresentativeCredentialFromVpToken(...)`](src/utils/vp-token.ts)
144
144
  - Extract typed VC objects from a VP token when GW/SDK flows carry canonical proof only in `vp_token`.
145
+ - [`docs/VP_TOKEN_101.md`](docs/VP_TOKEN_101.md)
146
+ - Step-by-step guide for building the canonical compact `vp_token` string from organization and representative VCs.
145
147
  - [`validateCommunicationResourceFhirR4(...)`](src/utils/communication-fhir-r4.ts)
146
148
  - Validates FHIR R4 `Communication` resources.
147
149
  - [`transformCommunicationClaimsToResourceFhirR4(...)`](src/utils/communication-fhir-r4.ts)
@@ -139,8 +139,3 @@ export declare enum ICAOIdentityParams {
139
139
  }
140
140
  export declare const indexedPersonAttributeList: string[];
141
141
  export declare const fullPersonParamsSchemaorg: ParameterData[];
142
- /**
143
- * Canonical schema.org `Service` flat claims commonly used by GW tenant and
144
- * individual onboarding flows.
145
- */
146
- export declare const fullServiceParamsSchemaorg: ParameterData[];
@@ -224,35 +224,3 @@ export const fullPersonParamsSchemaorg = [
224
224
  },
225
225
  */
226
226
  ];
227
- /**
228
- * Canonical schema.org `Service` flat claims commonly used by GW tenant and
229
- * individual onboarding flows.
230
- */
231
- export const fullServiceParamsSchemaorg = [
232
- {
233
- name: ClaimsServiceSchemaorg.category,
234
- type: 'token',
235
- value: undefined,
236
- },
237
- {
238
- name: ClaimsServiceSchemaorg.identifier,
239
- type: 'uri',
240
- value: undefined,
241
- unique: true,
242
- },
243
- {
244
- name: ClaimsServiceSchemaorg.serviceType,
245
- type: 'token',
246
- value: undefined,
247
- },
248
- {
249
- name: ClaimsServiceSchemaorg.termsOfService,
250
- type: 'uri',
251
- value: undefined,
252
- },
253
- {
254
- name: ClaimsServiceSchemaorg.url,
255
- type: 'uri',
256
- value: undefined,
257
- },
258
- ];
@@ -14,9 +14,25 @@ export type ServiceCapabilityFamilyValue = typeof ServiceCapabilityFamily[keyof
14
14
  * `.rs` and `.cruds` can evolve independently across runtimes.
15
15
  */
16
16
  export declare const ServiceCapabilityToken: {
17
+ readonly IndexReader: "indexing.rs";
18
+ readonly IndexProvider: "indexing.cruds";
19
+ readonly DigitalTwinReader: "digitaltwin.rs";
20
+ readonly DigitalTwinProvider: "digitaltwin.cruds";
21
+ /**
22
+ * @deprecated Prefer `IndexReader`.
23
+ */
17
24
  readonly IndexingReadSearch: "indexing.rs";
25
+ /**
26
+ * @deprecated Prefer `IndexProvider`.
27
+ */
18
28
  readonly IndexingCruds: "indexing.cruds";
29
+ /**
30
+ * @deprecated Prefer `DigitalTwinReader`.
31
+ */
19
32
  readonly DigitalTwinReadSearch: "digitaltwin.rs";
33
+ /**
34
+ * @deprecated Prefer `DigitalTwinProvider`.
35
+ */
20
36
  readonly DigitalTwinCruds: "digitaltwin.cruds";
21
37
  };
22
38
  export type ServiceCapabilityTokenValue = typeof ServiceCapabilityToken[keyof typeof ServiceCapabilityToken];
@@ -28,10 +44,18 @@ export type ServiceCapabilityTokenValue = typeof ServiceCapabilityToken[keyof ty
28
44
  * - `Reader` maps to read/search capability (`*.rs`)
29
45
  */
30
46
  export declare const ServiceCapability: {
31
- readonly IndexingProvider: "indexing.cruds";
32
- readonly IndexingReader: "indexing.rs";
47
+ readonly IndexProvider: "indexing.cruds";
48
+ readonly IndexReader: "indexing.rs";
33
49
  readonly DigitalTwinProvider: "digitaltwin.cruds";
34
50
  readonly DigitalTwinReader: "digitaltwin.rs";
51
+ /**
52
+ * @deprecated Prefer `IndexProvider`.
53
+ */
54
+ readonly IndexingProvider: "indexing.cruds";
55
+ /**
56
+ * @deprecated Prefer `IndexReader`.
57
+ */
58
+ readonly IndexingReader: "indexing.rs";
35
59
  };
36
60
  export type ServiceCapabilityValue = typeof ServiceCapability[keyof typeof ServiceCapability];
37
61
  /**
@@ -15,9 +15,25 @@ export const ServiceCapabilityFamily = {
15
15
  * `.rs` and `.cruds` can evolve independently across runtimes.
16
16
  */
17
17
  export const ServiceCapabilityToken = {
18
+ IndexReader: 'indexing.rs',
19
+ IndexProvider: 'indexing.cruds',
20
+ DigitalTwinReader: 'digitaltwin.rs',
21
+ DigitalTwinProvider: 'digitaltwin.cruds',
22
+ /**
23
+ * @deprecated Prefer `IndexReader`.
24
+ */
18
25
  IndexingReadSearch: 'indexing.rs',
26
+ /**
27
+ * @deprecated Prefer `IndexProvider`.
28
+ */
19
29
  IndexingCruds: 'indexing.cruds',
30
+ /**
31
+ * @deprecated Prefer `DigitalTwinReader`.
32
+ */
20
33
  DigitalTwinReadSearch: 'digitaltwin.rs',
34
+ /**
35
+ * @deprecated Prefer `DigitalTwinProvider`.
36
+ */
21
37
  DigitalTwinCruds: 'digitaltwin.cruds',
22
38
  };
23
39
  /**
@@ -28,10 +44,18 @@ export const ServiceCapabilityToken = {
28
44
  * - `Reader` maps to read/search capability (`*.rs`)
29
45
  */
30
46
  export const ServiceCapability = {
31
- IndexingProvider: ServiceCapabilityToken.IndexingCruds,
32
- IndexingReader: ServiceCapabilityToken.IndexingReadSearch,
33
- DigitalTwinProvider: ServiceCapabilityToken.DigitalTwinCruds,
34
- DigitalTwinReader: ServiceCapabilityToken.DigitalTwinReadSearch,
47
+ IndexProvider: ServiceCapabilityToken.IndexProvider,
48
+ IndexReader: ServiceCapabilityToken.IndexReader,
49
+ DigitalTwinProvider: ServiceCapabilityToken.DigitalTwinProvider,
50
+ DigitalTwinReader: ServiceCapabilityToken.DigitalTwinReader,
51
+ /**
52
+ * @deprecated Prefer `IndexProvider`.
53
+ */
54
+ IndexingProvider: ServiceCapabilityToken.IndexProvider,
55
+ /**
56
+ * @deprecated Prefer `IndexReader`.
57
+ */
58
+ IndexingReader: ServiceCapabilityToken.IndexReader,
35
59
  };
36
60
  /**
37
61
  * Parses the CSV stored in `org.schema.Service.serviceType`.
@@ -26,8 +26,8 @@ export const EXAMPLE_ACTIVATE_ORGANIZATION_FROM_ICA_PROOF_INPUT = {
26
26
  [ClaimsServiceSchemaorg.identifier]: EXAMPLE_SERVICE_PUBLIC_DID,
27
27
  [ClaimsServiceSchemaorg.url]: `https://operator.example.net/acme/cds-${String(EXAMPLE_JURISDICTION).toLowerCase()}/v1/${EXAMPLE_SECTOR}`,
28
28
  [ClaimsServiceSchemaorg.serviceType]: serializeServiceCapabilityTokens([
29
- ServiceCapabilityToken.IndexingCruds,
30
- ServiceCapabilityToken.DigitalTwinReadSearch,
29
+ ServiceCapabilityToken.IndexProvider,
30
+ ServiceCapabilityToken.DigitalTwinReader,
31
31
  ]),
32
32
  },
33
33
  };
@@ -1,9 +1,3 @@
1
- /**
2
- * @fileoverview Barrel export for shared model contracts.
3
- *
4
- * @architecture 101
5
- * Keep this file export-only; shared business logic belongs in dedicated modules.
6
- */
7
1
  export * from './actor-session';
8
2
  export * from './aes';
9
3
  export * from './auth';
@@ -21,7 +15,6 @@ export * from './crypto';
21
15
  export * from './device-license';
22
16
  export * from './did';
23
17
  export * from './fhir-documents';
24
- export * from './fhir-related-person';
25
18
  export * from './interoperable-claims';
26
19
  export * from './indexing';
27
20
  export * from './identity-bootstrap';
@@ -41,7 +34,6 @@ export * from './operation-outcome';
41
34
  export * from './params';
42
35
  export * from './resource-document';
43
36
  export * from './relationship-access';
44
- export * from './related-profile';
45
37
  export * from './response';
46
38
  export * from './urlPath';
47
39
  export * from './verifiable-credential';
@@ -1,10 +1,3 @@
1
- // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- /**
3
- * @fileoverview Barrel export for shared model contracts.
4
- *
5
- * @architecture 101
6
- * Keep this file export-only; shared business logic belongs in dedicated modules.
7
- */
8
1
  export * from './actor-session.js';
9
2
  export * from './aes.js';
10
3
  export * from './auth.js';
@@ -22,7 +15,6 @@ export * from './crypto.js';
22
15
  export * from './device-license.js';
23
16
  export * from './did.js';
24
17
  export * from './fhir-documents.js';
25
- export * from './fhir-related-person.js';
26
18
  export * from './interoperable-claims.js';
27
19
  export * from './indexing.js';
28
20
  export * from './identity-bootstrap.js';
@@ -42,7 +34,6 @@ export * from './operation-outcome.js';
42
34
  export * from './params.js';
43
35
  export * from './resource-document.js';
44
36
  export * from './relationship-access.js';
45
- export * from './related-profile.js';
46
37
  export * from './response.js';
47
38
  export * from './urlPath.js';
48
39
  export * from './verifiable-credential.js';
@@ -95,31 +95,6 @@ export interface ParameterData extends ParamAttribute {
95
95
  */
96
96
  appliesTo?: string[];
97
97
  }
98
- /**
99
- * Shared definition for a search parameter that can also be used as an
100
- * indexable attribute contract.
101
- *
102
- * `name` remains the canonical flat claim key that will be stored and queried.
103
- * The record key in a `SearchParameterCatalog` is the public search-attribute
104
- * name to expose in APIs or capability statements.
105
- */
106
- export interface SearchParameterDefinition extends ParameterData {
107
- /**
108
- * Optional compatibility aliases accepted on read/normalization before the
109
- * canonical `name` is used for indexing.
110
- */
111
- claimAliases?: readonly string[];
112
- /**
113
- * Whether this parameter is intended to be indexed for blind queries.
114
- * Defaults to `true` when omitted by catalog consumers.
115
- */
116
- indexed?: boolean;
117
- }
118
- /**
119
- * Per-resource search parameter catalog keyed by the public search attribute
120
- * name (e.g. `identifier`, `subject`, `status`).
121
- */
122
- export type SearchParameterCatalog<TSearchName extends string = string> = Record<TSearchName, SearchParameterDefinition>;
123
98
  export interface StringSearchParameter extends ParameterData {
124
99
  type: 'string';
125
100
  value: string;
@@ -1,2 +1,3 @@
1
1
  // Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ // File: crypto-ts/models/params.ts
2
3
  export {};
@@ -13,7 +13,6 @@ export * from './didcomm-submit-policy';
13
13
  export * from './discovery-normalization';
14
14
  export * from './format-converter';
15
15
  export * from './fhir-cid';
16
- export * from './gateway-index-params';
17
16
  export * from './communication-fhir-r4';
18
17
  export * from './communication-document-reference';
19
18
  export * from './communication-identity';
@@ -28,6 +27,5 @@ export * from './normalize';
28
27
  export * from './object-convert';
29
28
  export * from './normalize-uuid';
30
29
  export * from './smart-scope';
31
- export * from './search-parameter-catalog';
32
30
  export * from './activation-request';
33
31
  export * from './vp-token';
@@ -13,7 +13,6 @@ export * from './didcomm-submit-policy.js';
13
13
  export * from './discovery-normalization.js';
14
14
  export * from './format-converter.js';
15
15
  export * from './fhir-cid.js';
16
- export * from './gateway-index-params.js';
17
16
  export * from './communication-fhir-r4.js';
18
17
  export * from './communication-document-reference.js';
19
18
  export * from './communication-identity.js';
@@ -28,6 +27,5 @@ export * from './normalize.js';
28
27
  export * from './object-convert.js';
29
28
  export * from './normalize-uuid.js';
30
29
  export * from './smart-scope.js';
31
- export * from './search-parameter-catalog.js';
32
30
  export * from './activation-request.js';
33
31
  export * from './vp-token.js';
@@ -16,20 +16,47 @@ export type VpTokenPayload = {
16
16
  '@context'?: unknown;
17
17
  type?: unknown;
18
18
  holder?: string;
19
- verifiableCredential: string[];
19
+ verifiableCredential: Array<string | Record<string, unknown>>;
20
20
  [key: string]: unknown;
21
21
  };
22
22
  [key: string]: unknown;
23
23
  };
24
24
  export type VpCredential = Record<string, unknown>;
25
+ export type VpCredentialInput = string | Record<string, unknown>;
25
26
  export declare function generateUuidLike(): string;
26
27
  export declare function buildEpochWindow(ttlSeconds?: number): {
27
28
  iat: number;
28
29
  exp: number;
29
30
  };
30
31
  export declare function createVP(input?: Partial<VpTokenPayload>): VpTokenPayload;
31
- export declare function addVC(vpPayload: VpTokenPayload, vcJwt: string): VpTokenPayload;
32
- export declare function addVCs(vpPayload: VpTokenPayload, vcs: string[]): VpTokenPayload;
32
+ /**
33
+ * Appends one VC entry to the VP payload.
34
+ *
35
+ * Accepted input forms:
36
+ *
37
+ * - compact VC JWT/JWS string
38
+ * - raw JSON VC string
39
+ * - direct VC JSON object
40
+ *
41
+ * Storage rule:
42
+ *
43
+ * - string inputs are stored as strings
44
+ * - object inputs are stored as objects
45
+ *
46
+ * This keeps the builder compatible with existing compact-token flows while
47
+ * also supporting app/runtime code that already holds the VC as parsed JSON.
48
+ */
49
+ export declare function addVC(vpPayload: VpTokenPayload, vcInput: VpCredentialInput): VpTokenPayload;
50
+ /**
51
+ * Appends many VC entries to the VP payload.
52
+ *
53
+ * Each entry may be:
54
+ *
55
+ * - compact VC JWT/JWS string
56
+ * - raw JSON VC string
57
+ * - direct VC JSON object
58
+ */
59
+ export declare function addVCs(vpPayload: VpTokenPayload, vcs: VpCredentialInput[]): VpTokenPayload;
33
60
  /**
34
61
  * Decodes a compact VP token payload into a JSON object.
35
62
  *
@@ -67,8 +94,19 @@ export declare function getOrganizationCredentialFromVpToken(vpToken: string): V
67
94
  * @param vpToken Compact VP token or raw JSON string.
68
95
  */
69
96
  export declare function getLegalRepresentativeCredentialFromVpToken(vpToken: string): VpCredential | undefined;
70
- export declare function addOrganizationCredential(vpPayload: VpTokenPayload, vc: string): VpTokenPayload;
71
- export declare function addLegalRepresentativeCredential(vpPayload: VpTokenPayload, vc: string): VpTokenPayload;
97
+ /**
98
+ * Appends an organization activation credential after validating its VC type.
99
+ *
100
+ * Accepts compact VC strings, raw JSON VC strings, or VC JSON objects.
101
+ */
102
+ export declare function addOrganizationCredential(vpPayload: VpTokenPayload, vc: VpCredentialInput): VpTokenPayload;
103
+ /**
104
+ * Appends a legal-representative activation credential after validating its VC
105
+ * type.
106
+ *
107
+ * Accepts compact VC strings, raw JSON VC strings, or VC JSON objects.
108
+ */
109
+ export declare function addLegalRepresentativeCredential(vpPayload: VpTokenPayload, vc: VpCredentialInput): VpTokenPayload;
72
110
  export declare function prepareForSignature(header: VpTokenHeader, payload: VpTokenPayload): {
73
111
  encodedHeader: string;
74
112
  encodedPayload: string;
@@ -37,19 +37,52 @@ export function createVP(input) {
37
37
  };
38
38
  return base;
39
39
  }
40
- export function addVC(vpPayload, vcJwt) {
41
- const v = String(vcJwt || '').trim();
40
+ /**
41
+ * Appends one VC entry to the VP payload.
42
+ *
43
+ * Accepted input forms:
44
+ *
45
+ * - compact VC JWT/JWS string
46
+ * - raw JSON VC string
47
+ * - direct VC JSON object
48
+ *
49
+ * Storage rule:
50
+ *
51
+ * - string inputs are stored as strings
52
+ * - object inputs are stored as objects
53
+ *
54
+ * This keeps the builder compatible with existing compact-token flows while
55
+ * also supporting app/runtime code that already holds the VC as parsed JSON.
56
+ */
57
+ export function addVC(vpPayload, vcInput) {
58
+ if (vcInput && typeof vcInput === 'object') {
59
+ vpPayload.vp.verifiableCredential.push({ ...vcInput });
60
+ return vpPayload;
61
+ }
62
+ const v = String(vcInput || '').trim();
42
63
  if (!v)
43
64
  return vpPayload;
44
65
  vpPayload.vp.verifiableCredential.push(v);
45
66
  return vpPayload;
46
67
  }
68
+ /**
69
+ * Appends many VC entries to the VP payload.
70
+ *
71
+ * Each entry may be:
72
+ *
73
+ * - compact VC JWT/JWS string
74
+ * - raw JSON VC string
75
+ * - direct VC JSON object
76
+ */
47
77
  export function addVCs(vpPayload, vcs) {
48
78
  for (const vc of vcs || [])
49
79
  addVC(vpPayload, vc);
50
80
  return vpPayload;
51
81
  }
52
82
  function decodeVcPayload(vc) {
83
+ if (vc && typeof vc === 'object') {
84
+ return vc;
85
+ }
53
86
  const raw = String(vc || '').trim();
54
87
  if (!raw)
55
88
  return undefined;
@@ -173,9 +206,20 @@ function addTypedVC(vpPayload, vc, acceptedTypes, label) {
173
206
  }
174
207
  return addVC(vpPayload, vc);
175
208
  }
209
+ /**
210
+ * Appends an organization activation credential after validating its VC type.
211
+ *
212
+ * Accepts compact VC strings, raw JSON VC strings, or VC JSON objects.
213
+ */
176
214
  export function addOrganizationCredential(vpPayload, vc) {
177
215
  return addTypedVC(vpPayload, vc, [...ORGANIZATION_ACTIVATION_VC_TYPES], 'Organization');
178
216
  }
217
+ /**
218
+ * Appends a legal-representative activation credential after validating its VC
219
+ * type.
220
+ *
221
+ * Accepts compact VC strings, raw JSON VC strings, or VC JSON objects.
222
+ */
179
223
  export function addLegalRepresentativeCredential(vpPayload, vc) {
180
224
  return addTypedVC(vpPayload, vc, [...REPRESENTATIVE_ACTIVATION_VC_TYPES], 'LegalRepresentative');
181
225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-common-utils-ts",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },