gdc-sdk-node-ts 2.2.2 → 2.3.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.
Files changed (42) hide show
  1. package/dist/backend-profile-runtime.d.ts +23 -0
  2. package/dist/backend-profile-runtime.js +23 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +2 -0
  5. package/dist/node-runtime-client.d.ts +39 -4
  6. package/dist/node-runtime-client.js +124 -4
  7. package/dist/orchestration/client-port.d.ts +4 -1
  8. package/dist/orchestration/individual-controller-sdk.d.ts +10 -1
  9. package/dist/orchestration/individual-controller-sdk.js +15 -0
  10. package/dist/orchestration/individual-member-sdk.d.ts +10 -1
  11. package/dist/orchestration/individual-member-sdk.js +15 -0
  12. package/dist/resource-operations.d.ts +111 -4
  13. package/dist/resource-operations.js +83 -3
  14. package/dist/runtime-client-paths.d.ts +6 -2
  15. package/dist/runtime-client-paths.js +4 -0
  16. package/dist/runtime-transport.d.ts +13 -1
  17. package/dist/runtime-transport.js +18 -3
  18. package/dist/server-profile-protection.d.ts +64 -0
  19. package/dist/server-profile-protection.js +110 -0
  20. package/dist/server-profile-session.d.ts +115 -0
  21. package/dist/server-profile-session.js +259 -0
  22. package/dist/session.d.ts +7 -0
  23. package/dist/session.js +10 -0
  24. package/package.json +3 -3
  25. package/dist/legal-organization-onboarding-facade.d.ts +0 -70
  26. package/dist/legal-organization-onboarding-facade.js +0 -169
  27. package/dist/lifecycle-examples.d.ts +0 -7
  28. package/dist/lifecycle-examples.js +0 -8
  29. package/dist/runtime-software-proof.d.ts +0 -51
  30. package/dist/runtime-software-proof.js +0 -34
  31. package/dist/simple-device-activation.d.ts +0 -44
  32. package/dist/simple-device-activation.js +0 -44
  33. package/dist/simple-host-onboarding.d.ts +0 -27
  34. package/dist/simple-host-onboarding.js +0 -39
  35. package/dist/simple-individual-onboarding.d.ts +0 -27
  36. package/dist/simple-individual-onboarding.js +0 -38
  37. package/dist/simple-individual-start.d.ts +0 -45
  38. package/dist/simple-individual-start.js +0 -59
  39. package/dist/simple-poll-options.d.ts +0 -5
  40. package/dist/simple-poll-options.js +0 -17
  41. package/dist/simple-smart-token.d.ts +0 -58
  42. package/dist/simple-smart-token.js +0 -85
@@ -1,169 +0,0 @@
1
- // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- import { ClaimsOrganizationSchemaorg, ClaimsPersonSchemaorg, ClaimsServiceSchemaorg, } from 'gdc-common-utils-ts/constants/schemaorg';
3
- import { ServiceCapability } from 'gdc-common-utils-ts/constants/service-capabilities';
4
- import { validateLegalOrganizationOnboardingClaims, } from 'gdc-common-utils-ts/utils/legal-organization-onboarding';
5
- function normalizeText(value) {
6
- return typeof value === 'string' ? value.trim() : '';
7
- }
8
- function normalizeOptionalText(value) {
9
- const normalized = normalizeText(value);
10
- return normalized || undefined;
11
- }
12
- function cloneFields(fields) {
13
- return { ...(fields || {}) };
14
- }
15
- function patchFields(fields, patch) {
16
- return {
17
- ...cloneFields(fields),
18
- ...patch,
19
- };
20
- }
21
- function createIssues(fields) {
22
- const issues = [];
23
- if (!normalizeOptionalText(fields.legalName)) {
24
- issues.push({ severity: 'error', code: 'missing-legal-name', message: 'Legal organization name is required.', field: 'legalName' });
25
- }
26
- if (!normalizeOptionalText(fields.legalIdentifierType)) {
27
- issues.push({ severity: 'error', code: 'missing-legal-identifier-type', message: 'Legal identifier type is required.', field: 'legalIdentifierType' });
28
- }
29
- if (!normalizeOptionalText(fields.addressCountry)) {
30
- issues.push({ severity: 'error', code: 'missing-address-country', message: 'Address country is required.', field: 'addressCountry' });
31
- }
32
- if (!normalizeOptionalText(fields.controllerEmail)) {
33
- issues.push({ severity: 'error', code: 'missing-controller-email', message: 'Controller email is required.', field: 'controllerEmail' });
34
- }
35
- if (!normalizeOptionalText(fields.serviceCategory)) {
36
- issues.push({ severity: 'error', code: 'missing-service-category', message: 'Service category is required.', field: 'serviceCategory' });
37
- }
38
- return issues;
39
- }
40
- function createEditorFromFacade(facade, initial) {
41
- let formFields = facade.createDraft(initial);
42
- const editor = {
43
- setLegalName(value) { formFields = facade.setLegalName(formFields, value); return editor; },
44
- setLegalIdentifierType(value) { formFields = facade.setLegalIdentifierType(formFields, value); return editor; },
45
- setLegalIdentifierValue(value) { formFields = facade.setLegalIdentifierValue(formFields, value); return editor; },
46
- setTaxId(value) { formFields = facade.setTaxId(formFields, value); return editor; },
47
- setAddressCountry(value) { formFields = facade.setAddressCountry(formFields, value); return editor; },
48
- setControllerEmail(value) { formFields = facade.setControllerEmail(formFields, value); return editor; },
49
- setControllerRole(value) { formFields = facade.setControllerRole(formFields, value); return editor; },
50
- setServiceCategory(value) { formFields = facade.setServiceCategory(formFields, value); return editor; },
51
- setServiceIdentifier(value) { formFields = facade.setServiceIdentifier(formFields, value); return editor; },
52
- setServiceUrl(value) { formFields = facade.setServiceUrl(formFields, value); return editor; },
53
- getFormFields() { return cloneFields(formFields); },
54
- buildClaims() { return facade.buildClaims(formFields); },
55
- validate() { return facade.validate(formFields); },
56
- buildVerificationTransactionInput(input) {
57
- return {
58
- claims: facade.buildClaims(formFields),
59
- controller: input.controller,
60
- ...(input.organization ? { organization: input.organization } : {}),
61
- ...(input.legalRepresentativePayload ? { legalRepresentativePayload: input.legalRepresentativePayload } : {}),
62
- ...(input.verification ? { verification: input.verification } : {}),
63
- ...(input.attachments ? { attachments: input.attachments } : {}),
64
- };
65
- },
66
- buildActivationInput(input) {
67
- const claims = facade.buildClaims(formFields);
68
- const service = {
69
- url: String(claims[ClaimsServiceSchemaorg.url] || '').trim() || undefined,
70
- capabilities: [...new Set((input.capabilities || [ServiceCapability.IndexProvider, ServiceCapability.DigitalTwinReader])
71
- .map((item) => String(item || '').trim())
72
- .filter(Boolean))],
73
- };
74
- return {
75
- vpToken: input.vpToken,
76
- controller: input.controller,
77
- service,
78
- additionalClaims: claims,
79
- };
80
- },
81
- };
82
- return editor;
83
- }
84
- export function createLegalOrganizationOnboardingFacade() {
85
- return {
86
- createDraft(initial = {}) {
87
- return cloneFields(initial);
88
- },
89
- createEditor(initial = {}) {
90
- return createEditorFromFacade(this, initial);
91
- },
92
- setLegalName(fields, value) {
93
- return patchFields(fields, { legalName: normalizeOptionalText(value) });
94
- },
95
- setLegalIdentifierType(fields, value) {
96
- return patchFields(fields, { legalIdentifierType: normalizeOptionalText(value) });
97
- },
98
- setLegalIdentifierValue(fields, value) {
99
- return patchFields(fields, { legalIdentifierValue: normalizeOptionalText(value) });
100
- },
101
- setTaxId(fields, value) {
102
- return patchFields(fields, { taxId: normalizeOptionalText(value) });
103
- },
104
- setAddressCountry(fields, value) {
105
- return patchFields(fields, { addressCountry: normalizeOptionalText(value) });
106
- },
107
- setControllerEmail(fields, value) {
108
- const normalized = normalizeOptionalText(value);
109
- return patchFields(fields, { controllerEmail: normalized?.toLowerCase() });
110
- },
111
- setControllerRole(fields, value) {
112
- return patchFields(fields, { controllerRole: normalizeOptionalText(value) });
113
- },
114
- setServiceCategory(fields, value) {
115
- return patchFields(fields, { serviceCategory: normalizeOptionalText(value) });
116
- },
117
- setServiceIdentifier(fields, value) {
118
- return patchFields(fields, { serviceIdentifier: normalizeOptionalText(value) });
119
- },
120
- setServiceUrl(fields, value) {
121
- return patchFields(fields, { serviceUrl: normalizeOptionalText(value) });
122
- },
123
- buildClaims(fields) {
124
- const claims = {
125
- '@context': 'org.schema',
126
- };
127
- if (normalizeOptionalText(fields.legalName))
128
- claims[ClaimsOrganizationSchemaorg.legalName] = normalizeText(fields.legalName);
129
- if (normalizeOptionalText(fields.legalIdentifierType))
130
- claims[ClaimsOrganizationSchemaorg.identifierType] = normalizeText(fields.legalIdentifierType);
131
- if (normalizeOptionalText(fields.legalIdentifierValue))
132
- claims[ClaimsOrganizationSchemaorg.identifierValue] = normalizeText(fields.legalIdentifierValue);
133
- if (normalizeOptionalText(fields.taxId))
134
- claims[ClaimsOrganizationSchemaorg.taxId] = normalizeText(fields.taxId);
135
- if (normalizeOptionalText(fields.addressCountry))
136
- claims[ClaimsOrganizationSchemaorg.addressCountry] = normalizeText(fields.addressCountry);
137
- if (normalizeOptionalText(fields.controllerEmail))
138
- claims[ClaimsPersonSchemaorg.email] = normalizeText(fields.controllerEmail).toLowerCase();
139
- if (normalizeOptionalText(fields.controllerRole))
140
- claims[ClaimsPersonSchemaorg.hasOccupationalRoleValue] = normalizeText(fields.controllerRole);
141
- if (normalizeOptionalText(fields.serviceCategory))
142
- claims[ClaimsServiceSchemaorg.category] = normalizeText(fields.serviceCategory);
143
- if (normalizeOptionalText(fields.serviceIdentifier))
144
- claims[ClaimsServiceSchemaorg.identifier] = normalizeText(fields.serviceIdentifier);
145
- if (normalizeOptionalText(fields.serviceUrl))
146
- claims[ClaimsServiceSchemaorg.url] = normalizeText(fields.serviceUrl);
147
- return validateLegalOrganizationOnboardingClaims(claims).normalizedClaims;
148
- },
149
- validate(fields) {
150
- const normalizedClaims = this.buildClaims(fields);
151
- const issues = createIssues(fields);
152
- const sharedValidation = validateLegalOrganizationOnboardingClaims(normalizedClaims);
153
- for (const error of sharedValidation.errors) {
154
- issues.push({
155
- severity: 'error',
156
- code: error.code.toLowerCase(),
157
- message: error.message,
158
- field: error.claimPaths[0] || 'claims',
159
- });
160
- }
161
- return {
162
- ok: !issues.some((issue) => issue.severity === 'error'),
163
- errors: issues.filter((issue) => issue.severity === 'error'),
164
- warnings: issues.filter((issue) => issue.severity === 'warning'),
165
- normalizedClaims,
166
- };
167
- },
168
- };
169
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Re-export canonical lifecycle examples for Node runtime consumers.
3
- *
4
- * The Node SDK must not hardcode its own copies of lifecycle payload examples.
5
- * Import and reuse the shared `gdc-common-utils-ts` source instead.
6
- */
7
- export * from 'gdc-common-utils-ts/examples/lifecycle';
@@ -1,8 +0,0 @@
1
- // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- /**
3
- * Re-export canonical lifecycle examples for Node runtime consumers.
4
- *
5
- * The Node SDK must not hardcode its own copies of lifecycle payload examples.
6
- * Import and reuse the shared `gdc-common-utils-ts` source instead.
7
- */
8
- export * from 'gdc-common-utils-ts/examples/lifecycle';
@@ -1,51 +0,0 @@
1
- import type { NodeSdkCommunicationIdentityBootstrapResult } from './identity-bootstrap.js';
2
- export type SoftwareRuntimeCredentialInput = {
3
- /**
4
- * Public DID of the portal/backend/software runtime profile.
5
- */
6
- softwareDid: string;
7
- /**
8
- * Technical communication identity previously created with
9
- * `initializeCommunicationIdentity(...)`.
10
- */
11
- deviceIdentity: NodeSdkCommunicationIdentityBootstrapResult;
12
- /**
13
- * Optional VC identifier.
14
- */
15
- credentialId?: string;
16
- /**
17
- * Optional ICA issuer DID placeholder for examples/tests.
18
- */
19
- issuerDid?: string;
20
- /**
21
- * Optional human-readable software/application name.
22
- */
23
- softwareName?: string;
24
- /**
25
- * Optional issuance timestamp.
26
- */
27
- issuanceDate?: string;
28
- /**
29
- * Optional extra `credentialSubject` claims for profile-specific examples.
30
- */
31
- additionalCredentialSubject?: Record<string, unknown>;
32
- };
33
- export type SoftwareRuntimeCredential = {
34
- '@context': string[];
35
- type: string[];
36
- id?: string;
37
- issuer?: string;
38
- issuanceDate?: string;
39
- credentialSubject: Record<string, unknown>;
40
- };
41
- /**
42
- * Builds a copy/paste-friendly VC example for an ICA-authorized software or
43
- * runtime profile. The key binding is taken from the technical communication
44
- * signing key generated by `initializeCommunicationIdentity(...)`.
45
- *
46
- * This helper is intentionally example-oriented. It wires the runtime
47
- * communication `kid` into `credentialSubject.material` so SDK docs and tests
48
- * can express the intended future ICA contract without hand-shaping the object
49
- * inline every time.
50
- */
51
- export declare function buildSoftwareRuntimeCredential(input: SoftwareRuntimeCredentialInput): SoftwareRuntimeCredential;
@@ -1,34 +0,0 @@
1
- // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- /**
3
- * Builds a copy/paste-friendly VC example for an ICA-authorized software or
4
- * runtime profile. The key binding is taken from the technical communication
5
- * signing key generated by `initializeCommunicationIdentity(...)`.
6
- *
7
- * This helper is intentionally example-oriented. It wires the runtime
8
- * communication `kid` into `credentialSubject.material` so SDK docs and tests
9
- * can express the intended future ICA contract without hand-shaping the object
10
- * inline every time.
11
- */
12
- export function buildSoftwareRuntimeCredential(input) {
13
- const communicationKid = String(input.deviceIdentity.commSigningKeyPair.publicJWKey.kid || '').trim();
14
- if (!communicationKid) {
15
- throw new Error('buildSoftwareRuntimeCredential requires deviceIdentity.commSigningKeyPair.publicJWKey.kid.');
16
- }
17
- const softwareDid = String(input.softwareDid || '').trim();
18
- if (!softwareDid) {
19
- throw new Error('buildSoftwareRuntimeCredential requires softwareDid.');
20
- }
21
- return {
22
- '@context': ['https://www.w3.org/2018/credentials/v1', 'https://schema.org'],
23
- type: ['VerifiableCredential', 'SoftwareApplicationCredential'],
24
- ...(input.credentialId ? { id: input.credentialId } : {}),
25
- ...(input.issuerDid ? { issuer: input.issuerDid } : {}),
26
- ...(input.issuanceDate ? { issuanceDate: input.issuanceDate } : {}),
27
- credentialSubject: {
28
- id: softwareDid,
29
- material: communicationKid,
30
- ...(input.softwareName ? { name: input.softwareName } : {}),
31
- ...(input.additionalCredentialSubject || {}),
32
- },
33
- };
34
- }
@@ -1,44 +0,0 @@
1
- import type { PollOptions, SubmitAndPollResult } from './orchestration/client-port.js';
2
- import type { RouteContext } from './simple-individual-onboarding.js';
3
- export type EmployeeDeviceActivationInput = {
4
- activationCode: string;
5
- idToken: string;
6
- dcrPayload: Record<string, unknown>;
7
- pollOptions?: PollOptions;
8
- };
9
- export type EmployeeDeviceActivationRequestInput = {
10
- tenantId?: string;
11
- jurisdiction?: string;
12
- sector?: string;
13
- activationCode: string;
14
- idToken: string;
15
- dcrPayload: Record<string, unknown>;
16
- timeoutSeconds?: number;
17
- intervalSeconds?: number;
18
- };
19
- export type EmployeeDeviceActivationResult = {
20
- initialAccessToken: string;
21
- exchange: SubmitAndPollResult;
22
- dcr: SubmitAndPollResult;
23
- };
24
- type ActivateEmployeeDeviceDeps = {
25
- routeCtx: RouteContext;
26
- input: EmployeeDeviceActivationInput;
27
- identityTokenExchangePath: (ctx: RouteContext) => string;
28
- identityTokenExchangePollPath: (ctx: RouteContext) => string;
29
- identityDeviceDcrPath: (ctx: RouteContext) => string;
30
- identityDeviceDcrPollPath: (ctx: RouteContext) => string;
31
- submitAndPollWithBearerToken: (bearerToken: string | undefined, submitPath: string, pollPath: string, payload: {
32
- thid?: string;
33
- } & Record<string, unknown>, pollOptions?: PollOptions) => Promise<SubmitAndPollResult>;
34
- };
35
- type ActivateEmployeeDeviceRequestDeps = {
36
- routeCtx: RouteContext;
37
- input: EmployeeDeviceActivationRequestInput;
38
- defaultTimeoutMs?: number;
39
- defaultIntervalMs?: number;
40
- activateEmployeeDeviceWithActivationCode: (routeCtx: RouteContext, input: EmployeeDeviceActivationInput) => Promise<EmployeeDeviceActivationResult>;
41
- };
42
- export declare function activateEmployeeDeviceWithActivationCodeWithDeps(deps: ActivateEmployeeDeviceDeps): Promise<EmployeeDeviceActivationResult>;
43
- export declare function activateEmployeeDeviceWithActivationRequestWithDeps(deps: ActivateEmployeeDeviceRequestDeps): Promise<EmployeeDeviceActivationResult>;
44
- export {};
@@ -1,44 +0,0 @@
1
- // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- import { resolvePollOptionsFromSeconds } from './simple-poll-options.js';
3
- export async function activateEmployeeDeviceWithActivationCodeWithDeps(deps) {
4
- const exchangePayload = {
5
- thid: `exchange-${createRuntimeUuid()}`,
6
- subject_token: deps.input.activationCode,
7
- };
8
- const exchange = await deps.submitAndPollWithBearerToken(deps.input.idToken, deps.identityTokenExchangePath(deps.routeCtx), deps.identityTokenExchangePollPath(deps.routeCtx), exchangePayload, deps.input.pollOptions);
9
- const pollBody = exchange.poll.body || {};
10
- const exchangeBody = (pollBody.body || pollBody);
11
- const initialAccessToken = String(exchangeBody.initial_access_token || exchangeBody.access_token || '').trim();
12
- if (!initialAccessToken) {
13
- throw new Error('activateEmployeeDeviceWithActivationCode: missing initial_access_token in exchange response.');
14
- }
15
- const dcrPayload = {
16
- thid: `dcr-${createRuntimeUuid()}`,
17
- ...deps.input.dcrPayload,
18
- };
19
- const dcr = await deps.submitAndPollWithBearerToken(initialAccessToken, deps.identityDeviceDcrPath(deps.routeCtx), deps.identityDeviceDcrPollPath(deps.routeCtx), dcrPayload, deps.input.pollOptions);
20
- return {
21
- initialAccessToken,
22
- exchange,
23
- dcr,
24
- };
25
- }
26
- export async function activateEmployeeDeviceWithActivationRequestWithDeps(deps) {
27
- const pollOptions = resolvePollOptionsFromSeconds(deps.input.timeoutSeconds, deps.input.intervalSeconds, {
28
- timeoutMs: deps.defaultTimeoutMs,
29
- intervalMs: deps.defaultIntervalMs,
30
- });
31
- return deps.activateEmployeeDeviceWithActivationCode(deps.routeCtx, {
32
- activationCode: deps.input.activationCode,
33
- idToken: deps.input.idToken,
34
- dcrPayload: deps.input.dcrPayload,
35
- pollOptions,
36
- });
37
- }
38
- function createRuntimeUuid() {
39
- const fromCrypto = globalThis.crypto?.randomUUID?.();
40
- if (fromCrypto) {
41
- return fromCrypto;
42
- }
43
- return `fallback-${Date.now()}-${Math.random().toString(16).slice(2)}`;
44
- }
@@ -1,27 +0,0 @@
1
- import type { PollOptions, SubmitAndPollResult } from './orchestration/client-port.js';
2
- export type HostRouteContext = {
3
- jurisdiction: string;
4
- sector: string;
5
- };
6
- export type LegalOrganizationOrderInput = {
7
- offerId: string;
8
- jurisdiction?: string;
9
- sector?: string;
10
- dataType?: string;
11
- additionalClaims?: Record<string, unknown>;
12
- timeoutSeconds?: number;
13
- intervalSeconds?: number;
14
- };
15
- type ConfirmLegalOrganizationOrderDeps = {
16
- input: LegalOrganizationOrderInput;
17
- hostCtx: HostRouteContext;
18
- defaultTimeoutMs?: number;
19
- defaultIntervalMs?: number;
20
- hostRegistryOrderBatchPath: (ctx: HostRouteContext) => string;
21
- hostRegistryOrderPollPath: (ctx: HostRouteContext) => string;
22
- submitAndPoll: (submitPath: string, pollPath: string, payload: {
23
- thid?: string;
24
- } & Record<string, unknown>, options?: PollOptions) => Promise<SubmitAndPollResult>;
25
- };
26
- export declare function confirmLegalOrganizationOrderWithDeps(deps: ConfirmLegalOrganizationOrderDeps): Promise<SubmitAndPollResult>;
27
- export {};
@@ -1,39 +0,0 @@
1
- // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- import { resolvePollOptionsFromSeconds } from './simple-poll-options.js';
3
- export async function confirmLegalOrganizationOrderWithDeps(deps) {
4
- const offerId = String(deps.input.offerId || '').trim();
5
- if (!offerId) {
6
- throw new Error('confirmLegalOrganizationOrder requires offerId.');
7
- }
8
- const claims = {
9
- '@context': 'org.schema',
10
- 'Order.acceptedOffer.identifier': offerId,
11
- ...(deps.input.additionalClaims || {}),
12
- };
13
- const payload = {
14
- jti: `jti-${createRuntimeUuid()}`,
15
- iss: 'did:web:controller.example.com',
16
- aud: 'did:web:host.example.com',
17
- type: 'application/didcomm-plain+json',
18
- thid: `order-${createRuntimeUuid()}`,
19
- body: {
20
- data: [{
21
- type: deps.input.dataType || 'Organization-order-request-v1.0',
22
- meta: { claims },
23
- resource: { meta: { claims } },
24
- }],
25
- },
26
- };
27
- const pollOptions = resolvePollOptionsFromSeconds(deps.input.timeoutSeconds, deps.input.intervalSeconds, {
28
- timeoutMs: deps.defaultTimeoutMs,
29
- intervalMs: deps.defaultIntervalMs,
30
- });
31
- return deps.submitAndPoll(deps.hostRegistryOrderBatchPath(deps.hostCtx), deps.hostRegistryOrderPollPath(deps.hostCtx), payload, pollOptions);
32
- }
33
- function createRuntimeUuid() {
34
- const fromCrypto = globalThis.crypto?.randomUUID?.();
35
- if (fromCrypto) {
36
- return fromCrypto;
37
- }
38
- return `fallback-${Date.now()}-${Math.random().toString(16).slice(2)}`;
39
- }
@@ -1,27 +0,0 @@
1
- import type { PollOptions, SubmitAndPollResult } from './orchestration/client-port.js';
2
- export type RouteContext = {
3
- tenantId: string;
4
- jurisdiction: string;
5
- sector: string;
6
- };
7
- export type IndividualOrganizationConfirmOrderInput = {
8
- tenantId?: string;
9
- jurisdiction?: string;
10
- sector?: string;
11
- offerId: string;
12
- timeoutSeconds?: number;
13
- intervalSeconds?: number;
14
- };
15
- type ConfirmIndividualOrganizationOrderDeps = {
16
- input: IndividualOrganizationConfirmOrderInput;
17
- routeCtx: RouteContext;
18
- defaultTimeoutMs?: number;
19
- defaultIntervalMs?: number;
20
- individualFamilyOrderBatchPath: (ctx: RouteContext) => string;
21
- individualFamilyOrderPollPath: (ctx: RouteContext) => string;
22
- submitAndPoll: (submitPath: string, pollPath: string, payload: {
23
- thid?: string;
24
- } & Record<string, unknown>, options?: PollOptions) => Promise<SubmitAndPollResult>;
25
- };
26
- export declare function confirmIndividualOrganizationOrderWithDeps(deps: ConfirmIndividualOrganizationOrderDeps): Promise<SubmitAndPollResult>;
27
- export {};
@@ -1,38 +0,0 @@
1
- // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- import { resolvePollOptionsFromSeconds } from './simple-poll-options.js';
3
- export async function confirmIndividualOrganizationOrderWithDeps(deps) {
4
- const offerId = String(deps.input.offerId || '').trim();
5
- if (!offerId) {
6
- throw new Error('confirmIndividualOrganizationOrder requires offerId.');
7
- }
8
- const orderClaims = {
9
- '@context': 'org.schema',
10
- 'Order.acceptedOffer.identifier': offerId,
11
- };
12
- const payload = {
13
- jti: `jti-${createRuntimeUuid()}`,
14
- iss: deps.routeCtx.tenantId,
15
- aud: deps.routeCtx.tenantId,
16
- type: 'application/didcomm-plain+json',
17
- thid: `family-order-${createRuntimeUuid()}`,
18
- body: {
19
- data: [{
20
- type: 'Family-order-request-v1.0',
21
- meta: { claims: orderClaims },
22
- resource: { meta: { claims: orderClaims } },
23
- }],
24
- },
25
- };
26
- const pollOptions = resolvePollOptionsFromSeconds(deps.input.timeoutSeconds, deps.input.intervalSeconds, {
27
- timeoutMs: deps.defaultTimeoutMs,
28
- intervalMs: deps.defaultIntervalMs,
29
- });
30
- return deps.submitAndPoll(deps.individualFamilyOrderBatchPath(deps.routeCtx), deps.individualFamilyOrderPollPath(deps.routeCtx), payload, pollOptions);
31
- }
32
- function createRuntimeUuid() {
33
- const fromCrypto = globalThis.crypto?.randomUUID?.();
34
- if (fromCrypto) {
35
- return fromCrypto;
36
- }
37
- return `fallback-${Date.now()}-${Math.random().toString(16).slice(2)}`;
38
- }
@@ -1,45 +0,0 @@
1
- import type { PollOptions, SubmitAndPollResult } from './orchestration/client-port.js';
2
- import type { RouteContext } from './simple-individual-onboarding.js';
3
- export type IndividualOrganizationBootstrapInput = {
4
- tenantId?: string;
5
- jurisdiction?: string;
6
- sector?: string;
7
- alternateName: string;
8
- controllerEmail?: string;
9
- controllerTelephone?: string;
10
- controllerRole?: string;
11
- additionalClaims?: Record<string, unknown>;
12
- timeoutSeconds?: number;
13
- intervalSeconds?: number;
14
- };
15
- export type OfferPreview = {
16
- offerId?: string;
17
- amount?: string;
18
- currency?: string;
19
- seats?: number | undefined;
20
- planName?: string;
21
- sku?: string;
22
- paymentMethod?: string;
23
- checkoutUrl?: string;
24
- };
25
- export type IndividualOrganizationStartResult = {
26
- registration: SubmitAndPollResult;
27
- offerId: string;
28
- offerPreview: OfferPreview;
29
- };
30
- type StartIndividualOrganizationDeps = {
31
- input: IndividualOrganizationBootstrapInput;
32
- routeCtx: RouteContext;
33
- defaultTimeoutMs?: number;
34
- defaultIntervalMs?: number;
35
- individualFamilyOrganizationBatchPath: (ctx: RouteContext) => string;
36
- individualFamilyOrganizationPollPath: (ctx: RouteContext) => string;
37
- submitAndPoll: (submitPath: string, pollPath: string, payload: {
38
- thid?: string;
39
- } & Record<string, unknown>, options?: PollOptions) => Promise<SubmitAndPollResult>;
40
- assertFirstDidcommEntrySuccess?: (result: SubmitAndPollResult, contextLabel: string) => void;
41
- getOfferIdFromResponse: (result: SubmitAndPollResult) => string | undefined;
42
- getOfferPreviewFromResponse: (result: SubmitAndPollResult) => OfferPreview;
43
- };
44
- export declare function startIndividualOrganizationWithDeps(deps: StartIndividualOrganizationDeps): Promise<IndividualOrganizationStartResult>;
45
- export {};
@@ -1,59 +0,0 @@
1
- // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- import { resolvePollOptionsFromSeconds } from './simple-poll-options.js';
3
- export async function startIndividualOrganizationWithDeps(deps) {
4
- const alternateName = String(deps.input.alternateName || '').trim();
5
- if (!alternateName) {
6
- throw new Error('bootstrapIndividualOrganization requires alternateName.');
7
- }
8
- const controllerEmail = String(deps.input.controllerEmail || '').trim();
9
- const controllerTelephone = String(deps.input.controllerTelephone || '').trim();
10
- if (!controllerEmail && !controllerTelephone) {
11
- throw new Error('bootstrapIndividualOrganization requires controllerEmail or controllerTelephone.');
12
- }
13
- const controllerRole = String(deps.input.controllerRole || 'RESPRSN').trim();
14
- const claims = {
15
- '@context': 'org.schema',
16
- 'org.schema.Organization.alternateName': alternateName,
17
- 'org.schema.Service.category': deps.routeCtx.sector,
18
- 'org.schema.Person.hasOccupation': controllerRole,
19
- ...(controllerEmail ? { 'org.schema.Person.email': controllerEmail } : {}),
20
- ...(controllerTelephone ? { 'org.schema.Person.telephone': controllerTelephone } : {}),
21
- ...(deps.input.additionalClaims || {}),
22
- };
23
- const registrationPayload = {
24
- jti: `jti-${createRuntimeUuid()}`,
25
- iss: deps.routeCtx.tenantId,
26
- aud: deps.routeCtx.tenantId,
27
- type: 'application/didcomm-plain+json',
28
- thid: `family-org-${createRuntimeUuid()}`,
29
- body: {
30
- data: [{
31
- type: 'SubjectOrg-registration-form-v1.0',
32
- meta: { claims },
33
- resource: { meta: { claims } },
34
- }],
35
- },
36
- };
37
- const pollOptions = resolvePollOptionsFromSeconds(deps.input.timeoutSeconds, deps.input.intervalSeconds, {
38
- timeoutMs: deps.defaultTimeoutMs,
39
- intervalMs: deps.defaultIntervalMs,
40
- });
41
- const registration = await deps.submitAndPoll(deps.individualFamilyOrganizationBatchPath(deps.routeCtx), deps.individualFamilyOrganizationPollPath(deps.routeCtx), registrationPayload, pollOptions);
42
- deps.assertFirstDidcommEntrySuccess?.(registration, 'startIndividualOrganization.registration');
43
- const offerId = deps.getOfferIdFromResponse(registration);
44
- if (!offerId) {
45
- throw new Error('startIndividualOrganization failed: missing offerId in registration response.');
46
- }
47
- return {
48
- registration,
49
- offerId,
50
- offerPreview: deps.getOfferPreviewFromResponse(registration),
51
- };
52
- }
53
- function createRuntimeUuid() {
54
- const fromCrypto = globalThis.crypto?.randomUUID?.();
55
- if (fromCrypto) {
56
- return fromCrypto;
57
- }
58
- return `fallback-${Date.now()}-${Math.random().toString(16).slice(2)}`;
59
- }
@@ -1,5 +0,0 @@
1
- import type { PollOptions } from './orchestration/client-port.js';
2
- export declare function resolvePollOptionsFromSeconds(timeoutSeconds?: number, intervalSeconds?: number, defaults?: {
3
- timeoutMs?: number;
4
- intervalMs?: number;
5
- }): PollOptions | undefined;
@@ -1,17 +0,0 @@
1
- // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- export function resolvePollOptionsFromSeconds(timeoutSeconds, intervalSeconds, defaults) {
3
- const pollOptions = {};
4
- if (Number.isFinite(Number(timeoutSeconds))) {
5
- pollOptions.timeoutMs = Math.max(1, Math.floor(Number(timeoutSeconds) * 1000));
6
- }
7
- else if (defaults?.timeoutMs) {
8
- pollOptions.timeoutMs = defaults.timeoutMs;
9
- }
10
- if (Number.isFinite(Number(intervalSeconds))) {
11
- pollOptions.intervalMs = Math.max(1, Math.floor(Number(intervalSeconds) * 1000));
12
- }
13
- else if (defaults?.intervalMs) {
14
- pollOptions.intervalMs = defaults.intervalMs;
15
- }
16
- return Object.keys(pollOptions).length ? pollOptions : undefined;
17
- }