forked from passwordless-id/webauthn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
142 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/node_modules | ||
/.vscode | ||
/dist/esm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export declare function parseAuthBuffer(authData: ArrayBuffer): any; | ||
export declare function extractAaguid(authData: ArrayBuffer): string; | ||
export declare function resolveAuthenticatorName(aaguid: string): string; | ||
export declare function updateDevicesMetadata(): Promise<void>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './types'; | ||
export * from './webauthn'; | ||
export * from './parsers'; | ||
export * from './validation'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { AuthenticatorInfo, ClientInfo } from './types'; | ||
export declare function parseClient(data: string | ArrayBuffer): ClientInfo; | ||
export declare function parseAuthenticator(data: string | ArrayBuffer): AuthenticatorInfo; | ||
export declare function parseAttestation(data: string | ArrayBuffer): unknown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
export declare type AuthType = 'auto' | 'local' | 'extern' | 'both'; | ||
export declare type NumAlgo = -7 | -257; | ||
export declare type NamedAlgo = 'RS256' | 'ES256'; | ||
export interface LoginOptions { | ||
userVerification?: UserVerificationRequirement; | ||
authenticatorType?: AuthType; | ||
timeout?: number; | ||
debug?: boolean; | ||
} | ||
export interface LoginResult { | ||
credentialId: string; | ||
authenticatorData: string; | ||
clientData: string; | ||
signature: string; | ||
debug?: object; | ||
} | ||
export interface RegisterOptions extends LoginOptions { | ||
attestation?: boolean; | ||
} | ||
export interface RegisterResult { | ||
username: string; | ||
credential: { | ||
id: string; | ||
publicKey: string; | ||
algorithm: 'RS256' | 'ES256'; | ||
}; | ||
authenticatorData: string; | ||
clientData: string; | ||
attestationData?: string; | ||
debug?: object; | ||
} | ||
export interface ClientInfo { | ||
type: "webauthn.create" | "webauthn.get"; | ||
challenge: string; | ||
origin: string; | ||
crossOrigin: boolean; | ||
tokenBindingId?: { | ||
id: string; | ||
status: string; | ||
}; | ||
} | ||
export interface AuthenticatorInfo { | ||
rpIdHash: string; | ||
flags: { | ||
userPresent: boolean; | ||
userVerified: boolean; | ||
backupEligibility: boolean; | ||
backupState: boolean; | ||
attestedData: boolean; | ||
extensionsIncluded: boolean; | ||
}; | ||
counter: number; | ||
aaguid: string; | ||
name: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/******************************** | ||
Encoding/Decoding Utils | ||
********************************/ | ||
export declare function toBuffer(txt: string): ArrayBuffer; | ||
export declare function parseBuffer(buffer: ArrayBuffer): string; | ||
export declare function isBase64url(txt: string): boolean; | ||
export declare function toBase64url(buffer: ArrayBuffer): string; | ||
export declare function parseBase64url(txt: string): ArrayBuffer; | ||
export declare function sha256(buffer: ArrayBuffer): Promise<ArrayBuffer>; | ||
export declare function bufferToHex(buffer: ArrayBuffer): string; | ||
export declare function concatenateBuffers(buffer1: ArrayBuffer, buffer2: ArrayBuffer): Uint8Array; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { NamedAlgo } from './types'; | ||
declare type VerifyParams = { | ||
algorithm: NamedAlgo; | ||
publicKey: string; | ||
authenticatorData: string; | ||
clientData: string; | ||
signature: string; | ||
}; | ||
export declare function verify({ algorithm, publicKey, authenticatorData, clientData, signature }: VerifyParams): Promise<boolean>; | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { LoginOptions, LoginResult, RegisterOptions, RegisterResult } from './types'; | ||
/** | ||
* Returns whether passwordless authentication is available on this browser/platform or not. | ||
*/ | ||
export declare function isAvailable(): boolean; | ||
/** | ||
* Returns whether the device itself can be used as authenticator. | ||
*/ | ||
export declare function isLocalAuthenticator(): Promise<boolean>; | ||
/** | ||
* Creates a cryptographic key pair, in order to register the public key for later passwordless authentication. | ||
* | ||
* @param {string} username | ||
* @param {string} challenge A server-side randomly generated string. | ||
* @param {Object} [options] Optional parameters. | ||
* @param {number} [options.timeout=60000] Number of milliseconds the user has to respond to the biometric/PIN check. | ||
* @param {'required'|'preferred'|'discouraged'} [options.userVerification='required'] Whether to prompt for biometric/PIN check or not. | ||
* @param {'auto'|'local'|'extern'|'both'} [options.authenticatorType='auto'] Which device to use as authenticator. | ||
* 'auto': if the local device can be used as authenticator it will be preferred. Otherwise it will prompt for an external device. | ||
* 'local': use the local device (using TouchID, FaceID, Windows Hello or PIN) | ||
* 'extern': use an external device (security key or connected phone) | ||
* 'both': prompt the user to choose between local or external device. The UI and user interaction in this case is platform specific. | ||
* @param {boolean} [attestation=false] If enabled, the device attestation and clientData will be provided as Base64url encoded binary data. | ||
* Note that this is not available on some platforms. | ||
*/ | ||
export declare function register(username: string, challenge: string, options?: RegisterOptions): Promise<RegisterResult>; | ||
/** | ||
* Signs a challenge using one of the provided credentials IDs in order to authenticate the user. | ||
* | ||
* @param {string[]} credentialIds The list of credential IDs that can be used for signing. | ||
* @param {string} challenge A server-side randomly generated string, the base64 encoded version will be signed. | ||
* @param {Object} [options] Optional parameters. | ||
* @param {number} [options.timeout=60000] Number of milliseconds the user has to respond to the biometric/PIN check. | ||
* @param {'required'|'preferred'|'discouraged'} [options.userVerification='required'] Whether to prompt for biometric/PIN check or not. | ||
*/ | ||
export declare function login(credentialIds: string[], challenge: string, options?: LoginOptions): Promise<LoginResult>; |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2022", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ | ||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | ||
"module": "esnext", | ||
"strict": true, /* Enable all strict type-checking options. */ | ||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ | ||
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ | ||
|
||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
|
||
"outDir": "dist/esm", | ||
"declaration": true, | ||
"declarationDir": "dist/types" | ||
} | ||
} |