@joinmeow/cognito-passwordless-auth
Version:
Passwordless authentication with Amazon Cognito: FIDO2 (WebAuthn, support for Passkeys)
73 lines (72 loc) • 2.64 kB
TypeScript
import { IdleState, BusyState, TokensFromSignIn } from "./model.js";
declare function getConstants(): Promise<{
g: bigint;
N: bigint;
k: bigint;
}>;
declare function modPow(base: bigint, exp: bigint, mod: bigint): bigint;
declare function padHex(hexStr: string): string;
declare function generateSmallA(): bigint;
declare function calculateLargeAHex(smallA: bigint): Promise<string>;
type UserCreds = {
userPoolId: string;
username: string;
password: string;
};
type DeviceCreds = {
deviceGroupKey: string;
deviceKey: string;
devicePassword: string;
};
declare function calculateSrpSignature({ smallA, largeAHex, srpBHex, salt, secretBlock, creds, }: {
smallA: bigint;
largeAHex: string;
srpBHex: string;
salt: string;
secretBlock: string;
creds: UserCreds | DeviceCreds;
}): Promise<{
timestamp: string;
passwordClaimSignature: string;
}>;
declare function hexToArrayBuffer(hexStr: string): Uint8Array;
declare function arrayBufferToHex(arrBuf: ArrayBuffer): string;
declare function arrayBufferToBigInt(arrBuf: ArrayBuffer): bigint;
declare function formatDate(d: Date): string;
export declare function authenticateWithSRP({ username, password, smsMfaCode, otpMfaCode, newPassword, customChallengeAnswer, deviceKey, tokensCb, statusCb, clientMetadata, }: {
/**
* Username, or alias (e-mail, phone number)
*/
username: string;
password: string;
smsMfaCode?: () => Promise<string>;
otpMfaCode?: () => Promise<string>;
newPassword?: () => Promise<string>;
customChallengeAnswer?: () => Promise<string>;
/**
* Device key for device authentication (if available from previous sessions)
*/
deviceKey?: string;
tokensCb?: (tokens: TokensFromSignIn) => void | Promise<void>;
statusCb?: (status: BusyState | IdleState) => void;
currentStatus?: BusyState | IdleState;
clientMetadata?: Record<string, string>;
}): {
signedIn: Promise<TokensFromSignIn>;
abort: () => void;
};
declare function verifyDeviceSrp({ deviceGroupKey, deviceKey, devicePassword, srpB, secretBlock, salt, smallA, srpAHex, }: {
deviceGroupKey: string;
deviceKey: string;
devicePassword: string;
srpB: string;
secretBlock: string;
salt: string;
smallA: bigint;
srpAHex: string;
}): Promise<{
readonly passwordVerifier: string;
readonly passwordClaimSecretBlock: string;
readonly timestamp: string;
}>;
export { modPow, getConstants, padHex, hexToArrayBuffer, arrayBufferToHex, arrayBufferToBigInt, formatDate, generateSmallA, calculateLargeAHex, calculateSrpSignature, verifyDeviceSrp, };