@portaidentity/sdk 1.11.1 → 1.13.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/CHANGELOG.md +22 -0
- package/README.md +126 -49
- package/dist/client.d.ts +2 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -2
- package/dist/client.js.map +1 -1
- package/dist/transport/browser-transport.d.ts +7 -0
- package/dist/transport/browser-transport.d.ts.map +1 -1
- package/dist/transport/browser-transport.js +9 -4
- package/dist/transport/browser-transport.js.map +1 -1
- package/dist/transport/node-transport.d.ts +8 -1
- package/dist/transport/node-transport.d.ts.map +1 -1
- package/dist/transport/node-transport.js +8 -7
- package/dist/transport/node-transport.js.map +1 -1
- package/dist/transport/types.d.ts +1 -1
- package/dist/transport/utils.d.ts +2 -1
- package/dist/transport/utils.d.ts.map +1 -1
- package/dist/transport/utils.js +5 -3
- package/dist/transport/utils.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.13.0] - 2026-10-24
|
|
9
|
+
|
|
10
|
+
Changed: Updated README.md to reflect recent changes in usage and examples.
|
|
11
|
+
Changed: Refactored client.ts for improved performance and enhanced API consistency.
|
|
12
|
+
Changed: Optimized browser-transport.ts for better handling of network requests.
|
|
13
|
+
Changed: Enhanced node-transport.ts to support additional transport methods.
|
|
14
|
+
Changed: Improved type definitions in types.ts for better type safety.
|
|
15
|
+
Changed: Streamlined utility functions in utils.ts for cleaner code.
|
|
16
|
+
Changed: Updated tests in browser-transport.test.ts and node-transport.test.ts for better coverage.
|
|
17
|
+
|
|
18
|
+
## [1.12.0] - 2026-10-23
|
|
19
|
+
|
|
20
|
+
Added
|
|
21
|
+
- Updated documentation to clarify that /api/admin requires account-bound opaque access tokens.
|
|
22
|
+
|
|
23
|
+
Changed
|
|
24
|
+
- Removed client-credentials examples for Admin API automation.
|
|
25
|
+
- Corrected signatures for createTokenAuth and createCliAuth to adhere to the BFF pattern.
|
|
26
|
+
|
|
27
|
+
Fixed
|
|
28
|
+
- Updated authentication guidance in docs/api/authentication.md and several guide files to reflect accurate information.
|
|
29
|
+
|
|
8
30
|
## [1.11.1] - 2026-09-30
|
|
9
31
|
|
|
10
32
|
Added
|
package/README.md
CHANGED
|
@@ -27,16 +27,23 @@ yarn add @portaidentity/sdk
|
|
|
27
27
|
### Browser
|
|
28
28
|
|
|
29
29
|
```typescript
|
|
30
|
-
import { createPortaClient
|
|
30
|
+
import { createPortaClient } from '@portaidentity/sdk';
|
|
31
|
+
import { createBrowserTransport } from '@portaidentity/sdk/browser';
|
|
32
|
+
|
|
33
|
+
let csrfToken: string | null = null;
|
|
31
34
|
|
|
32
35
|
const transport = createBrowserTransport({
|
|
33
|
-
baseUrl: '
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
baseUrl: '', // same-origin BFF; the SDK adds the API prefix
|
|
37
|
+
getCsrfToken: () => csrfToken,
|
|
38
|
+
setCsrfToken: (token) => {
|
|
39
|
+
csrfToken = token;
|
|
40
|
+
},
|
|
41
|
+
onUnauthorized: () => {
|
|
42
|
+
window.location.href = '/login';
|
|
43
|
+
},
|
|
37
44
|
});
|
|
38
45
|
|
|
39
|
-
const client = createPortaClient(transport);
|
|
46
|
+
const client = createPortaClient({ transport });
|
|
40
47
|
|
|
41
48
|
// List organizations
|
|
42
49
|
const orgs = await client.organizations.list({ page: 1, pageSize: 20 });
|
|
@@ -53,16 +60,15 @@ const user = await client.users.create({
|
|
|
53
60
|
### Node.js (Automation / CLI)
|
|
54
61
|
|
|
55
62
|
```typescript
|
|
56
|
-
import { createPortaClient
|
|
57
|
-
|
|
58
|
-
const auth = createTokenAuth('your-bearer-token');
|
|
63
|
+
import { createPortaClient } from '@portaidentity/sdk';
|
|
64
|
+
import { createNodeTransport, createTokenAuth } from '@portaidentity/sdk/node';
|
|
59
65
|
|
|
60
66
|
const transport = createNodeTransport({
|
|
61
|
-
baseUrl: 'https://porta.local:3443
|
|
62
|
-
auth,
|
|
67
|
+
baseUrl: 'https://porta.local:3443',
|
|
68
|
+
auth: createTokenAuth({ token: 'opaque-access-token' }),
|
|
63
69
|
});
|
|
64
70
|
|
|
65
|
-
const client = createPortaClient(transport);
|
|
71
|
+
const client = createPortaClient({ transport });
|
|
66
72
|
|
|
67
73
|
// List all organizations (auto-pagination)
|
|
68
74
|
const allOrgs = await client.organizations.listAll();
|
|
@@ -71,37 +77,105 @@ const allOrgs = await client.organizations.listAll();
|
|
|
71
77
|
await client.users.deactivate('org-id', 'user-id');
|
|
72
78
|
|
|
73
79
|
// Assign a role
|
|
74
|
-
await client.userRoles.assign('org-id', 'user-id',
|
|
80
|
+
await client.userRoles.assign('org-id', 'user-id', ['role-id']);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Admin API from a BFF (Server-to-Server)
|
|
84
|
+
|
|
85
|
+
The Admin API requires an opaque access token bound to an active user in the
|
|
86
|
+
super-admin organization with a recognized admin role. Use one of these patterns:
|
|
87
|
+
|
|
88
|
+
1. **Dedicated control-plane user** — Authorization Code + PKCE once, then store the
|
|
89
|
+
refresh token in a secret manager and persist each rotation.
|
|
90
|
+
2. **Short-lived token** — obtain an access token through `porta login` or the
|
|
91
|
+
Authorization Code flow and pass it to `createTokenAuth`.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { createPortaClient } from '@portaidentity/sdk';
|
|
95
|
+
import { createNodeTransport, createTokenAuth } from '@portaidentity/sdk/node';
|
|
96
|
+
|
|
97
|
+
const client = createPortaClient({
|
|
98
|
+
transport: createNodeTransport({
|
|
99
|
+
baseUrl: 'https://porta.example.com',
|
|
100
|
+
auth: createTokenAuth({ token: process.env.PORTA_ACCESS_TOKEN! }),
|
|
101
|
+
}),
|
|
102
|
+
});
|
|
75
103
|
```
|
|
76
104
|
|
|
77
|
-
|
|
105
|
+
Client-credentials tokens carry no account identity and are rejected by `/api/admin/*`.
|
|
106
|
+
Do not use `createClientCredentialsAuth` for Admin API automation until service
|
|
107
|
+
accounts are supported.
|
|
108
|
+
|
|
109
|
+
### Tenant-scoped invitations from a BFF
|
|
110
|
+
|
|
111
|
+
Tenant applications can invite users without a control-plane service account.
|
|
112
|
+
The tenant route accepts either a confidential client using `client_credentials`
|
|
113
|
+
with the `org:user:invite` scope, or a tenant user's access token with the
|
|
114
|
+
`org:user:invite` permission in the token client's application.
|
|
115
|
+
|
|
116
|
+
Use `apiPrefix: '/api'` for the tenant route:
|
|
78
117
|
|
|
79
118
|
```typescript
|
|
119
|
+
import { createPortaClient } from '@portaidentity/sdk';
|
|
80
120
|
import {
|
|
81
|
-
createPortaClient,
|
|
82
|
-
createNodeTransport,
|
|
83
121
|
createClientCredentialsAuth,
|
|
122
|
+
createNodeTransport,
|
|
123
|
+
createTokenAuth,
|
|
84
124
|
} from '@portaidentity/sdk/node';
|
|
85
125
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
126
|
+
// Background jobs: one tenant client, no refresh token or local credentials file.
|
|
127
|
+
const serviceClient = createPortaClient({
|
|
128
|
+
transport: createNodeTransport({
|
|
129
|
+
baseUrl: 'https://porta.example.com',
|
|
130
|
+
apiPrefix: '/api',
|
|
131
|
+
auth: createClientCredentialsAuth({
|
|
132
|
+
tokenEndpoint: 'https://porta.example.com/acme/token',
|
|
133
|
+
clientId: process.env.PORTA_TENANT_CLIENT_ID!,
|
|
134
|
+
clientSecret: process.env.PORTA_TENANT_CLIENT_SECRET!,
|
|
135
|
+
scope: 'org:user:invite',
|
|
136
|
+
}),
|
|
137
|
+
}),
|
|
91
138
|
});
|
|
92
139
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
140
|
+
// Interactive requests: forward the caller's Porta access token.
|
|
141
|
+
const userClient = createPortaClient({
|
|
142
|
+
transport: createNodeTransport({
|
|
143
|
+
baseUrl: 'https://porta.example.com',
|
|
144
|
+
apiPrefix: '/api',
|
|
145
|
+
auth: createTokenAuth({ token: userPortaAccessToken }),
|
|
146
|
+
}),
|
|
96
147
|
});
|
|
97
148
|
|
|
98
|
-
|
|
149
|
+
await (interactive ? userClient : serviceClient).users.invite({
|
|
150
|
+
organizationId: process.env.PORTA_TENANT_ORG_ID!,
|
|
151
|
+
email: 'new.user@example.com',
|
|
152
|
+
roles: [{ applicationId: process.env.PORTA_APP_ID!, roleId: roleId }],
|
|
153
|
+
});
|
|
99
154
|
```
|
|
100
155
|
|
|
156
|
+
The tenant route only allows roles owned by the token client's application.
|
|
157
|
+
Custom claim pre-assignment remains a control-plane capability in this
|
|
158
|
+
iteration. A tenant user cannot grant a role that exceeds their own live
|
|
159
|
+
permissions.
|
|
160
|
+
|
|
161
|
+
The service client must be configured with:
|
|
162
|
+
|
|
163
|
+
| Field | Value |
|
|
164
|
+
| ------------------------- | ------------------------ |
|
|
165
|
+
| `clientType` | `confidential` |
|
|
166
|
+
| `applicationType` | `web` |
|
|
167
|
+
| `grantTypes` | `['client_credentials']` |
|
|
168
|
+
| `scope` | `org:user:invite` |
|
|
169
|
+
| `tokenEndpointAuthMethod` | `client_secret_post` |
|
|
170
|
+
|
|
171
|
+
`createClientCredentialsAuth` sends the client secret in the form body, so the
|
|
172
|
+
client must allow `client_secret_post`.
|
|
173
|
+
|
|
101
174
|
### AI Agent Integration
|
|
102
175
|
|
|
103
176
|
```typescript
|
|
104
|
-
import { createPortaClient
|
|
177
|
+
import { createPortaClient } from '@portaidentity/sdk';
|
|
178
|
+
import { getToolDefinitions, executeTool } from '@portaidentity/sdk/agent';
|
|
105
179
|
import { createNodeTransport, createTokenAuth } from '@portaidentity/sdk/node';
|
|
106
180
|
|
|
107
181
|
// Get tool definitions for LLM function calling
|
|
@@ -109,36 +183,39 @@ const tools = getToolDefinitions();
|
|
|
109
183
|
// → [{ name: 'organizations.list', description: '...', parameters: [...] }, ...]
|
|
110
184
|
|
|
111
185
|
// Execute a tool call from an AI agent
|
|
112
|
-
const client = createPortaClient(
|
|
113
|
-
createNodeTransport({
|
|
114
|
-
|
|
186
|
+
const client = createPortaClient({
|
|
187
|
+
transport: createNodeTransport({
|
|
188
|
+
baseUrl: 'https://porta.example.com',
|
|
189
|
+
auth: createTokenAuth({ token: process.env.PORTA_ACCESS_TOKEN! }),
|
|
190
|
+
}),
|
|
191
|
+
});
|
|
115
192
|
|
|
116
193
|
const result = await executeTool(client, 'organizations.list', { page: 1 });
|
|
117
194
|
```
|
|
118
195
|
|
|
119
196
|
## Domain Namespaces
|
|
120
197
|
|
|
121
|
-
| Namespace | Methods | Description
|
|
122
|
-
| --------------- | ------- |
|
|
123
|
-
| `organizations` | 10 | CRUD, status lifecycle, slug validation, history
|
|
124
|
-
| `applications` | 13 | CRUD, status, module management, history
|
|
125
|
-
| `clients` | 12 | CRUD, status, secret management, history
|
|
126
|
-
| `users` | 19 | CRUD, status transitions, password, email, and export
|
|
127
|
-
| `usersById` | 8 | Org-less get/update, password, email, and history
|
|
128
|
-
| `roles` | 9 | CRUD and permission assignment
|
|
129
|
-
| `permissions` | 6 | CRUD
|
|
198
|
+
| Namespace | Methods | Description |
|
|
199
|
+
| --------------- | ------- | ------------------------------------------------------- |
|
|
200
|
+
| `organizations` | 10 | CRUD, status lifecycle, slug validation, history |
|
|
201
|
+
| `applications` | 13 | CRUD, status, module management, history |
|
|
202
|
+
| `clients` | 12 | CRUD, status, secret management, history |
|
|
203
|
+
| `users` | 19 | CRUD, status transitions, password, email, and export |
|
|
204
|
+
| `usersById` | 8 | Org-less get/update, password, email, and history |
|
|
205
|
+
| `roles` | 9 | CRUD and permission assignment |
|
|
206
|
+
| `permissions` | 6 | CRUD |
|
|
130
207
|
| `userRoles` | 4 | List, assign, remove, and resolve effective permissions |
|
|
131
|
-
| `customClaims` | 10 | Claim definition CRUD and user claim values
|
|
132
|
-
| `config` | 3 | System configuration get/set/list
|
|
133
|
-
| `keys` | 3 | Signing key list/generate/rotate
|
|
134
|
-
| `audit` | 1 | Audit log listing with filters
|
|
135
|
-
| `stats` | 1 | Dashboard statistics
|
|
136
|
-
| `sessions` | 3 | Session listing and revocation
|
|
137
|
-
| `bulk` | 1 | Bulk status operations
|
|
138
|
-
| `branding` | 5 | Org branding settings and asset management
|
|
139
|
-
| `exports` | 2 | CSV/JSON reports and selective manifest export
|
|
140
|
-
| `twoFactor` | 3 | 2FA status, disable, reset
|
|
141
|
-
| `imports` | 2 | Manifest preview and atomic import
|
|
208
|
+
| `customClaims` | 10 | Claim definition CRUD and user claim values |
|
|
209
|
+
| `config` | 3 | System configuration get/set/list |
|
|
210
|
+
| `keys` | 3 | Signing key list/generate/rotate |
|
|
211
|
+
| `audit` | 1 | Audit log listing with filters |
|
|
212
|
+
| `stats` | 1 | Dashboard statistics |
|
|
213
|
+
| `sessions` | 3 | Session listing and revocation |
|
|
214
|
+
| `bulk` | 1 | Bulk status operations |
|
|
215
|
+
| `branding` | 5 | Org branding settings and asset management |
|
|
216
|
+
| `exports` | 2 | CSV/JSON reports and selective manifest export |
|
|
217
|
+
| `twoFactor` | 3 | 2FA status, disable, reset |
|
|
218
|
+
| `imports` | 2 | Manifest preview and atomic import |
|
|
142
219
|
|
|
143
220
|
## Environment Portability
|
|
144
221
|
|
package/dist/client.d.ts
CHANGED
|
@@ -41,8 +41,8 @@ export interface PortaClient {
|
|
|
41
41
|
* import { createTokenAuth } from '@portaidentity/sdk/node';
|
|
42
42
|
*
|
|
43
43
|
* const transport = createNodeTransport({
|
|
44
|
-
* baseUrl: 'https://porta.local:3443
|
|
45
|
-
* auth: createTokenAuth('my-bearer-token'),
|
|
44
|
+
* baseUrl: 'https://porta.local:3443',
|
|
45
|
+
* auth: createTokenAuth({ token: 'my-bearer-token' }),
|
|
46
46
|
* });
|
|
47
47
|
*
|
|
48
48
|
* const porta = createPortaClient({ transport });
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAsB1D,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,UAAU,EACV,cAAc,EACd,aAAa,EACb,eAAe,EACf,aAAa,EACd,MAAM,oBAAoB,CAAC;AAM5B,MAAM,WAAW,kBAAkB;IACjC,yFAAyF;IACzF,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,mBAAmB,CAAC;IACnC,YAAY,EAAE,kBAAkB,CAAC;IACjC,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,WAAW,CAAC;IACnB,kFAAkF;IAClF,SAAS,EAAE,qBAAqB,CAAC;IACjC,SAAS,EAAE,eAAe,CAAC;IAE3B,KAAK,EAAE,WAAW,CAAC;IACnB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,YAAY,EAAE,kBAAkB,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,aAAa,CAAC;IACvB,SAAS,EAAE,eAAe,CAAC;IAC3B,OAAO,EAAE,aAAa,CAAC;CACxB;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAyB1E"}
|
package/dist/client.js
CHANGED
|
@@ -17,8 +17,8 @@ import { createOrganizationsDomain, createApplicationsDomain, createClientsDomai
|
|
|
17
17
|
* import { createTokenAuth } from '@portaidentity/sdk/node';
|
|
18
18
|
*
|
|
19
19
|
* const transport = createNodeTransport({
|
|
20
|
-
* baseUrl: 'https://porta.local:3443
|
|
21
|
-
* auth: createTokenAuth('my-bearer-token'),
|
|
20
|
+
* baseUrl: 'https://porta.local:3443',
|
|
21
|
+
* auth: createTokenAuth({ token: 'my-bearer-token' }),
|
|
22
22
|
* });
|
|
23
23
|
*
|
|
24
24
|
* const porta = createPortaClient({ transport });
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,2BAA2B,EAC3B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,2BAA2B,EAC3B,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAwD5B,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE9B,OAAO;QACL,aAAa,EAAE,yBAAyB,CAAC,SAAS,CAAC;QACnD,YAAY,EAAE,wBAAwB,CAAC,SAAS,CAAC;QACjD,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC;QACvC,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC;QACnC,SAAS,EAAE,2BAA2B,CAAC,SAAS,CAAC;QACjD,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC;QAE3C,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC;QACnC,WAAW,EAAE,uBAAuB,CAAC,SAAS,CAAC;QAC/C,YAAY,EAAE,wBAAwB,CAAC,SAAS,CAAC;QACjD,MAAM,EAAE,kBAAkB,CAAC,SAAS,CAAC;QACrC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC;QACjC,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC;QACnC,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC;QACnC,QAAQ,EAAE,oBAAoB,CAAC,SAAS,CAAC;QACzC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC;QACjC,QAAQ,EAAE,oBAAoB,CAAC,SAAS,CAAC;QACzC,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC;QACvC,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC;QAC3C,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -40,6 +40,13 @@ export interface BrowserTransportOptions {
|
|
|
40
40
|
* Provide a custom handler to override (e.g., show a login modal).
|
|
41
41
|
*/
|
|
42
42
|
onUnauthorized?: () => void;
|
|
43
|
+
/**
|
|
44
|
+
* API mount prefix.
|
|
45
|
+
*
|
|
46
|
+
* Defaults to `/api/admin` for the control-plane Admin API. Tenant-scoped
|
|
47
|
+
* calls use `/api`.
|
|
48
|
+
*/
|
|
49
|
+
apiPrefix?: string;
|
|
43
50
|
}
|
|
44
51
|
/**
|
|
45
52
|
* Creates a browser-oriented HTTP transport.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-transport.d.ts","sourceRoot":"","sources":["../../src/transport/browser-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,YAAY,CAAC;AAUrF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAEnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE9C;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"browser-transport.d.ts","sourceRoot":"","sources":["../../src/transport/browser-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,YAAY,CAAC;AAUrF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAEnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE9C;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAE5B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,aAAa,CA2EtF"}
|
|
@@ -33,11 +33,11 @@ import { buildRequestUrl, extractResponseHeaders, buildCommonHeaders, serializeB
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
export function createBrowserTransport(options) {
|
|
36
|
-
const { baseUrl, getCsrfToken, setCsrfToken, onUnauthorized } = options;
|
|
36
|
+
const { baseUrl, getCsrfToken, setCsrfToken, onUnauthorized, apiPrefix } = options;
|
|
37
37
|
return {
|
|
38
38
|
async request(req) {
|
|
39
|
-
// Build full URL with
|
|
40
|
-
const url = buildRequestUrl(baseUrl, req.path, req.params);
|
|
39
|
+
// Build full URL with the configured API prefix and query params
|
|
40
|
+
const url = buildRequestUrl(baseUrl, req.path, req.params, apiPrefix);
|
|
41
41
|
// Build common headers (Accept, Content-Type, SDK version)
|
|
42
42
|
const headers = buildCommonHeaders(req);
|
|
43
43
|
// Add CSRF token for state-changing methods
|
|
@@ -85,7 +85,12 @@ export function createBrowserTransport(options) {
|
|
|
85
85
|
}
|
|
86
86
|
// 2xx + raw — return with native Response for binary streaming
|
|
87
87
|
if (req.responseType === 'raw') {
|
|
88
|
-
return {
|
|
88
|
+
return {
|
|
89
|
+
status: response.status,
|
|
90
|
+
headers: responseHeaders,
|
|
91
|
+
body: undefined,
|
|
92
|
+
raw: response,
|
|
93
|
+
};
|
|
89
94
|
}
|
|
90
95
|
// 2xx + json — parse body and return
|
|
91
96
|
const body = await response.json();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-transport.js","sourceRoot":"","sources":["../../src/transport/browser-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"browser-transport.js","sourceRoot":"","sources":["../../src/transport/browser-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC;AA2CpB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgC;IACrE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEnF,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,GAAqB;YACjC,iEAAiE;YACjE,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YAEtE,2DAA2D;YAC3D,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAExC,4CAA4C;YAC5C,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,YAAY,EAAE,CAAC;gBACzC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;gBACjC,IAAI,SAAS,EAAE,CAAC;oBACd,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;gBACtC,CAAC;YACH,CAAC;YAED,wCAAwC;YACxC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,OAAO;gBACP,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC;gBAC9C,WAAW,EAAE,SAAS;gBACtB,MAAM,EAAE,GAAG,CAAC,MAAM;aACnB,CAAC,CAAC;YAEH,6CA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gBAC/B,OAAO;oBACL,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,OAAO,EAAE,eAAe;oBACxB,IAAI,EAAE,SAAS;oBACf,GAAG,EAAE,QAAQ;iBACd,CAAC;YACJ,CAAC;YAED,qCAAqC;YACrC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;QACrE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -27,6 +27,13 @@ export interface NodeTransportOptions {
|
|
|
27
27
|
* a token refresh and one automatic retry.
|
|
28
28
|
*/
|
|
29
29
|
auth: AuthProvider;
|
|
30
|
+
/**
|
|
31
|
+
* API mount prefix.
|
|
32
|
+
*
|
|
33
|
+
* Defaults to `/api/admin` for the control-plane Admin API. Tenant-scoped
|
|
34
|
+
* BFF calls use `/api`.
|
|
35
|
+
*/
|
|
36
|
+
apiPrefix?: string;
|
|
30
37
|
}
|
|
31
38
|
/**
|
|
32
39
|
* Creates a Node.js / server-side HTTP transport.
|
|
@@ -43,7 +50,7 @@ export interface NodeTransportOptions {
|
|
|
43
50
|
* ```typescript
|
|
44
51
|
* const transport = createNodeTransport({
|
|
45
52
|
* baseUrl: 'https://porta.example.com',
|
|
46
|
-
* auth: createTokenAuth('my-access-token'),
|
|
53
|
+
* auth: createTokenAuth({ token: 'my-access-token' }),
|
|
47
54
|
* });
|
|
48
55
|
* ```
|
|
49
56
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-transport.d.ts","sourceRoot":"","sources":["../../src/transport/node-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUrD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAqBhF"}
|
|
1
|
+
{"version":3,"file":"node-transport.d.ts","sourceRoot":"","sources":["../../src/transport/node-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUrD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,IAAI,EAAE,YAAY,CAAC;IAEnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAqBhF"}
|
|
@@ -26,22 +26,22 @@ import { buildRequestUrl, extractResponseHeaders, buildCommonHeaders, serializeB
|
|
|
26
26
|
* ```typescript
|
|
27
27
|
* const transport = createNodeTransport({
|
|
28
28
|
* baseUrl: 'https://porta.example.com',
|
|
29
|
-
* auth: createTokenAuth('my-access-token'),
|
|
29
|
+
* auth: createTokenAuth({ token: 'my-access-token' }),
|
|
30
30
|
* });
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
export function createNodeTransport(options) {
|
|
34
|
-
const { baseUrl, auth } = options;
|
|
34
|
+
const { baseUrl, auth, apiPrefix } = options;
|
|
35
35
|
return {
|
|
36
36
|
async request(req) {
|
|
37
37
|
// Get access token from auth provider
|
|
38
38
|
const token = await auth.getToken();
|
|
39
39
|
// Execute the initial request
|
|
40
|
-
const response = await executeRequest(baseUrl, req, token);
|
|
40
|
+
const response = await executeRequest(baseUrl, req, token, apiPrefix);
|
|
41
41
|
// 401 + refreshToken available → attempt token refresh and retry once
|
|
42
42
|
if (response.status === 401 && auth.refreshToken) {
|
|
43
43
|
const newToken = await auth.refreshToken();
|
|
44
|
-
const retryResponse = await executeRequest(baseUrl, req, newToken);
|
|
44
|
+
const retryResponse = await executeRequest(baseUrl, req, newToken, apiPrefix);
|
|
45
45
|
return processResponse(retryResponse, req);
|
|
46
46
|
}
|
|
47
47
|
return processResponse(response, req);
|
|
@@ -58,11 +58,12 @@ export function createNodeTransport(options) {
|
|
|
58
58
|
* @param baseUrl - Base URL of the Porta instance
|
|
59
59
|
* @param req - The transport request to execute
|
|
60
60
|
* @param token - Bearer access token
|
|
61
|
+
* @param apiPrefix - API mount prefix
|
|
61
62
|
* @returns The raw fetch Response
|
|
62
63
|
*/
|
|
63
|
-
async function executeRequest(baseUrl, req, token) {
|
|
64
|
-
// Build full URL with
|
|
65
|
-
const url = buildRequestUrl(baseUrl, req.path, req.params);
|
|
64
|
+
async function executeRequest(baseUrl, req, token, apiPrefix) {
|
|
65
|
+
// Build full URL with the configured API prefix and query params
|
|
66
|
+
const url = buildRequestUrl(baseUrl, req.path, req.params, apiPrefix);
|
|
66
67
|
// Build common headers (Accept, Content-Type, SDK version)
|
|
67
68
|
const headers = buildCommonHeaders(req);
|
|
68
69
|
// Add Bearer token authentication
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-transport.js","sourceRoot":"","sources":["../../src/transport/node-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"node-transport.js","sourceRoot":"","sources":["../../src/transport/node-transport.ts"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C,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AACrE,CAAC"}
|
|
@@ -22,7 +22,7 @@ export interface TransportRequest {
|
|
|
22
22
|
method: HttpMethod;
|
|
23
23
|
/**
|
|
24
24
|
* Resource path (e.g., '/organizations', '/users/123').
|
|
25
|
-
* The transport prepends
|
|
25
|
+
* The transport prepends the configured API prefix (default `/api/admin`).
|
|
26
26
|
*/
|
|
27
27
|
path: string;
|
|
28
28
|
/** JSON request body (serialized by the transport) */
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
* @param baseUrl - Base URL (e.g., 'https://porta.example.com' or '' for same-origin)
|
|
18
18
|
* @param path - Resource path (e.g., '/organizations', '/users/123')
|
|
19
19
|
* @param params - Optional query parameters (null/undefined values are skipped)
|
|
20
|
+
* @param apiPrefix - API mount prefix; defaults to '/api/admin'
|
|
20
21
|
* @returns Complete URL string with query parameters
|
|
21
22
|
*/
|
|
22
|
-
export declare function buildRequestUrl(baseUrl: string, path: string, params?: Record<string, string | number | boolean | undefined | null
|
|
23
|
+
export declare function buildRequestUrl(baseUrl: string, path: string, params?: Record<string, string | number | boolean | undefined | null>, apiPrefix?: string): string;
|
|
23
24
|
/**
|
|
24
25
|
* Extracts response headers as a lowercased-key record.
|
|
25
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/transport/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/transport/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,EACrE,SAAS,SAAe,GACvB,MAAM,CAcR;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMjF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE;IACtC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,GAAG,SAAS,CAK9F;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAMxE"}
|
package/dist/transport/utils.js
CHANGED
|
@@ -18,10 +18,12 @@ import { SDK_VERSION } from '../version.js';
|
|
|
18
18
|
* @param baseUrl - Base URL (e.g., 'https://porta.example.com' or '' for same-origin)
|
|
19
19
|
* @param path - Resource path (e.g., '/organizations', '/users/123')
|
|
20
20
|
* @param params - Optional query parameters (null/undefined values are skipped)
|
|
21
|
+
* @param apiPrefix - API mount prefix; defaults to '/api/admin'
|
|
21
22
|
* @returns Complete URL string with query parameters
|
|
22
23
|
*/
|
|
23
|
-
export function buildRequestUrl(baseUrl, path, params) {
|
|
24
|
-
const
|
|
24
|
+
export function buildRequestUrl(baseUrl, path, params, apiPrefix = '/api/admin') {
|
|
25
|
+
const prefix = apiPrefix.replace(/\/+$/, '');
|
|
26
|
+
const url = `${baseUrl}${prefix}${path}`;
|
|
25
27
|
if (!params)
|
|
26
28
|
return url;
|
|
27
29
|
const parts = [];
|
|
@@ -67,7 +69,7 @@ export function extractResponseHeaders(response) {
|
|
|
67
69
|
*/
|
|
68
70
|
export function buildCommonHeaders(req) {
|
|
69
71
|
const headers = {
|
|
70
|
-
|
|
72
|
+
Accept: 'application/json',
|
|
71
73
|
'X-Porta-SDK-Version': SDK_VERSION,
|
|
72
74
|
};
|
|
73
75
|
// Content-Type: null → omit (FormData), string → use it, undefined → json if body
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/transport/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/transport/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,IAAY,EACZ,MAAqE,EACrE,SAAS,GAAG,YAAY;IAExB,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC;IAEzC,IAAI,CAAC,MAAM;QAAE,OAAO,GAAG,CAAC;IAExB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,CA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