@parlor/capabilities 0.0.0-stage → 0.2.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 +24 -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 +24 -0
- package/dist/adapters/tauri.js.map +1 -0
- package/dist/adapters/types.d.ts +18 -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 +17 -0
- package/dist/adapters/web.js.map +1 -0
- package/dist/auth-browser/capacitor.d.ts +15 -0
- package/dist/auth-browser/capacitor.d.ts.map +1 -0
- package/dist/auth-browser/capacitor.js +16 -0
- package/dist/auth-browser/capacitor.js.map +1 -0
- package/dist/auth-browser/index.d.ts +7 -0
- package/dist/auth-browser/index.d.ts.map +1 -0
- package/dist/auth-browser/index.js +10 -0
- package/dist/auth-browser/index.js.map +1 -0
- package/dist/auth-browser/interface.d.ts +9 -0
- package/dist/auth-browser/interface.d.ts.map +1 -0
- package/dist/auth-browser/interface.js +2 -0
- package/dist/auth-browser/interface.js.map +1 -0
- package/dist/auth-browser/scheme.d.ts +2 -0
- package/dist/auth-browser/scheme.d.ts.map +1 -0
- package/dist/auth-browser/scheme.js +4 -0
- package/dist/auth-browser/scheme.js.map +1 -0
- package/dist/auth-browser/tauri.d.ts +6 -0
- package/dist/auth-browser/tauri.d.ts.map +1 -0
- package/dist/auth-browser/tauri.js +20 -0
- package/dist/auth-browser/tauri.js.map +1 -0
- package/dist/auth-browser/web.d.ts +5 -0
- package/dist/auth-browser/web.d.ts.map +1 -0
- package/dist/auth-browser/web.js +15 -0
- package/dist/auth-browser/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 +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -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 @@
|
|
|
1
|
+
{"version":3,"file":"tauri.js","sourceRoot":"","sources":["../../src/deep-link/tauri.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAQ/C,MAAM,UAAU,aAAa,CAC3B,IAAI,GAAuC,GAAG,EAAE,CAAC,MAAM,CAAC,8BAA8B,CAAC;IAEvF,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,OAAO;gBACL,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;oBAClB,IAAI,SAAS,GAAG,KAAK,CAAC;oBACtB,MAAM,OAAO,GAAG,CAAC,IAAqB,EAAE,EAAE;wBACxC,IAAI,SAAS;4BAAE,OAAO;wBACtB,KAAK,MAAM,GAAG,IAAI,IAAI,IAAI,EAAE;4BAAE,OAAO,CAAC,GAAG,CAAC,CAAC;oBAC7C,CAAC,CAAC;oBACF,KAAK,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;oBAC3C,OAAO,GAAG,EAAE;wBACV,SAAS,GAAG,IAAI,CAAC;wBACjB,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;oBACvC,CAAC,CAAC;gBACJ,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { CapabilityAdapter } from \"../capability.js\";\nimport { detectPlatform } from \"../runtime.js\";\nimport type { DeepLink } from \"./interface.js\";\n\nexport interface TauriDeepLinkModule {\n getCurrent(): Promise<string[] | null>;\n onOpenUrl(handler: (urls: string[]) => void): Promise<() => void>;\n}\n\nexport function tauriDeepLink(\n load: () => Promise<TauriDeepLinkModule> = () => import(\"@tauri-apps/plugin-deep-link\"),\n): CapabilityAdapter<DeepLink> {\n return {\n platform: \"tauri\",\n available: () => detectPlatform() === \"tauri\",\n create: async () => {\n const plugin = await load();\n return {\n onOpen: (handler) => {\n let cancelled = false;\n const deliver = (urls: string[] | null) => {\n if (cancelled) return;\n for (const url of urls ?? []) handler(url);\n };\n void plugin.getCurrent().then(deliver);\n const unlisten = plugin.onOpenUrl(deliver);\n return () => {\n cancelled = true;\n void unlisten.then((stop) => stop());\n };\n },\n };\n },\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/deep-link/web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,wBAAgB,WAAW,CACzB,UAAU,GAAE,MAAM,MAAM,GAAG,SAA2C,GACrE,iBAAiB,CAAC,QAAQ,CAAC,CAiB7B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function webDeepLink(currentUrl = () => globalThis.location?.href) {
|
|
2
|
+
return {
|
|
3
|
+
platform: "web",
|
|
4
|
+
available: () => currentUrl() !== undefined,
|
|
5
|
+
create: () => ({
|
|
6
|
+
onOpen: (handler) => {
|
|
7
|
+
let cancelled = false;
|
|
8
|
+
queueMicrotask(() => {
|
|
9
|
+
const url = currentUrl();
|
|
10
|
+
if (!cancelled && url)
|
|
11
|
+
handler(url);
|
|
12
|
+
});
|
|
13
|
+
return () => {
|
|
14
|
+
cancelled = true;
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/deep-link/web.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,WAAW,CACzB,UAAU,GAA6B,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI;IAEtE,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,KAAK,SAAS;QAC3C,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;YACb,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;gBAClB,IAAI,SAAS,GAAG,KAAK,CAAC;gBACtB,cAAc,CAAC,GAAG,EAAE;oBAClB,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;oBACzB,IAAI,CAAC,SAAS,IAAI,GAAG;wBAAE,OAAO,CAAC,GAAG,CAAC,CAAC;gBACtC,CAAC,CAAC,CAAC;gBACH,OAAO,GAAG,EAAE;oBACV,SAAS,GAAG,IAAI,CAAC;gBACnB,CAAC,CAAC;YACJ,CAAC;SACF,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import type { CapabilityAdapter } from \"../capability.js\";\nimport type { DeepLink } from \"./interface.js\";\n\nexport function webDeepLink(\n currentUrl: () => string | undefined = () => globalThis.location?.href,\n): CapabilityAdapter<DeepLink> {\n return {\n platform: \"web\",\n available: () => currentUrl() !== undefined,\n create: () => ({\n onOpen: (handler) => {\n let cancelled = false;\n queueMicrotask(() => {\n const url = currentUrl();\n if (!cancelled && url) handler(url);\n });\n return () => {\n cancelled = true;\n };\n },\n }),\n };\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CapabilityAdapter } from "../capability.js";
|
|
2
|
+
import type { DeviceKey } from "./interface.js";
|
|
3
|
+
/** The `ParlorDeviceKey` native plugin: the Secure Enclave, or a Keychain key, on iOS. */
|
|
4
|
+
export interface CapacitorDeviceKeyModule {
|
|
5
|
+
ParlorDeviceKey: {
|
|
6
|
+
publicKeys(options: {
|
|
7
|
+
presence: boolean;
|
|
8
|
+
challenge: string;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
signing: {
|
|
11
|
+
keyId: string;
|
|
12
|
+
publicKey: JsonWebKey;
|
|
13
|
+
};
|
|
14
|
+
presence?: {
|
|
15
|
+
keyId: string;
|
|
16
|
+
publicKey: JsonWebKey;
|
|
17
|
+
};
|
|
18
|
+
proof: {
|
|
19
|
+
signature: string;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
/** A presence key carries a biometry-or-passcode access control the hardware enforces. */
|
|
23
|
+
sign(options: {
|
|
24
|
+
keyId: string;
|
|
25
|
+
payload: string;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
signature: string;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export declare function capacitorDeviceKey(load?: () => Promise<CapacitorDeviceKeyModule>): CapabilityAdapter<DeviceKey>;
|
|
32
|
+
//# sourceMappingURL=capacitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capacitor.d.ts","sourceRoot":"","sources":["../../src/device-key/capacitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,0FAA0F;AAC1F,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE;QACf,UAAU,CAAC,OAAO,EAAE;YAAE,QAAQ,EAAE,OAAO,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC;YACrE,OAAO,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,UAAU,CAAA;aAAE,CAAC;YAClD,QAAQ,CAAC,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,UAAU,CAAA;aAAE,CAAC;YACpD,KAAK,EAAE;gBAAE,SAAS,EAAE,MAAM,CAAA;aAAE,CAAC;SAC9B,CAAC,CAAC;QACH,0FAA0F;QAC1F,IAAI,CAAC,OAAO,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACnF,CAAC;CACH;AAED,wBAAgB,kBAAkB,CAChC,IAAI,GAAE,MAAM,OAAO,CAAC,wBAAwB,CACJ,GACvC,iBAAiB,CAAC,SAAS,CAAC,CAM9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { hasIosPlugin, nativeDeviceKey } from "./native.js";
|
|
2
|
+
export function capacitorDeviceKey(load = () => import("@parlor/capacitor-device-key")) {
|
|
3
|
+
return {
|
|
4
|
+
platform: "capacitor",
|
|
5
|
+
available: hasIosPlugin,
|
|
6
|
+
create: async () => nativeDeviceKey((await load()).ParlorDeviceKey),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=capacitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capacitor.js","sourceRoot":"","sources":["../../src/device-key/capacitor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAe5D,MAAM,UAAU,kBAAkB,CAChC,IAAI,GAA4C,GAAG,EAAE,CACnD,MAAM,CAAC,8BAA8B,CAAC;IAExC,OAAO;QACL,QAAQ,EAAE,WAAW;QACrB,SAAS,EAAE,YAAY;QACvB,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,eAAe,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,eAAe,CAAC;KACpE,CAAC;AACJ,CAAC","sourcesContent":["import type { CapabilityAdapter } from \"../capability.js\";\nimport type { DeviceKey } from \"./interface.js\";\nimport { hasIosPlugin, nativeDeviceKey } from \"./native.js\";\n\n/** The `ParlorDeviceKey` native plugin: the Secure Enclave, or a Keychain key, on iOS. */\nexport interface CapacitorDeviceKeyModule {\n ParlorDeviceKey: {\n publicKeys(options: { presence: boolean; challenge: string }): Promise<{\n signing: { keyId: string; publicKey: JsonWebKey };\n presence?: { keyId: string; publicKey: JsonWebKey };\n proof: { signature: string };\n }>;\n /** A presence key carries a biometry-or-passcode access control the hardware enforces. */\n sign(options: { keyId: string; payload: string }): Promise<{ signature: string }>;\n };\n}\n\nexport function capacitorDeviceKey(\n load: () => Promise<CapacitorDeviceKeyModule> = () =>\n import(\"@parlor/capacitor-device-key\"),\n): CapabilityAdapter<DeviceKey> {\n return {\n platform: \"capacitor\",\n available: hasIosPlugin,\n create: async () => nativeDeviceKey((await load()).ParlorDeviceKey),\n };\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PresencePublicKey } from "./interface.js";
|
|
2
|
+
export declare function encodeBase64url(bytes: Uint8Array): string;
|
|
3
|
+
export declare function decodeBase64url(text: string): Uint8Array<ArrayBuffer>;
|
|
4
|
+
/** Sorted-key JSON at every level, UTF-8: the same bytes on every device and host. */
|
|
5
|
+
export declare function canonicalBytes(value: unknown): Uint8Array;
|
|
6
|
+
export declare function publicPoint(key: JsonWebKey): JsonWebKey;
|
|
7
|
+
export declare function enrollmentBytes(input: {
|
|
8
|
+
readonly challenge: Uint8Array;
|
|
9
|
+
readonly signing: JsonWebKey;
|
|
10
|
+
readonly presence: PresencePublicKey | undefined;
|
|
11
|
+
}): Uint8Array;
|
|
12
|
+
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/device-key/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIzD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAIrE;AAcD,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAEzD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAEvD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,CAAC;CAClD,GAAG,UAAU,CAab"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function encodeBase64url(bytes) {
|
|
2
|
+
let binary = "";
|
|
3
|
+
for (const byte of bytes)
|
|
4
|
+
binary += String.fromCharCode(byte);
|
|
5
|
+
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
6
|
+
}
|
|
7
|
+
export function decodeBase64url(text) {
|
|
8
|
+
const padded = text.replaceAll("-", "+").replaceAll("_", "/");
|
|
9
|
+
const binary = atob(padded.padEnd(Math.ceil(padded.length / 4) * 4, "="));
|
|
10
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
11
|
+
}
|
|
12
|
+
function serialize(value) {
|
|
13
|
+
if (Array.isArray(value))
|
|
14
|
+
return `[${value.map(serialize).join(",")}]`;
|
|
15
|
+
if (value !== null && typeof value === "object") {
|
|
16
|
+
const members = Object.entries(value)
|
|
17
|
+
.filter(([, member]) => member !== undefined)
|
|
18
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
19
|
+
.map(([key, member]) => `${JSON.stringify(key)}:${serialize(member)}`);
|
|
20
|
+
return `{${members.join(",")}}`;
|
|
21
|
+
}
|
|
22
|
+
return JSON.stringify(value) ?? "null";
|
|
23
|
+
}
|
|
24
|
+
/** Sorted-key JSON at every level, UTF-8: the same bytes on every device and host. */
|
|
25
|
+
export function canonicalBytes(value) {
|
|
26
|
+
return new TextEncoder().encode(serialize(value));
|
|
27
|
+
}
|
|
28
|
+
export function publicPoint(key) {
|
|
29
|
+
return { kty: key.kty, crv: key.crv, x: key.x, y: key.y };
|
|
30
|
+
}
|
|
31
|
+
export function enrollmentBytes(input) {
|
|
32
|
+
const { presence } = input;
|
|
33
|
+
return canonicalBytes({
|
|
34
|
+
challenge: encodeBase64url(input.challenge),
|
|
35
|
+
signing: publicPoint(input.signing),
|
|
36
|
+
presence: presence
|
|
37
|
+
? {
|
|
38
|
+
format: presence.format,
|
|
39
|
+
id: presence.format === "webauthn" ? presence.credentialId : presence.keyId,
|
|
40
|
+
publicKey: publicPoint(presence.publicKey),
|
|
41
|
+
}
|
|
42
|
+
: null,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/device-key/encoding.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C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C,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK;gBAC3E,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC;aAC3C;YACH,CAAC,CAAC,IAAI;KACT,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { PresencePublicKey } from \"./interface.js\";\n\nexport function encodeBase64url(bytes: Uint8Array): string {\n let binary = \"\";\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return btoa(binary).replaceAll(\"+\", \"-\").replaceAll(\"/\", \"_\").replaceAll(\"=\", \"\");\n}\n\nexport function decodeBase64url(text: string): Uint8Array<ArrayBuffer> {\n const padded = text.replaceAll(\"-\", \"+\").replaceAll(\"_\", \"/\");\n const binary = atob(padded.padEnd(Math.ceil(padded.length / 4) * 4, \"=\"));\n return Uint8Array.from(binary, (char) => char.charCodeAt(0));\n}\n\nfunction serialize(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(serialize).join(\",\")}]`;\n if (value !== null && typeof value === \"object\") {\n const members = Object.entries(value)\n .filter(([, member]) => member !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([key, member]) => `${JSON.stringify(key)}:${serialize(member)}`);\n return `{${members.join(\",\")}}`;\n }\n return JSON.stringify(value) ?? \"null\";\n}\n\n/** Sorted-key JSON at every level, UTF-8: the same bytes on every device and host. */\nexport function canonicalBytes(value: unknown): Uint8Array {\n return new TextEncoder().encode(serialize(value));\n}\n\nexport function publicPoint(key: JsonWebKey): JsonWebKey {\n return { kty: key.kty!, crv: key.crv!, x: key.x!, y: key.y! };\n}\n\nexport function enrollmentBytes(input: {\n readonly challenge: Uint8Array;\n readonly signing: JsonWebKey;\n readonly presence: PresencePublicKey | undefined;\n}): Uint8Array {\n const { presence } = input;\n return canonicalBytes({\n challenge: encodeBase64url(input.challenge),\n signing: publicPoint(input.signing),\n presence: presence\n ? {\n format: presence.format,\n id: presence.format === \"webauthn\" ? presence.credentialId : presence.keyId,\n publicKey: publicPoint(presence.publicKey),\n }\n : null,\n });\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DeviceKey } from "./interface.js";
|
|
2
|
+
export { capacitorDeviceKey, type CapacitorDeviceKeyModule } from "./capacitor.js";
|
|
3
|
+
export { PresenceSetupCancelled } from "./interface.js";
|
|
4
|
+
export type { DeviceKey, DevicePublicKeys, DeviceSignature, PresenceEnrollment, PresencePublicKey, PresenceSignature, } from "./interface.js";
|
|
5
|
+
export { tauriDeviceKey, type TauriInvoke } from "./tauri.js";
|
|
6
|
+
export { webDeviceKey, type WebDeviceKeyApis } from "./web.js";
|
|
7
|
+
export declare const deviceKey: import("../capability.js").CapabilityDefinition<DeviceKey>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/device-key/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE/D,eAAO,MAAM,SAAS,4DAGpB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { platformAdapters } from "#adapters";
|
|
2
|
+
import { defineCapability } from "../capability.js";
|
|
3
|
+
export { capacitorDeviceKey } from "./capacitor.js";
|
|
4
|
+
export { PresenceSetupCancelled } from "./interface.js";
|
|
5
|
+
export { tauriDeviceKey } from "./tauri.js";
|
|
6
|
+
export { webDeviceKey } from "./web.js";
|
|
7
|
+
export const deviceKey = defineCapability({
|
|
8
|
+
name: "deviceKey",
|
|
9
|
+
adapters: platformAdapters.deviceKey,
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/device-key/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAiC,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AASxD,OAAO,EAAE,cAAc,EAAoB,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAyB,MAAM,UAAU,CAAC;AAE/D,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAgB,CAAY;IACnD,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,gBAAgB,CAAC,SAAS;CACrC,CAAC,CAAC","sourcesContent":["import { platformAdapters } from \"#adapters\";\n\nimport { defineCapability } from \"../capability.js\";\nimport type { DeviceKey } from \"./interface.js\";\n\nexport { capacitorDeviceKey, type CapacitorDeviceKeyModule } from \"./capacitor.js\";\n\nexport { PresenceSetupCancelled } from \"./interface.js\";\nexport type {\n DeviceKey,\n DevicePublicKeys,\n DeviceSignature,\n PresenceEnrollment,\n PresencePublicKey,\n PresenceSignature,\n} from \"./interface.js\";\nexport { tauriDeviceKey, type TauriInvoke } from \"./tauri.js\";\nexport { webDeviceKey, type WebDeviceKeyApis } from \"./web.js\";\n\nexport const deviceKey = defineCapability<DeviceKey>({\n name: \"deviceKey\",\n adapters: platformAdapters.deviceKey,\n});\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A device's signing identity; its private keys never leave the platform keystore. The
|
|
3
|
+
* signing key signs prompts with no user present. The presence key signs answers to an
|
|
4
|
+
* agent's own permission prompts and always needs Touch ID, Face ID or a passkey.
|
|
5
|
+
*/
|
|
6
|
+
export interface DeviceKey {
|
|
7
|
+
/**
|
|
8
|
+
* Creates the keys on first use; stable afterwards. `presence: false` settles this device
|
|
9
|
+
* without a presence key. Throws `PresenceSetupCancelled`, keeping nothing, when the user
|
|
10
|
+
* dismisses the platform's prompt, so a later call can ask again.
|
|
11
|
+
*/
|
|
12
|
+
publicKeys(enrollment: PresenceEnrollment, options?: {
|
|
13
|
+
readonly presence?: boolean;
|
|
14
|
+
}): Promise<DevicePublicKeys>;
|
|
15
|
+
/**
|
|
16
|
+
* `needed` while the next `publicKeys` would show a platform prompt (a passkey on the web),
|
|
17
|
+
* so the app can explain it first. Absent where creating the keys never prompts.
|
|
18
|
+
*/
|
|
19
|
+
presenceSetup?(): Promise<"needed" | "done">;
|
|
20
|
+
sign(payload: Uint8Array, options: {
|
|
21
|
+
readonly presence: false;
|
|
22
|
+
}): Promise<DeviceSignature>;
|
|
23
|
+
sign(payload: Uint8Array, options: {
|
|
24
|
+
readonly presence: true;
|
|
25
|
+
}): Promise<PresenceSignature>;
|
|
26
|
+
}
|
|
27
|
+
export declare class PresenceSetupCancelled extends Error {
|
|
28
|
+
readonly name = "PresenceSetupCancelled";
|
|
29
|
+
constructor();
|
|
30
|
+
}
|
|
31
|
+
export interface PresenceEnrollment {
|
|
32
|
+
readonly rpId: string;
|
|
33
|
+
readonly userId: string;
|
|
34
|
+
readonly userName: string;
|
|
35
|
+
/** Server-issued, single use; the proof of possession signs it. */
|
|
36
|
+
readonly challenge: Uint8Array;
|
|
37
|
+
}
|
|
38
|
+
export interface DevicePublicKeys {
|
|
39
|
+
readonly signing: {
|
|
40
|
+
readonly keyId: string;
|
|
41
|
+
readonly publicKey: JsonWebKey;
|
|
42
|
+
};
|
|
43
|
+
/** Absent where the platform has no presence authenticator. */
|
|
44
|
+
readonly presence?: PresencePublicKey | undefined;
|
|
45
|
+
readonly proof: DeviceSignature;
|
|
46
|
+
}
|
|
47
|
+
export type PresencePublicKey = {
|
|
48
|
+
readonly format: "webauthn";
|
|
49
|
+
readonly credentialId: string;
|
|
50
|
+
readonly publicKey: JsonWebKey;
|
|
51
|
+
/** The attestation object, verified by the server once at enrollment. */
|
|
52
|
+
readonly attestation: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly format: "es256-raw";
|
|
55
|
+
readonly keyId: string;
|
|
56
|
+
readonly publicKey: JsonWebKey;
|
|
57
|
+
};
|
|
58
|
+
export interface DeviceSignature {
|
|
59
|
+
readonly keyId: string;
|
|
60
|
+
readonly presence: "none" | "user";
|
|
61
|
+
readonly format: "es256-raw" | "webauthn";
|
|
62
|
+
/** base64url */
|
|
63
|
+
readonly signature: string;
|
|
64
|
+
readonly authenticatorData?: string | undefined;
|
|
65
|
+
readonly clientDataJSON?: string | undefined;
|
|
66
|
+
}
|
|
67
|
+
declare const presenceBrand: unique symbol;
|
|
68
|
+
/** Only `sign(..., { presence: true })` produces one, so an ordinary signature never passes for it. */
|
|
69
|
+
export type PresenceSignature = DeviceSignature & {
|
|
70
|
+
readonly presence: "user";
|
|
71
|
+
readonly [presenceBrand]: true;
|
|
72
|
+
};
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/device-key/interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,UAAU,CACR,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GACxC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAA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,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;CAChC,CAAC;AAEN,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC;IAC1C,gBAAgB;IAChB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9C;AAED,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C,uGAAuG;AACvG,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/device-key/interface.ts"],"names":[],"mappings":"AA8BA,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC7B,IAAI,GAAG,wBAAwB,CAAC;IAClD;QACE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["/**\n * A device's signing identity; its private keys never leave the platform keystore. The\n * signing key signs prompts with no user present. The presence key signs answers to an\n * agent's own permission prompts and always needs Touch ID, Face ID or a passkey.\n */\nexport interface DeviceKey {\n /**\n * Creates the keys on first use; stable afterwards. `presence: false` settles this device\n * without a presence key. Throws `PresenceSetupCancelled`, keeping nothing, when the user\n * dismisses the platform's prompt, so a later call can ask again.\n */\n publicKeys(\n enrollment: PresenceEnrollment,\n options?: { readonly presence?: boolean },\n ): Promise<DevicePublicKeys>;\n /**\n * `needed` while the next `publicKeys` would show a platform prompt (a passkey on the web),\n * so the app can explain it first. Absent where creating the keys never prompts.\n */\n presenceSetup?(): Promise<\"needed\" | \"done\">;\n sign(\n payload: Uint8Array,\n options: { readonly presence: false },\n ): Promise<DeviceSignature>;\n sign(\n payload: Uint8Array,\n options: { readonly presence: true },\n ): Promise<PresenceSignature>;\n}\n\nexport class PresenceSetupCancelled extends Error {\n override readonly name = \"PresenceSetupCancelled\";\n constructor() {\n super(\"The passkey was not created.\");\n }\n}\n\nexport interface PresenceEnrollment {\n readonly rpId: string;\n readonly userId: string;\n readonly userName: string;\n /** Server-issued, single use; the proof of possession signs it. */\n readonly challenge: Uint8Array;\n}\n\nexport interface DevicePublicKeys {\n readonly signing: { readonly keyId: string; readonly publicKey: JsonWebKey };\n /** Absent where the platform has no presence authenticator. */\n readonly presence?: PresencePublicKey | undefined;\n readonly proof: DeviceSignature;\n}\n\nexport type PresencePublicKey =\n | {\n readonly format: \"webauthn\";\n readonly credentialId: string;\n readonly publicKey: JsonWebKey;\n /** The attestation object, verified by the server once at enrollment. */\n readonly attestation: string;\n }\n | {\n readonly format: \"es256-raw\";\n readonly keyId: string;\n readonly publicKey: JsonWebKey;\n };\n\nexport interface DeviceSignature {\n readonly keyId: string;\n readonly presence: \"none\" | \"user\";\n readonly format: \"es256-raw\" | \"webauthn\";\n /** base64url */\n readonly signature: string;\n readonly authenticatorData?: string | undefined;\n readonly clientDataJSON?: string | undefined;\n}\n\ndeclare const presenceBrand: unique symbol;\n\n/** Only `sign(..., { presence: true })` produces one, so an ordinary signature never passes for it. */\nexport type PresenceSignature = DeviceSignature & {\n readonly presence: \"user\";\n readonly [presenceBrand]: true;\n};\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DeviceKey } from "./interface.js";
|
|
2
|
+
export interface NativePublicKeys {
|
|
3
|
+
readonly signing: {
|
|
4
|
+
readonly keyId: string;
|
|
5
|
+
readonly publicKey: JsonWebKey;
|
|
6
|
+
};
|
|
7
|
+
readonly presence?: {
|
|
8
|
+
readonly keyId: string;
|
|
9
|
+
readonly publicKey: JsonWebKey;
|
|
10
|
+
};
|
|
11
|
+
readonly proof: {
|
|
12
|
+
readonly signature: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface NativeKeystore {
|
|
16
|
+
publicKeys(options: {
|
|
17
|
+
readonly presence: boolean;
|
|
18
|
+
readonly challenge: string;
|
|
19
|
+
}): Promise<NativePublicKeys>;
|
|
20
|
+
sign(options: {
|
|
21
|
+
readonly keyId: string;
|
|
22
|
+
readonly payload: string;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
readonly signature: string;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export declare function nativeDeviceKey(keystore: NativeKeystore): DeviceKey;
|
|
28
|
+
interface Invoker {
|
|
29
|
+
invoke<T>(command: string, args?: Record<string, unknown>): Promise<T>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether the shell carries a working native command: one an older generated project lacks
|
|
33
|
+
* ("not found") or a platform without a keystore refuses ("unsupported") is unavailable.
|
|
34
|
+
*/
|
|
35
|
+
export declare function hasNativeCommand(load: () => Promise<Invoker>, command: string, args?: Record<string, unknown>): Promise<boolean>;
|
|
36
|
+
export declare function hasIosPlugin(): boolean;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/device-key/native.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EAIV,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;KAAE,CAAC;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EA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+
const keysOf = () => (known ??= keystore.publicKeys({ presence: true, challenge: "" }));
|
|
6
|
+
const signature = async (keyId, presence, payload) => ({
|
|
7
|
+
keyId,
|
|
8
|
+
presence,
|
|
9
|
+
format: "es256-raw",
|
|
10
|
+
signature: (await keystore.sign({ keyId, payload: encodeBase64url(payload) }))
|
|
11
|
+
.signature,
|
|
12
|
+
});
|
|
13
|
+
async function sign(payload, options) {
|
|
14
|
+
const keys = await keysOf();
|
|
15
|
+
if (!options.presence)
|
|
16
|
+
return signature(keys.signing.keyId, "none", payload);
|
|
17
|
+
if (!keys.presence)
|
|
18
|
+
throw new Error("This device has no presence key.");
|
|
19
|
+
return (await signature(keys.presence.keyId, "user", payload));
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
async publicKeys(enrollment) {
|
|
23
|
+
const pending = keystore.publicKeys({
|
|
24
|
+
presence: true,
|
|
25
|
+
challenge: encodeBase64url(enrollment.challenge),
|
|
26
|
+
});
|
|
27
|
+
known = pending;
|
|
28
|
+
const keys = await pending;
|
|
29
|
+
return {
|
|
30
|
+
signing: keys.signing,
|
|
31
|
+
presence: keys.presence && {
|
|
32
|
+
format: "es256-raw",
|
|
33
|
+
keyId: keys.presence.keyId,
|
|
34
|
+
publicKey: keys.presence.publicKey,
|
|
35
|
+
},
|
|
36
|
+
proof: {
|
|
37
|
+
keyId: keys.signing.keyId,
|
|
38
|
+
presence: "none",
|
|
39
|
+
format: "es256-raw",
|
|
40
|
+
signature: keys.proof.signature,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
sign,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const UNAVAILABLE = /not found|unsupported/i;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the shell carries a working native command: one an older generated project lacks
|
|
50
|
+
* ("not found") or a platform without a keystore refuses ("unsupported") is unavailable.
|
|
51
|
+
*/
|
|
52
|
+
export async function hasNativeCommand(load, command, args) {
|
|
53
|
+
if (detectPlatform() !== "tauri")
|
|
54
|
+
return false;
|
|
55
|
+
try {
|
|
56
|
+
await (await load()).invoke(command, args);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
return !UNAVAILABLE.test(error instanceof Error ? error.message : String(error));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function hasIosPlugin() {
|
|
64
|
+
const { Capacitor } = globalThis;
|
|
65
|
+
return detectPlatform() === "capacitor" && Capacitor?.getPlatform?.() === "ios";
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/device-key/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAyBhD,MAAM,UAAU,eAAe,CAAC,QAAwB;IACtD,IAAI,KAA4C,CAAC;IACjD,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAExF,MAAM,SAAS,GAAG,KAAK,EACrB,KAAa,EACb,QAAyB,EACzB,OAAmB,EACO,EAAE,CAAC,CAAC;QAC9B,KAAK;QACL,QAAQ;QACR,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;aAC3E,SAAS;KACb,CAAC,CAAC;IAUH,KAAK,UAAU,IAAI,CAAC,OAAmB,EAAE,OAAuC;QAC9E,MAAM,IAAI,GAAG,MAAM,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ;YAAE,OAA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,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACnF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,EAAE,SAAS,EAAE,GAAG,UAA4D,CAAC;IACnF,OAAO,cAAc,EAAE,KAAK,WAAW,IAAI,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,KAAK,CAAC;AAClF,CAAC","sourcesContent":["import { detectPlatform } from \"../runtime.js\";\nimport { encodeBase64url } from \"./encoding.js\";\nimport type {\n DeviceKey,\n DevicePublicKeys,\n DeviceSignature,\n PresenceSignature,\n} from \"./interface.js\";\n\nexport interface NativePublicKeys {\n readonly signing: { readonly keyId: string; readonly publicKey: JsonWebKey };\n readonly presence?: { readonly keyId: string; readonly publicKey: JsonWebKey };\n readonly proof: { readonly signature: string };\n}\n\nexport interface NativeKeystore {\n publicKeys(options: {\n readonly presence: boolean;\n readonly challenge: string;\n }): Promise<NativePublicKeys>;\n sign(options: {\n readonly keyId: string;\n readonly payload: string;\n }): Promise<{ readonly signature: string }>;\n}\n\nexport function nativeDeviceKey(keystore: NativeKeystore): DeviceKey {\n let known: Promise<NativePublicKeys> | undefined;\n const keysOf = () => (known ??= keystore.publicKeys({ presence: true, challenge: \"\" }));\n\n const signature = async (\n keyId: string,\n presence: \"none\" | \"user\",\n payload: Uint8Array,\n ): Promise<DeviceSignature> => ({\n keyId,\n presence,\n format: \"es256-raw\",\n signature: (await keystore.sign({ keyId, payload: encodeBase64url(payload) }))\n .signature,\n });\n\n async function sign(\n payload: Uint8Array,\n options: { readonly presence: false },\n ): Promise<DeviceSignature>;\n async function sign(\n payload: Uint8Array,\n options: { readonly presence: true },\n ): Promise<PresenceSignature>;\n async function sign(payload: Uint8Array, options: { readonly presence: boolean }) {\n const keys = await keysOf();\n if (!options.presence) return signature(keys.signing.keyId, \"none\", payload);\n if (!keys.presence) throw new Error(\"This device has no presence key.\");\n return (await signature(keys.presence.keyId, \"user\", payload)) as PresenceSignature;\n }\n\n return {\n async publicKeys(enrollment): Promise<DevicePublicKeys> {\n const pending = keystore.publicKeys({\n presence: true,\n challenge: encodeBase64url(enrollment.challenge),\n });\n known = pending;\n const keys = await pending;\n return {\n signing: keys.signing,\n presence: keys.presence && {\n format: \"es256-raw\",\n keyId: keys.presence.keyId,\n publicKey: keys.presence.publicKey,\n },\n proof: {\n keyId: keys.signing.keyId,\n presence: \"none\",\n format: \"es256-raw\",\n signature: keys.proof.signature,\n },\n };\n },\n sign,\n };\n}\n\ninterface Invoker {\n invoke<T>(command: string, args?: Record<string, unknown>): Promise<T>;\n}\n\nconst UNAVAILABLE = /not found|unsupported/i;\n\n/**\n * Whether the shell carries a working native command: one an older generated project lacks\n * (\"not found\") or a platform without a keystore refuses (\"unsupported\") is unavailable.\n */\nexport async function hasNativeCommand(\n load: () => Promise<Invoker>,\n command: string,\n args?: Record<string, unknown>,\n): Promise<boolean> {\n if (detectPlatform() !== \"tauri\") return false;\n try {\n await (await load()).invoke(command, args);\n return true;\n } catch (error) {\n return !UNAVAILABLE.test(error instanceof Error ? error.message : String(error));\n }\n}\n\nexport function hasIosPlugin(): boolean {\n const { Capacitor } = globalThis as { Capacitor?: { getPlatform?: () => string } };\n return detectPlatform() === \"capacitor\" && Capacitor?.getPlatform?.() === \"ios\";\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CapabilityAdapter } from "../capability.js";
|
|
2
|
+
import type { DeviceKey } from "./interface.js";
|
|
3
|
+
export interface TauriInvoke {
|
|
4
|
+
invoke<T>(command: string, args?: Record<string, unknown>): Promise<T>;
|
|
5
|
+
}
|
|
6
|
+
/** The generated `parlor_device_key_public` and `parlor_device_key_sign` commands, probed with a sign request for a key that cannot exist. */
|
|
7
|
+
export declare function tauriDeviceKey(load?: () => Promise<TauriInvoke>): CapabilityAdapter<DeviceKey>;
|
|
8
|
+
//# sourceMappingURL=tauri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tauri.d.ts","sourceRoot":"","sources":["../../src/device-key/tauri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACxE;AAED,8IAA8I;AAC9I,wBAAgB,cAAc,CAC5B,IAAI,GAAE,MAAM,OAAO,CAAC,WAAW,CAAwC,GACtE,iBAAiB,CAAC,SAAS,CAAC,CAe9B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { hasNativeCommand, nativeDeviceKey } from "./native.js";
|
|
2
|
+
/** The generated `parlor_device_key_public` and `parlor_device_key_sign` commands, probed with a sign request for a key that cannot exist. */
|
|
3
|
+
export function tauriDeviceKey(load = () => import("@tauri-apps/api/core")) {
|
|
4
|
+
return {
|
|
5
|
+
platform: "tauri",
|
|
6
|
+
available: () => hasNativeCommand(load, "parlor_device_key_sign", { keyId: "", payload: "" }),
|
|
7
|
+
create: async () => {
|
|
8
|
+
const { invoke } = await load();
|
|
9
|
+
return nativeDeviceKey({
|
|
10
|
+
publicKeys: (options) => invoke("parlor_device_key_public", { ...options }),
|
|
11
|
+
sign: (options) => invoke("parlor_device_key_sign", { ...options }),
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=tauri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tauri.js","sourceRoot":"","sources":["../../src/device-key/tauri.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAyB,MAAM,aAAa,CAAC;AAMvF,8IAA8I;AAC9I,MAAM,UAAU,cAAc,CAC5B,IAAI,GAA+B,GAAG,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC;IAEvE,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,SAAS,EAAE,GAAG,EAAE,CACd,gBAAgB,CAAC,IAAI,EAAE,wBAAwB,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAC9E,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;YAChC,OAAO,eAAe,CAAC;gBACrB,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE,CACtB,MAAM,CAAmB,0BAA0B,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC;gBACtE,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAChB,MAAM,CAAwB,wBAAwB,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC;aAC1E,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { CapabilityAdapter } from \"../capability.js\";\nimport type { DeviceKey } from \"./interface.js\";\nimport { hasNativeCommand, nativeDeviceKey, type NativePublicKeys } from \"./native.js\";\n\nexport interface TauriInvoke {\n invoke<T>(command: string, args?: Record<string, unknown>): Promise<T>;\n}\n\n/** The generated `parlor_device_key_public` and `parlor_device_key_sign` commands, probed with a sign request for a key that cannot exist. */\nexport function tauriDeviceKey(\n load: () => Promise<TauriInvoke> = () => import(\"@tauri-apps/api/core\"),\n): CapabilityAdapter<DeviceKey> {\n return {\n platform: \"tauri\",\n available: () =>\n hasNativeCommand(load, \"parlor_device_key_sign\", { keyId: \"\", payload: \"\" }),\n create: async () => {\n const { invoke } = await load();\n return nativeDeviceKey({\n publicKeys: (options) =>\n invoke<NativePublicKeys>(\"parlor_device_key_public\", { ...options }),\n sign: (options) =>\n invoke<{ signature: string }>(\"parlor_device_key_sign\", { ...options }),\n });\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CapabilityAdapter } from "../capability.js";
|
|
2
|
+
import { type DeviceKey } from "./interface.js";
|
|
3
|
+
export interface WebDeviceKeyApis {
|
|
4
|
+
readonly subtle: SubtleCrypto | undefined;
|
|
5
|
+
readonly indexedDB: IDBFactory | undefined;
|
|
6
|
+
readonly credentials: CredentialsContainer | undefined;
|
|
7
|
+
/** Whether a platform authenticator (Touch ID, Windows Hello) can make the passkey. */
|
|
8
|
+
readonly platformAuthenticator?: (() => Promise<boolean>) | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function webDeviceKey(apis?: () => WebDeviceKeyApis): CapabilityAdapter<DeviceKey>;
|
|
11
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/device-key/web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAO1D,OAAO,EACL,KAAK,SAAS,EAOf,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,UAAU,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,WAAW,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACvD,uFAAuF;IACvF,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CACvE;AAmQD,wBAAgB,YAAY,CAC1B,IAAI,GAAE,MAAM,gBAKV,GACD,iBAAiB,CAAC,SAAS,CAAC,CAoB9B"}
|