gdc-common-utils-ts 1.9.0 → 1.11.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 +2 -0
- package/dist/constants/cryptography.d.ts +23 -0
- package/dist/constants/cryptography.js +13 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/schemaorg.d.ts +33 -5
- package/dist/constants/schemaorg.js +34 -32
- package/dist/constants/service-capabilities.d.ts +26 -2
- package/dist/constants/service-capabilities.js +28 -4
- package/dist/constants/urn.d.ts +11 -0
- package/dist/constants/urn.js +11 -0
- package/dist/examples/ica-activation-proof.d.ts +29 -20
- package/dist/examples/ica-activation-proof.js +35 -25
- package/dist/examples/organization-controller.js +2 -2
- package/dist/interfaces/Cryptography.types.d.ts +9 -1
- package/dist/models/index.d.ts +0 -8
- package/dist/models/index.js +0 -9
- package/dist/models/params.d.ts +0 -25
- package/dist/models/params.js +1 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -2
- package/dist/utils/vp-token.d.ts +67 -6
- package/dist/utils/vp-token.js +61 -2
- package/package.json +1 -1
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)
|
|
@@ -14,6 +14,29 @@ export declare const CommunicationKeyPurposes: {
|
|
|
14
14
|
readonly CommunicationSignature: "comm_sig";
|
|
15
15
|
readonly VerifiableCredentialSignature: "vc_sign";
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Classical JOSE signature algorithms currently recognized across GDC VP/JWT
|
|
19
|
+
* examples and gateway trust adapters.
|
|
20
|
+
*
|
|
21
|
+
* Notes:
|
|
22
|
+
* - `ES256K` is the JOSE name for ECDSA over `secp256k1`
|
|
23
|
+
* - `ES384` remains the common P-384 legacy example in current GW fixtures
|
|
24
|
+
*/
|
|
25
|
+
export declare const ClassicalJoseSignatureAlgorithms: {
|
|
26
|
+
readonly Es256: "ES256";
|
|
27
|
+
readonly Es256K: "ES256K";
|
|
28
|
+
readonly Es384: "ES384";
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* JOSE signature algorithms accepted by shared VP/JWT helpers.
|
|
32
|
+
*
|
|
33
|
+
* This intentionally covers both:
|
|
34
|
+
* - classical ECDSA JOSE algorithms (`ES256`, `ES256K`, `ES384`)
|
|
35
|
+
* - post-quantum ML-DSA JOSE algorithm labels already used by GW
|
|
36
|
+
*
|
|
37
|
+
* Use this type when a helper builds or documents a JWS/JWT/VP proof header.
|
|
38
|
+
*/
|
|
39
|
+
export type JoseSignatureAlgorithm = typeof ClassicalJoseSignatureAlgorithms[keyof typeof ClassicalJoseSignatureAlgorithms] | MldsaAlg;
|
|
17
40
|
/**
|
|
18
41
|
* Default post-quantum signing algorithms used for communication bootstrap.
|
|
19
42
|
*/
|
|
@@ -15,6 +15,19 @@ export const CommunicationKeyPurposes = {
|
|
|
15
15
|
CommunicationSignature: 'comm_sig',
|
|
16
16
|
VerifiableCredentialSignature: 'vc_sign',
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Classical JOSE signature algorithms currently recognized across GDC VP/JWT
|
|
20
|
+
* examples and gateway trust adapters.
|
|
21
|
+
*
|
|
22
|
+
* Notes:
|
|
23
|
+
* - `ES256K` is the JOSE name for ECDSA over `secp256k1`
|
|
24
|
+
* - `ES384` remains the common P-384 legacy example in current GW fixtures
|
|
25
|
+
*/
|
|
26
|
+
export const ClassicalJoseSignatureAlgorithms = {
|
|
27
|
+
Es256: 'ES256',
|
|
28
|
+
Es256K: 'ES256K',
|
|
29
|
+
Es384: 'ES384',
|
|
30
|
+
};
|
|
18
31
|
/**
|
|
19
32
|
* Default post-quantum signing algorithms used for communication bootstrap.
|
|
20
33
|
*/
|
package/dist/constants/index.js
CHANGED
|
@@ -6,6 +6,29 @@ export declare enum ClaimsServiceSchemaorg {
|
|
|
6
6
|
termsOfService = "org.schema.Service.termsOfService",
|
|
7
7
|
url = "org.schema.Service.url"
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Canonical claim names used by the current GDC profile when a VC models a
|
|
11
|
+
* `schema.org/SoftwareApplication`.
|
|
12
|
+
*
|
|
13
|
+
* Contract note:
|
|
14
|
+
* - `material` is the public cryptographic material of the software
|
|
15
|
+
* application in the current GDC profile, typically the communication
|
|
16
|
+
* signing key id bound by ICA to the software/application instance
|
|
17
|
+
* - when that identifier is expressed as a JWK thumbprint, RFC 7638 defines
|
|
18
|
+
* the canonical thumbprint calculation over the public signing /
|
|
19
|
+
* verification JWK and RFC 9278 defines the canonical URN form
|
|
20
|
+
* `urn:ietf:params:oauth:jwk-thumbprint:sha-256:<base64url>`
|
|
21
|
+
* - the controller-side signature belongs to the prior ICA registration step,
|
|
22
|
+
* not to every later app-service operational proof
|
|
23
|
+
*/
|
|
24
|
+
export declare enum ClaimsSoftwareApplicationSchemaorg {
|
|
25
|
+
id = "org.schema.SoftwareApplication.id",
|
|
26
|
+
name = "org.schema.SoftwareApplication.name",
|
|
27
|
+
url = "org.schema.SoftwareApplication.url",
|
|
28
|
+
sameAs = "org.schema.SoftwareApplication.sameAs",
|
|
29
|
+
/** Communication signing key id bound by the ICA-issued SoftwareApplication VC. */
|
|
30
|
+
material = "org.schema.SoftwareApplication.material"
|
|
31
|
+
}
|
|
9
32
|
/**
|
|
10
33
|
* Defines the canonical claim names for the 'org.schema' context,
|
|
11
34
|
* based on Schema.org vocabulary.
|
|
@@ -39,6 +62,16 @@ export declare enum ClaimsOrganizationSchemaorg {
|
|
|
39
62
|
email = "org.schema.Organization.email",
|
|
40
63
|
/** Public contact phone */
|
|
41
64
|
telephone = "org.schema.Organization.telephone",
|
|
65
|
+
/**
|
|
66
|
+
* Public cryptographic material of the organization in VC/profile payloads.
|
|
67
|
+
*
|
|
68
|
+
* When represented as a JWK thumbprint identifier:
|
|
69
|
+
* - RFC 7638 defines the canonical thumbprint calculation over the public
|
|
70
|
+
* signing / verification JWK
|
|
71
|
+
* - RFC 9278 defines the canonical URN form
|
|
72
|
+
* `urn:ietf:params:oauth:jwk-thumbprint:sha-256:<base64url>`
|
|
73
|
+
*/
|
|
74
|
+
hasCredentialMaterial = "org.schema.Organization.hasCredential.material",
|
|
42
75
|
/** Individual/family owner email used by subject-index registration flows. */
|
|
43
76
|
ownerEmail = "org.schema.Organization.owner.email",
|
|
44
77
|
/** Individual/family owner telephone used by subject-index registration flows. */
|
|
@@ -139,8 +172,3 @@ export declare enum ICAOIdentityParams {
|
|
|
139
172
|
}
|
|
140
173
|
export declare const indexedPersonAttributeList: string[];
|
|
141
174
|
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[];
|
|
@@ -8,6 +8,30 @@ export var ClaimsServiceSchemaorg;
|
|
|
8
8
|
ClaimsServiceSchemaorg["termsOfService"] = "org.schema.Service.termsOfService";
|
|
9
9
|
ClaimsServiceSchemaorg["url"] = "org.schema.Service.url";
|
|
10
10
|
})(ClaimsServiceSchemaorg || (ClaimsServiceSchemaorg = {}));
|
|
11
|
+
/**
|
|
12
|
+
* Canonical claim names used by the current GDC profile when a VC models a
|
|
13
|
+
* `schema.org/SoftwareApplication`.
|
|
14
|
+
*
|
|
15
|
+
* Contract note:
|
|
16
|
+
* - `material` is the public cryptographic material of the software
|
|
17
|
+
* application in the current GDC profile, typically the communication
|
|
18
|
+
* signing key id bound by ICA to the software/application instance
|
|
19
|
+
* - when that identifier is expressed as a JWK thumbprint, RFC 7638 defines
|
|
20
|
+
* the canonical thumbprint calculation over the public signing /
|
|
21
|
+
* verification JWK and RFC 9278 defines the canonical URN form
|
|
22
|
+
* `urn:ietf:params:oauth:jwk-thumbprint:sha-256:<base64url>`
|
|
23
|
+
* - the controller-side signature belongs to the prior ICA registration step,
|
|
24
|
+
* not to every later app-service operational proof
|
|
25
|
+
*/
|
|
26
|
+
export var ClaimsSoftwareApplicationSchemaorg;
|
|
27
|
+
(function (ClaimsSoftwareApplicationSchemaorg) {
|
|
28
|
+
ClaimsSoftwareApplicationSchemaorg["id"] = "org.schema.SoftwareApplication.id";
|
|
29
|
+
ClaimsSoftwareApplicationSchemaorg["name"] = "org.schema.SoftwareApplication.name";
|
|
30
|
+
ClaimsSoftwareApplicationSchemaorg["url"] = "org.schema.SoftwareApplication.url";
|
|
31
|
+
ClaimsSoftwareApplicationSchemaorg["sameAs"] = "org.schema.SoftwareApplication.sameAs";
|
|
32
|
+
/** Communication signing key id bound by the ICA-issued SoftwareApplication VC. */
|
|
33
|
+
ClaimsSoftwareApplicationSchemaorg["material"] = "org.schema.SoftwareApplication.material";
|
|
34
|
+
})(ClaimsSoftwareApplicationSchemaorg || (ClaimsSoftwareApplicationSchemaorg = {}));
|
|
11
35
|
/**
|
|
12
36
|
* Defines the canonical claim names for the 'org.schema' context,
|
|
13
37
|
* based on Schema.org vocabulary.
|
|
@@ -42,6 +66,16 @@ export var ClaimsOrganizationSchemaorg;
|
|
|
42
66
|
ClaimsOrganizationSchemaorg["email"] = "org.schema.Organization.email";
|
|
43
67
|
/** Public contact phone */
|
|
44
68
|
ClaimsOrganizationSchemaorg["telephone"] = "org.schema.Organization.telephone";
|
|
69
|
+
/**
|
|
70
|
+
* Public cryptographic material of the organization in VC/profile payloads.
|
|
71
|
+
*
|
|
72
|
+
* When represented as a JWK thumbprint identifier:
|
|
73
|
+
* - RFC 7638 defines the canonical thumbprint calculation over the public
|
|
74
|
+
* signing / verification JWK
|
|
75
|
+
* - RFC 9278 defines the canonical URN form
|
|
76
|
+
* `urn:ietf:params:oauth:jwk-thumbprint:sha-256:<base64url>`
|
|
77
|
+
*/
|
|
78
|
+
ClaimsOrganizationSchemaorg["hasCredentialMaterial"] = "org.schema.Organization.hasCredential.material";
|
|
45
79
|
/** Individual/family owner email used by subject-index registration flows. */
|
|
46
80
|
ClaimsOrganizationSchemaorg["ownerEmail"] = "org.schema.Organization.owner.email";
|
|
47
81
|
/** Individual/family owner telephone used by subject-index registration flows. */
|
|
@@ -224,35 +258,3 @@ export const fullPersonParamsSchemaorg = [
|
|
|
224
258
|
},
|
|
225
259
|
*/
|
|
226
260
|
];
|
|
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
|
|
32
|
-
readonly
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
DigitalTwinProvider: ServiceCapabilityToken.
|
|
34
|
-
DigitalTwinReader: ServiceCapabilityToken.
|
|
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`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical URN prefixes reused across bootstrap and proof examples.
|
|
3
|
+
*
|
|
4
|
+
* The JWK thumbprint URI prefix below follows RFC 9278 and is intended for
|
|
5
|
+
* cases where a key identifier is represented as a normalized URI instead of
|
|
6
|
+
* as a bare base64url thumbprint value.
|
|
7
|
+
*/
|
|
8
|
+
export declare const UrnPrefixes: Readonly<{
|
|
9
|
+
readonly JwkThumbprintSha256KeyId: "urn:ietf:params:oauth:jwk-thumbprint:sha-256:";
|
|
10
|
+
}>;
|
|
11
|
+
export type UrnPrefix = typeof UrnPrefixes[keyof typeof UrnPrefixes];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
/**
|
|
3
|
+
* Canonical URN prefixes reused across bootstrap and proof examples.
|
|
4
|
+
*
|
|
5
|
+
* The JWK thumbprint URI prefix below follows RFC 9278 and is intended for
|
|
6
|
+
* cases where a key identifier is represented as a normalized URI instead of
|
|
7
|
+
* as a bare base64url thumbprint value.
|
|
8
|
+
*/
|
|
9
|
+
export const UrnPrefixes = Object.freeze({
|
|
10
|
+
JwkThumbprintSha256KeyId: 'urn:ietf:params:oauth:jwk-thumbprint:sha-256:',
|
|
11
|
+
});
|
|
@@ -2,33 +2,42 @@
|
|
|
2
2
|
* Shared synthetic ICA activation-proof fixtures reused by docs/tests.
|
|
3
3
|
*
|
|
4
4
|
* Contract note:
|
|
5
|
-
* -
|
|
6
|
-
*
|
|
5
|
+
* - controller-signing/audience ids and VC subtype names must be imported from
|
|
6
|
+
* this module instead of re-hardcoded
|
|
7
|
+
* inline
|
|
7
8
|
* - the representative `hasCredential.material` shape below reflects the
|
|
8
9
|
* current `activation-policy` helper contract; if ICA finalizes a different
|
|
9
10
|
* VC shape, update this module first and then the dependent helpers/tests
|
|
11
|
+
*
|
|
12
|
+
* Modeling note:
|
|
13
|
+
* - this onboarding example intentionally anchors the business subject on the
|
|
14
|
+
* organization tax ID rather than on a pre-existing provider DID
|
|
15
|
+
* - the VP envelope uses a synthetic RFC 7638-style JWK-thumbprint urn and a
|
|
16
|
+
* host id, which better matches the initial registration stage than a
|
|
17
|
+
* synthetic did:web
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Synthetic JWK-thumbprint-based signing key id for the organization
|
|
21
|
+
* controller who signs the initial legal-onboarding VP.
|
|
10
22
|
*/
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
17
|
-
export declare const EXAMPLE_ICA_REPRESENTATIVE_ROLE_CODE: "RESPRSN";
|
|
18
|
-
export declare const EXAMPLE_ICA_REPRESENTATIVE_BINDING_MATERIAL: "controller-sig-kid";
|
|
19
|
-
export declare const EXAMPLE_ICA_ORGANIZATION_CREDENTIAL: Readonly<{
|
|
23
|
+
export declare const EXAMPLE_ORG_CONTROLLER_SIGNING_KEY_ID: "urn:ietf:params:oauth:jwk-thumbprint:sha-256:Q0ZfM0V4YW1wbGVUaHVtYnByaW50X2Jhc2U2NHVybA";
|
|
24
|
+
export declare const EXAMPLE_PRESENTATION_AUDIENCE_HOST_ID: "host:node-operator-es";
|
|
25
|
+
export declare const EXAMPLE_ORGANIZATION_TAX_ID: "ESB00112233";
|
|
26
|
+
export declare const EXAMPLE_REPRESENTATIVE_ROLE_CODE: "RESPRSN";
|
|
27
|
+
export declare const EXAMPLE_ORGANIZATION_ID: "ESB00112233";
|
|
28
|
+
export declare const EXAMPLE_ORG_ACTIVATION_ORGANIZATION_CREDENTIAL: Readonly<{
|
|
20
29
|
'@context': string[];
|
|
21
30
|
type: ("VerifiableCredential" | "OrganizationCredential")[];
|
|
22
31
|
credentialSubject: {
|
|
23
|
-
id: "
|
|
32
|
+
id: "ESB00112233";
|
|
24
33
|
taxID: "ESB00112233";
|
|
25
34
|
};
|
|
26
35
|
}>;
|
|
27
|
-
export declare const
|
|
36
|
+
export declare const EXAMPLE_ORG_ACTIVATION_LEGAL_REPRESENTATIVE_CREDENTIAL: Readonly<{
|
|
28
37
|
'@context': string[];
|
|
29
38
|
type: ("VerifiableCredential" | "LegalRepresentativeCredential")[];
|
|
30
39
|
credentialSubject: {
|
|
31
|
-
id: "
|
|
40
|
+
id: "urn:ietf:params:oauth:jwk-thumbprint:sha-256:Q0ZfM0V4YW1wbGVUaHVtYnByaW50X2Jhc2U2NHVybA";
|
|
32
41
|
memberOf: {
|
|
33
42
|
taxID: "ESB00112233";
|
|
34
43
|
};
|
|
@@ -38,18 +47,18 @@ export declare const EXAMPLE_ICA_LEGAL_REPRESENTATIVE_CREDENTIAL: Readonly<{
|
|
|
38
47
|
};
|
|
39
48
|
};
|
|
40
49
|
hasCredential: {
|
|
41
|
-
material: "
|
|
50
|
+
material: "urn:ietf:params:oauth:jwk-thumbprint:sha-256:Q0ZfM0V4YW1wbGVUaHVtYnByaW50X2Jhc2U2NHVybA";
|
|
42
51
|
};
|
|
43
52
|
};
|
|
44
53
|
}>;
|
|
45
|
-
export declare const
|
|
46
|
-
iss: "
|
|
47
|
-
sub: "
|
|
48
|
-
aud: "
|
|
54
|
+
export declare const EXAMPLE_ORG_ACTIVATION_PROOF_VP_PAYLOAD: Readonly<{
|
|
55
|
+
iss: "urn:ietf:params:oauth:jwk-thumbprint:sha-256:Q0ZfM0V4YW1wbGVUaHVtYnByaW50X2Jhc2U2NHVybA";
|
|
56
|
+
sub: "ESB00112233";
|
|
57
|
+
aud: "host:node-operator-es";
|
|
49
58
|
vp: {
|
|
50
59
|
'@context': "https://www.w3.org/2018/credentials/v1"[];
|
|
51
60
|
type: "VerifiablePresentation"[];
|
|
52
|
-
holder: "
|
|
61
|
+
holder: "urn:ietf:params:oauth:jwk-thumbprint:sha-256:Q0ZfM0V4YW1wbGVUaHVtYnByaW50X2Jhc2U2NHVybA";
|
|
53
62
|
verifiableCredential: string[];
|
|
54
63
|
};
|
|
55
64
|
}>;
|
|
@@ -1,67 +1,77 @@
|
|
|
1
1
|
// Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
2
|
// Always create JSDoc, do not use strings inline in keys nor values, use types instead, and reuse the data test examples.
|
|
3
3
|
import { ActivationCredentialTypes, W3cCredentialContexts, W3cCredentialTypes, } from '../constants/verifiable-credentials.js';
|
|
4
|
+
import { UrnPrefixes } from '../constants/urn.js';
|
|
4
5
|
/**
|
|
5
6
|
* Shared synthetic ICA activation-proof fixtures reused by docs/tests.
|
|
6
7
|
*
|
|
7
8
|
* Contract note:
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
9
|
+
* - controller-signing/audience ids and VC subtype names must be imported from
|
|
10
|
+
* this module instead of re-hardcoded
|
|
11
|
+
* inline
|
|
10
12
|
* - the representative `hasCredential.material` shape below reflects the
|
|
11
13
|
* current `activation-policy` helper contract; if ICA finalizes a different
|
|
12
14
|
* VC shape, update this module first and then the dependent helpers/tests
|
|
15
|
+
*
|
|
16
|
+
* Modeling note:
|
|
17
|
+
* - this onboarding example intentionally anchors the business subject on the
|
|
18
|
+
* organization tax ID rather than on a pre-existing provider DID
|
|
19
|
+
* - the VP envelope uses a synthetic RFC 7638-style JWK-thumbprint urn and a
|
|
20
|
+
* host id, which better matches the initial registration stage than a
|
|
21
|
+
* synthetic did:web
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Synthetic JWK-thumbprint-based signing key id for the organization
|
|
25
|
+
* controller who signs the initial legal-onboarding VP.
|
|
13
26
|
*/
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
20
|
-
export const EXAMPLE_ICA_REPRESENTATIVE_ROLE_CODE = 'RESPRSN';
|
|
21
|
-
export const EXAMPLE_ICA_REPRESENTATIVE_BINDING_MATERIAL = 'controller-sig-kid';
|
|
22
|
-
export const EXAMPLE_ICA_ORGANIZATION_CREDENTIAL = Object.freeze({
|
|
27
|
+
export const EXAMPLE_ORG_CONTROLLER_SIGNING_KEY_ID = `${UrnPrefixes.JwkThumbprintSha256KeyId}Q0ZfM0V4YW1wbGVUaHVtYnByaW50X2Jhc2U2NHVybA`;
|
|
28
|
+
export const EXAMPLE_PRESENTATION_AUDIENCE_HOST_ID = 'host:node-operator-es';
|
|
29
|
+
export const EXAMPLE_ORGANIZATION_TAX_ID = 'ESB00112233';
|
|
30
|
+
export const EXAMPLE_REPRESENTATIVE_ROLE_CODE = 'RESPRSN';
|
|
31
|
+
export const EXAMPLE_ORGANIZATION_ID = EXAMPLE_ORGANIZATION_TAX_ID;
|
|
32
|
+
export const EXAMPLE_ORG_ACTIVATION_ORGANIZATION_CREDENTIAL = Object.freeze({
|
|
23
33
|
'@context': [W3cCredentialContexts.V2, 'https://schema.org'],
|
|
24
34
|
type: [
|
|
25
35
|
W3cCredentialTypes.VerifiableCredential,
|
|
26
36
|
ActivationCredentialTypes.OrganizationCredential,
|
|
27
37
|
],
|
|
28
38
|
credentialSubject: {
|
|
29
|
-
id:
|
|
30
|
-
taxID:
|
|
39
|
+
id: EXAMPLE_ORGANIZATION_ID,
|
|
40
|
+
taxID: EXAMPLE_ORGANIZATION_TAX_ID,
|
|
31
41
|
},
|
|
32
42
|
});
|
|
33
|
-
export const
|
|
43
|
+
export const EXAMPLE_ORG_ACTIVATION_LEGAL_REPRESENTATIVE_CREDENTIAL = Object.freeze({
|
|
34
44
|
'@context': [W3cCredentialContexts.V2, 'https://schema.org'],
|
|
35
45
|
type: [
|
|
36
46
|
W3cCredentialTypes.VerifiableCredential,
|
|
37
47
|
ActivationCredentialTypes.LegalRepresentativeCredential,
|
|
38
48
|
],
|
|
39
49
|
credentialSubject: {
|
|
40
|
-
id:
|
|
50
|
+
id: EXAMPLE_ORG_CONTROLLER_SIGNING_KEY_ID,
|
|
41
51
|
memberOf: {
|
|
42
|
-
taxID:
|
|
52
|
+
taxID: EXAMPLE_ORGANIZATION_TAX_ID,
|
|
43
53
|
},
|
|
44
54
|
hasOccupation: {
|
|
45
55
|
identifier: {
|
|
46
|
-
value:
|
|
56
|
+
value: EXAMPLE_REPRESENTATIVE_ROLE_CODE,
|
|
47
57
|
},
|
|
48
58
|
},
|
|
49
59
|
hasCredential: {
|
|
50
|
-
material:
|
|
60
|
+
material: EXAMPLE_ORG_CONTROLLER_SIGNING_KEY_ID,
|
|
51
61
|
},
|
|
52
62
|
},
|
|
53
63
|
});
|
|
54
|
-
export const
|
|
55
|
-
iss:
|
|
56
|
-
sub:
|
|
57
|
-
aud:
|
|
64
|
+
export const EXAMPLE_ORG_ACTIVATION_PROOF_VP_PAYLOAD = Object.freeze({
|
|
65
|
+
iss: EXAMPLE_ORG_CONTROLLER_SIGNING_KEY_ID,
|
|
66
|
+
sub: EXAMPLE_ORGANIZATION_TAX_ID,
|
|
67
|
+
aud: EXAMPLE_PRESENTATION_AUDIENCE_HOST_ID,
|
|
58
68
|
vp: {
|
|
59
69
|
'@context': [W3cCredentialContexts.V1],
|
|
60
70
|
type: [W3cCredentialTypes.VerifiablePresentation],
|
|
61
|
-
holder:
|
|
71
|
+
holder: EXAMPLE_ORG_CONTROLLER_SIGNING_KEY_ID,
|
|
62
72
|
verifiableCredential: [
|
|
63
|
-
JSON.stringify(
|
|
64
|
-
JSON.stringify(
|
|
73
|
+
JSON.stringify(EXAMPLE_ORG_ACTIVATION_ORGANIZATION_CREDENTIAL),
|
|
74
|
+
JSON.stringify(EXAMPLE_ORG_ACTIVATION_LEGAL_REPRESENTATIVE_CREDENTIAL),
|
|
65
75
|
],
|
|
66
76
|
},
|
|
67
77
|
});
|
|
@@ -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.
|
|
30
|
-
ServiceCapabilityToken.
|
|
29
|
+
ServiceCapabilityToken.IndexProvider,
|
|
30
|
+
ServiceCapabilityToken.DigitalTwinReader,
|
|
31
31
|
]),
|
|
32
32
|
},
|
|
33
33
|
};
|
|
@@ -59,7 +59,15 @@ export interface ClassicPublicJwk {
|
|
|
59
59
|
x: string;
|
|
60
60
|
y: string;
|
|
61
61
|
kid?: string;
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
|
+
* JOSE signing algorithm for classical EC keys.
|
|
64
|
+
*
|
|
65
|
+
* Examples:
|
|
66
|
+
* - `ES256` for P-256
|
|
67
|
+
* - `ES384` for P-384
|
|
68
|
+
* - `ES256K` for secp256k1
|
|
69
|
+
*/
|
|
70
|
+
alg?: "ES256" | "ES384" | "ES256K";
|
|
63
71
|
use?: string;
|
|
64
72
|
}
|
|
65
73
|
/**
|
package/dist/models/index.d.ts
CHANGED
|
@@ -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';
|
package/dist/models/index.js
CHANGED
|
@@ -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';
|
package/dist/models/params.d.ts
CHANGED
|
@@ -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;
|
package/dist/models/params.js
CHANGED
package/dist/utils/index.d.ts
CHANGED
|
@@ -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';
|
package/dist/utils/index.js
CHANGED
|
@@ -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';
|
package/dist/utils/vp-token.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import { JoseSignatureAlgorithm } from '../constants/cryptography';
|
|
2
|
+
/**
|
|
3
|
+
* Protected JOSE header used when assembling a compact VP JWT.
|
|
4
|
+
*
|
|
5
|
+
* The `alg` field is intentionally typed as a shared JOSE signature algorithm
|
|
6
|
+
* instead of a free-form string so docs/tests can show the supported values
|
|
7
|
+
* explicitly, including `ES256K` for secp256k1-based signers.
|
|
8
|
+
*/
|
|
1
9
|
export type VpTokenHeader = {
|
|
2
|
-
alg:
|
|
10
|
+
alg: JoseSignatureAlgorithm;
|
|
3
11
|
typ?: string;
|
|
4
12
|
kid?: string;
|
|
5
13
|
[key: string]: unknown;
|
|
@@ -16,20 +24,47 @@ export type VpTokenPayload = {
|
|
|
16
24
|
'@context'?: unknown;
|
|
17
25
|
type?: unknown;
|
|
18
26
|
holder?: string;
|
|
19
|
-
verifiableCredential: string
|
|
27
|
+
verifiableCredential: Array<string | Record<string, unknown>>;
|
|
20
28
|
[key: string]: unknown;
|
|
21
29
|
};
|
|
22
30
|
[key: string]: unknown;
|
|
23
31
|
};
|
|
24
32
|
export type VpCredential = Record<string, unknown>;
|
|
33
|
+
export type VpCredentialInput = string | Record<string, unknown>;
|
|
25
34
|
export declare function generateUuidLike(): string;
|
|
26
35
|
export declare function buildEpochWindow(ttlSeconds?: number): {
|
|
27
36
|
iat: number;
|
|
28
37
|
exp: number;
|
|
29
38
|
};
|
|
30
39
|
export declare function createVP(input?: Partial<VpTokenPayload>): VpTokenPayload;
|
|
31
|
-
|
|
32
|
-
|
|
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 declare function addVC(vpPayload: VpTokenPayload, vcInput: VpCredentialInput): VpTokenPayload;
|
|
58
|
+
/**
|
|
59
|
+
* Appends many VC entries to the VP payload.
|
|
60
|
+
*
|
|
61
|
+
* Each entry may be:
|
|
62
|
+
*
|
|
63
|
+
* - compact VC JWT/JWS string
|
|
64
|
+
* - raw JSON VC string
|
|
65
|
+
* - direct VC JSON object
|
|
66
|
+
*/
|
|
67
|
+
export declare function addVCs(vpPayload: VpTokenPayload, vcs: VpCredentialInput[]): VpTokenPayload;
|
|
33
68
|
/**
|
|
34
69
|
* Decodes a compact VP token payload into a JSON object.
|
|
35
70
|
*
|
|
@@ -67,12 +102,38 @@ export declare function getOrganizationCredentialFromVpToken(vpToken: string): V
|
|
|
67
102
|
* @param vpToken Compact VP token or raw JSON string.
|
|
68
103
|
*/
|
|
69
104
|
export declare function getLegalRepresentativeCredentialFromVpToken(vpToken: string): VpCredential | undefined;
|
|
70
|
-
|
|
71
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Appends an organization activation credential after validating its VC type.
|
|
107
|
+
*
|
|
108
|
+
* Accepts compact VC strings, raw JSON VC strings, or VC JSON objects.
|
|
109
|
+
*/
|
|
110
|
+
export declare function addOrganizationCredential(vpPayload: VpTokenPayload, vc: VpCredentialInput): VpTokenPayload;
|
|
111
|
+
/**
|
|
112
|
+
* Appends a legal-representative activation credential after validating its VC
|
|
113
|
+
* type.
|
|
114
|
+
*
|
|
115
|
+
* Accepts compact VC strings, raw JSON VC strings, or VC JSON objects.
|
|
116
|
+
*/
|
|
117
|
+
export declare function addLegalRepresentativeCredential(vpPayload: VpTokenPayload, vc: VpCredentialInput): VpTokenPayload;
|
|
72
118
|
export declare function prepareForSignature(header: VpTokenHeader, payload: VpTokenPayload): {
|
|
73
119
|
encodedHeader: string;
|
|
74
120
|
encodedPayload: string;
|
|
75
121
|
signingInput: string;
|
|
76
122
|
};
|
|
123
|
+
/**
|
|
124
|
+
* Returns the UTF-8 bytes of the canonical `base64url(header).base64url(payload)`
|
|
125
|
+
* signing input.
|
|
126
|
+
*
|
|
127
|
+
* This is the exact byte sequence an external wallet, HSM, or KMS must sign
|
|
128
|
+
* before the caller assembles the final compact VP JWT with
|
|
129
|
+
* `buildVpTokenCompact(...)`.
|
|
130
|
+
*/
|
|
77
131
|
export declare function prepareBytesForSignature(header: VpTokenHeader, payload: VpTokenPayload): Uint8Array;
|
|
132
|
+
/**
|
|
133
|
+
* Assembles the final compact VP JWT once the caller already has:
|
|
134
|
+
*
|
|
135
|
+
* - the base64url-encoded protected header
|
|
136
|
+
* - the base64url-encoded VP payload
|
|
137
|
+
* - the detached signature returned by the external signer, also base64url-encoded
|
|
138
|
+
*/
|
|
78
139
|
export declare function buildVpTokenCompact(encodedHeader: string, encodedPayload: string, signatureBase64Url: string): string;
|
package/dist/utils/vp-token.js
CHANGED
|
@@ -37,19 +37,52 @@ export function createVP(input) {
|
|
|
37
37
|
};
|
|
38
38
|
return base;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
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
|
}
|
|
@@ -188,10 +232,25 @@ export function prepareForSignature(header, payload) {
|
|
|
188
232
|
signingInput: `${encodedHeader}.${encodedPayload}`,
|
|
189
233
|
};
|
|
190
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Returns the UTF-8 bytes of the canonical `base64url(header).base64url(payload)`
|
|
237
|
+
* signing input.
|
|
238
|
+
*
|
|
239
|
+
* This is the exact byte sequence an external wallet, HSM, or KMS must sign
|
|
240
|
+
* before the caller assembles the final compact VP JWT with
|
|
241
|
+
* `buildVpTokenCompact(...)`.
|
|
242
|
+
*/
|
|
191
243
|
export function prepareBytesForSignature(header, payload) {
|
|
192
244
|
const { signingInput } = prepareForSignature(header, payload);
|
|
193
245
|
return new TextEncoder().encode(signingInput);
|
|
194
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Assembles the final compact VP JWT once the caller already has:
|
|
249
|
+
*
|
|
250
|
+
* - the base64url-encoded protected header
|
|
251
|
+
* - the base64url-encoded VP payload
|
|
252
|
+
* - the detached signature returned by the external signer, also base64url-encoded
|
|
253
|
+
*/
|
|
195
254
|
export function buildVpTokenCompact(encodedHeader, encodedPayload, signatureBase64Url) {
|
|
196
255
|
return `${encodedHeader}.${encodedPayload}.${String(signatureBase64Url || '').trim()}`;
|
|
197
256
|
}
|