fix: slack bot authenticates via oauth
This commit is contained in:
23
packages/auth/src/utils/authTokenUtils.ts
Normal file
23
packages/auth/src/utils/authTokenUtils.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
const AUTUMN_SECRET_KEY_PREFIX = "am_sk";
|
||||
const AUTUMN_PUBLISHABLE_KEY_PREFIX = "am_pk";
|
||||
const AUTUMN_OAUTH_TOKEN_PREFIX = "am_oauth_";
|
||||
|
||||
export const isSecretKeyPrefix = ({ token }: { token: string }) =>
|
||||
token.startsWith(AUTUMN_SECRET_KEY_PREFIX);
|
||||
|
||||
export const isPublishableKeyPrefix = ({ token }: { token: string }) =>
|
||||
token.startsWith(AUTUMN_PUBLISHABLE_KEY_PREFIX);
|
||||
|
||||
export const isAutumnApiKey = ({ token }: { token: string }) =>
|
||||
isSecretKeyPrefix({ token }) || isPublishableKeyPrefix({ token });
|
||||
|
||||
export const isOAuthToken = ({ token }: { token: string }) =>
|
||||
token.startsWith(AUTUMN_OAUTH_TOKEN_PREFIX);
|
||||
|
||||
export const prefixOAuthToken = ({ token }: { token: string }) =>
|
||||
isOAuthToken({ token }) ? token : `${AUTUMN_OAUTH_TOKEN_PREFIX}${token}`;
|
||||
|
||||
export const stripOAuthTokenPrefix = ({ token }: { token: string }) =>
|
||||
isOAuthToken({ token })
|
||||
? token.slice(AUTUMN_OAUTH_TOKEN_PREFIX.length)
|
||||
: token;
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./authTokenUtils.js";
|
||||
export * from "./getBearerToken.js";
|
||||
|
||||
Reference in New Issue
Block a user