Skip to content

Commit 6efd36e

Browse files
committed
feat: expose token as client setting
1 parent 794f522 commit 6efd36e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/react-headless/src/stores/clientSettings.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type ClientSettings = {
88
userEmail?: string;
99
userExternalId?: string;
1010
userKey?: string;
11+
token?: string;
1112
clientId: string;
1213
serverURL: string;
1314
getClient(): InstanceType<typeof UserClient>;
@@ -30,13 +31,14 @@ const clientSettings = createStore<ClientSettings>((set, get) => {
3031
userEmail: undefined,
3132
userExternalId: undefined,
3233
userKey: undefined,
34+
token: undefined,
3335
clientId: Math.random().toString(36).substring(2) + Date.now(),
3436
serverURL: 'https://api.magicbell.com',
3537
appInfo: undefined,
3638

3739
getClient() {
3840
const state = get();
39-
const key = JSON.stringify([state.apiKey, state.userEmail, state.userExternalId, state.userKey]);
41+
const key = JSON.stringify([state.apiKey, state.userEmail, state.userExternalId, state.userKey, state.token]);
4042

4143
if (key !== _key) {
4244
_key = key;
@@ -45,6 +47,7 @@ const clientSettings = createStore<ClientSettings>((set, get) => {
4547
userEmail: state.userEmail,
4648
userHmac: state.userKey,
4749
apiKey: state.apiKey,
50+
token: state.token,
4851
host: state.serverURL,
4952
appInfo: state.appInfo || {
5053
name: pkg.name,

0 commit comments

Comments
 (0)