gdc-sdk-node-ts 2.2.2 → 2.3.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 (44) 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/individual-start.d.ts +33 -0
  6. package/dist/individual-start.js +45 -2
  7. package/dist/node-runtime-client.d.ts +39 -4
  8. package/dist/node-runtime-client.js +124 -4
  9. package/dist/orchestration/client-port.d.ts +4 -1
  10. package/dist/orchestration/individual-controller-sdk.d.ts +10 -1
  11. package/dist/orchestration/individual-controller-sdk.js +15 -0
  12. package/dist/orchestration/individual-member-sdk.d.ts +10 -1
  13. package/dist/orchestration/individual-member-sdk.js +15 -0
  14. package/dist/resource-operations.d.ts +111 -4
  15. package/dist/resource-operations.js +83 -3
  16. package/dist/runtime-client-paths.d.ts +6 -2
  17. package/dist/runtime-client-paths.js +4 -0
  18. package/dist/runtime-transport.d.ts +13 -1
  19. package/dist/runtime-transport.js +18 -3
  20. package/dist/server-profile-protection.d.ts +64 -0
  21. package/dist/server-profile-protection.js +110 -0
  22. package/dist/server-profile-session.d.ts +115 -0
  23. package/dist/server-profile-session.js +259 -0
  24. package/dist/session.d.ts +7 -0
  25. package/dist/session.js +10 -0
  26. package/package.json +3 -3
  27. package/dist/legal-organization-onboarding-facade.d.ts +0 -70
  28. package/dist/legal-organization-onboarding-facade.js +0 -169
  29. package/dist/lifecycle-examples.d.ts +0 -7
  30. package/dist/lifecycle-examples.js +0 -8
  31. package/dist/runtime-software-proof.d.ts +0 -51
  32. package/dist/runtime-software-proof.js +0 -34
  33. package/dist/simple-device-activation.d.ts +0 -44
  34. package/dist/simple-device-activation.js +0 -44
  35. package/dist/simple-host-onboarding.d.ts +0 -27
  36. package/dist/simple-host-onboarding.js +0 -39
  37. package/dist/simple-individual-onboarding.d.ts +0 -27
  38. package/dist/simple-individual-onboarding.js +0 -38
  39. package/dist/simple-individual-start.d.ts +0 -45
  40. package/dist/simple-individual-start.js +0 -59
  41. package/dist/simple-poll-options.d.ts +0 -5
  42. package/dist/simple-poll-options.js +0 -17
  43. package/dist/simple-smart-token.d.ts +0 -58
  44. package/dist/simple-smart-token.js +0 -85
@@ -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
- }