Skip to content

Commit 020ee16

Browse files
authored
feat: make it possible to use client session tokens with SeamProvider (#161)
1 parent fe7f604 commit 020ee16

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/lib/SeamProvider.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,20 @@ export function SeamProvider({
5353
const contextRef = useRef(createSeamContextValue(props))
5454
if (
5555
contextRef.current.client == null &&
56-
contextRef.current.publishableKey == null
56+
contextRef.current.publishableKey == null &&
57+
contextRef.current.clientSessionToken == null
5758
) {
5859
contextRef.current = defaultSeamContextValue
5960
}
6061

6162
if (
6263
contextRef.current.client == null &&
63-
contextRef.current.publishableKey == null
64+
contextRef.current.publishableKey == null &&
65+
contextRef.current.clientSessionToken == null
6466
) {
65-
throw new Error('Must provide either a Seam client or a publishableKey.')
67+
throw new Error(
68+
`Must provide either a Seam client, clientSessionToken or a publishableKey.`
69+
)
6670
}
6771

6872
return (
@@ -178,11 +182,12 @@ const isSeamProviderPropsWithClientSessionToken = (
178182
throw new Error('Cannot provide a Seam client along with other options.')
179183
}
180184

181-
if ('publishableKey' in props && props.publishableKey != null) {
182-
throw new Error(
183-
'Cannot provide both a clientSessionToken and a publishableKey .'
184-
)
185-
}
185+
// No reason to ban this behavior, but it's unnecessary.
186+
// if ('publishableKey' in props && props.publishableKey != null) {
187+
// throw new Error(
188+
// 'Cannot provide both a clientSessionToken and a publishableKey .'
189+
// )
190+
// }
186191

187192
if ('userIdentifierKey' in props && props.userIdentifierKey != null) {
188193
throw new Error('Cannot use a userIdentifierKey with a clientSessionToken.')

0 commit comments

Comments
 (0)