@palbase/web 2.0.0 → 3.0.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.
- package/README.md +11 -9
- package/dist/{analytics-facade-ovP0pF2P.d.cts → analytics-facade-BOxQ8IP2.d.cts} +11 -10
- package/dist/{analytics-facade-DMtGDGfd.d.ts → analytics-facade-yfMJ69vw.d.ts} +11 -10
- package/dist/{chunk-V6VTX65P.js → chunk-3HVTEZ7N.js} +80 -58
- package/dist/chunk-3HVTEZ7N.js.map +1 -0
- package/dist/{chunk-VJXFABBW.js → chunk-6VGKMNXO.js} +11 -11
- package/dist/chunk-6VGKMNXO.js.map +1 -0
- package/dist/chunk-S7NAY3MW.js +24 -0
- package/dist/chunk-S7NAY3MW.js.map +1 -0
- package/dist/gen/cli.cjs +33 -8
- package/dist/gen/cli.cjs.map +1 -1
- package/dist/gen/cli.js +29 -9
- package/dist/gen/cli.js.map +1 -1
- package/dist/index.cjs +53 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/internal.cjs +83 -54
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +4 -4
- package/dist/internal.d.ts +4 -4
- package/dist/internal.js +2 -2
- package/dist/next/client.cjs +100 -68
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +1 -1
- package/dist/next/client.d.ts +1 -1
- package/dist/next/client.js +12 -10
- package/dist/next/client.js.map +1 -1
- package/dist/next/index.cjs +103 -69
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +11 -11
- package/dist/next/index.d.ts +11 -11
- package/dist/next/index.js +14 -13
- package/dist/next/index.js.map +1 -1
- package/dist/{pb-DDM_mCQB.d.cts → pb-B3h3NIPE.d.cts} +1 -1
- package/dist/{pb-CvpcQero.d.ts → pb-QRISxPd1.d.ts} +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-V6VTX65P.js.map +0 -1
- package/dist/chunk-VJXFABBW.js.map +0 -1
package/README.md
CHANGED
|
@@ -29,18 +29,20 @@ Then link your project and generate the typed client:
|
|
|
29
29
|
npx palbase web link
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
`palbase web link` writes
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
`palbase web link` writes the committed generator inputs
|
|
33
|
+
`Palbase/openapi.json` and `Palbase/palbase-config.json`, runs `palbe-gen` when
|
|
34
|
+
`@palbase/web` is installed, wires `import './palbe.gen';` into your app entry,
|
|
35
|
+
and adds a `predev`/`prebuild` hook that keeps the typed client in sync. Commit
|
|
36
|
+
the `Palbase/` inputs and `palbe.gen.ts`; the generated client is source your app
|
|
37
|
+
imports, not a build artifact.
|
|
38
|
+
|
|
39
|
+
The generated file calls `__configure(...)` with the linked Environment ref,
|
|
40
|
+
URL, app ID, and publishable API key at module load, so importing it once at
|
|
41
|
+
startup is all the setup there is.
|
|
40
42
|
If you forget to import it, every `pb` call throws a guided `BackendError`
|
|
41
43
|
(`kind: 'notConfigured'`).
|
|
42
44
|
|
|
43
|
-
> Regenerate any time your backend changes: `npx
|
|
45
|
+
> Regenerate any time your backend changes: `npx palbe-gen` (or just run
|
|
44
46
|
> `dev`/`build` — the hook does it for you).
|
|
45
47
|
|
|
46
48
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Room, ExternalE2EEKeyProvider } from 'livekit-client';
|
|
2
2
|
import { S as SessionStorageAdapter } from './storage-BPaeSG8K.cjs';
|
|
3
|
-
import { F } from './pooled-flags-
|
|
3
|
+
import { F } from './pooled-flags-4GtDtsiu.js';
|
|
4
4
|
|
|
5
5
|
declare class PalbaseError$1 extends Error {
|
|
6
6
|
readonly code: string;
|
|
@@ -79,8 +79,7 @@ declare class HttpClient$1 {
|
|
|
79
79
|
* with the parent at runtime — later changes on the parent propagate to
|
|
80
80
|
* the scope and vice versa.
|
|
81
81
|
*
|
|
82
|
-
* Typical use:
|
|
83
|
-
* gateway can route them to the correct project's data plane.
|
|
82
|
+
* Typical use: adding an Environment-routing header for an admin call.
|
|
84
83
|
*/
|
|
85
84
|
withHeaders(extra: Record<string, string>): HttpClient$1;
|
|
86
85
|
/** Add a request interceptor. Runs before every request. */
|
|
@@ -169,8 +168,7 @@ declare class HttpClient {
|
|
|
169
168
|
* with the parent at runtime — later changes on the parent propagate to
|
|
170
169
|
* the scope and vice versa.
|
|
171
170
|
*
|
|
172
|
-
* Typical use:
|
|
173
|
-
* gateway can route them to the correct project's data plane.
|
|
171
|
+
* Typical use: adding an Environment-routing header for an admin call.
|
|
174
172
|
*/
|
|
175
173
|
withHeaders(extra: Record<string, string>): HttpClient;
|
|
176
174
|
/** Add a request interceptor. Runs before every request. */
|
|
@@ -622,10 +620,13 @@ interface PalbeConfig {
|
|
|
622
620
|
apiKey: string;
|
|
623
621
|
/** Registered app identity persisted by `palbase web link`. */
|
|
624
622
|
appId: string;
|
|
625
|
-
/**
|
|
626
|
-
|
|
623
|
+
/** Stable reference of the linked Palbase Environment. */
|
|
624
|
+
environmentRef: string;
|
|
627
625
|
oauth?: PalbeOAuthConfig;
|
|
628
|
-
/**
|
|
626
|
+
/**
|
|
627
|
+
* Refresh-token persistence. Default: environment-scoped localStorage in
|
|
628
|
+
* browsers, memory elsewhere.
|
|
629
|
+
*/
|
|
629
630
|
storage?: SessionStorageAdapter;
|
|
630
631
|
/** Extra headers on every request. */
|
|
631
632
|
headers?: Record<string, string>;
|
|
@@ -645,7 +646,7 @@ type FlagsView = Readonly<Record<string, F>>;
|
|
|
645
646
|
* one-shot snapshot fetches with zero timers and zero storage access, so a
|
|
646
647
|
* pbServer request that reads flags pays exactly one HTTP call.
|
|
647
648
|
*
|
|
648
|
-
* localStorage persistence is scoped per
|
|
649
|
+
* localStorage persistence is scoped per environment ref (`palbe.flags.<ref>`),
|
|
649
650
|
* mirroring the session-storage key convention.
|
|
650
651
|
*/
|
|
651
652
|
declare class PalbeFlags {
|
|
@@ -679,7 +680,7 @@ declare class PalbeFlags {
|
|
|
679
680
|
*
|
|
680
681
|
* DEVIATION from iOS sync-cache parity: the platform does not propagate
|
|
681
682
|
* variant metadata into the user-flags snapshot/delta cache, so this is an
|
|
682
|
-
* ASYNC transport read (`GET /v1/flags
|
|
683
|
+
* ASYNC transport read (derived from `GET /v1/user-flags`), not a cache lookup.
|
|
683
684
|
*/
|
|
684
685
|
getVariant(key: string): Promise<string | null>;
|
|
685
686
|
/** Subscribe to any change in the cached flag set. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Room, ExternalE2EEKeyProvider } from 'livekit-client';
|
|
2
2
|
import { S as SessionStorageAdapter } from './storage-BPaeSG8K.js';
|
|
3
|
-
import { F } from './pooled-flags-
|
|
3
|
+
import { F } from './pooled-flags-4GtDtsiu.js';
|
|
4
4
|
|
|
5
5
|
declare class PalbaseError$1 extends Error {
|
|
6
6
|
readonly code: string;
|
|
@@ -79,8 +79,7 @@ declare class HttpClient$1 {
|
|
|
79
79
|
* with the parent at runtime — later changes on the parent propagate to
|
|
80
80
|
* the scope and vice versa.
|
|
81
81
|
*
|
|
82
|
-
* Typical use:
|
|
83
|
-
* gateway can route them to the correct project's data plane.
|
|
82
|
+
* Typical use: adding an Environment-routing header for an admin call.
|
|
84
83
|
*/
|
|
85
84
|
withHeaders(extra: Record<string, string>): HttpClient$1;
|
|
86
85
|
/** Add a request interceptor. Runs before every request. */
|
|
@@ -169,8 +168,7 @@ declare class HttpClient {
|
|
|
169
168
|
* with the parent at runtime — later changes on the parent propagate to
|
|
170
169
|
* the scope and vice versa.
|
|
171
170
|
*
|
|
172
|
-
* Typical use:
|
|
173
|
-
* gateway can route them to the correct project's data plane.
|
|
171
|
+
* Typical use: adding an Environment-routing header for an admin call.
|
|
174
172
|
*/
|
|
175
173
|
withHeaders(extra: Record<string, string>): HttpClient;
|
|
176
174
|
/** Add a request interceptor. Runs before every request. */
|
|
@@ -622,10 +620,13 @@ interface PalbeConfig {
|
|
|
622
620
|
apiKey: string;
|
|
623
621
|
/** Registered app identity persisted by `palbase web link`. */
|
|
624
622
|
appId: string;
|
|
625
|
-
/**
|
|
626
|
-
|
|
623
|
+
/** Stable reference of the linked Palbase Environment. */
|
|
624
|
+
environmentRef: string;
|
|
627
625
|
oauth?: PalbeOAuthConfig;
|
|
628
|
-
/**
|
|
626
|
+
/**
|
|
627
|
+
* Refresh-token persistence. Default: environment-scoped localStorage in
|
|
628
|
+
* browsers, memory elsewhere.
|
|
629
|
+
*/
|
|
629
630
|
storage?: SessionStorageAdapter;
|
|
630
631
|
/** Extra headers on every request. */
|
|
631
632
|
headers?: Record<string, string>;
|
|
@@ -645,7 +646,7 @@ type FlagsView = Readonly<Record<string, F>>;
|
|
|
645
646
|
* one-shot snapshot fetches with zero timers and zero storage access, so a
|
|
646
647
|
* pbServer request that reads flags pays exactly one HTTP call.
|
|
647
648
|
*
|
|
648
|
-
* localStorage persistence is scoped per
|
|
649
|
+
* localStorage persistence is scoped per environment ref (`palbe.flags.<ref>`),
|
|
649
650
|
* mirroring the session-storage key convention.
|
|
650
651
|
*/
|
|
651
652
|
declare class PalbeFlags {
|
|
@@ -679,7 +680,7 @@ declare class PalbeFlags {
|
|
|
679
680
|
*
|
|
680
681
|
* DEVIATION from iOS sync-cache parity: the platform does not propagate
|
|
681
682
|
* variant metadata into the user-flags snapshot/delta cache, so this is an
|
|
682
|
-
* ASYNC transport read (`GET /v1/flags
|
|
683
|
+
* ASYNC transport read (derived from `GET /v1/user-flags`), not a cache lookup.
|
|
683
684
|
*/
|
|
684
685
|
getVariant(key: string): Promise<string | null>;
|
|
685
686
|
/** Subscribe to any change in the cached flag set. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__export
|
|
3
|
-
|
|
2
|
+
__export,
|
|
3
|
+
environmentRefFromPublishableApiKey
|
|
4
|
+
} from "./chunk-S7NAY3MW.js";
|
|
4
5
|
|
|
5
6
|
// ../core/dist/index.js
|
|
6
7
|
var CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
@@ -17,18 +18,9 @@ var PalbaseError = class extends Error {
|
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
var PALBASE_DEFAULT_HOST = "api.palbase.studio";
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (apiKey.length < 13) return null;
|
|
24
|
-
if (!apiKey.startsWith("pb_")) return null;
|
|
25
|
-
if (apiKey[11] !== "_") return null;
|
|
26
|
-
const ref = apiKey.slice(3, 11);
|
|
27
|
-
if (ref.length !== REF_LEN) return null;
|
|
28
|
-
if (!BASE62_RE.test(ref)) return null;
|
|
29
|
-
const scope = apiKey[12];
|
|
30
|
-
if (scope !== "c") return null;
|
|
31
|
-
return ref;
|
|
21
|
+
var API_KEY_RE = /^pb_([a-z0-9]+)_c[A-Za-z0-9]{20}$/;
|
|
22
|
+
function parseEnvironmentRef(apiKey) {
|
|
23
|
+
return API_KEY_RE.exec(apiKey)?.[1] ?? null;
|
|
32
24
|
}
|
|
33
25
|
var MAX_RETRIES = 3;
|
|
34
26
|
var INITIAL_BACKOFF_MS = 200;
|
|
@@ -58,8 +50,7 @@ var HttpClient = class _HttpClient {
|
|
|
58
50
|
* with the parent at runtime — later changes on the parent propagate to
|
|
59
51
|
* the scope and vice versa.
|
|
60
52
|
*
|
|
61
|
-
* Typical use:
|
|
62
|
-
* gateway can route them to the correct project's data plane.
|
|
53
|
+
* Typical use: adding an Environment-routing header for an admin call.
|
|
63
54
|
*/
|
|
64
55
|
withHeaders(extra) {
|
|
65
56
|
const mergedHeaders = { ...this.options?.headers ?? {}, ...extra };
|
|
@@ -100,10 +91,10 @@ var HttpClient = class _HttpClient {
|
|
|
100
91
|
if (this.options?.url) {
|
|
101
92
|
return this.options.url;
|
|
102
93
|
}
|
|
103
|
-
if (this.apiKey &&
|
|
94
|
+
if (this.apiKey && parseEnvironmentRef(this.apiKey) === null) {
|
|
104
95
|
throw new PalbaseError(
|
|
105
96
|
"invalid_api_key",
|
|
106
|
-
'Invalid API key format. Expected pb_{
|
|
97
|
+
'Invalid API key format. Expected pb_{environment_ref}_c{20_base62_chars}. For dev/staging pass `url: "https://api.dev.palbase.studio"` via options.',
|
|
107
98
|
0
|
|
108
99
|
);
|
|
109
100
|
}
|
|
@@ -116,10 +107,6 @@ var HttpClient = class _HttpClient {
|
|
|
116
107
|
const effectiveKey = this.apiKey;
|
|
117
108
|
if (effectiveKey) {
|
|
118
109
|
headers["apikey"] = effectiveKey;
|
|
119
|
-
const ref = parseProjectRef(effectiveKey);
|
|
120
|
-
if (ref) {
|
|
121
|
-
headers["X-Project-Ref"] = ref;
|
|
122
|
-
}
|
|
123
110
|
}
|
|
124
111
|
const token = this.tokenManager?.getAccessToken();
|
|
125
112
|
if (token) {
|
|
@@ -1125,13 +1112,6 @@ var AuthClient = class {
|
|
|
1125
1112
|
}
|
|
1126
1113
|
};
|
|
1127
1114
|
|
|
1128
|
-
// src/api-key.ts
|
|
1129
|
-
var API_KEY_RE = /^pb_([^_]+)_[cs][A-Za-z0-9]{20}$/;
|
|
1130
|
-
function endpointRefFromApiKey(apiKey) {
|
|
1131
|
-
const m = API_KEY_RE.exec(apiKey);
|
|
1132
|
-
return m ? m[1] ?? "" : "";
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
1115
|
// src/analytics-facade.ts
|
|
1136
1116
|
var EVENT_NAME_RE = /^[a-zA-Z$][a-zA-Z0-9_.:$-]{0,63}$/;
|
|
1137
1117
|
var FLUSH_AT = 20;
|
|
@@ -1189,7 +1169,7 @@ var AnalyticsState = class {
|
|
|
1189
1169
|
idKey;
|
|
1190
1170
|
optOutKey;
|
|
1191
1171
|
constructor(rt) {
|
|
1192
|
-
const ref =
|
|
1172
|
+
const ref = rt.config.environmentRef;
|
|
1193
1173
|
this.idKey = ref ? `palbe.analytics.id.${ref}` : "palbe.analytics.id";
|
|
1194
1174
|
this.optOutKey = ref ? `palbe.analytics.optout.${ref}` : "palbe.analytics.optout";
|
|
1195
1175
|
rt.auth.onAuthEvent((event) => {
|
|
@@ -1969,6 +1949,19 @@ var PalbeCalls = class {
|
|
|
1969
1949
|
|
|
1970
1950
|
// ../modules/flags/dist/index.js
|
|
1971
1951
|
var FLAG_NAME_RE = /^[a-zA-Z0-9_-]+$/;
|
|
1952
|
+
function flagEnabled(value) {
|
|
1953
|
+
if (typeof value === "boolean") return value;
|
|
1954
|
+
return value != null && value !== 0 && value !== "";
|
|
1955
|
+
}
|
|
1956
|
+
function flagVariant(value) {
|
|
1957
|
+
return typeof value === "string" ? { name: value } : null;
|
|
1958
|
+
}
|
|
1959
|
+
function mapResponse(res, fn) {
|
|
1960
|
+
if (res.error || res.data == null) {
|
|
1961
|
+
return { ...res, data: null };
|
|
1962
|
+
}
|
|
1963
|
+
return { ...res, data: fn(res.data) };
|
|
1964
|
+
}
|
|
1972
1965
|
var FlagsClient = class {
|
|
1973
1966
|
httpClient;
|
|
1974
1967
|
getCurrentUserId;
|
|
@@ -1988,10 +1981,11 @@ var FlagsClient = class {
|
|
|
1988
1981
|
`Invalid flag name: "${flagName}". Flag names must match ${FLAG_NAME_RE.source}`
|
|
1989
1982
|
);
|
|
1990
1983
|
}
|
|
1991
|
-
const
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1984
|
+
const res = await this.httpClient.request(
|
|
1985
|
+
"GET",
|
|
1986
|
+
this.mergedPath(context)
|
|
1987
|
+
);
|
|
1988
|
+
return mapResponse(res, (snap) => flagEnabled(snap.values?.[flagName]));
|
|
1995
1989
|
}
|
|
1996
1990
|
async getVariant(flagName, context) {
|
|
1997
1991
|
if (!FLAG_NAME_RE.test(flagName)) {
|
|
@@ -1999,16 +1993,29 @@ var FlagsClient = class {
|
|
|
1999
1993
|
`Invalid flag name: "${flagName}". Flag names must match ${FLAG_NAME_RE.source}`
|
|
2000
1994
|
);
|
|
2001
1995
|
}
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
1996
|
+
const res = await this.httpClient.request(
|
|
1997
|
+
"GET",
|
|
1998
|
+
this.mergedPath(context)
|
|
1999
|
+
);
|
|
2000
|
+
if (res.error || res.data == null) {
|
|
2001
|
+
return { ...res, data: null };
|
|
2002
|
+
}
|
|
2003
|
+
return { ...res, data: flagVariant(res.data.values?.[flagName]) };
|
|
2006
2004
|
}
|
|
2007
2005
|
async getAll(context) {
|
|
2008
|
-
const
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2006
|
+
const res = await this.httpClient.request(
|
|
2007
|
+
"GET",
|
|
2008
|
+
this.mergedPath(context)
|
|
2009
|
+
);
|
|
2010
|
+
return mapResponse(res, (snap) => {
|
|
2011
|
+
const values = snap.values ?? {};
|
|
2012
|
+
return Object.keys(values).map((name) => {
|
|
2013
|
+
const value = values[name];
|
|
2014
|
+
const flag = { name, enabled: flagEnabled(value) };
|
|
2015
|
+
if (typeof value === "string") flag.variant = { name: value };
|
|
2016
|
+
return flag;
|
|
2017
|
+
});
|
|
2018
|
+
});
|
|
2012
2019
|
}
|
|
2013
2020
|
/**
|
|
2014
2021
|
* Cold-start read: the full merged flag set for the current auth identity.
|
|
@@ -2107,15 +2114,16 @@ var FlagsClient = class {
|
|
|
2107
2114
|
}
|
|
2108
2115
|
};
|
|
2109
2116
|
}
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2117
|
+
/**
|
|
2118
|
+
* Resolve the merged-read path for a context. With `context.userId` present the
|
|
2119
|
+
* read targets that specific user's merged view (`/v1/user-flags/users/{id}`, a
|
|
2120
|
+
* privileged cross-user read); otherwise the current auth user's view
|
|
2121
|
+
* (`/v1/user-flags`). `context.properties` has no server-side targeting support
|
|
2122
|
+
* in the user-flags module and is ignored.
|
|
2123
|
+
*/
|
|
2124
|
+
mergedPath(context) {
|
|
2125
|
+
const uid = context?.userId;
|
|
2126
|
+
return uid ? `/v1/user-flags/users/${encodeURIComponent(uid)}` : "/v1/user-flags";
|
|
2119
2127
|
}
|
|
2120
2128
|
};
|
|
2121
2129
|
var DEFAULT_POLL_MS = 3e4;
|
|
@@ -2520,7 +2528,7 @@ var PalbeFlags = class {
|
|
|
2520
2528
|
constructor(rt) {
|
|
2521
2529
|
this.transport = new FlagsClient(rt.http);
|
|
2522
2530
|
const browser = typeof document !== "undefined";
|
|
2523
|
-
const ref =
|
|
2531
|
+
const ref = rt.config.environmentRef;
|
|
2524
2532
|
const options = {
|
|
2525
2533
|
auth: palbeAuthAdapter(rt.auth),
|
|
2526
2534
|
...ref ? { storageKey: `palbe.flags.${ref}` } : {},
|
|
@@ -2577,7 +2585,7 @@ var PalbeFlags = class {
|
|
|
2577
2585
|
*
|
|
2578
2586
|
* DEVIATION from iOS sync-cache parity: the platform does not propagate
|
|
2579
2587
|
* variant metadata into the user-flags snapshot/delta cache, so this is an
|
|
2580
|
-
* ASYNC transport read (`GET /v1/flags
|
|
2588
|
+
* ASYNC transport read (derived from `GET /v1/user-flags`), not a cache lookup.
|
|
2581
2589
|
*/
|
|
2582
2590
|
async getVariant(key) {
|
|
2583
2591
|
let res;
|
|
@@ -8259,7 +8267,7 @@ var AnonTokenProvider = class {
|
|
|
8259
8267
|
}
|
|
8260
8268
|
/**
|
|
8261
8269
|
* Raw fetch, deliberately NOT through HttpClient/palbeRequest: the mint
|
|
8262
|
-
* must carry the
|
|
8270
|
+
* must carry the Environment API key and NEVER a Bearer (iOS keeps
|
|
8263
8271
|
* `/auth/anonymous` on the unauthenticated-path list), and HttpClient's
|
|
8264
8272
|
* pre-flight would try to refresh a stale session before an anon mint —
|
|
8265
8273
|
* exactly the entanglement this provider exists to avoid.
|
|
@@ -8916,10 +8924,25 @@ function defaultSessionStorage(key) {
|
|
|
8916
8924
|
}
|
|
8917
8925
|
|
|
8918
8926
|
// src/version.ts
|
|
8919
|
-
var VERSION = "
|
|
8927
|
+
var VERSION = "3.0.0";
|
|
8920
8928
|
|
|
8921
8929
|
// src/runtime.ts
|
|
8922
8930
|
function buildRuntime(config) {
|
|
8931
|
+
const keyEnvironmentRef = environmentRefFromPublishableApiKey(config.apiKey);
|
|
8932
|
+
if (keyEnvironmentRef === "") {
|
|
8933
|
+
throw new Error("PalbeConfig.apiKey does not contain a valid publishable Environment identity");
|
|
8934
|
+
} else if (config.environmentRef !== keyEnvironmentRef) {
|
|
8935
|
+
throw new Error("PalbeConfig.environmentRef must match the Environment identity in apiKey");
|
|
8936
|
+
}
|
|
8937
|
+
let runtimeURL;
|
|
8938
|
+
try {
|
|
8939
|
+
runtimeURL = new URL(config.url);
|
|
8940
|
+
} catch {
|
|
8941
|
+
throw new Error("PalbeConfig.url must be a valid URL");
|
|
8942
|
+
}
|
|
8943
|
+
if (runtimeURL.hostname.endsWith(".palbase.studio") && runtimeURL.hostname.split(".")[0] !== config.environmentRef) {
|
|
8944
|
+
throw new Error("PalbeConfig.url must match environmentRef for palbase.studio");
|
|
8945
|
+
}
|
|
8923
8946
|
const http = new HttpClient(config.apiKey, {
|
|
8924
8947
|
url: config.url,
|
|
8925
8948
|
headers: { "X-Client-Info": `palbe-web/${VERSION}`, ...config.headers }
|
|
@@ -8928,7 +8951,7 @@ function buildRuntime(config) {
|
|
|
8928
8951
|
const tokenManager = new TokenManager();
|
|
8929
8952
|
http.tokenManager = tokenManager;
|
|
8930
8953
|
const authClient = new AuthClient(http, tokenManager);
|
|
8931
|
-
const ref =
|
|
8954
|
+
const ref = config.environmentRef;
|
|
8932
8955
|
const storage = config.storage ?? defaultSessionStorage(ref ? `palbe.session.${ref}` : void 0);
|
|
8933
8956
|
const persisted = storage.load();
|
|
8934
8957
|
if (persisted) {
|
|
@@ -9305,7 +9328,6 @@ function __reset() {
|
|
|
9305
9328
|
}
|
|
9306
9329
|
|
|
9307
9330
|
export {
|
|
9308
|
-
endpointRefFromApiKey,
|
|
9309
9331
|
BackendError,
|
|
9310
9332
|
isBackendError,
|
|
9311
9333
|
PalbeAnalytics,
|
|
@@ -9329,4 +9351,4 @@ export {
|
|
|
9329
9351
|
pb,
|
|
9330
9352
|
createBoundClient
|
|
9331
9353
|
};
|
|
9332
|
-
//# sourceMappingURL=chunk-
|
|
9354
|
+
//# sourceMappingURL=chunk-3HVTEZ7N.js.map
|