gdc-common-utils-ts 1.24.3 → 2.0.2

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 (42) 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/ica-verify-response.d.ts +225 -0
  8. package/dist/examples/ica-verify-response.js +257 -0
  9. package/dist/examples/index.d.ts +2 -0
  10. package/dist/examples/index.js +2 -0
  11. package/dist/examples/lifecycle.js +5 -5
  12. package/dist/examples/organization-controller.d.ts +0 -1
  13. package/dist/examples/organization-controller.js +0 -1
  14. package/dist/examples/profile-runtime.d.ts +16 -0
  15. package/dist/examples/profile-runtime.js +18 -0
  16. package/dist/interfaces/Cryptography.types.d.ts +15 -0
  17. package/dist/models/identity-bootstrap.d.ts +9 -0
  18. package/dist/utils/activation-policy.d.ts +22 -3
  19. package/dist/utils/activation-policy.js +22 -3
  20. package/dist/utils/activation-request.d.ts +43 -1
  21. package/dist/utils/activation-request.js +74 -0
  22. package/dist/utils/communication-search-editor.d.ts +3 -3
  23. package/dist/utils/communication-search-editor.js +1 -1
  24. package/dist/utils/index.d.ts +3 -0
  25. package/dist/utils/index.js +3 -0
  26. package/dist/utils/individual-organization-lifecycle.d.ts +15 -5
  27. package/dist/utils/individual-organization-lifecycle.js +53 -6
  28. package/dist/utils/interoperable-resource-operation.d.ts +4 -4
  29. package/dist/utils/interoperable-resource-operation.js +22 -22
  30. package/dist/utils/jwk-thumbprint.d.ts +40 -0
  31. package/dist/utils/jwk-thumbprint.js +57 -0
  32. package/dist/utils/legal-organization-onboarding.d.ts +97 -0
  33. package/dist/utils/legal-organization-onboarding.js +128 -0
  34. package/dist/utils/license-commercial-search.d.ts +6 -6
  35. package/dist/utils/license-commercial-search.js +2 -2
  36. package/dist/utils/license-list-search.d.ts +7 -7
  37. package/dist/utils/license-list-search.js +23 -23
  38. package/dist/utils/license-offer-order.d.ts +19 -19
  39. package/dist/utils/license-offer-order.js +68 -68
  40. package/dist/utils/organization-lifecycle.d.ts +59 -0
  41. package/dist/utils/organization-lifecycle.js +155 -0
  42. package/package.json +2 -2
@@ -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';
@@ -47,7 +47,7 @@ export type IndividualOrganizationLifecyclePayload = Readonly<{
47
47
  data: IndividualOrganizationLifecycleDataEntry[];
48
48
  };
49
49
  }>;
50
- export type IndividualOrganizationLifecycleDraftState = Readonly<{
50
+ export type IndividualOrganizationLifecycleEditorState = Readonly<{
51
51
  operation: IndividualOrganizationLifecycleOperation;
52
52
  claims: IndividualOrganizationLifecycleClaims;
53
53
  resourceId?: string;
@@ -76,7 +76,7 @@ export declare function buildCurrentIndividualOrganizationLifecycleDataEntry(inp
76
76
  */
77
77
  export declare function buildCurrentIndividualOrganizationLifecyclePayload(input: IndividualOrganizationLifecyclePayloadInput): IndividualOrganizationLifecyclePayload;
78
78
  /**
79
- * High-level chainable draft for hosted individual/family lifecycle work.
79
+ * High-level chainable editor for hosted individual/family lifecycle work.
80
80
  *
81
81
  * Teaching goal:
82
82
  * - authors one canonical flat `org.schema.Organization.*` claim set
@@ -84,11 +84,12 @@ export declare function buildCurrentIndividualOrganizationLifecyclePayload(input
84
84
  * - can emit either a semantic lifecycle message or the current GW CORE
85
85
  * payload shape used by `sdk-node`
86
86
  */
87
- export declare class IndividualOrganizationLifecycleDraft {
87
+ export declare class IndividualOrganizationLifecycleEditor {
88
88
  private draft;
89
- constructor(initial?: Partial<IndividualOrganizationLifecycleDraftState>);
89
+ constructor(initial?: Partial<IndividualOrganizationLifecycleEditorState>);
90
90
  mergeClaims(claims: IndividualOrganizationLifecycleClaims): this;
91
91
  setClaims(claims: IndividualOrganizationLifecycleClaims): this;
92
+ setContext(context: string): this;
92
93
  setIdentifier(identifier: string): this;
93
94
  setAlternateName(alternateName: string): this;
94
95
  setOwnerEmail(email: string): this;
@@ -96,8 +97,17 @@ export declare class IndividualOrganizationLifecycleDraft {
96
97
  setResourceId(resourceId?: string): this;
97
98
  setRequestType(requestType: string): this;
98
99
  setThreadId(thid: string): this;
100
+ getIdentifier(): string | undefined;
101
+ getContext(): string | undefined;
102
+ getAlternateName(): string | undefined;
103
+ getOwnerEmail(): string | undefined;
104
+ getOperation(): IndividualOrganizationLifecycleOperation;
105
+ getResourceId(): string | undefined;
106
+ getRequestType(): string | undefined;
107
+ getThreadId(): string | undefined;
99
108
  getClaims(): IndividualOrganizationLifecycleClaims;
100
- getDraft(): IndividualOrganizationLifecycleDraftState;
109
+ getState(): IndividualOrganizationLifecycleEditorState;
110
+ getEditorState(): IndividualOrganizationLifecycleEditorState;
101
111
  toSemanticMessage(): IndividualOrganizationLifecycleSemanticMessage;
102
112
  buildCurrentGwDataEntry(): IndividualOrganizationLifecycleDataEntry;
103
113
  buildCurrentGwPayload(): IndividualOrganizationLifecyclePayload;
@@ -17,7 +17,10 @@ function normalizeText(value) {
17
17
  function normalizeDraft(draft) {
18
18
  return {
19
19
  operation: draft?.operation || IndividualOrganizationLifecycleOperations.Disable,
20
- claims: cloneClaims(draft?.claims),
20
+ claims: {
21
+ '@context': 'org.schema',
22
+ ...cloneClaims(draft?.claims),
23
+ },
21
24
  resourceId: normalizeText(draft?.resourceId),
22
25
  requestType: normalizeText(draft?.requestType),
23
26
  thid: normalizeText(draft?.thid),
@@ -75,7 +78,7 @@ export function buildCurrentIndividualOrganizationLifecyclePayload(input) {
75
78
  };
76
79
  }
77
80
  /**
78
- * High-level chainable draft for hosted individual/family lifecycle work.
81
+ * High-level chainable editor for hosted individual/family lifecycle work.
79
82
  *
80
83
  * Teaching goal:
81
84
  * - authors one canonical flat `org.schema.Organization.*` claim set
@@ -83,7 +86,7 @@ export function buildCurrentIndividualOrganizationLifecyclePayload(input) {
83
86
  * - can emit either a semantic lifecycle message or the current GW CORE
84
87
  * payload shape used by `sdk-node`
85
88
  */
86
- export class IndividualOrganizationLifecycleDraft {
89
+ export class IndividualOrganizationLifecycleEditor {
87
90
  draft;
88
91
  constructor(initial) {
89
92
  this.draft = normalizeDraft(initial);
@@ -96,6 +99,15 @@ export class IndividualOrganizationLifecycleDraft {
96
99
  this.draft = patchDraft(this.draft, { claims });
97
100
  return this;
98
101
  }
102
+ setContext(context) {
103
+ this.draft = patchDraft(this.draft, {
104
+ claims: {
105
+ ...this.draft.claims,
106
+ '@context': String(context).trim(),
107
+ },
108
+ });
109
+ return this;
110
+ }
99
111
  setIdentifier(identifier) {
100
112
  this.draft = patchDraft(this.draft, {
101
113
  claims: {
@@ -139,12 +151,47 @@ export class IndividualOrganizationLifecycleDraft {
139
151
  this.draft = patchDraft(this.draft, { thid });
140
152
  return this;
141
153
  }
154
+ getIdentifier() {
155
+ const value = this.draft.claims[ClaimsOrganizationSchemaorg.identifier];
156
+ const normalized = normalizeText(value);
157
+ return normalized || undefined;
158
+ }
159
+ getContext() {
160
+ const value = this.draft.claims['@context'];
161
+ const normalized = normalizeText(value);
162
+ return normalized || undefined;
163
+ }
164
+ getAlternateName() {
165
+ const value = this.draft.claims[ClaimsOrganizationSchemaorg.alternateName];
166
+ const normalized = normalizeText(value);
167
+ return normalized || undefined;
168
+ }
169
+ getOwnerEmail() {
170
+ const value = this.draft.claims[ClaimsOrganizationSchemaorg.ownerEmail];
171
+ const normalized = normalizeText(value);
172
+ return normalized || undefined;
173
+ }
174
+ getOperation() {
175
+ return this.draft.operation;
176
+ }
177
+ getResourceId() {
178
+ return normalizeText(this.draft.resourceId) || undefined;
179
+ }
180
+ getRequestType() {
181
+ return normalizeText(this.draft.requestType) || undefined;
182
+ }
183
+ getThreadId() {
184
+ return normalizeText(this.draft.thid) || undefined;
185
+ }
142
186
  getClaims() {
143
187
  return cloneClaims(this.draft.claims);
144
188
  }
145
- getDraft() {
189
+ getState() {
146
190
  return normalizeDraft(this.draft);
147
191
  }
192
+ getEditorState() {
193
+ return this.getState();
194
+ }
148
195
  toSemanticMessage() {
149
196
  return {
150
197
  operation: this.draft.operation,
@@ -156,7 +203,7 @@ export class IndividualOrganizationLifecycleDraft {
156
203
  buildCurrentGwDataEntry() {
157
204
  const requestType = normalizeText(this.draft.requestType);
158
205
  if (!requestType) {
159
- throw new Error('IndividualOrganizationLifecycleDraft.buildCurrentGwDataEntry requires requestType.');
206
+ throw new Error('IndividualOrganizationLifecycleEditor.buildCurrentGwDataEntry requires requestType.');
160
207
  }
161
208
  return buildCurrentIndividualOrganizationLifecycleDataEntry({
162
209
  claims: this.getClaims(),
@@ -167,7 +214,7 @@ export class IndividualOrganizationLifecycleDraft {
167
214
  buildCurrentGwPayload() {
168
215
  const requestType = normalizeText(this.draft.requestType);
169
216
  if (!requestType) {
170
- throw new Error('IndividualOrganizationLifecycleDraft.buildCurrentGwPayload requires requestType.');
217
+ throw new Error('IndividualOrganizationLifecycleEditor.buildCurrentGwPayload requires requestType.');
171
218
  }
172
219
  return {
173
220
  thid: this.draft.thid || createLifecycleThreadId(this.draft.operation),