UNPKG

slack-edge

Version:

Slack app development framework for edge functions with streamlined TypeScript support

24 lines 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultOpenIDConnectCallback = void 0; const slack_web_api_client_1 = require("slack-web-api-client"); const slack_web_api_client_2 = require("slack-web-api-client"); /** * The default OpenIDConnectCallback implementation. * @param env env variables * @param token openid.connect.token API response * @returns response */ const defaultOpenIDConnectCallback = async ({ env, token }) => { const client = new slack_web_api_client_1.SlackAPIClient(token.access_token, { logLevel: env.SLACK_LOGGING_LEVEL, }); const userInfo = await client.openid.connect.userInfo(); const body = `<html><head><style>body {{ padding: 10px 15px; font-family: verdana; text-align: center; }}</style></head><body><h1>It works!</h1><p>This is the default handler. To change this, pass \`oidc: { callback: async (token, req) => new Response("TODO") }\` to your SlackOAuthApp constructor.</p><pre>${(0, slack_web_api_client_2.prettyPrint)(userInfo)}</pre></body></html>`; return new Response(body, { status: 200, headers: { "Content-Type": "text/html; charset=utf-8" }, }); }; exports.defaultOpenIDConnectCallback = defaultOpenIDConnectCallback; //# sourceMappingURL=hook.js.map