slack-cloudflare-workers
Version:
Slack app development framework for Cloudflare Workers
47 lines • 2.63 kB
TypeScript
import { KVNamespace } from "@cloudflare/workers-types";
import { Authorize, Installation, InstallationStore, InstallationStoreQuery, SlackOAuthEnv } from "slack-edge";
/**
* Options for initializing a KV Installation Store instance
*/
export interface KVInstallationStoreOptions {
/**
* When this is set to true, calls to the `auth.test` Slack API method will use the authTestCacheStorage as a cache.
* The authTestCacheStorage must be provided when this is set to true.
* The default is set to false.
*/
authTestCacheEnabled?: boolean;
/**
* When `authTestCacheEnabled` is set to true, this is the TTL expiration time in seconds for each cache entry.
* 0 or negative value indicates the cache is permanent. The default is 10 minutes.
* @see https://developers.cloudflare.com/kv/api/write-key-value-pairs/#expiring-keys
*/
authTestCacheExpirationSecs?: number;
/**
* The KVNamespace to use for caching `auth.test` responses.
* This must be provided when `authTestCacheEnabled` is set to true.
*/
authTestCacheStorage?: KVNamespace;
}
export declare class KVInstallationStore<E extends SlackOAuthEnv> implements InstallationStore<E> {
#private;
constructor(env: E, namespace: KVNamespace, options?: KVInstallationStoreOptions);
save(installation: Installation, request?: Request | undefined): Promise<void>;
findBotInstallation(query: InstallationStoreQuery): Promise<Installation | undefined>;
findUserInstallation(query: InstallationStoreQuery): Promise<Installation | undefined>;
deleteBotInstallation(query: InstallationStoreQuery): Promise<void>;
deleteUserInstallation(query: InstallationStoreQuery): Promise<void>;
deleteAll(query: InstallationStoreQuery): Promise<void>;
toAuthorize(): Authorize<E>;
/**
* Calls the `auth.test` Slack API method, first checking the auth.test cache if enabled.
* @param client - The Slack API client to use for the request.
* @param token - The token to use for the request, and/or cache key.
* @returns The response from the `auth.test` Slack API method.
*/
private callAuthTest;
}
export declare function toBotInstallationQuery(clientId: string, q: InstallationStoreQuery): string;
export declare function toUserInstallationQuery(clientId: string, q: InstallationStoreQuery): string;
export declare function toBotInstallationKey(clientId: string, installation: Installation): string;
export declare function toUserInstallationKey(clientId: string, installation: Installation): string;
//# sourceMappingURL=kv-installation-store.d.ts.map