@eliya-oss/agent-slack 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,35 +0,0 @@
1
- import { NotAuthenticated, UnsafeMethodBlocked, UsageError } from "../domain/errors.js";
2
- export const getProfile = async (services, name) => {
3
- const profile = await services.tokenStore.getProfile(name);
4
- if (profile === null) {
5
- throw new NotAuthenticated(`No auth profile named ${name}`, { profile: name });
6
- }
7
- return profile;
8
- };
9
- export const tokenFor = (profile, tokenType) => {
10
- const token = tokenType === "user" ? profile.userToken :
11
- tokenType === "admin" ? profile.adminToken :
12
- tokenType === "app" ? profile.appToken :
13
- profile.botToken ?? profile.userToken ?? profile.adminToken ?? profile.appToken;
14
- if (token === undefined || token.length === 0) {
15
- throw new NotAuthenticated(`Profile ${profile.name} does not have a ${tokenType} token`, {
16
- profile: profile.name,
17
- tokenType
18
- });
19
- }
20
- return token;
21
- };
22
- export const parseTokenType = (value) => {
23
- if (value === undefined) {
24
- return "bot";
25
- }
26
- if (value === "user" || value === "bot" || value === "admin" || value === "app") {
27
- return value;
28
- }
29
- throw new UsageError("Invalid token type", { tokenType: value });
30
- };
31
- export const requireYes = (input) => {
32
- if (!input.yes) {
33
- throw new UnsafeMethodBlocked(input.message);
34
- }
35
- };