-
Notifications
You must be signed in to change notification settings - Fork 1
/
googleAppsScript.ts
47 lines (42 loc) · 1.3 KB
/
googleAppsScript.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import * as SecretService from "../external/secretService";
type AppType =
| GoogleAppsScript.Slides.SlidesApp
| GoogleAppsScript.Forms.FormApp
| GoogleAppsScript.Document.DocumentApp
| GoogleAppsScript.Spreadsheet.SpreadsheetApp;
export function getOrSetSecretInteractive(
scriptContainer: AppType,
key: string,
): string {
const service = SecretService.init({
storage: PropertiesService.getUserProperties(),
mode: "interactive",
scriptContainer,
});
return service.getSecret(key);
}
export function getOrSetDocumentPropertyInteractive(
scriptContainer: AppType,
key: string,
): string {
const service = SecretService.init({
storage: PropertiesService.getDocumentProperties(),
mode: "interactive",
scriptContainer,
});
return service.getSecret(key);
}
export function getDocumentProperty(key: string): string {
const service = SecretService.init({
storage: PropertiesService.getDocumentProperties(),
mode: "silent",
});
return service.getSecret(key);
}
export function saveDocumentProperty(key: string, value: string): void {
const service = SecretService.init({
storage: PropertiesService.getDocumentProperties(),
mode: "silent",
});
service.setSecret(key, value);
}