@simpleapps-com/augur-server 2.3.1 → 2026.11.1
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/EXPORTS.md +29 -72
- package/README.md +29 -198
- package/dist/actions/agr-info.d.ts +43 -0
- package/dist/actions/agr-info.d.ts.map +1 -0
- package/dist/actions/agr-site.d.ts +37 -0
- package/dist/actions/agr-site.d.ts.map +1 -0
- package/dist/actions/agr-work.d.ts +29 -0
- package/dist/actions/agr-work.d.ts.map +1 -0
- package/dist/actions/avalara.d.ts +38 -0
- package/dist/actions/avalara.d.ts.map +1 -0
- package/dist/actions/basecamp2.d.ts +47 -0
- package/dist/actions/basecamp2.d.ts.map +1 -0
- package/dist/actions/brand-folder.d.ts +38 -0
- package/dist/actions/brand-folder.d.ts.map +1 -0
- package/dist/actions/commerce.d.ts +58 -0
- package/dist/actions/commerce.d.ts.map +1 -0
- package/dist/actions/customers.d.ts +44 -0
- package/dist/actions/customers.d.ts.map +1 -0
- package/dist/actions/favorites.d.ts +20 -0
- package/dist/actions/favorites.d.ts.map +1 -0
- package/dist/actions/gregorovich.d.ts +34 -0
- package/dist/actions/gregorovich.d.ts.map +1 -0
- package/dist/actions/items.d.ts +80 -0
- package/dist/actions/items.d.ts.map +1 -0
- package/dist/actions/joomla.d.ts +59 -0
- package/dist/actions/joomla.d.ts.map +1 -0
- package/dist/actions/legacy.d.ts +45 -0
- package/dist/actions/legacy.d.ts.map +1 -0
- package/dist/actions/logistics.d.ts +40 -0
- package/dist/actions/logistics.d.ts.map +1 -0
- package/dist/actions/orders.d.ts +36 -0
- package/dist/actions/orders.d.ts.map +1 -0
- package/dist/actions/p21-apis.d.ts +33 -0
- package/dist/actions/p21-apis.d.ts.map +1 -0
- package/dist/actions/p21-core.d.ts +46 -0
- package/dist/actions/p21-core.d.ts.map +1 -0
- package/dist/actions/p21-pim.d.ts +36 -0
- package/dist/actions/p21-pim.d.ts.map +1 -0
- package/dist/actions/p21-sism.d.ts +37 -0
- package/dist/actions/p21-sism.d.ts.map +1 -0
- package/dist/actions/payments.d.ts +39 -0
- package/dist/actions/payments.d.ts.map +1 -0
- package/dist/actions/pricing.d.ts +45 -0
- package/dist/actions/pricing.d.ts.map +1 -0
- package/dist/actions/search.d.ts +61 -0
- package/dist/actions/search.d.ts.map +1 -0
- package/dist/actions/shipping.d.ts +56 -0
- package/dist/actions/shipping.d.ts.map +1 -0
- package/dist/actions/site.d.ts +141 -0
- package/dist/actions/site.d.ts.map +1 -0
- package/dist/actions/smarty-streets.d.ts +45 -0
- package/dist/actions/smarty-streets.d.ts.map +1 -0
- package/dist/actions/vmi.d.ts +44 -0
- package/dist/actions/vmi.d.ts.map +1 -0
- package/dist/actions/wishlists.d.ts +28 -0
- package/dist/actions/wishlists.d.ts.map +1 -0
- package/dist/api-handler.d.ts +25 -0
- package/dist/api-handler.d.ts.map +1 -0
- package/dist/api.d.ts +2 -26
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +19 -14
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +10 -12
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +2 -2
- package/dist/cache/redis-client.d.ts +16 -0
- package/dist/cache/redis-client.d.ts.map +1 -0
- package/dist/cache/with-cache.d.ts +18 -0
- package/dist/cache/with-cache.d.ts.map +1 -0
- package/dist/chunk-FWO6Q43T.js +162 -0
- package/dist/chunk-FWO6Q43T.js.map +1 -0
- package/dist/{chunk-HPQQYROJ.js → chunk-NTUPTNOI.js} +40 -7
- package/dist/chunk-NTUPTNOI.js.map +1 -0
- package/dist/{chunk-WOHZDFJF.js → chunk-PFYEMJTQ.js} +212 -642
- package/dist/chunk-PFYEMJTQ.js.map +1 -0
- package/dist/{chunk-KHFEDL47.js → chunk-SXXWBSTX.js} +18 -12
- package/dist/chunk-SXXWBSTX.js.map +1 -0
- package/dist/chunk-TVH5EONP.js +178 -0
- package/dist/chunk-TVH5EONP.js.map +1 -0
- package/dist/{chunk-TQP67TGL.js → chunk-U2BKHRJC.js} +13 -15
- package/dist/chunk-U2BKHRJC.js.map +1 -0
- package/dist/environment.d.ts +10 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/hooks.d.ts +8 -10
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +3 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +16 -125
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/dist/pagination.d.ts +32 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/query-action.d.ts +156 -17
- package/dist/query-action.d.ts.map +1 -0
- package/dist/query-action.js +3 -3
- package/dist/query-options-helper.d.ts +33 -0
- package/dist/query-options-helper.d.ts.map +1 -0
- package/dist/query.js +1 -2
- package/dist/recaptcha.d.ts +6 -0
- package/dist/recaptcha.d.ts.map +1 -0
- package/dist/rules.d.ts +221 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/scoped-client-key.d.ts +9 -0
- package/dist/scoped-client-key.d.ts.map +1 -0
- package/dist/sdk-call.d.ts +66 -0
- package/dist/sdk-call.d.ts.map +1 -0
- package/dist/sdk-client-store.d.ts +250 -0
- package/dist/sdk-client-store.d.ts.map +1 -0
- package/dist/server-actions.d.ts +2 -0
- package/dist/server-actions.d.ts.map +1 -0
- package/dist/server-query-client.d.ts +19 -0
- package/dist/server-query-client.d.ts.map +1 -0
- package/dist/{server-site-registry-CdBfczOj.d.ts → server-site-registry.d.ts} +7 -9
- package/dist/server-site-registry.d.ts.map +1 -0
- package/dist/{site.d.ts → server-site.d.ts} +11 -16
- package/dist/server-site.d.ts.map +1 -0
- package/dist/site-actions-store.d.ts +27 -0
- package/dist/site-actions-store.d.ts.map +1 -0
- package/dist/site.js +10 -10
- package/dist/site.js.map +1 -1
- package/dist/testing.d.ts +9 -12
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +7 -27
- package/dist/testing.js.map +1 -1
- package/dist/utils/batch-fetch.d.ts +7 -0
- package/dist/utils/batch-fetch.d.ts.map +1 -0
- package/llms.txt +71 -50
- package/package.json +34 -20
- package/dist/actions.d.ts +0 -2
- package/dist/chunk-DGUM43GV.js +0 -11
- package/dist/chunk-DGUM43GV.js.map +0 -1
- package/dist/chunk-HPQQYROJ.js.map +0 -1
- package/dist/chunk-KHFEDL47.js.map +0 -1
- package/dist/chunk-TQP67TGL.js.map +0 -1
- package/dist/chunk-WOHZDFJF.js.map +0 -1
- package/dist/chunk-ZUJZDRTP.js +0 -136
- package/dist/chunk-ZUJZDRTP.js.map +0 -1
- package/dist/query.d.ts +0 -31
- package/dist/site-BjSFqufX.d.ts +0 -469
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createQueryOptions,
|
|
3
3
|
createSuspenseQueryOptions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-U2BKHRJC.js";
|
|
5
5
|
import {
|
|
6
6
|
batchFetch,
|
|
7
7
|
cacheGet,
|
|
@@ -21,9 +21,11 @@ import {
|
|
|
21
21
|
unwrap,
|
|
22
22
|
unwrapOr,
|
|
23
23
|
withServerCache
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import
|
|
24
|
+
} from "./chunk-PFYEMJTQ.js";
|
|
25
|
+
import "./chunk-NTUPTNOI.js";
|
|
26
|
+
import {
|
|
27
|
+
recaptchaOk
|
|
28
|
+
} from "./chunk-TVH5EONP.js";
|
|
27
29
|
|
|
28
30
|
// src/server-query-client.ts
|
|
29
31
|
import { cache } from "react";
|
|
@@ -34,7 +36,9 @@ function createServerQueryClient() {
|
|
|
34
36
|
defaultOptions: {
|
|
35
37
|
queries: {
|
|
36
38
|
staleTime: CACHE_CONFIG.STATIC.staleTime,
|
|
37
|
-
|
|
39
|
+
// Infinity = no GC timer. A finite value pins this per-request client
|
|
40
|
+
// (and its whole cache) in memory until the timer fires (#481).
|
|
41
|
+
gcTime: Infinity,
|
|
38
42
|
retry: 0,
|
|
39
43
|
refetchOnMount: false,
|
|
40
44
|
refetchOnWindowFocus: false,
|
|
@@ -49,7 +53,7 @@ var getServerQueryClient = cache(() => createServerQueryClient());
|
|
|
49
53
|
async function verifyRecaptcha(token) {
|
|
50
54
|
try {
|
|
51
55
|
const secretKey = process.env["RECAPTCHA_SECRET_KEY"];
|
|
52
|
-
if (!secretKey) return false;
|
|
56
|
+
if (!secretKey) return recaptchaOk(false, false, void 0);
|
|
53
57
|
const res = await fetch("https://www.google.com/recaptcha/api/siteverify", {
|
|
54
58
|
method: "POST",
|
|
55
59
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -57,10 +61,10 @@ async function verifyRecaptcha(token) {
|
|
|
57
61
|
});
|
|
58
62
|
if (!res.ok) {
|
|
59
63
|
console.error("reCAPTCHA verify failed:", res.status);
|
|
60
|
-
return false;
|
|
64
|
+
return recaptchaOk(true, false, void 0);
|
|
61
65
|
}
|
|
62
66
|
const result = await res.json();
|
|
63
|
-
return result.success
|
|
67
|
+
return recaptchaOk(true, true, result.success);
|
|
64
68
|
} catch (error) {
|
|
65
69
|
console.error("reCAPTCHA verify error:", error);
|
|
66
70
|
return false;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server-query-client.ts","../src/recaptcha.ts"],"sourcesContent":["import { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\n\n/**\n * Creates a server-side query client optimised for prefetching.\n *\n * - No persistence (server-only)\n * -
|
|
1
|
+
{"version":3,"sources":["../src/server-query-client.ts","../src/recaptcha.ts"],"sourcesContent":["import { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\n\n/**\n * Creates a server-side query client optimised for prefetching.\n *\n * - No persistence (server-only)\n * - No GC timers (gcTime: Infinity), so the client is freed with the request\n * - No retries (fail fast on server)\n * - No refetching (server renders are one-shot)\n */\nexport function createServerQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: CACHE_CONFIG.STATIC.staleTime,\n // Infinity = no GC timer. A finite value pins this per-request client\n // (and its whole cache) in memory until the timer fires (#481).\n gcTime: Infinity,\n retry: 0,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n },\n },\n });\n}\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so each request gets its own QueryClient while avoiding the cross-request\n * state leakage that a module-level singleton would cause.\n */\nexport const getServerQueryClient = cache((): QueryClient => createServerQueryClient());\n","import { recaptchaOk } from \"./rules\";\n\n/**\n * Server-side Google reCAPTCHA v3 verification.\n * Used by API routes that accept public form submissions.\n */\nexport async function verifyRecaptcha(token: string): Promise<boolean> {\n try {\n const secretKey = process.env[\"RECAPTCHA_SECRET_KEY\"];\n if (!secretKey) return recaptchaOk(false, false, undefined);\n\n const res = await fetch(\"https://www.google.com/recaptcha/api/siteverify\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({ secret: secretKey, response: token }),\n });\n if (!res.ok) {\n console.error(\"reCAPTCHA verify failed:\", res.status);\n return recaptchaOk(true, false, undefined);\n }\n const result = (await res.json()) as { success?: boolean };\n return recaptchaOk(true, true, result.success);\n } catch (error) {\n console.error(\"reCAPTCHA verify error:\", error);\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAUtB,SAAS,0BAAuC;AACrD,SAAO,IAAI,YAAY;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW,aAAa,OAAO;AAAA;AAAA;AAAA,QAG/B,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,gBAAgB;AAAA,QAChB,sBAAsB;AAAA,QACtB,oBAAoB;AAAA,MACtB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AASO,IAAM,uBAAuB,MAAM,MAAmB,wBAAwB,CAAC;;;AC9BtF,eAAsB,gBAAgB,OAAiC;AACrE,MAAI;AACF,UAAM,YAAY,QAAQ,IAAI,sBAAsB;AACpD,QAAI,CAAC,UAAW,QAAO,YAAY,OAAO,OAAO,MAAS;AAE1D,UAAM,MAAM,MAAM,MAAM,mDAAmD;AAAA,MACzE,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,oCAAoC;AAAA,MAC/D,MAAM,IAAI,gBAAgB,EAAE,QAAQ,WAAW,UAAU,MAAM,CAAC;AAAA,IAClE,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,cAAQ,MAAM,4BAA4B,IAAI,MAAM;AACpD,aAAO,YAAY,MAAM,OAAO,MAAS;AAAA,IAC3C;AACA,UAAM,SAAU,MAAM,IAAI,KAAK;AAC/B,WAAO,YAAY,MAAM,MAAM,OAAO,OAAO;AAAA,EAC/C,SAAS,OAAO;AACd,YAAQ,MAAM,2BAA2B,KAAK;AAC9C,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standardized paginated response shape.
|
|
3
|
+
* Works with any factory method — compose with `paginateOffset()`.
|
|
4
|
+
*/
|
|
5
|
+
export interface PaginatedResult<T> {
|
|
6
|
+
data: T[];
|
|
7
|
+
total: number;
|
|
8
|
+
nextCursor?: number;
|
|
9
|
+
hasMore: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a list of items with offset-based pagination metadata.
|
|
13
|
+
*
|
|
14
|
+
* Use this to standardize pagination responses from any factory method.
|
|
15
|
+
* Compatible with React Query's infinite query pattern (`getNextPageParam`).
|
|
16
|
+
*
|
|
17
|
+
* @param items - The items returned from the current page
|
|
18
|
+
* @param pageParam - The current page number (0-based)
|
|
19
|
+
* @param limit - The page size
|
|
20
|
+
* @param total - Optional total count of items (from API response)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const result = await actions.items.getCategoryItems(uid, {
|
|
25
|
+
* ...filters, offset: page * 24, limit: 24,
|
|
26
|
+
* });
|
|
27
|
+
* return paginateOffset(result.items, page, 24, result.total);
|
|
28
|
+
* // { data: [...], total: 150, nextCursor: 1, hasMore: true }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function paginateOffset<T>(items: T[], pageParam: number, limit: number, total?: number): PaginatedResult<T>;
|
|
32
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACb,eAAe,CAAC,CAAC,CAAC,CASpB"}
|
package/dist/query-action.d.ts
CHANGED
|
@@ -1,21 +1,69 @@
|
|
|
1
|
+
import { type SessionCredentials, type ApprovedMethodPath } from "./sdk-client-store";
|
|
2
|
+
import { unwrapBaseResponse } from "@simpleapps-com/augur-core";
|
|
1
3
|
/**
|
|
2
4
|
* Resolve session credentials from the Auth.js JWT cookie.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* Trust-boundary mint point: this is the only function in the package that
|
|
7
|
+
* produces {@link SessionCredentials} values. Bytes from a cookie become
|
|
8
|
+
* typed, paired credentials here and only here. No other production code
|
|
9
|
+
* constructs the branded pair, so a `SessionCredentials` that came through
|
|
10
|
+
* this mint is JWT-validated and internally consistent. The brand is not
|
|
11
|
+
* enforced by the compiler: an `as SessionCredentials` cast compiles (tests
|
|
12
|
+
* do it), so audit casts (see "Brand strength" below).
|
|
13
|
+
*
|
|
14
|
+
* Returns null when:
|
|
15
|
+
* - no AUTH_SECRET is configured
|
|
16
|
+
* - next-auth/jwt, next/headers, or jose cannot be loaded
|
|
17
|
+
* - no session cookie is present
|
|
18
|
+
* - the JWT decode fails or returns null
|
|
19
|
+
* - the decoded payload is missing `targetSiteId` or `token`, or either is
|
|
20
|
+
* not a non-empty string (refuse to mint partial credentials)
|
|
21
|
+
* - `targetSiteId` fails augur-api's `isSiteId` (`[a-z0-9_-]+`): siteIds are
|
|
22
|
+
* lowercase by convention, and the scoped-client key's injectivity proof
|
|
23
|
+
* (`scoped-client-key.ts`) needs a NUL-free siteId
|
|
24
|
+
* - the bearer token's `client_id` siteId portion does not match
|
|
25
|
+
* `targetSiteId` (defense-in-depth: refuses internally inconsistent sessions
|
|
26
|
+
* before they reach the augur-api authority check)
|
|
27
|
+
*
|
|
28
|
+
* ## Verified preconditions for `result = some c`
|
|
29
|
+
*
|
|
30
|
+
* AUTH_SECRET configured
|
|
31
|
+
* next-auth/jwt, next/headers, jose all loadable
|
|
32
|
+
* session cookie present and decodable with the secret
|
|
33
|
+
* typeof jwt.targetSiteId === "string" ∧ isSiteId(jwt.targetSiteId) // implies non-empty
|
|
34
|
+
* typeof jwt.token === "string" ∧ jwt.token.length > 0
|
|
35
|
+
* bearerClientSiteId(jwt.token) = some jwt.targetSiteId
|
|
36
|
+
*
|
|
37
|
+
* Lean equivalent: each clause becomes a `requires` on the function;
|
|
38
|
+
* `result = none` is the disjunction of any failing.
|
|
39
|
+
* F* equivalent: refinement on the option payload covering the
|
|
40
|
+
* conjunction of these clauses.
|
|
41
|
+
*
|
|
42
|
+
* The bearer cross-check (`bearerClientSiteId(jwt.token) = some jwt.targetSiteId`)
|
|
43
|
+
* is the substantive runtime invariant: it refuses sessions where the bearer's
|
|
44
|
+
* encoded `client_id` siteId disagrees with the session's targetSiteId,
|
|
45
|
+
* catching internal-inconsistency bugs before the call reaches augur-api.
|
|
46
|
+
*
|
|
47
|
+
* ## By construction (not independently verified)
|
|
48
|
+
*
|
|
49
|
+
* c.siteId === jwt.targetSiteId (assigned, not checked)
|
|
50
|
+
* c.token === jwt.token (assigned, not checked)
|
|
51
|
+
*
|
|
52
|
+
* ## Brand strength
|
|
53
|
+
*
|
|
54
|
+
* `SessionCredentials` is a TS-level brand: there is no runtime tag on the
|
|
55
|
+
* value. `value as SessionCredentials` casts compile, so the brand is a
|
|
56
|
+
* code-review signal (audit `as SessionCredentials` usages — there should be
|
|
57
|
+
* exactly one, in this function), not a hard type-system gate.
|
|
5
58
|
*/
|
|
6
|
-
declare function getSessionCredentials(): Promise<
|
|
7
|
-
siteId: string;
|
|
8
|
-
token: string;
|
|
9
|
-
} | null>;
|
|
59
|
+
declare function getSessionCredentials(): Promise<SessionCredentials | null>;
|
|
10
60
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
61
|
+
* Resolve a dot-separated method path on an object, returning the leaf function.
|
|
62
|
+
*
|
|
63
|
+
* Demands {@link ApprovedMethodPath} so callers must have run the path through
|
|
64
|
+
* `parseMethodPath` first — passing an unvalidated string is a compile error.
|
|
15
65
|
*/
|
|
16
|
-
declare function
|
|
17
|
-
/** Resolve a dot-separated method path on an object, returning the leaf function. */
|
|
18
|
-
declare function resolveMethod(client: unknown, methodPath: string): (...a: unknown[]) => Promise<unknown>;
|
|
66
|
+
declare function resolveMethod(client: unknown, methodPath: ApprovedMethodPath): (...a: unknown[]) => Promise<unknown>;
|
|
19
67
|
/**
|
|
20
68
|
* Generic server action that routes any SDK method call through the raw
|
|
21
69
|
* SDK client with optional Redis caching. Used internally by
|
|
@@ -34,12 +82,103 @@ declare function resolveMethod(client: unknown, methodPath: string): (...a: unkn
|
|
|
34
82
|
* SDK responses wrapped in BaseResponse are automatically unwrapped --
|
|
35
83
|
* consumers receive `T` instead of `{ data: T, status, message }`.
|
|
36
84
|
*
|
|
85
|
+
* This is the chokepoint: every B2B site without a client-side SDK
|
|
86
|
+
* routes EVERY data access through this one function. The invariants
|
|
87
|
+
* below are load-bearing across every site, every request, every user.
|
|
88
|
+
*
|
|
89
|
+
* ## Preconditions (enforced at runtime via thrown Error)
|
|
90
|
+
*
|
|
91
|
+
* parseMethodPath(methodPath) ≠ null
|
|
92
|
+
* resolveClient().client ≠ null
|
|
93
|
+
*
|
|
94
|
+
* First clause: methodPath is a non-empty string AND — if an allowlist
|
|
95
|
+
* has been registered via `registerAllowedMethodPaths` — methodPath is
|
|
96
|
+
* in the allowlist. Assumes the site opted into surface restriction
|
|
97
|
+
* when narrower-than-augur-api authority is desired; otherwise any
|
|
98
|
+
* non-empty string passes (transparent forwarder default).
|
|
99
|
+
*
|
|
100
|
+
* Second clause: createServerSite() ran during bootstrap OR
|
|
101
|
+
* AUGUR_SITE_ID + AUGUR_JWT env vars are set so the registry can
|
|
102
|
+
* auto-init. Assumes the caller has bootstrapped one of the two paths.
|
|
103
|
+
*
|
|
104
|
+
* Lean equivalent: `requires path : ApprovedMethodPath ∧ client : SDKClient`.
|
|
105
|
+
*
|
|
106
|
+
* ## Cross-tenant cache-prefix invariant (load-bearing)
|
|
107
|
+
*
|
|
108
|
+
* resolution.kind = "scoped" ⟹ cachePrefix = `${resolution.credentials.siteId}:`
|
|
109
|
+
*
|
|
110
|
+
* On the scoped path the cache prefix is derived structurally from the
|
|
111
|
+
* same `SessionCredentials` value that minted the scoped client — they
|
|
112
|
+
* cannot be sourced separately. This makes "siteId from session A
|
|
113
|
+
* combined with token from session B" or "siteId X with cache prefix Y"
|
|
114
|
+
* unrepresentable here. Assumes `getSessionCredentials` performed the
|
|
115
|
+
* bearer/session siteId cross-check at mint time; see the brand-strength
|
|
116
|
+
* caveat on `SessionCredentials`.
|
|
117
|
+
*
|
|
118
|
+
* A regression here would silently leak cached data across tenants.
|
|
119
|
+
* The structural derivation is the only thing standing between the
|
|
120
|
+
* request and that leak — do not reintroduce a separate `cachePrefix`
|
|
121
|
+
* parameter or compute it from anything other than `resolution.credentials`.
|
|
122
|
+
*
|
|
123
|
+
* ### Sibling assumption — bearer is NOT in the cache key
|
|
124
|
+
*
|
|
125
|
+
* The cross-tenant invariant covers cross-SITE leaks. It does NOT cover
|
|
126
|
+
* intra-site cross-USER leaks: the cache key is `(siteId, methodPath, args)`
|
|
127
|
+
* and the bearer token is intentionally absent. Two users with different
|
|
128
|
+
* bearers on the same site share cached data for cacheable namespaces.
|
|
129
|
+
*
|
|
130
|
+
* This is a deliberate design choice. The assumption is:
|
|
131
|
+
*
|
|
132
|
+
* ∀ namespace ∉ NO_CACHE_PATHS, ∀ siteId, ∀ args.
|
|
133
|
+
* augur-api(bearer_A, siteId, args) = augur-api(bearer_B, siteId, args)
|
|
134
|
+
*
|
|
135
|
+
* i.e. for cacheable namespaces, augur-api's response is bearer-independent
|
|
136
|
+
* within a site. augur-api remains the auth authority; `NO_CACHE_PATHS`
|
|
137
|
+
* (commerce.*, payments.*) is the carve-out for namespaces whose responses
|
|
138
|
+
* ARE bearer-coupled. If a future namespace produces bearer-dependent
|
|
139
|
+
* responses (e.g. user-specific permissions affecting query results), it
|
|
140
|
+
* MUST be added to `NO_CACHE_PATHS` or the bearer MUST become part of the
|
|
141
|
+
* cache key — otherwise this assumption silently produces a permission leak.
|
|
142
|
+
*
|
|
143
|
+
* ## No-edge-cache defense-in-depth (load-bearing)
|
|
144
|
+
*
|
|
145
|
+
* ∀ a ∈ safeArgs. methodPath ∈ NO_CACHE_PATHS ⟹ "edgeCache" ∉ keys(a)
|
|
146
|
+
*
|
|
147
|
+
* `stripEdgeCacheForNoCachePaths` removes the `edgeCache` key from every
|
|
148
|
+
* first-level object arg when methodPath belongs to a no-cache namespace
|
|
149
|
+
* (currently `commerce.*`, `payments.*`). The augur-api SDK transforms
|
|
150
|
+
* `edgeCache` into a Cloudflare `cacheSiteId{N}` query param; removing
|
|
151
|
+
* it here guarantees no CDN edge-caching of identity-bound responses
|
|
152
|
+
* even if a caller passed one explicitly or a legacy factory injected
|
|
153
|
+
* one. Assumes `NO_CACHE_PATHS` enumerates every namespace whose
|
|
154
|
+
* responses must not cross identity boundaries.
|
|
155
|
+
*
|
|
156
|
+
* ## Postcondition — BaseResponse pass-through (exactly-once unwrap)
|
|
157
|
+
*
|
|
158
|
+
* result = unwrapBaseResponse(raw)
|
|
159
|
+
* = raw.data when raw is { data, status, message }
|
|
160
|
+
* = raw otherwise
|
|
161
|
+
*
|
|
162
|
+
* Consumers receive `T` directly when the SDK returns
|
|
163
|
+
* `{ data: T, status, message }`, and the original value otherwise.
|
|
164
|
+
* Assumes upstream cache wrappers do NOT themselves unwrap — they
|
|
165
|
+
* return whatever the SDK returned, so unwrapping happens exactly
|
|
166
|
+
* once, here. Double-unwrap (caller + queryAction) would silently
|
|
167
|
+
* strip a layer of legitimate `{data, status, message}` user data
|
|
168
|
+
* when that shape happens to round-trip through the API.
|
|
169
|
+
*
|
|
170
|
+
* ## Effects
|
|
171
|
+
*
|
|
172
|
+
* @mutates Redis (write-through on read methods when a wrapper is registered)
|
|
173
|
+
* @io augur-api SDK (network request)
|
|
174
|
+
* @throws Error when the allowlist gate fails or no client is initialised
|
|
175
|
+
*
|
|
37
176
|
* @param methodPath Dot-separated SDK method path (e.g. "items.invMast.doc.get")
|
|
38
177
|
* @param args Arguments to pass to the resolved method
|
|
39
178
|
* @returns The unwrapped result from the SDK method (possibly from Redis cache)
|
|
40
179
|
*/
|
|
41
|
-
declare function queryAction(methodPath: string, ...args: unknown[]): Promise<unknown>;
|
|
180
|
+
export declare function queryAction(methodPath: string, ...args: unknown[]): Promise<unknown>;
|
|
42
181
|
/** Reset lazy-loaded imports. Used in tests only. @internal */
|
|
43
|
-
declare function resetSessionImports(): void;
|
|
44
|
-
|
|
45
|
-
|
|
182
|
+
export declare function resetSessionImports(): void;
|
|
183
|
+
export { unwrapBaseResponse, getSessionCredentials, resolveMethod };
|
|
184
|
+
//# sourceMappingURL=query-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-action.d.ts","sourceRoot":"","sources":["../src/query-action.ts"],"names":[],"mappings":"AAUA,OAAO,EAOL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAGxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AA+FpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,iBAAe,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAyBzE;AA2DD;;;;;GAKG;AACH,iBAAS,aAAa,CACpB,MAAM,EAAE,OAAO,EACf,UAAU,EAAE,kBAAkB,GAC7B,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAkBvC;AAqCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgHG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CA4C1F;AAED,+DAA+D;AAC/D,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C;AAED,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/query-action.js
CHANGED
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
resetSessionImports,
|
|
6
6
|
resolveMethod,
|
|
7
7
|
unwrapBaseResponse
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-FWO6Q43T.js";
|
|
9
|
+
import "./chunk-NTUPTNOI.js";
|
|
10
|
+
import "./chunk-TVH5EONP.js";
|
|
11
11
|
export {
|
|
12
12
|
getSessionCredentials,
|
|
13
13
|
queryAction,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { UseQueryOptions, UseSuspenseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
export interface QueryOptionsConfig<TParams, TData> {
|
|
3
|
+
/** Base query key (e.g., "customer-orders") */
|
|
4
|
+
baseKey: string;
|
|
5
|
+
/** Parameters object */
|
|
6
|
+
params: TParams;
|
|
7
|
+
/** Function that returns the data */
|
|
8
|
+
queryFn: (params: TParams) => Promise<TData>;
|
|
9
|
+
/** Function to determine if query should be enabled */
|
|
10
|
+
enabledFn?: (params: TParams) => boolean;
|
|
11
|
+
/** Custom stale time in milliseconds (default: SEMI_STATIC) */
|
|
12
|
+
staleTime?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Custom garbage collection time in milliseconds (default: SEMI_STATIC).
|
|
15
|
+
* Browser only: on the server the returned gcTime is always `Infinity`
|
|
16
|
+
* (no GC timer), so the per-request cache is freed with the request (#481).
|
|
17
|
+
*/
|
|
18
|
+
gcTime?: number;
|
|
19
|
+
/** Key to exclude from query key generation */
|
|
20
|
+
excludeFromKey?: keyof TParams;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates useQuery options with consistent key generation.
|
|
24
|
+
* Filters out undefined/null/empty params from the query key.
|
|
25
|
+
*/
|
|
26
|
+
export declare const createQueryOptions: <TParams extends Record<string, unknown>, TData>({ baseKey, params, queryFn, enabledFn, staleTime, gcTime, excludeFromKey, }: QueryOptionsConfig<TParams, TData>) => UseQueryOptions<TData>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates useSuspenseQuery options with consistent key generation.
|
|
29
|
+
* Same as createQueryOptions but without enabledFn (suspense queries
|
|
30
|
+
* cannot be disabled).
|
|
31
|
+
*/
|
|
32
|
+
export declare const createSuspenseQueryOptions: <TParams extends Record<string, unknown>, TData>({ baseKey, params, queryFn, staleTime, gcTime, excludeFromKey, }: Omit<QueryOptionsConfig<TParams, TData>, "enabledFn">) => UseSuspenseQueryOptions<TData>;
|
|
33
|
+
//# sourceMappingURL=query-options-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-options-helper.d.ts","sourceRoot":"","sources":["../src/query-options-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAItF,MAAM,WAAW,kBAAkB,CAAC,OAAO,EAAE,KAAK;IAChD,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,qCAAqC;IACrC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7C,uDAAuD;IACvD,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;IACzC,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC;CAChC;AAsBD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,6EAQhF,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAG,eAAe,CAAC,KAAK,CAQ5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,kEAOxF,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,KAAG,uBAAuB,CAAC,KAAK,CAOvF,CAAC"}
|
package/dist/query.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recaptcha.d.ts","sourceRoot":"","sources":["../src/recaptcha.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBrE"}
|
package/dist/rules.d.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The siteId of a bearer's client_id claim (`<n>|<siteId>`): the text after the first "|", when
|
|
3
|
+
* there is one and it is non-empty. The prefix is not checked.
|
|
4
|
+
*
|
|
5
|
+
* @ensures exactly the model's ClientIdSiteId on a string claim
|
|
6
|
+
*/
|
|
7
|
+
export declare function clientIdSiteIdOf(clientId: string): string | null;
|
|
8
|
+
/** A session's siteId and bearer token, as minted, or refused. */
|
|
9
|
+
export type Mint = {
|
|
10
|
+
kind: "minted";
|
|
11
|
+
siteId: string;
|
|
12
|
+
token: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "refused";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* getSessionCredentials' mint, once the secret and the decoded session are in hand: a valid
|
|
18
|
+
* siteId (augur-api's `isSiteId`, checked by the caller), a non-empty token, and the bearer's
|
|
19
|
+
* client_id siteId (`""` for none: `clientIdSiteIdOf` never gives `""`) equal to it.
|
|
20
|
+
*
|
|
21
|
+
* @ensures exactly the model's MintCredentials with a secret and a decoded session
|
|
22
|
+
*/
|
|
23
|
+
export declare function mintedCredentials(siteIdOk: boolean, targetSiteId: string, token: string, bearerSiteId: string): Mint;
|
|
24
|
+
/**
|
|
25
|
+
* Whether there is another page: from the total when one is given, else a full page.
|
|
26
|
+
*
|
|
27
|
+
* @ensures exactly the model's HasMore
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasMoreOf(page: number, limit: number, total: number | undefined, itemCount: number): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The next page's cursor: page + 1 while there is more.
|
|
32
|
+
*
|
|
33
|
+
* @ensures exactly the model's NextCursor given HasMore
|
|
34
|
+
*/
|
|
35
|
+
export declare function nextCursorOf(hasMore: boolean, page: number): number | undefined;
|
|
36
|
+
/** The deployment environment. */
|
|
37
|
+
export type Env = "development" | "staging" | "production";
|
|
38
|
+
/**
|
|
39
|
+
* DEPLOYMENT_ENV first; then the server's NODE_ENV; then the browser's host (substring). A missing
|
|
40
|
+
* variable is "".
|
|
41
|
+
*
|
|
42
|
+
* @ensures exactly the model's EnvOf
|
|
43
|
+
*/
|
|
44
|
+
export declare function envOf(deploymentEnv: string, isServer: boolean, nodeEnv: string, host: string): Env;
|
|
45
|
+
/**
|
|
46
|
+
* On the server: development only for NODE_ENV "development".
|
|
47
|
+
*
|
|
48
|
+
* @ensures result = development ⟺ nodeEnv = "development", else production
|
|
49
|
+
*/
|
|
50
|
+
export declare function serverEnvOf(nodeEnv: string): Env;
|
|
51
|
+
/**
|
|
52
|
+
* In the browser: localhost or 127.0.0.1 anywhere in the host is development, agr-hosting.dev
|
|
53
|
+
* staging, anything else production.
|
|
54
|
+
*
|
|
55
|
+
* @ensures exactly the model's host rule
|
|
56
|
+
*/
|
|
57
|
+
export declare function hostEnvOf(host: string): Env;
|
|
58
|
+
/** The API route's outcome for a request. */
|
|
59
|
+
export type ApiOutcome = "forbidden" | "bad-json" | "bad-method-path" | "bad-args" | "run";
|
|
60
|
+
/**
|
|
61
|
+
* A present, non-empty Sec-Fetch-Site other than same-origin is refused (a missing one, `""`
|
|
62
|
+
* from the caller, passes).
|
|
63
|
+
*
|
|
64
|
+
* @ensures result ⟺ fetchSite ∉ {"", "same-origin"}
|
|
65
|
+
*/
|
|
66
|
+
export declare function isCrossOrigin(fetchSite: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The body's outcome: JSON, then a non-empty methodPath string, then an args array.
|
|
69
|
+
*
|
|
70
|
+
* @ensures exactly the model's ApiOutcomeOf past the origin check
|
|
71
|
+
*/
|
|
72
|
+
export declare function bodyOutcomeOf(jsonOk: boolean, methodPathOk: boolean, argsIsArray: boolean): ApiOutcome;
|
|
73
|
+
/**
|
|
74
|
+
* An outcome's HTTP status: 403, 400 for a bad body, 200 to run.
|
|
75
|
+
*
|
|
76
|
+
* @ensures exactly the model's ApiStatus
|
|
77
|
+
*/
|
|
78
|
+
export declare function apiStatusOf(o: ApiOutcome): number;
|
|
79
|
+
/**
|
|
80
|
+
* A refusal's response text ("" to run).
|
|
81
|
+
*
|
|
82
|
+
* @ensures each refusal has its fixed text
|
|
83
|
+
*/
|
|
84
|
+
export declare function apiMessageOf(o: ApiOutcome): string;
|
|
85
|
+
/**
|
|
86
|
+
* The Redis TTL for a cache tier: none for staleTime 0, the long TTL from an hour up, else the
|
|
87
|
+
* standard one.
|
|
88
|
+
*
|
|
89
|
+
* @ensures exactly the model's TtlFor
|
|
90
|
+
*/
|
|
91
|
+
export declare function ttlFor(staleTimeMs: number, redisTtl: number, longRedisTtl: number): number | null;
|
|
92
|
+
/** The Redis circuit breaker's state: consecutive failures, and when it closes (0 = closed). */
|
|
93
|
+
export interface Circuit {
|
|
94
|
+
failures: number;
|
|
95
|
+
openUntil: number;
|
|
96
|
+
}
|
|
97
|
+
/** The circuit's answer at a time: whether it is open, and its state after the check. */
|
|
98
|
+
export interface CircuitAnswer {
|
|
99
|
+
open: boolean;
|
|
100
|
+
next: Circuit;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* isCircuitOpen at `now`: closed at openUntil 0; past it, reset and closed; else open.
|
|
104
|
+
*
|
|
105
|
+
* @ensures exactly the model's CircuitCheck
|
|
106
|
+
*/
|
|
107
|
+
export declare function circuitCheck(c: Circuit, now: number): CircuitAnswer;
|
|
108
|
+
/**
|
|
109
|
+
* Whether a failure count opens the circuit: five in a row.
|
|
110
|
+
*
|
|
111
|
+
* @ensures result ⟺ failures ≥ 5
|
|
112
|
+
*/
|
|
113
|
+
export declare function opensAt(failures: number): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* A failure counts; from the threshold on the circuit opens for a minute from now.
|
|
116
|
+
*
|
|
117
|
+
* @ensures exactly the model's RecordFailure
|
|
118
|
+
*/
|
|
119
|
+
export declare function recordFailureOf(c: Circuit, now: number): Circuit;
|
|
120
|
+
/**
|
|
121
|
+
* A success clears the failure count and leaves openUntil.
|
|
122
|
+
*
|
|
123
|
+
* @ensures exactly the model's RecordSuccess
|
|
124
|
+
*/
|
|
125
|
+
export declare function recordSuccessOf(c: Circuit): Circuit;
|
|
126
|
+
/**
|
|
127
|
+
* authorize's verified flag: exactly the text "true".
|
|
128
|
+
*
|
|
129
|
+
* @ensures result ⟺ s = "true"
|
|
130
|
+
*/
|
|
131
|
+
export declare function verifiedFlag(s: string): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* reCAPTCHA passes only with a secret, an ok response and the reply's optional `success` exactly
|
|
134
|
+
* true (the score is not read).
|
|
135
|
+
*
|
|
136
|
+
* @ensures exactly the model's RecaptchaOk, success read as `=== true`
|
|
137
|
+
*/
|
|
138
|
+
export declare function recaptchaOk(hasSecret: boolean, httpOk: boolean, success: boolean | undefined): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* A customer id is used only above 0; anything else (NaN included, at the caller) is 0.
|
|
141
|
+
*
|
|
142
|
+
* @ensures result = n when n > 0, else 0
|
|
143
|
+
*/
|
|
144
|
+
export declare function positiveOrZero(n: number): number;
|
|
145
|
+
/**
|
|
146
|
+
* The category page size: 24 when none (or 0) is given.
|
|
147
|
+
*
|
|
148
|
+
* @ensures exactly the model's ItemsLimit, a missing limit as 0
|
|
149
|
+
*/
|
|
150
|
+
export declare function itemsLimitOf(limit: number | undefined): number;
|
|
151
|
+
/** How queryAction resolves its client. */
|
|
152
|
+
export type Resolution = "scoped" | "global" | "uninit";
|
|
153
|
+
/**
|
|
154
|
+
* resolveClient: scoped when credentials minted and a scoped client was made; else the global
|
|
155
|
+
* client when one is registered (also for a valid session without a factory); else none.
|
|
156
|
+
*
|
|
157
|
+
* @ensures exactly the model's ResolveClient
|
|
158
|
+
*/
|
|
159
|
+
export declare function resolutionOf(minted: boolean, scopedMade: boolean, hasGlobal: boolean): Resolution;
|
|
160
|
+
/** The scoped-client slot's decision. */
|
|
161
|
+
export type SlotDecision = "hit" | "mint" | "no-client";
|
|
162
|
+
/**
|
|
163
|
+
* getOrCreateScopedClient's single slot: a hit when it holds this key; else a new client when a
|
|
164
|
+
* factory is registered; else none. An empty slot is "" at the caller, which no key equals (a
|
|
165
|
+
* key holds a NUL).
|
|
166
|
+
*
|
|
167
|
+
* @ensures exactly the model's SlotDecisionOf
|
|
168
|
+
*/
|
|
169
|
+
export declare function slotDecisionOf(slotKey: string, key: string, hasFactory: boolean): SlotDecision;
|
|
170
|
+
/**
|
|
171
|
+
* parseMethodPath: a non-empty path, in the allowlist when one is registered (permissive by
|
|
172
|
+
* default); `listed` is the caller's Set lookup.
|
|
173
|
+
*
|
|
174
|
+
* @ensures exactly the model's ApprovePath
|
|
175
|
+
*/
|
|
176
|
+
export declare function approvePath(path: string, hasAllowlist: boolean, listed: boolean): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* queryAction caches a call only through a wrapper, and only for a read leaf (augur-core's
|
|
179
|
+
* `isReadMethod`, checked by the caller).
|
|
180
|
+
*
|
|
181
|
+
* @ensures exactly the model's UsesCache
|
|
182
|
+
*/
|
|
183
|
+
export declare function usesCache(hasWrapper: boolean, isRead: boolean): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* The scoped cache prefix: the session's siteId and ":".
|
|
186
|
+
*
|
|
187
|
+
* @ensures exactly the model's ScopedPrefix
|
|
188
|
+
*/
|
|
189
|
+
export declare function scopedPrefix(siteId: string): string;
|
|
190
|
+
/**
|
|
191
|
+
* withServerCache caches when the TTL is not 0 (missing or NaN is 0 at the caller; a negative
|
|
192
|
+
* TTL caches too).
|
|
193
|
+
*
|
|
194
|
+
* @ensures exactly the model's ShouldCache
|
|
195
|
+
*/
|
|
196
|
+
export declare function shouldCache(ttl: number): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* getInvMastDoc's positional uid: kept above 0, else none.
|
|
199
|
+
*
|
|
200
|
+
* @ensures result = uid when uid > 0, else undefined
|
|
201
|
+
*/
|
|
202
|
+
export declare function docUidOf(uid: number): number | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* The positional itemId is used only at uid 0 and when non-empty ("" for none, at the caller).
|
|
205
|
+
*
|
|
206
|
+
* @ensures result ⟺ uid = 0 ∧ itemId ≠ ""
|
|
207
|
+
*/
|
|
208
|
+
export declare function takesItemId(uid: number, itemId: string): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* A doc call needs a uid (truthy at the caller) or a non-empty itemId.
|
|
211
|
+
*
|
|
212
|
+
* @ensures result ⟺ uidSet ∨ itemId ≠ ""
|
|
213
|
+
*/
|
|
214
|
+
export declare function hasDocKey(uidSet: boolean, itemId: string): boolean;
|
|
215
|
+
/**
|
|
216
|
+
* The configured payments mode, "live" by default.
|
|
217
|
+
*
|
|
218
|
+
* @ensures result = configured ?? "live"
|
|
219
|
+
*/
|
|
220
|
+
export declare function configuredModeOf(configured: string | undefined): string;
|
|
221
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAShE;AAED,kEAAkE;AAClE,MAAM,MAAM,IAAI,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,C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teId with no NUL character
|
|
3
|
+
* (`getSessionCredentials` enforces `isSiteId`); with that, distinct pairs give distinct keys.
|
|
4
|
+
* A siteId with a NUL throws instead of returning a key that could collide.
|
|
5
|
+
*
|
|
6
|
+
* @throws TypeError when `siteId` contains a NUL character
|
|
7
|
+
*/
|
|
8
|
+
export declare function scopedClientKey(siteId: string, token: string): string;
|
|
9
|
+
//# sourceMappingURL=scoped-client-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-client-key.d.ts","sourceRoot":"","sources":["../src/scoped-client-key.ts"],"names":[],"mappings":"AAgCA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMrE"}
|