dataspace-client-sdk-node 0.1.1 → 0.1.2

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.
@@ -0,0 +1,72 @@
1
+ # React Web Integration
2
+
3
+ This guide is frontend-only.
4
+ Backend SDK usage is documented in `docs/BACKEND_NODE_INTEGRATION.md`.
5
+
6
+ ## 1. What the React app does
7
+
8
+ 1. Run ICA UX flow and obtain `vpToken`.
9
+ 2. Send onboarding payloads to your backend.
10
+ 3. Show progress and status from backend responses.
11
+
12
+ React does not call privileged GW onboarding routes directly.
13
+
14
+ ## 2. Legal onboarding payload sent by frontend
15
+
16
+ Minimum payload to backend endpoint `/api/onboarding/legal/activate`:
17
+
18
+ ```json
19
+ {
20
+ "jurisdiction": "ES",
21
+ "sector": "health-care",
22
+ "vpToken": "<vp_token>"
23
+ }
24
+ ```
25
+
26
+ Notes:
27
+ - `jurisdiction` is explicit route context. Do not infer from VAT.
28
+ - `sector` is explicit route context. Do not infer from DID.
29
+ - `organizationVc` / `legalRepresentativeVc` can be sent only for legacy compatibility.
30
+
31
+ ## 3. Frontend code example
32
+
33
+ ```ts
34
+ export async function activateLegalOrganization(input: {
35
+ jurisdiction: string;
36
+ sector: string;
37
+ vpToken: string;
38
+ }) {
39
+ const response = await fetch('/api/onboarding/legal/activate', {
40
+ method: 'POST',
41
+ headers: { 'content-type': 'application/json' },
42
+ body: JSON.stringify(input),
43
+ });
44
+ if (!response.ok) throw new Error(`Activation failed: ${response.status}`);
45
+ return response.json();
46
+ }
47
+ ```
48
+
49
+ ## 4. Personal/family onboarding from frontend
50
+
51
+ ```ts
52
+ export async function registerPersonalOrganization(payload: {
53
+ tenantId: string;
54
+ jurisdiction: string;
55
+ sector: string;
56
+ registrationPayload: unknown;
57
+ confirmationPayload?: unknown;
58
+ }) {
59
+ const response = await fetch('/api/onboarding/personal/register', {
60
+ method: 'POST',
61
+ headers: { 'content-type': 'application/json' },
62
+ body: JSON.stringify(payload),
63
+ });
64
+ if (!response.ok) throw new Error(`Personal onboarding failed: ${response.status}`);
65
+ return response.json();
66
+ }
67
+ ```
68
+
69
+ ## 5. Backend document
70
+
71
+ For exact SDK methods and backend implementation steps, use:
72
+ - `docs/BACKEND_NODE_INTEGRATION.md`
@@ -0,0 +1,40 @@
1
+ import { DataspaceNodeClient } from '../dist/index.js';
2
+
3
+ const baseUrl = process.env.BASE_URL || 'http://127.0.0.1:3000';
4
+ const bearerToken = process.env.AUTH_BEARER || 'demo-token';
5
+ const tenantId = process.env.TENANT_ID || 'acme';
6
+ const jurisdiction = process.env.JURISDICTION || 'ES';
7
+ const sector = process.env.HOST_REGISTRY_SECTOR || 'test';
8
+ const vpToken = process.env.VP_TOKEN || 'demo-vp';
9
+
10
+ const client = new DataspaceNodeClient({ baseUrl, bearerToken });
11
+ client
12
+ .setContextOrg({ tenantId, jurisdiction, sector })
13
+ .setDefaultTimeoutSeconds(Number(process.env.TIMEOUT_SECONDS || 60))
14
+ .setDefaultIntervalSeconds(Number(process.env.INTERVAL_SECONDS || 2));
15
+
16
+ try {
17
+ const activation = await client.activateOrganizationInGatewaySimple({
18
+ vpToken,
19
+ numberOfMembers: Number(process.env.NUMBER_OF_MEMBERS || 2),
20
+ });
21
+
22
+ console.log('[activate] submit=', activation.submit.status, 'poll=', activation.poll.status);
23
+
24
+ const offerId = client.getOfferIdFromResponse(activation);
25
+ const offer = client.getOfferPreviewFromResponse(activation);
26
+ console.log('[activate] offerId=', offerId || '<missing>');
27
+ console.log('[activate] offerPreview=', JSON.stringify(offer));
28
+
29
+ if (!offerId) {
30
+ console.log('[order] skipped: no offerId in activation response');
31
+ process.exit(0);
32
+ }
33
+
34
+ const order = await client.confirmLegalOrganizationOrderSimple({ offerId });
35
+ console.log('[order] submit=', order.submit.status, 'poll=', order.poll.status);
36
+ process.exit(order.poll.status === 200 ? 0 : 1);
37
+ } catch (error) {
38
+ console.error('[smoke-legal-org-local] ERROR:', error?.message || error);
39
+ process.exit(1);
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dataspace-client-sdk-node",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Node.js SDK skeleton for GW/UNID DIDComm plain batch + async polling flows",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",