mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-29 12:06:01 +02:00
75 lines
1.6 KiB
TypeScript
75 lines
1.6 KiB
TypeScript
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
declare global {
|
|
interface Window {
|
|
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
|
|
}
|
|
}
|
|
|
|
export class Authenticator {
|
|
async init(): Promise<void> {
|
|
return await window.__TAURI_INVOKE__("plugin:authenticator|init_auth");
|
|
}
|
|
|
|
async register(challenge: string, application: string): Promise<string> {
|
|
return await window.__TAURI_INVOKE__("plugin:authenticator|register", {
|
|
timeout: 10000,
|
|
challenge,
|
|
application,
|
|
});
|
|
}
|
|
|
|
async verifyRegistration(
|
|
challenge: string,
|
|
application: string,
|
|
registerData: string,
|
|
clientData: string
|
|
): Promise<string> {
|
|
return await window.__TAURI_INVOKE__(
|
|
"plugin:authenticator|verify_registration",
|
|
{
|
|
challenge,
|
|
application,
|
|
registerData,
|
|
clientData,
|
|
}
|
|
);
|
|
}
|
|
|
|
async sign(
|
|
challenge: string,
|
|
application: string,
|
|
keyHandle: string
|
|
): Promise<string> {
|
|
return await window.__TAURI_INVOKE__("plugin:authenticator|sign", {
|
|
timeout: 10000,
|
|
challenge,
|
|
application,
|
|
keyHandle,
|
|
});
|
|
}
|
|
|
|
async verifySignature(
|
|
challenge: string,
|
|
application: string,
|
|
signData: string,
|
|
clientData: string,
|
|
keyHandle: string,
|
|
pubkey: string
|
|
): Promise<number> {
|
|
return await window.__TAURI_INVOKE__(
|
|
"plugin:authenticator|verify_signature",
|
|
{
|
|
challenge,
|
|
application,
|
|
signData,
|
|
clientData,
|
|
keyHandle,
|
|
pubkey,
|
|
}
|
|
);
|
|
}
|
|
}
|