@sess.si/sdk 0.1.0-rc.9 → 0.1.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 +28 -6
- package/README.md +30 -9
- package/dist/errors.d.ts +5 -1
- package/dist/errors.js +10 -24
- package/dist/internal/version.d.ts +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/transport.js +11 -2
- package/package.json +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.1.0
|
|
3
|
+
## 0.1.0 — 2026-10-31
|
|
4
|
+
|
|
5
|
+
- The first stable release, published to the `latest` dist-tag. The API is that of
|
|
6
|
+
0.1.0-rc.10, unchanged.
|
|
7
|
+
- Development dependency only: the contract generator's `@redocly/openapi-core` now resolves
|
|
8
|
+
`minimatch` 11.0.1 (advisory GHSA-g3hv-75wg-m249), through a scoped `overrides` entry. No
|
|
9
|
+
runtime dependency changes; the generated types are byte-identical.
|
|
10
|
+
|
|
11
|
+
## 0.1.0-rc.10 — 2026-10-28
|
|
12
|
+
|
|
13
|
+
- Short human links: a request identifier holding a run of 22 or more base64url characters (a
|
|
14
|
+
short-link token is 22, as in `/n/<token>`; a `/s/` token 43; either may be glued to more) is
|
|
15
|
+
withheld from `SessError.requestId` and request events. Sess's own `req_<uuid>` ids are kept.
|
|
16
|
+
- A key Sess does not accept (HTTP 401 `UNAUTHORIZED`) now says so: the `SessError` message is
|
|
17
|
+
"Sess did not accept your API key. Check SESS_API_KEY and the portal you made it on." instead of
|
|
18
|
+
the generic "The Sess API returned an error. See the status and code fields." Other messages
|
|
19
|
+
are unchanged. `code`, `status` and `requestId` are still on the error.
|
|
20
|
+
- A `SessError` has an own property only for a field with a value. Printing one (an uncaught
|
|
21
|
+
error, `console.log`, `util.inspect`, `JSON.stringify`) no longer lists absent fields as
|
|
22
|
+
`undefined`; reading an absent field still gives `undefined`. The Node quickstart and the
|
|
23
|
+
README print the message first, then a `Details:` line with the code and request ID.
|
|
24
|
+
|
|
25
|
+
## 0.1.0-rc.9 — 2026-10-28
|
|
4
26
|
|
|
5
27
|
- Commerce: bills as ordinary Surfaces, for Sess's `items` component. Sess takes no payment.
|
|
6
28
|
`money(amount, currency)` checks a whole number of minor units (cents for USD, yen for JPY, fils
|
|
@@ -36,9 +58,9 @@
|
|
|
36
58
|
document paths. Every published package's packed bytes now pass a hygiene check (no maps,
|
|
37
59
|
fixtures, non-public hosts, credential-shaped strings or internal references).
|
|
38
60
|
|
|
39
|
-
## 0.1.0-rc.8 — 2026-10-22
|
|
61
|
+
## 0.1.0-rc.8 — 2026-10-22
|
|
40
62
|
|
|
41
|
-
- Link timing
|
|
63
|
+
- Link timing. On an interactive Sess link of 20 hours or less the
|
|
42
64
|
person may ask for more time, up to ten times, never past a fixed horizon. Session reads carry
|
|
43
65
|
`link_state` (`live`, `lapsed` or `expired`), `action_expires_horizon`, `extensions_used` and the
|
|
44
66
|
`extensions` history; the Session log (`listEvents()`) lists the same records as
|
|
@@ -55,7 +77,7 @@
|
|
|
55
77
|
describes: the interactive text limits with `field`, `limit` and `length` on a length error,
|
|
56
78
|
`progress`, the receipt `format` and the renderer identities list. The generated wire types gain
|
|
57
79
|
them; the SDK's public types and behavior in this change are link timing only.
|
|
58
|
-
- Renderer identities
|
|
80
|
+
- Renderer identities. A receipt's `surface.renderer_version` now
|
|
59
81
|
verifies when it is an identity this release bundles (`sess-html-form-1`, `sess-html-form-2`;
|
|
60
82
|
`BUNDLED_RENDERER_IDENTITIES`) or one on the issuer's renderer list whose signature verifies
|
|
61
83
|
under the same trusted keys and issuer, so a later Sess page change needs no SDK update. Every
|
|
@@ -91,7 +113,7 @@
|
|
|
91
113
|
Sess's own fix. The README and the quickstart show catching it, shortening the value and asking again.
|
|
92
114
|
Surfaces stored before these limits still read as before.
|
|
93
115
|
|
|
94
|
-
## 0.1.0-rc.7 — 2026-10-18
|
|
116
|
+
## 0.1.0-rc.7 — 2026-10-18
|
|
95
117
|
|
|
96
118
|
Includes everything in the unpublished 0.1.0-rc.6 below, which is not published on its own.
|
|
97
119
|
|
|
@@ -108,7 +130,7 @@ Includes everything in the unpublished 0.1.0-rc.6 below, which is not published
|
|
|
108
130
|
- `ResponseMeta.serverDate`: the response's HTTP `Date`, when the runtime sends one.
|
|
109
131
|
- Contract snapshot from Sess runtime commit `b48e8e7` (see `contract/contract-lock.json`), with
|
|
110
132
|
`expires_in`, `action_expires_at` on create and the target's `default_expires_in`.
|
|
111
|
-
- `@sess.si/sdk/qr
|
|
133
|
+
- `@sess.si/sdk/qr`: `qr(url, { format: 'svg' | 'png' | 'terminal' })` draws a Sess link as a
|
|
112
134
|
QR code locally (error correction level M, 4-module quiet zone, deterministic, no network call), and
|
|
113
135
|
`printQr(url)` prints "Scan to answer on your phone" and the code on an interactive terminal only:
|
|
114
136
|
never without a TTY, in CI or with `NODE_ENV=production`; `--no-qr` or `{ qr: false }` turn it off
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Ask a person a question from your server and continue with their verified answer
|
|
|
5
5
|
**Create and run** a small agent:
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm create @sess.si/agent@
|
|
8
|
+
npm create @sess.si/agent@latest my-agent
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
**What you'll see:** a Sess link. Answer two questions on your phone and your plan prints in the
|
|
@@ -14,7 +14,7 @@ terminal with a verified receipt.
|
|
|
14
14
|
**Install** the SDK in your own server project:
|
|
15
15
|
|
|
16
16
|
```sh
|
|
17
|
-
npm install --save-exact @sess.si/sdk@
|
|
17
|
+
npm install --save-exact @sess.si/sdk@0.1.0
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Ask a person
|
|
@@ -56,6 +56,29 @@ confirmed; calling `answer()` again replays the same completion. The handle live
|
|
|
56
56
|
resume after a restart, persist `sessionId` and `revision` and continue with the API below
|
|
57
57
|
([Integration](docs/integration.md#one-question-with-sessask)).
|
|
58
58
|
|
|
59
|
+
If Sess refuses a call, the error says what happened and what to do. A key Sess does not accept
|
|
60
|
+
prints: "Sess did not accept your API key. Check SESS_API_KEY and the portal you made it on." The
|
|
61
|
+
message comes first; the code and request ID follow it:
|
|
62
|
+
|
|
63
|
+
<!-- example:ask-error -->
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
try {
|
|
67
|
+
const question = await sess.ask({
|
|
68
|
+
question: 'Approve the synthetic refund?',
|
|
69
|
+
fields: [{ name: 'approved', label: 'Approve it', type: 'boolean' }],
|
|
70
|
+
});
|
|
71
|
+
console.log(`Send this Sess link to the person: ${question.link}`);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error(error.message); // what happened and what to do
|
|
74
|
+
const request = error.requestId ? `, request ${error.requestId}` : '';
|
|
75
|
+
console.error(`Details: ${error.code ?? error.kind}${request}`);
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
<!-- /example:ask-error -->
|
|
81
|
+
|
|
59
82
|
## Keep it short
|
|
60
83
|
|
|
61
84
|
A person reads the page on a phone, so Sess keeps every piece of it short. Lengths count
|
|
@@ -97,10 +120,9 @@ async function askShort(question: string) {
|
|
|
97
120
|
}
|
|
98
121
|
```
|
|
99
122
|
|
|
100
|
-
**Release status:**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
`npm view @sess.si/sdk dist-tags` shows what the registry serves now.
|
|
123
|
+
**Release status:** `0.1.0` is the first stable release, served under the `latest` dist-tag.
|
|
124
|
+
`next` stays at the last release candidate, `0.1.0-rc.10`. The [changelog](CHANGELOG.md) describes
|
|
125
|
+
each version; `npm view @sess.si/sdk dist-tags` shows what the registry serves now.
|
|
104
126
|
|
|
105
127
|
## Commerce
|
|
106
128
|
|
|
@@ -220,11 +242,10 @@ exact Surface and input, and the issuer's public keys. Check it on your own comp
|
|
|
220
242
|
trust (never the keys inside the bundle):
|
|
221
243
|
|
|
222
244
|
```sh
|
|
223
|
-
npx -p @sess.si/sdk@0.1.0
|
|
245
|
+
npx -p @sess.si/sdk@0.1.0 sess verify bundle.json --issuer https://api.sess.si --keys sess-receipt-keys.json
|
|
224
246
|
```
|
|
225
247
|
|
|
226
|
-
The `sess` command first ships in `0.1.0-rc.5`;
|
|
227
|
-
the bare package name resolves to the `latest` placeholder, which has no command.
|
|
248
|
+
The `sess` command first ships in `0.1.0-rc.5`; any later version, `0.1.0` included, has it.
|
|
228
249
|
|
|
229
250
|
You'll see `Valid decision bundle.` and what was accepted, when, on which revision; or `Invalid`
|
|
230
251
|
and the first reason. Exit status is 0 valid, 1 invalid, 2 usage error; add `--json` for the full
|
package/dist/errors.d.ts
CHANGED
|
@@ -21,7 +21,10 @@ export interface SessErrorDetails {
|
|
|
21
21
|
/** With a length error: the value's actual length, in Unicode code points. */
|
|
22
22
|
length?: number;
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Stable error fields; messages never include response bodies or request secrets. An optional
|
|
26
|
+
* field is an own property only when it has a value, so printing an error lists no empty fields.
|
|
27
|
+
*/
|
|
25
28
|
export declare class SessError extends Error {
|
|
26
29
|
readonly kind: SessErrorKind;
|
|
27
30
|
readonly code?: string;
|
|
@@ -49,6 +52,7 @@ export declare class SessError extends Error {
|
|
|
49
52
|
/** Explicit access only. A usable create body may accompany a defective header. */
|
|
50
53
|
getRecoveryResult(): Readonly<CreateSessionResponse> | undefined;
|
|
51
54
|
toJSON(): object;
|
|
55
|
+
/** `util.inspect` and `console.log`: the same fields as JSON, without the absent ones. */
|
|
52
56
|
[inspect.custom](): object;
|
|
53
57
|
}
|
|
54
58
|
/** Internal: the one-line fix every length error carries (field, limit, actual length, fix). */
|
package/dist/errors.js
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
import { inspect } from 'node:util';
|
|
2
2
|
const recovery = new WeakMap();
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Stable error fields; messages never include response bodies or request secrets. An optional
|
|
5
|
+
* field is an own property only when it has a value, so printing an error lists no empty fields.
|
|
6
|
+
*/
|
|
4
7
|
export class SessError extends Error {
|
|
5
8
|
kind;
|
|
6
|
-
code;
|
|
7
|
-
reason;
|
|
8
|
-
status;
|
|
9
|
-
requestId;
|
|
10
|
-
operation;
|
|
11
|
-
attempts;
|
|
12
|
-
outcome;
|
|
13
|
-
idempotencyKey;
|
|
14
|
-
retryAfterMs;
|
|
15
|
-
sessionId;
|
|
16
|
-
revision;
|
|
17
|
-
/**
|
|
18
|
-
* Set only when a value is too long (a 400 INVALID_SCHEMA from Sess, or INVALID_QUESTION from
|
|
19
|
-
* `ask`): a JSON pointer to it, e.g. `/interaction/title`. Nothing is ever truncated: shorten
|
|
20
|
-
* the value to at most `limit` characters and send again.
|
|
21
|
-
*/
|
|
22
|
-
field;
|
|
23
|
-
/** With `field`: the most the value may have, in Unicode code points (e.g. title 80). */
|
|
24
|
-
limit;
|
|
25
|
-
/** With `field`: the value's actual length, in Unicode code points. */
|
|
26
|
-
length;
|
|
27
9
|
constructor(kind, message, details = {}) {
|
|
28
10
|
super(message);
|
|
29
11
|
this.name = 'SessError';
|
|
30
12
|
this.kind = kind;
|
|
31
|
-
Object.
|
|
13
|
+
for (const [name, value] of Object.entries(details))
|
|
14
|
+
if (value !== undefined)
|
|
15
|
+
Object.assign(this, { [name]: value });
|
|
32
16
|
}
|
|
33
17
|
/** Explicit access only. A usable create body may accompany a defective header. */
|
|
34
18
|
getRecoveryResult() {
|
|
@@ -36,7 +20,7 @@ export class SessError extends Error {
|
|
|
36
20
|
}
|
|
37
21
|
toJSON() {
|
|
38
22
|
const { name, kind, message, code, reason, status, requestId, operation, attempts, outcome, idempotencyKey, retryAfterMs, field, limit, length, } = this;
|
|
39
|
-
|
|
23
|
+
const fields = {
|
|
40
24
|
name,
|
|
41
25
|
kind,
|
|
42
26
|
message,
|
|
@@ -53,7 +37,9 @@ export class SessError extends Error {
|
|
|
53
37
|
limit,
|
|
54
38
|
length,
|
|
55
39
|
};
|
|
40
|
+
return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
|
|
56
41
|
}
|
|
42
|
+
/** `util.inspect` and `console.log`: the same fields as JSON, without the absent ones. */
|
|
57
43
|
[inspect.custom]() {
|
|
58
44
|
return this.toJSON();
|
|
59
45
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** This package's version, sent in the User-Agent header. Tests check it against package.json. */
|
|
2
|
-
export declare const SDK_VERSION = "0.1.0
|
|
2
|
+
export declare const SDK_VERSION = "0.1.0";
|
package/dist/internal/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** This package's version, sent in the User-Agent header. Tests check it against package.json. */
|
|
2
|
-
export const SDK_VERSION = '0.1.0
|
|
2
|
+
export const SDK_VERSION = '0.1.0';
|
package/dist/transport.js
CHANGED
|
@@ -25,6 +25,8 @@ const rejections = {
|
|
|
25
25
|
// rate limit; a plain 429 (no code, or RATE_LIMITED) stays transient and its outcome uncertain.
|
|
26
26
|
429: ['PLAN_LIMIT_REACHED'],
|
|
27
27
|
};
|
|
28
|
+
/** A 401 UNAUTHORIZED: Sess refused the API key. */
|
|
29
|
+
const UNAUTHORIZED_MESSAGE = 'Sess did not accept your API key. Check SESS_API_KEY and the portal you made it on.';
|
|
28
30
|
/** RFC 9110 product tokens (`name` or `name/version`), separated by single spaces. */
|
|
29
31
|
const PRODUCT = "[!#$%&'*+.^_`|~0-9A-Za-z-]+(?:/[!#$%&'*+.^_`|~0-9A-Za-z-]+)?";
|
|
30
32
|
const PRODUCTS = new RegExp(`^${PRODUCT}(?: ${PRODUCT})*$`);
|
|
@@ -90,11 +92,16 @@ function origin(input, allowInsecure) {
|
|
|
90
92
|
}
|
|
91
93
|
return url.origin;
|
|
92
94
|
}
|
|
95
|
+
/** The request id the Sess API assigns: `req_` and a random UUID. */
|
|
96
|
+
const SESS_REQUEST_ID = /^req_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
93
97
|
function safeText(value, pattern, key, opaqueIdentifier = false) {
|
|
94
98
|
if (typeof value !== 'string' ||
|
|
95
99
|
!pattern.test(value) ||
|
|
96
100
|
/sess_(?:sk|mg|tk|mk)_|whsec_|eyJ/.test(value) ||
|
|
97
|
-
|
|
101
|
+
// A request identifier holding a run of 22 or more base64url characters may carry a reflected
|
|
102
|
+
// human-link token (22 for /n/ short links, 43 for /s/ links, alone or glued to more token
|
|
103
|
+
// characters), so it is withheld. Sess's own request ids, req_ and a lowercase UUID, are kept.
|
|
104
|
+
(opaqueIdentifier && /[A-Za-z0-9_-]{22,}/.test(value) && !SESS_REQUEST_ID.test(value)) ||
|
|
98
105
|
(key && value.includes(key)))
|
|
99
106
|
return undefined;
|
|
100
107
|
return value;
|
|
@@ -348,7 +355,9 @@ export class Transport {
|
|
|
348
355
|
const length = lengthDetail(remote, code, key);
|
|
349
356
|
const message = length.field !== undefined
|
|
350
357
|
? lengthMessage(length.field, length.limit, length.length)
|
|
351
|
-
:
|
|
358
|
+
: response.status === 401 && code === 'UNAUTHORIZED'
|
|
359
|
+
? UNAUTHORIZED_MESSAGE
|
|
360
|
+
: 'The Sess API returned an error. See the status and code fields.';
|
|
352
361
|
throw new SessError('api', message, {
|
|
353
362
|
code,
|
|
354
363
|
reason,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sess.si/sdk",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Ask a person from your server and continue with their verified answer. Sess API client with receipt and webhook verification.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -80,5 +80,10 @@
|
|
|
80
80
|
"typescript": "5.9.3",
|
|
81
81
|
"typescript-current": "npm:typescript@7.0.2",
|
|
82
82
|
"vitest": "5.0.4"
|
|
83
|
+
},
|
|
84
|
+
"overrides": {
|
|
85
|
+
"@redocly/openapi-core": {
|
|
86
|
+
"minimatch": "11.0.1"
|
|
87
|
+
}
|
|
83
88
|
}
|
|
84
89
|
}
|