@zhin.js/plugin-calendar 0.1.13 → 0.1.14
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/CHANGELOG.md +16 -0
- package/lib/credential-store.d.ts +4 -3
- package/lib/credential-store.d.ts.map +1 -1
- package/lib/credential-store.js.map +1 -1
- package/lib/runtime.d.ts +2 -1
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js +3 -2
- package/lib/runtime.js.map +1 -1
- package/package.json +14 -15
- package/pages/index/index.js +1 -2
- package/pages/index/index.ts +1 -2
- package/plugin.js +18 -6
- package/src/credential-store.ts +5 -4
- package/src/runtime.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @zhin.js/plugin-calendar
|
|
2
2
|
|
|
3
|
+
## 0.1.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cbf1fb1: Unify Console page blueprints (`definePageBlueprint`, `defineAdapterPage`, `defineCommentReviewPage`, `projectBlueprintToImCard`, `projectBlueprintToCliPanel`) into `@zhin.js/console-contract` and `@zhin.js/page`, add zero-esbuild pure Blueprint synthesis + static client bundle mounting to `@zhin.js/pagemanager`, remove `@zhin.js/client` (React 19) and `.tsx` from all 30 server-side plugins and adapters (including `bilibili` and `juejin`), and remove legacy Era-1 Koa `PageManager` code.
|
|
8
|
+
- 5419b88: Add generation-scoped `definePluginStore` (`PluginStore`), `Scope.get()`, declarative `PluginSetupCapabilities` return in `definePlugin()`, and `JsonSerializable<T>` typing on `PluginStateStore` to eliminate `as never` casts on TypeScript interfaces.
|
|
9
|
+
- Updated dependencies [cbf1fb1]
|
|
10
|
+
- Updated dependencies [008ccad]
|
|
11
|
+
- Updated dependencies [a1f1028]
|
|
12
|
+
- @zhin.js/console-contract@1.1.4
|
|
13
|
+
- @zhin.js/page@1.1.16
|
|
14
|
+
- @zhin.js/im-contract@1.1.13
|
|
15
|
+
- @zhin.js/host-http@1.1.16
|
|
16
|
+
- @zhin.js/tool@1.1.17
|
|
17
|
+
- @zhin.js/skill@1.1.15
|
|
18
|
+
|
|
3
19
|
## 0.1.13
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import type { JsonSerializable, JsonValue } from 'zhin.js';
|
|
2
3
|
/**
|
|
3
4
|
* Persists OAuth refresh tokens in the plugin's database state (never in .env).
|
|
4
5
|
*/
|
|
@@ -6,17 +7,17 @@ import type { OAuthProviderKind, RefreshTokenStore } from "./token-manager.js";
|
|
|
6
7
|
/** The subset of zhin's PluginStateStore used by the calendar plugin. */
|
|
7
8
|
export interface CalendarStateStore {
|
|
8
9
|
get<T>(key: string): Promise<T | undefined>;
|
|
9
|
-
set(key: string, value:
|
|
10
|
+
set<T>(key: string, value: T & JsonSerializable<T>): Promise<void>;
|
|
10
11
|
delete(key: string): Promise<void>;
|
|
11
12
|
}
|
|
12
13
|
/** Who completed the chat authorization and where to notify them later. */
|
|
13
|
-
export interface CredentialOwner<Target =
|
|
14
|
+
export interface CredentialOwner<Target = JsonValue> {
|
|
14
15
|
readonly sender_id: string;
|
|
15
16
|
/** Fixed when authorization starts; token rotation preserves it. */
|
|
16
17
|
readonly locale?: Locale;
|
|
17
18
|
readonly target: Target;
|
|
18
19
|
}
|
|
19
|
-
export interface StoredCredential<Target =
|
|
20
|
+
export interface StoredCredential<Target = JsonValue> {
|
|
20
21
|
readonly refresh_token: string;
|
|
21
22
|
readonly authorized_at: string;
|
|
22
23
|
readonly authorized_by: CredentialOwner<Target> | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-store.d.ts","sourceRoot":"","sources":["../src/credential-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C;;GAEG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"credential-store.d.ts","sourceRoot":"","sources":["../src/credential-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D;;GAEG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5C,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED,2EAA2E;AAC3E,MAAM,WAAW,eAAe,CAAC,MAAM,GAAG,SAAS;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB,CAAC,MAAM,GAAG,SAAS;IAClD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CACxD;AAMD,qBAAa,uBAAuB;;gBAGtB,KAAK,EAAE,kBAAkB;IAI/B,GAAG,CACP,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAUlC,IAAI,CACR,QAAQ,EAAE,iBAAiB,EAC3B,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,eAAe,GAAG,IAAI,GACnC,OAAO,CAAC,IAAI,CAAC;IASV,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD,6EAA6E;IAC7E,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,iBAAiB;CAalE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-store.js","sourceRoot":"","sources":["../src/credential-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credential-store.js","sourceRoot":"","sources":["../src/credential-store.ts"],"names":[],"mappings":"AA4BA,SAAS,aAAa,CAAC,QAA2B;IAChD,OAAO,SAAS,QAAQ,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,OAAO,uBAAuB;IACzB,MAAM,CAAqB;IAEpC,YAAY,KAAyB;QACnC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,GAAG,CACP,QAA2B;QAE3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAClC,aAAa,CAAC,QAAQ,CAAC,CACxB,CAAC;QACF,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ,EAAE,CAAC;YACxD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,IAAI,CACR,QAA2B,EAC3B,YAAoB,EACpB,YAAoC;QAEpC,MAAM,UAAU,GAAqB;YACnC,aAAa,EAAE,YAAY;YAC3B,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACvC,aAAa,EAAE,YAAY;SAC5B,CAAC;QACF,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAA2B;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,6EAA6E;IAC7E,iBAAiB,CAAC,QAA2B;QAC3C,OAAO;YACL,IAAI,EAAE,KAAK,IAAI,EAAE;gBACf,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC5C,OAAO,UAAU,EAAE,aAAa,CAAC;YACnC,CAAC;YACD,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;gBAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC1C,MAAM,YAAY,GAAG,QAAQ,EAAE,aAAa,IAAI,IAAI,CAAC;gBACrD,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;YACxD,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/lib/runtime.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export interface CalendarRuntime {
|
|
|
7
7
|
/** Chat authorization flow used by the `calendar` commands. */
|
|
8
8
|
readonly auth: CalendarAuthService<unknown>;
|
|
9
9
|
}
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const calendarRuntimeStore: import("zhin.js").PluginStore<CalendarRuntime, unknown>;
|
|
11
|
+
export declare const calendarRuntimeToken: import("zhin.js").PluginStore<CalendarRuntime, unknown>;
|
|
11
12
|
//# sourceMappingURL=runtime.d.ts.map
|
package/lib/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChD,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChD,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,oBAAoB,yDAGhC,CAAC;AACF,eAAO,MAAM,oBAAoB,yDAAuB,CAAC"}
|
package/lib/runtime.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const
|
|
1
|
+
import { definePluginStore } from "zhin.js";
|
|
2
|
+
export const calendarRuntimeStore = definePluginStore("zhin.calendar.runtime", "Owner-scoped calendar provider and config");
|
|
3
|
+
export const calendarRuntimeToken = calendarRuntimeStore;
|
|
3
4
|
//# sourceMappingURL=runtime.js.map
|
package/lib/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAY5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CACnD,uBAAuB,EACvB,2CAA2C,CAC5C,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/plugin-calendar",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "CalDAV / Google / Microsoft calendar tools for Zhin Agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -40,28 +40,27 @@
|
|
|
40
40
|
"url": "https://github.com/lc-cn"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@zhin.js/
|
|
44
|
-
"@zhin.js/
|
|
45
|
-
"@zhin.js/
|
|
46
|
-
"@zhin.js/
|
|
47
|
-
"@zhin.js/
|
|
48
|
-
"@zhin.js/
|
|
49
|
-
"@zhin.js/tool": "1.1.16"
|
|
43
|
+
"@zhin.js/console-contract": "1.1.4",
|
|
44
|
+
"@zhin.js/host-http": "1.1.16",
|
|
45
|
+
"@zhin.js/im-contract": "1.1.13",
|
|
46
|
+
"@zhin.js/page": "1.1.16",
|
|
47
|
+
"@zhin.js/skill": "1.1.15",
|
|
48
|
+
"@zhin.js/tool": "1.1.17"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"typescript": "^6.0.3",
|
|
53
52
|
"vitest": "^4.1.10",
|
|
54
53
|
"zod": "^4.4.3",
|
|
55
|
-
"@zhin.js/command": "1.1.
|
|
56
|
-
"zhin.js": "1.1.
|
|
54
|
+
"@zhin.js/command": "1.1.16",
|
|
55
|
+
"zhin.js": "1.1.23"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|
|
59
58
|
"zod": "^4.0.0",
|
|
60
|
-
"@zhin.js/command": "^1.1.
|
|
61
|
-
"@zhin.js/page": "^1.1.
|
|
62
|
-
"@zhin.js/skill": "^1.1.
|
|
63
|
-
"@zhin.js/tool": "^1.1.
|
|
64
|
-
"zhin.js": "^1.1.
|
|
59
|
+
"@zhin.js/command": "^1.1.16",
|
|
60
|
+
"@zhin.js/page": "^1.1.16",
|
|
61
|
+
"@zhin.js/skill": "^1.1.15",
|
|
62
|
+
"@zhin.js/tool": "^1.1.17",
|
|
63
|
+
"zhin.js": "^1.1.23"
|
|
65
64
|
},
|
|
66
65
|
"peerDependenciesMeta": {
|
|
67
66
|
"@zhin.js/command": {
|
package/pages/index/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
-
import { definePage } from '@zhin.js/console-contract';
|
|
3
|
-
import { createDeclarativePage } from '@zhin.js/client';
|
|
2
|
+
import { definePage, createDeclarativePage } from '@zhin.js/console-contract';
|
|
4
3
|
export const meta = definePage({
|
|
5
4
|
title: '日历日程',
|
|
6
5
|
titleI18n: { en: 'Calendar' },
|
package/pages/index/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { definePage } from '@zhin.js/console-contract';
|
|
2
|
-
import { createDeclarativePage } from '@zhin.js/client';
|
|
1
|
+
import { definePage, createDeclarativePage } from '@zhin.js/console-contract';
|
|
3
2
|
|
|
4
3
|
export interface CalendarConsoleStatus {
|
|
5
4
|
readonly provider: 'none' | 'google' | 'microsoft' | 'caldav' | 'ics';
|
package/plugin.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
2
|
import { projectLocaleToken } from 'zhin.js/i18n';
|
|
3
|
-
import { databaseHostToken, definePlugin, outboundHostToken, pluginConsoleRpcToken, } from "zhin.js";
|
|
3
|
+
import { databaseHostToken, definePlugin, definePluginCapabilityGraph, outboundHostToken, pluginConsoleRpcToken, } from "zhin.js";
|
|
4
4
|
import { httpHostToken } from "@zhin.js/host-http";
|
|
5
5
|
import { assertCalendarTimezone, createCalendarConsoleRpc, createCalendarProvider, createOAuthTokenManagers, } from "./lib/index.js";
|
|
6
6
|
import { buildRedirectUri, CalendarAuthService, DEFAULT_OAUTH_CALLBACK_PATH, localOriginFromAddress, } from "./lib/chat-auth.js";
|
|
7
7
|
import { CalendarCredentialStore, } from "./lib/credential-store.js";
|
|
8
8
|
import { registerOAuthCallbackRoute } from "./lib/http-callback.js";
|
|
9
|
-
import {
|
|
9
|
+
import { calendarRuntimeStore } from "./lib/runtime.js";
|
|
10
10
|
export default definePlugin({
|
|
11
11
|
name: "calendar",
|
|
12
12
|
metadata: { displayName: "日历" },
|
|
13
|
+
capabilityGraph: definePluginCapabilityGraph({
|
|
14
|
+
provides: [calendarRuntimeStore, pluginConsoleRpcToken],
|
|
15
|
+
injects: [databaseHostToken, outboundHostToken, httpHostToken, projectLocaleToken],
|
|
16
|
+
features: {
|
|
17
|
+
commands: ["calendar/auth", "calendar/logout", "calendar/status"],
|
|
18
|
+
skills: ["calendar-scheduling"],
|
|
19
|
+
tools: ["create_event", "find_free_time", "list_events"],
|
|
20
|
+
pages: ["index"],
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
13
23
|
setup(context) {
|
|
14
24
|
const config = context.config.get();
|
|
15
25
|
assertCalendarTimezone(config.timezone);
|
|
@@ -59,16 +69,18 @@ export default definePlugin({
|
|
|
59
69
|
provider,
|
|
60
70
|
auth: auth,
|
|
61
71
|
};
|
|
62
|
-
|
|
63
|
-
context.resources.provide(pluginConsoleRpcToken, createCalendarConsoleRpc(runtime));
|
|
72
|
+
calendarRuntimeStore.provide(context, runtime);
|
|
64
73
|
if (config.provider !== "none" && !provider) {
|
|
65
74
|
console.warn("[calendar] provider 已配置但凭据为空,日历工具将不可用;Google/Microsoft 请先配置 client_id,再在聊天中发送 calendar auth <provider>");
|
|
66
75
|
}
|
|
67
76
|
const releaseRoute = http
|
|
68
77
|
? registerOAuthCallbackRoute(http, callbackPath, (searchParams) => auth.handleCallback(searchParams))
|
|
69
78
|
: undefined;
|
|
70
|
-
return
|
|
71
|
-
|
|
79
|
+
return {
|
|
80
|
+
consoleRpc: createCalendarConsoleRpc(runtime),
|
|
81
|
+
dispose: () => {
|
|
82
|
+
releaseRoute?.();
|
|
83
|
+
},
|
|
72
84
|
};
|
|
73
85
|
},
|
|
74
86
|
});
|
package/src/credential-store.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import type { JsonSerializable, JsonValue } from 'zhin.js';
|
|
2
3
|
/**
|
|
3
4
|
* Persists OAuth refresh tokens in the plugin's database state (never in .env).
|
|
4
5
|
*/
|
|
@@ -7,19 +8,19 @@ import type { OAuthProviderKind, RefreshTokenStore } from "./token-manager.js";
|
|
|
7
8
|
/** The subset of zhin's PluginStateStore used by the calendar plugin. */
|
|
8
9
|
export interface CalendarStateStore {
|
|
9
10
|
get<T>(key: string): Promise<T | undefined>;
|
|
10
|
-
set(key: string, value:
|
|
11
|
+
set<T>(key: string, value: T & JsonSerializable<T>): Promise<void>;
|
|
11
12
|
delete(key: string): Promise<void>;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/** Who completed the chat authorization and where to notify them later. */
|
|
15
|
-
export interface CredentialOwner<Target =
|
|
16
|
+
export interface CredentialOwner<Target = JsonValue> {
|
|
16
17
|
readonly sender_id: string;
|
|
17
18
|
/** Fixed when authorization starts; token rotation preserves it. */
|
|
18
19
|
readonly locale?: Locale;
|
|
19
20
|
readonly target: Target;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export interface StoredCredential<Target =
|
|
23
|
+
export interface StoredCredential<Target = JsonValue> {
|
|
23
24
|
readonly refresh_token: string;
|
|
24
25
|
readonly authorized_at: string;
|
|
25
26
|
readonly authorized_by: CredentialOwner<Target> | null;
|
|
@@ -58,7 +59,7 @@ export class CalendarCredentialStore {
|
|
|
58
59
|
authorized_at: new Date().toISOString(),
|
|
59
60
|
authorized_by: authorizedBy,
|
|
60
61
|
};
|
|
61
|
-
await this.#state.set(credentialKey(provider), credential
|
|
62
|
+
await this.#state.set(credentialKey(provider), credential);
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
async delete(provider: OAuthProviderKind): Promise<void> {
|
package/src/runtime.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { definePluginStore } from "zhin.js";
|
|
2
2
|
import type { CalendarConfig } from "./config.js";
|
|
3
3
|
import type { CalendarProvider } from "./types.js";
|
|
4
4
|
import type { CalendarAuthService } from "./chat-auth.js";
|
|
@@ -10,7 +10,8 @@ export interface CalendarRuntime {
|
|
|
10
10
|
readonly auth: CalendarAuthService<unknown>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const
|
|
13
|
+
export const calendarRuntimeStore = definePluginStore<CalendarRuntime>(
|
|
14
14
|
"zhin.calendar.runtime",
|
|
15
15
|
"Owner-scoped calendar provider and config"
|
|
16
16
|
);
|
|
17
|
+
export const calendarRuntimeToken = calendarRuntimeStore;
|