gdc-sdk-node-ts 0.1.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 (60) hide show
  1. package/README.md +166 -0
  2. package/dist/async-polling.d.ts +7 -0
  3. package/dist/async-polling.js +26 -0
  4. package/dist/device-activation.d.ts +44 -0
  5. package/dist/device-activation.js +44 -0
  6. package/dist/gdc-session-bridge.d.ts +11 -0
  7. package/dist/gdc-session-bridge.js +74 -0
  8. package/dist/host-onboarding.d.ts +38 -0
  9. package/dist/host-onboarding.js +39 -0
  10. package/dist/identity-bootstrap.d.ts +30 -0
  11. package/dist/identity-bootstrap.js +32 -0
  12. package/dist/index.d.ts +23 -0
  13. package/dist/index.js +24 -0
  14. package/dist/individual-onboarding.d.ts +35 -0
  15. package/dist/individual-onboarding.js +38 -0
  16. package/dist/individual-start.d.ts +87 -0
  17. package/dist/individual-start.js +82 -0
  18. package/dist/legacy-compat.d.ts +22 -0
  19. package/dist/legacy-compat.js +18 -0
  20. package/dist/node-runtime-client.d.ts +195 -0
  21. package/dist/node-runtime-client.js +483 -0
  22. package/dist/orchestration/client-port.d.ts +47 -0
  23. package/dist/orchestration/client-port.js +31 -0
  24. package/dist/orchestration/host-onboarding-sdk.d.ts +14 -0
  25. package/dist/orchestration/host-onboarding-sdk.js +15 -0
  26. package/dist/orchestration/individual-controller-sdk.d.ts +54 -0
  27. package/dist/orchestration/individual-controller-sdk.js +70 -0
  28. package/dist/orchestration/individual-member-sdk.d.ts +17 -0
  29. package/dist/orchestration/individual-member-sdk.js +20 -0
  30. package/dist/orchestration/organization-controller-sdk.d.ts +46 -0
  31. package/dist/orchestration/organization-controller-sdk.js +56 -0
  32. package/dist/orchestration/organization-employee-sdk.d.ts +9 -0
  33. package/dist/orchestration/organization-employee-sdk.js +13 -0
  34. package/dist/orchestration/personal-sdk.d.ts +22 -0
  35. package/dist/orchestration/personal-sdk.js +34 -0
  36. package/dist/orchestration/professional-sdk.d.ts +58 -0
  37. package/dist/orchestration/professional-sdk.js +63 -0
  38. package/dist/poll-options.d.ts +1 -0
  39. package/dist/poll-options.js +2 -0
  40. package/dist/resource-operations.d.ts +225 -0
  41. package/dist/resource-operations.js +184 -0
  42. package/dist/runtime-contracts.d.ts +65 -0
  43. package/dist/runtime-contracts.js +7 -0
  44. package/dist/session.d.ts +64 -0
  45. package/dist/session.js +80 -0
  46. package/dist/simple-device-activation.d.ts +44 -0
  47. package/dist/simple-device-activation.js +44 -0
  48. package/dist/simple-host-onboarding.d.ts +27 -0
  49. package/dist/simple-host-onboarding.js +39 -0
  50. package/dist/simple-individual-onboarding.d.ts +27 -0
  51. package/dist/simple-individual-onboarding.js +38 -0
  52. package/dist/simple-individual-start.d.ts +45 -0
  53. package/dist/simple-individual-start.js +59 -0
  54. package/dist/simple-poll-options.d.ts +5 -0
  55. package/dist/simple-poll-options.js +17 -0
  56. package/dist/simple-smart-token.d.ts +58 -0
  57. package/dist/simple-smart-token.js +85 -0
  58. package/dist/smart-token.d.ts +135 -0
  59. package/dist/smart-token.js +100 -0
  60. package/package.json +26 -0
@@ -0,0 +1,184 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ import { HealthcareBasicSections } from 'gdc-common-utils-ts/constants';
3
+ export async function createOrganizationEmployeeWithDeps(routeCtx, input, options, deps) {
4
+ const payload = {
5
+ jti: `jti-${createRuntimeUuid()}`,
6
+ iss: routeCtx.tenantId,
7
+ aud: routeCtx.tenantId,
8
+ type: 'application/didcomm-plain+json',
9
+ thid: `employee-${createRuntimeUuid()}`,
10
+ body: {
11
+ data: [{
12
+ type: input.dataType || 'Employee-create-request-v1.0',
13
+ request: { method: 'POST' },
14
+ meta: { claims: input.employeeClaims || {} },
15
+ resource: { meta: { claims: input.employeeClaims || {} } },
16
+ }],
17
+ },
18
+ };
19
+ return deps.submitAndPoll(deps.employeeBatchPath(routeCtx), deps.employeePollPath(routeCtx), payload, options);
20
+ }
21
+ export async function importIpsOrFhirAndUpdateIndexWithDeps(routeCtx, input, deps) {
22
+ const payload = {
23
+ thid: input.compositionPayload.thid || `composition-${createRuntimeUuid()}`,
24
+ ...input.compositionPayload,
25
+ };
26
+ const submitPath = (input.format || 'r4') === 'api'
27
+ ? deps.individualCompositionR4BatchPath(routeCtx).replace('/org.hl7.fhir.r4/', '/org.hl7.fhir.api/')
28
+ : deps.individualCompositionR4BatchPath(routeCtx);
29
+ const pollPath = (input.format || 'r4') === 'api'
30
+ ? deps.individualCompositionR4PollPath(routeCtx).replace('/org.hl7.fhir.r4/', '/org.hl7.fhir.api/')
31
+ : deps.individualCompositionR4PollPath(routeCtx);
32
+ return deps.submitAndPoll(submitPath, pollPath, payload, input.pollOptions);
33
+ }
34
+ export async function upsertRelatedPersonAndPollWithDeps(routeCtx, input, deps) {
35
+ const payload = {
36
+ thid: input.relatedPersonPayload.thid || `relatedperson-${createRuntimeUuid()}`,
37
+ ...input.relatedPersonPayload,
38
+ };
39
+ return deps.submitAndPoll(deps.individualRelatedPersonBatchPath(routeCtx), deps.individualRelatedPersonPollPath(routeCtx), payload, input.pollOptions);
40
+ }
41
+ export async function ingestCommunicationAndUpdateIndexWithDeps(routeCtx, input, deps) {
42
+ const payload = {
43
+ thid: input.communicationPayload.thid || `communication-${createRuntimeUuid()}`,
44
+ ...input.communicationPayload,
45
+ };
46
+ const pathFormatSegment = normalizeCommunicationPathFormatSegment(input.pathFormatSegment);
47
+ const convertedPayload = pathFormatSegment === 'org.hl7.fhir.r4'
48
+ ? (deps.transformPayloadForFhirR4
49
+ ? deps.transformPayloadForFhirR4(payload, input.autoConvertClaimsToFhirR4 !== false)
50
+ : payload)
51
+ : payload;
52
+ return deps.submitAndPoll(deps.individualCommunicationBatchPath(routeCtx, pathFormatSegment), deps.individualCommunicationPollPath(routeCtx, pathFormatSegment), convertedPayload, input.pollOptions);
53
+ }
54
+ export async function searchClinicalBundleWithDeps(routeCtx, input, deps) {
55
+ const query = buildBundleSearchQuery(input);
56
+ const payload = {
57
+ thid: input.requestThid || `bundle-search-${createRuntimeUuid()}`,
58
+ body: {
59
+ resourceType: 'Bundle',
60
+ type: 'batch',
61
+ entry: [{ request: { method: 'GET', url: query } }],
62
+ },
63
+ };
64
+ return deps.submitAndPoll(deps.bundleSearchPath(routeCtx), deps.bundleSearchPollPath(routeCtx), payload, input.pollOptions);
65
+ }
66
+ export async function searchLatestIpsWithDeps(routeCtx, input, deps) {
67
+ return deps.searchClinicalBundle(routeCtx, {
68
+ ...input,
69
+ section: input.section || HealthcareBasicSections.PatientSummaryDocument.claim,
70
+ includedTypes: ['Composition', 'DocumentReference'],
71
+ });
72
+ }
73
+ export async function grantProfessionalAccessWithDeps(routeCtx, input, deps) {
74
+ const built = deps.buildConsentClaimsWithCid({
75
+ subjectDid: input.subjectDid,
76
+ subjectPhone: input.subjectPhone,
77
+ subjectGivenName: input.subjectGivenName,
78
+ actor: input.actorId ?? input.actor,
79
+ actorRole: input.actorRole,
80
+ purpose: input.purpose,
81
+ actions: input.actions,
82
+ consentIdentifier: input.consentIdentifier,
83
+ consentDate: input.consentDate,
84
+ decision: input.decision,
85
+ attachmentContentType: input.attachmentContentType,
86
+ attachmentBase64: input.attachmentBase64,
87
+ }, {
88
+ consentIdentifierFactory: () => `urn:uuid:${createRuntimeUuid()}`,
89
+ });
90
+ const thid = `consent-${createRuntimeUuid()}`;
91
+ const consentPayload = {
92
+ thid,
93
+ body: {
94
+ data: [{
95
+ type: input.dataType || 'Consent-grant-request-v1.0',
96
+ meta: { claims: built.consentClaims },
97
+ resource: { resourceType: 'Consent', meta: { claims: built.consentClaims } },
98
+ }],
99
+ },
100
+ };
101
+ const consent = await deps.submitAndPoll(deps.individualConsentR4BatchPath(routeCtx), deps.individualConsentR4PollPath(routeCtx), consentPayload, input.pollOptions);
102
+ return {
103
+ thid,
104
+ consent,
105
+ actorIdentifier: built.actorIdentifier,
106
+ subjectIdentifier: built.subjectIdentifier,
107
+ consentClaims: built.consentClaims,
108
+ claimsCid: built.claimsCid,
109
+ };
110
+ }
111
+ export async function generateDigitalTwinFromSubjectDataWithDeps(routeCtx, input, deps) {
112
+ const payload = {
113
+ thid: input.compositionPayload.thid || `digital-twin-${createRuntimeUuid()}`,
114
+ ...input.compositionPayload,
115
+ };
116
+ const submitPath = (input.format || 'r4') === 'api'
117
+ ? deps.digitalTwinCompositionApiBatchPath(routeCtx)
118
+ : deps.digitalTwinCompositionR4BatchPath(routeCtx);
119
+ const pollPath = (input.format || 'r4') === 'api'
120
+ ? deps.digitalTwinCompositionApiPollPath(routeCtx)
121
+ : deps.digitalTwinCompositionR4PollPath(routeCtx);
122
+ return deps.submitAndPoll(submitPath, pollPath, payload, input.pollOptions);
123
+ }
124
+ function normalizeCommunicationPathFormatSegment(raw) {
125
+ const value = String(raw || '').trim().toLowerCase();
126
+ if (!value || value === 'api' || value === 'org.hl7.fhir.api')
127
+ return 'org.hl7.fhir.api';
128
+ if (value === 'r4' || value === 'fhir.r4' || value === 'org.hl7.fhir.r4')
129
+ return 'org.hl7.fhir.r4';
130
+ return 'org.hl7.fhir.api';
131
+ }
132
+ function createRuntimeUuid() {
133
+ const fromCrypto = globalThis.crypto?.randomUUID?.();
134
+ if (fromCrypto) {
135
+ return fromCrypto;
136
+ }
137
+ return `fallback-${Date.now()}-${Math.random().toString(16).slice(2)}`;
138
+ }
139
+ function buildBundleSearchQuery(input) {
140
+ const params = new URLSearchParams();
141
+ params.set('subject', input.subject);
142
+ const sectionValues = normalizeToCsv(input.section);
143
+ if (sectionValues)
144
+ params.set('composition.section', sectionValues);
145
+ const typeValues = normalizeToCsv(input.includedTypes);
146
+ if (typeValues)
147
+ params.set('_type', typeValues);
148
+ if (input.date?.start)
149
+ params.set('start', input.date.start);
150
+ if (input.date?.end)
151
+ params.set('end', input.date.end);
152
+ const codeValues = normalizeToCsv(input.code);
153
+ if (codeValues)
154
+ params.set('code', codeValues);
155
+ const categoryValues = normalizeToCsv(input.category);
156
+ if (categoryValues)
157
+ params.set('category', categoryValues);
158
+ const authorValues = normalizeToCsv(input.author);
159
+ if (authorValues)
160
+ params.set('author', authorValues);
161
+ if (input.thid)
162
+ params.set('thid', input.thid);
163
+ if (input.pthid)
164
+ params.set('pthid', input.pthid);
165
+ if (input.channelId)
166
+ params.set('channelId', input.channelId);
167
+ if (input.partOf)
168
+ params.set('part-of', input.partOf);
169
+ if (input.extraSearchParams) {
170
+ for (const [key, value] of Object.entries(input.extraSearchParams)) {
171
+ if (value === undefined || value === null || String(value).trim() === '')
172
+ continue;
173
+ params.set(key, String(value));
174
+ }
175
+ }
176
+ return `Bundle?type=document&${params.toString()}`;
177
+ }
178
+ function normalizeToCsv(value) {
179
+ if (!value)
180
+ return '';
181
+ if (Array.isArray(value))
182
+ return value.map((v) => String(v).trim()).filter(Boolean).join(',');
183
+ return String(value).trim();
184
+ }
@@ -0,0 +1,65 @@
1
+ import type { NodeOperatorNetworkType } from 'gdc-common-utils-ts/constants/network';
2
+ import type { DataPersistencePolicy } from '../../gdc-sdk-core-ts/dist/index.js';
3
+ export type LegacyNodeSourcePackage = never;
4
+ /**
5
+ * Deployment/runtime form factor of the Node SDK host process itself.
6
+ */
7
+ export type NodeRuntimeMode = 'server' | 'bff' | 'cloud-function' | 'worker';
8
+ /**
9
+ * Interoperability strictness mode of the runtime.
10
+ *
11
+ * - `demo`: accept looser/demo-oriented payload shaping
12
+ * - `compat`: accept compatibility-oriented payload shaping
13
+ * - `strict`: enforce the canonical contract as much as the runtime allows
14
+ */
15
+ export type NodeInteropMode = 'demo' | 'compat' | 'strict';
16
+ /**
17
+ * Route context for tenant-scoped GW calls.
18
+ *
19
+ * This is not the web-portal context. It identifies the target tenant route in
20
+ * the node operator / GW:
21
+ * - `tenantId`: canonical tenant identifier
22
+ * - `jurisdiction`: legal jurisdiction
23
+ * - `sector`: functional sector path segment
24
+ */
25
+ export type TenantContext = {
26
+ tenantId: string;
27
+ jurisdiction: string;
28
+ sector: string;
29
+ };
30
+ /**
31
+ * Discovery/bootstrap context for a node operator environment.
32
+ *
33
+ * This describes the operator network/environment itself. It does not replace
34
+ * the tenant route context used by tenant-scoped GW endpoints.
35
+ */
36
+ export type NodeOperatorContext = {
37
+ networkType: NodeOperatorNetworkType;
38
+ jurisdiction: string;
39
+ operatorDid?: string;
40
+ baseUrl?: string;
41
+ };
42
+ export type NodeFetchLike = typeof fetch;
43
+ /**
44
+ * Node runtime configuration for backend/BFF integrations.
45
+ */
46
+ export type NodeRuntimeConfig = {
47
+ runtimeMode: NodeRuntimeMode;
48
+ interopMode?: NodeInteropMode;
49
+ fetcher: NodeFetchLike;
50
+ persistencePolicy?: DataPersistencePolicy;
51
+ walletProvider?: unknown;
52
+ cryptoProvider?: unknown;
53
+ storageProvider?: unknown;
54
+ outboxRepositoryFactory?: unknown;
55
+ defaultTenantId?: string;
56
+ defaultJurisdiction?: string;
57
+ defaultSector?: string;
58
+ };
59
+ export type NodePackageStatus = {
60
+ packageName: 'gdc-sdk-node-ts';
61
+ dependsOnCorePackage: 'gdc-sdk-core-ts';
62
+ legacySourcePackages: LegacyNodeSourcePackage[];
63
+ status: 'bootstrap';
64
+ };
65
+ export declare const GDC_SDK_NODE_STATUS: NodePackageStatus;
@@ -0,0 +1,7 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ export const GDC_SDK_NODE_STATUS = {
3
+ packageName: 'gdc-sdk-node-ts',
4
+ dependsOnCorePackage: 'gdc-sdk-core-ts',
5
+ legacySourcePackages: [],
6
+ status: 'bootstrap',
7
+ };
@@ -0,0 +1,64 @@
1
+ import type { ActorKind, Capability } from '../../gdc-sdk-core-ts/dist/index.js';
2
+ import { HostOnboardingSdk } from './orchestration/host-onboarding-sdk.js';
3
+ import { IndividualControllerSdk } from './orchestration/individual-controller-sdk.js';
4
+ import { IndividualMemberSdk } from './orchestration/individual-member-sdk.js';
5
+ import { OrganizationControllerSdk } from './orchestration/organization-controller-sdk.js';
6
+ import { OrganizationEmployeeSdk } from './orchestration/organization-employee-sdk.js';
7
+ import { ProfessionalSdk } from './orchestration/professional-sdk.js';
8
+ import type { RuntimeClient } from './orchestration/client-port.js';
9
+ export type NodeCapability = Capability | 'host.activate_organization' | 'host.confirm_order' | 'organization.activate_device' | 'individual.ingest_communication' | 'individual.upsert_related_person' | 'token.request_smart';
10
+ export type NodeActorSessionContext = {
11
+ actorKind: ActorKind;
12
+ actorDid?: string;
13
+ subjectDid?: string;
14
+ capabilities?: NodeCapability[];
15
+ };
16
+ /**
17
+ * Preferred neutral actor-session context contract.
18
+ *
19
+ * Keep `NodeActorSessionContext` only as a compatibility alias while names are
20
+ * converged across runtimes.
21
+ */
22
+ export type ActorSessionContext = NodeActorSessionContext;
23
+ /**
24
+ * Preferred neutral actor session abstraction for runtime packages.
25
+ *
26
+ * Keep `NodeActorSession` only as a compatibility alias while package naming is
27
+ * converged across node/front/other runtimes.
28
+ */
29
+ export declare class ActorSession {
30
+ readonly actorKind: ActorKind;
31
+ readonly actorDid?: string;
32
+ readonly subjectDid?: string;
33
+ readonly capabilities: NodeCapability[];
34
+ private readonly client?;
35
+ constructor(context: ActorSessionContext, client?: RuntimeClient);
36
+ is(actorKind: ActorKind): boolean;
37
+ assertActorKind(actorKind: ActorKind): void;
38
+ asHostOnboarding(): HostOnboardingSdk;
39
+ asOrganizationController(): OrganizationControllerSdk;
40
+ asOrganizationEmployee(): OrganizationEmployeeSdk;
41
+ asIndividualController(): IndividualControllerSdk;
42
+ asIndividualMember(): IndividualMemberSdk;
43
+ asProfessional(): ProfessionalSdk;
44
+ private requireClient;
45
+ }
46
+ /**
47
+ * @deprecated Prefer `ActorSessionContext`.
48
+ */
49
+ export declare class NodeActorSession {
50
+ private readonly inner;
51
+ constructor(context: NodeActorSessionContext, client?: RuntimeClient);
52
+ get actorKind(): ActorKind;
53
+ get actorDid(): string | undefined;
54
+ get subjectDid(): string | undefined;
55
+ get capabilities(): NodeCapability[];
56
+ is(actorKind: ActorKind): boolean;
57
+ assertActorKind(actorKind: ActorKind): void;
58
+ asHostOnboarding(): HostOnboardingSdk;
59
+ asOrganizationController(): OrganizationControllerSdk;
60
+ asOrganizationEmployee(): OrganizationEmployeeSdk;
61
+ asIndividualController(): IndividualControllerSdk;
62
+ asIndividualMember(): IndividualMemberSdk;
63
+ asProfessional(): ProfessionalSdk;
64
+ }
@@ -0,0 +1,80 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ import { HostOnboardingSdk } from './orchestration/host-onboarding-sdk.js';
3
+ import { IndividualControllerSdk } from './orchestration/individual-controller-sdk.js';
4
+ import { IndividualMemberSdk } from './orchestration/individual-member-sdk.js';
5
+ import { OrganizationControllerSdk } from './orchestration/organization-controller-sdk.js';
6
+ import { OrganizationEmployeeSdk } from './orchestration/organization-employee-sdk.js';
7
+ import { ProfessionalSdk } from './orchestration/professional-sdk.js';
8
+ /**
9
+ * Preferred neutral actor session abstraction for runtime packages.
10
+ *
11
+ * Keep `NodeActorSession` only as a compatibility alias while package naming is
12
+ * converged across node/front/other runtimes.
13
+ */
14
+ export class ActorSession {
15
+ constructor(context, client) {
16
+ this.actorKind = context.actorKind;
17
+ this.actorDid = context.actorDid;
18
+ this.subjectDid = context.subjectDid;
19
+ this.capabilities = [...new Set(context.capabilities || [])];
20
+ this.client = client;
21
+ }
22
+ is(actorKind) {
23
+ return this.actorKind === actorKind;
24
+ }
25
+ assertActorKind(actorKind) {
26
+ if (!this.is(actorKind)) {
27
+ throw new Error(`ActorSession is '${this.actorKind}' and cannot be used as '${actorKind}'.`);
28
+ }
29
+ }
30
+ asHostOnboarding() {
31
+ this.assertActorKind('host_onboarding');
32
+ return new HostOnboardingSdk(this.requireClient());
33
+ }
34
+ asOrganizationController() {
35
+ this.assertActorKind('organization_controller');
36
+ return new OrganizationControllerSdk(this.requireClient());
37
+ }
38
+ asOrganizationEmployee() {
39
+ this.assertActorKind('organization_employee');
40
+ return new OrganizationEmployeeSdk(this.requireClient());
41
+ }
42
+ asIndividualController() {
43
+ this.assertActorKind('individual_controller');
44
+ return new IndividualControllerSdk(this.requireClient());
45
+ }
46
+ asIndividualMember() {
47
+ this.assertActorKind('individual_member');
48
+ return new IndividualMemberSdk(this.requireClient());
49
+ }
50
+ asProfessional() {
51
+ this.assertActorKind('professional');
52
+ return new ProfessionalSdk(this.requireClient());
53
+ }
54
+ requireClient() {
55
+ if (!this.client) {
56
+ throw new Error('ActorSession requires a runtime client to materialize actor facades.');
57
+ }
58
+ return this.client;
59
+ }
60
+ }
61
+ /**
62
+ * @deprecated Prefer `ActorSessionContext`.
63
+ */
64
+ export class NodeActorSession {
65
+ constructor(context, client) {
66
+ this.inner = new ActorSession(context, client);
67
+ }
68
+ get actorKind() { return this.inner.actorKind; }
69
+ get actorDid() { return this.inner.actorDid; }
70
+ get subjectDid() { return this.inner.subjectDid; }
71
+ get capabilities() { return this.inner.capabilities; }
72
+ is(actorKind) { return this.inner.is(actorKind); }
73
+ assertActorKind(actorKind) { this.inner.assertActorKind(actorKind); }
74
+ asHostOnboarding() { return this.inner.asHostOnboarding(); }
75
+ asOrganizationController() { return this.inner.asOrganizationController(); }
76
+ asOrganizationEmployee() { return this.inner.asOrganizationEmployee(); }
77
+ asIndividualController() { return this.inner.asIndividualController(); }
78
+ asIndividualMember() { return this.inner.asIndividualMember(); }
79
+ asProfessional() { return this.inner.asProfessional(); }
80
+ }
@@ -0,0 +1,44 @@
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 {};
@@ -0,0 +1,44 @@
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
+ }
@@ -0,0 +1,27 @@
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 {};
@@ -0,0 +1,39 @@
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
+ }
@@ -0,0 +1,27 @@
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 {};
@@ -0,0 +1,38 @@
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
+ }
@@ -0,0 +1,45 @@
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 {};