File tree Expand file tree Collapse file tree 3 files changed +54
-23
lines changed Expand file tree Collapse file tree 3 files changed +54
-23
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ import {
1414 type SeamHttpOptionsWithPersonalAccessToken ,
1515} from './options.js'
1616import type { Options } from './parse-options.js'
17+ import {
18+ accessTokenPrefix ,
19+ clientSessionTokenPrefix ,
20+ isAccessToken ,
21+ isClientSessionToken ,
22+ isJwt ,
23+ isPublishableKey ,
24+ isSeamToken ,
25+ jwtPrefix ,
26+ publishableKeyTokenPrefix ,
27+ tokenPrefix ,
28+ } from './token.js'
1729
1830type Headers = Record < string , string >
1931
@@ -256,29 +268,6 @@ export const warnOnInsecureuserIdentifierKey = (
256268 }
257269}
258270
259- const tokenPrefix = 'seam_'
260-
261- const accessTokenPrefix = 'seam_at'
262-
263- const jwtPrefix = 'ey'
264-
265- const clientSessionTokenPrefix = 'seam_cst'
266-
267- const publishableKeyTokenPrefix = 'seam_pk'
268-
269- const isClientSessionToken = ( token : string ) : boolean =>
270- token . startsWith ( clientSessionTokenPrefix )
271-
272- const isAccessToken = ( token : string ) : boolean =>
273- token . startsWith ( accessTokenPrefix )
274-
275- const isJwt = ( token : string ) : boolean => token . startsWith ( jwtPrefix )
276-
277- const isSeamToken = ( token : string ) : boolean => token . startsWith ( tokenPrefix )
278-
279- const isPublishableKey = ( token : string ) : boolean =>
280- token . startsWith ( publishableKeyTokenPrefix )
281-
282271// SOURCE: https://stackoverflow.com/a/46181
283272const isEmail = ( value : string ) : boolean =>
284273 / ^ [ ^ \s @ ] + @ [ ^ \s @ ] + \. [ ^ \s @ ] + $ / . test ( value )
Original file line number Diff line number Diff line change @@ -14,4 +14,11 @@ export * from './routes/index.js'
1414export * from './seam-http.js'
1515export * from './seam-http-error.js'
1616export * from './seam-http-multi-workspace.js'
17+ export {
18+ isApiKey ,
19+ isClientSessionToken ,
20+ isConsoleSessionToken ,
21+ isPersonalAccessToken ,
22+ isPublishableKey ,
23+ } from './token.js'
1724export * from 'lib/params-serializer.js'
Original file line number Diff line number Diff line change 1+ export const tokenPrefix = 'seam_'
2+
3+ export const accessTokenPrefix = 'seam_at'
4+
5+ export const jwtPrefix = 'ey'
6+
7+ export const clientSessionTokenPrefix = 'seam_cst'
8+
9+ export const publishableKeyTokenPrefix = 'seam_pk'
10+
11+ export const isAccessToken = ( token : string ) : boolean =>
12+ token . startsWith ( accessTokenPrefix )
13+
14+ export const isJwt = ( token : string ) : boolean => token . startsWith ( jwtPrefix )
15+
16+ export const isSeamToken = ( token : string ) : boolean =>
17+ token . startsWith ( tokenPrefix )
18+
19+ export const isApiKey = ( token : string ) : boolean =>
20+ ! isClientSessionToken ( token ) &&
21+ ! isJwt ( token ) &&
22+ ! isAccessToken ( token ) &&
23+ ! isPublishableKey ( token ) &&
24+ isSeamToken ( token )
25+
26+ export const isClientSessionToken = ( token : string ) : boolean =>
27+ token . startsWith ( clientSessionTokenPrefix )
28+
29+ export const isPublishableKey = ( token : string ) : boolean =>
30+ token . startsWith ( publishableKeyTokenPrefix )
31+
32+ export const isConsoleSessionToken = ( token : string ) : boolean => isJwt ( token )
33+
34+ export const isPersonalAccessToken = ( token : string ) : boolean =>
35+ isAccessToken ( token )
You can’t perform that action at this time.
0 commit comments