@kodelyth/googlechat 2026.5.42 → 2026.6.2
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.
- package/klaw.plugin.json +967 -2
- package/package.json +18 -6
- package/api.ts +0 -3
- package/channel-config-api.ts +0 -1
- package/channel-plugin-api.ts +0 -1
- package/config-api.ts +0 -2
- package/contract-api.ts +0 -5
- package/doctor-contract-api.ts +0 -1
- package/index.ts +0 -20
- package/runtime-api.ts +0 -55
- package/secret-contract-api.ts +0 -5
- package/setup-entry.ts +0 -13
- package/setup-plugin-api.ts +0 -3
- package/src/accounts.ts +0 -181
- package/src/actions.test.ts +0 -289
- package/src/actions.ts +0 -227
- package/src/api.ts +0 -316
- package/src/approval-auth.test.ts +0 -24
- package/src/approval-auth.ts +0 -32
- package/src/auth.ts +0 -218
- package/src/channel-config.test.ts +0 -39
- package/src/channel.adapters.ts +0 -340
- package/src/channel.deps.runtime.ts +0 -29
- package/src/channel.runtime.ts +0 -17
- package/src/channel.setup.ts +0 -98
- package/src/channel.test.ts +0 -784
- package/src/channel.ts +0 -277
- package/src/config-schema.test.ts +0 -31
- package/src/config-schema.ts +0 -3
- package/src/doctor-contract.test.ts +0 -75
- package/src/doctor-contract.ts +0 -182
- package/src/doctor.ts +0 -57
- package/src/gateway.ts +0 -63
- package/src/google-auth.runtime.test.ts +0 -543
- package/src/google-auth.runtime.ts +0 -568
- package/src/group-policy.ts +0 -17
- package/src/monitor-access.test.ts +0 -491
- package/src/monitor-access.ts +0 -465
- package/src/monitor-durable.test.ts +0 -39
- package/src/monitor-durable.ts +0 -23
- package/src/monitor-reply-delivery.ts +0 -156
- package/src/monitor-routing.ts +0 -65
- package/src/monitor-types.ts +0 -33
- package/src/monitor-webhook.test.ts +0 -587
- package/src/monitor-webhook.ts +0 -303
- package/src/monitor.reply-delivery.test.ts +0 -144
- package/src/monitor.test.ts +0 -159
- package/src/monitor.ts +0 -527
- package/src/monitor.webhook-routing.test.ts +0 -257
- package/src/runtime.ts +0 -9
- package/src/secret-contract.test.ts +0 -60
- package/src/secret-contract.ts +0 -161
- package/src/setup-core.ts +0 -40
- package/src/setup-surface.ts +0 -243
- package/src/setup.test.ts +0 -619
- package/src/targets.test.ts +0 -453
- package/src/targets.ts +0 -66
- package/src/types.config.ts +0 -3
- package/src/types.ts +0 -73
- package/test-api.ts +0 -2
- package/tsconfig.json +0 -16
package/src/setup-surface.ts
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
addWildcardAllowFrom,
|
|
3
|
-
applySetupAccountConfigPatch,
|
|
4
|
-
createPromptParsedAllowFromForAccount,
|
|
5
|
-
createStandardChannelSetupStatus,
|
|
6
|
-
DEFAULT_ACCOUNT_ID,
|
|
7
|
-
formatDocsLink,
|
|
8
|
-
mergeAllowFromEntries,
|
|
9
|
-
migrateBaseNameToDefaultAccount,
|
|
10
|
-
splitSetupEntries,
|
|
11
|
-
createSetupTranslator,
|
|
12
|
-
type ChannelSetupDmPolicy,
|
|
13
|
-
type ChannelSetupWizard,
|
|
14
|
-
} from "klaw/plugin-sdk/setup";
|
|
15
|
-
import {
|
|
16
|
-
normalizeOptionalString,
|
|
17
|
-
normalizeStringifiedOptionalString,
|
|
18
|
-
} from "klaw/plugin-sdk/string-coerce-runtime";
|
|
19
|
-
import { resolveDefaultGoogleChatAccountId, resolveGoogleChatAccount } from "./accounts.js";
|
|
20
|
-
|
|
21
|
-
const t = createSetupTranslator();
|
|
22
|
-
|
|
23
|
-
const channel = "googlechat" as const;
|
|
24
|
-
const ENV_SERVICE_ACCOUNT = "GOOGLE_CHAT_SERVICE_ACCOUNT";
|
|
25
|
-
const ENV_SERVICE_ACCOUNT_FILE = "GOOGLE_CHAT_SERVICE_ACCOUNT_FILE";
|
|
26
|
-
const USE_ENV_FLAG = "__googlechatUseEnv";
|
|
27
|
-
const AUTH_METHOD_FLAG = "__googlechatAuthMethod";
|
|
28
|
-
|
|
29
|
-
type GoogleChatTextInput = NonNullable<ChannelSetupWizard["textInputs"]>[number];
|
|
30
|
-
type GoogleChatTextInputKey = GoogleChatTextInput["inputKey"];
|
|
31
|
-
|
|
32
|
-
const promptAllowFrom = createPromptParsedAllowFromForAccount({
|
|
33
|
-
defaultAccountId: resolveDefaultGoogleChatAccountId,
|
|
34
|
-
message: t("wizard.googlechat.allowFromPrompt"),
|
|
35
|
-
placeholder: "users/123456789, name@example.com",
|
|
36
|
-
parseEntries: (raw) => ({
|
|
37
|
-
entries: mergeAllowFromEntries(undefined, splitSetupEntries(raw)),
|
|
38
|
-
}),
|
|
39
|
-
getExistingAllowFrom: ({ cfg, accountId }) =>
|
|
40
|
-
resolveGoogleChatAccount({ cfg, accountId }).config.dm?.allowFrom ?? [],
|
|
41
|
-
applyAllowFrom: ({ cfg, accountId, allowFrom }) =>
|
|
42
|
-
applySetupAccountConfigPatch({
|
|
43
|
-
cfg,
|
|
44
|
-
channelKey: channel,
|
|
45
|
-
accountId,
|
|
46
|
-
patch: {
|
|
47
|
-
dm: {
|
|
48
|
-
...resolveGoogleChatAccount({ cfg, accountId }).config.dm,
|
|
49
|
-
allowFrom,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const googlechatDmPolicy: ChannelSetupDmPolicy = {
|
|
56
|
-
label: "Google Chat",
|
|
57
|
-
channel,
|
|
58
|
-
policyKey: "channels.googlechat.dm.policy",
|
|
59
|
-
allowFromKey: "channels.googlechat.dm.allowFrom",
|
|
60
|
-
resolveConfigKeys: (cfg, accountId) =>
|
|
61
|
-
(accountId ?? resolveDefaultGoogleChatAccountId(cfg)) !== DEFAULT_ACCOUNT_ID
|
|
62
|
-
? {
|
|
63
|
-
policyKey: `channels.googlechat.accounts.${accountId ?? resolveDefaultGoogleChatAccountId(cfg)}.dm.policy`,
|
|
64
|
-
allowFromKey: `channels.googlechat.accounts.${accountId ?? resolveDefaultGoogleChatAccountId(cfg)}.dm.allowFrom`,
|
|
65
|
-
}
|
|
66
|
-
: {
|
|
67
|
-
policyKey: "channels.googlechat.dm.policy",
|
|
68
|
-
allowFromKey: "channels.googlechat.dm.allowFrom",
|
|
69
|
-
},
|
|
70
|
-
getCurrent: (cfg, accountId) =>
|
|
71
|
-
resolveGoogleChatAccount({
|
|
72
|
-
cfg,
|
|
73
|
-
accountId: accountId ?? resolveDefaultGoogleChatAccountId(cfg),
|
|
74
|
-
}).config.dm?.policy ?? "pairing",
|
|
75
|
-
setPolicy: (cfg, policy, accountId) => {
|
|
76
|
-
const resolvedAccountId = accountId ?? resolveDefaultGoogleChatAccountId(cfg);
|
|
77
|
-
const currentDm = resolveGoogleChatAccount({
|
|
78
|
-
cfg,
|
|
79
|
-
accountId: resolvedAccountId,
|
|
80
|
-
}).config.dm;
|
|
81
|
-
return applySetupAccountConfigPatch({
|
|
82
|
-
cfg,
|
|
83
|
-
channelKey: channel,
|
|
84
|
-
accountId: resolvedAccountId,
|
|
85
|
-
patch: {
|
|
86
|
-
dm: {
|
|
87
|
-
...currentDm,
|
|
88
|
-
policy,
|
|
89
|
-
...(policy === "open" ? { allowFrom: addWildcardAllowFrom(currentDm?.allowFrom) } : {}),
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
promptAllowFrom,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
function createServiceAccountTextInput(params: {
|
|
98
|
-
inputKey: GoogleChatTextInputKey;
|
|
99
|
-
message: string;
|
|
100
|
-
placeholder: string;
|
|
101
|
-
authMethod: "file" | "inline";
|
|
102
|
-
patchKey: "serviceAccountFile" | "serviceAccount";
|
|
103
|
-
}): GoogleChatTextInput {
|
|
104
|
-
return {
|
|
105
|
-
inputKey: params.inputKey,
|
|
106
|
-
message: params.message,
|
|
107
|
-
placeholder: params.placeholder,
|
|
108
|
-
shouldPrompt: ({ credentialValues }) =>
|
|
109
|
-
credentialValues[USE_ENV_FLAG] !== "1" &&
|
|
110
|
-
credentialValues[AUTH_METHOD_FLAG] === params.authMethod,
|
|
111
|
-
validate: ({ value }) => (normalizeStringifiedOptionalString(value) ? undefined : "Required"),
|
|
112
|
-
normalizeValue: ({ value }) => normalizeStringifiedOptionalString(value) ?? "",
|
|
113
|
-
applySet: async ({ cfg, accountId, value }) =>
|
|
114
|
-
applySetupAccountConfigPatch({
|
|
115
|
-
cfg,
|
|
116
|
-
channelKey: channel,
|
|
117
|
-
accountId,
|
|
118
|
-
patch: { [params.patchKey]: value },
|
|
119
|
-
}),
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export const googlechatSetupWizard: ChannelSetupWizard = {
|
|
124
|
-
channel,
|
|
125
|
-
status: createStandardChannelSetupStatus({
|
|
126
|
-
channelLabel: "Google Chat",
|
|
127
|
-
configuredLabel: t("wizard.channels.statusConfigured"),
|
|
128
|
-
unconfiguredLabel: t("wizard.channels.statusNeedsServiceAccount"),
|
|
129
|
-
configuredHint: t("wizard.channels.statusConfigured"),
|
|
130
|
-
unconfiguredHint: t("wizard.channels.statusNeedsAuth"),
|
|
131
|
-
includeStatusLine: true,
|
|
132
|
-
resolveConfigured: ({ cfg, accountId }) =>
|
|
133
|
-
resolveGoogleChatAccount({ cfg, accountId }).credentialSource !== "none",
|
|
134
|
-
}),
|
|
135
|
-
introNote: {
|
|
136
|
-
title: t("wizard.googlechat.setupTitle"),
|
|
137
|
-
lines: [
|
|
138
|
-
t("wizard.googlechat.setupServiceAccount"),
|
|
139
|
-
t("wizard.googlechat.setupScopes"),
|
|
140
|
-
t("wizard.googlechat.setupAudience"),
|
|
141
|
-
t("wizard.channels.docs", { link: formatDocsLink("/channels/googlechat", "googlechat") }),
|
|
142
|
-
],
|
|
143
|
-
},
|
|
144
|
-
prepare: async ({ cfg, accountId, credentialValues, prompter }) => {
|
|
145
|
-
const envReady =
|
|
146
|
-
accountId === DEFAULT_ACCOUNT_ID &&
|
|
147
|
-
(Boolean(process.env[ENV_SERVICE_ACCOUNT]) || Boolean(process.env[ENV_SERVICE_ACCOUNT_FILE]));
|
|
148
|
-
if (envReady) {
|
|
149
|
-
const useEnv = await prompter.confirm({
|
|
150
|
-
message: t("wizard.googlechat.useEnvPrompt"),
|
|
151
|
-
initialValue: true,
|
|
152
|
-
});
|
|
153
|
-
if (useEnv) {
|
|
154
|
-
return {
|
|
155
|
-
cfg: applySetupAccountConfigPatch({
|
|
156
|
-
cfg,
|
|
157
|
-
channelKey: channel,
|
|
158
|
-
accountId,
|
|
159
|
-
patch: {},
|
|
160
|
-
}),
|
|
161
|
-
credentialValues: {
|
|
162
|
-
...credentialValues,
|
|
163
|
-
[USE_ENV_FLAG]: "1",
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const method = await prompter.select({
|
|
170
|
-
message: t("wizard.googlechat.authMethod"),
|
|
171
|
-
options: [
|
|
172
|
-
{ value: "file", label: t("wizard.googlechat.serviceAccountFile") },
|
|
173
|
-
{ value: "inline", label: t("wizard.googlechat.serviceAccountInline") },
|
|
174
|
-
],
|
|
175
|
-
initialValue: "file",
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
return {
|
|
179
|
-
credentialValues: {
|
|
180
|
-
...credentialValues,
|
|
181
|
-
[USE_ENV_FLAG]: "0",
|
|
182
|
-
[AUTH_METHOD_FLAG]: method,
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
},
|
|
186
|
-
credentials: [],
|
|
187
|
-
textInputs: [
|
|
188
|
-
createServiceAccountTextInput({
|
|
189
|
-
inputKey: "tokenFile",
|
|
190
|
-
message: t("wizard.googlechat.serviceAccountPath"),
|
|
191
|
-
placeholder: "/path/to/service-account.json",
|
|
192
|
-
authMethod: "file",
|
|
193
|
-
patchKey: "serviceAccountFile",
|
|
194
|
-
}),
|
|
195
|
-
createServiceAccountTextInput({
|
|
196
|
-
inputKey: "token",
|
|
197
|
-
message: t("wizard.googlechat.serviceAccountJson"),
|
|
198
|
-
placeholder: '{"type":"service_account", ... }',
|
|
199
|
-
authMethod: "inline",
|
|
200
|
-
patchKey: "serviceAccount",
|
|
201
|
-
}),
|
|
202
|
-
],
|
|
203
|
-
finalize: async ({ cfg, accountId, prompter }) => {
|
|
204
|
-
const account = resolveGoogleChatAccount({
|
|
205
|
-
cfg,
|
|
206
|
-
accountId,
|
|
207
|
-
});
|
|
208
|
-
const audienceType = await prompter.select({
|
|
209
|
-
message: t("wizard.googlechat.webhookAudienceType"),
|
|
210
|
-
options: [
|
|
211
|
-
{ value: "app-url", label: t("wizard.googlechat.appUrlRecommended") },
|
|
212
|
-
{ value: "project-number", label: t("wizard.googlechat.projectNumber") },
|
|
213
|
-
],
|
|
214
|
-
initialValue: account.config.audienceType === "project-number" ? "project-number" : "app-url",
|
|
215
|
-
});
|
|
216
|
-
const audience = await prompter.text({
|
|
217
|
-
message:
|
|
218
|
-
audienceType === "project-number"
|
|
219
|
-
? t("wizard.googlechat.projectNumber")
|
|
220
|
-
: t("wizard.googlechat.appUrl"),
|
|
221
|
-
placeholder:
|
|
222
|
-
audienceType === "project-number" ? "1234567890" : "https://your.host/googlechat",
|
|
223
|
-
initialValue: account.config.audience || undefined,
|
|
224
|
-
validate: (value) =>
|
|
225
|
-
normalizeStringifiedOptionalString(value) ? undefined : t("common.required"),
|
|
226
|
-
});
|
|
227
|
-
return {
|
|
228
|
-
cfg: migrateBaseNameToDefaultAccount({
|
|
229
|
-
cfg: applySetupAccountConfigPatch({
|
|
230
|
-
cfg,
|
|
231
|
-
channelKey: channel,
|
|
232
|
-
accountId,
|
|
233
|
-
patch: {
|
|
234
|
-
audienceType,
|
|
235
|
-
audience: normalizeOptionalString(audience) ?? "",
|
|
236
|
-
},
|
|
237
|
-
}),
|
|
238
|
-
channelKey: channel,
|
|
239
|
-
}),
|
|
240
|
-
};
|
|
241
|
-
},
|
|
242
|
-
dmPolicy: googlechatDmPolicy,
|
|
243
|
-
};
|