@@ -8,7 +8,7 @@ import { useSeamQueryContext } from './SeamQueryProvider.js'
88export function useSeamClient ( ) : {
99 client : SeamHttp | null
1010 endpointClient : SeamHttpEndpoints | null
11- queryKeyPrefix : string [ ]
11+ queryKeyPrefixes : string [ ]
1212 isPending : boolean
1313 isError : boolean
1414 error : unknown
@@ -29,7 +29,7 @@ export function useSeamClient(): {
2929 [ SeamHttp , SeamHttpEndpoints ]
3030 > ( {
3131 queryKey : [
32- 'seam' ,
32+ ... getQueryKeyPrefixes ( { queryKeyPrefix } ) ,
3333 'client' ,
3434 {
3535 client,
@@ -76,15 +76,12 @@ export function useSeamClient(): {
7676 return {
7777 client : data ?. [ 0 ] ?? null ,
7878 endpointClient : data ?. [ 1 ] ?? null ,
79- queryKeyPrefix : [
80- 'seam' ,
81- queryKeyPrefix ??
82- getQueryKeyPrefix ( {
83- userIdentifierKey,
84- publishableKey,
85- clientSessionToken,
86- } ) ,
87- ] ,
79+ queryKeyPrefixes : getQueryKeyPrefixes ( {
80+ queryKeyPrefix,
81+ userIdentifierKey,
82+ publishableKey,
83+ clientSessionToken,
84+ } ) ,
8885 isPending,
8986 isError,
9087 error,
@@ -130,22 +127,28 @@ This is not recommended because the client session is now bound to this machine
130127 return fingerprint
131128}
132129
133- const getQueryKeyPrefix = ( {
130+ const getQueryKeyPrefixes = ( {
131+ queryKeyPrefix,
134132 userIdentifierKey,
135133 publishableKey,
136134 clientSessionToken,
137135} : {
138- userIdentifierKey : string
139- publishableKey : string | undefined
140- clientSessionToken : string | undefined
141- } ) : string => {
136+ queryKeyPrefix : string | undefined
137+ userIdentifierKey ?: string
138+ publishableKey ?: string | undefined
139+ clientSessionToken ?: string | undefined
140+ } ) : string [ ] => {
141+ const seamPrefix = 'seam'
142+
143+ if ( queryKeyPrefix != null ) return [ seamPrefix , queryKeyPrefix ]
144+
142145 if ( clientSessionToken != null ) {
143- return clientSessionToken
146+ return [ seamPrefix , clientSessionToken ]
144147 }
145148
146- if ( publishableKey != null ) {
147- return [ publishableKey , userIdentifierKey ] . join ( ':' )
149+ if ( publishableKey != null && userIdentifierKey != null ) {
150+ return [ seamPrefix , publishableKey , userIdentifierKey ]
148151 }
149152
150- throw new Error ( 'Could not determine a queryKeyPrefix' )
153+ return [ seamPrefix ]
151154}
0 commit comments