@portaidentity/sdk 1.7.3 → 1.9.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 +27 -0
- package/README.md +70 -41
- package/dist/agent.d.ts +15 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +473 -69
- package/dist/agent.js.map +1 -1
- package/dist/auth/cli-auth.d.ts +45 -71
- package/dist/auth/cli-auth.d.ts.map +1 -1
- package/dist/auth/cli-auth.js +208 -144
- package/dist/auth/cli-auth.js.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/domains/applications.d.ts +22 -3
- package/dist/domains/applications.d.ts.map +1 -1
- package/dist/domains/applications.js +90 -20
- package/dist/domains/applications.js.map +1 -1
- package/dist/domains/branding.d.ts +47 -16
- package/dist/domains/branding.d.ts.map +1 -1
- package/dist/domains/branding.js +28 -5
- package/dist/domains/branding.js.map +1 -1
- package/dist/domains/clients.d.ts +23 -6
- package/dist/domains/clients.d.ts.map +1 -1
- package/dist/domains/clients.js +122 -21
- package/dist/domains/clients.js.map +1 -1
- package/dist/domains/config.d.ts +20 -3
- package/dist/domains/config.d.ts.map +1 -1
- package/dist/domains/config.js +30 -3
- package/dist/domains/config.js.map +1 -1
- package/dist/domains/custom-claims.d.ts +2 -1
- package/dist/domains/custom-claims.d.ts.map +1 -1
- package/dist/domains/custom-claims.js +2 -2
- package/dist/domains/custom-claims.js.map +1 -1
- package/dist/domains/exports.d.ts +6 -1
- package/dist/domains/exports.d.ts.map +1 -1
- package/dist/domains/exports.js +27 -1
- package/dist/domains/exports.js.map +1 -1
- package/dist/domains/helpers.d.ts +31 -0
- package/dist/domains/helpers.d.ts.map +1 -1
- package/dist/domains/helpers.js +72 -1
- package/dist/domains/helpers.js.map +1 -1
- package/dist/domains/imports.d.ts +8 -7
- package/dist/domains/imports.d.ts.map +1 -1
- package/dist/domains/imports.js +158 -14
- package/dist/domains/imports.js.map +1 -1
- package/dist/domains/index.d.ts +1 -1
- package/dist/domains/index.d.ts.map +1 -1
- package/dist/domains/organizations.d.ts +2 -9
- package/dist/domains/organizations.d.ts.map +1 -1
- package/dist/domains/organizations.js +2 -13
- package/dist/domains/organizations.js.map +1 -1
- package/dist/domains/permissions.d.ts +22 -4
- package/dist/domains/permissions.d.ts.map +1 -1
- package/dist/domains/permissions.js +47 -13
- package/dist/domains/permissions.js.map +1 -1
- package/dist/domains/roles.d.ts +26 -16
- package/dist/domains/roles.d.ts.map +1 -1
- package/dist/domains/roles.js +61 -31
- package/dist/domains/roles.js.map +1 -1
- package/dist/domains/user-roles.d.ts +9 -4
- package/dist/domains/user-roles.d.ts.map +1 -1
- package/dist/domains/user-roles.js +32 -6
- package/dist/domains/user-roles.js.map +1 -1
- package/dist/domains/users.d.ts +31 -26
- package/dist/domains/users.d.ts.map +1 -1
- package/dist/domains/users.js +56 -46
- package/dist/domains/users.js.map +1 -1
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +18 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/pagination/index.d.ts +5 -1
- package/dist/pagination/index.d.ts.map +1 -1
- package/dist/pagination/index.js +2 -2
- package/dist/pagination/index.js.map +1 -1
- package/dist/types/applications.d.ts +27 -6
- package/dist/types/applications.d.ts.map +1 -1
- package/dist/types/branding.d.ts +38 -11
- package/dist/types/branding.d.ts.map +1 -1
- package/dist/types/branding.js +0 -5
- package/dist/types/branding.js.map +1 -1
- package/dist/types/bulk.d.ts +2 -4
- package/dist/types/bulk.d.ts.map +1 -1
- package/dist/types/clients.d.ts +104 -13
- package/dist/types/clients.d.ts.map +1 -1
- package/dist/types/common.d.ts +26 -3
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/config.d.ts +57 -21
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -8
- package/dist/types/config.js.map +1 -1
- package/dist/types/exports.d.ts +17 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/imports.d.ts +390 -84
- package/dist/types/imports.d.ts.map +1 -1
- package/dist/types/imports.js +1 -7
- package/dist/types/imports.js.map +1 -1
- package/dist/types/index.d.ts +14 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/organizations.d.ts +5 -9
- package/dist/types/organizations.d.ts.map +1 -1
- package/dist/types/permissions.d.ts +21 -6
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/roles.d.ts +3 -1
- package/dist/types/roles.d.ts.map +1 -1
- package/dist/types/user-roles.d.ts +4 -10
- package/dist/types/user-roles.d.ts.map +1 -1
- package/dist/types/users.d.ts +102 -15
- package/dist/types/users.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,33 @@ 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.9.0] - 2026-09-25
|
|
9
|
+
|
|
10
|
+
Added:
|
|
11
|
+
- Exposed `requireConsent` in the Client, CreateClientInput, and UpdateClientInput.
|
|
12
|
+
|
|
13
|
+
Changed:
|
|
14
|
+
- Validated `requireConsent` in the `isClient` response guard.
|
|
15
|
+
- Added `require_consent` to the portability import type and updated SDK fixtures.
|
|
16
|
+
- Enhanced tests to reject responses whose `requireConsent` is missing or non-boolean; extended exact-type oracle.
|
|
17
|
+
|
|
18
|
+
Deprecated:
|
|
19
|
+
- None.
|
|
20
|
+
|
|
21
|
+
Removed:
|
|
22
|
+
- None.
|
|
23
|
+
|
|
24
|
+
Fixed:
|
|
25
|
+
- Improved testing for SDK client response handling.
|
|
26
|
+
|
|
27
|
+
Security:
|
|
28
|
+
- None.
|
|
29
|
+
|
|
30
|
+
## [1.8.0] - 2026-09-23
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
- Version bump to 1.8.0
|
|
34
|
+
|
|
8
35
|
## [1.7.3] - 2026-08-26
|
|
9
36
|
|
|
10
37
|
### Changed
|
package/README.md
CHANGED
|
@@ -30,10 +30,10 @@ yarn add @portaidentity/sdk
|
|
|
30
30
|
import { createPortaClient, createBrowserTransport } from '@portaidentity/sdk/browser';
|
|
31
31
|
|
|
32
32
|
const transport = createBrowserTransport({
|
|
33
|
-
baseUrl: '/api/admin',
|
|
34
|
-
csrfCookieName: '_csrf',
|
|
33
|
+
baseUrl: '/api/admin', // BFF proxy path
|
|
34
|
+
csrfCookieName: '_csrf', // CSRF cookie name
|
|
35
35
|
csrfHeaderName: 'x-csrf-token',
|
|
36
|
-
on401: () => window.location.href = '/login',
|
|
36
|
+
on401: () => (window.location.href = '/login'),
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
const client = createPortaClient(transport);
|
|
@@ -42,7 +42,8 @@ const client = createPortaClient(transport);
|
|
|
42
42
|
const orgs = await client.organizations.list({ page: 1, pageSize: 20 });
|
|
43
43
|
|
|
44
44
|
// Create a user
|
|
45
|
-
const user = await client.users.create(
|
|
45
|
+
const user = await client.users.create({
|
|
46
|
+
organizationId: 'org-id',
|
|
46
47
|
email: 'user@example.com',
|
|
47
48
|
givenName: 'Jane',
|
|
48
49
|
familyName: 'Doe',
|
|
@@ -66,8 +67,8 @@ const client = createPortaClient(transport);
|
|
|
66
67
|
// List all organizations (auto-pagination)
|
|
67
68
|
const allOrgs = await client.organizations.listAll();
|
|
68
69
|
|
|
69
|
-
//
|
|
70
|
-
await client.users.
|
|
70
|
+
// Deactivate a user
|
|
71
|
+
await client.users.deactivate('org-id', 'user-id');
|
|
71
72
|
|
|
72
73
|
// Assign a role
|
|
73
74
|
await client.userRoles.assign('org-id', 'user-id', { roleId: 'role-id' });
|
|
@@ -76,10 +77,14 @@ await client.userRoles.assign('org-id', 'user-id', { roleId: 'role-id' });
|
|
|
76
77
|
### Client Credentials (Server-to-Server)
|
|
77
78
|
|
|
78
79
|
```typescript
|
|
79
|
-
import {
|
|
80
|
+
import {
|
|
81
|
+
createPortaClient,
|
|
82
|
+
createNodeTransport,
|
|
83
|
+
createClientCredentialsAuth,
|
|
84
|
+
} from '@portaidentity/sdk/node';
|
|
80
85
|
|
|
81
86
|
const auth = createClientCredentialsAuth({
|
|
82
|
-
tokenUrl: 'https://porta.local:3443/super-admin/
|
|
87
|
+
tokenUrl: 'https://porta.local:3443/super-admin/token',
|
|
83
88
|
clientId: 'my-service',
|
|
84
89
|
clientSecret: 'my-secret',
|
|
85
90
|
scope: 'openid',
|
|
@@ -105,7 +110,7 @@ const tools = getToolDefinitions();
|
|
|
105
110
|
|
|
106
111
|
// Execute a tool call from an AI agent
|
|
107
112
|
const client = createPortaClient(
|
|
108
|
-
createNodeTransport({ baseUrl: '...', auth: createTokenAuth('...') })
|
|
113
|
+
createNodeTransport({ baseUrl: '...', auth: createTokenAuth('...') }),
|
|
109
114
|
);
|
|
110
115
|
|
|
111
116
|
const result = await executeTool(client, 'organizations.list', { page: 1 });
|
|
@@ -113,35 +118,55 @@ const result = await executeTool(client, 'organizations.list', { page: 1 });
|
|
|
113
118
|
|
|
114
119
|
## Domain Namespaces
|
|
115
120
|
|
|
116
|
-
| Namespace
|
|
117
|
-
|
|
118
|
-
| `organizations` |
|
|
119
|
-
| `applications`
|
|
120
|
-
| `clients`
|
|
121
|
-
| `users`
|
|
122
|
-
| `roles`
|
|
123
|
-
| `permissions`
|
|
124
|
-
| `userRoles`
|
|
125
|
-
| `userClaims`
|
|
126
|
-
| `customClaims`
|
|
127
|
-
| `config`
|
|
128
|
-
| `keys`
|
|
129
|
-
| `audit`
|
|
130
|
-
| `stats`
|
|
131
|
-
| `sessions`
|
|
132
|
-
| `bulk`
|
|
133
|
-
| `branding`
|
|
134
|
-
| `exports`
|
|
135
|
-
| `twoFactor`
|
|
136
|
-
| `imports` |
|
|
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
|
+
| `roles` | 9 | CRUD and permission assignment |
|
|
128
|
+
| `permissions` | 6 | CRUD |
|
|
129
|
+
| `userRoles` | 3 | List, assign, remove role assignments |
|
|
130
|
+
| `userClaims` | 3 | List, set, remove claim values |
|
|
131
|
+
| `customClaims` | 6 | Claim definition CRUD |
|
|
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 |
|
|
142
|
+
|
|
143
|
+
## Environment Portability
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
const exported = await client.exports.manifest({
|
|
147
|
+
scope: { kind: 'organization', organization_slug: 'acme' },
|
|
148
|
+
categories: ['organizations', 'applications_authorization'],
|
|
149
|
+
application_selection: { all_applications: true, application_slugs: [] },
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const preview = await client.imports.preview(exported.manifest);
|
|
153
|
+
if (preview.errors.length === 0) {
|
|
154
|
+
const applied = await client.imports.apply(exported.manifest, 'keep-existing');
|
|
155
|
+
// Store any applied.credentials secrets now; Porta returns them only once.
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The SDK returns parsed data and never writes files. Manifest export excludes existing credentials
|
|
160
|
+
and other authentication material. Import callers should always preview first; apply repeats all
|
|
161
|
+
server validation and commits atomically.
|
|
137
162
|
|
|
138
163
|
## Auth Providers
|
|
139
164
|
|
|
140
|
-
| Provider
|
|
141
|
-
|
|
142
|
-
| `createTokenAuth(token)`
|
|
143
|
-
| `createClientCredentialsAuth(opts)` | Server-to-server OAuth2 (with caching and concurrent dedup)
|
|
144
|
-
| `createCliAuth(opts)`
|
|
165
|
+
| Provider | Use Case |
|
|
166
|
+
| ----------------------------------- | -------------------------------------------------------------------- |
|
|
167
|
+
| `createTokenAuth(token)` | Static Bearer token (scripts, testing) |
|
|
168
|
+
| `createClientCredentialsAuth(opts)` | Server-to-server OAuth2 (with caching and concurrent dedup) |
|
|
169
|
+
| `createCliAuth(opts)` | CLI credentials file (`~/.porta/credentials.json`) with auto-refresh |
|
|
145
170
|
|
|
146
171
|
## Error Handling
|
|
147
172
|
|
|
@@ -173,6 +198,10 @@ const allUsers = await client.users.listAll('org-id');
|
|
|
173
198
|
// → User[]
|
|
174
199
|
```
|
|
175
200
|
|
|
201
|
+
`users.invite()` returns an `InviteUserResult`. Administrators can activate and deactivate users.
|
|
202
|
+
User lockout is automatic and is not an administrator mutation. `users.getHistory()` returns the
|
|
203
|
+
first-page `{ data, hasMore, nextCursor }` history envelope.
|
|
204
|
+
|
|
176
205
|
## Architecture
|
|
177
206
|
|
|
178
207
|
```
|
|
@@ -199,12 +228,12 @@ const allUsers = await client.users.listAll('org-id');
|
|
|
199
228
|
|
|
200
229
|
## Entrypoints
|
|
201
230
|
|
|
202
|
-
| Import Path
|
|
203
|
-
|
|
204
|
-
| `@portaidentity/sdk`
|
|
205
|
-
| `@portaidentity/sdk/browser` | + BrowserTransport
|
|
206
|
-
| `@portaidentity/sdk/node`
|
|
207
|
-
| `@portaidentity/sdk/agent`
|
|
231
|
+
| Import Path | Includes | Excludes |
|
|
232
|
+
| ---------------------------- | ----------------------------------------- | -------------------------------- |
|
|
233
|
+
| `@portaidentity/sdk` | Types, errors, pagination, client factory | Transport, auth (bring your own) |
|
|
234
|
+
| `@portaidentity/sdk/browser` | + BrowserTransport | NodeTransport, auth providers |
|
|
235
|
+
| `@portaidentity/sdk/node` | + NodeTransport, all auth providers | BrowserTransport |
|
|
236
|
+
| `@portaidentity/sdk/agent` | + Tool definitions, executeTool | Transports, auth |
|
|
208
237
|
|
|
209
238
|
## Testing
|
|
210
239
|
|
package/dist/agent.d.ts
CHANGED
|
@@ -8,21 +8,35 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { PortaClient } from './client.js';
|
|
10
10
|
export interface ToolParameter {
|
|
11
|
+
/** Argument name passed to the executor. */
|
|
11
12
|
name: string;
|
|
12
|
-
|
|
13
|
+
/** JSON-compatible argument category exposed to agent clients. */
|
|
14
|
+
type: 'string' | 'number' | 'number|string' | 'boolean' | 'object' | 'array';
|
|
15
|
+
/** Human-readable explanation of the argument. */
|
|
13
16
|
description: string;
|
|
17
|
+
/** Whether callers must provide the argument. */
|
|
14
18
|
required: boolean;
|
|
19
|
+
/** Optional closed set of accepted string values. */
|
|
15
20
|
enum?: string[];
|
|
16
21
|
}
|
|
22
|
+
/** Metadata that describes one callable SDK operation. */
|
|
17
23
|
export interface ToolDefinition {
|
|
24
|
+
/** Dot-separated SDK domain and method name. */
|
|
18
25
|
name: string;
|
|
26
|
+
/** Human-readable explanation of the operation. */
|
|
19
27
|
description: string;
|
|
28
|
+
/** Ordered arguments forwarded to the SDK method. */
|
|
20
29
|
parameters: ToolParameter[];
|
|
30
|
+
/** Human-readable TypeScript-style result description. */
|
|
21
31
|
returns: string;
|
|
22
32
|
}
|
|
33
|
+
/** Result returned by the generic tool executor. */
|
|
23
34
|
export interface ToolResult {
|
|
35
|
+
/** Whether the SDK method completed successfully. */
|
|
24
36
|
success: boolean;
|
|
37
|
+
/** SDK result when the operation succeeds. */
|
|
25
38
|
data?: unknown;
|
|
39
|
+
/** Safe error description when the operation fails. */
|
|
26
40
|
error?: string;
|
|
27
41
|
}
|
|
28
42
|
/**
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC7E,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA6hBD;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,CAErD;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,UAAU,CAAC,CAoCrB"}
|