You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tauri-plugins-workspace/plugins/authenticator/guest-js/index.ts

75 lines
1.6 KiB

// 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,
},
);
}
}