@wix/web5-core 1.63.46 → 1.63.48

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.
@@ -27,7 +27,7 @@ export declare const SCHEME_COLOR_TOKENS: ReadonlySet<string>;
27
27
  * derived from those two. The panel writes exactly these into the OWNER rows
28
28
  * it creates, and mirrors exactly these of the active row into `themeOverrides`.
29
29
  */
30
- export declare const SCHEME_TOKENS: readonly ["--background", "--foreground", "--popover", "--popover-foreground", "--muted", "--muted-foreground", "--border", "--input", "--secondary", "--accent"];
30
+ export declare const SCHEME_TOKENS: readonly ["--background", "--foreground", "--popover", "--popover-foreground", "--muted", "--muted-foreground", "--border", "--input"];
31
31
  export type SchemeToken = (typeof SCHEME_TOKENS)[number];
32
32
  /** Only the `SCHEME_TOKENS` entries of `map`. */
33
33
  export declare function schemeTokensOf(map: Record<string, string> | null | undefined): Record<string, string>;
@@ -54,11 +54,6 @@ export declare function resolveActiveScheme(cfg: {
54
54
  themeSchemes?: unknown;
55
55
  activeThemeSchemeId?: string | null;
56
56
  } | null | undefined): ThemeScheme | null;
57
- /** What `completeScheme` needs from outside the scheme. */
58
- export interface SchemeContext {
59
- /** The store's button colour, which tints `--secondary`/`--accent`. */
60
- primary?: string;
61
- }
62
57
  /**
63
58
  * The `SCHEME_TOKENS` of a scheme whose anchors the owner just edited.
64
59
  *
@@ -69,10 +64,10 @@ export interface SchemeContext {
69
64
  * unavailable keeps `base`'s value, if any.
70
65
  *
71
66
  * Returns ONLY `SCHEME_TOKENS`: whatever else `base` carries (a pre-0243 row's
72
- * card or button colours, its radius) is the store's global set now, not the
67
+ * card, button or secondary/accent colours, its radius) is the store's global set now, not the
73
68
  * scheme's, and is dropped. Every output entry passes `isSchemeTokenEntry`.
74
69
  */
75
- export declare function completeScheme(base: Record<string, string>, anchors: Partial<Record<SchemeAnchorToken, string>>, context?: SchemeContext): Record<string, string>;
70
+ export declare function completeScheme(base: Record<string, string>, anchors: Partial<Record<SchemeAnchorToken, string>>): Record<string, string>;
76
71
  /** The label the panel shows: the trimmed name, else `Palette N` (1-based). */
77
72
  export declare function schemeDisplayName(scheme: ThemeScheme, index: number): string;
78
73
  /** `owner-N` with the smallest N ≥ 1 not already taken. */
@@ -1 +1 @@
1
- {"version":3,"file":"themeScheme.d.ts","sourceRoot":"","sources":["../../../src/theme/themeScheme.ts"],"names":[],"mappings":"AAiGA,8EAA8E;AAC9E,MAAM,MAAM,YAAY,GAAG,uBAAuB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEvE,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IAC/B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,qFAAqF;AACrF,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAM5B,CAAC;AA2BzB;;;;GAIG;AACH,eAAO,MAAM,aAAa,mKAWhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAIzD,iDAAiD;AACjD,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,GAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIxB;AAED,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,2CAA4C,CAAC;AAE9E,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,gDAAgD;AAChD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAQpC;;;;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AAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,GAClD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4DxB;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED,2DAA2D;AAC3D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,MAAM,CAO5E;AAQD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAevE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wix/web5-core",
3
3
  "license": "MIT",
4
- "version": "1.63.46",
4
+ "version": "1.63.48",
5
5
  "author": {
6
6
  "name": "tsachis",
7
7
  "email": "tsachis@wix.com"
@@ -100,5 +100,5 @@
100
100
  "wallaby": {
101
101
  "autoDetect": true
102
102
  },
103
- "falconPackageHash": "e47c6bd14d93504787f5ccf0de580c1ba835fff9e7110c134180d51c"
103
+ "falconPackageHash": "e337237995d7148c06753872c373dd099ea00d7e56f0f6048915a854"
104
104
  }
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.createWixAuthFetch = createWixAuthFetch;
5
- var _sdk = require("@wix/sdk");
6
- /**
7
- * Wix-authenticated `fetch` for Web5 BE calls from a host (third-party) origin.
8
- *
9
- * `wixapis.com`'s `/wix-assistant-web5/v1/turn` endpoint refuses
10
- * cross-origin anonymous calls (HTTP 500) — the only auth path that survives
11
- * CORS from a host (e.g. Shopify) origin is `@wix/sdk`'s `OAuthStrategy`, which
12
- * supplies the `Authorization` header the BE allowlists.
13
- *
14
- * Shared by every embed bundle that talks to the turn endpoint — the
15
- * placement bundle and the input-widget chip generator — so they all attach
16
- * the same token. Token caching uses the same `localStorage` key format
17
- * (`web5_tokens_<clientId>`) as `web50-server-ui`'s token cache, so the loader,
18
- * full app, placement, and input widget share one OAuth token instead of each
19
- * burning a `/oauth2/token` round-trip per page load.
20
- */
21
-
22
- const TOKEN_CACHE_KEY_PREFIX = 'web5_tokens_';
23
- function tokenKey(clientId) {
24
- return `${TOKEN_CACHE_KEY_PREFIX}${clientId}`;
25
- }
26
- function loadTokens(client, clientId) {
27
- try {
28
- const raw = localStorage.getItem(tokenKey(clientId));
29
- if (!raw) return;
30
- client.auth.setTokens(JSON.parse(raw));
31
- } catch {
32
- try {
33
- localStorage.removeItem(tokenKey(clientId));
34
- } catch {
35
- /* ignore */
36
- }
37
- }
38
- }
39
- function saveTokens(client, clientId) {
40
- try {
41
- localStorage.setItem(tokenKey(clientId), JSON.stringify(client.auth.getTokens()));
42
- } catch {
43
- // privacy mode / quota — in-memory token still works for this session
44
- }
45
- }
46
-
47
- /**
48
- * Build a `fetch`-shaped function pre-bound to the given Wix client id. The
49
- * returned value is drop-in compatible with any `fetchImpl` option
50
- * (`placementFetch`, `fetchContextualChips`, …).
51
- *
52
- * Each call loads cached tokens before the request, then saves the (possibly
53
- * refreshed) tokens after the response headers arrive — we deliberately do NOT
54
- * wait for the streaming body; the SDK's refresh runs alongside the stream and
55
- * the saved tokens benefit subsequent calls.
56
- */
57
- function createWixAuthFetch(clientId) {
58
- if (!clientId) {
59
- throw new Error('[web5-core] createWixAuthFetch: clientId is empty');
60
- }
61
- const client = (0, _sdk.createClient)({
62
- auth: (0, _sdk.OAuthStrategy)({
63
- clientId
64
- })
65
- });
66
- return async (input, init) => {
67
- loadTokens(client, clientId);
68
- const res = await client.fetchWithAuth(input, init);
69
- saveTokens(client, clientId);
70
- return res;
71
- };
72
- }
73
- //# sourceMappingURL=wixAuthFetch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_sdk","require","TOKEN_CACHE_KEY_PREFIX","tokenKey","clientId","loadTokens","client","raw","localStorage","getItem","auth","setTokens","JSON","parse","removeItem","saveTokens","setItem","stringify","getTokens","createWixAuthFetch","Error","createClient","OAuthStrategy","input","init","res","fetchWithAuth"],"sources":["../../../src/client/wixAuthFetch.ts"],"sourcesContent":["/**\n * Wix-authenticated `fetch` for Web5 BE calls from a host (third-party) origin.\n *\n * `wixapis.com`'s `/wix-assistant-web5/v1/turn` endpoint refuses\n * cross-origin anonymous calls (HTTP 500) — the only auth path that survives\n * CORS from a host (e.g. Shopify) origin is `@wix/sdk`'s `OAuthStrategy`, which\n * supplies the `Authorization` header the BE allowlists.\n *\n * Shared by every embed bundle that talks to the turn endpoint — the\n * placement bundle and the input-widget chip generator — so they all attach\n * the same token. Token caching uses the same `localStorage` key format\n * (`web5_tokens_<clientId>`) as `web50-server-ui`'s token cache, so the loader,\n * full app, placement, and input widget share one OAuth token instead of each\n * burning a `/oauth2/token` round-trip per page load.\n */\nimport { createClient, OAuthStrategy } from '@wix/sdk';\n\nconst TOKEN_CACHE_KEY_PREFIX = 'web5_tokens_';\n\ninterface SdkClient {\n fetchWithAuth: typeof fetch;\n auth: {\n setTokens: (tokens: unknown) => void;\n getTokens: () => unknown;\n };\n}\n\nfunction tokenKey(clientId: string): string {\n return `${TOKEN_CACHE_KEY_PREFIX}${clientId}`;\n}\n\nfunction loadTokens(client: SdkClient, clientId: string): void {\n try {\n const raw = localStorage.getItem(tokenKey(clientId));\n if (!raw) return;\n client.auth.setTokens(JSON.parse(raw));\n } catch {\n try {\n localStorage.removeItem(tokenKey(clientId));\n } catch {\n /* ignore */\n }\n }\n}\n\nfunction saveTokens(client: SdkClient, clientId: string): void {\n try {\n localStorage.setItem(\n tokenKey(clientId),\n JSON.stringify(client.auth.getTokens()),\n );\n } catch {\n // privacy mode / quota — in-memory token still works for this session\n }\n}\n\n/**\n * Build a `fetch`-shaped function pre-bound to the given Wix client id. The\n * returned value is drop-in compatible with any `fetchImpl` option\n * (`placementFetch`, `fetchContextualChips`, …).\n *\n * Each call loads cached tokens before the request, then saves the (possibly\n * refreshed) tokens after the response headers arrive — we deliberately do NOT\n * wait for the streaming body; the SDK's refresh runs alongside the stream and\n * the saved tokens benefit subsequent calls.\n */\nexport function createWixAuthFetch(clientId: string): typeof fetch {\n if (!clientId) {\n throw new Error('[web5-core] createWixAuthFetch: clientId is empty');\n }\n const client = createClient({\n auth: OAuthStrategy({ clientId }),\n }) as unknown as SdkClient;\n\n return (async (input: RequestInfo | URL, init?: RequestInit) => {\n loadTokens(client, clientId);\n const res = await client.fetchWithAuth(input, init);\n saveTokens(client, clientId);\n return res;\n }) as typeof fetch;\n}\n"],"mappings":";;;;AAeA,IAAAA,IAAA,GAAAC,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAMC,sBAAsB,GAAG,cAAc;AAU7C,SAASC,QAAQA,CAACC,QAAgB,EAAU;EAC1C,OAAO,GAAGF,sBAAsB,GAAGE,QAAQ,EAAE;AAC/C;AAEA,SAASC,UAAUA,CAACC,MAAiB,EAAEF,QAAgB,EAAQ;EAC7D,IAAI;IACF,MAAMG,GAAG,GAAGC,YAAY,CAACC,OAAO,CAACN,QAAQ,CAACC,QAAQ,CAAC,CAAC;IACpD,IAAI,CAACG,GAAG,EAAE;IACVD,MAAM,CAACI,IAAI,CAACC,SAAS,CAACC,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC,CAAC;EACxC,CAAC,CAAC,MAAM;IACN,IAAI;MACFC,YAAY,CAACM,UAAU,CAACX,QAAQ,CAACC,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;AACF;AAEA,SAASW,UAAUA,CAACT,MAAiB,EAAEF,QAAgB,EAAQ;EAC7D,IAAI;IACFI,YAAY,CAACQ,OAAO,CAClBb,QAAQ,CAACC,QAAQ,CAAC,EAClBQ,IAAI,CAACK,SAAS,CAACX,MAAM,CAACI,IAAI,CAACQ,SAAS,CAAC,CAAC,CACxC,CAAC;EACH,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAACf,QAAgB,EAAgB;EACjE,IAAI,CAACA,QAAQ,EAAE;IACb,MAAM,IAAIgB,KAAK,CAAC,mDAAmD,CAAC;EACtE;EACA,MAAMd,MAAM,GAAG,IAAAe,iBAAY,EAAC;IAC1BX,IAAI,EAAE,IAAAY,kBAAa,EAAC;MAAElB;IAAS,CAAC;EAClC,CAAC,CAAyB;EAE1B,OAAQ,OAAOmB,KAAwB,EAAEC,IAAkB,KAAK;IAC9DnB,UAAU,CAACC,MAAM,EAAEF,QAAQ,CAAC;IAC5B,MAAMqB,GAAG,GAAG,MAAMnB,MAAM,CAACoB,aAAa,CAACH,KAAK,EAAEC,IAAI,CAAC;IACnDT,UAAU,CAACT,MAAM,EAAEF,QAAQ,CAAC;IAC5B,OAAOqB,GAAG;EACZ,CAAC;AACH","ignoreList":[]}
@@ -1,68 +0,0 @@
1
- /**
2
- * Wix-authenticated `fetch` for Web5 BE calls from a host (third-party) origin.
3
- *
4
- * `wixapis.com`'s `/wix-assistant-web5/v1/turn` endpoint refuses
5
- * cross-origin anonymous calls (HTTP 500) — the only auth path that survives
6
- * CORS from a host (e.g. Shopify) origin is `@wix/sdk`'s `OAuthStrategy`, which
7
- * supplies the `Authorization` header the BE allowlists.
8
- *
9
- * Shared by every embed bundle that talks to the turn endpoint — the
10
- * placement bundle and the input-widget chip generator — so they all attach
11
- * the same token. Token caching uses the same `localStorage` key format
12
- * (`web5_tokens_<clientId>`) as `web50-server-ui`'s token cache, so the loader,
13
- * full app, placement, and input widget share one OAuth token instead of each
14
- * burning a `/oauth2/token` round-trip per page load.
15
- */
16
- import { createClient, OAuthStrategy } from '@wix/sdk';
17
- const TOKEN_CACHE_KEY_PREFIX = 'web5_tokens_';
18
- function tokenKey(clientId) {
19
- return `${TOKEN_CACHE_KEY_PREFIX}${clientId}`;
20
- }
21
- function loadTokens(client, clientId) {
22
- try {
23
- const raw = localStorage.getItem(tokenKey(clientId));
24
- if (!raw) return;
25
- client.auth.setTokens(JSON.parse(raw));
26
- } catch {
27
- try {
28
- localStorage.removeItem(tokenKey(clientId));
29
- } catch {
30
- /* ignore */
31
- }
32
- }
33
- }
34
- function saveTokens(client, clientId) {
35
- try {
36
- localStorage.setItem(tokenKey(clientId), JSON.stringify(client.auth.getTokens()));
37
- } catch {
38
- // privacy mode / quota — in-memory token still works for this session
39
- }
40
- }
41
-
42
- /**
43
- * Build a `fetch`-shaped function pre-bound to the given Wix client id. The
44
- * returned value is drop-in compatible with any `fetchImpl` option
45
- * (`placementFetch`, `fetchContextualChips`, …).
46
- *
47
- * Each call loads cached tokens before the request, then saves the (possibly
48
- * refreshed) tokens after the response headers arrive — we deliberately do NOT
49
- * wait for the streaming body; the SDK's refresh runs alongside the stream and
50
- * the saved tokens benefit subsequent calls.
51
- */
52
- export function createWixAuthFetch(clientId) {
53
- if (!clientId) {
54
- throw new Error('[web5-core] createWixAuthFetch: clientId is empty');
55
- }
56
- const client = createClient({
57
- auth: OAuthStrategy({
58
- clientId
59
- })
60
- });
61
- return async (input, init) => {
62
- loadTokens(client, clientId);
63
- const res = await client.fetchWithAuth(input, init);
64
- saveTokens(client, clientId);
65
- return res;
66
- };
67
- }
68
- //# sourceMappingURL=wixAuthFetch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createClient","OAuthStrategy","TOKEN_CACHE_KEY_PREFIX","tokenKey","clientId","loadTokens","client","raw","localStorage","getItem","auth","setTokens","JSON","parse","removeItem","saveTokens","setItem","stringify","getTokens","createWixAuthFetch","Error","input","init","res","fetchWithAuth"],"sources":["../../../src/client/wixAuthFetch.ts"],"sourcesContent":["/**\n * Wix-authenticated `fetch` for Web5 BE calls from a host (third-party) origin.\n *\n * `wixapis.com`'s `/wix-assistant-web5/v1/turn` endpoint refuses\n * cross-origin anonymous calls (HTTP 500) — the only auth path that survives\n * CORS from a host (e.g. Shopify) origin is `@wix/sdk`'s `OAuthStrategy`, which\n * supplies the `Authorization` header the BE allowlists.\n *\n * Shared by every embed bundle that talks to the turn endpoint — the\n * placement bundle and the input-widget chip generator — so they all attach\n * the same token. Token caching uses the same `localStorage` key format\n * (`web5_tokens_<clientId>`) as `web50-server-ui`'s token cache, so the loader,\n * full app, placement, and input widget share one OAuth token instead of each\n * burning a `/oauth2/token` round-trip per page load.\n */\nimport { createClient, OAuthStrategy } from '@wix/sdk';\n\nconst TOKEN_CACHE_KEY_PREFIX = 'web5_tokens_';\n\ninterface SdkClient {\n fetchWithAuth: typeof fetch;\n auth: {\n setTokens: (tokens: unknown) => void;\n getTokens: () => unknown;\n };\n}\n\nfunction tokenKey(clientId: string): string {\n return `${TOKEN_CACHE_KEY_PREFIX}${clientId}`;\n}\n\nfunction loadTokens(client: SdkClient, clientId: string): void {\n try {\n const raw = localStorage.getItem(tokenKey(clientId));\n if (!raw) return;\n client.auth.setTokens(JSON.parse(raw));\n } catch {\n try {\n localStorage.removeItem(tokenKey(clientId));\n } catch {\n /* ignore */\n }\n }\n}\n\nfunction saveTokens(client: SdkClient, clientId: string): void {\n try {\n localStorage.setItem(\n tokenKey(clientId),\n JSON.stringify(client.auth.getTokens()),\n );\n } catch {\n // privacy mode / quota — in-memory token still works for this session\n }\n}\n\n/**\n * Build a `fetch`-shaped function pre-bound to the given Wix client id. The\n * returned value is drop-in compatible with any `fetchImpl` option\n * (`placementFetch`, `fetchContextualChips`, …).\n *\n * Each call loads cached tokens before the request, then saves the (possibly\n * refreshed) tokens after the response headers arrive — we deliberately do NOT\n * wait for the streaming body; the SDK's refresh runs alongside the stream and\n * the saved tokens benefit subsequent calls.\n */\nexport function createWixAuthFetch(clientId: string): typeof fetch {\n if (!clientId) {\n throw new Error('[web5-core] createWixAuthFetch: clientId is empty');\n }\n const client = createClient({\n auth: OAuthStrategy({ clientId }),\n }) as unknown as SdkClient;\n\n return (async (input: RequestInfo | URL, init?: RequestInit) => {\n loadTokens(client, clientId);\n const res = await client.fetchWithAuth(input, init);\n saveTokens(client, clientId);\n return res;\n }) as typeof fetch;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,aAAa,QAAQ,UAAU;AAEtD,MAAMC,sBAAsB,GAAG,cAAc;AAU7C,SAASC,QAAQA,CAACC,QAAgB,EAAU;EAC1C,OAAO,GAAGF,sBAAsB,GAAGE,QAAQ,EAAE;AAC/C;AAEA,SAASC,UAAUA,CAACC,MAAiB,EAAEF,QAAgB,EAAQ;EAC7D,IAAI;IACF,MAAMG,GAAG,GAAGC,YAAY,CAACC,OAAO,CAACN,QAAQ,CAACC,QAAQ,CAAC,CAAC;IACpD,IAAI,CAACG,GAAG,EAAE;IACVD,MAAM,CAACI,IAAI,CAACC,SAAS,CAACC,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC,CAAC;EACxC,CAAC,CAAC,MAAM;IACN,IAAI;MACFC,YAAY,CAACM,UAAU,CAACX,QAAQ,CAACC,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;AACF;AAEA,SAASW,UAAUA,CAACT,MAAiB,EAAEF,QAAgB,EAAQ;EAC7D,IAAI;IACFI,YAAY,CAACQ,OAAO,CAClBb,QAAQ,CAACC,QAAQ,CAAC,EAClBQ,IAAI,CAACK,SAAS,CAACX,MAAM,CAACI,IAAI,CAACQ,SAAS,CAAC,CAAC,CACxC,CAAC;EACH,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACf,QAAgB,EAAgB;EACjE,IAAI,CAACA,QAAQ,EAAE;IACb,MAAM,IAAIgB,KAAK,CAAC,mDAAmD,CAAC;EACtE;EACA,MAAMd,MAAM,GAAGN,YAAY,CAAC;IAC1BU,IAAI,EAAET,aAAa,CAAC;MAAEG;IAAS,CAAC;EAClC,CAAC,CAAyB;EAE1B,OAAQ,OAAOiB,KAAwB,EAAEC,IAAkB,KAAK;IAC9DjB,UAAU,CAACC,MAAM,EAAEF,QAAQ,CAAC;IAC5B,MAAMmB,GAAG,GAAG,MAAMjB,MAAM,CAACkB,aAAa,CAACH,KAAK,EAAEC,IAAI,CAAC;IACnDP,UAAU,CAACT,MAAM,EAAEF,QAAQ,CAAC;IAC5B,OAAOmB,GAAG;EACZ,CAAC;AACH","ignoreList":[]}
@@ -1,12 +0,0 @@
1
- /**
2
- * Build a `fetch`-shaped function pre-bound to the given Wix client id. The
3
- * returned value is drop-in compatible with any `fetchImpl` option
4
- * (`placementFetch`, `fetchContextualChips`, …).
5
- *
6
- * Each call loads cached tokens before the request, then saves the (possibly
7
- * refreshed) tokens after the response headers arrive — we deliberately do NOT
8
- * wait for the streaming body; the SDK's refresh runs alongside the stream and
9
- * the saved tokens benefit subsequent calls.
10
- */
11
- export declare function createWixAuthFetch(clientId: string): typeof fetch;
12
- //# sourceMappingURL=wixAuthFetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wixAuthFetch.d.ts","sourceRoot":"","sources":["../../../src/client/wixAuthFetch.ts"],"names":[],"mappings":"AAwDA;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,KAAK,CAcjE"}