gdc-sdk-node-ts 2.1.4 → 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 (56) hide show
  1. package/README.md +11 -5
  2. package/dist/backend-profile-runtime.d.ts +23 -0
  3. package/dist/backend-profile-runtime.js +23 -0
  4. package/dist/backend-profile-workspace.d.ts +48 -0
  5. package/dist/backend-profile-workspace.js +91 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.js +3 -0
  8. package/dist/individual-controller-backend-runtime.d.ts +6 -1
  9. package/dist/individual-controller-backend-runtime.js +7 -0
  10. package/dist/node-runtime-client.d.ts +51 -4
  11. package/dist/node-runtime-client.js +148 -4
  12. package/dist/orchestration/client-port.d.ts +6 -1
  13. package/dist/orchestration/individual-controller-sdk.d.ts +46 -1
  14. package/dist/orchestration/individual-controller-sdk.js +59 -0
  15. package/dist/orchestration/individual-member-sdk.d.ts +35 -1
  16. package/dist/orchestration/individual-member-sdk.js +44 -0
  17. package/dist/orchestration/personal-sdk.d.ts +3 -1
  18. package/dist/orchestration/personal-sdk.js +4 -0
  19. package/dist/orchestration/professional-sdk.d.ts +11 -1
  20. package/dist/orchestration/professional-sdk.js +14 -0
  21. package/dist/professional-backend-runtime.d.ts +6 -1
  22. package/dist/professional-backend-runtime.js +7 -0
  23. package/dist/profile-workspace.d.ts +12 -0
  24. package/dist/profile-workspace.js +15 -0
  25. package/dist/resource-operations.d.ts +185 -4
  26. package/dist/resource-operations.js +267 -3
  27. package/dist/runtime-client-paths.d.ts +8 -2
  28. package/dist/runtime-client-paths.js +6 -0
  29. package/dist/runtime-route-context.js +18 -1
  30. package/dist/runtime-transport.d.ts +13 -1
  31. package/dist/runtime-transport.js +18 -3
  32. package/dist/server-profile-protection.d.ts +64 -0
  33. package/dist/server-profile-protection.js +110 -0
  34. package/dist/server-profile-session.d.ts +115 -0
  35. package/dist/server-profile-session.js +259 -0
  36. package/dist/session.d.ts +7 -0
  37. package/dist/session.js +10 -0
  38. package/package.json +3 -3
  39. package/dist/legal-organization-onboarding-facade.d.ts +0 -70
  40. package/dist/legal-organization-onboarding-facade.js +0 -169
  41. package/dist/lifecycle-examples.d.ts +0 -7
  42. package/dist/lifecycle-examples.js +0 -8
  43. package/dist/runtime-software-proof.d.ts +0 -51
  44. package/dist/runtime-software-proof.js +0 -34
  45. package/dist/simple-device-activation.d.ts +0 -44
  46. package/dist/simple-device-activation.js +0 -44
  47. package/dist/simple-host-onboarding.d.ts +0 -27
  48. package/dist/simple-host-onboarding.js +0 -39
  49. package/dist/simple-individual-onboarding.d.ts +0 -27
  50. package/dist/simple-individual-onboarding.js +0 -38
  51. package/dist/simple-individual-start.d.ts +0 -45
  52. package/dist/simple-individual-start.js +0 -59
  53. package/dist/simple-poll-options.d.ts +0 -5
  54. package/dist/simple-poll-options.js +0 -17
  55. package/dist/simple-smart-token.d.ts +0 -58
  56. package/dist/simple-smart-token.js +0 -85
@@ -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
- }
@@ -1,58 +0,0 @@
1
- import type { PollOptions, SubmitAndPollResult } from './orchestration/client-port.js';
2
- import type { RouteContext } from './simple-individual-onboarding.js';
3
- export type SmartTokenRequestInput = {
4
- tenantId?: string;
5
- jurisdiction?: string;
6
- sector?: string;
7
- idToken: string;
8
- scopes: string[];
9
- subjectDid?: string;
10
- vpToken?: string;
11
- clientId?: string;
12
- audience?: string;
13
- issuer?: string;
14
- redirectUri?: string;
15
- acrValues?: string;
16
- codeChallenge?: string;
17
- codeChallengeMethod?: 'S256';
18
- presentationSubmission?: Record<string, unknown>;
19
- purpose?: string;
20
- requestBodyClaims?: Record<string, unknown>;
21
- smartTokenKind?: 'token-exchange' | 'openid-smart';
22
- tokenCacheKey?: string;
23
- endpointId?: string;
24
- timeoutSeconds?: number;
25
- intervalSeconds?: number;
26
- additionalClaims?: Record<string, unknown>;
27
- };
28
- export type SmartTokenExchangeResult = {
29
- status: 'fetched' | 'cached' | 'failed';
30
- accessToken?: string;
31
- tokenType?: string;
32
- scopes?: string[];
33
- statusCode?: number;
34
- response?: unknown;
35
- };
36
- type CachedTokenWrite = {
37
- accessToken: string;
38
- tokenType: string;
39
- scopes: string[];
40
- expiresAt: number;
41
- };
42
- type RequestSmartTokenDeps = {
43
- input: SmartTokenRequestInput;
44
- routeCtx: RouteContext;
45
- baseUrl: string;
46
- defaultTimeoutMs?: number;
47
- defaultIntervalMs?: number;
48
- identityTokenExchangePath: (ctx: RouteContext) => string;
49
- identityTokenExchangePollPath: (ctx: RouteContext) => string;
50
- identityOpenIdSmartTokenPath: (ctx: RouteContext) => string;
51
- identityOpenIdSmartTokenPollPath: (ctx: RouteContext) => string;
52
- submitAndPoll: (submitPath: string, pollPath: string, payload: {
53
- thid?: string;
54
- } & Record<string, unknown>, options?: PollOptions) => Promise<SubmitAndPollResult>;
55
- setTokenCache: (tokenCacheKey: string, token: CachedTokenWrite) => void;
56
- };
57
- export declare function requestSmartTokenWithDeps(deps: RequestSmartTokenDeps): Promise<SmartTokenExchangeResult>;
58
- export {};
@@ -1,85 +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 requestSmartTokenWithDeps(deps) {
4
- const normalizedScopes = Array.from(new Set((deps.input.scopes || []).filter(Boolean))).sort();
5
- const tokenCacheKey = String(deps.input.tokenCacheKey || deps.input.endpointId || `smart:${deps.routeCtx.tenantId}:${normalizedScopes.join(',')}`).trim();
6
- if (!tokenCacheKey) {
7
- throw new Error('requestSmartToken requires tokenCacheKey (or non-empty scopes).');
8
- }
9
- const pollOptions = resolvePollOptionsFromSeconds(deps.input.timeoutSeconds, deps.input.intervalSeconds, {
10
- timeoutMs: deps.defaultTimeoutMs,
11
- intervalMs: deps.defaultIntervalMs,
12
- });
13
- if (deps.input.smartTokenKind === 'openid-smart') {
14
- const smartPayload = {
15
- thid: `smart-${createRuntimeUuid()}`,
16
- iss: deps.input.issuer || deps.input.clientId || deps.routeCtx.tenantId,
17
- aud: deps.input.audience || deps.routeCtx.tenantId,
18
- body: {
19
- client_id: deps.input.clientId || deps.input.subjectDid || deps.routeCtx.tenantId,
20
- redirect_uri: deps.input.redirectUri || `${deps.baseUrl}/callback`,
21
- code_challenge: deps.input.codeChallenge || 'demo-code-challenge',
22
- code_challenge_method: deps.input.codeChallengeMethod || 'S256',
23
- acr_values: deps.input.acrValues || 'urn:antifraud:acr:openid4vp:employee',
24
- vp_token: deps.input.vpToken || deps.input.idToken,
25
- presentation_submission: deps.input.presentationSubmission,
26
- expires_in: 300,
27
- token_type: 'Bearer',
28
- sub: deps.input.subjectDid || deps.input.issuer || deps.input.clientId || deps.routeCtx.tenantId,
29
- purpose: deps.input.purpose || 'TREAT',
30
- scope: normalizedScopes.join(' '),
31
- ...(deps.input.requestBodyClaims || {}),
32
- },
33
- ...(deps.input.additionalClaims || {}),
34
- };
35
- const exchange = await deps.submitAndPoll(deps.identityOpenIdSmartTokenPath(deps.routeCtx), deps.identityOpenIdSmartTokenPollPath(deps.routeCtx), smartPayload, pollOptions);
36
- return resolveTokenExchangeResult(exchange, normalizedScopes, tokenCacheKey, deps.setTokenCache);
37
- }
38
- const payload = {
39
- thid: `exchange-${createRuntimeUuid()}`,
40
- grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',
41
- subject_token_type: 'urn:ietf:params:oauth:token-type:id_token',
42
- subject_token: deps.input.idToken,
43
- scope: normalizedScopes.join(' '),
44
- organization: deps.routeCtx.tenantId,
45
- ...(deps.input.additionalClaims || {}),
46
- };
47
- const exchange = await deps.submitAndPoll(deps.identityTokenExchangePath(deps.routeCtx), deps.identityTokenExchangePollPath(deps.routeCtx), payload, pollOptions);
48
- return resolveTokenExchangeResult(exchange, normalizedScopes, tokenCacheKey, deps.setTokenCache);
49
- }
50
- function resolveTokenExchangeResult(exchange, normalizedScopes, tokenCacheKey, setTokenCache) {
51
- const exchangeBody = exchange.poll.body ?? {};
52
- const accessToken = String(exchangeBody.access_token || '').trim();
53
- if (exchange.poll.status >= 400 || !accessToken) {
54
- return {
55
- status: 'failed',
56
- statusCode: exchange.poll.status,
57
- response: exchange.poll.body,
58
- };
59
- }
60
- const tokenType = String(exchangeBody.token_type || 'Bearer');
61
- const grantedScopes = String(exchangeBody.scope || '').trim().split(' ').filter(Boolean);
62
- const resolvedScopes = grantedScopes.length ? grantedScopes : normalizedScopes;
63
- const expiresIn = Number(exchangeBody.expires_in ?? 0);
64
- setTokenCache(tokenCacheKey, {
65
- accessToken,
66
- tokenType,
67
- scopes: resolvedScopes,
68
- expiresAt: Date.now() + expiresIn * 1000,
69
- });
70
- return {
71
- status: 'fetched',
72
- accessToken,
73
- tokenType,
74
- scopes: resolvedScopes,
75
- statusCode: exchange.poll.status,
76
- response: exchange.poll.body,
77
- };
78
- }
79
- function createRuntimeUuid() {
80
- const fromCrypto = globalThis.crypto?.randomUUID?.();
81
- if (fromCrypto) {
82
- return fromCrypto;
83
- }
84
- return `fallback-${Date.now()}-${Math.random().toString(16).slice(2)}`;
85
- }