@parlor/capabilities 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +15 -2
- package/dist/adapters/capacitor.d.ts +3 -0
- package/dist/adapters/capacitor.d.ts.map +1 -0
- package/dist/adapters/capacitor.js +21 -0
- package/dist/adapters/capacitor.js.map +1 -0
- package/dist/adapters/tauri.d.ts +3 -0
- package/dist/adapters/tauri.d.ts.map +1 -0
- package/dist/adapters/tauri.js +21 -0
- package/dist/adapters/tauri.js.map +1 -0
- package/dist/adapters/types.d.ts +16 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/adapters/web.d.ts +3 -0
- package/dist/adapters/web.d.ts.map +1 -0
- package/dist/adapters/web.js +15 -0
- package/dist/adapters/web.js.map +1 -0
- package/dist/capability.d.ts +21 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +21 -0
- package/dist/capability.js.map +1 -0
- package/dist/deep-link/capacitor.d.ts +16 -0
- package/dist/deep-link/capacitor.d.ts.map +1 -0
- package/dist/deep-link/capacitor.js +28 -0
- package/dist/deep-link/capacitor.js.map +1 -0
- package/dist/deep-link/index.d.ts +7 -0
- package/dist/deep-link/index.d.ts.map +1 -0
- package/dist/deep-link/index.js +10 -0
- package/dist/deep-link/index.js.map +1 -0
- package/dist/deep-link/interface.d.ts +5 -0
- package/dist/deep-link/interface.d.ts.map +1 -0
- package/dist/deep-link/interface.js +2 -0
- package/dist/deep-link/interface.js.map +1 -0
- package/dist/deep-link/tauri.d.ts +8 -0
- package/dist/deep-link/tauri.d.ts.map +1 -0
- package/dist/deep-link/tauri.js +28 -0
- package/dist/deep-link/tauri.js.map +1 -0
- package/dist/deep-link/web.d.ts +4 -0
- package/dist/deep-link/web.d.ts.map +1 -0
- package/dist/deep-link/web.js +20 -0
- package/dist/deep-link/web.js.map +1 -0
- package/dist/device-key/capacitor.d.ts +32 -0
- package/dist/device-key/capacitor.d.ts.map +1 -0
- package/dist/device-key/capacitor.js +9 -0
- package/dist/device-key/capacitor.js.map +1 -0
- package/dist/device-key/encoding.d.ts +12 -0
- package/dist/device-key/encoding.d.ts.map +1 -0
- package/dist/device-key/encoding.js +45 -0
- package/dist/device-key/encoding.js.map +1 -0
- package/dist/device-key/index.d.ts +8 -0
- package/dist/device-key/index.d.ts.map +1 -0
- package/dist/device-key/index.js +11 -0
- package/dist/device-key/index.js.map +1 -0
- package/dist/device-key/interface.d.ts +74 -0
- package/dist/device-key/interface.d.ts.map +1 -0
- package/dist/device-key/interface.js +7 -0
- package/dist/device-key/interface.js.map +1 -0
- package/dist/device-key/native.d.ts +38 -0
- package/dist/device-key/native.d.ts.map +1 -0
- package/dist/device-key/native.js +67 -0
- package/dist/device-key/native.js.map +1 -0
- package/dist/device-key/tauri.d.ts +8 -0
- package/dist/device-key/tauri.d.ts.map +1 -0
- package/dist/device-key/tauri.js +16 -0
- package/dist/device-key/tauri.js.map +1 -0
- package/dist/device-key/web.d.ts +11 -0
- package/dist/device-key/web.d.ts.map +1 -0
- package/dist/device-key/web.js +210 -0
- package/dist/device-key/web.js.map +1 -0
- package/dist/files/capacitor.d.ts +19 -0
- package/dist/files/capacitor.d.ts.map +1 -0
- package/dist/files/capacitor.js +47 -0
- package/dist/files/capacitor.js.map +1 -0
- package/dist/files/index.d.ts +7 -0
- package/dist/files/index.d.ts.map +1 -0
- package/dist/files/index.js +10 -0
- package/dist/files/index.js.map +1 -0
- package/dist/files/interface.d.ts +29 -0
- package/dist/files/interface.d.ts.map +1 -0
- package/dist/files/interface.js +2 -0
- package/dist/files/interface.js.map +1 -0
- package/dist/files/mime.d.ts +11 -0
- package/dist/files/mime.d.ts.map +1 -0
- package/dist/files/mime.js +56 -0
- package/dist/files/mime.js.map +1 -0
- package/dist/files/tauri.d.ts +27 -0
- package/dist/files/tauri.d.ts.map +1 -0
- package/dist/files/tauri.js +46 -0
- package/dist/files/tauri.js.map +1 -0
- package/dist/files/web.d.ts +21 -0
- package/dist/files/web.d.ts.map +1 -0
- package/dist/files/web.js +82 -0
- package/dist/files/web.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/local-agent-host/capacitor.d.ts +5 -0
- package/dist/local-agent-host/capacitor.d.ts.map +1 -0
- package/dist/local-agent-host/capacitor.js +11 -0
- package/dist/local-agent-host/capacitor.js.map +1 -0
- package/dist/local-agent-host/index.d.ts +7 -0
- package/dist/local-agent-host/index.d.ts.map +1 -0
- package/dist/local-agent-host/index.js +10 -0
- package/dist/local-agent-host/index.js.map +1 -0
- package/dist/local-agent-host/interface.d.ts +62 -0
- package/dist/local-agent-host/interface.d.ts.map +1 -0
- package/dist/local-agent-host/interface.js +2 -0
- package/dist/local-agent-host/interface.js.map +1 -0
- package/dist/local-agent-host/tauri.d.ts +10 -0
- package/dist/local-agent-host/tauri.d.ts.map +1 -0
- package/dist/local-agent-host/tauri.js +38 -0
- package/dist/local-agent-host/tauri.js.map +1 -0
- package/dist/local-agent-host/web.d.ts +5 -0
- package/dist/local-agent-host/web.d.ts.map +1 -0
- package/dist/local-agent-host/web.js +11 -0
- package/dist/local-agent-host/web.js.map +1 -0
- package/dist/notifications/capacitor.d.ts +28 -0
- package/dist/notifications/capacitor.d.ts.map +1 -0
- package/dist/notifications/capacitor.js +39 -0
- package/dist/notifications/capacitor.js.map +1 -0
- package/dist/notifications/index.d.ts +7 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +10 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/interface.d.ts +14 -0
- package/dist/notifications/interface.d.ts.map +1 -0
- package/dist/notifications/interface.js +2 -0
- package/dist/notifications/interface.js.map +1 -0
- package/dist/notifications/tauri.d.ts +12 -0
- package/dist/notifications/tauri.d.ts.map +1 -0
- package/dist/notifications/tauri.js +28 -0
- package/dist/notifications/tauri.js.map +1 -0
- package/dist/notifications/web.d.ts +15 -0
- package/dist/notifications/web.d.ts.map +1 -0
- package/dist/notifications/web.js +23 -0
- package/dist/notifications/web.js.map +1 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +9 -0
- package/dist/runtime.js.map +1 -0
- package/dist/session-store/capacitor.d.ts +17 -0
- package/dist/session-store/capacitor.d.ts.map +1 -0
- package/dist/session-store/capacitor.js +21 -0
- package/dist/session-store/capacitor.js.map +1 -0
- package/dist/session-store/index.d.ts +8 -0
- package/dist/session-store/index.d.ts.map +1 -0
- package/dist/session-store/index.js +11 -0
- package/dist/session-store/index.js.map +1 -0
- package/dist/session-store/interface.d.ts +9 -0
- package/dist/session-store/interface.d.ts.map +1 -0
- package/dist/session-store/interface.js +2 -0
- package/dist/session-store/interface.js.map +1 -0
- package/dist/session-store/keychain.d.ts +13 -0
- package/dist/session-store/keychain.d.ts.map +1 -0
- package/dist/session-store/keychain.js +36 -0
- package/dist/session-store/keychain.js.map +1 -0
- package/dist/session-store/local.d.ts +10 -0
- package/dist/session-store/local.d.ts.map +1 -0
- package/dist/session-store/local.js +15 -0
- package/dist/session-store/local.js.map +1 -0
- package/dist/session-store/tauri.d.ts +10 -0
- package/dist/session-store/tauri.d.ts.map +1 -0
- package/dist/session-store/tauri.js +24 -0
- package/dist/session-store/tauri.js.map +1 -0
- package/dist/session-store/web.d.ts +5 -0
- package/dist/session-store/web.d.ts.map +1 -0
- package/dist/session-store/web.js +11 -0
- package/dist/session-store/web.js.map +1 -0
- package/package.json +95 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { platformAdapters } from "#adapters";
|
|
2
|
+
import { defineCapability } from "../capability.js";
|
|
3
|
+
export { capacitorNotifications } from "./capacitor.js";
|
|
4
|
+
export { tauriNotifications } from "./tauri.js";
|
|
5
|
+
export { webNotifications } from "./web.js";
|
|
6
|
+
export const notifications = defineCapability({
|
|
7
|
+
name: "notifications",
|
|
8
|
+
adapters: platformAdapters.notifications,
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AASpD,OAAO,EAAE,sBAAsB,EAAoC,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAgC,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAgB;IAC3D,IAAI,EAAE,eAAe;IACrB,QAAQ,EAAE,gBAAgB,CAAC,aAAa;CACzC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type NotificationPermission = "granted" | "denied" | "default";
|
|
2
|
+
export interface NotificationOptions {
|
|
3
|
+
readonly body?: string | undefined;
|
|
4
|
+
readonly tag?: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface NotificationHandle {
|
|
7
|
+
close(): void;
|
|
8
|
+
}
|
|
9
|
+
export interface Notifications {
|
|
10
|
+
permission(): NotificationPermission;
|
|
11
|
+
request(): Promise<NotificationPermission>;
|
|
12
|
+
show(title: string, options?: NotificationOptions): Promise<NotificationHandle>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/notifications/interface.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEtE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,IAAI,sBAAsB,CAAC;IACrC,OAAO,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/notifications/interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CapabilityAdapter } from "../capability.js";
|
|
2
|
+
import type { NotificationPermission, Notifications } from "./interface.js";
|
|
3
|
+
export interface TauriNotificationModule {
|
|
4
|
+
isPermissionGranted(): Promise<boolean>;
|
|
5
|
+
requestPermission(): Promise<NotificationPermission>;
|
|
6
|
+
sendNotification(options: {
|
|
7
|
+
title: string;
|
|
8
|
+
body?: string;
|
|
9
|
+
}): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function tauriNotifications(load?: () => Promise<TauriNotificationModule>): CapabilityAdapter<Notifications>;
|
|
12
|
+
//# sourceMappingURL=tauri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tauri.d.ts","sourceRoot":"","sources":["../../src/notifications/tauri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE5E,MAAM,WAAW,uBAAuB;IACtC,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,iBAAiB,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrD,gBAAgB,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACnE;AAED,wBAAgB,kBAAkB,CAChC,IAAI,GAAE,MAAM,OAAO,CAAC,uBAAuB,CACA,GAC1C,iBAAiB,CAAC,aAAa,CAAC,CA2BlC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { detectPlatform } from "../runtime.js";
|
|
2
|
+
export function tauriNotifications(load = () => import("@tauri-apps/plugin-notification")) {
|
|
3
|
+
return {
|
|
4
|
+
platform: "tauri",
|
|
5
|
+
available: () => detectPlatform() === "tauri",
|
|
6
|
+
create: async () => {
|
|
7
|
+
const plugin = await load();
|
|
8
|
+
let permission = (await plugin.isPermissionGranted())
|
|
9
|
+
? "granted"
|
|
10
|
+
: "default";
|
|
11
|
+
return {
|
|
12
|
+
permission: () => permission,
|
|
13
|
+
request: async () => {
|
|
14
|
+
permission = await plugin.requestPermission();
|
|
15
|
+
return permission;
|
|
16
|
+
},
|
|
17
|
+
show: async (title, options) => {
|
|
18
|
+
if (permission !== "granted") {
|
|
19
|
+
throw new Error("Notification permission has not been granted");
|
|
20
|
+
}
|
|
21
|
+
plugin.sendNotification(options?.body === undefined ? { title } : { title, body: options.body });
|
|
22
|
+
return { close: () => { } };
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=tauri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tauri.js","sourceRoot":"","sources":["../../src/notifications/tauri.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAS/C,MAAM,UAAU,kBAAkB,CAChC,IAAI,GAA2C,GAAG,EAAE,CAClD,MAAM,CAAC,iCAAiC,CAAC;IAE3C,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,SAAS,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,KAAK,OAAO;QAC7C,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;YAC5B,IAAI,UAAU,GAA2B,CAAC,MAAM,MAAM,CAAC,mBAAmB,EAAE,CAAC;gBAC3E,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,SAAS,CAAC;YACd,OAAO;gBACL,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU;gBAC5B,OAAO,EAAE,KAAK,IAAI,EAAE;oBAClB,UAAU,GAAG,MAAM,MAAM,CAAC,iBAAiB,EAAE,CAAC;oBAC9C,OAAO,UAAU,CAAC;gBACpB,CAAC;gBACD,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;oBAC7B,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;wBAC7B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;oBAClE,CAAC;oBACD,MAAM,CAAC,gBAAgB,CACrB,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CACxE,CAAC;oBACF,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;gBAC7B,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CapabilityAdapter } from "../capability.js";
|
|
2
|
+
import type { NotificationPermission, Notifications } from "./interface.js";
|
|
3
|
+
interface NotificationApi {
|
|
4
|
+
readonly permission: NotificationPermission;
|
|
5
|
+
requestPermission(): Promise<NotificationPermission>;
|
|
6
|
+
new (title: string, options?: {
|
|
7
|
+
body?: string | undefined;
|
|
8
|
+
tag?: string | undefined;
|
|
9
|
+
}): {
|
|
10
|
+
close(): void;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function webNotifications(getApi?: () => NotificationApi | undefined): CapabilityAdapter<Notifications>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/notifications/web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE5E,UAAU,eAAe;IACvB,QAAQ,CAAC,UAAU,EAAE,sBAAsB,CAAC;IAC5C,iBAAiB,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrD,KACE,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GAChE;QAAE,KAAK,IAAI,IAAI,CAAA;KAAE,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,GAAE,MAAM,eAAe,GAAG,SACiC,GAChE,iBAAiB,CAAC,aAAa,CAAC,CAoBlC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function webNotifications(getApi = () => globalThis.Notification) {
|
|
2
|
+
return {
|
|
3
|
+
platform: "web",
|
|
4
|
+
available: () => getApi() !== undefined,
|
|
5
|
+
create: () => {
|
|
6
|
+
const api = getApi();
|
|
7
|
+
if (!api)
|
|
8
|
+
throw new Error("Notification API is not available");
|
|
9
|
+
return {
|
|
10
|
+
permission: () => api.permission,
|
|
11
|
+
request: () => api.requestPermission(),
|
|
12
|
+
show: async (title, options) => {
|
|
13
|
+
if (api.permission !== "granted") {
|
|
14
|
+
throw new Error("Notification permission has not been granted");
|
|
15
|
+
}
|
|
16
|
+
const notification = new api(title, options);
|
|
17
|
+
return { close: () => notification.close() };
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/notifications/web.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,gBAAgB,CAC9B,MAAM,GAAsC,GAAG,EAAE,CAC9C,UAAiD,CAAC,YAAY;IAEjE,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,KAAK,SAAS;QACvC,MAAM,EAAE,GAAG,EAAE;YACX,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;YACrB,IAAI,CAAC,GAAG;gBAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YAC/D,OAAO;gBACL,UAAU,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU;gBAChC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,iBAAiB,EAAE;gBACtC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;oBAC7B,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;wBACjC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;oBAClE,CAAC;oBACD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;oBAC7C,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC;gBAC/C,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,WAAW,GAAG,OAAO,CAAC;AAOrD,wBAAgB,cAAc,CAAC,OAAO,GAAE,OAAoB,GAAG,QAAQ,CAKtE"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,cAAc,CAAC,OAAO,GAAY,UAAU;IAC1D,MAAM,CAAC,GAAG,OAA0B,CAAC;IACrC,IAAI,CAAC,CAAC,mBAAmB;QAAE,OAAO,OAAO,CAAC;IAC1C,IAAI,CAAC,CAAC,SAAS,EAAE,gBAAgB,EAAE,EAAE;QAAE,OAAO,WAAW,CAAC;IAC1D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CapabilityAdapter } from "../capability.js";
|
|
2
|
+
import type { SessionStore } from "./interface.js";
|
|
3
|
+
import { type StorageLike } from "./local.js";
|
|
4
|
+
/** The `ParlorSessionStore` native plugin: the iOS Keychain. */
|
|
5
|
+
export interface CapacitorSessionModule {
|
|
6
|
+
ParlorSessionStore: {
|
|
7
|
+
get(): Promise<{
|
|
8
|
+
value?: string;
|
|
9
|
+
}>;
|
|
10
|
+
set(options: {
|
|
11
|
+
value?: string;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** The iOS Keychain; the webview's own storage where the plugin has no implementation. */
|
|
16
|
+
export declare function capacitorSessionStore(storage?: () => StorageLike, load?: () => Promise<CapacitorSessionModule>): CapabilityAdapter<SessionStore>;
|
|
17
|
+
//# sourceMappingURL=capacitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capacitor.d.ts","sourceRoot":"","sources":["../../src/session-store/capacitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE,gEAAgE;AAChE,MAAM,WAAW,sBAAsB;IACrC,kBAAkB,EAAE;QAClB,GAAG,IAAI,OAAO,CAAC;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACnC,GAAG,CAAC,OAAO,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACjD,CAAC;CACH;AAED,0FAA0F;AAC1F,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,MAAM,WAA2C,EAC1D,IAAI,GAAE,MAAM,OAAO,CAAC,sBAAsB,CACF,GACvC,iBAAiB,CAAC,YAAY,CAAC,CAiBjC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { hasIosPlugin } from "../device-key/native.js";
|
|
2
|
+
import { detectPlatform } from "../runtime.js";
|
|
3
|
+
import { keychainSessionStore } from "./keychain.js";
|
|
4
|
+
import { localSessionStore } from "./local.js";
|
|
5
|
+
/** The iOS Keychain; the webview's own storage where the plugin has no implementation. */
|
|
6
|
+
export function capacitorSessionStore(storage = () => globalThis.localStorage, load = () => import("@parlor/capacitor-device-key")) {
|
|
7
|
+
return {
|
|
8
|
+
platform: "capacitor",
|
|
9
|
+
available: () => detectPlatform() === "capacitor",
|
|
10
|
+
create: async () => {
|
|
11
|
+
if (!hasIosPlugin())
|
|
12
|
+
return localSessionStore(storage());
|
|
13
|
+
const { ParlorSessionStore } = await load();
|
|
14
|
+
return keychainSessionStore({
|
|
15
|
+
get: async () => (await ParlorSessionStore.get()).value,
|
|
16
|
+
set: (token) => ParlorSessionStore.set(token === undefined ? {} : { value: token }),
|
|
17
|
+
}, storage());
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=capacitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capacitor.js","sourceRoot":"","sources":["../../src/session-store/capacitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AAUjE,0FAA0F;AAC1F,MAAM,UAAU,qBAAqB,CACnC,OAAO,GAAsB,GAAG,EAAE,CAAC,UAAU,CAAC,YAAY,EAC1D,IAAI,GAA0C,GAAG,EAAE,CACjD,MAAM,CAAC,8BAA8B,CAAC;IAExC,OAAO;QACL,QAAQ,EAAE,WAAW;QACrB,SAAS,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,KAAK,WAAW;QACjD,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC,YAAY,EAAE;gBAAE,OAAO,iBAAiB,CAAC,OAAO,EAAE,CAAC,CAAC;YACzD,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;YAC5C,OAAO,oBAAoB,CACzB;gBACE,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK;gBACvD,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CACb,kBAAkB,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;aACtE,EACD,OAAO,EAAE,CACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SessionStore } from "./interface.js";
|
|
2
|
+
export type { SessionStore } from "./interface.js";
|
|
3
|
+
export { capacitorSessionStore } from "./capacitor.js";
|
|
4
|
+
export { localSessionStore, SESSION_STORAGE_KEY, type StorageLike } from "./local.js";
|
|
5
|
+
export { tauriSessionStore } from "./tauri.js";
|
|
6
|
+
export { webSessionStore } from "./web.js";
|
|
7
|
+
export declare const sessionStore: import("../capability.js").CapabilityDefinition<SessionStore>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session-store/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY,+DAGvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { platformAdapters } from "#adapters";
|
|
2
|
+
import { defineCapability } from "../capability.js";
|
|
3
|
+
export { capacitorSessionStore } from "./capacitor.js";
|
|
4
|
+
export { localSessionStore, SESSION_STORAGE_KEY } from "./local.js";
|
|
5
|
+
export { tauriSessionStore } from "./tauri.js";
|
|
6
|
+
export { webSessionStore } from "./web.js";
|
|
7
|
+
export const sessionStore = defineCapability({
|
|
8
|
+
name: "sessionStore",
|
|
9
|
+
adapters: platformAdapters.sessionStore,
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session-store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAoB,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAe;IACzD,IAAI,EAAE,cAAc;IACpB,QAAQ,EAAE,gBAAgB,CAAC,YAAY;CACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a native shell keeps its bearer session. A browser needs none: the session rides
|
|
3
|
+
* in a cookie the page cannot read.
|
|
4
|
+
*/
|
|
5
|
+
export interface SessionStore {
|
|
6
|
+
get(): Promise<string | undefined>;
|
|
7
|
+
set(token: string | undefined): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/session-store/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACnC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/session-store/interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SessionStore } from "./interface.js";
|
|
2
|
+
import { type StorageLike } from "./local.js";
|
|
3
|
+
export interface NativeSession {
|
|
4
|
+
get(): Promise<string | undefined>;
|
|
5
|
+
set(token: string | undefined): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The token lives in the platform keychain only. A token an earlier release left in the
|
|
9
|
+
* webview's storage moves over on the first read and is deleted there; a failed move is
|
|
10
|
+
* retried by the next call.
|
|
11
|
+
*/
|
|
12
|
+
export declare function keychainSessionStore(native: NativeSession, legacy: StorageLike): SessionStore;
|
|
13
|
+
//# sourceMappingURL=keychain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../src/session-store/keychain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,WAAW,aAAa;IAC5B,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACnC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,WAAW,GAClB,YAAY,CAyBd"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SESSION_STORAGE_KEY } from "./local.js";
|
|
2
|
+
/**
|
|
3
|
+
* The token lives in the platform keychain only. A token an earlier release left in the
|
|
4
|
+
* webview's storage moves over on the first read and is deleted there; a failed move is
|
|
5
|
+
* retried by the next call.
|
|
6
|
+
*/
|
|
7
|
+
export function keychainSessionStore(native, legacy) {
|
|
8
|
+
let migrated;
|
|
9
|
+
const move = async () => {
|
|
10
|
+
const old = legacy.getItem(SESSION_STORAGE_KEY);
|
|
11
|
+
if (old === null)
|
|
12
|
+
return;
|
|
13
|
+
if ((await native.get()) === undefined)
|
|
14
|
+
await native.set(old);
|
|
15
|
+
legacy.removeItem(SESSION_STORAGE_KEY);
|
|
16
|
+
};
|
|
17
|
+
const migrate = () => {
|
|
18
|
+
const attempt = (migrated ??= move());
|
|
19
|
+
attempt.catch(() => {
|
|
20
|
+
if (migrated === attempt)
|
|
21
|
+
migrated = undefined;
|
|
22
|
+
});
|
|
23
|
+
return attempt;
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
get: async () => {
|
|
27
|
+
await migrate();
|
|
28
|
+
return native.get();
|
|
29
|
+
},
|
|
30
|
+
set: async (token) => {
|
|
31
|
+
await migrate();
|
|
32
|
+
await native.set(token);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=keychain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keychain.js","sourceRoot":"","sources":["../../src/session-store/keychain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,YAAY,CAAC;AAOnE;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAqB,EACrB,MAAmB;IAEnB,IAAI,QAAmC,CAAC;IACxC,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;QACtB,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAChD,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO;QACzB,IAAI,CAAC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,SAAS;YAAE,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9D,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,MAAM,OAAO,GAAG,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC,CAAC;QACtC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE;YACjB,IAAI,QAAQ,KAAK,OAAO;gBAAE,QAAQ,GAAG,SAAS,CAAC;QACjD,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IACF,OAAO;QACL,GAAG,EAAE,KAAK,IAAI,EAAE;YACd,MAAM,OAAO,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC;QACtB,CAAC;QACD,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACnB,MAAM,OAAO,EAAE,CAAC;YAChB,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SessionStore } from "./interface.js";
|
|
2
|
+
export declare const SESSION_STORAGE_KEY = "parlor.session";
|
|
3
|
+
export interface StorageLike {
|
|
4
|
+
getItem(key: string): string | null;
|
|
5
|
+
setItem(key: string, value: string): void;
|
|
6
|
+
removeItem(key: string): void;
|
|
7
|
+
}
|
|
8
|
+
/** The baseline for native shells until their keystore adapters land: the webview's own storage. */
|
|
9
|
+
export declare function localSessionStore(storage: StorageLike): SessionStore;
|
|
10
|
+
//# sourceMappingURL=local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/session-store/local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,YAAY,CASpE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const SESSION_STORAGE_KEY = "parlor.session";
|
|
2
|
+
/** The baseline for native shells until their keystore adapters land: the webview's own storage. */
|
|
3
|
+
export function localSessionStore(storage) {
|
|
4
|
+
return {
|
|
5
|
+
get: () => Promise.resolve(storage.getItem(SESSION_STORAGE_KEY) ?? undefined),
|
|
6
|
+
set: (token) => {
|
|
7
|
+
if (token === undefined)
|
|
8
|
+
storage.removeItem(SESSION_STORAGE_KEY);
|
|
9
|
+
else
|
|
10
|
+
storage.setItem(SESSION_STORAGE_KEY, token);
|
|
11
|
+
return Promise.resolve();
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/session-store/local.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAQpD,oGAAoG;AACpG,MAAM,UAAU,iBAAiB,CAAC,OAAoB;IACpD,OAAO;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,SAAS,CAAC;QAC7E,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;YACb,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;;gBAC5D,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;YACjD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CapabilityAdapter } from "../capability.js";
|
|
2
|
+
import type { TauriInvoke } from "../device-key/tauri.js";
|
|
3
|
+
import type { SessionStore } from "./interface.js";
|
|
4
|
+
import { type StorageLike } from "./local.js";
|
|
5
|
+
/**
|
|
6
|
+
* The macOS Keychain through the generated `parlor_session_*` commands; the webview's own
|
|
7
|
+
* storage in a shell without a working one, such as a project generated by an older version.
|
|
8
|
+
*/
|
|
9
|
+
export declare function tauriSessionStore(storage?: () => StorageLike, load?: () => Promise<TauriInvoke>): CapabilityAdapter<SessionStore>;
|
|
10
|
+
//# sourceMappingURL=tauri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tauri.d.ts","sourceRoot":"","sources":["../../src/session-store/tauri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,MAAM,WAA2C,EAC1D,IAAI,GAAE,MAAM,OAAO,CAAC,WAAW,CAAwC,GACtE,iBAAiB,CAAC,YAAY,CAAC,CAkBjC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { hasNativeCommand } from "../device-key/native.js";
|
|
2
|
+
import { detectPlatform } from "../runtime.js";
|
|
3
|
+
import { keychainSessionStore } from "./keychain.js";
|
|
4
|
+
import { localSessionStore } from "./local.js";
|
|
5
|
+
/**
|
|
6
|
+
* The macOS Keychain through the generated `parlor_session_*` commands; the webview's own
|
|
7
|
+
* storage in a shell without a working one, such as a project generated by an older version.
|
|
8
|
+
*/
|
|
9
|
+
export function tauriSessionStore(storage = () => globalThis.localStorage, load = () => import("@tauri-apps/api/core")) {
|
|
10
|
+
return {
|
|
11
|
+
platform: "tauri",
|
|
12
|
+
available: () => detectPlatform() === "tauri",
|
|
13
|
+
create: async () => {
|
|
14
|
+
if (!(await hasNativeCommand(load, "parlor_session_get")))
|
|
15
|
+
return localSessionStore(storage());
|
|
16
|
+
const { invoke } = await load();
|
|
17
|
+
return keychainSessionStore({
|
|
18
|
+
get: async () => (await invoke("parlor_session_get")) ?? undefined,
|
|
19
|
+
set: (token) => invoke("parlor_session_set", { token: token ?? null }),
|
|
20
|
+
}, storage());
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=tauri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tauri.js","sourceRoot":"","sources":["../../src/session-store/tauri.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAO,GAAsB,GAAG,EAAE,CAAC,UAAU,CAAC,YAAY,EAC1D,IAAI,GAA+B,GAAG,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC;IAEvE,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,SAAS,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,KAAK,OAAO;QAC7C,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;gBACvD,OAAO,iBAAiB,CAAC,OAAO,EAAE,CAAC,CAAC;YACtC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;YAChC,OAAO,oBAAoB,CACzB;gBACE,GAAG,EAAE,KAAK,IAAI,EAAE,CACd,CAAC,MAAM,MAAM,CAAgB,oBAAoB,CAAC,CAAC,IAAI,SAAS;gBAClE,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAO,oBAAoB,EAAE,EAAE,KAAK,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;aAC7E,EACD,OAAO,EAAE,CACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CapabilityAdapter } from "../capability.js";
|
|
2
|
+
import type { SessionStore } from "./interface.js";
|
|
3
|
+
/** Never available: the browser carries the session in an HttpOnly cookie. */
|
|
4
|
+
export declare function webSessionStore(): CapabilityAdapter<SessionStore>;
|
|
5
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/session-store/web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,8EAA8E;AAC9E,wBAAgB,eAAe,IAAI,iBAAiB,CAAC,YAAY,CAAC,CAQjE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Never available: the browser carries the session in an HttpOnly cookie. */
|
|
2
|
+
export function webSessionStore() {
|
|
3
|
+
return {
|
|
4
|
+
platform: "web",
|
|
5
|
+
available: () => false,
|
|
6
|
+
create: () => {
|
|
7
|
+
throw new Error("The web keeps its session in a cookie.");
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/session-store/web.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK;QACtB,MAAM,EAAE,GAAG,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,98 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parlor/capabilities",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"homepage": "https://cychien.github.io/parlor",
|
|
5
|
+
"bugs": "https://github.com/cychien/parlor/issues",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/cychien/parlor.git",
|
|
10
|
+
"directory": "packages/capabilities"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"imports": {
|
|
17
|
+
"#adapters": {
|
|
18
|
+
"parlor-tauri": "./dist/adapters/tauri.js",
|
|
19
|
+
"parlor-capacitor": "./dist/adapters/capacitor.js",
|
|
20
|
+
"default": "./dist/adapters/web.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./encoding": {
|
|
29
|
+
"types": "./dist/device-key/encoding.d.ts",
|
|
30
|
+
"import": "./dist/device-key/encoding.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@capacitor/app": "^8.1.2",
|
|
35
|
+
"@capacitor/filesystem": "^8.1.5",
|
|
36
|
+
"@capacitor/local-notifications": "^8.3.1",
|
|
37
|
+
"@capacitor/share": "^8.0.3",
|
|
38
|
+
"@tauri-apps/api": "^2.12.1",
|
|
39
|
+
"@tauri-apps/plugin-deep-link": "^2.6.1",
|
|
40
|
+
"@tauri-apps/plugin-dialog": "^2.8.3",
|
|
41
|
+
"@tauri-apps/plugin-fs": "^2.7.1",
|
|
42
|
+
"@tauri-apps/plugin-notification": "^2.5.1",
|
|
43
|
+
"@types/node": "^24.14.0",
|
|
44
|
+
"happy-dom": "^20.14.5",
|
|
45
|
+
"typescript": "^7.0.2",
|
|
46
|
+
"vitest": "^5.0.3",
|
|
47
|
+
"@parlor/capacitor-device-key": "0.1.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@capacitor/app": ">=8",
|
|
51
|
+
"@capacitor/filesystem": ">=8",
|
|
52
|
+
"@capacitor/local-notifications": ">=8",
|
|
53
|
+
"@capacitor/share": ">=8",
|
|
54
|
+
"@parlor/capacitor-device-key": ">=0",
|
|
55
|
+
"@tauri-apps/api": ">=2",
|
|
56
|
+
"@tauri-apps/plugin-deep-link": ">=2",
|
|
57
|
+
"@tauri-apps/plugin-dialog": ">=2",
|
|
58
|
+
"@tauri-apps/plugin-fs": ">=2",
|
|
59
|
+
"@tauri-apps/plugin-notification": ">=2"
|
|
60
|
+
},
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"@capacitor/app": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
65
|
+
"@capacitor/filesystem": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"@capacitor/local-notifications": {
|
|
69
|
+
"optional": true
|
|
70
|
+
},
|
|
71
|
+
"@capacitor/share": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"@parlor/capacitor-device-key": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"@tauri-apps/api": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"@tauri-apps/plugin-deep-link": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"@tauri-apps/plugin-dialog": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
86
|
+
"@tauri-apps/plugin-fs": {
|
|
87
|
+
"optional": true
|
|
88
|
+
},
|
|
89
|
+
"@tauri-apps/plugin-notification": {
|
|
90
|
+
"optional": true
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "tsc -p tsconfig.json",
|
|
95
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
96
|
+
"test": "vitest run"
|
|
97
|
+
}
|
|
6
98
|
}
|