@seliseblocks/client 0.1.6 → 0.2.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/{AI_USAGE_GUIDE.md → AGENT_GUIDE.md} +2 -2
- package/CHANGELOG.md +57 -0
- package/LICENSE +21 -21
- package/README.md +25 -13
- package/dist/auth/auth-client.d.ts +3 -3
- package/dist/client.d.ts +18 -2
- package/dist/client.js +2 -1
- package/dist/http/http-client.d.ts +2 -2
- package/dist/http/http-client.js +25 -4
- package/dist/index.d.ts +7 -4
- package/dist/mfa/mfa-client.d.ts +2 -0
- package/dist/mfa/mfa-client.js +2 -0
- package/dist/mfa/types.d.ts +2 -1
- package/dist/notifier/types.d.ts +1 -1
- package/package.json +59 -48
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Blocks Client Guide for AI Agents
|
|
2
2
|
|
|
3
3
|
Use this file only for `@seliseblocks/client` app-code work. For full method details, read the source docstrings.
|
|
4
4
|
|
|
@@ -159,7 +159,7 @@ await blocks.auth.refresh({
|
|
|
159
159
|
npm test
|
|
160
160
|
npm run lint
|
|
161
161
|
npm pack --dry-run
|
|
162
|
-
rg -n "v4[/\\]api|iam[/\\]v4[/\\]api|data[/\\]v4[/\\]api|localization[/\\]v4[/\\]api" src README.md
|
|
162
|
+
rg -n "v4[/\\]api|iam[/\\]v4[/\\]api|data[/\\]v4[/\\]api|localization[/\\]v4[/\\]api" src README.md AGENT_GUIDE.md test
|
|
163
163
|
```
|
|
164
164
|
|
|
165
165
|
Only negative route-guard tests should match.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@seliseblocks/client`.
|
|
4
|
+
|
|
5
|
+
This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
Versions before 0.2.0 were released without a changelog; their history is in the
|
|
7
|
+
repository's git log.
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Breaking
|
|
12
|
+
|
|
13
|
+
- `blocks.config` no longer carries `accessToken` or `onUnauthorized`. Both are
|
|
14
|
+
callables that reach a live session, and this package's stated boundary is that
|
|
15
|
+
it never becomes somewhere to read one from. Use
|
|
16
|
+
`await blocks.auth.accessToken()` for the token; the hook stays available to
|
|
17
|
+
the client internally. Everything else on `config` (`apiUrl`, `xBlocksKey`,
|
|
18
|
+
`appDomain`, `oidc`) is unchanged, and its type is now `BlocksPublicConfig`.
|
|
19
|
+
- `http.request()` refuses an absolute URL whose origin is not the configured
|
|
20
|
+
`apiUrl`. It attaches the bearer token, `x-blocks-key`, and cookies, so a
|
|
21
|
+
foreign origin would have received a live session. `http.external(url)` is the
|
|
22
|
+
path for third-party URLs and sends no Blocks credentials. An absolute URL on
|
|
23
|
+
the configured API still works.
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Types that were reachable in the public surface but not importable by name are
|
|
28
|
+
now exported: `BlocksHttpClient`, `BlocksDataSchema`,
|
|
29
|
+
`BlocksDataCollectionOptions`, `BlocksDataGetOptions`,
|
|
30
|
+
`BlocksDataDeleteOptions`, `BlocksAuthJsonOptions`,
|
|
31
|
+
`BlocksExternalRequestOptions`, and `BlocksPublicConfig`.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- `RequiredConfig` is renamed `BlocksResolvedConfig`, matching every other
|
|
36
|
+
exported name. `RequiredConfig` remains as a deprecated alias.
|
|
37
|
+
- Documented the IAM enums the typings previously called opaque:
|
|
38
|
+
`mfaType`/`UserMfaType` (0 None, 1 TOTP, 2 Email, 3 Sms, 4 WhatsApp — only 1
|
|
39
|
+
and 2 have a provider, and `setMethod` turns MFA *off* for any other value)
|
|
40
|
+
and the notifier sort order (1 CreatedTime newest-first, 2 ReadStatus; any
|
|
41
|
+
other value, including an omitted 0, returns an empty list).
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- A non-2xx response whose body is not valid JSON despite an
|
|
46
|
+
`application/json` content type now throws `BlocksApiError` carrying the status
|
|
47
|
+
and the raw text. It previously threw a bare `SyntaxError` before the status
|
|
48
|
+
was ever checked, which lost the status and broke the documented contract that
|
|
49
|
+
every non-2xx response surfaces as a `BlocksApiError` — the case that matters
|
|
50
|
+
most, since a proxy or WAF error page is exactly what arrives mislabelled.
|
|
51
|
+
- The README's MFA examples were stranded under the Auth heading with no heading
|
|
52
|
+
of their own.
|
|
53
|
+
|
|
54
|
+
### Package metadata
|
|
55
|
+
|
|
56
|
+
- Added `repository`, `homepage`, `bugs`, and `author`.
|
|
57
|
+
- `LICENSE` now matches the repository's copyright line.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) SELISE
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SELISE Digital Platforms
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Framework-neutral TypeScript SDK for SELISE Blocks frontend and app-runtime code.
|
|
4
4
|
|
|
5
|
-
`@seliseblocks/client` gives consumer apps a small, typed wrapper around the Blocks APIs they normally call at runtime: Auth/IAM, Data, Localization, and shared HTTP configuration. Detailed `what / why / how` descriptions are kept on the SDK functions themselves so editors and generated typings show the guidance where developers use the API.
|
|
5
|
+
[`@seliseblocks/client`](https://www.npmjs.com/package/@seliseblocks/client) gives consumer apps a small, typed wrapper around the Blocks APIs they normally call at runtime: Auth/IAM, Data, Localization, and shared HTTP configuration. Detailed `what / why / how` descriptions are kept on the SDK functions themselves so editors and generated typings show the guidance where developers use the API.
|
|
6
6
|
|
|
7
7
|
Admin/control-plane work belongs in `@seliseblocks/cli-os`: project setup, schema/rules deploy, release deploy, and AI/admin terminal workflows.
|
|
8
8
|
|
|
9
|
-
For AI agents and automation, see [
|
|
9
|
+
For AI agents and automation, see [AGENT_GUIDE.md](AGENT_GUIDE.md).
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -37,6 +37,17 @@ const blocks = createBlocksClient({
|
|
|
37
37
|
|
|
38
38
|
The SDK does not store tokens. Your app owns login state, refresh scheduling, storage, and logout cleanup.
|
|
39
39
|
|
|
40
|
+
`blocks.config` reads back the resolved settings (`apiUrl`, `xBlocksKey`,
|
|
41
|
+
`appDomain`, `oidc`). It deliberately excludes your `accessToken` resolver and
|
|
42
|
+
`onUnauthorized` hook, so the client never doubles as a place to read a live
|
|
43
|
+
session out of; use `await blocks.auth.accessToken()` when you need the token.
|
|
44
|
+
|
|
45
|
+
`http.request()` only ever talks to the configured `apiUrl` — it attaches your
|
|
46
|
+
bearer token, `x-blocks-key`, and cookies, so an absolute URL on another origin
|
|
47
|
+
is refused rather than handed a live session. Use `http.external(url)` for
|
|
48
|
+
third-party URLs such as a pre-signed storage upload; it sends no Blocks
|
|
49
|
+
credentials.
|
|
50
|
+
|
|
40
51
|
Use a configured OIDC redirect URI when your app has one. The current-origin `/login/callback` URL is only a browser fallback.
|
|
41
52
|
|
|
42
53
|
## Auth
|
|
@@ -75,6 +86,13 @@ Other auth APIs, such as user info, organization switch, logout, signup, recover
|
|
|
75
86
|
|
|
76
87
|
`auth.accessToken()` resolves the caller-owned bearer token configured on `createBlocksClient` (string or callback). `auth.isAuthenticated()` checks the current session against IAM through `GET /iam/v4/auth/me` and returns a boolean based on the raw response status - use it instead of `userInfo()` when you need a true/false signal, since IAM's hosted IdP flow may set the session as a cookie with no local `accessToken` to inspect.
|
|
77
88
|
|
|
89
|
+
## MFA
|
|
90
|
+
|
|
91
|
+
`blocks.mfa` covers the signed-in user's own multi-factor setup — TOTP
|
|
92
|
+
enrollment, OTP challenges, switching the active method, and backup codes —
|
|
93
|
+
plus `mfa.saveConfig()` for tenant-wide MFA policy, which needs an admin
|
|
94
|
+
token.
|
|
95
|
+
|
|
78
96
|
```ts
|
|
79
97
|
const config = await blocks.mfa.config();
|
|
80
98
|
await blocks.mfa.totp.setup();
|
|
@@ -177,17 +195,11 @@ const selectedKeys = await blocks.localization.keysByNames({
|
|
|
177
195
|
|
|
178
196
|
## API Surface
|
|
179
197
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
- `
|
|
185
|
-
- `blocks.localization`: tenant language/module discovery, UILM dictionary loading, selected key lookup, simple `t()` lookup.
|
|
186
|
-
- `blocks.mfa`: tenant MFA policy read/save, TOTP enrollment, OTP generate/resend/verify, method switch, disable, and backup codes.
|
|
187
|
-
- `blocks.mail`: `send`/`sendToAny` transactional email through the tenant's configured mail provider.
|
|
188
|
-
- `blocks.notifier`: `notify`, `getNotifications`, `getUnreadNotificationsBySubscriptionFilter`, `markNotificationAsRead`, `markAllNotificationAsRead`.
|
|
189
|
-
|
|
190
|
-
Professional class names are exported for advanced typing and adapters: `BlocksAuthenticationClient`, `BlocksIAMClient`, `BlocksDataClient`, `BlocksLocalizationClient`, `BlocksMfaClient`, `BlocksMailClient`, and `BlocksNotifierClient`. `BlocksApiError` is exported for typed error handling - every non-2xx response from `http.request`/`http.external` throws it, exposing `status`, `statusText`, and the parsed `body`:
|
|
198
|
+
See [`AGENT_GUIDE.md`](AGENT_GUIDE.md)'s Service Map for the full method-level
|
|
199
|
+
list under `blocks.auth`, `blocks.iam`, `blocks.data`, `blocks.localization`,
|
|
200
|
+
`blocks.mfa`, `blocks.mail`, and `blocks.notifier`.
|
|
201
|
+
|
|
202
|
+
Professional class names are exported for advanced typing and adapters: `BlocksAuthenticationClient`, `BlocksIAMClient`, `BlocksDataClient`, `BlocksLocalizationClient`, `BlocksMfaClient`, `BlocksMailClient`, and `BlocksNotifierClient`. `BlocksApiError` is exported for typed error handling - every non-2xx response from `http.request`/`http.external` throws it, exposing `status`, `statusText`, and the parsed `body`. That holds even when the body is not really JSON: a proxy or WAF answering with an HTML error page under a JSON content type surfaces as a `BlocksApiError` carrying the status and the raw text, not as a `SyntaxError`.
|
|
191
203
|
|
|
192
204
|
```ts
|
|
193
205
|
try {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlocksResolvedConfig } from "../client.js";
|
|
2
2
|
import type { BlocksAuthJsonOptions, BlocksAuthLoginRequest, BlocksAuthPassThroughResponse, BlocksAuthResponse, BlocksClientCredentialsRequest, BlocksIdpCallbackRequest, BlocksIdpInitiateRequest, BlocksIdpInitiateResponse, BlocksLoginOption, BlocksLogoutRequest, BlocksOidcRefreshRequest, BlocksOidcUserInfo, BlocksRefreshRequest, BlocksSocialLoginRequest, BlocksSwitchOrganizationRequest } from "./types.js";
|
|
3
|
-
export type { BlocksAuthLoginRequest, BlocksAuthPassThroughResponse, BlocksAuthResponse, BlocksClientCredentialsRequest, BlocksIdpCallbackRequest, BlocksIdpInitiateRequest, BlocksIdpInitiateResponse, BlocksLoginOption, BlocksLogoutRequest, BlocksOidcRefreshRequest, BlocksOidcUserInfo, BlocksRefreshRequest, BlocksSocialLoginRequest, BlocksSwitchOrganizationRequest } from "./types.js";
|
|
3
|
+
export type { BlocksAuthJsonOptions, BlocksAuthLoginRequest, BlocksAuthPassThroughResponse, BlocksAuthResponse, BlocksClientCredentialsRequest, BlocksIdpCallbackRequest, BlocksIdpInitiateRequest, BlocksIdpInitiateResponse, BlocksLoginOption, BlocksLogoutRequest, BlocksOidcRefreshRequest, BlocksOidcUserInfo, BlocksRefreshRequest, BlocksSocialLoginRequest, BlocksSwitchOrganizationRequest } from "./types.js";
|
|
4
4
|
export declare class BlocksAuthenticationClient {
|
|
5
5
|
private readonly clientConfig;
|
|
6
6
|
private readonly fetchImpl;
|
|
7
|
-
constructor(clientConfig:
|
|
7
|
+
constructor(clientConfig: BlocksResolvedConfig, fetchImpl?: typeof fetch);
|
|
8
8
|
/**
|
|
9
9
|
* What: discovers tenant login options through `GET /iam/v4/auth/login-options`.
|
|
10
10
|
* Why: login screens need to know which login methods the tenant supports before rendering controls.
|
package/dist/client.d.ts
CHANGED
|
@@ -58,9 +58,18 @@ export type BlocksClientConfig = {
|
|
|
58
58
|
*/
|
|
59
59
|
xBlocksKey: string;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* The resolved configuration a client exposes on `blocks.config`: the settings
|
|
63
|
+
* an app may want to read back (which tenant, which API, which OIDC client),
|
|
64
|
+
* with the caller-owned `accessToken` resolver and `onUnauthorized` hook left
|
|
65
|
+
* out. Those two are callables that reach live credentials, and this package's
|
|
66
|
+
* boundary is that it never becomes a place to read a session from -- use
|
|
67
|
+
* `blocks.auth.accessToken()` when you need the token itself.
|
|
68
|
+
*/
|
|
69
|
+
export type BlocksPublicConfig = Omit<BlocksResolvedConfig, "accessToken" | "onUnauthorized">;
|
|
61
70
|
export type BlocksClient = {
|
|
62
71
|
auth: BlocksAuthenticationClient;
|
|
63
|
-
config: Readonly<
|
|
72
|
+
config: Readonly<BlocksPublicConfig>;
|
|
64
73
|
data: BlocksDataClient;
|
|
65
74
|
http: BlocksHttpClient;
|
|
66
75
|
iam: BlocksIAMClient;
|
|
@@ -69,7 +78,12 @@ export type BlocksClient = {
|
|
|
69
78
|
mfa: BlocksMfaClient;
|
|
70
79
|
notifier: BlocksNotifierClient;
|
|
71
80
|
};
|
|
72
|
-
|
|
81
|
+
/**
|
|
82
|
+
* `BlocksClientConfig` after defaults are applied -- the shape the internal
|
|
83
|
+
* service clients are constructed with. Consumers normally want
|
|
84
|
+
* `BlocksPublicConfig` (what `blocks.config` actually exposes) instead.
|
|
85
|
+
*/
|
|
86
|
+
export type BlocksResolvedConfig = {
|
|
73
87
|
accessToken?: string | (() => Promise<string | undefined> | string | undefined);
|
|
74
88
|
apiUrl: string;
|
|
75
89
|
appDomain?: string;
|
|
@@ -80,6 +94,8 @@ export type RequiredConfig = {
|
|
|
80
94
|
};
|
|
81
95
|
xBlocksKey: string;
|
|
82
96
|
};
|
|
97
|
+
/** @deprecated Renamed to `BlocksResolvedConfig` for consistency with the other exported names. */
|
|
98
|
+
export type RequiredConfig = BlocksResolvedConfig;
|
|
83
99
|
/**
|
|
84
100
|
* What: creates a framework-neutral Blocks SDK instance for one tenant/app runtime.
|
|
85
101
|
* Why: frontend code needs a single configured entry point for IAM, Auth, Data, and Localization APIs.
|
package/dist/client.js
CHANGED
|
@@ -15,9 +15,10 @@ export function createBlocksClient(config) {
|
|
|
15
15
|
const normalized = normalizeConfig(config);
|
|
16
16
|
const auth = new BlocksAuthenticationClient(normalized, config.fetch);
|
|
17
17
|
const http = new BlocksHttpClient(normalized, auth, config.fetch);
|
|
18
|
+
const { accessToken: _accessToken, onUnauthorized: _onUnauthorized, ...publicConfig } = normalized;
|
|
18
19
|
return {
|
|
19
20
|
auth,
|
|
20
|
-
config:
|
|
21
|
+
config: publicConfig,
|
|
21
22
|
data: new BlocksDataClient(http),
|
|
22
23
|
http,
|
|
23
24
|
iam: new BlocksIAMClient(http),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BlocksAuthenticationClient } from "../auth/auth-client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { BlocksResolvedConfig } from "../client.js";
|
|
3
3
|
import { BlocksExternalRequestOptions, BlocksRequestOptions } from "../types.js";
|
|
4
4
|
export declare class BlocksHttpClient {
|
|
5
5
|
private readonly config;
|
|
6
6
|
private readonly auth;
|
|
7
7
|
private readonly fetchImpl;
|
|
8
|
-
constructor(config:
|
|
8
|
+
constructor(config: BlocksResolvedConfig, auth: BlocksAuthenticationClient, fetchImpl?: typeof fetch);
|
|
9
9
|
request<T>(path: string, options?: BlocksRequestOptions): Promise<T>;
|
|
10
10
|
external<T = unknown>(url: string, options?: BlocksExternalRequestOptions): Promise<T>;
|
|
11
11
|
}
|
package/dist/http/http-client.js
CHANGED
|
@@ -61,6 +61,23 @@ export class BlocksHttpClient {
|
|
|
61
61
|
return body;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* `request` attaches the caller's bearer token, `x-blocks-key`, and
|
|
66
|
+
* `credentials: "include"`, so it must only ever reach the configured Blocks
|
|
67
|
+
* API. An absolute URL is still accepted -- callers legitimately pass a full
|
|
68
|
+
* API URL -- but one pointing somewhere else would hand a live session to a
|
|
69
|
+
* third party, so it is refused with a pointer to `external`, which sends no
|
|
70
|
+
* Blocks credentials by design.
|
|
71
|
+
*/
|
|
72
|
+
function sameOriginOnly(path, baseUrl) {
|
|
73
|
+
const target = new URL(path);
|
|
74
|
+
const base = new URL(`${baseUrl}/`);
|
|
75
|
+
if (target.origin !== base.origin) {
|
|
76
|
+
throw new Error(`Refusing to send Blocks credentials to ${target.origin}: it is not the configured apiUrl (${base.origin}). `
|
|
77
|
+
+ "Use blocks.http.external(url) for third-party URLs such as a pre-signed storage upload.");
|
|
78
|
+
}
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
64
81
|
function isBodyInit(value) {
|
|
65
82
|
return typeof Blob !== "undefined" && value instanceof Blob
|
|
66
83
|
|| typeof FormData !== "undefined" && value instanceof FormData
|
|
@@ -71,7 +88,7 @@ function isBodyInit(value) {
|
|
|
71
88
|
}
|
|
72
89
|
function buildUrl(baseUrl, path, query) {
|
|
73
90
|
const url = /^https?:\/\//i.test(path)
|
|
74
|
-
?
|
|
91
|
+
? sameOriginOnly(path, baseUrl)
|
|
75
92
|
: new URL(path.replace(/^\/+/, ""), `${baseUrl}/`);
|
|
76
93
|
for (const [key, value] of Object.entries(query ?? {})) {
|
|
77
94
|
if (value !== undefined)
|
|
@@ -85,9 +102,13 @@ async function parseBody(response) {
|
|
|
85
102
|
const text = await response.text();
|
|
86
103
|
if (!text)
|
|
87
104
|
return undefined;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
// Parsing is best-effort for every content type, including a declared
|
|
106
|
+
// application/json. A proxy, WAF, or load balancer in front of the API can
|
|
107
|
+
// answer with an HTML error page while still claiming JSON; throwing a raw
|
|
108
|
+
// SyntaxError there would lose the HTTP status entirely and break the
|
|
109
|
+
// documented contract that a non-2xx response always surfaces as a
|
|
110
|
+
// BlocksApiError. Returning the raw text keeps the status and hands the
|
|
111
|
+
// caller the body it actually got.
|
|
91
112
|
try {
|
|
92
113
|
return JSON.parse(text);
|
|
93
114
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
export { createBlocksClient } from "./client.js";
|
|
2
2
|
export { BlocksAuthenticationClient } from "./auth/auth-client.js";
|
|
3
3
|
export { BlocksDataClient } from "./data/data-client.js";
|
|
4
|
-
export type { BlocksClient, BlocksClientConfig, BlocksOidcConfig
|
|
4
|
+
export type { BlocksClient, BlocksClientConfig, BlocksOidcConfig, BlocksPublicConfig, BlocksResolvedConfig,
|
|
5
|
+
/** @deprecated Renamed to `BlocksResolvedConfig`. */
|
|
6
|
+
RequiredConfig } from "./client.js";
|
|
5
7
|
export { BlocksApiError } from "./http/errors.js";
|
|
8
|
+
export type { BlocksHttpClient } from "./http/http-client.js";
|
|
6
9
|
export { BlocksIAMClient } from "./iam/iam-client.js";
|
|
7
10
|
export { BlocksLocalizationClient } from "./localization/localization-client.js";
|
|
8
11
|
export { BlocksMailClient } from "./mail/mail-client.js";
|
|
9
12
|
export { BlocksMfaClient } from "./mfa/mfa-client.js";
|
|
10
13
|
export { BlocksNotifierClient } from "./notifier/notifier-client.js";
|
|
11
|
-
export type { BlocksAuthPassThroughResponse, BlocksAuthResponse, BlocksClientCredentialsRequest, BlocksAuthLoginRequest, BlocksIdpCallbackRequest, BlocksIdpInitiateRequest, BlocksIdpInitiateResponse, BlocksLoginOption, BlocksLogoutRequest, BlocksOidcRefreshRequest, BlocksOidcUserInfo, BlocksRefreshRequest, BlocksSocialLoginRequest, BlocksSwitchOrganizationRequest } from "./auth/auth-client.js";
|
|
12
|
-
export type { BlocksRequestOptions } from "./types.js";
|
|
14
|
+
export type { BlocksAuthJsonOptions, BlocksAuthPassThroughResponse, BlocksAuthResponse, BlocksClientCredentialsRequest, BlocksAuthLoginRequest, BlocksIdpCallbackRequest, BlocksIdpInitiateRequest, BlocksIdpInitiateResponse, BlocksLoginOption, BlocksLogoutRequest, BlocksOidcRefreshRequest, BlocksOidcUserInfo, BlocksRefreshRequest, BlocksSocialLoginRequest, BlocksSwitchOrganizationRequest } from "./auth/auth-client.js";
|
|
15
|
+
export type { BlocksExternalRequestOptions, BlocksRequestOptions } from "./types.js";
|
|
13
16
|
export type { BlocksBaseResponse, BlocksGetMyOrganizationsResponse, BlocksGetOrganizationResponse, BlocksGetOrganizationsResponse, BlocksGetPermissionResponse, BlocksGetPermissionsResponse, BlocksGetRoleResponse, BlocksGetRolesResponse, BlocksGetUserResponse, BlocksGetUsersResponse, BlocksIamListRequest, BlocksMeResponse, BlocksOrganization, BlocksPermission, BlocksQueryListResponse, BlocksQueryResponse, BlocksRole, BlocksUser } from "./iam/types.js";
|
|
14
|
-
export type { BlocksDataCollection, BlocksDataListOptions, BlocksDirectoryCreateRequest, BlocksDirectoryDeleteRequest, BlocksDirectoryMoveRequest, BlocksDirectoryUpdateRequest, BlocksFileCopyRequest, BlocksFileCreateVersionRequest, BlocksFileDeleteRequest, BlocksFileGetOptions, BlocksFileInfoListRequest, BlocksFileListRequest, BlocksFileMoveRequest, BlocksFileRenameRequest, BlocksFileUpdateAdditionalInfoRequest, BlocksFileUploadRequest, BlocksFileVersionsRequest, BlocksGraphqlRequest, BlocksLocalStorageUploadRequest, BlocksPagedResult, BlocksRegexGenerateRequest, BlocksSchemaFieldValidationOptions, BlocksSchemaListOptions, BlocksSchemaValidationListOptions, BlocksStorageAccessPolicyRequest, BlocksStorageEffect, BlocksStorageObject, BlocksStorageObjectListRequest, BlocksStorageObjectPageRequest, BlocksStorageObjectSearchRequest, BlocksStorageObjectsResponse, BlocksStorageObjectType, BlocksStoragePermission, BlocksStoragePermissionFlags, BlocksStoragePrincipalType, BlocksStorageResourceRequest, BlocksStorageResourceType, BlocksStorageRevokeAccessRequest, BlocksStorageShareRequest, BlocksStorageToggleInheritanceRequest, BlocksUploadToUrlRequest } from "./data/types.js";
|
|
17
|
+
export type { BlocksDataCollection, BlocksDataCollectionOptions, BlocksDataDeleteOptions, BlocksDataGetOptions, BlocksDataListOptions, BlocksDataSchema, BlocksDirectoryCreateRequest, BlocksDirectoryDeleteRequest, BlocksDirectoryMoveRequest, BlocksDirectoryUpdateRequest, BlocksFileCopyRequest, BlocksFileCreateVersionRequest, BlocksFileDeleteRequest, BlocksFileGetOptions, BlocksFileInfoListRequest, BlocksFileListRequest, BlocksFileMoveRequest, BlocksFileRenameRequest, BlocksFileUpdateAdditionalInfoRequest, BlocksFileUploadRequest, BlocksFileVersionsRequest, BlocksGraphqlRequest, BlocksLocalStorageUploadRequest, BlocksPagedResult, BlocksRegexGenerateRequest, BlocksSchemaFieldValidationOptions, BlocksSchemaListOptions, BlocksSchemaValidationListOptions, BlocksStorageAccessPolicyRequest, BlocksStorageEffect, BlocksStorageObject, BlocksStorageObjectListRequest, BlocksStorageObjectPageRequest, BlocksStorageObjectSearchRequest, BlocksStorageObjectsResponse, BlocksStorageObjectType, BlocksStoragePermission, BlocksStoragePermissionFlags, BlocksStoragePrincipalType, BlocksStorageResourceRequest, BlocksStorageResourceType, BlocksStorageRevokeAccessRequest, BlocksStorageShareRequest, BlocksStorageToggleInheritanceRequest, BlocksUploadToUrlRequest } from "./data/types.js";
|
|
15
18
|
export type { BlocksLocalizationDictionary, BlocksLocalizationKey, BlocksLocalizationKeyResource, BlocksLocalizationKeysByNamesRequest, BlocksLocalizationKeysByNamesResponse, BlocksLocalizationLanguage, BlocksLocalizationModule, BlocksLocalizationTranslationOptions } from "./localization/types.js";
|
|
16
19
|
export type { BlocksMfaBackupCodeUseRequest, BlocksMfaConfig, BlocksMfaConfigSaveRequest, BlocksMfaGenerateRequest, BlocksMfaPassThroughResponse, BlocksMfaResendRequest, BlocksMfaSetMethodRequest, BlocksMfaVerifyRequest, BlocksMfaVerifyTotpSetupRequest } from "./mfa/types.js";
|
|
17
20
|
export type { BlocksMailPassThroughResponse, BlocksSendMailRequest, BlocksSendMailToAnyRequest } from "./mail/types.js";
|
package/dist/mfa/mfa-client.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export declare class BlocksMfaClient {
|
|
|
58
58
|
* What: sets the signed-in user's active MFA method through `PUT /iam/v4/mfa/method`.
|
|
59
59
|
* Why: users who have enrolled more than one method need to switch which one is active.
|
|
60
60
|
* How: pass the `mfaType` to activate; enroll it first (e.g. via `totp.setup`/`verifySetup`) if it isn't already.
|
|
61
|
+
* Careful: IAM only branches on TOTP (1) and Email (2) here -- every other value falls through to its
|
|
62
|
+
* disable path and turns the user's MFA off. Use `disable()` when that is the intent.
|
|
61
63
|
*/
|
|
62
64
|
setMethod(request: BlocksMfaSetMethodRequest): Promise<BlocksMfaPassThroughResponse>;
|
|
63
65
|
/**
|
package/dist/mfa/mfa-client.js
CHANGED
|
@@ -69,6 +69,8 @@ export class BlocksMfaClient {
|
|
|
69
69
|
* What: sets the signed-in user's active MFA method through `PUT /iam/v4/mfa/method`.
|
|
70
70
|
* Why: users who have enrolled more than one method need to switch which one is active.
|
|
71
71
|
* How: pass the `mfaType` to activate; enroll it first (e.g. via `totp.setup`/`verifySetup`) if it isn't already.
|
|
72
|
+
* Careful: IAM only branches on TOTP (1) and Email (2) here -- every other value falls through to its
|
|
73
|
+
* disable path and turns the user's MFA off. Use `disable()` when that is the intent.
|
|
72
74
|
*/
|
|
73
75
|
setMethod(request) {
|
|
74
76
|
return this.http.request(`${MFA_API}/method`, {
|
package/dist/mfa/types.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type BlocksMfaConfigSaveRequest = Record<string, unknown> & {
|
|
|
21
21
|
userMfaType?: number[];
|
|
22
22
|
};
|
|
23
23
|
export type BlocksMfaGenerateRequest = {
|
|
24
|
-
/** IAM
|
|
24
|
+
/** IAM's UserMfaType: 0 None, 1 TOTP, 2 Email, 3 Sms, 4 WhatsApp. Only 1 and 2 have a provider. */
|
|
25
25
|
mfaType: number;
|
|
26
26
|
sendPhoneNumberAsEmailDomain?: string;
|
|
27
27
|
};
|
|
@@ -30,6 +30,7 @@ export type BlocksMfaResendRequest = {
|
|
|
30
30
|
sendPhoneNumberAsEmailDomain?: string;
|
|
31
31
|
};
|
|
32
32
|
export type BlocksMfaVerifyRequest = {
|
|
33
|
+
/** Same UserMfaType enum as `mfaType`: the method that issued this challenge (1 TOTP, 2 Email). */
|
|
33
34
|
authType: number;
|
|
34
35
|
isFromTokenCall?: boolean;
|
|
35
36
|
mfaId: string;
|
package/dist/notifier/types.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type BlocksNotifyRequest = {
|
|
|
16
16
|
userIds?: string[];
|
|
17
17
|
};
|
|
18
18
|
export type BlocksGetUnreadNotificationsBySubscriptionFilterRequest = {
|
|
19
|
-
/**
|
|
19
|
+
/** 1 = CreatedTime (newest first), 2 = ReadStatus. Any other value (including an omitted 0) returns an empty list. */
|
|
20
20
|
orderBy?: 1 | 2;
|
|
21
21
|
subscriptionFilterData?: BlocksNotifierSubscriptionFilter;
|
|
22
22
|
userId?: string;
|
package/package.json
CHANGED
|
@@ -1,48 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@seliseblocks/client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Framework-neutral TypeScript client SDK for SELISE Blocks frontend applications.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"keywords": [
|
|
8
|
-
"selise",
|
|
9
|
-
"blocks",
|
|
10
|
-
"sdk",
|
|
11
|
-
"typescript",
|
|
12
|
-
"frontend"
|
|
13
|
-
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
},
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@seliseblocks/client",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Framework-neutral TypeScript client SDK for SELISE Blocks frontend applications.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"selise",
|
|
9
|
+
"blocks",
|
|
10
|
+
"sdk",
|
|
11
|
+
"typescript",
|
|
12
|
+
"frontend"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/SELISEdigitalplatforms/blocks-cli/tree/main/blocks-client#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/SELISEdigitalplatforms/blocks-cli/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/SELISEdigitalplatforms/blocks-cli.git",
|
|
21
|
+
"directory": "blocks-client"
|
|
22
|
+
},
|
|
23
|
+
"author": "SELISE Digital Platforms",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"sideEffects": false,
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md",
|
|
40
|
+
"CHANGELOG.md",
|
|
41
|
+
"AGENT_GUIDE.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
46
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
47
|
+
"lint": "tsc -p tsconfig.json --noEmit",
|
|
48
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
49
|
+
"prepack": "npm run build",
|
|
50
|
+
"prepublishOnly": "npm test"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=20"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.0.0",
|
|
57
|
+
"typescript": "^5.5.0"
|
|
58
|
+
}
|
|
59
|
+
}
|