gdc-common-utils-ts 1.24.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +39 -0
  2. package/dist/constants/index.d.ts +1 -0
  3. package/dist/constants/index.js +1 -0
  4. package/dist/constants/profile-runtime.d.ts +33 -0
  5. package/dist/constants/profile-runtime.js +30 -0
  6. package/dist/examples/frontend-session.js +2 -1
  7. package/dist/examples/index.d.ts +1 -0
  8. package/dist/examples/index.js +1 -0
  9. package/dist/examples/lifecycle.js +5 -5
  10. package/dist/examples/organization-controller.d.ts +0 -1
  11. package/dist/examples/organization-controller.js +0 -1
  12. package/dist/examples/profile-runtime.d.ts +16 -0
  13. package/dist/examples/profile-runtime.js +18 -0
  14. package/dist/interfaces/Cryptography.types.d.ts +15 -0
  15. package/dist/models/identity-bootstrap.d.ts +9 -0
  16. package/dist/utils/activation-policy.d.ts +22 -3
  17. package/dist/utils/activation-policy.js +22 -3
  18. package/dist/utils/activation-request.d.ts +43 -1
  19. package/dist/utils/activation-request.js +74 -0
  20. package/dist/utils/communication-search-editor.d.ts +3 -3
  21. package/dist/utils/communication-search-editor.js +1 -1
  22. package/dist/utils/index.d.ts +3 -0
  23. package/dist/utils/index.js +3 -0
  24. package/dist/utils/individual-organization-lifecycle.d.ts +15 -5
  25. package/dist/utils/individual-organization-lifecycle.js +53 -6
  26. package/dist/utils/interoperable-resource-operation.d.ts +4 -4
  27. package/dist/utils/interoperable-resource-operation.js +22 -22
  28. package/dist/utils/jwk-thumbprint.d.ts +40 -0
  29. package/dist/utils/jwk-thumbprint.js +57 -0
  30. package/dist/utils/legal-organization-onboarding.d.ts +97 -0
  31. package/dist/utils/legal-organization-onboarding.js +128 -0
  32. package/dist/utils/license-commercial-search.d.ts +6 -6
  33. package/dist/utils/license-commercial-search.js +2 -2
  34. package/dist/utils/license-list-search.d.ts +7 -7
  35. package/dist/utils/license-list-search.js +23 -23
  36. package/dist/utils/license-offer-order.d.ts +19 -19
  37. package/dist/utils/license-offer-order.js +68 -68
  38. package/dist/utils/organization-lifecycle.d.ts +59 -0
  39. package/dist/utils/organization-lifecycle.js +155 -0
  40. package/package.json +2 -2
package/README.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # gdc-common-utils-ts
2
2
 
3
+ See [ARCHITECTURE.md](./ARCHITECTURE.md) and
4
+ [CONTRIBUTING.md](./CONTRIBUTING.md) before adding new shared helpers,
5
+ fixtures, or high-level tests.
6
+
7
+ Short rule:
8
+
9
+ - if a test/example can reuse a shared type or fixture, it must do so
10
+ - do not add ad hoc literals in `101` tests when `gdc-common-utils-ts` can own
11
+ the reusable value instead
12
+
3
13
  Employee shared examples live in `src/examples/employee.ts`.
4
14
  Employee pure helper functions live in `src/utils/employee.ts`.
5
15
 
@@ -30,6 +40,35 @@ boundaries used in `gdc-common-utils-ts`.
30
40
  - `resource.meta.claims` is the canonical project-specific claims container and must be preserved across conversions/transports.
31
41
  - `resource.meta.claims` is not part of base FHIR; it is a claims-first extension carried by FHIR-like resources in GDC contracts.
32
42
 
43
+ ## Identity Continuity
44
+
45
+ For ICA-backed organization activation, the representative/controller proof is
46
+ intentionally split into two complementary dimensions:
47
+
48
+ - `credentialSubject.sameAs`
49
+ public identity continuity, typically an email-derived
50
+ `urn:multibase:z...`
51
+ - `credentialSubject.hasCredential.material`
52
+ signing-key continuity, ideally an RFC 9278 JWK-thumbprint URN bound to the
53
+ controller key that signs the VP or was captured during ICA verification
54
+
55
+ They are not interchangeable:
56
+
57
+ - `sameAs` does not prove possession of the signing key
58
+ - `hasCredential.material` does not by itself prove the expected public alias
59
+ or email continuity
60
+
61
+ Production-grade flows should prefer ICA-issued representative VCs that carry
62
+ both dimensions.
63
+
64
+ Step by step:
65
+
66
+ 1. ICA verifies the signed PDF and emits the representative VC.
67
+ 2. ICA projects `credentialSubject.sameAs` from signed email evidence when available.
68
+ 3. ICA projects `credentialSubject.hasCredential.material` from the captured controller binding key.
69
+ 4. GW/common-utils enforce key-binding continuity as the hard activation requirement.
70
+ 5. Higher layers may additionally compare `sameAs` for stronger identity/audit continuity.
71
+
33
72
  ## 101 Test Convention
34
73
 
35
74
  Every `101` test in this repo is expected to be a didactic executable tutorial,
@@ -14,6 +14,7 @@ export * from './schemaorg';
14
14
  export * from './hl7-roles';
15
15
  export * from './healthcare';
16
16
  export * from './permission-templates';
17
+ export * from './profile-runtime';
17
18
  export * from './vital-signs';
18
19
  export * from './network';
19
20
  export * from './observation-category';
@@ -14,6 +14,7 @@ export * from './schemaorg.js';
14
14
  export * from './hl7-roles.js';
15
15
  export * from './healthcare.js';
16
16
  export * from './permission-templates.js';
17
+ export * from './profile-runtime.js';
17
18
  export * from './vital-signs.js';
18
19
  export * from './network.js';
19
20
  export * from './observation-category.js';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Canonical logical application families used by shared SDK profile/session
3
+ * contracts.
4
+ */
5
+ export declare const ProfileAppTypes: Readonly<{
6
+ readonly Organization: "Organization";
7
+ readonly Family: "Family";
8
+ }>;
9
+ export type ProfileAppType = typeof ProfileAppTypes[keyof typeof ProfileAppTypes];
10
+ /**
11
+ * Canonical runtime classes for actor-aware profile loading.
12
+ */
13
+ export declare const ActorRuntimeClasses: Readonly<{
14
+ readonly Frontend: "frontend";
15
+ readonly Server: "server";
16
+ }>;
17
+ export type ActorRuntimeClass = typeof ActorRuntimeClasses[keyof typeof ActorRuntimeClasses];
18
+ /**
19
+ * Canonical key access strategies for profile loading/unlocking.
20
+ */
21
+ export declare const KeyAccessModes: Readonly<{
22
+ readonly DeriveFromSeed: "derive-from-seed";
23
+ readonly UnlockEncryptedKeys: "unlock-encrypted-keys";
24
+ }>;
25
+ export type KeyAccessMode = typeof KeyAccessModes[keyof typeof KeyAccessModes];
26
+ /**
27
+ * Canonical secret kinds for subject/index relationship connection.
28
+ */
29
+ export declare const ConnectionSecretKinds: Readonly<{
30
+ readonly PinPassword: "pin-password";
31
+ readonly OtpCode: "otp-code";
32
+ }>;
33
+ export type ConnectionSecretKind = typeof ConnectionSecretKinds[keyof typeof ConnectionSecretKinds];
@@ -0,0 +1,30 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ /**
3
+ * Canonical logical application families used by shared SDK profile/session
4
+ * contracts.
5
+ */
6
+ export const ProfileAppTypes = Object.freeze({
7
+ Organization: 'Organization',
8
+ Family: 'Family',
9
+ });
10
+ /**
11
+ * Canonical runtime classes for actor-aware profile loading.
12
+ */
13
+ export const ActorRuntimeClasses = Object.freeze({
14
+ Frontend: 'frontend',
15
+ Server: 'server',
16
+ });
17
+ /**
18
+ * Canonical key access strategies for profile loading/unlocking.
19
+ */
20
+ export const KeyAccessModes = Object.freeze({
21
+ DeriveFromSeed: 'derive-from-seed',
22
+ UnlockEncryptedKeys: 'unlock-encrypted-keys',
23
+ });
24
+ /**
25
+ * Canonical secret kinds for subject/index relationship connection.
26
+ */
27
+ export const ConnectionSecretKinds = Object.freeze({
28
+ PinPassword: 'pin-password',
29
+ OtpCode: 'otp-code',
30
+ });
@@ -9,12 +9,13 @@
9
9
  * - do not inline DID/email/profile literals directly in frontend examples
10
10
  */
11
11
  import { EXAMPLE_PROFILE_EMAIL, EXAMPLE_PROFILE_ID, EXAMPLE_PROFILE_ORGANIZATION_DID, } from './shared.js';
12
+ import { EXAMPLE_PROFILE_APP_TYPE_FAMILY } from './profile-runtime.js';
12
13
  export const EXAMPLE_PROFILE_SESSION_INPUT = {
13
14
  profileId: ` ${EXAMPLE_PROFILE_ID} `,
14
15
  email: ` ${EXAMPLE_PROFILE_EMAIL} `,
15
16
  role: ' controller ',
16
17
  providerDid: ` ${EXAMPLE_PROFILE_ORGANIZATION_DID} `,
17
- appType: 'Family',
18
+ appType: EXAMPLE_PROFILE_APP_TYPE_FAMILY,
18
19
  };
19
20
  export const EXAMPLE_PROFILE_REGISTRY_ENTRY = {
20
21
  id: EXAMPLE_PROFILE_ID,
@@ -11,6 +11,7 @@ export * from './related-person';
11
11
  export * from './consent-access';
12
12
  export * from './relationship-access';
13
13
  export * from './frontend-session';
14
+ export * from './profile-runtime';
14
15
  export * from './lifecycle';
15
16
  export * from './api-flow-examples';
16
17
  export * from './contract-examples';
@@ -11,6 +11,7 @@ export * from './related-person.js';
11
11
  export * from './consent-access.js';
12
12
  export * from './relationship-access.js';
13
13
  export * from './frontend-session.js';
14
+ export * from './profile-runtime.js';
14
15
  export * from './lifecycle.js';
15
16
  export * from './api-flow-examples.js';
16
17
  export * from './contract-examples.js';
@@ -2,7 +2,7 @@
2
2
  import { ClaimsOrganizationSchemaorg, ClaimsPersonSchemaorg, } from '../constants/schemaorg.js';
3
3
  import { LifecycleRequestType } from '../constants/lifecycle.js';
4
4
  import { ClaimConsent } from '../models/consent-rule.js';
5
- import { IndividualOrganizationLifecycleDraft, IndividualOrganizationLifecycleOperations, } from '../utils/individual-organization-lifecycle.js';
5
+ import { IndividualOrganizationLifecycleEditor, IndividualOrganizationLifecycleOperations, } from '../utils/individual-organization-lifecycle.js';
6
6
  import { EXAMPLE_EMAIL_CONTROLLER_INDIVIDUAL, EXAMPLE_EMAIL_CONTROLLER_ORG, EXAMPLE_CLINICAL_SECTION_ALLERGIES, EXAMPLE_CONSENT_PURPOSE_TREATMENT, EXAMPLE_HEALTHCARE_ACTOR_ROLE_PHYSICIAN, EXAMPLE_JURISDICTION, EXAMPLE_SECTOR, EXAMPLE_TENANT_IDENTIFIER, } from './shared.js';
7
7
  /**
8
8
  * Canonical lifecycle naming for `v1`.
@@ -190,12 +190,12 @@ export const EXAMPLE_INDIVIDUAL_DISABLE_MESSAGE = {
190
190
  erasesPersonalDataImmediately: false,
191
191
  },
192
192
  };
193
- export const EXAMPLE_INDIVIDUAL_ORGANIZATION_DISABLE_ENTRY = new IndividualOrganizationLifecycleDraft()
193
+ export const EXAMPLE_INDIVIDUAL_ORGANIZATION_DISABLE_ENTRY = new IndividualOrganizationLifecycleEditor()
194
194
  .setClaims(EXAMPLE_INDIVIDUAL_DISABLE_MESSAGE.claims)
195
195
  .setOperation(IndividualOrganizationLifecycleOperations.Disable)
196
196
  .setRequestType(EXAMPLE_INDIVIDUAL_ORGANIZATION_DISABLE_REQUEST_TYPE)
197
197
  .buildCurrentGwDataEntry();
198
- export const EXAMPLE_INDIVIDUAL_ORGANIZATION_DISABLE_PAYLOAD = new IndividualOrganizationLifecycleDraft()
198
+ export const EXAMPLE_INDIVIDUAL_ORGANIZATION_DISABLE_PAYLOAD = new IndividualOrganizationLifecycleEditor()
199
199
  .setClaims(EXAMPLE_INDIVIDUAL_DISABLE_MESSAGE.claims)
200
200
  .setOperation(IndividualOrganizationLifecycleOperations.Disable)
201
201
  .setRequestType(EXAMPLE_INDIVIDUAL_ORGANIZATION_DISABLE_REQUEST_TYPE)
@@ -221,12 +221,12 @@ export const EXAMPLE_INDIVIDUAL_DELETE_MESSAGE = {
221
221
  keepsMinimumAuditTrailRequiredByLaw: true,
222
222
  },
223
223
  };
224
- export const EXAMPLE_INDIVIDUAL_ORGANIZATION_PURGE_ENTRY = new IndividualOrganizationLifecycleDraft()
224
+ export const EXAMPLE_INDIVIDUAL_ORGANIZATION_PURGE_ENTRY = new IndividualOrganizationLifecycleEditor()
225
225
  .setClaims(EXAMPLE_INDIVIDUAL_DISABLE_MESSAGE.claims)
226
226
  .setOperation(IndividualOrganizationLifecycleOperations.Purge)
227
227
  .setRequestType(EXAMPLE_INDIVIDUAL_ORGANIZATION_PURGE_REQUEST_TYPE)
228
228
  .buildCurrentGwDataEntry();
229
- export const EXAMPLE_INDIVIDUAL_ORGANIZATION_PURGE_PAYLOAD = new IndividualOrganizationLifecycleDraft()
229
+ export const EXAMPLE_INDIVIDUAL_ORGANIZATION_PURGE_PAYLOAD = new IndividualOrganizationLifecycleEditor()
230
230
  .setClaims(EXAMPLE_INDIVIDUAL_DISABLE_MESSAGE.claims)
231
231
  .setOperation(IndividualOrganizationLifecycleOperations.Purge)
232
232
  .setRequestType(EXAMPLE_INDIVIDUAL_ORGANIZATION_PURGE_REQUEST_TYPE)
@@ -32,7 +32,6 @@ export declare const EXAMPLE_ACTIVATE_ORGANIZATION_FROM_ICA_PROOF_INPUT: {
32
32
  };
33
33
  };
34
34
  readonly additionalClaims: {
35
- readonly "org.schema.Organization.alternateName": "acme";
36
35
  readonly "org.schema.Organization.legalName": "ACME HEALTH SL";
37
36
  readonly "org.schema.Organization.identifier.additionalType": "taxID";
38
37
  readonly "org.schema.Organization.identifier.value": "VATES-B00112233";
@@ -14,7 +14,6 @@ export const EXAMPLE_ACTIVATE_ORGANIZATION_FROM_ICA_PROOF_INPUT = {
14
14
  vpToken: '<ica-proof-token>',
15
15
  controller: EXAMPLE_CONTROLLER_BINDING,
16
16
  additionalClaims: {
17
- [ClaimsOrganizationSchemaorg.alternateName]: 'acme',
18
17
  [ClaimsOrganizationSchemaorg.legalName]: 'ACME HEALTH SL',
19
18
  [ClaimsOrganizationSchemaorg.identifierType]: 'taxID',
20
19
  [ClaimsOrganizationSchemaorg.identifierValue]: 'VATES-B00112233',
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shared fixtures for profile-runtime tests and 101 examples.
3
+ *
4
+ * Keep runtime-class, key-access, secret-kind, app-type, and local secret
5
+ * placeholders here so SDK packages do not re-inline them in their own tests.
6
+ */
7
+ export declare const EXAMPLE_PROFILE_APP_TYPE_FAMILY: "Family";
8
+ export declare const EXAMPLE_PROFILE_RUNTIME_CLASS_SERVER: "server";
9
+ export declare const EXAMPLE_PROFILE_RUNTIME_CLASS_FRONTEND: "frontend";
10
+ export declare const EXAMPLE_PROFILE_KEY_ACCESS_MODE_SERVER: "unlock-encrypted-keys";
11
+ export declare const EXAMPLE_PROFILE_KEY_ACCESS_MODE_FRONTEND: "derive-from-seed";
12
+ export declare const EXAMPLE_PROFILE_CONNECTION_SECRET_KIND_PIN_PASSWORD: "pin-password";
13
+ export declare const EXAMPLE_PROFILE_LOCAL_PIN_PASSWORD_BACKEND: "local-backend-pin";
14
+ export declare const EXAMPLE_PROFILE_LOCAL_PIN_PASSWORD_FRONTEND: "local-frontend-pin";
15
+ export declare const EXAMPLE_PROFILE_CONNECTION_PIN_PASSWORD: "subject-channel-pin";
16
+ export declare const EXAMPLE_PROFILE_RUNTIME_JOB_ID: "job-id";
@@ -0,0 +1,18 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ import { ActorRuntimeClasses, ConnectionSecretKinds, KeyAccessModes, ProfileAppTypes, } from '../constants/profile-runtime.js';
3
+ /**
4
+ * Shared fixtures for profile-runtime tests and 101 examples.
5
+ *
6
+ * Keep runtime-class, key-access, secret-kind, app-type, and local secret
7
+ * placeholders here so SDK packages do not re-inline them in their own tests.
8
+ */
9
+ export const EXAMPLE_PROFILE_APP_TYPE_FAMILY = ProfileAppTypes.Family;
10
+ export const EXAMPLE_PROFILE_RUNTIME_CLASS_SERVER = ActorRuntimeClasses.Server;
11
+ export const EXAMPLE_PROFILE_RUNTIME_CLASS_FRONTEND = ActorRuntimeClasses.Frontend;
12
+ export const EXAMPLE_PROFILE_KEY_ACCESS_MODE_SERVER = KeyAccessModes.UnlockEncryptedKeys;
13
+ export const EXAMPLE_PROFILE_KEY_ACCESS_MODE_FRONTEND = KeyAccessModes.DeriveFromSeed;
14
+ export const EXAMPLE_PROFILE_CONNECTION_SECRET_KIND_PIN_PASSWORD = ConnectionSecretKinds.PinPassword;
15
+ export const EXAMPLE_PROFILE_LOCAL_PIN_PASSWORD_BACKEND = 'local-backend-pin';
16
+ export const EXAMPLE_PROFILE_LOCAL_PIN_PASSWORD_FRONTEND = 'local-frontend-pin';
17
+ export const EXAMPLE_PROFILE_CONNECTION_PIN_PASSWORD = 'subject-channel-pin';
18
+ export const EXAMPLE_PROFILE_RUNTIME_JOB_ID = 'job-id';
@@ -27,6 +27,17 @@ export type AlgMlDsa2 = "ML-DSA-44";
27
27
  export type AlgMlDsa3 = "ML-DSA-65";
28
28
  export type AlgMlDsa5 = "ML-DSA-87";
29
29
  export type MldsaAlg = AlgMlDsa2 | AlgMlDsa3 | AlgMlDsa5;
30
+ /**
31
+ * Base JWKs used for RFC 7638 thumbprint calculation.
32
+ *
33
+ * Mapping used by this codebase:
34
+ * - ML-KEM uses `OKP` with `crv`
35
+ * - ML-DSA uses `AKP` with `alg` and `pub`
36
+ * - classical EC uses `EC` with `crv`, `x`, `y`
37
+ *
38
+ * Note that ML-DSA does not use `crv` here. The algorithm family/strength is
39
+ * captured by `alg` instead, for example `ML-DSA-44`.
40
+ */
30
41
  export type MlkemBaseJwk = {
31
42
  kty: "OKP";
32
43
  crv: MlkemCurve;
@@ -52,6 +63,10 @@ export interface MldsaPublicJwk extends MldsaBaseJwk {
52
63
  }
53
64
  /**
54
65
  * Represents a public key for classic cryptography algorithms like Elliptic Curve.
66
+ *
67
+ * The RFC 7638 thumbprint for these keys is derived from `kty`, `crv`, `x`,
68
+ * and `y`. This means curves such as `P-256`, `P-384`, and `secp256k1` are
69
+ * covered through the `crv` field.
55
70
  */
56
71
  export interface ClassicPublicJwk {
57
72
  kty: "EC";
@@ -1,6 +1,7 @@
1
1
  import { PublicJwk } from '../interfaces/Cryptography.types';
2
2
  import { type IssueSeverityAttentionCode } from './issue';
3
3
  import { JwkSet } from './jwk';
4
+ import { DidCommDecodedMetadata } from './confidential-message';
4
5
  /**
5
6
  * Public key binding for a human actor/controller identity.
6
7
  *
@@ -79,6 +80,14 @@ export interface OrganizationActivationRequest extends ActivationProofInput {
79
80
  */
80
81
  representativeCredential?: unknown;
81
82
  }
83
+ /**
84
+ * Technical metadata mirrored into plaintext DIDComm payloads when no real
85
+ * outer JWS/JWE envelope is present on the wire.
86
+ *
87
+ * This must be treated as transport compatibility metadata only. It does not
88
+ * replace canonical activation fields such as `vp_token` or `controller.*`.
89
+ */
90
+ export type DidcommPlaintextTransportMetadata = DidCommDecodedMetadata;
82
91
  /**
83
92
  * Structured validation issue emitted by bootstrap validators.
84
93
  */
@@ -48,6 +48,14 @@ export declare function hasRoleCode(roleCode: string | undefined, requiredCode?:
48
48
  /**
49
49
  * Extracts representative signing/binding continuity data from `credentialSubject.hasCredential`.
50
50
  *
51
+ * Security note:
52
+ * - this field proves continuity of the controller signing/binding key
53
+ * - it is intentionally different from `credentialSubject.sameAs`, which
54
+ * proves continuity of the representative public identity alias (for example
55
+ * email-derived `urn:multibase:z...`)
56
+ * - production-grade activation flows are strongest when both dimensions are
57
+ * present in the ICA-issued representative VC
58
+ *
51
59
  * Compatibility rules:
52
60
  * - legacy VC payloads may still carry `hasCredential.material`
53
61
  * - newer payloads may carry the same semantic value in `hasCredential.value`
@@ -60,9 +68,12 @@ export declare function extractRepresentativeCredentialBinding(representativeCre
60
68
  * Extracts the representative subject identifier from `credentialSubject.id`.
61
69
  *
62
70
  * ICA currently models the natural person with a stable person URN while the
63
- * controller/bootstrap continuity is carried in sibling claims such as
64
- * `sameAs` and `hasCredential`. Activation policy must therefore accept the
65
- * canonical person URN form and must not require a representative `did:web`.
71
+ * controller/bootstrap continuity is carried in sibling claims:
72
+ * - `sameAs` for public identity continuity
73
+ * - `hasCredential` for key-binding continuity
74
+ *
75
+ * Activation policy must therefore accept the canonical person URN form and
76
+ * must not require a representative `did:web`.
66
77
  *
67
78
  * @param representativeCredential Candidate representative credential.
68
79
  */
@@ -148,6 +159,14 @@ export declare function isMemberDidWebUnderOwner(memberDidWeb: string, ownerDidW
148
159
  /**
149
160
  * Validates the activation representative policy against organization and representative credentials.
150
161
  *
162
+ * The representative proof model is intentionally two-dimensional:
163
+ * - `credentialSubject.sameAs` expresses public identity continuity
164
+ * - `credentialSubject.hasCredential.material` expresses signing-key continuity
165
+ *
166
+ * For GW activation, the key-binding dimension is the hard requirement
167
+ * enforced here. The public-identity dimension may still be used by higher
168
+ * layers for stronger demo/production matching and auditability.
169
+ *
151
170
  * @param input.organizationCredential Candidate organization credential.
152
171
  * @param input.representativeCredential Candidate representative credential.
153
172
  * @param input.requiredRoleCode Required representative role, defaults to `RESPRSN`.
@@ -106,6 +106,14 @@ export function hasRoleCode(roleCode, requiredCode = 'RESPRSN') {
106
106
  /**
107
107
  * Extracts representative signing/binding continuity data from `credentialSubject.hasCredential`.
108
108
  *
109
+ * Security note:
110
+ * - this field proves continuity of the controller signing/binding key
111
+ * - it is intentionally different from `credentialSubject.sameAs`, which
112
+ * proves continuity of the representative public identity alias (for example
113
+ * email-derived `urn:multibase:z...`)
114
+ * - production-grade activation flows are strongest when both dimensions are
115
+ * present in the ICA-issued representative VC
116
+ *
109
117
  * Compatibility rules:
110
118
  * - legacy VC payloads may still carry `hasCredential.material`
111
119
  * - newer payloads may carry the same semantic value in `hasCredential.value`
@@ -145,9 +153,12 @@ function extractCredentialBindingValue(value) {
145
153
  * Extracts the representative subject identifier from `credentialSubject.id`.
146
154
  *
147
155
  * ICA currently models the natural person with a stable person URN while the
148
- * controller/bootstrap continuity is carried in sibling claims such as
149
- * `sameAs` and `hasCredential`. Activation policy must therefore accept the
150
- * canonical person URN form and must not require a representative `did:web`.
156
+ * controller/bootstrap continuity is carried in sibling claims:
157
+ * - `sameAs` for public identity continuity
158
+ * - `hasCredential` for key-binding continuity
159
+ *
160
+ * Activation policy must therefore accept the canonical person URN form and
161
+ * must not require a representative `did:web`.
151
162
  *
152
163
  * @param representativeCredential Candidate representative credential.
153
164
  */
@@ -306,6 +317,14 @@ export function isMemberDidWebUnderOwner(memberDidWeb, ownerDidWeb) {
306
317
  /**
307
318
  * Validates the activation representative policy against organization and representative credentials.
308
319
  *
320
+ * The representative proof model is intentionally two-dimensional:
321
+ * - `credentialSubject.sameAs` expresses public identity continuity
322
+ * - `credentialSubject.hasCredential.material` expresses signing-key continuity
323
+ *
324
+ * For GW activation, the key-binding dimension is the hard requirement
325
+ * enforced here. The public-identity dimension may still be used by higher
326
+ * layers for stronger demo/production matching and auditability.
327
+ *
309
328
  * @param input.organizationCredential Candidate organization credential.
310
329
  * @param input.representativeCredential Candidate representative credential.
311
330
  * @param input.requiredRoleCode Required representative role, defaults to `RESPRSN`.
@@ -1,4 +1,4 @@
1
- import { ControllerBindingInput, IdentityBootstrapValidationResult, OrganizationActivationRequest, OrganizationBindingInput } from '../models/identity-bootstrap';
1
+ import { ControllerBindingInput, DidcommPlaintextTransportMetadata, IdentityBootstrapValidationResult, OrganizationActivationRequest, OrganizationBindingInput } from '../models/identity-bootstrap';
2
2
  import { JwkSet } from '../models/jwk';
3
3
  /**
4
4
  * Builder input for the canonical organization/service activation payload.
@@ -54,6 +54,23 @@ export interface BuildOrganizationBindingInputInput {
54
54
  keys: Array<Record<string, unknown>>;
55
55
  } | Array<Record<string, unknown>>;
56
56
  }
57
+ export interface BuildDidcommPlaintextTransportMetadataInput {
58
+ /**
59
+ * Explicit controller/person binding used by `_activate`.
60
+ *
61
+ * In demo/plaintext flows this is the preferred source for mirroring the
62
+ * technical communication key metadata into `meta.jws.protected` /
63
+ * `meta.jwe.header`.
64
+ */
65
+ controller?: ControllerBindingInput;
66
+ /**
67
+ * Optional explicit content type copied into the mirrored technical JWS
68
+ * header.
69
+ *
70
+ * Defaults to `application/didcomm-plaintext+json`.
71
+ */
72
+ contentType?: string;
73
+ }
57
74
  /**
58
75
  * Builds the canonical controller/person binding from semantic variables.
59
76
  *
@@ -79,12 +96,37 @@ export declare function buildControllerBindingInput(input: BuildControllerBindin
79
96
  * Builds the canonical organization/provider binding from semantic variables.
80
97
  */
81
98
  export declare function buildOrganizationBindingInput(input: BuildOrganizationBindingInputInput): OrganizationBindingInput;
99
+ /**
100
+ * Builds the technical plaintext transport metadata expected by GW-compatible
101
+ * demo flows.
102
+ *
103
+ * Transport rule:
104
+ * - in secure JOSE transport, these values belong in the protected JWS/JWE
105
+ * headers of the real envelope
106
+ * - in `application/didcomm-plaintext+json`, there is no signed outer
107
+ * envelope on the wire, so high-level SDK/BFF helpers may mirror the same
108
+ * technical key identifiers and public JWKs into `meta.jws.protected` and
109
+ * `meta.jwe.header`
110
+ *
111
+ * This is technical compatibility fallback only. The canonical activation
112
+ * contract remains `controller.publicKeyJwk` / `controller.jwks`.
113
+ */
114
+ export declare function buildDidcommPlaintextTransportMetadata(input: BuildDidcommPlaintextTransportMetadataInput): DidcommPlaintextTransportMetadata | undefined;
82
115
  /**
83
116
  * Builds the canonical `_activate` request payload shared by SDK and GW helpers.
84
117
  *
85
118
  * The resulting object intentionally preserves deprecated compatibility fields
86
119
  * when supplied, so callers can keep legacy flows alive while validators and
87
120
  * runtime layers flag that debt explicitly.
121
+ *
122
+ * Transport note:
123
+ * - secure JOSE submission should place technical signing/encryption metadata
124
+ * in the protected headers of the real JWS/JWE envelope
125
+ * - demo `application/didcomm-plaintext+json` flows may mirror those same
126
+ * values into plaintext `meta.jws.protected` / `meta.jwe.header` as a
127
+ * technical fallback expected by GW-compatible backends
128
+ * - that plaintext transport metadata must not replace the canonical
129
+ * `controller.publicKeyJwk` / `controller.jwks` activation contract
88
130
  */
89
131
  export declare function buildOrganizationActivationRequest(input: BuildOrganizationActivationRequestInput): OrganizationActivationRequest;
90
132
  /**
@@ -1,5 +1,6 @@
1
1
  // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
2
  import { IssueSeverity } from '../models/issue.js';
3
+ import { JoseContentEncryptionAlgorithms } from '../constants/cryptography.js';
3
4
  function pushIssue(issues, severity, code, message, path) {
4
5
  issues.push({ severity, code, message, ...(path ? { path } : {}) });
5
6
  }
@@ -12,6 +13,22 @@ function normalizeJwkSet(publicKeys) {
12
13
  }
13
14
  return publicKeys;
14
15
  }
16
+ function normalizeJwk(input) {
17
+ return input && typeof input === 'object'
18
+ ? input
19
+ : undefined;
20
+ }
21
+ function isEncryptionJwk(key) {
22
+ if (!key) {
23
+ return false;
24
+ }
25
+ const purposes = Array.isArray(key.purposes) ? key.purposes.map((value) => String(value)) : [];
26
+ const keyOps = Array.isArray(key.key_ops) ? key.key_ops.map((value) => String(value)) : [];
27
+ return String(key.use || '').trim() === 'enc'
28
+ || purposes.includes('didcomm-enc')
29
+ || keyOps.includes('encrypt')
30
+ || keyOps.includes('deriveKey');
31
+ }
15
32
  /**
16
33
  * Builds the canonical controller/person binding from semantic variables.
17
34
  *
@@ -53,12 +70,69 @@ export function buildOrganizationBindingInput(input) {
53
70
  ...(jwks ? { jwks } : {}),
54
71
  };
55
72
  }
73
+ /**
74
+ * Builds the technical plaintext transport metadata expected by GW-compatible
75
+ * demo flows.
76
+ *
77
+ * Transport rule:
78
+ * - in secure JOSE transport, these values belong in the protected JWS/JWE
79
+ * headers of the real envelope
80
+ * - in `application/didcomm-plaintext+json`, there is no signed outer
81
+ * envelope on the wire, so high-level SDK/BFF helpers may mirror the same
82
+ * technical key identifiers and public JWKs into `meta.jws.protected` and
83
+ * `meta.jwe.header`
84
+ *
85
+ * This is technical compatibility fallback only. The canonical activation
86
+ * contract remains `controller.publicKeyJwk` / `controller.jwks`.
87
+ */
88
+ export function buildDidcommPlaintextTransportMetadata(input) {
89
+ const signingKey = normalizeJwk(input.controller?.publicKeyJwk);
90
+ const encryptionKey = normalizeJwk(input.controller?.jwks?.keys?.find((candidate) => isEncryptionJwk(normalizeJwk(candidate))));
91
+ if (!signingKey && !encryptionKey) {
92
+ return undefined;
93
+ }
94
+ return {
95
+ ...(signingKey
96
+ ? {
97
+ jws: {
98
+ protected: {
99
+ alg: String(signingKey.alg || '').trim() || 'none',
100
+ kid: String(signingKey.kid || '').trim() || 'none',
101
+ cty: String(input.contentType || '').trim() || 'application/didcomm-plaintext+json',
102
+ jwk: signingKey,
103
+ },
104
+ },
105
+ }
106
+ : {}),
107
+ ...(encryptionKey
108
+ ? {
109
+ jwe: {
110
+ header: {
111
+ alg: String(encryptionKey.alg || encryptionKey.crv || '').trim() || 'none',
112
+ enc: JoseContentEncryptionAlgorithms.Aes256Gcm,
113
+ skid: String(encryptionKey.kid || '').trim() || 'none',
114
+ jwk: encryptionKey,
115
+ },
116
+ },
117
+ }
118
+ : {}),
119
+ };
120
+ }
56
121
  /**
57
122
  * Builds the canonical `_activate` request payload shared by SDK and GW helpers.
58
123
  *
59
124
  * The resulting object intentionally preserves deprecated compatibility fields
60
125
  * when supplied, so callers can keep legacy flows alive while validators and
61
126
  * runtime layers flag that debt explicitly.
127
+ *
128
+ * Transport note:
129
+ * - secure JOSE submission should place technical signing/encryption metadata
130
+ * in the protected headers of the real JWS/JWE envelope
131
+ * - demo `application/didcomm-plaintext+json` flows may mirror those same
132
+ * values into plaintext `meta.jws.protected` / `meta.jwe.header` as a
133
+ * technical fallback expected by GW-compatible backends
134
+ * - that plaintext transport metadata must not replace the canonical
135
+ * `controller.publicKeyJwk` / `controller.jwks` activation contract
62
136
  */
63
137
  export function buildOrganizationActivationRequest(input) {
64
138
  return {
@@ -6,7 +6,7 @@ export declare const CommunicationSearchEntryTypes: Readonly<{
6
6
  export declare const CommunicationSearchOperationTypes: Readonly<{
7
7
  readonly Search: "search";
8
8
  }>;
9
- export type CommunicationSearchDraft = Readonly<{
9
+ export type CommunicationSearchState = Readonly<{
10
10
  searchParams: Readonly<Record<string, string | number | boolean | readonly (string | number | boolean)[] | undefined>>;
11
11
  periodStart?: string;
12
12
  periodEnd?: string;
@@ -24,7 +24,7 @@ export type CommunicationSearchDraft = Readonly<{
24
24
  */
25
25
  export declare class CommunicationSearchEditor {
26
26
  private draft;
27
- constructor(initial?: Partial<CommunicationSearchDraft>);
27
+ constructor(initial?: Partial<CommunicationSearchState>);
28
28
  setSearchParams(value: Readonly<Record<string, string | number | boolean | readonly (string | number | boolean)[] | undefined>>): this;
29
29
  setSearchParam(claimKey: string, value: string | number | boolean | readonly (string | number | boolean)[] | undefined): this;
30
30
  setSearchParamSender(value: string | readonly string[]): this;
@@ -36,7 +36,7 @@ export declare class CommunicationSearchEditor {
36
36
  setPeriodEnd(value: string): this;
37
37
  setPaginationCount(value: number): this;
38
38
  setPageNumber(value: number): this;
39
- getDraft(): CommunicationSearchDraft;
39
+ getState(): CommunicationSearchState;
40
40
  toSearchInput(): CommunicationParticipantSearchInput;
41
41
  buildRequest(): FhirParametersResource;
42
42
  buildEntry(): {
@@ -121,7 +121,7 @@ export class CommunicationSearchEditor {
121
121
  this.draft = cloneDraft({ ...this.draft, page: value });
122
122
  return this;
123
123
  }
124
- getDraft() {
124
+ getState() {
125
125
  return cloneDraft(this.draft);
126
126
  }
127
127
  toSearchInput() {
@@ -48,6 +48,7 @@ export * from './fhir-validator';
48
48
  export * from './family-registration-test-data';
49
49
  export * from './individual-form-pdf';
50
50
  export * from './individual-organization-claims';
51
+ export * from './organization-lifecycle';
51
52
  export * from './individual-organization-lifecycle';
52
53
  export * from './individual-onboarding-editor';
53
54
  export * from './individual-onboarding-document-reference';
@@ -57,6 +58,8 @@ export * from './invoice-bundle';
57
58
  export * from './ips-bundle-claims';
58
59
  export * from './interoperable-resource-operation';
59
60
  export * from './jwt';
61
+ export * from './jwk-thumbprint';
62
+ export * from './legal-organization-onboarding';
60
63
  export * from './license';
61
64
  export * from './license-commercial-search';
62
65
  export * from './license-list-search';
@@ -48,6 +48,7 @@ export * from './fhir-validator.js';
48
48
  export * from './family-registration-test-data.js';
49
49
  export * from './individual-form-pdf.js';
50
50
  export * from './individual-organization-claims.js';
51
+ export * from './organization-lifecycle.js';
51
52
  export * from './individual-organization-lifecycle.js';
52
53
  export * from './individual-onboarding-editor.js';
53
54
  export * from './individual-onboarding-document-reference.js';
@@ -57,6 +58,8 @@ export * from './invoice-bundle.js';
57
58
  export * from './ips-bundle-claims.js';
58
59
  export * from './interoperable-resource-operation.js';
59
60
  export * from './jwt.js';
61
+ export * from './jwk-thumbprint.js';
62
+ export * from './legal-organization-onboarding.js';
60
63
  export * from './license.js';
61
64
  export * from './license-commercial-search.js';
62
65
  export * from './license-list-search.js';