Skip to content

Commit ce81deb

Browse files
committed
rename to publishableKey
1 parent 36c37d8 commit ce81deb

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

src/components/DeviceManager/DeviceManager.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { SeamContext } from '../SeamProvider'
77
import './DeviceManager.css' // TODO: add postcss
88

99
const DeviceManager = (props: any) => {
10-
const { publishedKey, clientSessionToken, seamEndpoint, userIdentifierKey } = useContext(SeamContext)
10+
const { publishableKey, clientSessionToken, seamEndpoint, userIdentifierKey } = useContext(SeamContext)
1111
const { email } = props // TODO: change email to userIdentifierKey in DB
1212
const seam = useSeamClient({
13-
publishedKey,
13+
publishableKey,
1414
clientSessionToken,
1515
endpoint: seamEndpoint,
1616
userIdentifierKey,

src/components/SeamProvider/index.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { createContext, ReactNode } from 'react'
22
import React from 'react'
3-
import { QueryClientProvider, QueryClient } from "@tanstack/react-query"
3+
import { QueryClientProvider, QueryClient } from '@tanstack/react-query'
44

55
export const queryClient = new QueryClient()
66

77
export type SeamContextType = {
8-
publishedKey?: string
8+
publishableKey?: string
99
clientSessionToken?: string
1010
seamEndpoint: string
1111
userIdentifierKey: string
1212
}
1313

1414
export const SeamContext = createContext<SeamContextType>({
15-
publishedKey: '',
15+
publishableKey: '',
1616
clientSessionToken: '',
1717
seamEndpoint: '',
1818
userIdentifierKey: '',
@@ -24,16 +24,14 @@ type Props = {
2424

2525
export default function SeamProvider({
2626
children,
27-
publishedKey,
27+
publishableKey,
2828
clientSessionToken,
2929
seamEndpoint,
3030
userIdentifierKey,
3131
}: Props & SeamContextType) {
3232
return (
33-
<SeamContext.Provider value={{ publishedKey, clientSessionToken, seamEndpoint, userIdentifierKey }}>
34-
<QueryClientProvider client={queryClient}>
35-
{children}
36-
</QueryClientProvider>
33+
<SeamContext.Provider value={{ publishableKey, clientSessionToken, seamEndpoint, userIdentifierKey }}>
34+
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
3735
</SeamContext.Provider>
3836
)
3937
}

src/hooks/use-seam-client.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import Seam from 'seamapi'
22
import { getCookie, setCookie } from '../utils'
33

44
export const useSeamClient = ({
5-
publishedKey,
5+
publishableKey,
66
endpoint,
77
userIdentifierKey,
88
clientSessionToken,
99
}: {
10-
publishedKey?: string
10+
publishableKey?: string
1111
endpoint: string
1212
userIdentifierKey: string
1313
clientSessionToken?: string
@@ -31,10 +31,14 @@ export const useSeamClient = ({
3131
// no need to use public key
3232
// TODO: check if client access token is valid (not expired), if expired/invalid, get new one with the public key
3333
return getSeam(clientSessionTokenFromCookie)
34-
} else if (publishedKey?.startsWith('seam_pk1')) {
34+
} else if (publishableKey?.startsWith('seam_pk1')) {
3535
// public key, need to create a client access token and store it in cookie
3636
;(async () => {
37-
const clientSessionTokenResponse = await Seam.getClientSessionToken({ publishedKey, userIdentifierKey, endpoint })
37+
const clientSessionTokenResponse = await Seam.getClientSessionToken({
38+
publishableKey,
39+
userIdentifierKey,
40+
endpoint,
41+
})
3842
if (clientSessionTokenResponse.ok === false || !clientSessionTokenResponse['client_session']) {
3943
throw new Error('Could not get client access token')
4044
}
@@ -47,7 +51,7 @@ export const useSeamClient = ({
4751
// TODO: improve: use devices are not loading probably due to async nature of this hook
4852
})()
4953
} else {
50-
throw new Error('No publishedKey nor clientSessionToken provided or they are invalid')
54+
throw new Error('No publishableKey nor clientSessionToken provided or they are invalid')
5155
return null as any
5256
}
5357
return null as any

0 commit comments

Comments
 (0)