gdc-sdk-front-ts 2.1.2 → 2.2.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.
package/README.md CHANGED
@@ -7,8 +7,11 @@ profile/session runtime logic, or orchestration tests.
7
7
  Short rule:
8
8
 
9
9
  - `101` tests must stay didactic and step by step
10
- - reusable fixtures/types must come from `gdc-common-utils-ts` instead of
11
- being repeated as frontend-local literals
10
+ - `gdc-common-utils-ts` owns the canonical step-by-step editors/readers,
11
+ shared fixtures, and reusable payload examples
12
+ - `gdc-sdk-front-ts` starts at `ProfileRuntime -> loadProfile(...) ->
13
+ workspace/session -> actor facade` and only then handles frontend runtime
14
+ orchestration
12
15
 
13
16
  Frontend runtime package for consuming the shared GDC SDK contracts in web or
14
17
  mobile apps.
@@ -39,7 +42,8 @@ If you are integrating this package for the first time, open these in order:
39
42
  Why `core`, `node`, and `front` are separate packages, what each one owns,
40
43
  and why frontend facades should mirror backend actor boundaries.
41
44
  1. [docs/101-SDK_INTEGRATION.md](./docs/101-SDK_INTEGRATION.md)
42
- Real frontend/native setup, imports, `new ClientSDK(...)`,
45
+ Real frontend/native setup, injected runtime adapters, `loadProfile(...)`
46
+ into one loaded workspace/session, `new ClientSDK(...)`,
43
47
  `initializeCommunicationIdentity(...)`, `initializeSession(...)`, and the
44
48
  public actor entrypoints exposed by `ProfileManager.asXxx()`.
45
49
  2. [gdc-sdk-core-ts/docs/101-SDK_FLOWS.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/101-SDK_FLOWS.md)
@@ -72,6 +76,8 @@ If you need the shortest path:
72
76
  [`ClientSDK`](src/ClientSDK.ts)
73
77
  - profile/session bootstrap:
74
78
  [`initializeSession(...)`](./docs/101-SDK_INTEGRATION.md)
79
+ - loaded profile workspace bootstrap:
80
+ `new ProfileRuntime(...).loadProfile(...)`
75
81
  - first public actor entrypoints:
76
82
  `session.asHostOnboarding()`, `session.asOrganizationController()`,
77
83
  `session.asIndividualController()`, `session.asProfessional()`
@@ -1,7 +1,7 @@
1
1
  import { ProfileManager } from './ProfileManager.js';
2
2
  import { ProfileRegistry } from './ProfileRegistry.js';
3
3
  import type { AppInfo, InitializeSessionParams, IVerifier, IVaultRepository, ProfileRegistryEntry, SdkConfig } from './types.js';
4
- import { type ResolvedAppInfo } from 'gdc-sdk-core-ts';
4
+ import { type AuthorityResolution, type AuthorityResolutionInput, type AuthorityResolver, type ResolvedAppInfo } from 'gdc-sdk-core-ts';
5
5
  /**
6
6
  * Frontend-facing SDK entry point for profile/session bootstrapping, lightweight
7
7
  * provider discovery, and role-scoped session creation.
@@ -94,6 +94,16 @@ export declare class ClientSDK {
94
94
  * Clears the current in-memory session reference.
95
95
  */
96
96
  shutdownSession(): void;
97
+ /**
98
+ * Resolves one technical host/authority descriptor from business tenant
99
+ * context or one already-known subject/public identifier.
100
+ *
101
+ * Convenience rule:
102
+ * - browser/native callers should not have to handcraft `did:web`
103
+ * - pass a shared resolver when your app already preloaded one
104
+ * - without a resolver, the SDK falls back to the shared static/legacy rules
105
+ */
106
+ resolveAuthority(input: AuthorityResolutionInput, resolver?: AuthorityResolver): Promise<AuthorityResolution>;
97
107
  private resolveBaseUrl;
98
108
  }
99
109
  export type { InitializeSessionParams, ProfileRegistryEntry, };
package/dist/ClientSDK.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
2
  import { ProfileManager } from './ProfileManager.js';
3
3
  import { ProfileRegistry } from './ProfileRegistry.js';
4
- import { buildAppHeaders, resolveAppInfo, } from 'gdc-sdk-core-ts';
4
+ import { StaticAuthorityResolver, buildAppHeaders, resolveAppInfo, } from 'gdc-sdk-core-ts';
5
5
  /**
6
6
  * Frontend-facing SDK entry point for profile/session bootstrapping, lightweight
7
7
  * provider discovery, and role-scoped session creation.
@@ -154,6 +154,18 @@ export class ClientSDK {
154
154
  shutdownSession() {
155
155
  this.currentSession = null;
156
156
  }
157
+ /**
158
+ * Resolves one technical host/authority descriptor from business tenant
159
+ * context or one already-known subject/public identifier.
160
+ *
161
+ * Convenience rule:
162
+ * - browser/native callers should not have to handcraft `did:web`
163
+ * - pass a shared resolver when your app already preloaded one
164
+ * - without a resolver, the SDK falls back to the shared static/legacy rules
165
+ */
166
+ async resolveAuthority(input, resolver = new StaticAuthorityResolver()) {
167
+ return resolver.resolveAuthority(input);
168
+ }
157
169
  async resolveBaseUrl(source) {
158
170
  const raw = String(source || '').trim();
159
171
  if (!raw)
@@ -0,0 +1,62 @@
1
+ import type { LoadedActorProfile, ProfileLoadRequest, SubjectIndexCompositionRequest, SubjectIndexConnectionRequest, TrustedDeviceRegistrationRequest } from 'gdc-sdk-core-ts';
2
+ import { ProfileManager } from './ProfileManager.js';
3
+ import type { FrontendProfileRuntimeClient, FrontendSubjectIndexCompositionResult, FrontendSubjectIndexConnectionResult, FrontendTrustedDeviceRegistrationResult } from './frontend-profile-runtime.js';
4
+ import { HostOnboardingSdk } from './orchestration/host-onboarding-sdk.js';
5
+ import { IndividualControllerSdk } from './orchestration/individual-controller-sdk.js';
6
+ import { IndividualMemberSdk } from './orchestration/individual-member-sdk.js';
7
+ import { OrganizationControllerSdk } from './orchestration/organization-controller-sdk.js';
8
+ import { OrganizationEmployeeSdk } from './orchestration/organization-employee-sdk.js';
9
+ import { PersonalSdk } from './orchestration/personal-sdk.js';
10
+ import { ProfessionalSdk } from './orchestration/professional-sdk.js';
11
+ import type { FrontRuntimeClient } from './orchestration/client-port.js';
12
+ export type FrontendLoadedActorProfile = LoadedActorProfile & {
13
+ actorSession: ProfileManager;
14
+ };
15
+ export type LoadedProfile = FrontendLoadedActorProfile;
16
+ /**
17
+ * Frontend loaded-profile workspace that keeps the login/profile bootstrap
18
+ * steps explicit and then exposes actor-scoped facades from that loaded
19
+ * profile.
20
+ */
21
+ export declare class LoadedProfileWorkspace {
22
+ readonly profile: FrontendLoadedActorProfile;
23
+ readonly actorSession: ProfileManager;
24
+ private readonly profileRuntime;
25
+ private readonly facadeClient?;
26
+ constructor(profileRuntime: FrontendProfileRuntimeClient, loadedProfile: LoadedActorProfile, facadeClient?: FrontRuntimeClient);
27
+ registerTrustedDevice(input: TrustedDeviceRegistrationRequest): Promise<FrontendTrustedDeviceRegistrationResult>;
28
+ connectToSubjectIndex(input: SubjectIndexConnectionRequest): Promise<FrontendSubjectIndexConnectionResult>;
29
+ getSubjectIndexComposition(input: SubjectIndexCompositionRequest): Promise<FrontendSubjectIndexCompositionResult>;
30
+ asHostOnboarding(): HostOnboardingSdk;
31
+ asOrganizationController(): OrganizationControllerSdk;
32
+ asOrganizationEmployee(): OrganizationEmployeeSdk;
33
+ asIndividualController(): IndividualControllerSdk;
34
+ asIndividualMember(): IndividualMemberSdk;
35
+ asPersonal(): PersonalSdk;
36
+ asProfessional(): ProfessionalSdk;
37
+ private requireFacadeClient;
38
+ }
39
+ /**
40
+ * Frontend counterpart to the backend loaded-profile runtime:
41
+ * inject adapters once, load one protected profile, then work from the
42
+ * returned workspace/session facade instead of one-off helper calls.
43
+ */
44
+ export declare class ProfileRuntime {
45
+ private readonly profileRuntime;
46
+ private readonly facadeClient?;
47
+ constructor(profileRuntime: FrontendProfileRuntimeClient, facadeClient?: FrontRuntimeClient | undefined);
48
+ loadProfile(input: ProfileLoadRequest): Promise<LoadedProfileWorkspace>;
49
+ }
50
+ export declare function createLoadedProfileWorkspace(profileRuntime: FrontendProfileRuntimeClient, loadedProfile: LoadedActorProfile, facadeClient?: FrontRuntimeClient): LoadedProfileWorkspace;
51
+ /**
52
+ * @deprecated Prefer `LoadedProfileWorkspace`.
53
+ */
54
+ export { LoadedProfileWorkspace as FrontendProfileWorkspace };
55
+ /**
56
+ * @deprecated Prefer `ProfileRuntime`.
57
+ */
58
+ export { ProfileRuntime as FrontendProfileWorkspaceRuntime };
59
+ /**
60
+ * @deprecated Prefer `createLoadedProfileWorkspace`.
61
+ */
62
+ export { createLoadedProfileWorkspace as createFrontendProfileWorkspace };
@@ -0,0 +1,129 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ import { ActorKinds, } from 'gdc-common-utils-ts/constants/actor-session';
3
+ import { ProfileAppTypes } from 'gdc-common-utils-ts/constants';
4
+ import { ProfileManager } from './ProfileManager.js';
5
+ import { getFrontendSubjectIndexComposition, loadFrontendProfile, connectFrontendToSubjectIndex, registerFrontendTrustedDevice, } from './frontend-profile-runtime.js';
6
+ import { HostOnboardingSdk } from './orchestration/host-onboarding-sdk.js';
7
+ import { IndividualControllerSdk } from './orchestration/individual-controller-sdk.js';
8
+ import { IndividualMemberSdk } from './orchestration/individual-member-sdk.js';
9
+ import { OrganizationControllerSdk } from './orchestration/organization-controller-sdk.js';
10
+ import { OrganizationEmployeeSdk } from './orchestration/organization-employee-sdk.js';
11
+ import { PersonalSdk } from './orchestration/personal-sdk.js';
12
+ import { ProfessionalSdk } from './orchestration/professional-sdk.js';
13
+ function toSessionProfile(profile) {
14
+ const descriptor = profile.descriptor || {};
15
+ const id = String(descriptor.profileId
16
+ || descriptor.profileDid
17
+ || descriptor.subjectDid
18
+ || descriptor.providerDid
19
+ || 'frontend-profile').trim();
20
+ return {
21
+ id,
22
+ email: String(descriptor.email || '').trim(),
23
+ role: String(descriptor.actorRole || '').trim(),
24
+ providerDid: String(descriptor.providerDid || '').trim(),
25
+ appType: descriptor.appType || ProfileAppTypes.Family,
26
+ createdAt: new Date().toISOString(),
27
+ };
28
+ }
29
+ function requireActorKind(profile, actorKind) {
30
+ if (!profile.session.actorKinds.includes(actorKind)) {
31
+ throw new Error(`Loaded frontend profile does not expose actor kind '${actorKind}'.`);
32
+ }
33
+ }
34
+ function requirePersonalCapability(profile) {
35
+ if (profile.session.actorKinds.includes(ActorKinds.IndividualController)
36
+ || profile.session.actorKinds.includes(ActorKinds.IndividualMember)) {
37
+ return;
38
+ }
39
+ throw new Error('Loaded frontend profile does not expose one personal-capable actor kind.');
40
+ }
41
+ /**
42
+ * Frontend loaded-profile workspace that keeps the login/profile bootstrap
43
+ * steps explicit and then exposes actor-scoped facades from that loaded
44
+ * profile.
45
+ */
46
+ export class LoadedProfileWorkspace {
47
+ constructor(profileRuntime, loadedProfile, facadeClient) {
48
+ this.profileRuntime = profileRuntime;
49
+ this.facadeClient = facadeClient;
50
+ this.actorSession = new ProfileManager(toSessionProfile(loadedProfile), String(loadedProfile.descriptor.providerDid || ''));
51
+ this.profile = {
52
+ ...loadedProfile,
53
+ actorSession: this.actorSession,
54
+ };
55
+ }
56
+ registerTrustedDevice(input) {
57
+ return registerFrontendTrustedDevice(this.profileRuntime, input);
58
+ }
59
+ connectToSubjectIndex(input) {
60
+ return connectFrontendToSubjectIndex(this.profileRuntime, input);
61
+ }
62
+ getSubjectIndexComposition(input) {
63
+ return getFrontendSubjectIndexComposition(this.profileRuntime, input);
64
+ }
65
+ asHostOnboarding() {
66
+ requireActorKind(this.profile, ActorKinds.HostOnboarding);
67
+ return new HostOnboardingSdk(this.requireFacadeClient('HostOnboardingSdk'));
68
+ }
69
+ asOrganizationController() {
70
+ requireActorKind(this.profile, ActorKinds.OrganizationController);
71
+ return new OrganizationControllerSdk(this.requireFacadeClient('OrganizationControllerSdk'));
72
+ }
73
+ asOrganizationEmployee() {
74
+ requireActorKind(this.profile, ActorKinds.OrganizationEmployee);
75
+ return new OrganizationEmployeeSdk(this.requireFacadeClient('OrganizationEmployeeSdk'));
76
+ }
77
+ asIndividualController() {
78
+ requireActorKind(this.profile, ActorKinds.IndividualController);
79
+ return new IndividualControllerSdk(this.requireFacadeClient('IndividualControllerSdk'));
80
+ }
81
+ asIndividualMember() {
82
+ requireActorKind(this.profile, ActorKinds.IndividualMember);
83
+ return new IndividualMemberSdk(this.requireFacadeClient('IndividualMemberSdk'));
84
+ }
85
+ asPersonal() {
86
+ requirePersonalCapability(this.profile);
87
+ return new PersonalSdk(this.requireFacadeClient('PersonalSdk'));
88
+ }
89
+ asProfessional() {
90
+ requireActorKind(this.profile, ActorKinds.Professional);
91
+ return new ProfessionalSdk(this.requireFacadeClient('ProfessionalSdk'));
92
+ }
93
+ requireFacadeClient(name) {
94
+ if (!this.facadeClient) {
95
+ throw new Error(`${name} requires one FrontRuntimeClient on the loaded frontend profile workspace.`);
96
+ }
97
+ return this.facadeClient;
98
+ }
99
+ }
100
+ /**
101
+ * Frontend counterpart to the backend loaded-profile runtime:
102
+ * inject adapters once, load one protected profile, then work from the
103
+ * returned workspace/session facade instead of one-off helper calls.
104
+ */
105
+ export class ProfileRuntime {
106
+ constructor(profileRuntime, facadeClient) {
107
+ this.profileRuntime = profileRuntime;
108
+ this.facadeClient = facadeClient;
109
+ }
110
+ async loadProfile(input) {
111
+ const profile = await loadFrontendProfile(this.profileRuntime, input);
112
+ return new LoadedProfileWorkspace(this.profileRuntime, profile, this.facadeClient);
113
+ }
114
+ }
115
+ export function createLoadedProfileWorkspace(profileRuntime, loadedProfile, facadeClient) {
116
+ return new LoadedProfileWorkspace(profileRuntime, loadedProfile, facadeClient);
117
+ }
118
+ /**
119
+ * @deprecated Prefer `LoadedProfileWorkspace`.
120
+ */
121
+ export { LoadedProfileWorkspace as FrontendProfileWorkspace };
122
+ /**
123
+ * @deprecated Prefer `ProfileRuntime`.
124
+ */
125
+ export { ProfileRuntime as FrontendProfileWorkspaceRuntime };
126
+ /**
127
+ * @deprecated Prefer `createLoadedProfileWorkspace`.
128
+ */
129
+ export { createLoadedProfileWorkspace as createFrontendProfileWorkspace };
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from './ProfileRegistry.js';
13
13
  export * from './UserProfileIndexStore.js';
14
14
  export * from './ClientSDK.js';
15
15
  export * from './frontend-profile-runtime.js';
16
+ export * from './frontend-profile-workspace.js';
16
17
  export * from './individual-controller-frontend-runtime.js';
17
18
  export * from './discovery/index.js';
18
19
  export * from './orchestration/client-port.js';
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ export * from './ProfileRegistry.js';
14
14
  export * from './UserProfileIndexStore.js';
15
15
  export * from './ClientSDK.js';
16
16
  export * from './frontend-profile-runtime.js';
17
+ export * from './frontend-profile-workspace.js';
17
18
  export * from './individual-controller-frontend-runtime.js';
18
19
  export * from './discovery/index.js';
19
20
  export * from './orchestration/client-port.js';
@@ -1,11 +1,17 @@
1
1
  import type { SubmitAndPollResult } from 'gdc-sdk-core-ts';
2
2
  import type { ProfileLoadRequest } from 'gdc-sdk-core-ts';
3
- import { type FrontendProfileRuntimeClient } from './frontend-profile-runtime.js';
4
- import { IndividualControllerSdk } from './orchestration/individual-controller-sdk.js';
3
+ import type { ProfileManager } from './ProfileManager.js';
4
+ import { type LoadedProfileWorkspace } from './frontend-profile-workspace.js';
5
+ import type { FrontendProfileRuntimeClient } from './frontend-profile-runtime.js';
6
+ import type { IndividualControllerSdk } from './orchestration/individual-controller-sdk.js';
5
7
  import type { FrontClinicalBundleSearchInput, FrontIndividualOrganizationBootstrapInput, FrontIndividualOrganizationConfirmOrderInput, FrontIndividualOrganizationStartResult, FrontRouteContext, FrontRuntimeClient } from './orchestration/client-port.js';
6
8
  import type { LoadedActorProfile } from 'gdc-sdk-core-ts';
7
9
  export type FrontendIndividualControllerProfile = {
8
- profile: LoadedActorProfile;
10
+ profile: LoadedActorProfile & {
11
+ actorSession: ProfileManager;
12
+ };
13
+ workspace: LoadedProfileWorkspace;
14
+ actorSession: ProfileManager;
9
15
  sdk: IndividualControllerSdk;
10
16
  };
11
17
  /**
@@ -1,7 +1,6 @@
1
1
  // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
2
  import { ActorKinds } from 'gdc-common-utils-ts/constants/actor-session';
3
- import { loadFrontendProfile, } from './frontend-profile-runtime.js';
4
- import { IndividualControllerSdk } from './orchestration/individual-controller-sdk.js';
3
+ import { ProfileRuntime, } from './frontend-profile-workspace.js';
5
4
  /**
6
5
  * First pragmatic frontend use-case wrapper on top of the generic v2 profile
7
6
  * runtime.
@@ -20,13 +19,15 @@ export class IndividualControllerFrontendRuntime {
20
19
  * actor capability before materializing the facade.
21
20
  */
22
21
  async loadProfile(input) {
23
- const profile = await loadFrontendProfile(this.profileRuntime, input);
24
- if (!profile.session.actorKinds.includes(ActorKinds.IndividualController)) {
22
+ const workspace = await new ProfileRuntime(this.profileRuntime, this.facadeClient).loadProfile(input);
23
+ if (!workspace.profile.session.actorKinds.includes(ActorKinds.IndividualController)) {
25
24
  throw new Error('Loaded frontend profile does not expose actor kind \'individual_controller\'.');
26
25
  }
27
26
  return {
28
- profile,
29
- sdk: new IndividualControllerSdk(this.facadeClient),
27
+ profile: workspace.profile,
28
+ workspace,
29
+ actorSession: workspace.actorSession,
30
+ sdk: workspace.asIndividualController(),
30
31
  };
31
32
  }
32
33
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-sdk-front-ts",
3
- "version": "2.1.2",
3
+ "version": "2.2.1",
4
4
  "description": "Next-generation frontend runtime package for the GDC SDK family",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Antifraud Services Inc.",
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/runtime": "^7.28.4",
20
- "gdc-common-utils-ts": "^2.1.2",
21
- "gdc-sdk-core-ts": "~2.1.2"
20
+ "gdc-common-utils-ts": "^2.2.2",
21
+ "gdc-sdk-core-ts": "~2.2.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^20.14.10",