@wix/himalaya-cli 0.1369.0 → 0.1371.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,9 @@ export interface WixCachePolicy {
11
11
  rules: WixCacheRule[];
12
12
  defaultCacheable: boolean;
13
13
  }
14
+ /** The path a rule's prefix names: itself, or the path of an absolute `https://host/path` prefix
15
+ * (an account-level read a worker makes to a full Wix URL) — so the platform denies apply to it. */
16
+ export declare function rulePath(pathPrefix: string): string;
14
17
  export declare function clampRule(rule: WixCacheRule, denyPrefixes: string[], maxTTL: number): WixCacheRule;
15
18
  /** What an app declares in `defineApp({ cache })`. */
16
19
  export type DeclaredWixCache = AppCacheConfig;
@@ -141,4 +141,122 @@ export declare function wixClientIdOf(appConfigJson: string): {
141
141
  } | {
142
142
  error: "unsupported_auth" | "no_client_id";
143
143
  };
144
+ /** The account-session cookies worth forwarding — `WixNativeAuthProvider.isForwardableWixSessionCookie`
145
+ * (iOS) by name, and the predicate RFC 0071 §3 measured: an instance minted with exactly these works
146
+ * as a plain `Authorization` header, and one minted with a session-BINDING cookie
147
+ * (`server-session-bind`, `bSession`, …) would not. The mint and every forwarded call use this one
148
+ * predicate, so the instance and the call always name the same principal. */
149
+ export declare function isForwardableWixSessionCookie(name: string): boolean;
150
+ /** [cookieHeader] narrowed to the forwardable account-session cookies, or "" when it carries no
151
+ * `wixSession2` (nothing to act as). */
152
+ export declare function forwardableWixSessionCookies(cookieHeader: string | null | undefined): string;
153
+ /** Where an account sign-in starts: Wix's own login (email, Google, Apple, 2FA), back to [postLogin]. */
154
+ export declare function wixAccountSignInUrl(postLogin: string): string;
155
+ /**
156
+ * EVERY endpoint the account session is forwarded to: host, method and exact path, taken from what
157
+ * apps/himi-spaces-lite/{my-sites,join,site-open}.ts call (their header comments cite the RN Spaces
158
+ * sources). An exact path, not a prefix: a prefix on apps.wix.com would hand the account's session to
159
+ * every service mounted under it. Anything else gets no cookie — it is served by the bridge's other
160
+ * rungs, which carry none. tests/webwix-account.test.ts holds this list against those files.
161
+ */
162
+ export declare const ACCOUNT_FORWARD_ALLOWLIST: ReadonlyArray<{
163
+ host: string;
164
+ method: string;
165
+ path: string;
166
+ }>;
167
+ /** The parsed target when [method] [url] is on `ACCOUNT_FORWARD_ALLOWLIST`, else null. https on the
168
+ * default port, no userinfo — the same shape check as `isAllowedConsumerStreamTarget`. */
169
+ export declare function allowedAccountTarget(method: string, url: string): URL | null;
170
+ /** Whether a successful [method] [url] was a join (see `ACCOUNT_JOIN_PATHS`). */
171
+ export declare function isAccountJoinCall(method: string, url: string): boolean;
172
+ /**
173
+ * One allowlisted call as the account: the forwardable session cookies, the XSRF mirror and JSON
174
+ * accept (the recipe `wixOwnerSitesCall` documents), and — for a site-scoped call — the site's Member
175
+ * instance as a raw `Authorization` (RFC 0071 §3: never `Bearer`). Refuses anything off the
176
+ * allowlist, and never follows a redirect: a 3xx is this call's answer, not a hop that would carry
177
+ * the session somewhere else.
178
+ */
179
+ export declare function wixAccountCall(method: string, url: string, body: string | undefined, sessionCookie: string, fetchImpl?: typeof fetch, forwardedHeaders?: Record<string, string>, memberInstance?: string): Promise<WixBridgeEnvelope>;
180
+ /** RFC 0071 §3 — the account is not a member of [metaSiteId]. Raised ONLY by the Member mint (403/404)
181
+ * or its validation, never by a call's own 403. The name is the contract: the bridge answers it as
182
+ * `{"error":"NotSiteMember"}`, which apps/himi-spaces-lite/site-open.ts `isNotSiteMember` reads. */
183
+ export declare class NotSiteMember extends Error {
184
+ readonly metaSiteId: string;
185
+ readonly reason: string;
186
+ readonly code = "NotSiteMember";
187
+ constructor(metaSiteId: string, reason: string);
188
+ }
189
+ /** The account session itself is gone: the Member mint — which authenticates by the session alone —
190
+ * answered 401. Not a membership verdict and not transient: the host must
191
+ * sign the account in again. */
192
+ export declare class AccountSessionExpired extends Error {
193
+ readonly metaSiteId: string;
194
+ readonly reason: string;
195
+ readonly code = "AccountSessionExpired";
196
+ constructor(metaSiteId: string, reason: string);
197
+ }
198
+ /** The Member instance could not be had for a TRANSIENT reason (network, 5xx, timeout). Not a
199
+ * membership verdict: a host retries it and never shows the join screen. */
200
+ export declare class SiteInstanceUnavailable extends Error {
201
+ readonly metaSiteId: string;
202
+ readonly reason: string;
203
+ readonly code = "SiteInstanceUnavailable";
204
+ constructor(metaSiteId: string, reason: string);
205
+ }
206
+ /** Why [instance] is not a Member instance of [metaSiteId], or null when it is — iOS
207
+ * `memberInstanceRejection`, word for word: the payload names the site, a non-empty `siteMemberId`
208
+ * equal to `uid`, and no `permissions` (a User instance carries `permissions: "OWNER"`). */
209
+ export declare function memberInstanceRejection(instance: string, metaSiteId: string): string | null;
210
+ /** When to stop using [instance]: 60 s before its payload's `expirationDate` (RFC 0071 §3), or
211
+ * [fallbackMs] after [now] when it carries none. */
212
+ export declare function memberInstanceRefreshAt(instance: string, now: number, fallbackMs?: number): number;
213
+ /** How long a refusal is remembered. Short on purpose: it only stops one screen's burst of calls from
214
+ * re-minting per call; a join clears it at once (`forgetRefusals`). */
215
+ export declare const MEMBER_NEGATIVE_TTL_MS = 10000;
216
+ /** A transient failure is remembered for less: it is the next retry's to try. */
217
+ export declare const MEMBER_TRANSIENT_TTL_MS = 3000;
218
+ /**
219
+ * RFC 0071 §3 — per-(site, account session) Member instances: single-flight (N racing calls cost one
220
+ * mint), a short negative cache, refreshed 60 s before the instance's own expiry. Keyed by a DIGEST
221
+ * of `wixSession2`, never the cookie itself. Same mint as owner preview's `OwnerInstanceCache`, with
222
+ * `signed_instance_type=Member`, and — unlike owner mode — no fallback: a failure fails the call.
223
+ */
224
+ export declare class MemberInstanceCache {
225
+ private fetchImpl;
226
+ private mintTimeoutMs;
227
+ private cache;
228
+ private inflight;
229
+ private refusals;
230
+ /** Per session: bumped by `forgetSession` / `forgetRefusals`. A mint that started under an older
231
+ * generation still answers its own callers, but writes nothing back — otherwise a mint in flight
232
+ * across a sign-out re-caches the signed-out instance, and one in flight across a join re-caches
233
+ * the `NotSiteMember` the join just made stale. */
234
+ private generations;
235
+ constructor(fetchImpl?: typeof fetch, mintTimeoutMs?: number);
236
+ private session;
237
+ private key;
238
+ /** The site's Member instance for this session. Throws `NotSiteMember` or `SiteInstanceUnavailable`.
239
+ * `force`: Wix refused the instance this cache handed out (a 401) — mint a new one. */
240
+ instance(msid: string, sessionCookie: string, opts?: {
241
+ force?: boolean;
242
+ now?: number;
243
+ }): Promise<string>;
244
+ /** Drop everything held for this session — instances and refusals alike: its sign-out or expiry
245
+ * (RFC 0071 §6, sign-out purges every per-site instance). */
246
+ forgetSession(sessionCookie: string): void;
247
+ /** Drop every refusal held for this session — after a join, which makes them stale. */
248
+ forgetRefusals(sessionCookie: string): void;
249
+ private mint;
250
+ }
251
+ /** The bridge's answer for a Member-instance failure: `NotSiteMember` → 403, `AccountSessionExpired` →
252
+ * 401, anything else → 502, in the `{ error }` shape every bridge refusal has. The name in `error` is
253
+ * what a host branches on. */
254
+ export declare function memberInstanceRefusal(e: unknown): {
255
+ status: number;
256
+ body: {
257
+ error: string;
258
+ metaSiteId?: string;
259
+ reason?: string;
260
+ };
261
+ };
144
262
  export {};
@@ -652,11 +652,15 @@ export interface AndroidAssetLinks {
652
652
  packageName: string;
653
653
  sha256CertFingerprints: string[];
654
654
  }
655
+ /** An absolute cache-rule prefix: `https://` + a Wix host + a path (`https://apps.wix.com/…`). */
656
+ export declare function isWixAbsoluteCachePrefix(prefix: string): boolean;
655
657
  /** Per-endpoint cache intent declared by an app. */
656
658
  export interface AppCacheRule {
657
659
  /** HTTP method this rule applies to. Omit for any method. */
658
660
  method?: string;
659
- /** Path prefix, e.g. "/stores/v3/products/". Matched by prefix. */
661
+ /** Path prefix, e.g. "/stores/v3/products/". Matched by prefix. A call a worker makes to an
662
+ * absolute Wix URL (an account-level read such as `https://apps.wix.com/…`) is matched by an
663
+ * absolute prefix instead: `https://` + a Wix host (`*.wix.com`, `*.wixapis.com`) + a path. */
660
664
  pathPrefix: string;
661
665
  cacheable: boolean;
662
666
  /** Fresh window, seconds. */
@@ -7272,6 +7272,12 @@ function validateNames(kind, names) {
7272
7272
  }
7273
7273
 
7274
7274
  // ../../core/ts/src/define-app.ts
7275
+ function isWixAbsoluteCachePrefix(prefix) {
7276
+ const m = /^https:\/\/([a-z0-9.-]+)(\/.*)$/i.exec(prefix);
7277
+ if (!m) return false;
7278
+ const host = m[1].toLowerCase();
7279
+ return host === "wix.com" || host.endsWith(".wix.com") || host === "wixapis.com" || host.endsWith(".wixapis.com");
7280
+ }
7275
7281
  var ALL_ORIENTATIONS = [
7276
7282
  "portrait",
7277
7283
  "portraitUpsideDown",
@@ -7630,8 +7636,8 @@ function validateConfigShape(config) {
7630
7636
  }
7631
7637
  if (config.cache) {
7632
7638
  for (const r of config.cache.rules ?? []) {
7633
- if (!r.pathPrefix || !r.pathPrefix.startsWith("/")) {
7634
- throw new Error(`defineApp: cache rule pathPrefix must start with "/". Got "${r.pathPrefix}".`);
7639
+ if (!r.pathPrefix || !(r.pathPrefix.startsWith("/") || isWixAbsoluteCachePrefix(r.pathPrefix))) {
7640
+ throw new Error(`defineApp: cache rule pathPrefix must start with "/" or be an https:// Wix URL (*.wix.com, *.wixapis.com). Got "${r.pathPrefix}".`);
7635
7641
  }
7636
7642
  if (r.ttl < 0 || (r.swr ?? 0) < 0) {
7637
7643
  throw new Error(`defineApp: cache rule ttl/swr must be non-negative (pathPrefix "${r.pathPrefix}").`);
@@ -13851,6 +13857,7 @@ export {
13851
13857
  isValidStreamPolicy,
13852
13858
  isViewTarget,
13853
13859
  isWidgetFamilySurface,
13860
+ isWixAbsoluteCachePrefix,
13854
13861
  layoutDirection,
13855
13862
  mergeIdiomOverlay,
13856
13863
  mergeSiteMenu,