@sess.si/sdk 0.1.0-rc.8 → 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 +66 -9
- package/NOTICE +1 -1
- package/README.md +92 -16
- package/dist/ask.d.ts +0 -1
- package/dist/ask.js +0 -1
- package/dist/cli/main.d.ts +0 -1
- package/dist/cli/main.js +0 -1
- package/dist/cli/verify.d.ts +0 -1
- package/dist/cli/verify.js +0 -1
- package/dist/client.d.ts +0 -1
- package/dist/client.js +0 -1
- package/dist/commerce/builders.d.ts +99 -0
- package/dist/commerce/builders.js +208 -0
- package/dist/commerce/currency.d.ts +4 -0
- package/dist/commerce/currency.js +25 -0
- package/dist/commerce/items.d.ts +119 -0
- package/dist/commerce/items.js +280 -0
- package/dist/commerce/lint.d.ts +16 -0
- package/dist/commerce/lint.js +56 -0
- package/dist/errors.d.ts +5 -2
- package/dist/errors.js +15 -25
- package/dist/generated/openapi.d.ts +12 -13
- package/dist/generated/openapi.js +0 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -1
- package/dist/internal/decode.d.ts +0 -1
- package/dist/internal/decode.js +9 -2
- package/dist/internal/json.d.ts +0 -1
- package/dist/internal/json.js +0 -1
- package/dist/internal/time.d.ts +0 -1
- package/dist/internal/time.js +0 -1
- package/dist/internal/version.d.ts +2 -0
- package/dist/internal/version.js +2 -0
- package/dist/polling.d.ts +0 -1
- package/dist/polling.js +0 -1
- package/dist/qr/encoder.d.ts +0 -1
- package/dist/qr/encoder.js +0 -1
- package/dist/qr/index.d.ts +0 -1
- package/dist/qr/index.js +0 -1
- package/dist/receipts/bundle.d.ts +0 -1
- package/dist/receipts/bundle.js +0 -1
- package/dist/receipts/index.d.ts +0 -1
- package/dist/receipts/index.js +0 -1
- package/dist/receipts/json.d.ts +0 -1
- package/dist/receipts/json.js +0 -1
- package/dist/receipts/key-cache.d.ts +0 -1
- package/dist/receipts/key-cache.js +0 -1
- package/dist/receipts/renderers.d.ts +0 -1
- package/dist/receipts/renderers.js +1 -2
- package/dist/receipts/resource.d.ts +0 -1
- package/dist/receipts/resource.js +0 -1
- package/dist/receipts/verify.d.ts +0 -1
- package/dist/receipts/verify.js +0 -1
- package/dist/sessions.d.ts +0 -1
- package/dist/sessions.js +0 -1
- package/dist/transport.d.ts +0 -1
- package/dist/transport.js +35 -5
- package/dist/types.d.ts +56 -2
- package/dist/types.js +0 -1
- package/dist/webhook-resource.d.ts +0 -1
- package/dist/webhook-resource.js +0 -1
- package/dist/webhooks/index.d.ts +0 -1
- package/dist/webhooks/index.js +0 -1
- package/package.json +8 -3
- package/dist/ask.d.ts.map +0 -1
- package/dist/ask.js.map +0 -1
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/verify.d.ts.map +0 -1
- package/dist/cli/verify.js.map +0 -1
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/generated/openapi.d.ts.map +0 -1
- package/dist/generated/openapi.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/decode.d.ts.map +0 -1
- package/dist/internal/decode.js.map +0 -1
- package/dist/internal/json.d.ts.map +0 -1
- package/dist/internal/json.js.map +0 -1
- package/dist/internal/time.d.ts.map +0 -1
- package/dist/internal/time.js.map +0 -1
- package/dist/polling.d.ts.map +0 -1
- package/dist/polling.js.map +0 -1
- package/dist/qr/encoder.d.ts.map +0 -1
- package/dist/qr/encoder.js.map +0 -1
- package/dist/qr/index.d.ts.map +0 -1
- package/dist/qr/index.js.map +0 -1
- package/dist/receipts/bundle.d.ts.map +0 -1
- package/dist/receipts/bundle.js.map +0 -1
- package/dist/receipts/index.d.ts.map +0 -1
- package/dist/receipts/index.js.map +0 -1
- package/dist/receipts/json.d.ts.map +0 -1
- package/dist/receipts/json.js.map +0 -1
- package/dist/receipts/key-cache.d.ts.map +0 -1
- package/dist/receipts/key-cache.js.map +0 -1
- package/dist/receipts/renderers.d.ts.map +0 -1
- package/dist/receipts/renderers.js.map +0 -1
- package/dist/receipts/resource.d.ts.map +0 -1
- package/dist/receipts/resource.js.map +0 -1
- package/dist/receipts/verify.d.ts.map +0 -1
- package/dist/receipts/verify.js.map +0 -1
- package/dist/sessions.d.ts.map +0 -1
- package/dist/sessions.js.map +0 -1
- package/dist/transport.d.ts.map +0 -1
- package/dist/transport.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/webhook-resource.d.ts.map +0 -1
- package/dist/webhook-resource.js.map +0 -1
- package/dist/webhooks/index.d.ts.map +0 -1
- package/dist/webhooks/index.js.map +0 -1
- package/src/ask.ts +0 -683
- package/src/cli/main.ts +0 -8
- package/src/cli/verify.ts +0 -349
- package/src/client.ts +0 -55
- package/src/errors.ts +0 -127
- package/src/generated/openapi.ts +0 -8586
- package/src/index.ts +0 -5
- package/src/internal/decode.ts +0 -348
- package/src/internal/json.ts +0 -64
- package/src/internal/time.ts +0 -85
- package/src/polling.ts +0 -173
- package/src/qr/encoder.ts +0 -345
- package/src/qr/index.ts +0 -203
- package/src/receipts/bundle.ts +0 -547
- package/src/receipts/index.ts +0 -29
- package/src/receipts/json.ts +0 -168
- package/src/receipts/key-cache.ts +0 -143
- package/src/receipts/renderers.ts +0 -220
- package/src/receipts/resource.ts +0 -264
- package/src/receipts/verify.ts +0 -554
- package/src/sessions.ts +0 -238
- package/src/transport.ts +0 -566
- package/src/types.ts +0 -219
- package/src/webhook-resource.ts +0 -81
- package/src/webhooks/index.ts +0 -246
|
@@ -829,7 +829,7 @@ export interface paths {
|
|
|
829
829
|
};
|
|
830
830
|
get?: never;
|
|
831
831
|
put?: never;
|
|
832
|
-
/** @description P2-13 V3 / P2-11, step 1 of "Keep your receipt" (
|
|
832
|
+
/** @description P2-13 V3 / P2-11, step 1 of "Keep your receipt" (the Sess keep-v1 specification). The human link is the capability; never log it. Sent by the receipt card’s same-origin script after the person taps Keep: Sec-Fetch-Site same-origin (or, without Fetch Metadata, an Origin equal to the page’s origin), application/json, at most 65536 bytes, at most 128 grants. Each round is authorized only by its own receipt-scoped Keep grant: the Session, a receipt list or another round’s grant never authorize it. Reads one Session snapshot (its Event sequence cutoff) and, when some authorized receipt in custody has no holder yet, records one fresh challenge (5 minutes) bound to exactly that batch. Headers as every /s/* response (no-store, no-referrer, noindex, no CORS). */
|
|
833
833
|
post: operations['createKeepChallenge'];
|
|
834
834
|
delete?: never;
|
|
835
835
|
options?: never;
|
|
@@ -846,7 +846,7 @@ export interface paths {
|
|
|
846
846
|
};
|
|
847
847
|
get?: never;
|
|
848
848
|
put?: never;
|
|
849
|
-
/** @description P2-13 V3 / P2-11, step 2: the kept-conversation file (
|
|
849
|
+
/** @description P2-13 V3 / P2-11, step 2: the kept-conversation file (the Sess keep-v1 specification), the one bounded, versioned file the person saves — every authorized accepted round of the Session through the snapshot cutoff with its unchanged receipt and bundle (or content unavailable once purged), preservation status (the witness state at snapshot time, with the evidence attached by then), holder status and an inventory. Same request checks as the challenge. With `enrollment`, first enrolls one fresh holder key per receipt of the challenge’s exact batch (or only its final receipt: the disclosed fallback): every proof is checked, then all enrollments and the challenge’s consumption commit atomically; the same request again is an idempotent replay, a different one is refused, a receipt keeps its first holder and a key holds one receipt. Without `enrollment` (key generation or storage failed, or nothing to enrol) the file is exported with every round marked unenrolled: export never depends on enrollment. The file holds no private key, grant secret or Sess link. Content-Disposition: attachment. */
|
|
850
850
|
post: operations['keepConversation'];
|
|
851
851
|
delete?: never;
|
|
852
852
|
options?: never;
|
|
@@ -863,7 +863,7 @@ export interface paths {
|
|
|
863
863
|
};
|
|
864
864
|
get?: never;
|
|
865
865
|
put?: never;
|
|
866
|
-
/** @description P2-15 PR-B, Save to Sess from a human page on another origin than /personal (
|
|
866
|
+
/** @description P2-15 PR-B, Save to Sess from a human page on another origin than /personal (the Sess personal-copies-v1 specification §7). The Sess link is the capability; never log it. Sent by the receipt card’s same-origin script once the Save sheet on the personal origin is signed in and has sent its destination binding: Sec-Fetch-Site same-origin (or an Origin equal to the page’s), application/json, at most 65536 bytes, rate limited per link. Records one pending claim bound to the rounds the presented Keep grants authorize now, exactly as Keep reads them (restricted or deleted rounds never included; no client-chosen IDs), their cutoff, a fresh 256-bit transfer secret (stored as its hash), the purpose, the personal origin, the source verifier’s challenge and the destination binding. The claim expires in 5 minutes. Nothing is saved until the sheet redeems it. Headers as every /s/* response. */
|
|
867
867
|
post: operations['createSaveClaim'];
|
|
868
868
|
delete?: never;
|
|
869
869
|
options?: never;
|
|
@@ -931,7 +931,7 @@ export interface paths {
|
|
|
931
931
|
};
|
|
932
932
|
get?: never;
|
|
933
933
|
put?: never;
|
|
934
|
-
/** @description P2-12: the payment provider’s signed asynchronous events (provider-to-Sess only;
|
|
934
|
+
/** @description P2-12: the payment provider’s signed asynchronous events (provider-to-Sess only; the Sess billing-provider-v1 specification). The signature header is verified over the exact raw body (at most 256 KiB, timestamp within 300 s) before the body is parsed. Each event id is processed once (a duplicate is acknowledged without effect); older subscription states never replace newer ones; unknown event types are acknowledged and ignored. Not configured → 404. */
|
|
935
935
|
post: operations['receiveBillingProviderEvent'];
|
|
936
936
|
delete?: never;
|
|
937
937
|
options?: never;
|
|
@@ -1032,7 +1032,7 @@ export interface paths {
|
|
|
1032
1032
|
path?: never;
|
|
1033
1033
|
cookie?: never;
|
|
1034
1034
|
};
|
|
1035
|
-
/** @description The deliberate export of one accepted response as a bundle-v1 disclosure (
|
|
1035
|
+
/** @description The deliberate export of one accepted response as a bundle-v1 disclosure (the Sess bundle-v1 specification): its stored receipt exactly as issued, the complete normalized Surface of the revision it was accepted on, the accepted data, and the current public receipt keys. Never a private key, owner credential or Sess link. Anyone holding the bundle can verify it (POST /v1/receipts/verify, or offline with trusted keys); share it only with whom you mean to show the decision. Read-only. Cache-Control: no-store, no-transform; Referrer-Policy: no-referrer. */
|
|
1036
1036
|
get: operations['exportDecisionBundle'];
|
|
1037
1037
|
put?: never;
|
|
1038
1038
|
post?: never;
|
|
@@ -1068,7 +1068,7 @@ export interface paths {
|
|
|
1068
1068
|
};
|
|
1069
1069
|
get?: never;
|
|
1070
1070
|
put?: never;
|
|
1071
|
-
/** @description Public, no credential. Verifies an archival envelope (
|
|
1071
|
+
/** @description Public, no credential. Verifies an archival envelope (the Sess archival-core-v1 specification §3) with the successor archival verifier against this server's own configuration only: its published receipt keys, its receipt issuer as the expected context issuer, its published witness key set (/.well-known/sess-witness-keys.json) and, when configured, its TUF-verified witness trusted root. Nothing in the request is trusted. It reports the independent dimensions of archival-core-v1 §5 (signature, contents, context, witness, key_trust, live_expiry) with the same statuses and reasons as @sess.si/sdk/archival, and their presentation. The body is the envelope only: contents is therefore unverifiable: content_unavailable (verify a bundle-v1 at /v1/receipts/verify for content), and context is at most incomplete (application_context_unchecked). Without a witness trusted root, attached evidence is indeterminate: witness_trust_unavailable. It looks nothing up and stores nothing. A malformed or oversized envelope is a 200 result. The bundle route is unchanged. Body: application/json, at most 2097152 bytes (413 above); 65,536 bytes envelope bound (reason oversized). The same per-client and total rate limits as /v1/receipts/verify, shared with it (429 RATE_LIMITED with Retry-After), and the same absolute 2-second deadline from the request's arrival (503 SERVICE_UNAVAILABLE with Connection: close). Cache-Control: no-store, no-transform; Referrer-Policy: no-referrer; CORS only for the product site origins. Never put an envelope or receipt in a URL. */
|
|
1072
1072
|
post: operations['verifyArchivalEnvelope'];
|
|
1073
1073
|
delete?: never;
|
|
1074
1074
|
options?: never;
|
|
@@ -1288,7 +1288,7 @@ export interface paths {
|
|
|
1288
1288
|
path?: never;
|
|
1289
1289
|
cookie?: never;
|
|
1290
1290
|
};
|
|
1291
|
-
/** @description P2-13 V5: the status of one custody record of the owner workspace (from the credential only), never its content: available, restricted (with its reason code and since when) or deleted (with its reason code and deletion time). A restricted or deleted record is excluded from the list, the export, its bundle and every other receipt-scoped fetch; a restricted one stays verifiable for preservation integrity. Restriction, holds and deletion are decided by the operator through the recorded procedure (
|
|
1291
|
+
/** @description P2-13 V5: the status of one custody record of the owner workspace (from the credential only), never its content: available, restricted (with its reason code and since when) or deleted (with its reason code and deletion time). A restricted or deleted record is excluded from the list, the export, its bundle and every other receipt-scoped fetch; a restricted one stays verifiable for preservation integrity. Restriction, holds and deletion are decided by the operator through the recorded procedure (the Sess custody-restriction-deletion-v1 specification); holds are not shown here. A deletion does not recall exported copies or files people already kept, and the public witness commitment (an aggregate batch root) remains. Another workspace’s record, or an unknown event ID, is 404. Cache-Control: no-store, no-transform. */
|
|
1292
1292
|
get: operations['getEvidenceRecordStatus'];
|
|
1293
1293
|
put?: never;
|
|
1294
1294
|
post?: never;
|
|
@@ -1322,7 +1322,7 @@ export interface paths {
|
|
|
1322
1322
|
path?: never;
|
|
1323
1323
|
cookie?: never;
|
|
1324
1324
|
};
|
|
1325
|
-
/** @description Decision 0009 Amendment 13: the renderer identities Sess signs receipts under (the values of a receipt’s surface.renderer_version), as one JWS signed with the receipt keys, in the RFC 7515 flattened JSON serialization {protected, payload, signature} (joined with dots they are its compact form). Protected header {alg EdDSA, kid, typ sess-renderer-identities+jwt}; payload the RFC 8785 canonical JSON {sess_renderer_identities: 1, iss: the receipt issuer, seq: the list edition (an integer, higher in every later published edition), iat: when this copy was signed (NumericDate), identities: [{renderer_version, since: the UTC date it was added}]}; the signature covers seq and iat. Order authentic lists by seq, with containment as the cross-check; an older list still proves the identities it contains. Verify it with GET /.well-known/sess-receipt-keys.json (the key its kid names) and the expected issuer; a receipt verifies when its renderer_version is on a list whose signature verifies. The list only grows: an identity is never removed, reordered or reused, so every receipt issued keeps verifying (sess-html-form-1 is always on it).
|
|
1325
|
+
/** @description Decision 0009 Amendment 13: the renderer identities Sess signs receipts under (the values of a receipt’s surface.renderer_version), as one JWS signed with the receipt keys, in the RFC 7515 flattened JSON serialization {protected, payload, signature} (joined with dots they are its compact form). Protected header {alg EdDSA, kid, typ sess-renderer-identities+jwt}; payload the RFC 8785 canonical JSON {sess_renderer_identities: 1, iss: the receipt issuer, seq: the list edition (an integer, higher in every later published edition), iat: when this copy was signed (NumericDate), identities: [{renderer_version, since: the UTC date it was added}]}; the signature covers seq and iat. Order authentic lists by seq, with containment as the cross-check; an older list still proves the identities it contains. Verify it with GET /.well-known/sess-receipt-keys.json (the key its kid names) and the expected issuer; a receipt verifies when its renderer_version is on a list whose signature verifies. The list only grows: an identity is never removed, reordered or reused, so every receipt issued keeps verifying (sess-html-form-1 is always on it). the Sess receipt-v1 specification §10. No credential. 503 SERVICE_UNAVAILABLE while the receipt keys are not configured. Cache-Control: no-store, no-transform. */
|
|
1326
1326
|
get: operations['rendererIdentities'];
|
|
1327
1327
|
put?: never;
|
|
1328
1328
|
post?: never;
|
|
@@ -1339,7 +1339,7 @@ export interface paths {
|
|
|
1339
1339
|
path?: never;
|
|
1340
1340
|
cookie?: never;
|
|
1341
1341
|
};
|
|
1342
|
-
/** @description The issuer’s published witness key set (
|
|
1342
|
+
/** @description The issuer’s published witness key set (the Sess witness-evidence-v1 specification §5.1): the public ECDSA P-256 keys that sign witness checkpoints, each with its validity window. The current key has valid_to null; a rotated-out key is kept with its closed window, so evidence it signed stays verifiable. Read with parseWitnessKeySet and pass as the witnessKeys anchor of verifyWitnessEvidence, beside an independently distributed trusted root. Public keys only. No credential. Empty keys when no witness key is configured; 503 SERVICE_UNAVAILABLE when a configured key set is unusable (it is never trimmed or served empty). Cache-Control: no-store, no-transform. */
|
|
1343
1343
|
get: operations['witnessKeys'];
|
|
1344
1344
|
put?: never;
|
|
1345
1345
|
post?: never;
|
|
@@ -2074,12 +2074,12 @@ export interface components {
|
|
|
2074
2074
|
x: string;
|
|
2075
2075
|
y: string;
|
|
2076
2076
|
};
|
|
2077
|
-
/** @description base64url of the 64-byte ECDSA P-256 SHA-256 signature (IEEE P1363) over the holder proof message (
|
|
2077
|
+
/** @description base64url of the 64-byte ECDSA P-256 SHA-256 signature (IEEE P1363) over the holder proof message (the Sess keep-v1 specification §3). */
|
|
2078
2078
|
proof: string;
|
|
2079
2079
|
}[];
|
|
2080
2080
|
};
|
|
2081
2081
|
};
|
|
2082
|
-
/** @description The kept conversation (
|
|
2082
|
+
/** @description The kept conversation (the Sess keep-v1 specification): every authorized accepted round of the Session through the snapshot cutoff, each with its unchanged receipt-v1, its bundle-v1 while the content is retained (else unavailable, never reconstructed), its preservation status and holder status, plus an inventory. No private key, grant secret or Sess link. Each extracted bundle verifies with the unchanged bundle-v1 verifier. */
|
|
2083
2083
|
KeptConversation: {
|
|
2084
2084
|
/** @constant */
|
|
2085
2085
|
type: 'sess.kept-conversation';
|
|
@@ -2159,7 +2159,7 @@ export interface components {
|
|
|
2159
2159
|
status: 'preserved';
|
|
2160
2160
|
/** @description The witness state at snapshot time (the custody witness job: `pending` until a witness attaches, then e.g. `witnessed`); the envelope carries the evidence attached by then. */
|
|
2161
2161
|
witness: string;
|
|
2162
|
-
/** @description The archival envelope (
|
|
2162
|
+
/** @description The archival envelope (the Sess archival-core-v1 specification). */
|
|
2163
2163
|
archival_envelope: {
|
|
2164
2164
|
[key: string]: unknown;
|
|
2165
2165
|
};
|
|
@@ -8358,4 +8358,3 @@ export interface operations {
|
|
|
8358
8358
|
};
|
|
8359
8359
|
};
|
|
8360
8360
|
}
|
|
8361
|
-
//# sourceMappingURL=openapi.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,9 @@ export { SessError } from './errors.js';
|
|
|
3
3
|
export type { SessErrorKind, SessErrorDetails, WriteOutcome } from './errors.js';
|
|
4
4
|
export type { AskAnswer, AskAnswerOptions, AskField, AskHandle, AskInput, AskOptions } from './ask.js';
|
|
5
5
|
export * from './types.js';
|
|
6
|
-
|
|
6
|
+
export { ITEMS_DEFAULT_LABELS, ITEMS_LIMITS, items, money } from './commerce/items.js';
|
|
7
|
+
export type { Amount, ItemLineInput, ItemPaymentInput, ItemRowInput, ItemsInput, Money, } from './commerce/items.js';
|
|
8
|
+
export { COMMERCE_DEFAULTS, invoice, purchaseOrder, quote, receipt, refund } from './commerce/builders.js';
|
|
9
|
+
export type { BillInput, RefundInput } from './commerce/builders.js';
|
|
10
|
+
export { lintText } from './commerce/lint.js';
|
|
11
|
+
export type { TextLintFinding } from './commerce/lint.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { Sess } from './client.js';
|
|
2
2
|
export { SessError } from './errors.js';
|
|
3
3
|
export * from './types.js';
|
|
4
|
-
|
|
4
|
+
export { ITEMS_DEFAULT_LABELS, ITEMS_LIMITS, items, money } from './commerce/items.js';
|
|
5
|
+
export { COMMERCE_DEFAULTS, invoice, purchaseOrder, quote, receipt, refund } from './commerce/builders.js';
|
|
6
|
+
export { lintText } from './commerce/lint.js';
|
|
@@ -18,4 +18,3 @@ export declare function decodeWebhook(value: unknown): WebhookResponse;
|
|
|
18
18
|
export declare function decodeWebhookRotate(value: unknown): WebhookRotateResponse;
|
|
19
19
|
export declare function decodeDeliveries(value: unknown, expectedId: string): Deliveries;
|
|
20
20
|
export declare function decodeRedelivery(value: unknown, expectedEvent: string): RedeliverResponse;
|
|
21
|
-
//# sourceMappingURL=decode.d.ts.map
|
package/dist/internal/decode.js
CHANGED
|
@@ -68,7 +68,7 @@ function interaction(value, mode) {
|
|
|
68
68
|
protocol();
|
|
69
69
|
for (const item of array(source.components)) {
|
|
70
70
|
const c = object(item);
|
|
71
|
-
oneOf(c.type, ['heading', 'text', 'record', 'field']);
|
|
71
|
+
oneOf(c.type, ['heading', 'text', 'record', 'field', 'items']);
|
|
72
72
|
if (c.type === 'heading')
|
|
73
73
|
string(c.text, undefined, 200);
|
|
74
74
|
if (c.type === 'text')
|
|
@@ -80,6 +80,14 @@ function interaction(value, mode) {
|
|
|
80
80
|
string(c.label, undefined, 200);
|
|
81
81
|
oneOf(object(c.schema).type, ['string', 'number', 'integer', 'boolean', 'array']);
|
|
82
82
|
}
|
|
83
|
+
// Commerce: line items in one ISO 4217 currency (Sess checks rows and totals on create).
|
|
84
|
+
if (c.type === 'items') {
|
|
85
|
+
string(c.currency, /^[A-Z]{3}$/, 3);
|
|
86
|
+
if (!array(c.rows).length)
|
|
87
|
+
protocol();
|
|
88
|
+
if (c.totals !== undefined)
|
|
89
|
+
array(c.totals);
|
|
90
|
+
}
|
|
83
91
|
}
|
|
84
92
|
const seen = new Set();
|
|
85
93
|
for (const item of array(v.actions)) {
|
|
@@ -370,4 +378,3 @@ export function decodeRedelivery(value, expectedEvent) {
|
|
|
370
378
|
protocol();
|
|
371
379
|
return value;
|
|
372
380
|
}
|
|
373
|
-
//# sourceMappingURL=decode.js.map
|
package/dist/internal/json.d.ts
CHANGED
package/dist/internal/json.js
CHANGED
package/dist/internal/time.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ export declare function abortError(signal: AbortSignal): SessError;
|
|
|
8
8
|
/** Enforce deadlines even when a custom fetch/provider fails to observe its signal. */
|
|
9
9
|
export declare function withSignal<T>(promise: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
10
10
|
export declare function delay(ms: number, signal: AbortSignal): Promise<void>;
|
|
11
|
-
//# sourceMappingURL=time.d.ts.map
|
package/dist/internal/time.js
CHANGED
package/dist/polling.d.ts
CHANGED
|
@@ -9,4 +9,3 @@ import type { RequestOptions, Session, VersionedResult, WaitOptions, WaitResult
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const LINK_EXPIRY_GRACE_MS = 2000;
|
|
11
11
|
export declare function waitForResponse(retrieve: (options: RequestOptions) => Promise<VersionedResult<Session>>, id: string, input: WaitOptions, clientOperationTimeoutMs: number): Promise<WaitResult>;
|
|
12
|
-
//# sourceMappingURL=polling.d.ts.map
|
package/dist/polling.js
CHANGED
package/dist/qr/encoder.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ export declare function formatBits(mask: number): number;
|
|
|
8
8
|
export declare function maskBit(mask: number, x: number, y: number): boolean;
|
|
9
9
|
/** Encodes `text` (UTF-8, byte mode, level M) at the smallest version 1–10 that holds it. */
|
|
10
10
|
export declare function encodeQr(text: string): QrMatrix;
|
|
11
|
-
//# sourceMappingURL=encoder.d.ts.map
|
package/dist/qr/encoder.js
CHANGED
package/dist/qr/index.d.ts
CHANGED
package/dist/qr/index.js
CHANGED
package/dist/receipts/bundle.js
CHANGED
package/dist/receipts/index.d.ts
CHANGED
|
@@ -6,4 +6,3 @@ export type { DeepReadonly } from './json.js';
|
|
|
6
6
|
export { verifyDecisionBundle, BUNDLE_LIMITS } from './bundle.js';
|
|
7
7
|
export type { BundleContextField, BundleJwk, BundleRejection, DecisionBundle, DecisionBundleVerification, ExpectedBundleContext, VerifiedReceiptSummary, VerifyDecisionBundleOptions, } from './bundle.js';
|
|
8
8
|
export type { ReceiptResource, VerifyResponseInput, VerifiedResponse, VerificationRequestOptions, } from './resource.js';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/receipts/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { verifyDecisionReceipt, verifyRendererIdentities } from './verify.js';
|
|
2
2
|
export { BUNDLED_RENDERER_IDENTITIES, BUNDLED_RENDERER_LIST, newerRendererList } from './renderers.js';
|
|
3
3
|
export { verifyDecisionBundle, BUNDLE_LIMITS } from './bundle.js';
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
package/dist/receipts/json.d.ts
CHANGED
|
@@ -19,4 +19,3 @@ export declare function checkedInstant(value: unknown): number | undefined;
|
|
|
19
19
|
export declare function abortError(signal: AbortSignal): SessError;
|
|
20
20
|
/** Race a promise without cancelling shared work; always remove this waiter's listener. */
|
|
21
21
|
export declare function waitWithSignal<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
22
|
-
//# sourceMappingURL=json.d.ts.map
|
package/dist/receipts/json.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// with the issuer's trusted receipt keys, so a future Sess page change needs no SDK update.
|
|
4
4
|
//
|
|
5
5
|
// The issuer publishes the list at `<issuer>/.well-known/sess-renderer-identities.json`
|
|
6
|
-
// (
|
|
6
|
+
// (receipt-v1 §10, docs/spec/receipt-v1.md in this repository): one JWS in the RFC 7515 flattened JSON serialization
|
|
7
7
|
// {"protected", "payload", "signature"}, protected header {"alg": "EdDSA", "kid",
|
|
8
8
|
// "typ": "sess-renderer-identities+jwt"}, payload the RFC 8785 canonical JSON
|
|
9
9
|
// {"iat", "identities": [{"renderer_version", "since"}, …], "iss", "seq",
|
|
@@ -151,4 +151,3 @@ export function newerRendererList(a, b) {
|
|
|
151
151
|
}
|
|
152
152
|
return newer;
|
|
153
153
|
}
|
|
154
|
-
//# sourceMappingURL=renderers.js.map
|
package/dist/receipts/verify.js
CHANGED
package/dist/sessions.d.ts
CHANGED
package/dist/sessions.js
CHANGED
package/dist/transport.d.ts
CHANGED
package/dist/transport.js
CHANGED
|
@@ -3,6 +3,7 @@ import { SessError, attachRecovery, lengthMessage } from './errors.js';
|
|
|
3
3
|
import { isLoopback } from './internal/decode.js';
|
|
4
4
|
import { serializeBody } from './internal/json.js';
|
|
5
5
|
import { abortError, boundedNumber, deadline, delay, withSignal } from './internal/time.js';
|
|
6
|
+
import { SDK_VERSION } from './internal/version.js';
|
|
6
7
|
const transientStatuses = new Set([408, 429, 500, 502, 503, 504]);
|
|
7
8
|
const rejections = {
|
|
8
9
|
400: ['INVALID_SCHEMA', 'UNKNOWN_COMPONENT', 'WEBHOOK_INVALID_URL'],
|
|
@@ -20,7 +21,27 @@ const rejections = {
|
|
|
20
21
|
413: ['PAYLOAD_TOO_LARGE'],
|
|
21
22
|
422: ['VALIDATION_FAILED', 'WEBHOOK_VERIFICATION_FAILED'],
|
|
22
23
|
428: ['PRECONDITION_REQUIRED'],
|
|
24
|
+
// A plan limit refuses the create before anything is written: nothing is created. It is not a
|
|
25
|
+
// rate limit; a plain 429 (no code, or RATE_LIMITED) stays transient and its outcome uncertain.
|
|
26
|
+
429: ['PLAN_LIMIT_REACHED'],
|
|
23
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.';
|
|
30
|
+
/** RFC 9110 product tokens (`name` or `name/version`), separated by single spaces. */
|
|
31
|
+
const PRODUCT = "[!#$%&'*+.^_`|~0-9A-Za-z-]+(?:/[!#$%&'*+.^_`|~0-9A-Za-z-]+)?";
|
|
32
|
+
const PRODUCTS = new RegExp(`^${PRODUCT}(?: ${PRODUCT})*$`);
|
|
33
|
+
/**
|
|
34
|
+
* The User-Agent: a wrapping client's tokens, then `sess-sdk/<version>`, then the runtime's
|
|
35
|
+
* `node/<version>` when there is one. Sess classifies the creating client by these tokens.
|
|
36
|
+
*/
|
|
37
|
+
function userAgent(prefix) {
|
|
38
|
+
if (prefix !== undefined && (typeof prefix !== 'string' || prefix.length > 256 || !PRODUCTS.test(prefix)))
|
|
39
|
+
throw new SessError('configuration', 'userAgent must be one or more product tokens such as my-app/1.2.0, separated by single spaces.', { outcome: 'not_sent' });
|
|
40
|
+
const node = typeof process === 'undefined' ? undefined : process.versions?.node;
|
|
41
|
+
return [prefix, `sess-sdk/${SDK_VERSION}`, typeof node === 'string' ? `node/${node}` : undefined]
|
|
42
|
+
.filter((token) => token !== undefined)
|
|
43
|
+
.join(' ');
|
|
44
|
+
}
|
|
24
45
|
function credential(value) {
|
|
25
46
|
if (typeof value !== 'string' || !/^[\x21-\x7e]{1,4096}$/.test(value)) {
|
|
26
47
|
throw new SessError('configuration', 'Supply a Sess API key on the server. It must not be empty or contain whitespace or control characters.', { code: 'INVALID_API_KEY', outcome: 'not_sent' });
|
|
@@ -71,11 +92,16 @@ function origin(input, allowInsecure) {
|
|
|
71
92
|
}
|
|
72
93
|
return url.origin;
|
|
73
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}$/;
|
|
74
97
|
function safeText(value, pattern, key, opaqueIdentifier = false) {
|
|
75
98
|
if (typeof value !== 'string' ||
|
|
76
99
|
!pattern.test(value) ||
|
|
77
100
|
/sess_(?:sk|mg|tk|mk)_|whsec_|eyJ/.test(value) ||
|
|
78
|
-
|
|
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)) ||
|
|
79
105
|
(key && value.includes(key)))
|
|
80
106
|
return undefined;
|
|
81
107
|
return value;
|
|
@@ -172,6 +198,7 @@ export class Transport {
|
|
|
172
198
|
#maxRetries;
|
|
173
199
|
#maxResponseBytes;
|
|
174
200
|
#onRequestEvent;
|
|
201
|
+
#userAgent;
|
|
175
202
|
constructor(options) {
|
|
176
203
|
if (!options || typeof options !== 'object')
|
|
177
204
|
throw new SessError('configuration', 'Sess options with apiKey are required.', { outcome: 'not_sent' });
|
|
@@ -202,6 +229,7 @@ export class Transport {
|
|
|
202
229
|
this.operationTimeoutMs = boundedNumber(options.operationTimeoutMs, 30000, 'operationTimeoutMs');
|
|
203
230
|
this.#maxRetries = boundedNumber(options.maxRetries, 2, 'maxRetries', 0, 10);
|
|
204
231
|
this.#maxResponseBytes = boundedNumber(options.maxResponseBytes, 16 * 1024 * 1024, 'maxResponseBytes', 1, 256 * 1024 * 1024);
|
|
232
|
+
this.#userAgent = userAgent(options.userAgent);
|
|
205
233
|
this.#onRequestEvent = options.onRequestEvent;
|
|
206
234
|
if (this.#onRequestEvent !== undefined && typeof this.#onRequestEvent !== 'function')
|
|
207
235
|
throw new SessError('configuration', 'onRequestEvent must be a function.', { outcome: 'not_sent' });
|
|
@@ -225,7 +253,7 @@ export class Transport {
|
|
|
225
253
|
op.path.includes('#') ||
|
|
226
254
|
op.path.includes('?'))
|
|
227
255
|
throw new SessError('configuration', 'Invalid API resource path.', { outcome: 'not_sent' });
|
|
228
|
-
const headers = { Accept: 'application/json' };
|
|
256
|
+
const headers = { Accept: 'application/json', 'User-Agent': this.#userAgent };
|
|
229
257
|
if (body !== undefined)
|
|
230
258
|
headers['Content-Type'] = 'application/json';
|
|
231
259
|
let idempotencyKey;
|
|
@@ -322,11 +350,14 @@ export class Transport {
|
|
|
322
350
|
const reason = safeText(remote.reason, /^[a-z_]{1,40}$/, key);
|
|
323
351
|
const remoteId = safeText(remote.request_id, /^[A-Za-z0-9._:-]{1,128}$/, key, true) ?? requestId;
|
|
324
352
|
const rejected = code !== undefined && rejections[response.status]?.includes(code);
|
|
325
|
-
|
|
353
|
+
// A definite coded refusal is final: repeating it cannot succeed, so it is never retried.
|
|
354
|
+
retryable = transientStatuses.has(response.status) && !rejected;
|
|
326
355
|
const length = lengthDetail(remote, code, key);
|
|
327
356
|
const message = length.field !== undefined
|
|
328
357
|
? lengthMessage(length.field, length.limit, length.length)
|
|
329
|
-
:
|
|
358
|
+
: response.status === 401 && code === 'UNAUTHORIZED'
|
|
359
|
+
? UNAUTHORIZED_MESSAGE
|
|
360
|
+
: 'The Sess API returned an error. See the status and code fields.';
|
|
330
361
|
throw new SessError('api', message, {
|
|
331
362
|
code,
|
|
332
363
|
reason,
|
|
@@ -478,4 +509,3 @@ export class Transport {
|
|
|
478
509
|
}
|
|
479
510
|
}
|
|
480
511
|
}
|
|
481
|
-
//# sourceMappingURL=transport.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -68,6 +68,50 @@ type WireComponent = Schemas['SurfaceComponent'];
|
|
|
68
68
|
type Component<T extends WireComponent['type']> = Extract<WireComponent, {
|
|
69
69
|
type: T;
|
|
70
70
|
}>;
|
|
71
|
+
/** The role of a totals line: how Sess checks the arithmetic, never a colour. */
|
|
72
|
+
export type ItemTotalRole = 'subtotal' | 'tax' | 'discount' | 'shipping' | 'fee' | 'tip' | 'paid' | 'due' | 'adjustment' | 'total' | 'other';
|
|
73
|
+
/**
|
|
74
|
+
* Line items with amounts and totals (Commerce): the runtime's `items` component, as sent. Amounts
|
|
75
|
+
* are whole numbers in the currency's minor unit (cents for USD, yen for JPY, fils for BHD), one
|
|
76
|
+
* ISO 4217 currency per component; Sess never rounds, converts or computes them, and checks a
|
|
77
|
+
* stated subtotal, total and amount due exactly. Build one with `items()` or a Commerce builder.
|
|
78
|
+
*/
|
|
79
|
+
export interface ItemsComponent {
|
|
80
|
+
type: 'items';
|
|
81
|
+
/** Optional caption: what the list is, a few words; at most 200. Example: `Invoice 2041` */
|
|
82
|
+
label?: string;
|
|
83
|
+
/** ISO 4217 code with known minor units, such as `CAD`, `JPY` or `BHD`. */
|
|
84
|
+
currency: string;
|
|
85
|
+
/** The person may choose rows: one (radios) or many (checkboxes). Needs `name`. */
|
|
86
|
+
select?: 'one' | 'many';
|
|
87
|
+
/** The person may change the quantity of rows that carry one. Needs `name` and a `request_change` action. */
|
|
88
|
+
editable?: ['quantity'];
|
|
89
|
+
/** The answer's name, `^[a-z][a-z0-9_]{0,55}$`, with `select` or `editable` only. */
|
|
90
|
+
name?: string;
|
|
91
|
+
/** 1–100 rows, in order. */
|
|
92
|
+
rows: {
|
|
93
|
+
/** What one line is: at most 80. Example: `Design retainer, October` */
|
|
94
|
+
name: string;
|
|
95
|
+
/** Optional second line: quantity, unit price or a reference; at most 160. Example: `3 × $150.00` */
|
|
96
|
+
detail?: string;
|
|
97
|
+
/** An editable quantity (with `editable`): an integer 0–1,000,000 within `min` and `max`. */
|
|
98
|
+
quantity?: {
|
|
99
|
+
value: number;
|
|
100
|
+
unit?: string;
|
|
101
|
+
min?: number;
|
|
102
|
+
max?: number;
|
|
103
|
+
};
|
|
104
|
+
/** Minor units, |amount| ≤ 10^15, or null for a line with no amount. */
|
|
105
|
+
amount: number | null;
|
|
106
|
+
}[];
|
|
107
|
+
/** Up to 8 totals lines, in order, as stated. A label: a word or two; at most 40. */
|
|
108
|
+
totals?: {
|
|
109
|
+
label: string;
|
|
110
|
+
amount: number;
|
|
111
|
+
role: ItemTotalRole;
|
|
112
|
+
included?: boolean;
|
|
113
|
+
}[];
|
|
114
|
+
}
|
|
71
115
|
/**
|
|
72
116
|
* One piece of an interactive Surface, shown in order. Lengths are Unicode code points; Sess
|
|
73
117
|
* never truncates: a value over its limit is a 400 INVALID_SCHEMA whose `field`, `limit` and
|
|
@@ -105,7 +149,7 @@ export type SurfaceComponent = (Component<'heading'> & {
|
|
|
105
149
|
[key: string]: string;
|
|
106
150
|
};
|
|
107
151
|
schema: FieldSchema;
|
|
108
|
-
});
|
|
152
|
+
}) | ItemsComponent;
|
|
109
153
|
type DocumentedAction = RawPublishSessionRequest['interaction']['actions'][number] & {
|
|
110
154
|
/** A button: a verb, 1–3 words; at most 24. Examples: `Approve`, `Send refund` */
|
|
111
155
|
label: string;
|
|
@@ -127,6 +171,11 @@ export type InteractiveInteraction = Omit<RawPublishSessionRequest['interaction'
|
|
|
127
171
|
* sentences; at most 280. Example: `The customer was charged twice for order 1042.`
|
|
128
172
|
*/
|
|
129
173
|
description?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Advanced: one BCP 47 locale for formatting this page's amounts (default: the page's language,
|
|
176
|
+
* `en`). It does not translate the page. Example: `en-CA`
|
|
177
|
+
*/
|
|
178
|
+
locale?: string;
|
|
130
179
|
source: {
|
|
131
180
|
kind: 'sess_surface';
|
|
132
181
|
components: SurfaceComponent[];
|
|
@@ -221,9 +270,14 @@ export interface SessOptions {
|
|
|
221
270
|
expectedWorkspaceId?: string;
|
|
222
271
|
allowInsecureLocalhost?: boolean;
|
|
223
272
|
onRequestEvent?: (event: Readonly<RequestEvent>) => void;
|
|
273
|
+
/**
|
|
274
|
+
* Product tokens of a client built on this SDK, sent before the SDK's own in the User-Agent
|
|
275
|
+
* header: `'my-app/1.2.0'` sends `my-app/1.2.0 sess-sdk/<version> node/<version>`. One or more
|
|
276
|
+
* `name` or `name/version` tokens separated by single spaces, at most 256 characters.
|
|
277
|
+
*/
|
|
278
|
+
userAgent?: string;
|
|
224
279
|
}
|
|
225
280
|
/** Narrow a retrieved display/interactive Session without asserting business data. */
|
|
226
281
|
export declare function isInteractiveSession(session: Session): session is InteractiveSession;
|
|
227
282
|
/** Narrow immutable content before accessing interactive-only schema or actions. */
|
|
228
283
|
export declare function isInteractiveSurface(surface: SurfaceRevision): surface is InteractiveSurfaceRevision;
|
|
229
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
CHANGED
package/dist/webhook-resource.js
CHANGED
package/dist/webhooks/index.d.ts
CHANGED
|
@@ -19,4 +19,3 @@ export interface VerifyWebhookOptions {
|
|
|
19
19
|
* not decision-receipt verification or authorization to perform application business work.
|
|
20
20
|
*/
|
|
21
21
|
export declare function verifyWebhook(rawBody: Uint8Array | string, headers: WebhookHeaders, options: VerifyWebhookOptions): VerifiedWebhook;
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/webhooks/index.js
CHANGED