gdc-sdk-front-ts 0.2.1 → 0.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.
- package/README.md +291 -93
- package/dist/ClientSDK.d.ts +30 -1
- package/dist/ClientSDK.js +40 -3
- package/dist/actor-session.d.ts +2 -2
- package/dist/actor-session.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lifecycle-examples.d.ts +6 -0
- package/dist/lifecycle-examples.js +7 -0
- package/dist/runtime-contracts.d.ts +1 -1
- package/dist/session-descriptor.d.ts +1 -1
- package/dist/session-descriptor.js +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,118 +1,316 @@
|
|
|
1
1
|
# gdc-sdk-front-ts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Frontend runtime package for consuming the shared GDC SDK contracts in web or
|
|
4
|
+
mobile apps.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Use this package when your frontend needs to:
|
|
6
7
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
8
|
+
- build UI flows on top of GDC shared contracts
|
|
9
|
+
- manage session/profile state
|
|
10
|
+
- prepare consent-aware requests
|
|
11
|
+
- consume the shared invitation, OTP, and relationship-PIN flows
|
|
12
|
+
- work with communication drafts and local outbox patterns
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
This package is frontend-facing. It should explain app flows, not gateway route
|
|
15
|
+
details.
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
- build/test baseline created
|
|
16
|
-
- migration target from `gdc-sdk-client-ts` declared
|
|
17
|
-
- frontend runtime contract skeleton declared
|
|
18
|
-
- shared core identity/discovery/bootstrap contracts are now available for frontend wiring
|
|
17
|
+
## Start Here
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
If you are integrating this package for the first time, open these in order:
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
1. [docs/SDK_INTEGRATION_101.md](./docs/SDK_INTEGRATION_101.md)
|
|
22
|
+
Real frontend/native setup, imports, `new ClientSDK(...)`,
|
|
23
|
+
`initializeCommunicationIdentity(...)`, provider discovery, and
|
|
24
|
+
`initializeSession(...)`.
|
|
25
|
+
2. [gdc-sdk-core-ts/docs/SDK_FLOWS_101.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/SDK_FLOWS_101.md)
|
|
26
|
+
Shared business-flow map by actor family.
|
|
27
|
+
3. [gdc-common-utils-ts/src/examples/frontend-session.ts](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/src/examples/frontend-session.ts)
|
|
28
|
+
Shared profile/session payload source of truth.
|
|
29
|
+
4. [gdc-common-utils-ts/docs/LIFECYCLE_101.md](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/docs/LIFECYCLE_101.md)
|
|
30
|
+
Canonical lifecycle semantics and reusable placeholders for UI and portal flows.
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
If you need the shortest path:
|
|
27
33
|
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
- controller bootstrap helper for `_activate` with `vp_token + controller.*`
|
|
34
|
+
- app identity required by GW CORE:
|
|
35
|
+
`appId` mandatory, `appVersion` optional with default `v1.0`
|
|
36
|
+
- frontend technical identity:
|
|
37
|
+
[`initializeCommunicationIdentity(...)`](./docs/SDK_INTEGRATION_101.md)
|
|
38
|
+
- main runtime class:
|
|
39
|
+
[`ClientSDK`](src/ClientSDK.ts)
|
|
40
|
+
- profile/session bootstrap:
|
|
41
|
+
[`initializeSession(...)`](./docs/SDK_INTEGRATION_101.md)
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
## Executable Usage Examples
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
- `gdc-sdk-front-ts` will own frontend-facing runtime adapters and session/profile orchestration
|
|
42
|
-
- `gdc-sdk-client-ts` is now the legacy source repo for migration, not the final name
|
|
45
|
+
Open these tests when you want to see exact frontend calls and exact inputs:
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
- [tests/client-sdk.test.mjs](tests/client-sdk.test.mjs)
|
|
48
|
+
`ClientSDK` bootstrap, provider metadata, and session-facing behavior.
|
|
49
|
+
- [tests/actor-session.test.mjs](tests/actor-session.test.mjs)
|
|
50
|
+
Actor-session descriptors and facade expansion.
|
|
51
|
+
- [tests/individual-service.test.mjs](tests/individual-service.test.mjs)
|
|
52
|
+
Individual-facing service composition.
|
|
53
|
+
- [tests/profile-registry.test.mjs](tests/profile-registry.test.mjs)
|
|
54
|
+
Profile registry and persistence behavior.
|
|
55
|
+
- [tests/session-descriptor.test.mjs](tests/session-descriptor.test.mjs)
|
|
56
|
+
Session descriptor shaping for UI/runtime code.
|
|
57
|
+
|
|
58
|
+
## Actor Split And UI Scope
|
|
59
|
+
|
|
60
|
+
The frontend package must also start from actor families, because screens and
|
|
61
|
+
permissions differ:
|
|
62
|
+
|
|
63
|
+
- organization controller
|
|
64
|
+
- organization employee / professional member
|
|
65
|
+
- individual controller
|
|
66
|
+
- individual member / self
|
|
67
|
+
- related person
|
|
68
|
+
- professional with consented access
|
|
69
|
+
|
|
70
|
+
Frontend concerns include:
|
|
71
|
+
|
|
72
|
+
- actor/session bootstrap
|
|
73
|
+
- invitation and acceptance UX
|
|
74
|
+
- permission management UX
|
|
75
|
+
- notification / permission-request UX
|
|
76
|
+
- communication draft and submission UX
|
|
77
|
+
- clinical read/write UX constrained by evaluated permissions
|
|
78
|
+
|
|
79
|
+
## Flow Families
|
|
80
|
+
|
|
81
|
+
- organization onboarding and employee invitation screens
|
|
82
|
+
- individual onboarding and order/offer confirmation screens
|
|
83
|
+
- permission creation, edit, deactivation, and grouped views
|
|
84
|
+
- invitation acceptance and relationship activation
|
|
85
|
+
- permission-request notification review
|
|
86
|
+
- document/resource import into the subject index
|
|
87
|
+
- subject-scoped communication and search flows
|
|
88
|
+
|
|
89
|
+
## Main Flows
|
|
90
|
+
|
|
91
|
+
### 1. Controller invites another actor to connect with a subject
|
|
92
|
+
|
|
93
|
+
Typical frontend sequence:
|
|
94
|
+
|
|
95
|
+
1. collect invitee data
|
|
96
|
+
2. build invitation payload using shared helpers
|
|
97
|
+
3. send it through your frontend/backend integration
|
|
98
|
+
4. show invitation state to the user
|
|
99
|
+
|
|
100
|
+
The frontend should only care about the shared contract:
|
|
101
|
+
|
|
102
|
+
- actor kind
|
|
103
|
+
- delivery channel
|
|
104
|
+
- delivery target
|
|
105
|
+
- subject id
|
|
106
|
+
- purpose
|
|
107
|
+
|
|
108
|
+
It should not care about gateway path families.
|
|
109
|
+
|
|
110
|
+
### 2. Invitee accepts the invitation
|
|
111
|
+
|
|
112
|
+
Typical frontend sequence:
|
|
113
|
+
|
|
114
|
+
1. enter invitation or activation details
|
|
115
|
+
2. start OTP challenge
|
|
116
|
+
3. confirm OTP
|
|
117
|
+
4. set relationship PIN if required
|
|
118
|
+
5. activate the relationship locally in UI/session state
|
|
119
|
+
|
|
120
|
+
Shared builders for this flow come from `gdc-sdk-core-ts`.
|
|
121
|
+
|
|
122
|
+
### 3. Consent-aware communication UI
|
|
123
|
+
|
|
124
|
+
Use this package when the frontend needs to:
|
|
125
|
+
|
|
126
|
+
- evaluate whether access is already covered
|
|
127
|
+
- show missing permissions
|
|
128
|
+
- prepare a permission-request `Communication`
|
|
129
|
+
- build local communication drafts before sending
|
|
130
|
+
|
|
131
|
+
## What This Package Owns
|
|
132
|
+
|
|
133
|
+
- frontend runtime config
|
|
134
|
+
- session/profile-facing helpers
|
|
135
|
+
- app-facing composition over shared SDK contracts
|
|
136
|
+
|
|
137
|
+
## What This Package Does Not Own
|
|
138
|
+
|
|
139
|
+
- canonical shared invitation/consent contract definitions
|
|
140
|
+
- Node GW runtime execution
|
|
141
|
+
- UNID-specific reminder/task runtime
|
|
142
|
+
|
|
143
|
+
Those belong to:
|
|
144
|
+
|
|
145
|
+
- `gdc-sdk-core-ts`
|
|
146
|
+
- `gdc-sdk-node-ts`
|
|
147
|
+
- product/runtime extension layers
|
|
148
|
+
|
|
149
|
+
## Minimal Examples
|
|
150
|
+
|
|
151
|
+
### Build invitation and OTP payloads in frontend code
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import {
|
|
155
|
+
createRelationshipChannelInvitationInput,
|
|
156
|
+
createRelationshipChannelOtpStartInput,
|
|
157
|
+
RelationshipAccessActorKinds,
|
|
158
|
+
RelationshipEnrollmentChannels,
|
|
159
|
+
RelationshipOtpDeliveryChannels,
|
|
160
|
+
RelationshipSubjectKinds,
|
|
161
|
+
type RelationshipChannelInvitationInput,
|
|
162
|
+
type RelationshipChannelOtpStartInput,
|
|
163
|
+
} from 'gdc-sdk-core-ts';
|
|
164
|
+
import {
|
|
165
|
+
buildIndividualDidWeb,
|
|
166
|
+
HealthcareConsentPurposes,
|
|
167
|
+
} from 'gdc-common-utils-ts';
|
|
168
|
+
|
|
169
|
+
const tenantId = 'acme-id';
|
|
170
|
+
const jurisdiction = 'ES';
|
|
171
|
+
const sector = 'health-care';
|
|
172
|
+
const providerOrganizationDid = activeSubjectProfile.organizationDid;
|
|
173
|
+
const subjectLocalId = activeSubjectProfile.subjectId;
|
|
174
|
+
const subjectId = buildIndividualDidWeb({
|
|
175
|
+
organizationDidWeb: providerOrganizationDid,
|
|
176
|
+
subjectId: subjectLocalId,
|
|
177
|
+
});
|
|
178
|
+
const actorIdentifier = relatedPersonForm.email;
|
|
179
|
+
const deliveryTarget = actorIdentifier;
|
|
180
|
+
|
|
181
|
+
const invitationInput: RelationshipChannelInvitationInput = {
|
|
182
|
+
tenantId,
|
|
183
|
+
jurisdiction,
|
|
184
|
+
sector,
|
|
185
|
+
subjectId,
|
|
186
|
+
subjectKind: RelationshipSubjectKinds.Person,
|
|
187
|
+
actorKind: RelationshipAccessActorKinds.RelatedPerson,
|
|
188
|
+
actorIdentifier,
|
|
189
|
+
relationshipLabel: 'daughter',
|
|
190
|
+
deliveryChannel: RelationshipEnrollmentChannels.Email,
|
|
191
|
+
deliveryTarget,
|
|
192
|
+
purpose: HealthcareConsentPurposes.CareManagement,
|
|
193
|
+
phonePinOptional: true,
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const invitation = createRelationshipChannelInvitationInput(invitationInput);
|
|
197
|
+
|
|
198
|
+
const invitationId = 'rel-invite-001';
|
|
199
|
+
|
|
200
|
+
const otpStartInput: RelationshipChannelOtpStartInput = {
|
|
201
|
+
invitationId,
|
|
202
|
+
deliveryChannel: RelationshipOtpDeliveryChannels.Email,
|
|
203
|
+
locale: 'es-ES',
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const otpStart = createRelationshipChannelOtpStartInput(otpStartInput);
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Build permission-request communication
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import {
|
|
213
|
+
buildPermissionRequestCommunication,
|
|
214
|
+
getMissingPermissions,
|
|
215
|
+
} from 'gdc-sdk-core-ts';
|
|
216
|
+
import {
|
|
217
|
+
EXAMPLE_EMAIL_PROFESSIONAL,
|
|
218
|
+
EXAMPLE_INDIVIDUAL_DID_WEB,
|
|
219
|
+
} from 'gdc-common-utils-ts/examples/consent-access';
|
|
220
|
+
import { HealthcareActorRoles } from 'gdc-common-utils-ts/constants/healthcare';
|
|
221
|
+
|
|
222
|
+
const individualDidWeb = EXAMPLE_INDIVIDUAL_DID_WEB;
|
|
223
|
+
const emailProfessional = EXAMPLE_EMAIL_PROFESSIONAL;
|
|
224
|
+
const missing = getMissingPermissions(evaluation);
|
|
225
|
+
|
|
226
|
+
const communication = buildPermissionRequestCommunication({
|
|
227
|
+
subject: individualDidWeb,
|
|
228
|
+
requester: { actorKind: 'professional', email: emailProfessional },
|
|
229
|
+
requesterRole: HealthcareActorRoles.Physician,
|
|
230
|
+
missing,
|
|
231
|
+
});
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Shared Contract Sources
|
|
235
|
+
|
|
236
|
+
- [gdc-sdk-core-ts/README.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/README.md)
|
|
237
|
+
- [gdc-common-utils-ts/docs/CONSENT_ACCESS_101.md](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/docs/CONSENT_ACCESS_101.md)
|
|
238
|
+
|
|
239
|
+
Reusable payload examples:
|
|
45
240
|
|
|
46
241
|
- `gdc-common-utils-ts/examples/frontend-session`
|
|
47
|
-
- session/profile bootstrap examples
|
|
48
242
|
- `gdc-common-utils-ts/examples/professional`
|
|
49
|
-
|
|
50
|
-
- reusable professional role/permission scenarios by section and expected FHIR types
|
|
51
|
-
- reusable consent-vs-smart matrices for actor targeting by email, organization, or jurisdiction
|
|
243
|
+
- `gdc-common-utils-ts/examples/lifecycle`
|
|
52
244
|
- `gdc-common-utils-ts/examples/api-flow-examples`
|
|
53
|
-
- preferred compatibility aggregator when one import surface is needed without using the overloaded term `contract`
|
|
54
245
|
|
|
55
|
-
|
|
246
|
+
## API Index
|
|
56
247
|
|
|
57
|
-
|
|
58
|
-
- phone-only subject/controller fields are compatibility or product-extension concerns, not required CORE GW inputs
|
|
59
|
-
- individual/family bootstrap uses `org.schema.Organization.owner.*` claims for the owner/controller of the subject index
|
|
60
|
-
- legal organization activation uses `Person` representative semantics plus VC `memberOf` / `hasOccupation`
|
|
248
|
+
## Full Public Surface
|
|
61
249
|
|
|
62
|
-
|
|
250
|
+
This package exports the full `gdc-sdk-core-ts` surface plus the frontend
|
|
251
|
+
runtime modules below.
|
|
252
|
+
|
|
253
|
+
- [`src/runtime-contracts.ts`](src/runtime-contracts.ts)
|
|
254
|
+
- types/constants: `LegacyFrontSourcePackage`, `FrontRuntimeKind`, `FrontFetchLike`, `FrontRuntimeConfig`, `FrontPackageStatus`, `GDC_SDK_FRONT_STATUS`
|
|
255
|
+
- [`src/actor-session.ts`](src/actor-session.ts)
|
|
256
|
+
- re-exports actor-session descriptor helpers for frontend consumption
|
|
257
|
+
- [`src/session-descriptor.ts`](src/session-descriptor.ts)
|
|
258
|
+
- types: `FrontActorFlags`, `FrontSessionDescriptorInput`
|
|
259
|
+
- functions: `describeFrontActorSession(...)`, `describeFrontActorFacades(...)`
|
|
260
|
+
- [`src/types.ts`](src/types.ts)
|
|
261
|
+
- types: `SdkConfig`, `FrontDateRange`, `FrontBundleSearchQuery`, `FrontCommunicationInput`
|
|
262
|
+
- re-exported shared types: `AppInfo`, `InitializeSessionParams`, `Profile`, `ProfileRegistryEntry`, `VaultQueryCondition`, `VaultQuery`, `IVaultRepository`, `IApiConfig`, `INetwork`, `IVerifier`
|
|
263
|
+
- [`src/services.ts`](src/services.ts)
|
|
264
|
+
- classes: `CommonAuthService`, `OrgAdminService`, `FamilyAdminService`, `IndividualService`, `PhysicianService`, `ParamedicService`
|
|
265
|
+
- [`src/roleRegistry.ts`](src/roleRegistry.ts)
|
|
266
|
+
- interfaces: `OrgAdminServices`, `FamilyAdminServices`, `IndividualServices`, `ProfessionalServices`, `CommonServices`
|
|
267
|
+
- [`src/capabilityMapper.ts`](src/capabilityMapper.ts)
|
|
268
|
+
- function: `mapCapabilitiesToServices(...)`
|
|
269
|
+
- [`src/VerifierService.ts`](src/VerifierService.ts)
|
|
270
|
+
- class: `VerifierService`
|
|
271
|
+
- [`src/ProfileManager.ts`](src/ProfileManager.ts)
|
|
272
|
+
- class: `ProfileManager`
|
|
273
|
+
- compatibility export: `ActorSession`
|
|
274
|
+
- [`src/ProfileRegistry.ts`](src/ProfileRegistry.ts)
|
|
275
|
+
- class: `ProfileRegistry`
|
|
276
|
+
- [`src/ClientSDK.ts`](src/ClientSDK.ts)
|
|
277
|
+
- class: `ClientSDK`
|
|
278
|
+
- re-exported session/profile types from shared contracts
|
|
63
279
|
|
|
64
|
-
The
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
- [`createBloodPressureObservation(...)`](../gdc-sdk-core-ts/src/vital-signs.ts)
|
|
85
|
-
|
|
86
|
-
### Consent access helpers re-exported from `gdc-sdk-core-ts`
|
|
87
|
-
|
|
88
|
-
- [`groupConsentsForControllerView(...)`](../gdc-sdk-core-ts/src/consent-access.ts)
|
|
89
|
-
- [`evaluateRequestedAccess(...)`](../gdc-sdk-core-ts/src/consent-access.ts)
|
|
90
|
-
- [`getMissingPermissions(...)`](../gdc-sdk-core-ts/src/consent-access.ts)
|
|
91
|
-
- [`buildPermissionRequestCommunication(...)`](../gdc-sdk-core-ts/src/consent-access.ts)
|
|
92
|
-
- [`buildPermissionRequestCommunicationLookupQuery(...)`](../gdc-sdk-core-ts/src/consent-access.ts)
|
|
93
|
-
|
|
94
|
-
Use these helpers when the frontend needs to:
|
|
95
|
-
|
|
96
|
-
- show the controller which active permissions exist by target
|
|
97
|
-
- detect whether a SMART request is fully covered
|
|
98
|
-
- prepare the canonical permission-request `Communication`
|
|
99
|
-
- recover that request by identifier, thread id, or linked CID
|
|
100
|
-
|
|
101
|
-
Consent precedence in the shared model is documented as:
|
|
102
|
-
|
|
103
|
-
1. explicit deny for a concrete email
|
|
104
|
-
2. explicit permit for a concrete email
|
|
105
|
-
3. organization decision
|
|
106
|
-
4. jurisdiction decision
|
|
107
|
-
5. default deny
|
|
108
|
-
|
|
109
|
-
### Runtime configuration
|
|
280
|
+
The runtime-facing meaning of these exports is:
|
|
281
|
+
|
|
282
|
+
- `ClientSDK`, `ProfileManager`, `ProfileRegistry`, `VerifierService`
|
|
283
|
+
- app/session orchestration
|
|
284
|
+
- `services.ts`
|
|
285
|
+
- app-facing domain services
|
|
286
|
+
- `session-descriptor.ts` and `actor-session.ts`
|
|
287
|
+
- actor-role expansion for frontend use
|
|
288
|
+
- `capabilityMapper.ts` and `roleRegistry.ts`
|
|
289
|
+
- capability-to-service wiring
|
|
290
|
+
|
|
291
|
+
### Re-exported shared helpers from `gdc-sdk-core-ts`
|
|
292
|
+
|
|
293
|
+
- consent access helpers
|
|
294
|
+
- relationship invitation/acceptance builders
|
|
295
|
+
- communication draft helpers
|
|
296
|
+
- document facade helpers
|
|
297
|
+
- vital-sign helpers
|
|
298
|
+
|
|
299
|
+
### Frontend runtime configuration
|
|
110
300
|
|
|
111
301
|
- [`FrontRuntimeConfig`](src/runtime-contracts.ts)
|
|
112
|
-
- Includes `persistencePolicy?` and `outboxRepositoryFactory?` so frontend runtimes can disable local persistence on shared devices or use secure local storage on confidential devices.
|
|
113
302
|
|
|
114
|
-
###
|
|
303
|
+
### Frontend runtime services
|
|
304
|
+
|
|
305
|
+
- [`ClientSDK`](src/ClientSDK.ts)
|
|
306
|
+
- [`ProfileManager`](src/ProfileManager.ts)
|
|
307
|
+
- [`ProfileRegistry`](src/ProfileRegistry.ts)
|
|
308
|
+
- [`VerifierService`](src/VerifierService.ts)
|
|
309
|
+
- [`describeFrontActorSession(...)`](src/actor-session.ts)
|
|
310
|
+
- [`describeFrontActorFacades(...)`](src/actor-session.ts)
|
|
311
|
+
|
|
312
|
+
## Documentation Rule
|
|
115
313
|
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
314
|
+
- README should explain app flows first.
|
|
315
|
+
- Shared contract definitions should stay in `gdc-sdk-core-ts`.
|
|
316
|
+
- Frontend consumers should not need UNID runtime knowledge to understand this package.
|
package/dist/ClientSDK.d.ts
CHANGED
|
@@ -1,6 +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
5
|
/**
|
|
5
6
|
* Frontend-facing SDK entry point for profile/session bootstrapping, lightweight
|
|
6
7
|
* provider discovery, and role-scoped session creation.
|
|
@@ -19,16 +20,44 @@ export declare class ClientSDK {
|
|
|
19
20
|
private readonly _verifier;
|
|
20
21
|
private readonly _icaDid?;
|
|
21
22
|
private readonly mockDidDocuments;
|
|
23
|
+
private readonly resolvedAppInfo;
|
|
22
24
|
currentSession: ProfileManager | null;
|
|
23
25
|
profileRegistry: ProfileRegistry | null;
|
|
24
26
|
/**
|
|
25
27
|
* @param sdkConfig Frontend runtime adapters such as fetch/network/api.
|
|
26
|
-
* @param appInfo Information about the host app.
|
|
28
|
+
* @param appInfo Information about the host app. `appId` is mandatory and
|
|
29
|
+
* may be a reverse-DNS string or a URL/domain. `appVersion` is optional and
|
|
30
|
+
* defaults to `v1.0`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const sdk = new ClientSDK(
|
|
35
|
+
* { network, api, fetcher: fetch },
|
|
36
|
+
* {
|
|
37
|
+
* appId: 'https://globaldatacare.es/portal',
|
|
38
|
+
* appType: 'Family',
|
|
39
|
+
* sector: 'health-care',
|
|
40
|
+
* },
|
|
41
|
+
* wallet,
|
|
42
|
+
* verifier,
|
|
43
|
+
* );
|
|
44
|
+
*
|
|
45
|
+
* console.log(sdk.getAppHeaders());
|
|
46
|
+
* // { AppId: 'es.globaldatacare', AppVersion: 'v1.0' }
|
|
47
|
+
* ```
|
|
27
48
|
* @param _wallet Reserved wallet/provider dependency.
|
|
28
49
|
* @param _verifier DID/VC verifier dependency.
|
|
29
50
|
* @param _icaDid Optional bootstrap ICA DID used by the host app.
|
|
30
51
|
*/
|
|
31
52
|
constructor(sdkConfig: SdkConfig, appInfo: AppInfo, _wallet: unknown, _verifier: IVerifier, _icaDid?: string | undefined);
|
|
53
|
+
/**
|
|
54
|
+
* Returns the canonical GW CORE app identity resolved by the SDK.
|
|
55
|
+
*/
|
|
56
|
+
getResolvedAppInfo(): ResolvedAppInfo;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the standard GW CORE headers added by the SDK to outbound requests.
|
|
59
|
+
*/
|
|
60
|
+
getAppHeaders(): Record<'AppId' | 'AppVersion', string>;
|
|
32
61
|
/**
|
|
33
62
|
* Registers a mock DID document for local/demo discovery flows.
|
|
34
63
|
*/
|
package/dist/ClientSDK.js
CHANGED
|
@@ -1,6 +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
5
|
/**
|
|
5
6
|
* Frontend-facing SDK entry point for profile/session bootstrapping, lightweight
|
|
6
7
|
* provider discovery, and role-scoped session creation.
|
|
@@ -15,7 +16,26 @@ import { ProfileRegistry } from './ProfileRegistry.js';
|
|
|
15
16
|
export class ClientSDK {
|
|
16
17
|
/**
|
|
17
18
|
* @param sdkConfig Frontend runtime adapters such as fetch/network/api.
|
|
18
|
-
* @param appInfo Information about the host app.
|
|
19
|
+
* @param appInfo Information about the host app. `appId` is mandatory and
|
|
20
|
+
* may be a reverse-DNS string or a URL/domain. `appVersion` is optional and
|
|
21
|
+
* defaults to `v1.0`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const sdk = new ClientSDK(
|
|
26
|
+
* { network, api, fetcher: fetch },
|
|
27
|
+
* {
|
|
28
|
+
* appId: 'https://globaldatacare.es/portal',
|
|
29
|
+
* appType: 'Family',
|
|
30
|
+
* sector: 'health-care',
|
|
31
|
+
* },
|
|
32
|
+
* wallet,
|
|
33
|
+
* verifier,
|
|
34
|
+
* );
|
|
35
|
+
*
|
|
36
|
+
* console.log(sdk.getAppHeaders());
|
|
37
|
+
* // { AppId: 'es.globaldatacare', AppVersion: 'v1.0' }
|
|
38
|
+
* ```
|
|
19
39
|
* @param _wallet Reserved wallet/provider dependency.
|
|
20
40
|
* @param _verifier DID/VC verifier dependency.
|
|
21
41
|
* @param _icaDid Optional bootstrap ICA DID used by the host app.
|
|
@@ -29,6 +49,19 @@ export class ClientSDK {
|
|
|
29
49
|
this.mockDidDocuments = new Map();
|
|
30
50
|
this.currentSession = null;
|
|
31
51
|
this.profileRegistry = null;
|
|
52
|
+
this.resolvedAppInfo = resolveAppInfo(appInfo);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns the canonical GW CORE app identity resolved by the SDK.
|
|
56
|
+
*/
|
|
57
|
+
getResolvedAppInfo() {
|
|
58
|
+
return { ...this.resolvedAppInfo };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns the standard GW CORE headers added by the SDK to outbound requests.
|
|
62
|
+
*/
|
|
63
|
+
getAppHeaders() {
|
|
64
|
+
return buildAppHeaders(this.resolvedAppInfo);
|
|
32
65
|
}
|
|
33
66
|
/**
|
|
34
67
|
* Registers a mock DID document for local/demo discovery flows.
|
|
@@ -41,7 +74,9 @@ export class ClientSDK {
|
|
|
41
74
|
*/
|
|
42
75
|
async fetchWellKnownApiConfig(source) {
|
|
43
76
|
const baseUrl = await this.resolveBaseUrl(source);
|
|
44
|
-
const response = await this.sdkConfig.fetcher(new URL('.well-known/api-config.json', baseUrl).href
|
|
77
|
+
const response = await this.sdkConfig.fetcher(new URL('.well-known/api-config.json', baseUrl).href, {
|
|
78
|
+
headers: this.getAppHeaders(),
|
|
79
|
+
});
|
|
45
80
|
if (!response.ok) {
|
|
46
81
|
throw new Error(`Failed to load API config (${response.status}).`);
|
|
47
82
|
}
|
|
@@ -52,7 +87,9 @@ export class ClientSDK {
|
|
|
52
87
|
*/
|
|
53
88
|
async fetchSupportedFields(source) {
|
|
54
89
|
const baseUrl = await this.resolveBaseUrl(source);
|
|
55
|
-
const response = await this.sdkConfig.fetcher(new URL('.well-known/supported-fields.json', baseUrl).href
|
|
90
|
+
const response = await this.sdkConfig.fetcher(new URL('.well-known/supported-fields.json', baseUrl).href, {
|
|
91
|
+
headers: this.getAppHeaders(),
|
|
92
|
+
});
|
|
56
93
|
if (!response.ok)
|
|
57
94
|
return [];
|
|
58
95
|
const body = await response.json();
|
package/dist/actor-session.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { ActorFacadeDescriptor, ActorKind, ActorSessionDescriptor, Capability, } from '
|
|
2
|
-
export { expandActorSessionDescriptorToFacades, filterCapabilitiesForActor, } from '
|
|
1
|
+
export type { ActorFacadeDescriptor, ActorKind, ActorSessionDescriptor, Capability, } from 'gdc-sdk-core-ts';
|
|
2
|
+
export { expandActorSessionDescriptorToFacades, filterCapabilitiesForActor, } from 'gdc-sdk-core-ts';
|
package/dist/actor-session.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
-
export { expandActorSessionDescriptorToFacades, filterCapabilitiesForActor, } from '
|
|
2
|
+
export { expandActorSessionDescriptorToFacades, filterCapabilitiesForActor, } from 'gdc-sdk-core-ts';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
-
export * from '
|
|
2
|
+
export * from 'gdc-sdk-core-ts';
|
|
3
3
|
export * from './runtime-contracts.js';
|
|
4
4
|
export * from './actor-session.js';
|
|
5
5
|
export * from './session-descriptor.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
/**
|
|
3
|
+
* Re-export canonical lifecycle examples for frontend consumers.
|
|
4
|
+
*
|
|
5
|
+
* Frontend code should render or adapt these examples, not fork them.
|
|
6
|
+
*/
|
|
7
|
+
export * from 'gdc-common-utils-ts/examples/lifecycle';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataPersistencePolicy } from '
|
|
1
|
+
import type { DataPersistencePolicy } from 'gdc-sdk-core-ts';
|
|
2
2
|
export type LegacyFrontSourcePackage = never;
|
|
3
3
|
export type FrontRuntimeKind = 'expo' | 'web' | 'react-native';
|
|
4
4
|
export type FrontFetchLike = typeof fetch;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActorFlags, ActorFacadeDescriptor, ActorSessionDescriptor } from '
|
|
1
|
+
import type { ActorFlags, ActorFacadeDescriptor, ActorSessionDescriptor } from 'gdc-sdk-core-ts';
|
|
2
2
|
export type FrontActorFlags = ActorFlags;
|
|
3
3
|
export type FrontSessionDescriptorInput = {
|
|
4
4
|
appType: 'Organization' | 'Family';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
-
import { buildActorSessionDescriptorFromActorFlags, expandActorSessionDescriptorToFacades, } from '
|
|
2
|
+
import { buildActorSessionDescriptorFromActorFlags, expandActorSessionDescriptorToFacades, } from 'gdc-sdk-core-ts';
|
|
3
3
|
export function describeFrontActorSession(input) {
|
|
4
4
|
return buildActorSessionDescriptorFromActorFlags(input);
|
|
5
5
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IApiConfig, INetwork, BundleSearchQuery, CommunicationInput, DateRange } from '
|
|
2
|
-
export type { AppInfo, InitializeSessionParams, Profile, ProfileRegistryEntry, VaultQueryCondition, VaultQuery, IVaultRepository, IApiConfig, INetwork, IVerifier } from '
|
|
1
|
+
import type { IApiConfig, INetwork, BundleSearchQuery, CommunicationInput, DateRange } from 'gdc-sdk-core-ts';
|
|
2
|
+
export type { AppInfo, ResolvedAppInfo, InitializeSessionParams, Profile, ProfileRegistryEntry, VaultQueryCondition, VaultQuery, IVaultRepository, IApiConfig, INetwork, IVerifier } from 'gdc-sdk-core-ts';
|
|
3
3
|
export type SdkConfig = {
|
|
4
4
|
crypto?: unknown;
|
|
5
5
|
network: INetwork;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdc-sdk-front-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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,7 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime": "^7.28.4",
|
|
20
|
-
"gdc-common-utils-ts": "^1.
|
|
20
|
+
"gdc-common-utils-ts": "^1.7.0",
|
|
21
|
+
"gdc-sdk-core-ts": "^0.3.2"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@types/node": "^20.14.10",
|