totalum-sdk 1.7.2 → 1.7.3
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 +10 -0
- package/dist/http.js +6 -2
- package/dist/webhooks/index.d.ts +3 -2
- package/dist/webhooks/index.js +3 -2
- package/package.json +1 -1
- package/totalum-sdk.md +5 -3
- package/totalum-sdk.signatures.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -20,6 +20,16 @@ regenerated), plus the request each call sends to SDK-API (`compat/requests/*.js
|
|
|
20
20
|
- **Dist-tags:** `next` is the newest release; `latest` moves only by a decision at launch. `dev` holds the old
|
|
21
21
|
`0.1.0-dev.N` prereleases.
|
|
22
22
|
|
|
23
|
+
## 1.7.3 — 2026-10-03
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- Every namespace but the database reads `TOTALUM_APP_KEY` before `TOTALUM_PROJECT_KEY`. Totalum sets it only in the
|
|
28
|
+
sandbox, to the deployed app's own key, so the agent's dev server calls the built-ins with the app's permissions: a
|
|
29
|
+
check that passes there passes on the site (sbfix SB10). The database driver keeps `TOTALUM_PROJECT_KEY`.
|
|
30
|
+
- Docs: `TOTALUM_WEBHOOK_SECRET` is set by Totalum on the preview, the published site and the sandbox, and a rotation
|
|
31
|
+
reaches them at once; an app never asks its owner to set it (sbfix SB1).
|
|
32
|
+
|
|
23
33
|
## 1.7.2 — 2026-10-02
|
|
24
34
|
|
|
25
35
|
### Fixed
|
package/dist/http.js
CHANGED
|
@@ -6,9 +6,13 @@ export function readEnv(name) {
|
|
|
6
6
|
const value = typeof process === 'undefined' ? undefined : process.env[name];
|
|
7
7
|
return value === '' ? undefined : value;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* The project key: the option, else `TOTALUM_APP_KEY` (set only in Totalum's sandbox: the deployed app's own key, so the
|
|
11
|
+
* agent's checks run with the app's permissions), else `TOTALUM_PROJECT_KEY`, else `SDK_NOT_CONFIGURED`. Read at call
|
|
12
|
+
* time, never at import. The database driver (`totalum-sdk/d1`) reads `TOTALUM_PROJECT_KEY` only.
|
|
13
|
+
*/
|
|
10
14
|
export function projectKey(options) {
|
|
11
|
-
const key = options.key ?? readEnv('TOTALUM_PROJECT_KEY');
|
|
15
|
+
const key = options.key ?? readEnv('TOTALUM_APP_KEY') ?? readEnv('TOTALUM_PROJECT_KEY');
|
|
12
16
|
if (key === undefined)
|
|
13
17
|
throw new TotalumError('SDK_NOT_CONFIGURED', MISSING_KEY);
|
|
14
18
|
return key;
|
package/dist/webhooks/index.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ declare class TotalumWebhookError extends TotalumError {
|
|
|
12
12
|
/**
|
|
13
13
|
* `totalum.webhooks.verify` (plan 04 §5.13): checks `Totalum-Signature: t=…,v1=…` — HMAC-SHA256 keyed with the
|
|
14
14
|
* endpoint's secret string over `${t}.${rawBody}` — within ±300 s, and returns the parsed event. Pass the body exactly
|
|
15
|
-
* as received (`await request.text()`). `secret` defaults to `TOTALUM_WEBHOOK_SECRET
|
|
15
|
+
* as received (`await request.text()`). `secret` defaults to `TOTALUM_WEBHOOK_SECRET`, which Totalum sets on the
|
|
16
|
+
* preview, the published site and the sandbox (a rotation reaches them at once): never ask the owner to set it.
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* const event = await verifyWebhook(await request.text(), request.headers);
|
|
@@ -37,7 +38,7 @@ declare function totalumWebhooks(options?: TotalumClientOptions): {
|
|
|
37
38
|
enabled: boolean;
|
|
38
39
|
secretPrefix: string | null;
|
|
39
40
|
}>;
|
|
40
|
-
/** A new signing secret, shown once; the old one keeps co-signing for 24 h.
|
|
41
|
+
/** A new signing secret, shown once; the old one keeps co-signing for 24 h. Totalum binds it as `TOTALUM_WEBHOOK_SECRET`. */
|
|
41
42
|
rotateSecret: () => Promise<{
|
|
42
43
|
secret: string;
|
|
43
44
|
}>;
|
package/dist/webhooks/index.js
CHANGED
|
@@ -15,7 +15,8 @@ const enc = new TextEncoder();
|
|
|
15
15
|
/**
|
|
16
16
|
* `totalum.webhooks.verify` (plan 04 §5.13): checks `Totalum-Signature: t=…,v1=…` — HMAC-SHA256 keyed with the
|
|
17
17
|
* endpoint's secret string over `${t}.${rawBody}` — within ±300 s, and returns the parsed event. Pass the body exactly
|
|
18
|
-
* as received (`await request.text()`). `secret` defaults to `TOTALUM_WEBHOOK_SECRET
|
|
18
|
+
* as received (`await request.text()`). `secret` defaults to `TOTALUM_WEBHOOK_SECRET`, which Totalum sets on the
|
|
19
|
+
* preview, the published site and the sandbox (a rotation reaches them at once): never ask the owner to set it.
|
|
19
20
|
*
|
|
20
21
|
* @example
|
|
21
22
|
* const event = await verifyWebhook(await request.text(), request.headers);
|
|
@@ -55,7 +56,7 @@ export function totalumWebhooks(options = {}) {
|
|
|
55
56
|
get: () => call('GET', '/v1/webhooks'),
|
|
56
57
|
/** Sets the `https://` URL the project's events are delivered to. */
|
|
57
58
|
setUrl: (url) => call('PUT', '/v1/webhooks', { url }),
|
|
58
|
-
/** A new signing secret, shown once; the old one keeps co-signing for 24 h.
|
|
59
|
+
/** A new signing secret, shown once; the old one keeps co-signing for 24 h. Totalum binds it as `TOTALUM_WEBHOOK_SECRET`. */
|
|
59
60
|
rotateSecret: () => call('POST', '/v1/webhooks/rotate-secret'),
|
|
60
61
|
};
|
|
61
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "totalum-sdk",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "The SDK generated Totalum apps import: every integration namespace over SDK-API (totalum-sdk, or one subpath each: /files, /ai, /web, \u2026) and totalum-sdk/d1, the D1 driver",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
package/totalum-sdk.md
CHANGED
|
@@ -22,7 +22,8 @@ same environment at call time, never at import; an option of the same name wins:
|
|
|
22
22
|
| `TOTALUM_ENV` | `env` | `dev` or `live` (default), sent as `x-totalum-env`: the database `totalum-sdk/d1` targets over HTTPS, and dev vs live usage. |
|
|
23
23
|
| `TOTALUM_FILES_URL` | `filesUrl` | The public files host of `files.url()`. |
|
|
24
24
|
| `TOTALUM_AI_BASE_URL` | `aiBaseUrl` | The exact-OpenRouter gateway `ai.gatewayConfig()` returns. |
|
|
25
|
-
| `
|
|
25
|
+
| `TOTALUM_APP_KEY` | `key` | Set by Totalum in the sandbox only: the deployed app's own key, used before `TOTALUM_PROJECT_KEY` by every namespace but the database, so the agent's checks have the app's permissions. |
|
|
26
|
+
| `TOTALUM_WEBHOOK_SECRET` | argument | The secret `webhooks.verify` checks `Totalum-Signature` with. Totalum sets it on the preview, the published site and the sandbox, and a rotation reaches them at once: never set it yourself. |
|
|
26
27
|
|
|
27
28
|
```ts
|
|
28
29
|
import { totalum } from 'totalum-sdk'; // or one namespace: import { totalumFiles } from 'totalum-sdk/files';
|
|
@@ -304,7 +305,8 @@ verifyWebhook(rawBody: string, headers: Headers | Record<string, string | undefi
|
|
|
304
305
|
|
|
305
306
|
`totalum.webhooks.verify`: checks `Totalum-Signature: t=…,v1=…` — HMAC-SHA256 keyed with the
|
|
306
307
|
endpoint's secret string over `${t}.${rawBody}` — within ±300 s, and returns the parsed event. Pass the body exactly
|
|
307
|
-
as received (`await request.text()`). `secret` defaults to `TOTALUM_WEBHOOK_SECRET
|
|
308
|
+
as received (`await request.text()`). `secret` defaults to `TOTALUM_WEBHOOK_SECRET`, which Totalum sets on the
|
|
309
|
+
preview, the published site and the sandbox (a rotation reaches them at once): never ask the owner to set it.
|
|
308
310
|
|
|
309
311
|
```ts
|
|
310
312
|
const event = await verifyWebhook(await request.text(), request.headers);
|
|
@@ -349,7 +351,7 @@ Sets the `https://` URL the project's events are delivered to.
|
|
|
349
351
|
webhooks.rotateSecret(): Promise<{ secret: string; }>
|
|
350
352
|
```
|
|
351
353
|
|
|
352
|
-
A new signing secret, shown once; the old one keeps co-signing for 24 h.
|
|
354
|
+
A new signing secret, shown once; the old one keeps co-signing for 24 h. Totalum binds it as `TOTALUM_WEBHOOK_SECRET`.
|
|
353
355
|
|
|
354
356
|
## `totalum-sdk/web`
|
|
355
357
|
|