dataspace-client-sdk-node 0.2.2 → 0.2.4

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 (33) hide show
  1. package/README.md +13 -14
  2. package/docs/API.md +14 -13
  3. package/docs/DEVELOPER_USE_CASES.md +4 -12
  4. package/package.json +1 -1
  5. package/src/types.ts +8 -0
  6. package/TODO_PROMPT_NEXT_STEPS.md +0 -185
  7. package/artifacts/update-smart-wallet.js +0 -1016
  8. package/dist/builders.d.ts +0 -12
  9. package/dist/builders.js +0 -17
  10. package/dist/client.d.ts +0 -453
  11. package/dist/client.js +0 -1755
  12. package/dist/consent/pdfSignatureVerification.d.ts +0 -18
  13. package/dist/consent/pdfSignatureVerification.js +0 -23
  14. package/dist/index.d.ts +0 -5
  15. package/dist/index.js +0 -9
  16. package/dist/sdk/dataspace-wallet-sdk-node/MultiWalletClient.d.ts +0 -9
  17. package/dist/sdk/dataspace-wallet-sdk-node/MultiWalletClient.js +0 -21
  18. package/dist/sdk/dataspace-wallet-sdk-node/WalletClient.d.ts +0 -26
  19. package/dist/sdk/dataspace-wallet-sdk-node/WalletClient.js +0 -36
  20. package/dist/sdk/dataspace-wallet-sdk-node/index.d.ts +0 -6
  21. package/dist/sdk/dataspace-wallet-sdk-node/index.js +0 -6
  22. package/dist/sdk/dataspace-wallet-sdk-node/provider.d.ts +0 -24
  23. package/dist/sdk/dataspace-wallet-sdk-node/provider.js +0 -1
  24. package/dist/sdk/dataspace-wallet-sdk-node/providers/memory-provider.d.ts +0 -41
  25. package/dist/sdk/dataspace-wallet-sdk-node/providers/memory-provider.js +0 -216
  26. package/dist/sdk/dataspace-wallet-sdk-node/providers/seed-provider.d.ts +0 -22
  27. package/dist/sdk/dataspace-wallet-sdk-node/providers/seed-provider.js +0 -28
  28. package/dist/sdk/dataspace-wallet-sdk-node/types.d.ts +0 -51
  29. package/dist/sdk/dataspace-wallet-sdk-node/types.js +0 -1
  30. package/dist/types.d.ts +0 -556
  31. package/dist/types.js +0 -1
  32. package/dist/vp-token.d.ts +0 -37
  33. package/dist/vp-token.js +0 -56
package/README.md CHANGED
@@ -4,20 +4,19 @@ Node.js SDK to consume GW/UNID async DIDComm endpoints.
4
4
 
5
5
  ## Documentation Index
6
6
 
7
- 1. [Full API Reference](docs/API.md)
8
- 2. [Data Model Alignment (GW + Chat + SDK)](docs/DATA_MODEL_ALIGNMENT.md)
9
- 3. [Frontend/Backend SDK Ownership Matrix](../docs/SDK_AUTH_OWNERSHIP.md)
10
- 4. [Developer Use-Case Cookbook (UC5 + additional patterns)](docs/DEVELOPER_USE_CASES.md)
11
- 5. [Live Local GW UC5 E2E (no mocks)](docs/E2E_LOCAL_GW_UC5.md)
12
- 6. [React Web Integration Guide](docs/REACT_WEB_INTEGRATION.md)
13
- 7. [Backend Node Integration Guide](docs/BACKEND_NODE_INTEGRATION.md)
14
- 8. [Controller Flow Step by Step](docs/CONTROLLER_FLOW_STEP_BY_STEP.md)
15
- 9. [Legal Organization Flow Step by Step](docs/LEGAL_ORGANIZATION_FLOW_STEP_BY_STEP.md)
16
- 10. [Practitioner Flow Step by Step](docs/PRACTITIONER_FLOW_STEP_BY_STEP.md)
17
- 11. [Portal Backend Integration Handover](docs/PORTAL_BACKEND_INTEGRATION_HANDOVER.md)
7
+ 1. [Legal Organization Flow Step by Step](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/LEGAL_ORGANIZATION_FLOW_STEP_BY_STEP.md)
8
+ 2. [Practitioner Flow Step by Step](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/PRACTITIONER_FLOW_STEP_BY_STEP.md)
9
+ 3. [Personal Flow Step by Step](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/PERSONAL_FLOW_STEP_BY_STEP.md)
10
+ 4. [Controller Flow Step by Step](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/CONTROLLER_FLOW_STEP_BY_STEP.md)
11
+ 5. [Live Local GW UC5 E2E (no mocks)](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/E2E_LOCAL_GW_UC5.md)
12
+ 6. [Backend Node Integration Guide](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/BACKEND_NODE_INTEGRATION.md)
13
+ 7. [Full API Reference](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/API.md)
14
+ 8. [Developer Use-Case Cookbook (secondary examples)](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/DEVELOPER_USE_CASES.md)
15
+ 9. [Data Model Alignment (GW + Chat + SDK)](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/DATA_MODEL_ALIGNMENT.md)
16
+ 10. [React Web Integration Guide](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/REACT_WEB_INTEGRATION.md)
17
+ 11. [Portal Backend Integration Handover](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/PORTAL_BACKEND_INTEGRATION_HANDOVER.md)
18
18
 
19
19
  ## TODO and Roadmap
20
20
 
21
- 1. [Prompt Next Steps TODO](TODO_PROMPT_NEXT_STEPS.md)
22
- 2. [SMART EHR Compatibility TODO](docs/TODO_SMART_EHR_COMPAT.md)
23
- 3. [SDK Parity Map](../SDK_PARITY_MAP.md)
21
+ 1. [Prompt Next Steps TODO](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/TODO_PROMPT_NEXT_STEPS.md)
22
+ 2. [SMART EHR Compatibility TODO](https://github.com/Global-DataCare/dataspace-client-sdk-node/blob/main/docs/TODO_SMART_EHR_COMPAT.md)
package/docs/API.md CHANGED
@@ -139,10 +139,10 @@ type CreatePhoneReminderTasksInput = {
139
139
  windows: Array<{ offsetMinutes: number; remindAt: string }>; // remindAt = ISO-8601
140
140
  locale?: string;
141
141
  callSid?: string;
142
- notificationPhone?: string;
143
- controllerPhone?: string;
144
- subjectRef: string; // e.g. 'Person/+34600000001'
145
- ownerRef: string; // e.g. 'RelatedPerson/+34699999999'
142
+ notificationPhone?: string; // optional legacy/fallback only
143
+ controllerPhone?: string; // optional legacy/fallback only
144
+ subjectRef: string; // e.g. 'Person/subject-uuid' or 'Person/mailto:subject@example.com'
145
+ ownerRef: string; // e.g. 'RelatedPerson/controller-uuid' or 'RelatedPerson/mailto:controller@example.com'
146
146
  focusRef: string; // e.g. 'Appointment/2026-05-10T10:00:00.000Z'
147
147
  reminderSummary?: string;
148
148
  description?: string;
@@ -252,7 +252,7 @@ const ctx: RouteContext = { tenantId: 'acme', jurisdiction: 'ES', sector: 'healt
252
252
 
253
253
  // Register or resume a family organization
254
254
  const payload = createDidcommPlainMessage({
255
- iss: '+34600000001',
255
+ iss: 'mailto:controller@example.com',
256
256
  aud: 'did:web:api.acme.org',
257
257
  body: {
258
258
  data: [{
@@ -260,9 +260,9 @@ const payload = createDidcommPlainMessage({
260
260
  meta: {
261
261
  claims: {
262
262
  '@context': 'org.schema',
263
- 'org.schema.Organization.telephone': '+34611111111', // notification phone (subject)
264
- 'org.schema.Organization.creator': '+34600000001', // controller phone
265
- 'org.schema.Organization.owner.telephone': '+34600000001', // controller (indexed)
263
+ 'org.schema.Organization.email': 'subject@example.com', // subject contact (primary)
264
+ 'org.schema.Organization.creator': 'mailto:controller@example.com', // controller (primary)
265
+ 'org.schema.Organization.owner.email': 'controller@example.com', // controller (indexed)
266
266
  'org.schema.Organization.alternateName': 'Maria', // usualname (indexed)
267
267
  'org.schema.Service.category': 'health-care',
268
268
  'org.schema.Organization.addressCountry': 'ES',
@@ -667,6 +667,8 @@ console.log(poll.status, poll.attempts);
667
667
  ### `createPhoneReminderTasks`
668
668
 
669
669
  Creates one reminder `Task` per reminder window via `individual/Task/_batch`.
670
+ Primary identity channels are `subjectRef` and `ownerRef` (UUID/email/DID references).
671
+ `notificationPhone` and `controllerPhone` are optional compatibility fields.
670
672
 
671
673
  Each window maps to one deterministic task ID (SHA-256 of routing context + refs + `remindAt`).
672
674
 
@@ -686,10 +688,8 @@ const result = await client.createPhoneReminderTasks(ctx, {
686
688
  { offsetMinutes: 60, remindAt: '2026-05-10T09:00:00.000Z' }, // 1 hour before
687
689
  ],
688
690
  locale: 'es-ES',
689
- notificationPhone: '+34611111111',
690
- controllerPhone: '+34600000001',
691
- subjectRef: 'Person/+34611111111',
692
- ownerRef: 'RelatedPerson/+34600000001',
691
+ subjectRef: 'Person/subject-uuid',
692
+ ownerRef: 'RelatedPerson/controller-uuid',
693
693
  focusRef: 'Appointment/2026-05-10T10:00:00.000Z',
694
694
  reminderSummary: '10/05 10:00 | Hospital San Juan | Consulta cardiología',
695
695
  maxAttempts: 3,
@@ -702,7 +702,8 @@ console.log(result.poll.status); // 200 if all tasks created
702
702
 
703
703
  ### `searchFamilyOrganization`
704
704
 
705
- Search for an existing family organization by controller phone + usualname. Returns `null` when not found.
705
+ Legacy helper: search an existing family organization by controller phone + usualname.
706
+ For portal onboarding, use email-based registration flow docs (`PERSONAL_FLOW_STEP_BY_STEP.md`).
706
707
 
707
708
  ```ts
708
709
  searchFamilyOrganization(
@@ -19,7 +19,7 @@ const client = new DataspaceNodeClient({
19
19
  });
20
20
 
21
21
  const ctx = {
22
- tenantId: 'acme',
22
+ tenantId: 'VATES-B00112233',
23
23
  jurisdiction: 'ES',
24
24
  sector: 'health-care',
25
25
  };
@@ -126,7 +126,7 @@ Scope namespace note:
126
126
 
127
127
  ```ts
128
128
  const consent = await client.grantProfessionalAccessSimple(ctx, {
129
- subjectPhone: '+34600111222',
129
+ subjectDid: 'did:web:subject.example.com',
130
130
  subjectGivenName: 'Ana',
131
131
  actor: { identifier: 'did:web:hospital.example.com' },
132
132
  actorRole: 'Practitioner',
@@ -201,7 +201,7 @@ await client.grantProfessionalAccessSimple(ctx, {
201
201
  });
202
202
  ```
203
203
 
204
- ### C) Actor by email/phone + role
204
+ ### C) Actor by email + role (portal-first)
205
205
 
206
206
  ```ts
207
207
  await client.grantProfessionalAccessSimple(ctx, {
@@ -213,15 +213,7 @@ await client.grantProfessionalAccessSimple(ctx, {
213
213
  });
214
214
  ```
215
215
 
216
- ```ts
217
- await client.grantProfessionalAccessSimple(ctx, {
218
- subjectDid: 'did:web:subject.example.com',
219
- actor: { phone: '+34600111222' }, // maps to urn:tel:+34600111222
220
- actorRole: 'Practitioner',
221
- purpose: 'TREAT',
222
- actions: ['organization/AppointmentResponse.cruds'],
223
- });
224
- ```
216
+ Phone-based actor identifiers are supported for compatibility flows, but email/DID are the primary portal channels.
225
217
 
226
218
  ### D) Jurisdiction + role (explicit claims)
227
219
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dataspace-client-sdk-node",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Node.js SDK for DIDComm plain batch + async polling flows",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Antifraud Services Inc.",
package/src/types.ts CHANGED
@@ -436,7 +436,15 @@ export type CreatePhoneReminderTasksInput = {
436
436
  * in backend task execution. Provide this only for audit/fallback/optimization.
437
437
  */
438
438
  controllerPhone?: string;
439
+ /**
440
+ * Canonical subject reference (preferred): UUID/resource reference, email-based ref, or DID ref.
441
+ * Example: `Person/subject-uuid`, `Person/mailto:subject@example.com`, `Person/did:web:...`.
442
+ */
439
443
  subjectRef: string;
444
+ /**
445
+ * Canonical owner/controller reference (preferred): UUID/resource reference, email-based ref, or DID ref.
446
+ * Example: `RelatedPerson/controller-uuid`, `RelatedPerson/mailto:controller@example.com`.
447
+ */
440
448
  ownerRef: string;
441
449
  focusRef: string;
442
450
  subjectDisplay?: string;
@@ -1,185 +0,0 @@
1
- # TODO / Prompt - Next Steps (dataspace-client-sdk-node)
2
-
3
- Objetivo de este backlog:
4
- - Mantener `dataspace-client-sdk-node` como SDK backend oficial para Node.
5
- - Añadir una capa wallet/KMS reutilizable para clientes backend Node (paridad conceptual con Python).
6
- - Evitar que servicios consumidores implementen crypto/auth ad-hoc fuera del SDK.
7
-
8
- Importante (decisión de arquitectura actual):
9
- - El wallet/KMS se implementa temporalmente dentro de este repo en:
10
- - `src/sdk/dataspace-wallet-sdk-node/`
11
- - Más adelante se extraerá a repo/npm independiente (`dataspace-wallet-sdk-node`) sin romper API.
12
-
13
- ## Repositorio fuente y referencias obligatorias
14
-
15
- Estas son las fuentes que el agente debe tomar como referencia técnica antes de implementar:
16
-
17
- 1. Frontend / cliente app:
18
- - `gdc-sdk-client-ts`
19
- - Papel: SDK frontend/wallet UX-side (no backend custodial KMS).
20
-
21
- 2. Backend gateway template:
22
- - `gwtemplate-node-ts`
23
- - Ruta clave: `src/gdc-backend-utils-node`
24
- - Papel: utilidades backend de crypto/KMS y contratos base.
25
-
26
- 3. Backend UNID (fork operativo):
27
- - `gdc-unid-node-ts`
28
- - Papel: integración real de GW + managers + KMS runtime + flujos de negocio.
29
-
30
- 4. SDK Python de referencia de paridad:
31
- - `connector-sdk-py`
32
- - Papel: referencia 1:1 de casos de uso backend.
33
-
34
- 5. Orquestador de canal (consumidor actual):
35
- - `uhc-unid-chat-node`
36
- - Papel: usa SDK de alto nivel; no debe contener crypto/KMS de backend.
37
-
38
- Regla: si hay contradicción entre implementación Node actual y Python, documentar la divergencia y dejar TODO de convergencia.
39
-
40
- ## Contexto que el agente debe respetar
41
-
42
- 1. `uhc-unid-chat-node` y otros consumidores deben seguir usando métodos de alto nivel del SDK.
43
- 2. Los cambios internos de path builders de identidad son breaking solo para consumidores que montan rutas a mano.
44
- 3. Si el consumidor usa `authenticateBackendPkceAndExchange(...)`, no debe cambiar nada en su código por la migración de rutas identity.
45
-
46
- ## Funcionamiento actual de backend tools + KMS (baseline)
47
-
48
- Resumen operativo esperado por el ecosistema backend:
49
-
50
- 1. Capa SDK cliente (`dataspace-client-sdk-node`):
51
- - construye paths canónicos,
52
- - hace submit/poll,
53
- - orquesta auth backend (`_dcr -> _code -> _token -> _exchange`).
54
-
55
- 2. Capa backend utils / KMS (hoy en GW/template repos):
56
- - `KmsService` / `DemoKmsService`,
57
- - interfaces de crypto (`IKmsService`, tipos JWK/JWS/JWE),
58
- - utilidades KEK/envelope para protección de claves y datos.
59
-
60
- 3. Capa GW backend (`gdc-unid-node-ts` / `gwtemplate-node-ts`):
61
- - runtime multitenant,
62
- - provisión y resolución de claves por tenant,
63
- - operaciones de firma/verificación/cifrado en contexto servidor.
64
-
65
- Límite de responsabilidad:
66
- - `dataspace-client-sdk-node` no debe replicar managers de GW.
67
- - Sí debe poder exponer wallet/KMS cliente reutilizable para backends no-GW.
68
-
69
- ## Definición de Hecho (DoD)
70
-
71
- 1. Existe módulo wallet interno funcional con interfaz pública estable.
72
- 2. El flujo `identity-exchange.v1` está soportado por métodos de alto nivel en Node (sin construir rutas manuales fuera del SDK).
73
- 3. Se documenta paridad Node/Python por capability (no solo por endpoint).
74
- 4. Hay tests que fallen si se rompe la paridad mínima acordada.
75
- 5. README y ejemplos permiten a otro equipo integrar sin leer código interno.
76
-
77
- ## Alcance técnico a implementar
78
-
79
- ### A) Wallet/KMS interno (nuevo)
80
-
81
- Crear módulo en `src/sdk/dataspace-wallet-sdk-node/`:
82
-
83
- - `types.ts`
84
- - `WalletContext` (`tenantId`, `jurisdiction`, `sector`, opcional `walletId`)
85
- - `PublicJwk`, `PrivateKeyRef`, `SignOptions`, `EncryptOptions`, `DecryptOptions`
86
- - `WalletProviderKind = 'mem' | 'seed' | 'external'`
87
-
88
- - `provider.ts`
89
- - `WalletProvider` interface:
90
- - `init(...)`
91
- - `getPublicJwks(context)`
92
- - `sign(payload, context, options)`
93
- - `verify(payload, signature, jwk)`
94
- - `encrypt(plaintext, recipientJwk, options)`
95
- - `decrypt(ciphertext, context, options)`
96
-
97
- - `providers/memory-provider.ts`
98
- - provider mínimo productivo para pruebas.
99
-
100
- - `providers/seed-provider.ts`
101
- - solo para `demo/dev` (determinístico).
102
- - prohibido recomendarlo para staging/prod.
103
-
104
- - `WalletClient.ts`
105
- - fachada single-tenant.
106
-
107
- - `MultiWalletClient.ts`
108
- - resolución por `tenantId/jurisdiction/sector`.
109
-
110
- ### B) Integración en `DataspaceNodeClient`
111
-
112
- - Aceptar opcionalmente `wallet` en constructor/options.
113
- - Mantener compatibilidad de los métodos actuales de negocio/auth.
114
- - No mover lógica de dominios al wallet: wallet solo crypto/key operations.
115
-
116
- ### C) Auth de alto nivel (paridad Python)
117
-
118
- Asegurar métodos de alto nivel para:
119
- - `authenticateBackendPkceAndExchange(...)`
120
- - base para `authenticateBackendSmartStandard(...)` (si el contrato backend ya está listo)
121
-
122
- Notas:
123
- - Internamente usar path builders canónicos nuevos.
124
- - Evitar exponer helpers de rutas como API pública “recomendada” para auth.
125
-
126
- ## Plan de ejecución (orden obligatorio)
127
-
128
- 1. Fase 1 - Contratos y estructura
129
- - Crear árbol `src/sdk/dataspace-wallet-sdk-node/*`.
130
- - Definir interfaces y tipos.
131
- - Añadir tests unitarios de contrato (sin integración GW todavía).
132
-
133
- 2. Fase 2 - Provider mem/seed
134
- - Implementar `memory-provider` y `seed-provider`.
135
- - Añadir tests de firma/verificación y cifrado/descifrado.
136
-
137
- 3. Fase 3 - Integración client
138
- - Conectar wallet opcional en `src/client.ts`.
139
- - Mantener sin breaking en usos actuales.
140
-
141
- 4. Fase 4 - Paridad y documentación
142
- - Actualizar `SDK_PARITY_MAP.md` con estado real.
143
- - Actualizar `README.md` con sección “Wallet/KMS for backend clients”.
144
- - Añadir ejemplo runnable en `examples/`.
145
-
146
- 5. Fase 5 - Puerta de extracción futura
147
- - Definir imports internos de forma que luego sea fácil reemplazar:
148
- - `src/sdk/dataspace-wallet-sdk-node/*` -> paquete npm externo.
149
-
150
- ## Tests mínimos obligatorios
151
-
152
- 1. Unit tests wallet:
153
- - sign/verify roundtrip
154
- - encrypt/decrypt roundtrip
155
- - error handling de context faltante
156
-
157
- 2. Unit tests auth orchestration:
158
- - secuencia `_dcr -> _code -> _token -> _exchange`
159
- - gestión de token cacheado vs refresh
160
-
161
- 3. Regression tests identity routes:
162
- - verificar que internamente se usa patrón canónico
163
- - `/{prefix}/cds-{j}/v1/{sector}/{tenantId}/identity/auth/{action}`
164
-
165
- 4. Public API smoke:
166
- - import del SDK no rompe para consumidores actuales.
167
-
168
- ## Criterios de seguridad
169
-
170
- - Ninguna private key en logs.
171
- - `seed-provider` marcado explícitamente como no apto para staging/prod.
172
- - Errores crypto sin volcar material sensible.
173
-
174
- ## Entregables esperados del agente
175
-
176
- 1. PR con código + tests + docs.
177
- 2. Resumen de decisiones (tradeoffs) en la descripción.
178
- 3. Tabla de estado actualizada en `SDK_PARITY_MAP.md`.
179
- 4. Lista de pendientes para extracción a repo independiente.
180
-
181
- ## Plantilla de commit sugerida
182
-
183
- - `feat(wallet): add internal dataspace-wallet-sdk-node module (mem/seed providers)`
184
- - `feat(auth): keep pkce high-level orchestration aligned with canonical identity routes`
185
- - `docs(parity): update SDK parity map and wallet roadmap`