@usequeek/app-sdk 0.6.1 → 0.6.2
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/README.md +76 -70
- package/dist/app-auth.d.ts +14 -15
- package/dist/app-auth.d.ts.map +1 -1
- package/dist/app-auth.js +19 -21
- package/dist/app-auth.js.map +1 -1
- package/dist/auth-fetch.d.ts +2 -4
- package/dist/auth-fetch.d.ts.map +1 -1
- package/dist/auth-fetch.js +2 -4
- package/dist/auth-fetch.js.map +1 -1
- package/dist/background.d.ts +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/client.d.ts +8 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -2
- package/dist/client.js.map +1 -1
- package/dist/collected.d.ts +13 -14
- package/dist/collected.d.ts.map +1 -1
- package/dist/collected.js +4 -4
- package/dist/collected.js.map +1 -1
- package/dist/crypto.js +3 -3
- package/dist/crypto.js.map +1 -1
- package/dist/delivery.d.ts +4 -8
- package/dist/delivery.d.ts.map +1 -1
- package/dist/delivery.js +4 -8
- package/dist/delivery.js.map +1 -1
- package/dist/frame.d.ts +11 -11
- package/dist/frame.d.ts.map +1 -1
- package/dist/frame.js +11 -11
- package/dist/frame.js.map +1 -1
- package/dist/handoff.d.ts +35 -38
- package/dist/handoff.d.ts.map +1 -1
- package/dist/handoff.js +9 -9
- package/dist/hono.d.ts +3 -3
- package/dist/hono.js +3 -3
- package/dist/install-handlers.d.ts +6 -7
- package/dist/install-handlers.d.ts.map +1 -1
- package/dist/install-handlers.js +11 -11
- package/dist/install-handlers.js.map +1 -1
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/merchant-schema.d.ts +14882 -6288
- package/dist/merchant-schema.d.ts.map +1 -1
- package/dist/proxy.d.ts +20 -22
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +19 -20
- package/dist/proxy.js.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/resync.d.ts +4 -4
- package/dist/resync.d.ts.map +1 -1
- package/dist/resync.js +4 -4
- package/dist/resync.js.map +1 -1
- package/dist/scopes.d.ts +22 -26
- package/dist/scopes.d.ts.map +1 -1
- package/dist/scopes.js +19 -23
- package/dist/scopes.js.map +1 -1
- package/dist/session.d.ts +15 -16
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +12 -14
- package/dist/session.js.map +1 -1
- package/dist/signatures.d.ts +5 -4
- package/dist/signatures.d.ts.map +1 -1
- package/dist/signatures.js +7 -6
- package/dist/signatures.js.map +1 -1
- package/dist/store.d.ts +20 -25
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +16 -19
- package/dist/store.js.map +1 -1
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +1 -1
- package/dist/tokens.d.ts +9 -9
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +9 -10
- package/dist/tokens.js.map +1 -1
- package/dist/webhooks.d.ts +2 -3
- package/dist/webhooks.d.ts.map +1 -1
- package/dist/webhooks.js +2 -3
- package/dist/webhooks.js.map +1 -1
- package/package.json +4 -3
package/dist/scopes.js
CHANGED
|
@@ -4,8 +4,7 @@ import { isAllowedOpenTarget } from "./frame.js";
|
|
|
4
4
|
import { installationScopesEqual } from "./install-handlers.js";
|
|
5
5
|
import { resolveAppApiBase } from "./tokens.js";
|
|
6
6
|
/**
|
|
7
|
-
* Optional scopes
|
|
8
|
-
* parity — symbol names cited only).
|
|
7
|
+
* Optional scopes: query, request and revoke.
|
|
9
8
|
*
|
|
10
9
|
* - `queryScopes`: the cached effective grant split against the app's own
|
|
11
10
|
* declared-optional list. Store-read only, never a fetch: the app-credential
|
|
@@ -17,25 +16,24 @@ import { resolveAppApiBase } from "./tokens.js";
|
|
|
17
16
|
* consent — it hands the app a link shaped like the bridge
|
|
18
17
|
* `open`/`navigate` targets (dashboard-relative path, or an absolute URL
|
|
19
18
|
* under a given dashboard origin) for the app to open via `sendOpen` or
|
|
20
|
-
* redirect to.
|
|
21
|
-
*
|
|
19
|
+
* redirect to. Opening it requires a dashboard that supports the consent
|
|
20
|
+
* screen, which honours this link shape.
|
|
22
21
|
* - `revokeScopes`: `POST
|
|
23
22
|
* /api/v1/apps/installations/{installation}/scopes/revoke` with the app
|
|
24
|
-
* JWT (same credential as mint/resync —
|
|
25
|
-
*
|
|
26
|
-
* `RevokeAppScopesRequest`); an `Idempotency-Key` rides the write for
|
|
23
|
+
* JWT (same credential as mint/resync — not the installation token).
|
|
24
|
+
* Body `{scopes[]}` (1–50); an `Idempotency-Key` rides the write for
|
|
27
25
|
* discipline (generated when the caller does not supply one — the client
|
|
28
26
|
* write discipline), though the route is naturally idempotent: revoking
|
|
29
27
|
* a never-granted optional scope is 200 with no change. Required scopes
|
|
30
28
|
* refuse 422 `app_scope_required` (surfaced as `AppScopeRequiredError`).
|
|
31
29
|
* On 200 the cached grant is refreshed from the response and the cached
|
|
32
30
|
* token dropped only when the grant moved (same compare-and-clear as the
|
|
33
|
-
* scopes_update handler —
|
|
34
|
-
*
|
|
31
|
+
* scopes_update handler — Queek rewrites live token rows in place, so
|
|
32
|
+
* the drop is a backstop, not the mechanism).
|
|
35
33
|
*
|
|
36
34
|
* Types here are hand-written: the revoke endpoint and the scopes_update
|
|
37
|
-
* handoff live on the app-credential surface, which the
|
|
38
|
-
* `openapi/merchant.json` does not cover (types are generated app-side by
|
|
35
|
+
* handoff live on the app-credential surface, which the bundled
|
|
36
|
+
* `openapi/merchant.json` snapshot does not cover (types are generated app-side by
|
|
39
37
|
* `queek app codegen`; the merchant spec file is never hand-edited).
|
|
40
38
|
*/
|
|
41
39
|
/** 422 on the revoke endpoint: required scopes are never revocable (uninstall is the remedy). */
|
|
@@ -48,8 +46,8 @@ export function isAppScopeRequired(status, code) {
|
|
|
48
46
|
}
|
|
49
47
|
/**
|
|
50
48
|
* A required-scope refusal, typed so callers switch on the class (or
|
|
51
|
-
* `code`), never on `message`. Carries the offending scopes when
|
|
52
|
-
*
|
|
49
|
+
* `code`), never on `message`. Carries the offending scopes when Queek
|
|
50
|
+
* named them.
|
|
53
51
|
*/
|
|
54
52
|
export class AppScopeRequiredError extends QueekApiError {
|
|
55
53
|
scopes;
|
|
@@ -79,13 +77,13 @@ export class InvalidScopesError extends Error {
|
|
|
79
77
|
this.name = "InvalidScopesError";
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
|
-
/**
|
|
80
|
+
/** Bounds of the revoke request (1–50 scopes), mirrored client-side. */
|
|
83
81
|
export const MAX_SCOPE_LIST = 50;
|
|
84
82
|
export const MAX_SCOPE_LENGTH = 120;
|
|
85
83
|
/**
|
|
86
84
|
* Validate + normalise a scope list (trim, drop empties, dedupe keeping
|
|
87
|
-
* first order). Mirrors the
|
|
88
|
-
*
|
|
85
|
+
* first order). Mirrors the revoke endpoint's rules (a required array of
|
|
86
|
+
* 1–50 string items) so a malformed call fails before any fetch.
|
|
89
87
|
*/
|
|
90
88
|
export function normaliseScopeList(scopes) {
|
|
91
89
|
if (!Array.isArray(scopes)) {
|
|
@@ -134,8 +132,7 @@ export function revokeScopesPath(installationId) {
|
|
|
134
132
|
* under `dashboardOrigin` (refused exactly like `sendOpen` refuses a bad
|
|
135
133
|
* target).
|
|
136
134
|
*
|
|
137
|
-
* Link shape (the
|
|
138
|
-
* the only query route the dashboard `AppsPage` serves):
|
|
135
|
+
* Link shape (the contract the dashboard's consent screen honours):
|
|
139
136
|
* `/apps?app={slug}&view=scopes&scopes={a},{b}` (each scope
|
|
140
137
|
* URL-encoded, comma-separated). The link carries the slug + the scope
|
|
141
138
|
* list only: the dashboard resolves the installation from the signed-in
|
|
@@ -193,7 +190,7 @@ export function createInstallationScopesClient(options) {
|
|
|
193
190
|
* The dashboard deep link that opens the merchant's consent screen in
|
|
194
191
|
* the dashboard. Pure (no store, no network): the app opens it via
|
|
195
192
|
* `sendOpen` or a redirect and the merchant consents in the dashboard
|
|
196
|
-
* (
|
|
193
|
+
* (requires a dashboard that supports the consent screen). Shaped like the bridge `open`
|
|
197
194
|
* targets — dashboard-relative, or absolute under the dashboard origin
|
|
198
195
|
* when one is configured.
|
|
199
196
|
*/
|
|
@@ -209,14 +206,13 @@ export function createInstallationScopesClient(options) {
|
|
|
209
206
|
});
|
|
210
207
|
}
|
|
211
208
|
/**
|
|
212
|
-
* App-initiated revoke of optional scopes
|
|
213
|
-
* `AppInstallationController::revokeScopes`): the app JWT signs the call
|
|
209
|
+
* App-initiated revoke of optional scopes: the app JWT signs the call
|
|
214
210
|
* (same credential as mint/resync), an `Idempotency-Key` rides the write
|
|
215
211
|
* for discipline only (the route is naturally idempotent), and on 200
|
|
216
212
|
* the cached grant is refreshed from the response with the cached token
|
|
217
213
|
* dropped only when the grant moved (same compare-and-clear as the
|
|
218
|
-
* scopes_update handler — backstop, since
|
|
219
|
-
*
|
|
214
|
+
* scopes_update handler — a backstop, since Queek rewrites live token
|
|
215
|
+
* rows in place). A required scope refuses 422
|
|
220
216
|
* `app_scope_required` as `AppScopeRequiredError`; a gone installation
|
|
221
217
|
* purges the local row and rethrows; anything else propagates untouched.
|
|
222
218
|
* A 401 never halts here — the mint path owns that mapping and halts on
|
package/dist/scopes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scopes.js","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"scopes.js","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA,OAA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AC;AAED,uGAAuG;AACvG,SAAS,eAAe,CAAC,IAAa;IACpC,MAAM,MAAM,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAA4B,CAAC;IAClG,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;QAClF,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IACzC,CAAC;AACH,CAAC"}
|
package/dist/session.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dashboard session tokens: short-lived HS256 JWTs
|
|
3
|
-
* installation for the framed merchant page. The app
|
|
4
|
-
* with the per-installation `embsec_…` secret before trusting any
|
|
5
|
-
* that carries one.
|
|
2
|
+
* Dashboard session tokens: short-lived HS256 JWTs Queek mints per
|
|
3
|
+
* installation for the framed merchant page. The app's server verifies
|
|
4
|
+
* them with the per-installation `embsec_…` secret before trusting any
|
|
5
|
+
* call that carries one.
|
|
6
6
|
*
|
|
7
|
-
* ONE token type
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* is the whole check.
|
|
7
|
+
* ONE token type: the dashboard puts the same token in the first-load URL
|
|
8
|
+
* param (`queek_token`, stripped on arrival) and answers bridge `ready`
|
|
9
|
+
* requests with it, so the app's exchange endpoint verifies first-load and
|
|
10
|
+
* refresh tokens with this one verifier. No purpose split: extra claims the
|
|
11
|
+
* mint may carry are ignored, never gated — identity binding
|
|
12
|
+
* (installation, audience, issuer, expiry) is the whole check.
|
|
14
13
|
*
|
|
15
14
|
* Server-only: the secret must never enter a browser bundle, so this module
|
|
16
15
|
* ships behind the `./server` export, not the main entry. Style mirrors
|
|
@@ -20,7 +19,7 @@
|
|
|
20
19
|
export declare const EMBED_SECRET_PREFIX = "embsec_";
|
|
21
20
|
/** The only JWS algorithm the dashboard mints (HS256 over the embsec_ secret). */
|
|
22
21
|
export declare const SESSION_TOKEN_ALG = "HS256";
|
|
23
|
-
/**
|
|
22
|
+
/** Clock skew the verifier tolerates, in seconds (matches the mint side). */
|
|
24
23
|
export declare const SESSION_CLOCK_TOLERANCE_SECONDS = 20;
|
|
25
24
|
export type SessionTokenFailure = "missing_token" | "missing_secret" | "wrong_algorithm" | "invalid_signature" | "expired" | "not_yet_valid" | "wrong_audience" | "wrong_issuer" | "binding_mismatch";
|
|
26
25
|
export interface SessionTokenClaims {
|
|
@@ -46,15 +45,15 @@ export interface VerifySessionTokenOptions {
|
|
|
46
45
|
audience: string;
|
|
47
46
|
/**
|
|
48
47
|
* Expected issuer: the handoff `api_base` VERBATIM
|
|
49
|
-
* (`installation.apiBase` — it equals the bare `app.url`
|
|
50
|
-
*
|
|
48
|
+
* (`installation.apiBase` — it equals the bare `app.url` Queek signs as
|
|
49
|
+
* `iss`). Never a prefix or a suffix of it.
|
|
51
50
|
*/
|
|
52
51
|
issuer: string;
|
|
53
52
|
/**
|
|
54
|
-
* The installation row the token must belong to (the app
|
|
53
|
+
* The installation row the token must belong to (the app server's own
|
|
55
54
|
* record). Every field is compared — a token minted for another
|
|
56
55
|
* installation fails closed even when its signature and audience check
|
|
57
|
-
* out
|
|
56
|
+
* out.
|
|
58
57
|
*/
|
|
59
58
|
expected: SessionTokenBinding;
|
|
60
59
|
clockToleranceSeconds?: number;
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAEzC,6EAA6E;AAC7E,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,GACnB,SAAS,GACT,eAAe,GACf,gBAAgB,GAChB,cAAc,GACd,kBAAkB,CAAC;AAEvB,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAUhG;AAkDD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOvE"}
|
package/dist/session.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { decodeJwt, decodeProtectedHeader, jwtVerify } from "jose";
|
|
2
2
|
/**
|
|
3
|
-
* Dashboard session tokens: short-lived HS256 JWTs
|
|
4
|
-
* installation for the framed merchant page. The app
|
|
5
|
-
* with the per-installation `embsec_…` secret before trusting any
|
|
6
|
-
* that carries one.
|
|
3
|
+
* Dashboard session tokens: short-lived HS256 JWTs Queek mints per
|
|
4
|
+
* installation for the framed merchant page. The app's server verifies
|
|
5
|
+
* them with the per-installation `embsec_…` secret before trusting any
|
|
6
|
+
* call that carries one.
|
|
7
7
|
*
|
|
8
|
-
* ONE token type
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* is the whole check.
|
|
8
|
+
* ONE token type: the dashboard puts the same token in the first-load URL
|
|
9
|
+
* param (`queek_token`, stripped on arrival) and answers bridge `ready`
|
|
10
|
+
* requests with it, so the app's exchange endpoint verifies first-load and
|
|
11
|
+
* refresh tokens with this one verifier. No purpose split: extra claims the
|
|
12
|
+
* mint may carry are ignored, never gated — identity binding
|
|
13
|
+
* (installation, audience, issuer, expiry) is the whole check.
|
|
15
14
|
*
|
|
16
15
|
* Server-only: the secret must never enter a browser bundle, so this module
|
|
17
16
|
* ships behind the `./server` export, not the main entry. Style mirrors
|
|
@@ -21,7 +20,7 @@ import { decodeJwt, decodeProtectedHeader, jwtVerify } from "jose";
|
|
|
21
20
|
export const EMBED_SECRET_PREFIX = "embsec_";
|
|
22
21
|
/** The only JWS algorithm the dashboard mints (HS256 over the embsec_ secret). */
|
|
23
22
|
export const SESSION_TOKEN_ALG = "HS256";
|
|
24
|
-
/**
|
|
23
|
+
/** Clock skew the verifier tolerates, in seconds (matches the mint side). */
|
|
25
24
|
export const SESSION_CLOCK_TOLERANCE_SECONDS = 20;
|
|
26
25
|
export async function verifySessionToken(token, options) {
|
|
27
26
|
const result = await verifySessionTokenDetailed(token, options);
|
|
@@ -132,8 +131,7 @@ function readSessionClaims(payload) {
|
|
|
132
131
|
return { installationId, vendorId, appSlug, appId, subject, sessionId, issuedAt, expiresAt };
|
|
133
132
|
}
|
|
134
133
|
function classifyJoseError(error) {
|
|
135
|
-
// Exact jose v6
|
|
136
|
-
// the `claim` field probed, not guessed): claim failures carry code
|
|
134
|
+
// Exact jose v6 error shapes (jose@6.2.12): claim failures carry code
|
|
137
135
|
// ERR_JWT_CLAIM_VALIDATION_FAILED and name the claim; expiry also
|
|
138
136
|
// surfaces as JWTExpired / ERR_JWT_EXPIRED; algorithm refusal is
|
|
139
137
|
// JOSEAlgNotAllowed / ERR_JOSE_ALG_NOT_ALLOWED (unreachable in practice —
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEnE
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"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K,EAAE,CAAC;QACpB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACpB,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,MAAM,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,IAAI,KAAK,0BAA0B,EAAE,CAAC;QACxC,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,MAAM,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,IAAI,KAAK,mBAAmB,EAAE,CAAC;QACjC,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
package/dist/signatures.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Standard Webhooks verification, byte-for-byte compatible with
|
|
3
|
-
*
|
|
2
|
+
* Standard Webhooks verification, byte-for-byte compatible with the way
|
|
3
|
+
* Queek signs deliveries
|
|
4
|
+
* (https://github.com/standard-webhooks/standard-webhooks/blob/main/spec/standard-webhooks.md).
|
|
4
5
|
*
|
|
5
6
|
* Signed content: `{id}.{timestamp}.{body}` where `body` is the RAW request
|
|
6
7
|
* bytes. Re-serialising JSON before verifying breaks the MAC — verify first,
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
*
|
|
9
10
|
* The MAC key is the DECODED bytes of the `whsec_<base64>` secret, not the
|
|
10
11
|
* printable string. A secret without the prefix (or with undecodable base64)
|
|
11
|
-
* falls back to the raw string, exactly like
|
|
12
|
+
* falls back to the raw string, exactly like Queek's signer.
|
|
12
13
|
*
|
|
13
14
|
* Header names: `webhook-id`, `webhook-timestamp`, `webhook-signature`.
|
|
14
15
|
* The signature header may carry several space-delimited `v1,<base64>`
|
|
@@ -41,7 +42,7 @@ export interface VerifyOptions {
|
|
|
41
42
|
skipFreshnessCheck?: boolean;
|
|
42
43
|
}
|
|
43
44
|
export declare function secretKeyBytes(secret: string): Buffer;
|
|
44
|
-
/** One `v1,<base64>` signature for one secret
|
|
45
|
+
/** One `v1,<base64>` signature for one secret, in the format Queek sends. */
|
|
45
46
|
export declare function signQueekPayload(eventId: string, timestamp: number | string, body: string, secret: string): string;
|
|
46
47
|
/** Failure reason when verification rejects a delivery. */
|
|
47
48
|
export type SignatureFailure = "missing_headers" | "stale_timestamp" | "signature_mismatch";
|
package/dist/signatures.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signatures.d.ts","sourceRoot":"","sources":["../src/signatures.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"signatures.d.ts","sourceRoot":"","sources":["../src/signatures.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAC9C,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,eAAO,MAAM,aAAa,WAAW,CAAC;AAEtC,2GAA2G;AAC3G,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,eAAe,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yFAAyF;IACzF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAarD;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,MAAM,CAKR;AAED,2DAA2D;AAC3D,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAE5F,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAEhG;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,cAAc,EACrB,OAAO,GAAE,aAAkB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAyBxD"}
|
package/dist/signatures.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
2
|
/**
|
|
3
|
-
* Standard Webhooks verification, byte-for-byte compatible with
|
|
4
|
-
*
|
|
3
|
+
* Standard Webhooks verification, byte-for-byte compatible with the way
|
|
4
|
+
* Queek signs deliveries
|
|
5
|
+
* (https://github.com/standard-webhooks/standard-webhooks/blob/main/spec/standard-webhooks.md).
|
|
5
6
|
*
|
|
6
7
|
* Signed content: `{id}.{timestamp}.{body}` where `body` is the RAW request
|
|
7
8
|
* bytes. Re-serialising JSON before verifying breaks the MAC — verify first,
|
|
@@ -9,7 +10,7 @@ import { createHmac, timingSafeEqual } from "node:crypto";
|
|
|
9
10
|
*
|
|
10
11
|
* The MAC key is the DECODED bytes of the `whsec_<base64>` secret, not the
|
|
11
12
|
* printable string. A secret without the prefix (or with undecodable base64)
|
|
12
|
-
* falls back to the raw string, exactly like
|
|
13
|
+
* falls back to the raw string, exactly like Queek's signer.
|
|
13
14
|
*
|
|
14
15
|
* Header names: `webhook-id`, `webhook-timestamp`, `webhook-signature`.
|
|
15
16
|
* The signature header may carry several space-delimited `v1,<base64>`
|
|
@@ -25,8 +26,8 @@ export function secretKeyBytes(secret) {
|
|
|
25
26
|
const encoded = secret.startsWith(SECRET_PREFIX) ? secret.slice(SECRET_PREFIX.length) : secret;
|
|
26
27
|
try {
|
|
27
28
|
const decoded = Buffer.from(encoded, "base64");
|
|
28
|
-
// Round-trip guard:
|
|
29
|
-
//
|
|
29
|
+
// Round-trip guard: Queek's signer falls back to the raw secret string
|
|
30
|
+
// when the input is not strictly valid base64.
|
|
30
31
|
if (decoded.length > 0 && decoded.toString("base64").replace(/=+$/, "") === encoded.replace(/=+$/, "")) {
|
|
31
32
|
return decoded;
|
|
32
33
|
}
|
|
@@ -36,7 +37,7 @@ export function secretKeyBytes(secret) {
|
|
|
36
37
|
return Buffer.from(secret, "utf8");
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
/** One `v1,<base64>` signature for one secret
|
|
40
|
+
/** One `v1,<base64>` signature for one secret, in the format Queek sends. */
|
|
40
41
|
export function signQueekPayload(eventId, timestamp, body, secret) {
|
|
41
42
|
const mac = createHmac("sha256", secretKeyBytes(secret))
|
|
42
43
|
.update(`${eventId}.${timestamp}.${body}`, "utf8")
|
package/dist/signatures.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signatures.js","sourceRoot":"","sources":["../src/signatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,a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D,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClD,KAAK,MAAM,SAAS,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5D,IAAI,SAAS,KAAK,EAAE;YAAE,SAAS;QAC/B,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACpD,IAAI,YAAY,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,IAAI,eAAe,CAAC,YAAY,EAAE,WAAW,CAAC,EAAE,CAAC;YAC7F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC;AACrD,CAAC"}
|
package/dist/store.d.ts
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { Pool } from "pg";
|
|
2
2
|
/**
|
|
3
|
-
* The app database holds INSTALLATIONS ONLY
|
|
4
|
-
*
|
|
5
|
-
* Business data lives in Queek (product metafields,
|
|
6
|
-
* orders.integrator_metadata) — never here.
|
|
3
|
+
* The app database holds INSTALLATIONS ONLY. Business data lives in Queek
|
|
4
|
+
* (for example in product metafields) — never here.
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* No store-callable credential crosses the install handoff, so there is no
|
|
7
|
+
* `api_key` column. The app mints short-lived
|
|
10
8
|
* installation tokens with its asymmetric app key and caches ONE token per
|
|
11
9
|
* installation here (`token_enc` + `token_expires_at` + `token_kid`);
|
|
12
10
|
* `webhook_secret` AND the whole `settings` blob stay encrypted at rest
|
|
13
11
|
* (AES-256-GCM via node:crypto, key from `APP_ENCRYPTION_KEY`): manifests
|
|
14
|
-
* may declare `secret` settings (API keys, webhook secrets) and
|
|
12
|
+
* may declare `secret` settings (API keys, webhook secrets) and Queek
|
|
15
13
|
* encrypts those too, so the SDK must not be weaker. NOTHING secret is ever
|
|
16
14
|
* logged: only ids and the store p_id may appear in logs.
|
|
17
15
|
*/
|
|
18
16
|
export interface InstallationRecord {
|
|
19
|
-
/** Queek installation id (string form of the
|
|
17
|
+
/** Queek installation id (string form of the UUID). */
|
|
20
18
|
installationId: string;
|
|
21
19
|
/** Queek installation p_id (short public id, safe to log). */
|
|
22
20
|
installationPid: string;
|
|
23
|
-
/** Vendor id (
|
|
21
|
+
/** Vendor id (UUID, string form). */
|
|
24
22
|
vendorId: string;
|
|
25
23
|
/** Store p_id (safe to log). */
|
|
26
24
|
storePid: string | null;
|
|
@@ -54,9 +52,9 @@ export interface InstallationRecord {
|
|
|
54
52
|
webhookSecret: string | null;
|
|
55
53
|
/**
|
|
56
54
|
* Plaintext per-installation proxy secret — memory only, persisted as
|
|
57
|
-
* `proxy_secret_enc`, null when the app has no proxy. Signs
|
|
58
|
-
* slot-claims
|
|
59
|
-
*
|
|
55
|
+
* `proxy_secret_enc`, null when the app has no proxy. Signs claims such
|
|
56
|
+
* as booking slot-claims; never logged (the logger redacts secret-named
|
|
57
|
+
* keys).
|
|
60
58
|
*/
|
|
61
59
|
proxySecret: string | null;
|
|
62
60
|
/**
|
|
@@ -152,19 +150,17 @@ export interface SqliteStoreOptions {
|
|
|
152
150
|
* built-in `node:sqlite` (`DatabaseSync` — synchronous, file-backed, WAL
|
|
153
151
|
* mode).
|
|
154
152
|
*
|
|
155
|
-
* Why not better-sqlite3: its prebuilt binary segfaults on
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* identical synchronous shape.
|
|
153
|
+
* Why not better-sqlite3: its prebuilt binary segfaults on Node 22.12, and
|
|
154
|
+
* building from source would force a C++ toolchain into every environment
|
|
155
|
+
* — dev Macs, CI, and slim alpine images. `node:sqlite` is
|
|
156
|
+
* dependency-free with an identical synchronous shape.
|
|
160
157
|
*
|
|
161
|
-
* `node:sqlite` needs no flag since Node 22.13.0 (
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* swap is contained here, behind `InstallationStore`.
|
|
158
|
+
* `node:sqlite` needs no flag since Node 22.13.0 (an ExperimentalWarning on
|
|
159
|
+
* stderr remains — Stability 1.1). Devs on an older 22 minor set
|
|
160
|
+
* `NODE_OPTIONS=--experimental-sqlite` in their shell. The swap to another
|
|
161
|
+
* driver is contained here, behind `InstallationStore`.
|
|
166
162
|
*
|
|
167
|
-
*
|
|
163
|
+
* Legacy upgrade: databases created by SDK 0.1.x carry a legacy
|
|
168
164
|
* `api_key_enc` column (the handoff no longer delivers that key, so its
|
|
169
165
|
* value is dead — minted tokens replace it; resync restores connectivity).
|
|
170
166
|
* Opening such a database adds the token-cache columns and drops
|
|
@@ -195,8 +191,7 @@ export declare class SqliteInstallationStore implements InstallationStore {
|
|
|
195
191
|
}
|
|
196
192
|
/**
|
|
197
193
|
* Canonical integer-string form of a Queek `p_id`: the handoff contract
|
|
198
|
-
* types p_ids as strings
|
|
199
|
-
* tolerance stays — a JSON integer would reach here as a JS number, and
|
|
194
|
+
* types p_ids as strings, but the tolerance stays — a JSON integer would reach here as a JS number, and
|
|
200
195
|
* `node:sqlite` binds that number into a TEXT column as `"1021.0"`, which
|
|
201
196
|
* never equals the proxy `kid` (`"1021"`). Non-numeric pids pass through
|
|
202
197
|
* untouched.
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAG1B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;IACrB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,yBAAyB,GAAG,iBAAiB,CAsB7F"}
|
package/dist/store.js
CHANGED
|
@@ -50,19 +50,17 @@ const INSTALLATIONS_TABLE_SQLITE = `
|
|
|
50
50
|
* built-in `node:sqlite` (`DatabaseSync` — synchronous, file-backed, WAL
|
|
51
51
|
* mode).
|
|
52
52
|
*
|
|
53
|
-
* Why not better-sqlite3: its prebuilt binary segfaults on
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* identical synchronous shape.
|
|
53
|
+
* Why not better-sqlite3: its prebuilt binary segfaults on Node 22.12, and
|
|
54
|
+
* building from source would force a C++ toolchain into every environment
|
|
55
|
+
* — dev Macs, CI, and slim alpine images. `node:sqlite` is
|
|
56
|
+
* dependency-free with an identical synchronous shape.
|
|
58
57
|
*
|
|
59
|
-
* `node:sqlite` needs no flag since Node 22.13.0 (
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* swap is contained here, behind `InstallationStore`.
|
|
58
|
+
* `node:sqlite` needs no flag since Node 22.13.0 (an ExperimentalWarning on
|
|
59
|
+
* stderr remains — Stability 1.1). Devs on an older 22 minor set
|
|
60
|
+
* `NODE_OPTIONS=--experimental-sqlite` in their shell. The swap to another
|
|
61
|
+
* driver is contained here, behind `InstallationStore`.
|
|
64
62
|
*
|
|
65
|
-
*
|
|
63
|
+
* Legacy upgrade: databases created by SDK 0.1.x carry a legacy
|
|
66
64
|
* `api_key_enc` column (the handoff no longer delivers that key, so its
|
|
67
65
|
* value is dead — minted tokens replace it; resync restores connectivity).
|
|
68
66
|
* Opening such a database adds the token-cache columns and drops
|
|
@@ -90,21 +88,21 @@ export class SqliteInstallationStore {
|
|
|
90
88
|
// its ciphertext is dropped, never decrypted or re-encrypted.
|
|
91
89
|
this.db.exec(`ALTER TABLE installations DROP COLUMN api_key_enc;`);
|
|
92
90
|
}
|
|
93
|
-
// Schema v2
|
|
91
|
+
// Schema v2: the persisted 409-pending mark. Existing
|
|
94
92
|
// rows backfill to 0 (not pending); fresh tables already carry the
|
|
95
93
|
// column via the CREATE above, so this is a no-op for them.
|
|
96
94
|
const live = new Set(this.db.prepare(`PRAGMA table_info(installations)`).all().map((column) => column.name));
|
|
97
95
|
if (!live.has("pending")) {
|
|
98
96
|
this.db.exec(`ALTER TABLE installations ADD COLUMN pending INTEGER NOT NULL DEFAULT 0;`);
|
|
99
97
|
}
|
|
100
|
-
// Schema v3
|
|
98
|
+
// Schema v3: the installation proxy secret for slot-claim
|
|
101
99
|
// signing. Existing rows backfill to NULL (no proxy secret known
|
|
102
100
|
// until the next install/resync handoff); fresh tables already carry
|
|
103
101
|
// the column via the CREATE above, so this is a no-op for them.
|
|
104
102
|
if (!live.has("proxy_secret_enc")) {
|
|
105
103
|
this.db.exec(`ALTER TABLE installations ADD COLUMN proxy_secret_enc TEXT;`);
|
|
106
104
|
}
|
|
107
|
-
// Schema v4
|
|
105
|
+
// Schema v4: the embed secret + app id that verify dashboard
|
|
108
106
|
// session tokens. Existing rows backfill to NULL until the next
|
|
109
107
|
// install/resync handoff delivers them.
|
|
110
108
|
if (!live.has("embed_secret_enc")) {
|
|
@@ -252,8 +250,7 @@ export class SqliteInstallationStore {
|
|
|
252
250
|
}
|
|
253
251
|
/**
|
|
254
252
|
* Canonical integer-string form of a Queek `p_id`: the handoff contract
|
|
255
|
-
* types p_ids as strings
|
|
256
|
-
* tolerance stays — a JSON integer would reach here as a JS number, and
|
|
253
|
+
* types p_ids as strings, but the tolerance stays — a JSON integer would reach here as a JS number, and
|
|
257
254
|
* `node:sqlite` binds that number into a TEXT column as `"1021.0"`, which
|
|
258
255
|
* never equals the proxy `kid` (`"1021"`). Non-numeric pids pass through
|
|
259
256
|
* untouched.
|
|
@@ -418,17 +415,17 @@ export class PostgresInstallationStore {
|
|
|
418
415
|
webhook_id TEXT PRIMARY KEY,
|
|
419
416
|
seen_at BIGINT NOT NULL
|
|
420
417
|
);
|
|
421
|
-
-- Schema v2
|
|
418
|
+
-- Schema v2: the persisted 409-pending mark.
|
|
422
419
|
-- Fresh tables already carry the column; this migrates v1
|
|
423
420
|
-- databases in place (existing rows backfill to FALSE).
|
|
424
421
|
ALTER TABLE installations
|
|
425
422
|
ADD COLUMN IF NOT EXISTS pending BOOLEAN NOT NULL DEFAULT FALSE;
|
|
426
|
-
-- Schema v3
|
|
423
|
+
-- Schema v3: the installation proxy secret for slot-claim
|
|
427
424
|
-- signing. Existing rows backfill to NULL (unknown until the
|
|
428
425
|
-- next install/resync handoff).
|
|
429
426
|
ALTER TABLE installations
|
|
430
427
|
ADD COLUMN IF NOT EXISTS proxy_secret_enc TEXT;
|
|
431
|
-
-- Schema v4
|
|
428
|
+
-- Schema v4: the embed secret + app id that verify
|
|
432
429
|
-- dashboard session tokens (NULL until the next handoff).
|
|
433
430
|
ALTER TABLE installations
|
|
434
431
|
ADD COLUMN IF NOT EXISTS embed_secret_enc TEXT;
|