fix: slack bot authenticates via oauth

This commit is contained in:
johnyeo
2026-06-05 18:52:26 +01:00
parent f9fe8fa196
commit 1cda503264
37 changed files with 8513 additions and 181 deletions

View 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;

View File

@@ -1 +1,2 @@
export * from "./authTokenUtils.js";
export * from "./getBearerToken.js";