@simpleapps-com/augur-server 2026.11.11 → 2026.11.12

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.
Files changed (50) hide show
  1. package/EXPORTS.md +2 -2
  2. package/README.md +37 -7
  3. package/dist/api-handler.d.ts.map +1 -1
  4. package/dist/api.js +7 -5
  5. package/dist/api.js.map +1 -1
  6. package/dist/auth.d.ts +38 -4
  7. package/dist/auth.d.ts.map +1 -1
  8. package/dist/auth.js +4 -3
  9. package/dist/{chunk-5X2QWOTO.js → chunk-5DBFTSWY.js} +4 -11
  10. package/dist/chunk-5DBFTSWY.js.map +1 -0
  11. package/dist/{chunk-4CU4UNBH.js → chunk-GKT4MAWC.js} +4 -4
  12. package/dist/{chunk-BG4G5QUQ.js → chunk-HGJF667G.js} +8 -1
  13. package/dist/{chunk-BG4G5QUQ.js.map → chunk-HGJF667G.js.map} +1 -1
  14. package/dist/chunk-ILXNFJVM.js +86 -0
  15. package/dist/chunk-ILXNFJVM.js.map +1 -0
  16. package/dist/{chunk-JIYVQWXK.js → chunk-IM7FDRER.js} +1 -1
  17. package/dist/chunk-IM7FDRER.js.map +1 -0
  18. package/dist/chunk-M35O5JDZ.js +257 -0
  19. package/dist/chunk-M35O5JDZ.js.map +1 -0
  20. package/dist/{chunk-OTZUEADV.js → chunk-Y54RGILF.js} +35 -3
  21. package/dist/chunk-Y54RGILF.js.map +1 -0
  22. package/dist/hooks.js +4 -3
  23. package/dist/hooks.js.map +1 -1
  24. package/dist/index.js +6 -5
  25. package/dist/index.js.map +1 -1
  26. package/dist/query-action.d.ts +2 -8
  27. package/dist/query-action.d.ts.map +1 -1
  28. package/dist/query-action.js +4 -3
  29. package/dist/recaptcha.d.ts.map +1 -1
  30. package/dist/rules.d.ts +2 -14
  31. package/dist/rules.d.ts.map +1 -1
  32. package/dist/sdk-client-store.d.ts +4 -3
  33. package/dist/sdk-client-store.d.ts.map +1 -1
  34. package/dist/server-site.d.ts +6 -8
  35. package/dist/server-site.d.ts.map +1 -1
  36. package/dist/session-rules.d.ts +118 -0
  37. package/dist/session-rules.d.ts.map +1 -0
  38. package/dist/site.js +14 -9
  39. package/dist/site.js.map +1 -1
  40. package/dist/sitemap.js +2 -2
  41. package/dist/testing.js +4 -4
  42. package/llms.txt +4 -2
  43. package/next-auth.d.ts +2 -2
  44. package/package.json +7 -6
  45. package/dist/chunk-5X2QWOTO.js.map +0 -1
  46. package/dist/chunk-AEFUT3MB.js +0 -183
  47. package/dist/chunk-AEFUT3MB.js.map +0 -1
  48. package/dist/chunk-JIYVQWXK.js.map +0 -1
  49. package/dist/chunk-OTZUEADV.js.map +0 -1
  50. /package/dist/{chunk-4CU4UNBH.js.map → chunk-GKT4MAWC.js.map} +0 -0
package/dist/rules.d.ts CHANGED
@@ -142,12 +142,6 @@ export declare function recordFailureOf(c: Circuit, now: Millis): Circuit;
142
142
  * @ensures exactly the model's RecordSuccess
143
143
  */
144
144
  export declare function recordSuccessOf(c: Circuit): Circuit;
145
- /**
146
- * authorize's verified flag: exactly the text "true".
147
- *
148
- * @ensures result ⟺ s = "true"
149
- */
150
- export declare function verifiedFlag(s: string): boolean;
151
145
  /**
152
146
  * reCAPTCHA passes only with a secret, an ok response and the reply's optional `success` exactly
153
147
  * true (the score is not read).
@@ -178,13 +172,6 @@ export declare function customerRefusalOf(customerId: AddressId | null, refusal:
178
172
  * @ensures exactly the model's ItemsLimit, a missing limit as 0
179
173
  */
180
174
  export declare function itemsLimitOf(limit: number | undefined): number;
181
- /**
182
- * The cross-site opt-in as configured (`auth.crossSite`): on only when set to true, so a site
183
- * that says nothing stays off (atlas#105).
184
- *
185
- * @ensures exactly the model's CrossSiteOf
186
- */
187
- export declare function crossSiteOf(flag: boolean | undefined): boolean;
188
175
  /**
189
176
  * Whether queryAction looks for a cross-site session (imports next/headers and reads the
190
177
  * cookie): only on a site that opted in and has a secret. Every other site never reads cookies
@@ -195,7 +182,8 @@ export declare function crossSiteOf(flag: boolean | undefined): boolean;
195
182
  export declare function readsSession(crossSite: boolean, hasSecret: boolean): boolean;
196
183
  /**
197
184
  * The target siteId authorize writes into the session: the sign-in's `siteId` only on an
198
- * opted-in site, and only when it is not empty (atlas#105).
185
+ * opted-in site, and only when it is not empty (atlas#105), ASCII-lowercased (owner 2026-11-16:
186
+ * every siteId is made lowercase; models/Platform.dfy SiteIdFrom).
199
187
  *
200
188
  * @ensures exactly the model's SignInTarget
201
189
  */
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAMlD;;;;;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,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAE3F;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,GACnB,IAAI,CAQN;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,GAChB,OAAO,CAMT;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM/E;AAED,kCAAkC;AAClC,MAAM,MAAM,GAAG,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BAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAIlE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMxD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAIhE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAIlE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMvE"}
@@ -108,9 +108,10 @@ export declare function registerAuthSecret(secret: string): void;
108
108
  /** Returns the registered auth secret, or null if not registered. */
109
109
  export declare function getAuthSecret(): string | null;
110
110
  /**
111
- * Register the cross-site opt-in (`auth.crossSite`, through rules.crossSiteOf). Called by
112
- * createServerSite(). The ONE source both queryAction's session read and authorize's sign-in
113
- * target read (models/AugurServer.dfy, "the cross-site opt-in", atlas#105).
111
+ * Register whether this is the cross-site site: the augur_info client's own siteId
112
+ * (session-rules `crossSiteSite`, owner 2026-11-16). Called by createServerSite(). The ONE source
113
+ * both queryAction's session read and authorize's sign-in target read (models/AugurServer.dfy,
114
+ * atlas#105; models/AugurServerSecurity.dfy, cross-site).
114
115
  */
115
116
  export declare function registerCrossSite(on: boolean): void;
116
117
  /** Whether this site opted in to cross-site sessions; false unless registered. */
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-client-store.d.ts","sourceRoot":"","sources":["../src/sdk-client-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,gEAAgE;AAChE,MAAM,MAAM,cAAc,GAAG,CAC3B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC/B,GAAG,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wBAAgB,qBAAqB,IAAI,kBAAkB,GAAG,IAAI,CAEjE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAWhF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAMzE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,OAAO,CAEzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAM7E;AAED,mGAAmG;AACnG,wBAAgB,cAAc,IAAI,IAAI,CAgBrC"}
@@ -1,5 +1,5 @@
1
1
  import type { SiteActionsConfig, SiteActions } from "./actions/site";
2
- import type { AugurAuthCallbacks } from "./auth";
2
+ import type { AugurAuthCallbacks, WithoutCustomer } from "./auth";
3
3
  import type { NextAuthConfig } from "next-auth";
4
4
  /** Auth options forwarded to NextAuth when creating a server site. */
5
5
  export interface ServerSiteAuthConfig {
@@ -8,13 +8,11 @@ export interface ServerSiteAuthConfig {
8
8
  callbacks?: Partial<AugurAuthCallbacks>;
9
9
  debug?: boolean;
10
10
  /**
11
- * Cross-site sessions (the augur-support pattern: an augur_info client, and the target
12
- * `siteId` passed to `signIn`). Only when true does sign-in keep the target siteId and does
13
- * `queryAction` read the session cookie to use a client scoped to that site. Default off: a
14
- * site that does not set it never reads cookies in `queryAction`, so its pages can render
15
- * statically (atlas#105). A multi-tenant site MUST set it.
11
+ * A signed-in user with no usable customer of their own (atlas#212): `"default"` acts as
12
+ * `defaultCustomerId` (and gets its cart), `"none"` gets no customer. Required: a B2B portal
13
+ * MUST say `"none"`, a site whose shoppers buy as the default customer `"default"`.
16
14
  */
17
- crossSite?: boolean;
15
+ withoutCustomer: WithoutCustomer;
18
16
  }
19
17
  /** Configuration for {@link createServerSite}, combining action config and auth. */
20
18
  export interface ServerSiteConfig extends SiteActionsConfig {
@@ -38,7 +36,7 @@ export interface ServerSite<TApi extends object> {
38
36
  * const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });
39
37
  * export const site = createServerSite(api, {
40
38
  * defaultCustomerId: "12345",
41
- * auth: { secret: process.env.AUTH_SECRET },
39
+ * auth: { secret: process.env.AUTH_SECRET, withoutCustomer: "default" },
42
40
  * });
43
41
  * ```
44
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"server-site.d.ts","sourceRoot":"","sources":["../src/server-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,QAAQ,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAehD,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,IAAI,CAAC,EAAE,oBAAoB,CAAC;CAC7B;AAED,uDAAuD;AACvD,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,MAAM;IAC7C,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;CAClC;AAcD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,MAAM,EAAE,IAAI,EACZ,MAAM,GAAE,gBAAqB,GAC5B,UAAU,CAAC,IAAI,CAAC,CAiElB"}
1
+ {"version":3,"file":"server-site.d.ts","sourceRoot":"","sources":["../src/server-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAmB,eAAe,EAAE,MAAM,QAAQ,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAehD,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,IAAI,CAAC,EAAE,oBAAoB,CAAC;CAC7B;AAED,uDAAuD;AACvD,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,MAAM;IAC7C,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;CAClC;AAeD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,MAAM,EAAE,IAAI,EACZ,MAAM,GAAE,gBAAqB,GAC5B,UAAU,CAAC,IAAI,CAAC,CAqElB"}
@@ -0,0 +1,118 @@
1
+ import type { AddressId } from "./address-id";
2
+ /**
3
+ * The keys the `session` callback adds to the session the browser gets: the user's fields and
4
+ * the cross-site target. Never `token`: the user's Augur bearer stays in the encrypted JWT, where
5
+ * queryAction reads it (model `SessionHasNoBearer`, `ServerKeepsTheBearer`).
6
+ *
7
+ * @ensures exactly the model's SessionFields
8
+ */
9
+ export declare function sessionKeys(): string[];
10
+ /**
11
+ * A site's `withoutCustomer` as configured: true for `"default"` (a signed-in user with no
12
+ * usable customer acts as the site's default customer), false for `"none"` (they get no
13
+ * customer), and null for anything else, which `createAuthConfig` refuses: the choice is the
14
+ * site's and has no default (model `NoSilentChoice`).
15
+ *
16
+ * @ensures exactly the model's AuthConfigBuilt and WithoutCustomer
17
+ */
18
+ export declare function actsAsDefaultOf(choice: string | undefined): boolean | null;
19
+ /**
20
+ * A sign-in's outcome (atlas#97), from Joomla's answer to `verifyPassword`, asked by the server:
21
+ * "wrong-password" when a field is blank (Joomla is not asked) or the answer names no user;
22
+ * "not-activated" for a match on an unverified account (augur never answers so; kept because the
23
+ * answer is not validated at run time); "no-token" for a cross-site sign-in without a token;
24
+ * else "signed-in", as the answer's user. Nothing the browser posts besides the username and
25
+ * password reaches it.
26
+ *
27
+ * @ensures exactly the model's Authorize (AsksJoomla, SignInOf)
28
+ */
29
+ export declare function signInOutcomeOf(asks: boolean, answerId: number, verified: boolean, hasToken: boolean, crossSite: boolean): string;
30
+ /**
31
+ * Whether a session is kept on this read: the account was found and is not blocked
32
+ * (owner 2026-11-16: a blocked account "can't have a session").
33
+ *
34
+ * @ensures exactly the model's SessionKept
35
+ */
36
+ export declare function sessionKept(hasProfile: boolean, blocked: boolean): boolean;
37
+ /**
38
+ * Cross-site sign-in is on exactly for the system site, augur_info (owner 2026-11-16: it
39
+ * "REQUIRES the site_id to be augur_info", and only then is a target siteId processed). The
40
+ * system site is the repo's one proved definition, auth-core's `systemSiteId()`
41
+ * (models: Platform.SystemSite). The siteId is lowercased first (owner 2026-11-16: every siteId
42
+ * is made lowercase), so a config's "AUGUR_INFO" is the system site too.
43
+ *
44
+ * @ensures exactly the model's CrossSiteSite
45
+ */
46
+ export declare function crossSiteSite(siteId: string): boolean;
47
+ /**
48
+ * Whether queryAction follows a segment of a method path: the object's own property, or, for the
49
+ * first segment only, an accessor (the SDK's services are getters on the client). The client's
50
+ * own members (`setAuthToken`, `call`, `withRequest`, `constructor`) are prototype methods, so a
51
+ * caller never reaches them.
52
+ *
53
+ * @ensures exactly the model's SegmentReachable
54
+ */
55
+ /**
56
+ * Whether the site's SDK registry refuses a `queryAction` path (atlas#104): the client has a
57
+ * registry (`AugurAPI.hasEndpoint`) and the path is not in it. A client without one (an SDK
58
+ * before it, a test double) leaves the path to the walk alone.
59
+ *
60
+ * @ensures exactly the model's RegistryRefuses
61
+ */
62
+ export declare function registryRefuses(hasRegistry: boolean, inRegistry: boolean): boolean;
63
+ /**
64
+ * A chain segment's route chain when it is a data proxy (`invMastData` → `invMast`), or "" when
65
+ * it is not one.
66
+ *
67
+ * @ensures exactly the model's DataChainOf
68
+ */
69
+ export declare function dataChainOf(segment: string): string;
70
+ /**
71
+ * Whether a path is in the registry: it is an id, or its data chain makes one.
72
+ *
73
+ * @ensures exactly the model's InRegistry
74
+ */
75
+ export declare function inRegistry(isId: boolean, dataChainIsId: boolean): boolean;
76
+ export declare function segmentReachable(isFirst: boolean, isOwn: boolean, isAccessor: boolean): boolean;
77
+ /**
78
+ * Where a callback comes from: the site's own (`callbacks.getUserProfile`, `.cartHdrLookup`)
79
+ * when given, else the package's SDK call when it has a client, else none.
80
+ *
81
+ * @ensures exactly the model's CallbackSourceOf
82
+ */
83
+ export declare function callbackSourceOf(hasOverride: boolean, hasClient: boolean): string;
84
+ /**
85
+ * Whether `createAuthConfig` refuses a config: no client, and not both a profile callback and a
86
+ * password check, so a user could not be loaded or a sign-in could not be verified (atlas#97).
87
+ *
88
+ * @ensures exactly the model's ConfigRefused
89
+ */
90
+ export declare function configRefused(hasClient: boolean, hasProfileOverride: boolean, hasVerifyOverride: boolean): boolean;
91
+ /**
92
+ * Whether Joomla is asked at all: only with both a username and a password (a blank one is a
93
+ * wrong password at once, with no call).
94
+ *
95
+ * @ensures exactly the model's AsksJoomla
96
+ */
97
+ export declare function asksJoomla(username: string, password: string): boolean;
98
+ /**
99
+ * The JWT's verified flag as read for the session: verified only when present and true.
100
+ *
101
+ * @ensures exactly the model's ClaimVerified
102
+ */
103
+ export declare function claimVerified(present: boolean, flag: boolean): boolean;
104
+ /**
105
+ * A number the cart lookup sends: the value when it is a number, else 0 (the SDK's "none").
106
+ *
107
+ * @ensures exactly the model's LookupNumberOf
108
+ */
109
+ export declare function lookupNumberOf(isNumber: boolean, n: number): number;
110
+ /**
111
+ * The session's customer, and the one the sign-in cart is looked up for: the user's own usable
112
+ * customer always; else the site's default only on a site that chose `"default"`; else none.
113
+ * Both ids come through augur-utils' `addressIdOf`, so "", "0" and 0 are already none (atlas#95).
114
+ *
115
+ * @ensures exactly the model's SessionCustomer (and CartCustomer, the same function)
116
+ */
117
+ export declare function sessionCustomerOf(own: AddressId | null, siteDefault: AddressId | null, actsAsDefault: boolean): AddressId | null;
118
+ //# sourceMappingURL=session-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-rules.d.ts","sourceRoot":"","sources":["../src/session-rules.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAKtC;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,CAS1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,OAAO,GACjB,MAAM,CAYR;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAI1E;AAED;;;;;;;;GAQG;AACH,wB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
  createAuthConfig
3
- } from "./chunk-AEFUT3MB.js";
3
+ } from "./chunk-M35O5JDZ.js";
4
+ import {
5
+ crossSiteSite
6
+ } from "./chunk-ILXNFJVM.js";
4
7
  import {
5
8
  createSiteActions,
6
9
  registerSiteActions,
7
10
  serverTtlOf,
8
11
  withRawSdkCache
9
- } from "./chunk-4CU4UNBH.js";
10
- import "./chunk-JIYVQWXK.js";
12
+ } from "./chunk-GKT4MAWC.js";
13
+ import "./chunk-IM7FDRER.js";
11
14
  import {
12
- crossSiteOf,
13
15
  registerAuthSecret,
14
16
  registerClientFactory,
15
17
  registerCrossSite,
16
18
  registerScopedCacheWrapper,
17
19
  registerSdkCallWrapper,
18
20
  registerSdkClient
19
- } from "./chunk-5X2QWOTO.js";
20
- import "./chunk-BG4G5QUQ.js";
21
+ } from "./chunk-5DBFTSWY.js";
22
+ import "./chunk-HGJF667G.js";
21
23
 
22
24
  // src/server-site.ts
23
25
  import { hours } from "@simpleapps-com/augur-utils";
24
26
  import { getCacheTier, isP21Path } from "@simpleapps-com/augur-core";
25
- function registerSessionAuth(auth) {
27
+ function registerSessionAuth(auth, siteId) {
26
28
  const authSecret = auth?.secret ?? process.env["AUTH_SECRET"];
27
29
  if (authSecret) {
28
30
  registerAuthSecret(authSecret);
29
31
  }
30
- registerCrossSite(crossSiteOf(auth?.crossSite));
32
+ registerCrossSite(crossSiteSite(siteId));
31
33
  }
32
34
  function createServerSite(client, config = {}) {
33
35
  const actions = createSiteActions(client, config);
@@ -59,7 +61,10 @@ function createServerSite(client, config = {}) {
59
61
  return new Ctor({ ...baseConfig, siteId, bearerToken });
60
62
  });
61
63
  }
62
- registerSessionAuth(config.auth);
64
+ registerSessionAuth(
65
+ config.auth,
66
+ baseConfig?.["siteId"] === void 0 ? "" : String(baseConfig["siteId"])
67
+ );
63
68
  const auth = config.auth ? createAuthConfig({
64
69
  augurClient: client,
65
70
  defaultCustomerId: config.defaultCustomerId,
package/dist/site.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server-site.ts"],"sourcesContent":["import { hours } from \"@simpleapps-com/augur-utils\";\nimport { createSiteActions } from \"./actions/site\";\nimport type { SiteActionsConfig, SiteActions } from \"./actions/site\";\nimport { createAuthConfig } from \"./auth\";\nimport type { AugurAuthCallbacks, AugurAuthClient } from \"./auth\";\nimport type { NextAuthConfig } from \"next-auth\";\nimport { registerSiteActions } from \"./server-site-registry\";\nimport {\n registerSdkClient,\n registerSdkCallWrapper,\n registerAuthSecret,\n registerClientFactory,\n registerCrossSite,\n registerScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport { withRawSdkCache } from \"./cache/with-cache\";\nimport { crossSiteOf } from \"./rules\";\nimport { serverTtlOf } from \"./read-rules\";\nimport { getCacheTier, isP21Path } from \"@simpleapps-com/augur-core\";\n\n/** Auth options forwarded to NextAuth when creating a server site. */\nexport interface ServerSiteAuthConfig {\n secret?: string;\n maxAge?: number;\n callbacks?: Partial<AugurAuthCallbacks>;\n debug?: boolean;\n /**\n * Cross-site sessions (the augur-support pattern: an augur_info client, and the target\n * `siteId` passed to `signIn`). Only when true does sign-in keep the target siteId and does\n * `queryAction` read the session cookie to use a client scoped to that site. Default off: a\n * site that does not set it never reads cookies in `queryAction`, so its pages can render\n * statically (atlas#105). A multi-tenant site MUST set it.\n */\n crossSite?: boolean;\n}\n\n/** Configuration for {@link createServerSite}, combining action config and auth. */\nexport interface ServerSiteConfig extends SiteActionsConfig {\n auth?: ServerSiteAuthConfig;\n}\n\n/** The object returned by {@link createServerSite}. */\nexport interface ServerSite<TApi extends object> {\n client: TApi;\n actions: SiteActions;\n auth: NextAuthConfig | undefined;\n}\n\n/**\n * Register what queryAction and sign-in need from `auth`: the secret (`auth.secret`, else\n * `AUTH_SECRET`) and the cross-site opt-in, the one source both read (atlas#105).\n */\nfunction registerSessionAuth(auth: ServerSiteAuthConfig | undefined): void {\n const authSecret = auth?.secret ?? process.env[\"AUTH_SECRET\"];\n if (authSecret) {\n registerAuthSecret(authSecret);\n }\n registerCrossSite(crossSiteOf(auth?.crossSite));\n}\n\n/**\n * Create a server-side site instance that bundles the SDK client, server\n * actions, and (optional) NextAuth configuration.\n *\n * @example\n * ```ts\n * import { AugurAPI } from \"@simpleapps-com/augur-api\";\n * import { createServerSite } from \"@simpleapps-com/augur-server/site\";\n *\n * const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });\n * export const site = createServerSite(api, {\n * defaultCustomerId: \"12345\",\n * auth: { secret: process.env.AUTH_SECRET },\n * });\n * ```\n */\nexport function createServerSite<TApi extends object>(\n client: TApi,\n config: ServerSiteConfig = {},\n): ServerSite<TApi> {\n const actions = createSiteActions(client, config);\n registerSiteActions(actions);\n registerSdkClient(client);\n\n // Register a cache wrapper that captures the site's Redis config.\n // queryAction uses this to wrap read methods in Redis caching without\n // importing the cache directly (which would pull ioredis into the client\n // bundle via tsup code splitting). The SDK's raw result is cached, in its\n // own key space (withRawSdkCache, #98); queryAction unwraps after the read.\n const { cachePrefix = \"\", redisTtl = hours(1), longRedisTtl = hours(8) } = config;\n // No Redis TTL on the tier (no-cache, user): no caching; else an hour of staleTime or more,\n // the long TTL; any other, the standard (proved serverTtlOf, atlas#102).\n const cachedRaw = <T>(\n prefix: string,\n methodPath: string,\n sdkCall: () => Promise<T>,\n keyArgs: unknown[],\n ): Promise<T> => {\n const tier = getCacheTier(methodPath);\n const ttl = serverTtlOf(\n tier.redisTtl !== undefined,\n isP21Path(methodPath),\n tier.staleTime,\n redisTtl,\n longRedisTtl,\n );\n if (ttl === null) return sdkCall();\n return withRawSdkCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);\n };\n registerSdkCallWrapper((methodPath, sdkCall, ...keyArgs) =>\n cachedRaw(cachePrefix, methodPath, sdkCall, keyArgs),\n );\n\n // Register scoped cache wrapper for per-request session credentials.\n // queryAction uses this to wrap scoped client calls with Redis caching\n // using the targetSiteId as the cache prefix.\n registerScopedCacheWrapper((prefix, methodPath, sdkCall, ...keyArgs) =>\n cachedRaw(prefix, methodPath, sdkCall, keyArgs),\n );\n\n // Register client factory for creating scoped SDK clients with\n // per-request credentials. Uses the same constructor + base config\n // (baseUrl, timeout, retries) but different siteId/bearerToken.\n const baseConfig = (client as Record<string, unknown>)[\"config\"] as\n Record<string, unknown> | undefined;\n if (baseConfig) {\n const Ctor = client.constructor as new (cfg: Record<string, unknown>) => object;\n registerClientFactory((siteId: string, bearerToken: string) => {\n return new Ctor({ ...baseConfig, siteId, bearerToken });\n });\n }\n\n registerSessionAuth(config.auth);\n\n const auth = config.auth\n ? createAuthConfig({\n augurClient: client as unknown as AugurAuthClient,\n defaultCustomerId: config.defaultCustomerId,\n defaultContactId: config.defaultContactId,\n ...config.auth,\n })\n : undefined;\n\n return { client, actions, auth };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AAkBtB,SAAS,cAAc,iBAAiB;AAkCxC,SAAS,oBAAoB,MAA8C;AACzE,QAAM,aAAa,MAAM,UAAU,QAAQ,IAAI,aAAa;AAC5D,MAAI,YAAY;AACd,uBAAmB,UAAU;AAAA,EAC/B;AACA,oBAAkB,YAAY,MAAM,SAAS,CAAC;AAChD;AAkBO,SAAS,iBACd,QACA,SAA2B,CAAC,GACV;AAClB,QAAM,UAAU,kBAAkB,QAAQ,MAAM;AAChD,sBAAoB,OAAO;AAC3B,oBAAkB,MAAM;AAOxB,QAAM,EAAE,cAAc,IAAI,WAAW,MAAM,CAAC,GAAG,eAAe,MAAM,CAAC,EAAE,IAAI;AAG3E,QAAM,YAAY,CAChB,QACA,YACA,SACA,YACe;AACf,UAAM,OAAO,aAAa,UAAU;AACpC,UAAM,MAAM;AAAA,MACV,KAAK,aAAa;AAAA,MAClB,UAAU,UAAU;AAAA,MACpB,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACF;AACA,QAAI,QAAQ,KAAM,QAAO,QAAQ;AACjC,WAAO,gBAAgB,QAAQ,KAAK,YAAY,SAAS,GAAG,OAAO;AAAA,EACrE;AACA;AAAA,IAAuB,CAAC,YAAY,YAAY,YAC9C,UAAU,aAAa,YAAY,SAAS,OAAO;AAAA,EACrD;AAKA;AAAA,IAA2B,CAAC,QAAQ,YAAY,YAAY,YAC1D,UAAU,QAAQ,YAAY,SAAS,OAAO;AAAA,EAChD;AAKA,QAAM,aAAc,OAAmC,QAAQ;AAE/D,MAAI,YAAY;AACd,UAAM,OAAO,OAAO;AACpB,0BAAsB,CAAC,QAAgB,gBAAwB;AAC7D,aAAO,IAAI,KAAK,EAAE,GAAG,YAAY,QAAQ,YAAY,CAAC;AAAA,IACxD,CAAC;AAAA,EACH;AAEA,sBAAoB,OAAO,IAAI;AAE/B,QAAM,OAAO,OAAO,OAChB,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,mBAAmB,OAAO;AAAA,IAC1B,kBAAkB,OAAO;AAAA,IACzB,GAAG,OAAO;AAAA,EACZ,CAAC,IACD;AAEJ,SAAO,EAAE,QAAQ,SAAS,KAAK;AACjC;","names":[]}
1
+ {"version":3,"sources":["../src/server-site.ts"],"sourcesContent":["import { hours } from \"@simpleapps-com/augur-utils\";\nimport { createSiteActions } from \"./actions/site\";\nimport type { SiteActionsConfig, SiteActions } from \"./actions/site\";\nimport { createAuthConfig } from \"./auth\";\nimport type { AugurAuthCallbacks, AugurAuthClient, WithoutCustomer } from \"./auth\";\nimport type { NextAuthConfig } from \"next-auth\";\nimport { registerSiteActions } from \"./server-site-registry\";\nimport {\n registerSdkClient,\n registerSdkCallWrapper,\n registerAuthSecret,\n registerClientFactory,\n registerCrossSite,\n registerScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport { withRawSdkCache } from \"./cache/with-cache\";\nimport { crossSiteSite } from \"./session-rules\";\nimport { serverTtlOf } from \"./read-rules\";\nimport { getCacheTier, isP21Path } from \"@simpleapps-com/augur-core\";\n\n/** Auth options forwarded to NextAuth when creating a server site. */\nexport interface ServerSiteAuthConfig {\n secret?: string;\n maxAge?: number;\n callbacks?: Partial<AugurAuthCallbacks>;\n debug?: boolean;\n /**\n * A signed-in user with no usable customer of their own (atlas#212): `\"default\"` acts as\n * `defaultCustomerId` (and gets its cart), `\"none\"` gets no customer. Required: a B2B portal\n * MUST say `\"none\"`, a site whose shoppers buy as the default customer `\"default\"`.\n */\n withoutCustomer: WithoutCustomer;\n}\n\n/** Configuration for {@link createServerSite}, combining action config and auth. */\nexport interface ServerSiteConfig extends SiteActionsConfig {\n auth?: ServerSiteAuthConfig;\n}\n\n/** The object returned by {@link createServerSite}. */\nexport interface ServerSite<TApi extends object> {\n client: TApi;\n actions: SiteActions;\n auth: NextAuthConfig | undefined;\n}\n\n/**\n * Register what queryAction and sign-in need: the secret (`auth.secret`, else `AUTH_SECRET`) and\n * whether this is the cross-site (augur_info) site, the one source both read (atlas#105). Cross-site\n * sign-in is on exactly when the client's own siteId is augur_info (owner 2026-11-16).\n */\nfunction registerSessionAuth(auth: ServerSiteAuthConfig | undefined, siteId: string): void {\n const authSecret = auth?.secret ?? process.env[\"AUTH_SECRET\"];\n if (authSecret) {\n registerAuthSecret(authSecret);\n }\n registerCrossSite(crossSiteSite(siteId));\n}\n\n/**\n * Create a server-side site instance that bundles the SDK client, server\n * actions, and (optional) NextAuth configuration.\n *\n * @example\n * ```ts\n * import { AugurAPI } from \"@simpleapps-com/augur-api\";\n * import { createServerSite } from \"@simpleapps-com/augur-server/site\";\n *\n * const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });\n * export const site = createServerSite(api, {\n * defaultCustomerId: \"12345\",\n * auth: { secret: process.env.AUTH_SECRET, withoutCustomer: \"default\" },\n * });\n * ```\n */\nexport function createServerSite<TApi extends object>(\n client: TApi,\n config: ServerSiteConfig = {},\n): ServerSite<TApi> {\n const actions = createSiteActions(client, config);\n registerSiteActions(actions);\n registerSdkClient(client);\n\n // Register a cache wrapper that captures the site's Redis config.\n // queryAction uses this to wrap read methods in Redis caching without\n // importing the cache directly (which would pull ioredis into the client\n // bundle via tsup code splitting). The SDK's raw result is cached, in its\n // own key space (withRawSdkCache, #98); queryAction unwraps after the read.\n const { cachePrefix = \"\", redisTtl = hours(1), longRedisTtl = hours(8) } = config;\n // No Redis TTL on the tier (no-cache, user): no caching; else an hour of staleTime or more,\n // the long TTL; any other, the standard (proved serverTtlOf, atlas#102).\n const cachedRaw = <T>(\n prefix: string,\n methodPath: string,\n sdkCall: () => Promise<T>,\n keyArgs: unknown[],\n ): Promise<T> => {\n const tier = getCacheTier(methodPath);\n const ttl = serverTtlOf(\n tier.redisTtl !== undefined,\n isP21Path(methodPath),\n tier.staleTime,\n redisTtl,\n longRedisTtl,\n );\n if (ttl === null) return sdkCall();\n return withRawSdkCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);\n };\n registerSdkCallWrapper((methodPath, sdkCall, ...keyArgs) =>\n cachedRaw(cachePrefix, methodPath, sdkCall, keyArgs),\n );\n\n // Register scoped cache wrapper for per-request session credentials.\n // queryAction uses this to wrap scoped client calls with Redis caching\n // using the targetSiteId as the cache prefix.\n registerScopedCacheWrapper((prefix, methodPath, sdkCall, ...keyArgs) =>\n cachedRaw(prefix, methodPath, sdkCall, keyArgs),\n );\n\n // Register client factory for creating scoped SDK clients with\n // per-request credentials. Uses the same constructor + base config\n // (baseUrl, timeout, retries) but different siteId/bearerToken.\n const baseConfig = (client as Record<string, unknown>)[\"config\"] as\n Record<string, unknown> | undefined;\n if (baseConfig) {\n const Ctor = client.constructor as new (cfg: Record<string, unknown>) => object;\n registerClientFactory((siteId: string, bearerToken: string) => {\n return new Ctor({ ...baseConfig, siteId, bearerToken });\n });\n }\n\n // The client's own siteId (private config, read the same way createSiteActions reads it).\n registerSessionAuth(\n config.auth,\n baseConfig?.[\"siteId\"] === undefined ? \"\" : String(baseConfig[\"siteId\"]),\n );\n\n const auth = config.auth\n ? createAuthConfig({\n augurClient: client as unknown as AugurAuthClient,\n defaultCustomerId: config.defaultCustomerId,\n defaultCont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AAA,IACP,aAAa,QAAQ,MAAM,SAAY,KAAK,OAAO,WAAW,QAAQ,CAAC;AAAA,EACzE;AAEA,QAAM,OAAO,OAAO,OAChB,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,mBAAmB,OAAO;AAAA,IAC1B,kBAAkB,OAAO;AAAA,IACzB,GAAG,OAAO;AAAA,EACZ,CAAC,IACD;AAEJ,SAAO,EAAE,QAAQ,SAAS,KAAK;AACjC;","names":[]}
package/dist/sitemap.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  decimal
3
- } from "./chunk-JIYVQWXK.js";
3
+ } from "./chunk-IM7FDRER.js";
4
4
  import {
5
5
  canonicalNatValue,
6
6
  endsWith,
@@ -8,7 +8,7 @@ import {
8
8
  lineFeed,
9
9
  rStripCode,
10
10
  startsWithAt
11
- } from "./chunk-BG4G5QUQ.js";
11
+ } from "./chunk-HGJF667G.js";
12
12
 
13
13
  // ../utils/src/replace.ts
14
14
  function codeIndex(codes, c, i) {
package/dist/testing.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  clearSiteActions
3
- } from "./chunk-4CU4UNBH.js";
4
- import "./chunk-JIYVQWXK.js";
5
- import "./chunk-5X2QWOTO.js";
6
- import "./chunk-BG4G5QUQ.js";
3
+ } from "./chunk-GKT4MAWC.js";
4
+ import "./chunk-IM7FDRER.js";
5
+ import "./chunk-5DBFTSWY.js";
6
+ import "./chunk-HGJF667G.js";
7
7
 
8
8
  // src/testing.ts
9
9
  import { createMockClient } from "@simpleapps-com/augur-core/testing";
package/llms.txt CHANGED
@@ -117,6 +117,8 @@ const result = await sdkCall(
117
117
  - type: AugurSession
118
118
  - type: AugurUser
119
119
  - type: CreateAuthConfigOptions
120
+ - type: PasswordAnswer
121
+ - type: WithoutCustomer
120
122
 
121
123
  ## @simpleapps-com/augur-server/query
122
124
 
@@ -170,7 +172,7 @@ import { createServerSite } from "@simpleapps-com/augur-server/site";
170
172
  const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });
171
173
  export const site = createServerSite(api, {
172
174
  defaultCustomerId: "12345",
173
- auth: { secret: process.env.AUTH_SECRET },
175
+ auth: { secret: process.env.AUTH_SECRET, withoutCustomer: "default" },
174
176
  });
175
177
  ```
176
178
 
@@ -216,7 +218,7 @@ const addToCart = useMutation(q.commerce.cartLine.add.create());
216
218
  - function: queryActionRawWith - `queryActionRaw`, bounded: the same options as {@link queryActionWith}.
217
219
  - function: queryActionWith - `queryAction`, bounded (atlas#106): `options.deadline` caps the whole call in milliseconds (every retry and the waits between them), and `options.signal` lets the caller cancel it. At the deadline the call rejects with a `TimeoutError` (the request is cancelled, nothing more is retried, nothing is cached), so a server render can fall back to a client-side fetch.
218
220
  - function: resetSessionImports - Reset lazy-loaded imports. Used in tests only. @internal
219
- - function: resolveMethod - Resolve a dot-separated method path on an object, returning the leaf function.
221
+ - function: resolveMethod
220
222
  - value: unwrapBaseResponse
221
223
 
222
224
  ### Examples
package/next-auth.d.ts CHANGED
@@ -33,9 +33,9 @@ declare module "next-auth" {
33
33
  customerId?: string | number;
34
34
  contactId?: string | number;
35
35
  cartHdrUid?: number;
36
- token?: string;
37
36
  } & DefaultSession["user"];
38
- token?: string;
37
+ // No `token`: the session reaches the browser, so the Augur token stays in the JWT (atlas#212).
38
+ targetSiteId?: string;
39
39
  expires: string;
40
40
  }
41
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleapps-com/augur-server",
3
- "version": "2026.11.11",
3
+ "version": "2026.11.12",
4
4
  "description": "Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -63,11 +63,11 @@
63
63
  ],
64
64
  "dependencies": {
65
65
  "@simpleapps-com/augur-core": "^2026.11.5",
66
- "@simpleapps-com/augur-hooks": "^2026.11.8",
67
- "@simpleapps-com/augur-utils": "^2026.11.5"
66
+ "@simpleapps-com/augur-hooks": "^2026.11.9",
67
+ "@simpleapps-com/augur-utils": "^2026.11.6"
68
68
  },
69
69
  "peerDependencies": {
70
- "@simpleapps-com/augur-api": "^2026.11.4",
70
+ "@simpleapps-com/augur-api": "^2026.11.10",
71
71
  "@tanstack/react-query": "^5.80.0",
72
72
  "ioredis": "^5.9.0",
73
73
  "jose": "^5.0.0 || ^6.0.0",
@@ -99,13 +99,14 @@
99
99
  "tsup": "^9.0.0",
100
100
  "typescript": "~6.0.3",
101
101
  "vitest": "~5.0.3",
102
+ "@atlas/auth-core": "0.0.0",
102
103
  "@atlas/eslint-config": "0.0.0",
103
104
  "@atlas/tsconfig": "0.0.0",
105
+ "@atlas/tsup-config": "0.0.0",
104
106
  "@atlas/foundation": "0.0.0",
105
107
  "@atlas/utils": "0.0.0",
106
- "@atlas/tsup-config": "0.0.0",
107
108
  "@atlas/vitest-config": "0.0.0",
108
- "@simpleapps-com/augur-api": "2026.11.7"
109
+ "@simpleapps-com/augur-api": "2026.11.10"
109
110
  },
110
111
  "engines": {
111
112
  "node": ">=22.0.0"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../foundation/src/duration.ts","../../utils/src/includes.ts","../src/rules.ts","../src/scoped-client-key.ts","../src/sdk-client-store.ts"],"sourcesContent":["//@ backend dafny\n\n/* Seconds and milliseconds as two types (2026-11-08). Verified with LemmaScript → Dafny\n (`pnpm proofs`; model: models/Durations.dfy, where they are two datatypes; link:\n models/links/foundation-duration.dfy).\n\n Both are branded: a plain `number` is neither, and a `Seconds` is not a `Millis`, so a TTL in\n seconds can't be passed where milliseconds are meant (augur-core's `staleTime` vs\n `redisTtl`), and a JWT `exp` can't be compared with `Date.now()` unconverted. Write a\n duration in the unit people think in (`minutes(15)`) and convert with `toMillis`; read a\n clock or a millisecond count back with `floorSeconds`. Values enter through the guards\n `secondsOf` / `millisOf` (an env value, a JSON `expires_in`); the clock is `millis(Date.now())`\n (the platform's time value is a whole, non-negative number of milliseconds).\n lsc writes both aliases as `nat` (no refinement, models/LSC-GAPS.md). */\n\n/** A whole number of seconds, made only by the builders and guards below. */\n//@ type nat\nexport type Seconds = number & { readonly __seconds: true };\n\n/** A whole number of milliseconds, made only by the builders and guards below. */\n//@ type nat\nexport type Millis = number & { readonly __millis: true };\n\n/**\n * `n` seconds.\n *\n * @ensures exactly the model's Seconds(n)\n */\nexport function seconds(n: number): Seconds {\n //@ verify\n //@ type n nat\n //@ requires n >= 0\n //@ ensures \\result === n\n return n as Seconds;\n}\n\n/**\n * `n` minutes, in seconds.\n *\n * @ensures exactly the model's Minutes\n */\nexport function minutes(n: number): Seconds {\n //@ verify\n //@ type n nat\n //@ requires n >= 0\n //@ ensures \\result === n * 60\n return (n * 60) as Seconds;\n}\n\n/**\n * `n` hours, in seconds.\n *\n * @ensures exactly the model's Hours\n */\nexport function hours(n: number): Seconds {\n //@ verify\n //@ type n nat\n //@ requires n >= 0\n //@ ensures \\result === n * 3600\n return (n * 3600) as Seconds;\n}\n\n/**\n * `n` days, in seconds.\n *\n * @ensures exactly the model's Days\n */\nexport function days(n: number): Seconds {\n //@ verify\n //@ type n nat\n //@ requires n >= 0\n //@ ensures \\result === n * 86400\n return (n * 86400) as Seconds;\n}\n\n/**\n * `n` milliseconds: for a duration under a second (a retry backoff, a debounce).\n *\n * @ensures exactly the model's Millis(n)\n */\nexport function millis(n: number): Millis {\n //@ verify\n //@ type n nat\n //@ requires n >= 0\n //@ ensures \\result === n\n return n as Millis;\n}\n\n/**\n * Seconds as milliseconds, exactly.\n *\n * @ensures exactly the model's ToMillis\n */\nexport function toMillis(d: Seconds): Millis {\n //@ verify\n //@ requires d >= 0\n //@ ensures \\result === d * 1000\n return (d * 1000) as Millis;\n}\n\n/**\n * Milliseconds as whole seconds, rounded down (a JWT `exp` or `iat` from a clock).\n *\n * @ensures exactly the model's FloorSeconds\n */\nexport function floorSeconds(m: Millis): Seconds {\n //@ verify\n //@ type m nat\n //@ requires m >= 0\n //@ ensures \\result === Math.floor(m / 1000)\n return Math.floor(m / 1000) as Seconds;\n}\n\n/**\n * A clock reading plus a duration, both `Millis`: when something expires (`addMillis(now,\n * toMillis(minutes(15)))`).\n *\n * @ensures exactly the model's AddMillis\n */\nexport function addMillis(a: Millis, b: Millis): Millis {\n //@ verify\n //@ requires a >= 0 && b >= 0\n //@ ensures \\result === a + b\n return (a + b) as Millis;\n}\n\n/**\n * A reading less a duration, never below 0 (a token used until a minute before it expires). An\n * expiry clamped to 0 is no more live than the negative one it stands for (the model's\n * MinusMillisKeepsLiveness).\n *\n * @ensures exactly the model's MinusMillis\n */\nexport function minusMillis(a: Millis, b: Millis): Millis {\n //@ verify\n //@ requires a >= 0 && b >= 0\n //@ ensures \\result === (a >= b ? a - b : 0)\n return a >= b ? ((a - b) as Millis) : millis(0);\n}\n\n/**\n * `n` as `Seconds`, or null when it is not a safe integer at least 0: a fraction, NaN, a\n * negative, an infinity, or past `Number.MAX_SAFE_INTEGER`. Where a number of seconds enters.\n *\n * @ensures exactly the model's AcceptedAsDuration, and the value is kept\n */\nexport function secondsOf(n: number): Seconds | null {\n //@ verify\n //@ ensures (\\result !== null) <==> (n >= 0 && n <= 9007199254740991)\n //@ ensures \\result !== null ==> \\result === n\n return Math.floor(n) === n && n >= 0 && n <= 9007199254740991 ? (n as Seconds) : null;\n}\n\n/**\n * An outside count of seconds (a token's `expires_in`, a JWT's `exp`) as `Seconds`: rounded\n * down, and 0 when it is then no safe integer at least 0 (a negative, NaN, an infinity), so a\n * bad lifetime is no lifetime and a bad expiry is already past.\n *\n * @ensures exactly the model's WholeSeconds (the proof reads a number as an integer)\n */\nexport function wholeSeconds(n: number): Seconds {\n //@ verify\n //@ ensures (n >= 0 && n <= 9007199254740991) ==> \\result === n\n //@ ensures !(n >= 0 && n <= 9007199254740991) ==> \\result === 0\n const whole = secondsOf(Math.floor(n));\n return whole === null ? seconds(0) : whole;\n}\n\n/**\n * `n` as `Millis`, or null when it is not a safe integer at least 0 (the same rule as\n * `secondsOf`). Where a number of milliseconds enters.\n *\n * @ensures exactly the model's AcceptedAsDuration, and the value is kept\n */\nexport function millisOf(n: number): Millis | null {\n //@ verify\n //@ ensures (\\result !== null) <==> (n >= 0 && n <= 9007199254740991)\n //@ ensures \\result !== null ==> \\result === n\n return Math.floor(n) === n && n >= 0 && n <= 9007199254740991 ? (n as Millis) : null;\n}\n","//@ backend dafny\nimport { startsWithAt } from \"./strings\";\n\n/* Substring search from an index, verified with LemmaScript → Dafny (model: models/Utils.dfy\n IncludesFrom; link: models/links/utils-includes.dfy). Its own file (moved out of strings.ts,\n 2026-11-06) so its contract can name `startsWithAt`: lsc gives an importer a helper from\n another file with that helper's contract, never one from the same file (models/LSC-GAPS.md). */\n\n/**\n * Whether `x` occurs in `s` at some index ≥ `i` (JS `s.includes(x, i)`). `i` MUST be at most\n * |s|: past the end JS clamps it to |s| (Fable review 2026-11-06), so a start there is the end.\n *\n * A loop, so its depth doesn't grow with `s` (agr-entity-graphql runs it on a whole schema's JSON).\n *\n * @requires i ≤ |s|\n * @ensures result ⟺ ∃ k. i ≤ k ≤ |s| ∧ startsWithAt(s, x, k) — exactly the model's IncludesFrom\n */\nexport function includesFrom(s: string, x: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ requires i >= 0 && i <= s.length\n //@ ensures \\result <==> exists(k: nat, i <= k && k <= s.length && startsWithAt(s, x, k))\n for (let k = i; k !== s.length + 1; k++) {\n //@ invariant i <= k && k <= s.length + 1\n //@ invariant forall(j: nat, (i <= j && j < k) ==> !startsWithAt(s, x, j))\n //@ decreases s.length + 1 - k\n if (startsWithAt(s, x, k)) return true;\n }\n return false;\n}\n","//@ backend dafny\nimport { addMillis, hours, millis, minutes, seconds, toMillis } from \"@atlas/foundation/duration\";\nimport { includesFrom } from \"@atlas/utils/includes\";\nimport { indexOfCode } from \"@atlas/utils/strings\";\nimport type { AddressId } from \"./address-id\";\nimport type { Millis, Seconds } from \"./duration\";\n\n/* The server's decisions, as pure functions verified with LemmaScript → Dafny (model:\n models/AugurServer.dfy; link: models/links/augur-server-rules.dfy). Cookies, JWT decoding,\n fetch, Redis and process.env stay in the callers, which hand over plain values. */\n\n/**\n * The siteId of a bearer's client_id claim (`<n>|<siteId>`): the text after the first \"|\", when\n * there is one and it is non-empty. The prefix is not checked.\n *\n * @ensures exactly the model's ClientIdSiteId on a string claim\n */\nexport function clientIdSiteIdOf(clientId: string): string | null {\n //@ verify\n //@ ensures indexOfCode(clientId, 124, 0) < 0 ==> \\result === null\n //@ ensures indexOfCode(clientId, 124, 0) >= 0 && indexOfCode(clientId, 124, 0) + 1 >= clientId.length ==> \\result === null\n //@ ensures indexOfCode(clientId, 124, 0) >= 0 && indexOfCode(clientId, 124, 0) + 1 < clientId.length ==> \\result === clientId.slice(indexOfCode(clientId, 124, 0) + 1)\n const k = indexOfCode(clientId, 124, 0);\n if (k < 0) return null;\n if (k + 1 >= clientId.length) return null;\n return clientId.slice(k + 1);\n}\n\n/** A session's siteId and bearer token, as minted, or refused. */\nexport type Mint = { kind: \"minted\"; siteId: string; token: string } | { kind: \"refused\" };\n\n/**\n * getSessionCredentials' mint, once the secret and the decoded session are in hand: a valid\n * siteId (augur-api's `isSiteId`, checked by the caller), a non-empty token, and the bearer's\n * client_id siteId (`\"\"` for none: `clientIdSiteIdOf` never gives `\"\"`) equal to it.\n *\n * @ensures exactly the model's MintCredentials with a secret and a decoded session\n */\nexport function mintedCredentials(\n siteIdOk: boolean,\n targetSiteId: string,\n token: string,\n bearerSiteId: string,\n): Mint {\n //@ verify\n //@ ensures siteIdOk && token !== \"\" && bearerSiteId !== \"\" && bearerSiteId === targetSiteId ==> \\result.kind === \"minted\" && \\result.siteId === targetSiteId && \\result.token === token\n //@ ensures !(siteIdOk && token !== \"\" && bearerSiteId !== \"\" && bearerSiteId === targetSiteId) ==> \\result.kind === \"refused\"\n if (!siteIdOk || token === \"\" || bearerSiteId === \"\" || bearerSiteId !== targetSiteId) {\n return { kind: \"refused\" };\n }\n return { kind: \"minted\", siteId: targetSiteId, token };\n}\n\n/**\n * Whether there is another page: from the total when one is given, else a full page.\n *\n * @ensures exactly the model's HasMore\n */\nexport function hasMoreOf(\n page: number,\n limit: number,\n total: number | undefined,\n itemCount: number,\n): boolean {\n //@ verify\n //@ ensures total !== undefined ==> \\result === ((page + 1) * limit < total)\n //@ ensures total === undefined ==> \\result === (itemCount === limit)\n if (total !== undefined) return (page + 1) * limit < total;\n return itemCount === limit;\n}\n\n/**\n * The next page's cursor: page + 1 while there is more.\n *\n * @ensures exactly the model's NextCursor given HasMore\n */\nexport function nextCursorOf(hasMore: boolean, page: number): number | undefined {\n //@ verify\n //@ ensures hasMore ==> \\result === page + 1\n //@ ensures !hasMore ==> \\result === undefined\n if (hasMore) return page + 1;\n return undefined;\n}\n\n/** The deployment environment. */\nexport type Env = \"development\" | \"staging\" | \"production\";\n\n/**\n * DEPLOYMENT_ENV first; then the server's NODE_ENV; then the browser's host (substring). A missing\n * variable is \"\".\n *\n * @ensures exactly the model's EnvOf\n */\nexport function envOf(\n deploymentEnv: string,\n isServer: boolean,\n nodeEnv: string,\n host: string,\n): Env {\n //@ verify\n //@ ensures deploymentEnv === \"dev\" ==> \\result === \"staging\"\n //@ ensures deploymentEnv !== \"dev\" && deploymentEnv === \"live\" ==> \\result === \"production\"\n //@ ensures deploymentEnv !== \"dev\" && deploymentEnv !== \"live\" && isServer ==> \\result === serverEnvOf(nodeEnv)\n //@ ensures deploymentEnv !== \"dev\" && deploymentEnv !== \"live\" && !isServer ==> \\result === hostEnvOf(host)\n if (deploymentEnv === \"dev\") return \"staging\";\n if (deploymentEnv === \"live\") return \"production\";\n if (isServer) return serverEnvOf(nodeEnv);\n return hostEnvOf(host);\n}\n\n/**\n * On the server: development only for NODE_ENV \"development\".\n *\n * @ensures result = development ⟺ nodeEnv = \"development\", else production\n */\nexport function serverEnvOf(nodeEnv: string): Env {\n //@ verify\n //@ ensures nodeEnv === \"development\" ==> \\result === \"development\"\n //@ ensures nodeEnv !== \"development\" ==> \\result === \"production\"\n return nodeEnv === \"development\" ? \"development\" : \"production\";\n}\n\n/**\n * In the browser: localhost or 127.0.0.1 anywhere in the host is development, agr-hosting.dev\n * staging, anything else production.\n *\n * @ensures exactly the model's host rule\n */\nexport function hostEnvOf(host: string): Env {\n //@ verify\n //@ ensures (includesFrom(host, \"localhost\", 0) || includesFrom(host, \"127.0.0.1\", 0)) ==> \\result === \"development\"\n //@ ensures !(includesFrom(host, \"localhost\", 0) || includesFrom(host, \"127.0.0.1\", 0)) && includesFrom(host, \"agr-hosting.dev\", 0) ==> \\result === \"staging\"\n //@ ensures !(includesFrom(host, \"localhost\", 0) || includesFrom(host, \"127.0.0.1\", 0)) && !includesFrom(host, \"agr-hosting.dev\", 0) ==> \\result === \"production\"\n if (includesFrom(host, \"localhost\", 0) || includesFrom(host, \"127.0.0.1\", 0))\n return \"development\";\n if (includesFrom(host, \"agr-hosting.dev\", 0)) return \"staging\";\n return \"production\";\n}\n\n/**\n * The API route's outcome for a request: \"run\" answers queryAction's data, \"run-full\"\n * queryActionRaw's full response (atlas#107).\n */\nexport type ApiOutcome =\n \"forbidden\" | \"bad-json\" | \"bad-method-path\" | \"bad-args\" | \"run\" | \"run-full\";\n\n/**\n * A present, non-empty Sec-Fetch-Site other than same-origin is refused (a missing one, `\"\"`\n * from the caller, passes).\n *\n * @ensures result ⟺ fetchSite ∉ {\"\", \"same-origin\"}\n */\nexport function isCrossOrigin(fetchSite: string): boolean {\n //@ verify\n //@ ensures \\result === (fetchSite !== \"\" && fetchSite !== \"same-origin\")\n return fetchSite !== \"\" && fetchSite !== \"same-origin\";\n}\n\n/**\n * The body's outcome: JSON, then a non-empty methodPath string, then an args array; a valid\n * body with `raw: true` (`full`) runs for the full response, any other for its data.\n *\n * @ensures exactly the model's ApiOutcomeOf past the origin check\n */\nexport function bodyOutcomeOf(\n jsonOk: boolean,\n methodPathOk: boolean,\n argsIsArray: boolean,\n full: boolean,\n): ApiOutcome {\n //@ verify\n //@ ensures !jsonOk ==> \\result === \"bad-json\"\n //@ ensures jsonOk && !methodPathOk ==> \\result === \"bad-method-path\"\n //@ ensures jsonOk && methodPathOk && !argsIsArray ==> \\result === \"bad-args\"\n //@ ensures jsonOk && methodPathOk && argsIsArray && full ==> \\result === \"run-full\"\n //@ ensures jsonOk && methodPathOk && argsIsArray && !full ==> \\result === \"run\"\n if (!jsonOk) return \"bad-json\";\n if (!methodPathOk) return \"bad-method-path\";\n if (!argsIsArray) return \"bad-args\";\n if (full) return \"run-full\";\n return \"run\";\n}\n\n/**\n * The route runs the call: either view; any other outcome is a refusal.\n *\n * @ensures exactly the model's Runs\n */\nexport function runsOf(o: ApiOutcome): boolean {\n //@ verify\n //@ ensures \\result === (o === \"run\" || o === \"run-full\")\n return o === \"run\" || o === \"run-full\";\n}\n\n/**\n * The route answers the full response (queryActionRaw), not its data.\n *\n * @ensures exactly the model's AnswersFull\n */\nexport function answersFullOf(o: ApiOutcome): boolean {\n //@ verify\n //@ ensures \\result === (o === \"run-full\")\n return o === \"run-full\";\n}\n\n/**\n * An outcome's HTTP status: 403, 400 for a bad body, 200 to run.\n *\n * @ensures exactly the model's ApiStatus\n */\nexport function apiStatusOf(o: ApiOutcome): number {\n //@ verify\n //@ ensures o === \"forbidden\" ==> \\result === 403\n //@ ensures (o === \"bad-json\" || o === \"bad-method-path\" || o === \"bad-args\") ==> \\result === 400\n //@ ensures (o === \"run\" || o === \"run-full\") ==> \\result === 200\n if (o === \"forbidden\") return 403;\n if (o === \"run\" || o === \"run-full\") return 200;\n return 400;\n}\n\n/**\n * A refusal's response text (\"\" to run).\n *\n * @ensures each refusal has its fixed text\n */\nexport function apiMessageOf(o: ApiOutcome): string {\n //@ verify\n //@ ensures o === \"forbidden\" ==> \\result === \"Forbidden: cross-origin requests not allowed\"\n //@ ensures o === \"bad-json\" ==> \\result === \"Invalid JSON body\"\n //@ ensures o === \"bad-method-path\" ==> \\result === \"Missing or invalid methodPath\"\n //@ ensures o === \"bad-args\" ==> \\result === \"Missing or invalid args array\"\n //@ ensures (o === \"run\" || o === \"run-full\") ==> \\result === \"\"\n if (o === \"forbidden\") return \"Forbidden: cross-origin requests not allowed\";\n if (o === \"bad-json\") return \"Invalid JSON body\";\n if (o === \"bad-method-path\") return \"Missing or invalid methodPath\";\n if (o === \"bad-args\") return \"Missing or invalid args array\";\n return \"\";\n}\n\n/**\n * The Redis TTL for a cache tier: none for staleTime 0, the long TTL from an hour up, else the\n * standard one. `staleTime` is React Query's `Millis`, the TTLs Redis's `Seconds`; the hour is\n * compared in milliseconds.\n *\n * @ensures exactly the model's TtlFor\n */\nexport function ttlFor(\n staleTime: Millis,\n redisTtl: Seconds,\n longRedisTtl: Seconds,\n): Seconds | null {\n //@ verify\n //@ ensures staleTime === 0 ==> \\result === null\n //@ ensures staleTime !== 0 && staleTime >= 3600000 ==> \\result === longRedisTtl\n //@ ensures staleTime !== 0 && staleTime < 3600000 ==> \\result === redisTtl\n if (staleTime === 0) return null;\n if (staleTime >= toMillis(hours(1))) return longRedisTtl;\n return redisTtl;\n}\n\n/** The Redis circuit breaker's state: consecutive failures, and when it closes (0 = closed). */\nexport interface Circuit {\n failures: number;\n openUntil: Millis;\n}\n\n/** The circuit's answer at a time: whether it is open, and its state after the check. */\nexport interface CircuitAnswer {\n open: boolean;\n next: Circuit;\n}\n\n/**\n * isCircuitOpen at `now`: closed at openUntil 0; past it, reset and closed; else open.\n *\n * @ensures exactly the model's CircuitCheck\n */\nexport function circuitCheck(c: Circuit, now: Millis): CircuitAnswer {\n //@ verify\n //@ ensures c.openUntil === 0 ==> !\\result.open && \\result.next === c\n //@ ensures c.openUntil !== 0 && now >= c.openUntil ==> !\\result.open && \\result.next.failures === 0 && \\result.next.openUntil === 0\n //@ ensures c.openUntil !== 0 && now < c.openUntil ==> \\result.open && \\result.next === c\n if (c.openUntil === 0) return { open: false, next: c };\n if (now >= c.openUntil) return { open: false, next: { failures: 0, openUntil: millis(0) } };\n return { open: true, next: c };\n}\n\n/**\n * Whether a failure count opens the circuit: five in a row.\n *\n * @ensures result ⟺ failures ≥ 5\n */\nexport function opensAt(failures: number): boolean {\n //@ verify\n //@ ensures \\result === (failures >= 5)\n return failures >= 5;\n}\n\n/**\n * A failure counts; from the threshold on the circuit opens for a minute from now.\n *\n * @ensures exactly the model's RecordFailure\n */\nexport function recordFailureOf(c: Circuit, now: Millis): Circuit {\n //@ verify\n //@ ensures \\result.failures === c.failures + 1\n //@ ensures opensAt(c.failures + 1) ==> \\result.openUntil === now + 60000\n //@ ensures !opensAt(c.failures + 1) ==> \\result.openUntil === c.openUntil\n const failures = c.failures + 1;\n if (opensAt(failures)) return { failures, openUntil: addMillis(now, toMillis(minutes(1))) };\n return { failures, openUntil: c.openUntil };\n}\n\n/**\n * A success clears the failure count and leaves openUntil.\n *\n * @ensures exactly the model's RecordSuccess\n */\nexport function recordSuccessOf(c: Circuit): Circuit {\n //@ verify\n //@ ensures \\result.failures === 0 && \\result.openUntil === c.openUntil\n return { failures: 0, openUntil: c.openUntil };\n}\n\n/**\n * authorize's verified flag: exactly the text \"true\".\n *\n * @ensures result ⟺ s = \"true\"\n */\nexport function verifiedFlag(s: string): boolean {\n //@ verify\n //@ ensures \\result === (s === \"true\")\n return s === \"true\";\n}\n\n/**\n * reCAPTCHA passes only with a secret, an ok response and the reply's optional `success` exactly\n * true (the score is not read).\n *\n * @ensures exactly the model's RecaptchaOk, success read as `=== true`\n */\nexport function recaptchaOk(\n hasSecret: boolean,\n httpOk: boolean,\n success: boolean | undefined,\n): boolean {\n //@ verify\n //@ ensures \\result === (hasSecret && httpOk && success === true)\n return hasSecret && httpOk && success === true;\n}\n\n/**\n * Whether the session's cart header is looked up: a lookup to call, the user's id and a usable\n * customer (`customerId`, resolved by augur-utils `resolveAddressId`; null when none is), so no\n * cart is ever looked up for customer 0 (atlas#95).\n *\n * @ensures exactly the model's CartLookupRuns, a customer being customerId ≠ null\n */\nexport function cartLookupRuns(\n hasLookup: boolean,\n hasUserId: boolean,\n customerId: AddressId | null,\n): boolean {\n //@ verify\n //@ ensures \\result === (hasLookup && hasUserId && customerId !== null)\n return hasLookup && hasUserId && customerId !== null;\n}\n\n/**\n * Why a call scoped to one customer is refused: the caller's `refusal` when no usable customer\n * resolved (`customerId` null), else null and the call is asked (atlas#95). Pricing (a price, a\n * tax estimate, a whole batch, refused once before any item) and the customers actions use it,\n * so none is ever asked for customer 0.\n *\n * @ensures exactly the model's CustomerRefusal\n */\nexport function customerRefusalOf(customerId: AddressId | null, refusal: string): string | null {\n //@ verify\n //@ ensures \\result === (customerId === null ? refusal : null)\n return customerId === null ? refusal : null;\n}\n\n/**\n * The category page size: 24 when none (or 0) is given.\n *\n * @ensures exactly the model's ItemsLimit, a missing limit as 0\n */\nexport function itemsLimitOf(limit: number | undefined): number {\n //@ verify\n //@ ensures (limit === undefined || limit === 0) ==> \\result === 24\n //@ ensures limit !== undefined && limit !== 0 ==> \\result === limit\n if (limit === undefined) return 24;\n if (limit === 0) return 24;\n return limit;\n}\n\n/**\n * The cross-site opt-in as configured (`auth.crossSite`): on only when set to true, so a site\n * that says nothing stays off (atlas#105).\n *\n * @ensures exactly the model's CrossSiteOf\n */\nexport function crossSiteOf(flag: boolean | undefined): boolean {\n //@ verify\n //@ ensures \\result === (flag === true)\n return flag === true;\n}\n\n/**\n * Whether queryAction looks for a cross-site session (imports next/headers and reads the\n * cookie): only on a site that opted in and has a secret. Every other site never reads cookies\n * here, so its pages can render statically (atlas#105).\n *\n * @ensures exactly the model's ReadsSession\n */\nexport function readsSession(crossSite: boolean, hasSecret: boolean): boolean {\n //@ verify\n //@ ensures \\result === (crossSite && hasSecret)\n return crossSite && hasSecret;\n}\n\n/**\n * The target siteId authorize writes into the session: the sign-in's `siteId` only on an\n * opted-in site, and only when it is not empty (atlas#105).\n *\n * @ensures exactly the model's SignInTarget\n */\nexport function signInTarget(crossSite: boolean, siteId: string | undefined): string | undefined {\n //@ verify\n //@ ensures !crossSite ==> \\result === undefined\n //@ ensures crossSite && siteId === undefined ==> \\result === undefined\n //@ ensures crossSite && siteId !== undefined && siteId === \"\" ==> \\result === undefined\n //@ ensures crossSite && siteId !== undefined && siteId !== \"\" ==> \\result === siteId\n if (!crossSite) return undefined;\n if (siteId === undefined) return undefined;\n if (siteId === \"\") return undefined;\n return siteId;\n}\n\n/** How queryAction resolves its client. */\nexport type Resolution = \"scoped\" | \"global\" | \"uninit\";\n\n/**\n * resolveClient: scoped when credentials minted and a scoped client was made; else the global\n * client when one is registered (also for a valid session without a factory); else none.\n *\n * @ensures exactly the model's ResolveClient\n */\nexport function resolutionOf(minted: boolean, scopedMade: boolean, hasGlobal: boolean): Resolution {\n //@ verify\n //@ ensures minted && scopedMade ==> \\result === \"scoped\"\n //@ ensures !(minted && scopedMade) && hasGlobal ==> \\result === \"global\"\n //@ ensures !(minted && scopedMade) && !hasGlobal ==> \\result === \"uninit\"\n if (minted && scopedMade) return \"scoped\";\n return hasGlobal ? \"global\" : \"uninit\";\n}\n\n/** The scoped-client slot's decision. */\nexport type SlotDecision = \"hit\" | \"mint\" | \"no-client\";\n\n/**\n * getOrCreateScopedClient's single slot: a hit when it holds this key; else a new client when a\n * factory is registered; else none. An empty slot is \"\" at the caller, which no key equals (a\n * key holds a NUL).\n *\n * @ensures exactly the model's SlotDecisionOf\n */\nexport function slotDecisionOf(slotKey: string, key: string, hasFactory: boolean): SlotDecision {\n //@ verify\n //@ ensures slotKey === key ==> \\result === \"hit\"\n //@ ensures slotKey !== key && hasFactory ==> \\result === \"mint\"\n //@ ensures slotKey !== key && !hasFactory ==> \\result === \"no-client\"\n if (slotKey === key) return \"hit\";\n return hasFactory ? \"mint\" : \"no-client\";\n}\n\n/**\n * parseMethodPath: a non-empty path, in the allowlist when one is registered (permissive by\n * default); `listed` is the caller's Set lookup.\n *\n * @ensures exactly the model's ApprovePath\n */\nexport function approvePath(path: string, hasAllowlist: boolean, listed: boolean): boolean {\n //@ verify\n //@ ensures \\result === (path !== \"\" && (!hasAllowlist || listed))\n return path !== \"\" && (!hasAllowlist || listed);\n}\n\n/**\n * queryAction caches a call only through a wrapper, and only for a read leaf (augur-core's\n * `isReadMethod`, checked by the caller).\n *\n * @ensures exactly the model's UsesCache\n */\nexport function usesCache(hasWrapper: boolean, isRead: boolean): boolean {\n //@ verify\n //@ ensures \\result === (hasWrapper && isRead)\n return hasWrapper && isRead;\n}\n\n/**\n * The Auth.js session cookie decodeSessionJwt reads, and the salt it decodes with: the HTTPS\n * cookie when the request has one, else the plain one.\n *\n * @ensures exactly the model's SessionCookieName\n */\nexport function sessionCookieName(hasSecure: boolean): string {\n //@ verify\n //@ ensures hasSecure ==> \\result === \"__Secure-authjs.session-token\"\n //@ ensures !hasSecure ==> \\result === \"authjs.session-token\"\n return hasSecure ? \"__Secure-authjs.session-token\" : \"authjs.session-token\";\n}\n\n/** Which client a bounded call runs on (atlas#106). */\nexport type ClientChoice = \"client\" | \"view\" | \"refuse\";\n\n/**\n * queryActionWith's client: today's client with no options; else the client's `withRequest`\n * view, refused when the client has none (a call asked to be bounded never runs unbounded).\n *\n * @ensures exactly the model's ClientFor\n */\nexport function clientFor(hasOptions: boolean, hasWithRequest: boolean): ClientChoice {\n //@ verify\n //@ ensures !hasOptions ==> \\result === \"client\"\n //@ ensures hasOptions && hasWithRequest ==> \\result === \"view\"\n //@ ensures hasOptions && !hasWithRequest ==> \\result === \"refuse\"\n if (!hasOptions) return \"client\";\n return hasWithRequest ? \"view\" : \"refuse\";\n}\n\n/**\n * The scoped cache prefix: the session's siteId and \":\".\n *\n * @ensures exactly the model's ScopedPrefix\n */\nexport function scopedPrefix(siteId: string): string {\n //@ verify\n //@ ensures \\result === siteId + \":\"\n return siteId + \":\";\n}\n\n/**\n * withServerCache caches when the TTL is not 0 (missing or NaN is 0 at the caller; a `Seconds`\n * is never negative).\n *\n * @ensures exactly the model's ShouldCache\n */\nexport function shouldCache(ttl: Seconds): boolean {\n //@ verify\n //@ ensures \\result === (ttl !== 0)\n return ttl !== 0;\n}\n\n/**\n * The TTL a server cache call uses: a missing one (undefined or NaN, which the caller reads) is 0,\n * as `!redisTtl` had it.\n *\n * @ensures exactly the model's CacheTtl\n */\nexport function cacheTtlOf(missing: boolean, ttl: Seconds): Seconds {\n //@ verify\n //@ ensures \\result === (missing ? 0 : ttl)\n return missing ? seconds(0) : ttl;\n}\n\n/**\n * getInvMastDoc's positional uid: kept above 0, else none.\n *\n * @ensures result = uid when uid > 0, else undefined\n */\nexport function docUidOf(uid: number): number | undefined {\n //@ verify\n //@ ensures uid > 0 ==> \\result === uid\n //@ ensures uid <= 0 ==> \\result === undefined\n if (uid > 0) return uid;\n return undefined;\n}\n\n/**\n * The positional itemId is used only at uid 0 and when non-empty (\"\" for none, at the caller).\n *\n * @ensures result ⟺ uid = 0 ∧ itemId ≠ \"\"\n */\nexport function takesItemId(uid: number, itemId: string): boolean {\n //@ verify\n //@ ensures \\result === (uid === 0 && itemId !== \"\")\n return uid === 0 && itemId !== \"\";\n}\n\n/**\n * A doc call needs a uid (truthy at the caller) or a non-empty itemId.\n *\n * @ensures result ⟺ uidSet ∨ itemId ≠ \"\"\n */\nexport function hasDocKey(uidSet: boolean, itemId: string): boolean {\n //@ verify\n //@ ensures \\result === (uidSet || itemId !== \"\")\n return uidSet || itemId !== \"\";\n}\n\n/**\n * The configured payments mode, \"live\" by default.\n *\n * @ensures result = configured ?? \"live\"\n */\nexport function configuredModeOf(configured: string | undefined): string {\n //@ verify\n //@ ensures configured === undefined ==> \\result === \"live\"\n //@ ensures configured !== undefined ==> \\result === configured\n if (configured === undefined) return \"live\";\n return configured;\n}\n","//@ backend dafny\n\n/* Cache key for the per-request scoped SDK client (`sdk-client-store.ts`\n `getOrCreateScopedClient`). Verified with LemmaScript → Dafny (`pnpm proofs`; model:\n models/AugurServer.dfy `ScopedClientKey`, whose `ScopedClientKeyInjective` proves that for two\n siteIds with no NUL character, equal keys mean equal siteIds AND equal tokens, so two\n credential pairs never share a cached client; link:\n models/links/augur-server-scoped-client-key.dfy). Only the siteId needs to be NUL-free; the\n token may contain anything. Not proved: that every siteId reaching this function is NUL-free.\n That rests on `getSessionCredentials` (query-action.ts), the only mint point, refusing any\n siteId that fails augur-api's `isSiteId` (`[a-z0-9_-]+`, proved in augur-api), which is\n tested. */\n\n/** Character code of the separator; no siteId contains it. */\nconst SEPARATOR_CODE = 0;\n\n/** `siteId` has no NUL character, so the first NUL in a key marks where the siteId ends. */\nfunction hasNoSeparator(siteId: string): boolean {\n //@ verify\n //@ ensures \\result === !siteId.includes(String.fromCharCode(0))\n return !siteId.includes(String.fromCharCode(SEPARATOR_CODE));\n}\n\n/** The key `siteId + \"\\0\" + token`, or null (the refusal) when the siteId has a NUL. */\nfunction scopedClientKeyOf(siteId: string, token: string): string | null {\n //@ verify\n //@ ensures hasNoSeparator(siteId) ==> \\result === siteId + String.fromCharCode(0) + token\n //@ ensures !hasNoSeparator(siteId) ==> \\result === null\n if (!hasNoSeparator(siteId)) return null;\n return siteId + String.fromCharCode(SEPARATOR_CODE) + token;\n}\n\n/**\n * The key `siteId + \"\\0\" + token`. Callers MUST pass a siteId with no NUL character\n * (`getSessionCredentials` enforces `isSiteId`); with that, distinct pairs give distinct keys.\n * A siteId with a NUL throws instead of returning a key that could collide.\n *\n * @throws TypeError when `siteId` contains a NUL character\n */\nexport function scopedClientKey(siteId: string, token: string): string {\n const key = scopedClientKeyOf(siteId, token);\n if (key === null) {\n throw new TypeError(\"scopedClientKey: siteId must not contain a NUL character\");\n }\n return key;\n}\n","/**\n * Lightweight getter/setter for the raw SDK client instance, cache wrapper,\n * auth secret, client factory, and scoped client cache.\n *\n * queryAction resolves method paths on the SDK client directly (not on\n * SiteActions). This ensures the proxy pattern works end-to-end: the\n * proxy generates SDK namespace paths (e.g. \"pricing.priceEngine.get\")\n * which match the SDK client structure.\n *\n * The cache wrapper is a function registered by createServerSite() that\n * wraps SDK calls with Redis caching. It captures withServerCache + config\n * in its closure, so queryAction can use it without importing heavy deps.\n *\n * The auth secret, client factory, and scoped cache wrapper support\n * per-request session credentials for multi-tenant apps. queryAction\n * decodes the JWT from request cookies and creates scoped SDK clients\n * when the session contains a targetSiteId + token.\n *\n * This module has ZERO imports from actions/site, cache/, or any factory.\n * Same isolation constraints as site-actions-store.ts.\n */\n\nimport { approvePath, slotDecisionOf } from \"./rules\";\nimport { scopedClientKey } from \"./scoped-client-key\";\n\n/** Function that wraps an SDK call with server-side caching. */\nexport type SdkCallWrapper = (\n methodPath: string,\n sdkCall: () => Promise<unknown>,\n ...keyArgs: unknown[]\n) => Promise<unknown>;\n\n/** Function that wraps an SDK call with server-side caching using a specific prefix. */\nexport type ScopedCacheWrapper = (\n prefix: string,\n methodPath: string,\n sdkCall: () => Promise<unknown>,\n ...keyArgs: unknown[]\n) => Promise<unknown>;\n\n/** Function that creates a scoped SDK client with different credentials. */\nexport type ClientFactory = (siteId: string, bearerToken: string) => unknown;\n\ndeclare const SessionSiteIdBrand: unique symbol;\ndeclare const SessionBearerTokenBrand: unique symbol;\ndeclare const SessionCredentialsBrand: unique symbol;\ndeclare const ApprovedMethodPathBrand: unique symbol;\n\n/**\n * Site identifier extracted from a validated Auth.js session JWT cookie.\n *\n * Intended to be minted only by `getSessionCredentials` in query-action.ts.\n *\n * Brand strength: code-review signal, not type-system enforcement. TypeScript\n * allows `value as SessionSiteId` casts, so audit `as SessionSiteId` usages\n * to catch unintended mints — there should be exactly one, at the JWT mint\n * point.\n */\nexport type SessionSiteId = string & { readonly [SessionSiteIdBrand]: true };\n\n/**\n * Bearer token extracted from a validated Auth.js session JWT cookie.\n * Same intended-mint and brand-strength caveat as {@link SessionSiteId}.\n */\nexport type SessionBearerToken = string & { readonly [SessionBearerTokenBrand]: true };\n\n/**\n * Paired session credentials. Bundles `siteId` and `token` from the same\n * validated session into one value so downstream functions can accept the\n * pair as a unit, instead of two separate parameters that callers might\n * accidentally mix across sessions.\n *\n * Intended to be minted only by `getSessionCredentials` in query-action.ts,\n * which performs the cross-check that the bearer's `client_id` siteId\n * matches `targetSiteId`. Anything that holds a `SessionCredentials` *was*\n * cross-checked at mint time — provided the value came through that mint\n * and not via a cast.\n *\n * Brand strength: same code-review signal as the field brands. `value as\n * SessionCredentials` compiles. Audit `as SessionCredentials` usages — there\n * should be exactly one, in `getSessionCredentials`.\n */\nexport type SessionCredentials = {\n readonly siteId: SessionSiteId;\n readonly token: SessionBearerToken;\n readonly [SessionCredentialsBrand]: true;\n};\n\n/**\n * SDK method path validated against the registered allowlist.\n *\n * Intended to be minted only by `parseMethodPath` below. Functions that walk\n * the path into the SDK client (notably `resolveMethod`) demand this type\n * so that an unvalidated string flowing into the walker is a compile error\n * for code that respects the convention.\n *\n * Brand strength: code-review signal. `value as ApprovedMethodPath` compiles.\n * Audit `as ApprovedMethodPath` usages — there should be one, in\n * `parseMethodPath`.\n *\n * Scope of validation: this is a *site-level surface restriction*, not a\n * security boundary. augur-api is the auth authority; the allowlist limits\n * what the application's proxy will forward to the SDK, not what tokens are\n * permitted to do. Useful for narrowing same-origin attack surface (XSS,\n * malicious bundled deps); not a substitute for API-level authorization.\n */\nexport type ApprovedMethodPath = string & { readonly [ApprovedMethodPathBrand]: true };\n\nconst g = globalThis as unknown as {\n __augur_sdk_client?: unknown;\n __augur_sdk_call_wrapper?: SdkCallWrapper;\n __augur_auth_secret?: string;\n __augur_cross_site?: boolean;\n __augur_client_factory?: ClientFactory;\n __augur_scoped_cache_wrapper?: ScopedCacheWrapper;\n __augur_allowed_method_paths?: Set<string>;\n};\n\nlet _cachedClient: unknown = null;\nlet _cachedWrapper: SdkCallWrapper | null = null;\nlet _cachedAuthSecret: string | null = null;\nlet _cachedCrossSite = false;\nlet _cachedClientFactory: ClientFactory | null = null;\nlet _cachedScopedCacheWrapper: ScopedCacheWrapper | null = null;\nlet _scopedClient: { key: string; client: unknown } | null = null;\nlet _allowedMethodPaths: Set<string> | null = null;\n\n/** Register the raw SDK client instance. Called by createServerSite(). */\nexport function registerSdkClient(client: unknown): void {\n _cachedClient = client;\n g.__augur_sdk_client = client;\n}\n\n/** Returns the registered SDK client, or null if not yet registered. */\nexport function getSdkClientOrNull(): unknown {\n const client = g.__augur_sdk_client ?? _cachedClient;\n if (client) {\n if (!g.__augur_sdk_client) {\n g.__augur_sdk_client = client;\n }\n return client;\n }\n return null;\n}\n\n/**\n * Register a cache wrapper for SDK calls. Called by createServerSite().\n * The wrapper captures withServerCache + config in its closure so that\n * queryAction can use Redis caching without importing heavy deps.\n */\nexport function registerSdkCallWrapper(wrapper: SdkCallWrapper): void {\n _cachedWrapper = wrapper;\n g.__augur_sdk_call_wrapper = wrapper;\n}\n\n/** Returns the registered cache wrapper, or null if not registered. */\nexport function getSdkCallWrapper(): SdkCallWrapper | null {\n return g.__augur_sdk_call_wrapper ?? _cachedWrapper ?? null;\n}\n\n/** Register the auth secret for JWT decoding. Called by createServerSite(). */\nexport function registerAuthSecret(secret: string): void {\n _cachedAuthSecret = secret;\n g.__augur_auth_secret = secret;\n}\n\n/** Returns the registered auth secret, or null if not registered. */\nexport function getAuthSecret(): string | null {\n return g.__augur_auth_secret ?? _cachedAuthSecret ?? null;\n}\n\n/**\n * Register the cross-site opt-in (`auth.crossSite`, through rules.crossSiteOf). Called by\n * createServerSite(). The ONE source both queryAction's session read and authorize's sign-in\n * target read (models/AugurServer.dfy, \"the cross-site opt-in\", atlas#105).\n */\nexport function registerCrossSite(on: boolean): void {\n _cachedCrossSite = on;\n g.__augur_cross_site = on;\n}\n\n/** Whether this site opted in to cross-site sessions; false unless registered. */\nexport function getCrossSite(): boolean {\n return g.__augur_cross_site ?? _cachedCrossSite;\n}\n\n/** Register a factory that creates scoped SDK clients. Called by createServerSite(). */\nexport function registerClientFactory(factory: ClientFactory): void {\n _cachedClientFactory = factory;\n g.__augur_client_factory = factory;\n}\n\n/** Returns the registered client factory, or null if not registered. */\nexport function getClientFactory(): ClientFactory | null {\n return g.__augur_client_factory ?? _cachedClientFactory ?? null;\n}\n\n/** Register a scoped cache wrapper that accepts a prefix. Called by createServerSite(). */\nexport function registerScopedCacheWrapper(wrapper: ScopedCacheWrapper): void {\n _cachedScopedCacheWrapper = wrapper;\n g.__augur_scoped_cache_wrapper = wrapper;\n}\n\n/** Returns the registered scoped cache wrapper, or null if not registered. */\nexport function getScopedCacheWrapper(): ScopedCacheWrapper | null {\n return g.__augur_scoped_cache_wrapper ?? _cachedScopedCacheWrapper ?? null;\n}\n\n/**\n * Returns a cached scoped client for the given credentials, or creates one\n * via the registered factory. Caches the last credential pair so that\n * multiple queryAction calls in the same request reuse the same client.\n *\n * Accepts `SessionCredentials` (a branded paired type) rather than two raw\n * strings: well-behaved callers pass the pair as a unit, eliminating the\n * \"siteId from session A combined with token from session B\" mistake at\n * the type level — see {@link SessionCredentials} brand-strength caveat.\n * The factory itself still receives strings (its signature is user-facing API).\n *\n * ## Trust\n *\n * @trusted credentials // the SessionCredentials brand carries the\n * // bearer/session siteId cross-check discharged at\n * // mint time by `getSessionCredentials`. This\n * // function does NOT re-validate; if a non-mint\n * // path produces a SessionCredentials value (via\n * // `as` cast), this function will materialise a\n * // client for whatever siteId + token are present\n * // in the value. Audit `as SessionCredentials`\n * // usages — there should be exactly one, in\n * // getSessionCredentials.\n *\n * ## Decision (Property)\n *\n * let key = `${credentials.siteId}\\0${credentials.token}` in\n * result(credentials) =\n * _scopedClient.client when _scopedClient?.key = key // cache hit\n * factory(siteId, token) when factory ≠ null // mint + cache\n * null when factory = null // uninitialised\n *\n * Three outcomes. Throws only if `credentials.siteId` contains a NUL\n * (`scopedClientKey`), which the mint point rules out by `isSiteId`, so it\n * is reachable only through an `as SessionCredentials` cast. Side effect on\n * the mint path only:\n * `_scopedClient` is replaced with `{key, client}` so the next call with\n * the same credentials hits the cached branch. Minting implicitly evicts\n * the previous `_scopedClient` value (single-slot semantics — see invariant).\n *\n * ## Invariant — null-byte key separator (machine-checked)\n *\n * The key is `scopedClientKey(siteId, token)` = `siteId + \"\\0\" + token`\n * (`scoped-client-key.ts`). Dafny proves (`ScopedClientKeyInjective`) that\n * for two NUL-free siteIds, equal keys mean equal siteIds and equal tokens,\n * so the cache cannot hand one credential pair another pair's client. Only\n * the siteId has to be NUL-free; the token may contain anything.\n *\n * The precondition is enforced, not assumed: `getSessionCredentials`, the\n * only mint point, refuses any `targetSiteId` that fails augur-api's\n * `isSiteId` (`[a-z0-9_-]+`, machine-checked in augur-api), and\n * `scopedClientKey` throws on a NUL rather than return a key that could\n * collide. What is NOT proved: that no other code path casts a value to\n * `SessionCredentials` (see the Trust note above).\n *\n * Do NOT change the separator to a character that could appear in a\n * siteId; the proof is stated for NUL and would have to be redone.\n *\n * ## Invariant — single-slot cache (eviction is implicit)\n *\n * `_scopedClient` holds at most one entry. Minting a client for\n * credentials A AFTER credentials B were cached evicts B unrecoverably;\n * a later request with credentials B will call the factory again rather\n * than retrieving the previously-minted client.\n *\n * This is intentional. Scoped clients are per-request shortcuts; the\n * cache exists to let multiple queryAction calls within a single request\n * share an SDK client without re-running the factory. Cross-request\n * caching is NOT a goal — Next.js may or may not preserve module state\n * across invocations, so any retention beyond the single slot is\n * best-effort and MUST NOT be relied upon for correctness.\n *\n * A future refactor to multi-slot LRU would change this contract:\n * per-credential client identity becomes ambiguous across requests, and\n * eviction policy becomes security-relevant (e.g. oldest-out could re-mint\n * a client immediately after a credential rotation, surfacing stale\n * permissions to the next caller). Do not multi-slot this without\n * re-deriving the contract — particularly the relationship to credential\n * rotation and bearer-token revocation in augur-api.\n *\n * ## Postcondition — identity, not transformation\n *\n * result ≠ null ⟹ result is referentially identical to the value the\n * factory returned for the matching credentials.\n *\n * The cache stores and serves the factory's exact return value. It does\n * not wrap, transform, proxy, or copy the client. Consumers that mutate\n * the returned client (e.g. setting per-request properties on a singleton\n * field) will observe the mutation on subsequent cache hits within the\n * same request — by design.\n */\nexport function getOrCreateScopedClient(credentials: SessionCredentials): unknown {\n const { siteId, token } = credentials;\n const key = scopedClientKey(siteId, token);\n const factory = g.__augur_client_factory ?? _cachedClientFactory;\n const decision = slotDecisionOf(_scopedClient?.key ?? \"\", key, !!factory);\n if (decision === \"hit\") return _scopedClient!.client;\n if (decision === \"no-client\") return null;\n\n const client = factory!(siteId, token);\n _scopedClient = { key, client };\n return client;\n}\n\n/**\n * Register one or more SDK method paths the application is permitted to call\n * through `queryAction`. Subsequent calls accumulate (idempotent on repeats).\n *\n * This is *site-level surface restriction*, not security. augur-api remains\n * the auth authority; this primitive lets a site narrow its proxy's surface\n * to the methods its UI actually wires up. Useful as defense-in-depth against\n * same-origin XSS or compromised bundled deps POSTing arbitrary methodPaths\n * to `/api/augur` — those calls will hit augur-api with the user's bearer\n * (which augur-api will allow if the bearer is authorized), but the allowlist\n * stops them from leaving the proxy in the first place.\n *\n * Permissive default: if `registerAllowedMethodPaths` is never called, all\n * non-empty paths pass — the proxy behaves as a transparent forwarder, which\n * is the package's design intent. Sites that want surface restriction opt in\n * by calling this function.\n */\nexport function registerAllowedMethodPaths(paths: readonly string[]): void {\n if (_allowedMethodPaths === null) {\n _allowedMethodPaths = new Set();\n g.__augur_allowed_method_paths = _allowedMethodPaths;\n }\n for (const p of paths) _allowedMethodPaths.add(p);\n}\n\n/**\n * Returns true if the application has registered an allowlist via\n * {@link registerAllowedMethodPaths}. When false, `parseMethodPath` operates\n * in permissive mode (any non-empty string passes).\n */\nexport function isMethodPathAllowlistRegistered(): boolean {\n return (g.__augur_allowed_method_paths ?? _allowedMethodPaths) !== null;\n}\n\n/**\n * Validate a candidate method path against the registered allowlist.\n *\n * - Returns the branded value if the path is a non-empty string AND\n * (no allowlist is registered OR the path is in the allowlist).\n * - Returns null if the path is not a non-empty string, or if an allowlist\n * has been registered and the path is not in it.\n *\n * The brand on the return type is the only way internal code can produce an\n * `ApprovedMethodPath`. Functions that walk the path into the SDK should\n * accept `ApprovedMethodPath`, forcing the caller to discharge the validation.\n */\nexport function parseMethodPath(candidate: unknown): ApprovedMethodPath | null {\n if (typeof candidate !== \"string\") return null;\n const allowed = g.__augur_allowed_method_paths ?? _allowedMethodPaths;\n const listed = allowed !== null && allowed.has(candidate);\n if (!approvePath(candidate, allowed !== null, listed)) return null;\n return candidate as ApprovedMethodPath;\n}\n\n/** Clears the registered SDK client, wrapper, and session stores. Used in tests only. @internal */\nexport function clearSdkClient(): void {\n _cachedClient = null;\n _cachedWrapper = null;\n _cachedAuthSecret = null;\n _cachedCrossSite = false;\n _cachedClientFactory = null;\n _cachedScopedCacheWrapper = null;\n _scopedClient = null;\n _allowedMethodPaths = null;\n g.__augur_sdk_client = undefined;\n g.__augur_sdk_call_wrapper = undefined;\n g.__augur_auth_secret = undefined;\n g.__augur_cross_site = undefined;\n g.__augur_client_factory = undefined;\n g.__augur_scoped_cache_wrapper = undefined;\n g.__augur_allowed_method_paths = undefined;\n}\n"],"mappings":";;;;;;AA4BO,SAAS,QAAQ,GAAoB;AAK1C,SAAO;AACT;AAOO,SAAS,QAAQ,GAAoB;AAK1C,SAAQ,IAAI;AACd;AAOO,SAAS,MAAM,GAAoB;AAKxC,SAAQ,IAAI;AACd;AAoBO,SAAS,OAAO,GAAmB;AAKxC,SAAO;AACT;AAOO,SAAS,SAAS,GAAoB;AAI3C,SAAQ,IAAI;AACd;AAqBO,SAAS,UAAU,GAAW,GAAmB;AAItD,SAAQ,IAAI;AACd;;;AC3GO,SAAS,aAAa,GAAW,GAAW,GAAoB;AAKrE,WAAS,IAAI,GAAG,MAAM,EAAE,SAAS,GAAG,KAAK;AAIvC,QAAI,aAAa,GAAG,GAAG,CAAC,EAAG,QAAO;AAAA,EACpC;AACA,SAAO;AACT;;;ACZO,SAAS,iBAAiB,UAAiC;AAKhE,QAAM,IAAI,YAAY,UAAU,KAAK,CAAC;AACtC,MAAI,IAAI,EAAG,QAAO;AAClB,MAAI,IAAI,KAAK,SAAS,OAAQ,QAAO;AACrC,SAAO,SAAS,MAAM,IAAI,CAAC;AAC7B;AAYO,SAAS,kBACd,UACA,cACA,OACA,cACM;AAIN,MAAI,CAAC,YAAY,UAAU,MAAM,iBAAiB,MAAM,iBAAiB,cAAc;AACrF,WAAO,EAAE,MAAM,UAAU;AAAA,EAC3B;AACA,SAA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