@muljax/edge-passkey 1.0.0 → 1.0.2
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/README.md +2 -2
- package/package.json +3 -2
- package/dist/binary/base64url.d.ts +0 -12
- package/dist/binary/cbor.d.ts +0 -12
- package/dist/binary/index.d.ts +0 -3
- package/dist/binary/reader.d.ts +0 -19
- package/dist/core/authentication.d.ts +0 -5
- package/dist/core/index.d.ts +0 -2
- package/dist/core/registration.d.ts +0 -5
- package/dist/cose/coseParser.d.ts +0 -5
- package/dist/cose/index.d.ts +0 -1
- package/dist/errors/index.d.ts +0 -30
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/options.d.ts +0 -80
- package/dist/index.d.ts +0 -7
- package/dist/protocol/authData.d.ts +0 -9
- package/dist/protocol/clientData.d.ts +0 -5
- package/dist/protocol/der.d.ts +0 -4
- package/dist/protocol/extensions.d.ts +0 -29
- package/dist/protocol/index.d.ts +0 -5
- package/dist/protocol/origin.d.ts +0 -5
- package/dist/types/cose.d.ts +0 -30
- package/dist/types/flags.d.ts +0 -12
- package/dist/types/index.d.ts +0 -3
- package/dist/types/models.d.ts +0 -103
package/README.md
CHANGED
|
@@ -5,14 +5,14 @@ Zero-dependency, high-performance WebAuthn and Passkey verification engine desig
|
|
|
5
5
|
[](#)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](#)
|
|
8
|
-
[-blue)](#)
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
## Highlights
|
|
13
13
|
|
|
14
14
|
- **Zero Dependencies:** Pure TypeScript running directly on native Web Cryptography (`crypto.subtle`) and `DataView`.
|
|
15
|
-
- **Ultra Lightweight:**
|
|
15
|
+
- **Ultra Lightweight:** 5.1 KB minified + gzipped. Strips out legacy enterprise attestation bloat (X.509 chains, TPM 2.0, SafetyNet).
|
|
16
16
|
- **Sub-Millisecond Verification:** Verified in $< 0.8\text{ ms}$ on V8 isolates and Cloudflare Workers.
|
|
17
17
|
- **Modern Passkey Profile:** Native support for Apple iCloud Keychain, Google Password Manager, Windows Hello, 1Password, Bitwarden, and YubiKeys.
|
|
18
18
|
- **Cryptographic Suite:** Hardware-verified ES256 (P-256), EdDSA (Ed25519), RS256, PS256, ES384, and ES512.
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muljax/edge-passkey",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Zero-dependency, high-performance WebAuthn / Passkey verification engine for edge runtimes (Cloudflare Workers, Bun, Deno, Node)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "git+https://github.com/Muljax/edge-passkey.git"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
10
11
|
"main": "./dist/index.js",
|
|
11
12
|
"module": "./dist/index.js",
|
|
12
13
|
"types": "./dist/index.d.ts",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Decodes a Base64URL string into a Uint8Array.
|
|
3
|
-
*/
|
|
4
|
-
export declare function base64URLToBytes(base64url: string): Uint8Array;
|
|
5
|
-
/**
|
|
6
|
-
* Encodes a Uint8Array into an unpadded Base64URL string.
|
|
7
|
-
*/
|
|
8
|
-
export declare function bytesToBase64URL(bytes: Uint8Array): string;
|
|
9
|
-
/**
|
|
10
|
-
* Performs a constant-time byte equality check to prevent timing side-channels.
|
|
11
|
-
*/
|
|
12
|
-
export declare function timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;
|
package/dist/binary/cbor.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type CBORValue = number | bigint | string | boolean | null | undefined | Uint8Array | CBORValue[] | Map<number | string, CBORValue>;
|
|
2
|
-
/**
|
|
3
|
-
* Decodes a CBOR buffer into its corresponding JavaScript value.
|
|
4
|
-
*/
|
|
5
|
-
export declare function decodeCBOR(buffer: Uint8Array): CBORValue;
|
|
6
|
-
/**
|
|
7
|
-
* Decodes a CBOR item and returns the decoded value along with the exact raw byte slice consumed.
|
|
8
|
-
*/
|
|
9
|
-
export declare function decodeCBORWithSlice(buffer: Uint8Array): {
|
|
10
|
-
value: CBORValue;
|
|
11
|
-
rawSlice: Uint8Array;
|
|
12
|
-
};
|
package/dist/binary/index.d.ts
DELETED
package/dist/binary/reader.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bounds-checked sequential binary reader over an underlying DataView.
|
|
3
|
-
*/
|
|
4
|
-
export declare class BinaryReader {
|
|
5
|
-
private readonly buffer;
|
|
6
|
-
private readonly view;
|
|
7
|
-
private offset;
|
|
8
|
-
constructor(buffer: Uint8Array);
|
|
9
|
-
get cursor(): number;
|
|
10
|
-
get remaining(): number;
|
|
11
|
-
hasBytes(count: number): boolean;
|
|
12
|
-
readUint8(): number;
|
|
13
|
-
readUint16(): number;
|
|
14
|
-
readUint32(): number;
|
|
15
|
-
readBigUint64(): bigint;
|
|
16
|
-
readBytes(length: number): Uint8Array;
|
|
17
|
-
seek(offset: number): void;
|
|
18
|
-
private assertAvailable;
|
|
19
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AuthenticationVerificationOptions, AuthenticationResult } from "@/types";
|
|
2
|
-
/**
|
|
3
|
-
* Verifies a WebAuthn authentication assertion response.
|
|
4
|
-
*/
|
|
5
|
-
export declare function verifyAuthentication(options: AuthenticationVerificationOptions): Promise<AuthenticationResult>;
|
package/dist/core/index.d.ts
DELETED
package/dist/cose/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./coseParser";
|
package/dist/errors/index.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export type WebAuthnErrorCode = "CHALLENGE_MISMATCH" | "ORIGIN_MISMATCH" | "RP_ID_MISMATCH" | "USER_PRESENCE_NOT_SET" | "USER_VERIFICATION_FAILED" | "COUNTER_ROLLBACK" | "INVALID_SIGNATURE" | "INVALID_ATTESTATION" | "MALFORMED_PAYLOAD" | "UNSUPPORTED_ALGORITHM" | "KEY_PARSING_FAILED";
|
|
2
|
-
export declare class WebAuthnError extends Error {
|
|
3
|
-
readonly code: WebAuthnErrorCode;
|
|
4
|
-
readonly details?: Record<string, unknown>;
|
|
5
|
-
constructor(code: WebAuthnErrorCode, message: string, details?: Record<string, unknown>);
|
|
6
|
-
}
|
|
7
|
-
export declare class ChallengeMismatchError extends WebAuthnError {
|
|
8
|
-
constructor(expected: string, received: string);
|
|
9
|
-
}
|
|
10
|
-
export declare class OriginMismatchError extends WebAuthnError {
|
|
11
|
-
constructor(expected: string | string[], received: string);
|
|
12
|
-
}
|
|
13
|
-
export declare class RpIdMismatchError extends WebAuthnError {
|
|
14
|
-
constructor(expectedRpId: string);
|
|
15
|
-
}
|
|
16
|
-
export declare class UserPresenceError extends WebAuthnError {
|
|
17
|
-
constructor();
|
|
18
|
-
}
|
|
19
|
-
export declare class UserVerificationPolicyError extends WebAuthnError {
|
|
20
|
-
constructor();
|
|
21
|
-
}
|
|
22
|
-
export declare class CounterRollbackError extends WebAuthnError {
|
|
23
|
-
constructor(storedCount: number, receivedCount: number);
|
|
24
|
-
}
|
|
25
|
-
export declare class InvalidSignatureError extends WebAuthnError {
|
|
26
|
-
constructor(message?: string);
|
|
27
|
-
}
|
|
28
|
-
export declare class MalformedPayloadError extends WebAuthnError {
|
|
29
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
30
|
-
}
|
package/dist/helpers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./options";
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { COSEAlgorithm } from "@/types";
|
|
2
|
-
export interface GenerateRegistrationOptionsArgs {
|
|
3
|
-
rpName: string;
|
|
4
|
-
rpId: string;
|
|
5
|
-
userName: string;
|
|
6
|
-
userID?: Uint8Array | string;
|
|
7
|
-
userDisplayName?: string;
|
|
8
|
-
challenge?: Uint8Array | string;
|
|
9
|
-
supportedAlgorithms?: COSEAlgorithm[];
|
|
10
|
-
attestationType?: "none" | "direct" | "enterprise";
|
|
11
|
-
residentKey?: "preferred" | "required" | "discouraged";
|
|
12
|
-
userVerification?: "preferred" | "required" | "discouraged";
|
|
13
|
-
authenticatorAttachment?: "platform" | "cross-platform";
|
|
14
|
-
timeout?: number;
|
|
15
|
-
excludeCredentials?: Array<{
|
|
16
|
-
id: Uint8Array | string;
|
|
17
|
-
transports?: AuthenticatorTransport[];
|
|
18
|
-
}>;
|
|
19
|
-
extensions?: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
export interface PublicKeyCredentialCreationOptionsJSON {
|
|
22
|
-
challenge: string;
|
|
23
|
-
rp: {
|
|
24
|
-
name: string;
|
|
25
|
-
id: string;
|
|
26
|
-
};
|
|
27
|
-
user: {
|
|
28
|
-
id: string;
|
|
29
|
-
name: string;
|
|
30
|
-
displayName: string;
|
|
31
|
-
};
|
|
32
|
-
pubKeyCredParams: Array<{
|
|
33
|
-
type: "public-key";
|
|
34
|
-
alg: COSEAlgorithm;
|
|
35
|
-
}>;
|
|
36
|
-
timeout: number;
|
|
37
|
-
attestation: "none" | "direct" | "enterprise";
|
|
38
|
-
authenticatorSelection: {
|
|
39
|
-
residentKey?: "preferred" | "required" | "discouraged";
|
|
40
|
-
userVerification?: "preferred" | "required" | "discouraged";
|
|
41
|
-
authenticatorAttachment?: "platform" | "cross-platform";
|
|
42
|
-
};
|
|
43
|
-
excludeCredentials?: Array<{
|
|
44
|
-
id: string;
|
|
45
|
-
type: "public-key";
|
|
46
|
-
transports?: AuthenticatorTransport[];
|
|
47
|
-
}>;
|
|
48
|
-
extensions?: Record<string, unknown>;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Generates RFC-compliant PublicKeyCredentialCreationOptions for navigator.credentials.create().
|
|
52
|
-
*/
|
|
53
|
-
export declare function generateRegistrationOptions(args: GenerateRegistrationOptionsArgs): PublicKeyCredentialCreationOptionsJSON;
|
|
54
|
-
export interface GenerateAuthenticationOptionsArgs {
|
|
55
|
-
rpId: string;
|
|
56
|
-
challenge?: Uint8Array | string;
|
|
57
|
-
timeout?: number;
|
|
58
|
-
userVerification?: "preferred" | "required" | "discouraged";
|
|
59
|
-
allowCredentials?: Array<{
|
|
60
|
-
id: Uint8Array | string;
|
|
61
|
-
transports?: AuthenticatorTransport[];
|
|
62
|
-
}>;
|
|
63
|
-
extensions?: Record<string, unknown>;
|
|
64
|
-
}
|
|
65
|
-
export interface PublicKeyCredentialRequestOptionsJSON {
|
|
66
|
-
challenge: string;
|
|
67
|
-
rpId: string;
|
|
68
|
-
timeout: number;
|
|
69
|
-
userVerification: "preferred" | "required" | "discouraged";
|
|
70
|
-
allowCredentials?: Array<{
|
|
71
|
-
id: string;
|
|
72
|
-
type: "public-key";
|
|
73
|
-
transports?: AuthenticatorTransport[];
|
|
74
|
-
}>;
|
|
75
|
-
extensions?: Record<string, unknown>;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Generates RFC-compliant PublicKeyCredentialRequestOptions for navigator.credentials.get().
|
|
79
|
-
*/
|
|
80
|
-
export declare function generateAuthenticationOptions(args: GenerateAuthenticationOptionsArgs): PublicKeyCredentialRequestOptionsJSON;
|
package/dist/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ParsedAuthData } from "@/types";
|
|
2
|
-
/**
|
|
3
|
-
* Parses raw binary authenticatorData, unpacking flags, counters, and credential structures.
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseAuthenticatorData(authDataBytes: Uint8Array): ParsedAuthData;
|
|
6
|
-
/**
|
|
7
|
-
* Formats a 16-byte AAGUID into a canonical UUID string (8-4-4-4-12).
|
|
8
|
-
*/
|
|
9
|
-
export declare function formatAAGUID(aaguid: Uint8Array): string;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ParsedClientData } from "@/types";
|
|
2
|
-
/**
|
|
3
|
-
* Validates the clientDataJSON string and computes its SHA-256 hash.
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseAndVerifyClientData(clientDataInput: string | Uint8Array, expectedType: "webauthn.create" | "webauthn.get"): Promise<ParsedClientData>;
|
package/dist/protocol/der.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { CBORValue } from "@/binary";
|
|
2
|
-
export interface CredentialPropertiesExtension {
|
|
3
|
-
rk?: boolean;
|
|
4
|
-
}
|
|
5
|
-
export interface PRFExtensionResults {
|
|
6
|
-
first?: Uint8Array;
|
|
7
|
-
second?: Uint8Array;
|
|
8
|
-
}
|
|
9
|
-
export interface ParsedExtensions {
|
|
10
|
-
credProps?: CredentialPropertiesExtension;
|
|
11
|
-
prf?: {
|
|
12
|
-
enabled?: boolean;
|
|
13
|
-
results?: PRFExtensionResults;
|
|
14
|
-
};
|
|
15
|
-
largeBlob?: {
|
|
16
|
-
supported?: boolean;
|
|
17
|
-
blob?: Uint8Array;
|
|
18
|
-
written?: boolean;
|
|
19
|
-
};
|
|
20
|
-
appId?: boolean;
|
|
21
|
-
raw?: Map<string | number, CBORValue>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Parses trailing CBOR extension map from authenticatorData when the ED flag is present.
|
|
25
|
-
*/
|
|
26
|
-
export declare function parseAuthenticatorExtensions(extensionBytes: Uint8Array): {
|
|
27
|
-
extensions: ParsedExtensions;
|
|
28
|
-
bytesConsumed: number;
|
|
29
|
-
};
|
package/dist/protocol/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type ExpectedOrigin = string | string[] | ((origin: string) => boolean | Promise<boolean>);
|
|
2
|
-
/**
|
|
3
|
-
* Validates the clientData origin against allowed origins, wildcards, or mobile app facet identifiers.
|
|
4
|
-
*/
|
|
5
|
-
export declare function verifyOrigin(receivedOrigin: string, expectedOrigin: ExpectedOrigin, allowCrossOrigin?: boolean, crossOriginFlag?: boolean): Promise<void>;
|
package/dist/types/cose.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Supported COSE algorithm identifiers.
|
|
3
|
-
*/
|
|
4
|
-
export declare enum COSEAlgorithm {
|
|
5
|
-
ES256 = -7,
|
|
6
|
-
EdDSA = -8,
|
|
7
|
-
ES384 = -35,
|
|
8
|
-
ES512 = -36,
|
|
9
|
-
RS256 = -257,
|
|
10
|
-
RS384 = -258,
|
|
11
|
-
RS512 = -259,
|
|
12
|
-
PS256 = -37
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Supported COSE key types.
|
|
16
|
-
*/
|
|
17
|
-
export declare enum COSEKeyType {
|
|
18
|
-
OKP = 1,
|
|
19
|
-
EC2 = 2,
|
|
20
|
-
RSA = 3
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Supported COSE elliptic curves.
|
|
24
|
-
*/
|
|
25
|
-
export declare enum COSECurve {
|
|
26
|
-
P256 = 1,
|
|
27
|
-
P384 = 2,
|
|
28
|
-
P521 = 3,
|
|
29
|
-
Ed25519 = 6
|
|
30
|
-
}
|
package/dist/types/flags.d.ts
DELETED
package/dist/types/index.d.ts
DELETED
package/dist/types/models.d.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import type { AuthenticatorFlags } from "./flags";
|
|
2
|
-
import type { COSEAlgorithm, COSEKeyType } from "./cose";
|
|
3
|
-
import type { ParsedExtensions } from "@/protocol/extensions";
|
|
4
|
-
import type { ExpectedOrigin } from "@/protocol/origin";
|
|
5
|
-
/**
|
|
6
|
-
* Parsed binary authenticator data structure.
|
|
7
|
-
*/
|
|
8
|
-
export interface ParsedAuthData {
|
|
9
|
-
rpIdHash: Uint8Array;
|
|
10
|
-
flags: AuthenticatorFlags;
|
|
11
|
-
signCount: number;
|
|
12
|
-
aaguid?: Uint8Array;
|
|
13
|
-
credentialId?: Uint8Array;
|
|
14
|
-
credentialPublicKey?: Uint8Array;
|
|
15
|
-
extensions?: ParsedExtensions;
|
|
16
|
-
raw: Uint8Array;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Parsed and validated clientDataJSON payload.
|
|
20
|
-
*/
|
|
21
|
-
export interface ParsedClientData {
|
|
22
|
-
type: string;
|
|
23
|
-
challenge: string;
|
|
24
|
-
origin: string;
|
|
25
|
-
crossOrigin?: boolean;
|
|
26
|
-
rawJson: string;
|
|
27
|
-
sha256: Uint8Array;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Imported WebCrypto public key with associated COSE metadata.
|
|
31
|
-
*/
|
|
32
|
-
export interface ParsedCOSEKey {
|
|
33
|
-
kty: COSEKeyType;
|
|
34
|
-
alg: COSEAlgorithm;
|
|
35
|
-
cryptoKey: CryptoKey;
|
|
36
|
-
algorithmParams: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Input parameters for verifying a WebAuthn registration response.
|
|
40
|
-
*/
|
|
41
|
-
export interface RegistrationVerificationOptions {
|
|
42
|
-
response: {
|
|
43
|
-
id: string;
|
|
44
|
-
rawId: string;
|
|
45
|
-
response: {
|
|
46
|
-
clientDataJSON: string | Uint8Array;
|
|
47
|
-
attestationObject: string | Uint8Array;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
expectedChallenge: string;
|
|
51
|
-
expectedOrigin: ExpectedOrigin;
|
|
52
|
-
expectedRpId: string;
|
|
53
|
-
requireUserVerification?: boolean;
|
|
54
|
-
allowCrossOrigin?: boolean;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Verification outcome containing the newly enrolled credential.
|
|
58
|
-
*/
|
|
59
|
-
export interface RegistrationResult {
|
|
60
|
-
verified: boolean;
|
|
61
|
-
credential: {
|
|
62
|
-
id: string;
|
|
63
|
-
publicKey: Uint8Array;
|
|
64
|
-
aaguid: string;
|
|
65
|
-
signCount: number;
|
|
66
|
-
backupEligible: boolean;
|
|
67
|
-
backupState: boolean;
|
|
68
|
-
};
|
|
69
|
-
extensions?: ParsedExtensions;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Input parameters for verifying a WebAuthn authentication assertion response.
|
|
73
|
-
*/
|
|
74
|
-
export interface AuthenticationVerificationOptions {
|
|
75
|
-
response: {
|
|
76
|
-
id: string;
|
|
77
|
-
rawId: string;
|
|
78
|
-
response: {
|
|
79
|
-
clientDataJSON: string | Uint8Array;
|
|
80
|
-
authenticatorData: string | Uint8Array;
|
|
81
|
-
signature: string | Uint8Array;
|
|
82
|
-
userHandle?: string;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
expectedChallenge: string;
|
|
86
|
-
expectedOrigin: ExpectedOrigin;
|
|
87
|
-
expectedRpId: string;
|
|
88
|
-
credentialPublicKey: Uint8Array;
|
|
89
|
-
prevSignCount?: number;
|
|
90
|
-
requireUserVerification?: boolean;
|
|
91
|
-
allowCrossOrigin?: boolean;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Verification outcome of an authentication assertion.
|
|
95
|
-
*/
|
|
96
|
-
export interface AuthenticationResult {
|
|
97
|
-
verified: boolean;
|
|
98
|
-
newSignCount: number;
|
|
99
|
-
userPresent: boolean;
|
|
100
|
-
userVerified: boolean;
|
|
101
|
-
backupState: boolean;
|
|
102
|
-
extensions?: ParsedExtensions;
|
|
103
|
-
}
|