@tsg-dsp/tsg-sdk 0.20.1 → 0.21.0
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 +116 -27
- package/dist/.generated/control-plane.d.ts +287 -344
- package/dist/.generated/sso-bridge.d.ts +979 -42
- package/dist/.generated/wallet.d.ts +104 -206
- package/dist/auth/auth.provider.d.ts +5 -1
- package/dist/auth/auth.provider.d.ts.map +1 -1
- package/dist/auth/auth.provider.js +9 -1
- package/dist/auth/auth.provider.js.map +1 -1
- package/dist/browser.d.ts +525 -523
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +17 -4
- package/dist/browser.js.map +1 -1
- package/dist/catalog/catalog.sdk.d.ts.map +1 -1
- package/dist/catalog/catalog.sdk.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -1
- package/dist/config/sdk.config.d.ts +20 -4
- package/dist/config/sdk.config.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/metadata/metadata.sdk.d.ts +10 -7
- package/dist/metadata/metadata.sdk.d.ts.map +1 -1
- package/dist/metadata/metadata.sdk.js +7 -4
- package/dist/metadata/metadata.sdk.js.map +1 -1
- package/dist/negotiations/negotiations.sdk.d.ts +1 -1
- package/dist/negotiations/negotiations.sdk.d.ts.map +1 -1
- package/dist/negotiations/negotiations.sdk.js.map +1 -1
- package/dist/requirements/requirements.sdk.d.ts.map +1 -1
- package/dist/requirements/requirements.sdk.js.map +1 -1
- package/dist/sso/sso-management.sdk.d.ts.map +1 -1
- package/dist/sso/sso-management.sdk.js.map +1 -1
- package/dist/sso/sso.sdk.d.ts +1 -1
- package/dist/sso/sso.sdk.d.ts.map +1 -1
- package/dist/sso/sso.sdk.js +4 -2
- package/dist/sso/sso.sdk.js.map +1 -1
- package/dist/tenants/tenant-management.sdk.d.ts +48 -0
- package/dist/tenants/tenant-management.sdk.d.ts.map +1 -0
- package/dist/tenants/tenant-management.sdk.js +107 -0
- package/dist/tenants/tenant-management.sdk.js.map +1 -0
- package/dist/transfers/transfers.sdk.d.ts +27 -8
- package/dist/transfers/transfers.sdk.d.ts.map +1 -1
- package/dist/transfers/transfers.sdk.js +15 -1
- package/dist/transfers/transfers.sdk.js.map +1 -1
- package/dist/tsg-sdk.d.ts +4 -1
- package/dist/tsg-sdk.d.ts.map +1 -1
- package/dist/tsg-sdk.js +23 -6
- package/dist/tsg-sdk.js.map +1 -1
- package/dist/utils/errors.d.ts +2 -2
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/reason.d.ts +16 -0
- package/dist/utils/reason.d.ts.map +1 -0
- package/dist/utils/reason.js +34 -0
- package/dist/utils/reason.js.map +1 -0
- package/dist/utils/validate.js.map +1 -1
- package/dist/vendor/common-dtos/abac.policy.d.ts +10 -1
- package/dist/vendor/common-dtos/abac.policy.js +5 -2
- package/dist/vendor/common-dtos/audit.types.d.ts +1 -1
- package/dist/vendor/common-dtos/audit.types.js +0 -1
- package/dist/vendor/common-dtos/credential-requirements.d.ts +0 -1
- package/dist/vendor/common-dtos/credential-requirements.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/credential-requirements.dto.js +0 -1
- package/dist/vendor/common-dtos/credential-requirements.js +0 -1
- package/dist/vendor/common-dtos/dataplane.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/dataplane.dto.js +0 -1
- package/dist/vendor/common-dtos/dcp.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/dcp.dto.js +0 -1
- package/dist/vendor/common-dtos/dcql.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/dcql.dto.js +0 -1
- package/dist/vendor/common-dtos/did.schemas.d.ts +0 -1
- package/dist/vendor/common-dtos/did.schemas.js +0 -1
- package/dist/vendor/common-dtos/index.d.ts +1 -1
- package/dist/vendor/common-dtos/index.js +1 -1
- package/dist/vendor/common-dtos/metadata.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/metadata.dto.js +0 -1
- package/dist/vendor/common-dtos/negotiations.dto.d.ts +2 -3
- package/dist/vendor/common-dtos/negotiations.dto.js +6 -7
- package/dist/vendor/common-dtos/permission-resources.d.ts +3 -0
- package/dist/vendor/common-dtos/permission-resources.js +18 -0
- package/dist/vendor/common-dtos/permissions.d.ts +6 -1
- package/dist/vendor/common-dtos/permissions.js +73 -1
- package/dist/vendor/common-dtos/presentation.request.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/presentation.request.dto.js +0 -1
- package/dist/vendor/common-dtos/presentation.status.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/presentation.status.dto.js +0 -1
- package/dist/vendor/common-dtos/presentationdefinition.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/presentationdefinition.dto.js +0 -1
- package/dist/vendor/common-dtos/signatures.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/signatures.dto.js +0 -1
- package/dist/vendor/common-dtos/transfer.dto.d.ts +0 -1
- package/dist/vendor/common-dtos/transfer.dto.js +0 -1
- package/dist/vendor/common-dtos/utils.swagger.d.ts +0 -1
- package/dist/vendor/common-dtos/utils.swagger.js +0 -1
- package/dist/vendor/control-plane-dtos/index.d.ts +0 -1
- package/dist/vendor/control-plane-dtos/index.js +0 -1
- package/dist/vendor/control-plane-dtos/registry/registry.dto.d.ts +0 -1
- package/dist/vendor/control-plane-dtos/registry/registry.dto.js +0 -1
- package/dist/vendor/control-plane-dtos/registry/registry.search.dto.d.ts +0 -1
- package/dist/vendor/control-plane-dtos/registry/registry.search.dto.js +0 -1
- package/dist/vendor/control-plane-dtos/ssi/verifiablePresentations.dto.d.ts +0 -1
- package/dist/vendor/control-plane-dtos/ssi/verifiablePresentations.dto.js +0 -1
- package/dist/vendor/control-plane-dtos/status/status.dto.d.ts +0 -1
- package/dist/vendor/control-plane-dtos/status/status.dto.js +0 -1
- package/dist/vendor/sso-bridge-dtos/clients.dto.d.ts +7 -4
- package/dist/vendor/sso-bridge-dtos/clients.dto.js +38 -4
- package/dist/vendor/sso-bridge-dtos/grants.d.ts +2 -1
- package/dist/vendor/sso-bridge-dtos/grants.js +7 -2
- package/dist/vendor/sso-bridge-dtos/index.d.ts +1 -1
- package/dist/vendor/sso-bridge-dtos/index.js +1 -1
- package/dist/vendor/sso-bridge-dtos/tenant.dto.d.ts +70 -0
- package/dist/vendor/sso-bridge-dtos/tenant.dto.js +1 -0
- package/dist/vendor/sso-bridge-dtos/users.dto.d.ts +19 -1
- package/dist/vendor/sso-bridge-dtos/users.dto.js +85 -2
- package/dist/vendor/tenant-dtos/authorization.dto.d.ts +46 -0
- package/dist/vendor/tenant-dtos/authorization.dto.js +5 -0
- package/dist/vendor/tenant-dtos/consumer.dto.d.ts +29 -0
- package/dist/vendor/tenant-dtos/consumer.dto.js +1 -0
- package/dist/vendor/tenant-dtos/fixtures.d.ts +15 -0
- package/dist/vendor/tenant-dtos/fixtures.js +48 -0
- package/dist/vendor/tenant-dtos/index.d.ts +8 -0
- package/dist/vendor/tenant-dtos/index.js +8 -0
- package/dist/vendor/tenant-dtos/management.dto.d.ts +137 -0
- package/dist/vendor/tenant-dtos/management.dto.js +1 -0
- package/dist/vendor/tenant-dtos/membership.dto.d.ts +22 -0
- package/dist/vendor/tenant-dtos/membership.dto.js +7 -0
- package/dist/vendor/tenant-dtos/principal.dto.d.ts +13 -0
- package/dist/vendor/tenant-dtos/principal.dto.js +6 -0
- package/dist/vendor/tenant-dtos/provisioning.dto.d.ts +47 -0
- package/dist/vendor/tenant-dtos/provisioning.dto.js +1 -0
- package/dist/vendor/tenant-dtos/service-binding.dto.d.ts +9 -0
- package/dist/vendor/tenant-dtos/service-binding.dto.js +1 -0
- package/dist/vendor/tenant-dtos/tenant.dto.d.ts +15 -0
- package/dist/vendor/tenant-dtos/tenant.dto.js +1 -0
- package/dist/vendor/wallet-dtos/clients.dto.d.ts +0 -1
- package/dist/vendor/wallet-dtos/clients.dto.js +0 -1
- package/dist/vendor/wallet-dtos/credentials.dto.d.ts +0 -1
- package/dist/vendor/wallet-dtos/credentials.dto.js +0 -1
- package/dist/vendor/wallet-dtos/index.d.ts +0 -1
- package/dist/vendor/wallet-dtos/index.js +0 -1
- package/dist/vendor/wallet-dtos/issuance.dto.d.ts +0 -1
- package/dist/vendor/wallet-dtos/issuance.dto.js +0 -1
- package/dist/vendor/wallet-dtos/scopes.dto.d.ts +0 -1
- package/dist/vendor/wallet-dtos/scopes.dto.js +0 -1
- package/dist/vendor/wallet-dtos/status.dto.d.ts +0 -1
- package/dist/vendor/wallet-dtos/status.dto.js +0 -1
- package/dist/vendor/wallet-dtos/utils/schema-converter.d.ts +0 -1
- package/dist/vendor/wallet-dtos/utils/schema-converter.js +0 -1
- package/dist/wallet/wallet.sdk.d.ts +3 -3
- package/dist/wallet/wallet.sdk.d.ts.map +1 -1
- package/dist/wallet/wallet.sdk.js.map +1 -1
- package/package.json +17 -16
package/README.md
CHANGED
|
@@ -4,16 +4,28 @@ TypeScript SDK for interacting with TSG (TNO Security Gateway) Dataspace Protoco
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
Install the latest released SDK from npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @tsg-dsp/tsg-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Within this monorepo, use a workspace dependency to consume the current source:
|
|
9
14
|
|
|
10
15
|
```bash
|
|
11
16
|
pnpm --filter <consumer-package> add '@tsg-dsp/tsg-sdk@workspace:*'
|
|
12
17
|
```
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
For an interactive example against the current shared services, use the
|
|
20
|
+
[managed SDK playground](../../sample/sdk/README.md).
|
|
15
21
|
|
|
16
|
-
## Quick
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
Use URLs, audiences, canonical tenant ID, service-local slugs and workload
|
|
25
|
+
credentials from your provisioned deployment. Values below illustrate the
|
|
26
|
+
configuration shape; they are not seeded accounts or deployment defaults.
|
|
27
|
+
The [module examples](samples/README.md) read these settings from environment
|
|
28
|
+
variables and support an offline construction check.
|
|
17
29
|
|
|
18
30
|
```typescript
|
|
19
31
|
import { TsgSdk } from "@tsg-dsp/tsg-sdk";
|
|
@@ -22,11 +34,19 @@ const sdk = TsgSdk.create({
|
|
|
22
34
|
controlPlaneBaseUrl: "http://localhost:3000",
|
|
23
35
|
walletBaseUrl: "http://localhost:3001",
|
|
24
36
|
ssoBridgeBaseUrl: "http://localhost:3002",
|
|
25
|
-
tenantSlug: "
|
|
37
|
+
tenantSlug: "acme", // sent as X-Tenant-Slug on control-plane / wallet calls
|
|
38
|
+
canonicalTenantId: "11111111-1111-4111-8111-111111111111",
|
|
39
|
+
controlPlaneAudience: "control-plane-api",
|
|
40
|
+
walletAudience: "wallet-api",
|
|
26
41
|
auth: {
|
|
27
42
|
method: "client_secret_post",
|
|
28
|
-
clientId:
|
|
29
|
-
clientSecret:
|
|
43
|
+
clientId: controlPlaneClientId,
|
|
44
|
+
clientSecret: controlPlaneClientSecret
|
|
45
|
+
},
|
|
46
|
+
walletAuth: {
|
|
47
|
+
method: "client_secret_post",
|
|
48
|
+
clientId: walletClientId,
|
|
49
|
+
clientSecret: walletClientSecret
|
|
30
50
|
}
|
|
31
51
|
});
|
|
32
52
|
|
|
@@ -43,18 +63,64 @@ const negotiation = await sdk.negotiations.requestNegotiation(
|
|
|
43
63
|
);
|
|
44
64
|
|
|
45
65
|
// Wait for agreement
|
|
46
|
-
const finalized = await sdk.negotiations.waitForAgreement(negotiation
|
|
66
|
+
const finalized = await sdk.negotiations.waitForAgreement(negotiation.id);
|
|
47
67
|
|
|
48
68
|
// Request a transfer
|
|
49
69
|
const transfer = await sdk.transfers.requestTransfer(
|
|
50
70
|
agreementId,
|
|
51
71
|
participantId,
|
|
52
72
|
remoteAddress,
|
|
53
|
-
"
|
|
54
|
-
|
|
73
|
+
"https://w3id.org/dspace-sig/profile/http-pull"
|
|
74
|
+
);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Managed tenants
|
|
78
|
+
|
|
79
|
+
`TenantManagementSdk` is a standalone client for the central manager. Use a
|
|
80
|
+
human token issued for its audience. Workload provisioning credentials cannot
|
|
81
|
+
administer organizations through these endpoints.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { AuthProvider, TenantManagementSdk } from "@tsg-dsp/tsg-sdk";
|
|
85
|
+
|
|
86
|
+
const tenants = new TenantManagementSdk(
|
|
87
|
+
"https://hosted.example.com/tenant-management/api",
|
|
88
|
+
new AuthProvider(
|
|
89
|
+
{ method: "access_token", accessToken: humanToken },
|
|
90
|
+
undefined
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
const accepted = await tenants.createForPlatform(
|
|
94
|
+
{
|
|
95
|
+
name: "Alice Corp",
|
|
96
|
+
slug: "alice-corp",
|
|
97
|
+
profile: "default",
|
|
98
|
+
owner: { kind: "new", username: "alice", email: "alice@example.com" }
|
|
99
|
+
},
|
|
100
|
+
"alice-corp-create-1"
|
|
55
101
|
);
|
|
102
|
+
const operation = await tenants.operation(accepted.operationId);
|
|
56
103
|
```
|
|
57
104
|
|
|
105
|
+
The client covers capabilities, account lookup/onboarding, setup links, operation
|
|
106
|
+
history/retry, invitations, memberships, grants, ownership, lifecycle, audit and
|
|
107
|
+
workload credential rotation. Self-service `create` requires explicit deployment
|
|
108
|
+
policy. A setup link contains a URL only when email delivery is disabled.
|
|
109
|
+
The browser export also provides `TenantManagementSdk`; omit its auth argument
|
|
110
|
+
for same-origin cookie sessions.
|
|
111
|
+
|
|
112
|
+
For managed Wallet/Control Plane calls, set `canonicalTenantId`,
|
|
113
|
+
`controlPlaneAudience` and `walletAudience`. Keep the target-local tenant selector
|
|
114
|
+
in `tenantSlug`, or use `controlPlaneTenantSlug` and `walletTenantSlug` when
|
|
115
|
+
imported services have different URL names. `walletAuth` supplies a separate
|
|
116
|
+
Wallet token or credential whenever explicit Control Plane authentication is configured. Tokens are never inherited across services. Setting `ssoBridgeBaseUrl` allows
|
|
117
|
+
workload token discovery; it does not give `sdk.sso` management authority.
|
|
118
|
+
Use `ssoAuth` and `ssoAudience` for a separate credential authorized to administer
|
|
119
|
+
SSO. Tenant Management administration and consumer authorization use separate
|
|
120
|
+
audiences. A tenant slug selects a service-local tenant; it does not replace the
|
|
121
|
+
canonical tenant UUID in workload token requests. There is no implicit `default`
|
|
122
|
+
tenant, seeded workload client, or token audience fallback.
|
|
123
|
+
|
|
58
124
|
## Modules
|
|
59
125
|
|
|
60
126
|
The SDK is organized into focused modules, each accessible as a property on the `TsgSdk` instance:
|
|
@@ -164,10 +230,13 @@ The SDK supports three authentication methods:
|
|
|
164
230
|
const sdk = TsgSdk.create({
|
|
165
231
|
controlPlaneBaseUrl: "http://localhost:3000",
|
|
166
232
|
ssoBridgeBaseUrl: "http://localhost:3002",
|
|
233
|
+
canonicalTenantId,
|
|
234
|
+
controlPlaneTenantSlug,
|
|
235
|
+
controlPlaneAudience,
|
|
167
236
|
auth: {
|
|
168
237
|
method: "client_secret_post",
|
|
169
|
-
clientId:
|
|
170
|
-
clientSecret:
|
|
238
|
+
clientId: controlPlaneClientId,
|
|
239
|
+
clientSecret: controlPlaneClientSecret
|
|
171
240
|
}
|
|
172
241
|
});
|
|
173
242
|
```
|
|
@@ -178,33 +247,40 @@ const sdk = TsgSdk.create({
|
|
|
178
247
|
const sdk = TsgSdk.create({
|
|
179
248
|
controlPlaneBaseUrl: "http://localhost:3000",
|
|
180
249
|
ssoBridgeBaseUrl: "http://localhost:3002",
|
|
250
|
+
canonicalTenantId,
|
|
251
|
+
controlPlaneTenantSlug,
|
|
252
|
+
controlPlaneAudience,
|
|
181
253
|
auth: {
|
|
182
254
|
method: "private_key_jwt",
|
|
183
|
-
clientId:
|
|
184
|
-
privateKeyJwk:
|
|
255
|
+
clientId: controlPlaneClientId,
|
|
256
|
+
privateKeyJwk: controlPlanePrivateKey
|
|
185
257
|
}
|
|
186
258
|
});
|
|
187
259
|
```
|
|
188
260
|
|
|
189
|
-
### Pre-obtained
|
|
261
|
+
### Pre-obtained access token
|
|
262
|
+
|
|
263
|
+
Use a token issued for the receiving service and intended tenant. The SDK does
|
|
264
|
+
not change its claims or refresh it. Configure `walletAuth` and `ssoAuth` with
|
|
265
|
+
separate tokens when calling those services.
|
|
190
266
|
|
|
191
267
|
```typescript
|
|
192
268
|
const sdk = TsgSdk.create({
|
|
193
269
|
controlPlaneBaseUrl: "http://localhost:3000",
|
|
270
|
+
controlPlaneTenantSlug,
|
|
194
271
|
auth: {
|
|
195
272
|
method: "access_token",
|
|
196
|
-
accessToken:
|
|
273
|
+
accessToken: controlPlaneToken
|
|
197
274
|
}
|
|
198
275
|
});
|
|
199
276
|
```
|
|
200
277
|
|
|
201
|
-
###
|
|
278
|
+
### Cookie sessions
|
|
202
279
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
```
|
|
280
|
+
Omitting auth sends no bearer token. It does not bypass service authorization or
|
|
281
|
+
select a tenant. In a same-origin browser session, configure the service-local
|
|
282
|
+
tenant slug explicitly and let the browser send its existing session cookie.
|
|
283
|
+
The Node.js module examples use explicit workload credentials instead.
|
|
208
284
|
|
|
209
285
|
## Optional Modules
|
|
210
286
|
|
|
@@ -267,8 +343,21 @@ The SDK build includes compiled private DTOs and their declarations under
|
|
|
267
343
|
metadata by copying the TypeScript compiler output. Only `common-dsp` remains a
|
|
268
344
|
separately published TSG dependency. The browser entry does not load the DTOs.
|
|
269
345
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
346
|
+
To check an external installation locally, build with
|
|
347
|
+
`pnpm --filter @tsg-dsp/tsg-sdk... -r build`, pack with
|
|
348
|
+
`pnpm --filter @tsg-dsp/tsg-sdk pack`, install the tarball outside the workspace,
|
|
349
|
+
and compile a TypeScript consumer using both the main and browser entries.
|
|
350
|
+
|
|
351
|
+
### Renewable HTTP data access
|
|
352
|
+
|
|
353
|
+
Use `transfers.dataAccess(transferId)` before sending an HTTP data request. The
|
|
354
|
+
control plane coordinates refresh-token rotation across clients and persists the
|
|
355
|
+
new credentials. The returned object contains `endpoint` and `headers`.
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
const access = await sdk.transfers.dataAccess(transferId);
|
|
359
|
+
const response = await fetch(access.endpoint, { headers: access.headers });
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
After a 401, request `{ forceRefresh: true }` and decide whether to repeat the
|
|
363
|
+
request. The SDK never retries data requests automatically.
|