Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit ed1bad2

Browse files
rename webauthn to passkey
1 parent a125398 commit ed1bad2

14 files changed

+102
-106
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A collection of auth-related utilities, including:
99
- `oslo/jwt`: Create and verify JWTs
1010
- `oslo/oauth2`: OAuth2 helpers
1111
- `oslo/otp`: HOTP, TOTP
12-
- `oslo/webauthn`: Verify Web Authentication API attestations and assertions
12+
- `oslo/passkey`: Verify Web Authentication API attestations and assertions for passkeys
1313

1414
It's lightweight, runtime-agnostic, and fully typed.
1515

docs/malta.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
["oslo/jwt", "/reference/jwt"],
1616
["oslo/oauth2", "/reference/oauth2"],
1717
["oslo/otp", "/reference/otp"],
18-
["oslo/webauthn", "/reference/webauthn"]
18+
["oslo/passkey", "/reference/passkey"]
1919
]
2020
},
2121
{

docs/pages/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A collection of auth-related utilities, including:
1313
- `oslo/jwt`: Create and verify JWTs
1414
- `oslo/oauth2`: OAuth2 helpers
1515
- `oslo/otp`: HOTP, TOTP
16-
- `oslo/webauthn`: Verify Web Authentication API attestations and assertions
16+
- `oslo/passkey`: Verify Web Authentication API attestations and assertions for passkeys
1717

1818
It's lightweight, runtime-agnostic, and fully typed.
1919

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: "PasskeyController"
3+
---
4+
5+
# `PasskeyController`
6+
7+
Provides methods for validating WebAuthn attestation and assertion responses for passkeys. Supports ES256 (algorithm id `-7`) and RS256 (algorithm id `-257`).
8+
9+
## Constructor
10+
11+
```ts
12+
function constructor(origin: string): this;
13+
```
14+
15+
### Parameters
16+
17+
- `origin`: Where the frontend is hosted (full url)
18+
19+
## Methods
20+
21+
- [`validateAssertionResponse()`](/reference/passkey/PasskeyController/validateAssertionResponse)
22+
- [`validateAttestationResponse()`](/reference/passkey/PasskeyController/validateAttestationResponse)

docs/pages/reference/webauthn/WebAuthnController/validateAssertionResponse.md docs/pages/reference/passkey/PasskeyController/validateAssertionResponse.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
2-
title: "WebAuthnController.validateAssertionResponse()"
2+
title: "PasskeyController.validateAssertionResponse()"
33
---
44

5-
# `WebAuthnController.validateAssertionResponse()`
5+
# `PasskeyController.validateAssertionResponse()`
66

77
Validates a WebAuthn assertion response, including the signature. Supports ES256 (algorithm id `-7`) and RS256 (algorithm id `-257`). Throws an error on invalid response.
88

99
## Definition
1010

1111
```ts
12-
//$ AssertionResponse=/reference/webauthn/AssertionResponse
12+
//$ WebAuthnAssertionResponse=/reference/passkey/WebAuthnAssertionResponse
1313
function validateAssertionResponse(
1414
algorithm: "ES256" | "RS256",
1515
publicKey: Uint8Array,
16-
response: $$AssertionResponse,
16+
response: $$WebAuthnAssertionResponse,
1717
challenge: Uint8Array
1818
): Promise<void>;
1919
```
@@ -28,15 +28,15 @@ function validateAssertionResponse(
2828
## Example
2929

3030
```ts
31-
//$ AssertionResponse=/reference/webauthn/AssertionResponse
32-
//$ webAuthnController=/reference/webauthn/WebAuthnController
31+
//$ WebAuthnAssertionResponse=/reference/passkey/WebAuthnAssertionResponse
32+
//$ passkeyController=/reference/passkey/PasskeyController
3333
try {
34-
const response: $$AssertionResponse = {
34+
const response: $$WebAuthnAssertionResponse = {
3535
clientDataJSON,
3636
authenticatorData,
3737
signature
3838
};
39-
await $$webAuthnController.validateAssertionResponse("ES256", publicKey, response, challenge);
39+
await $$passkeyController.validateAssertionResponse("ES256", publicKey, response, challenge);
4040
} catch {
4141
// failed to validate
4242
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "PasskeyController.validateAssertionResponse()"
3+
---
4+
5+
# `PasskeyController.validateAttestationResponse()`
6+
7+
Validates a WebAuthn attestation response, including the signature, but not the attestation certificate. Throws an error on invalid response.
8+
9+
## Definition
10+
11+
```ts
12+
//$ WebAuthnAttestationResponse=/reference/passkey/WebAuthnAttestationResponse
13+
function validateAttestationResponse(
14+
response: $$WebAuthnAttestationResponse,
15+
challenge: Uint8Array
16+
): Promise<void>;
17+
```
18+
19+
### Parameters
20+
21+
- `response`: Attestation response
22+
- `challenge`: Challenge used for creating the signature
23+
24+
## Example
25+
26+
```ts
27+
//$ WebAuthnAttestationResponse=/reference/passkey/WebAuthnAttestationResponse
28+
//$ passkeyController=/reference/passkey/PasskeyController
29+
try {
30+
const response: $$WebAuthnAttestationResponse = {
31+
clientDataJSON,
32+
authenticatorData
33+
};
34+
await $$passkeyController.validateAttestationResponse(response, challenge);
35+
} catch {
36+
// failed to validate
37+
}
38+
```

docs/pages/reference/webauthn/AssertionResponse.md docs/pages/reference/passkey/WebAuthnAssertionResponse.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
2-
title: "AssertionResponse"
2+
title: "WebAuthnAssertionResponse"
33
---
44

5-
# `AssertionResponse`
5+
# `WebAuthnAssertionResponse`
66

77
Represents a WebAuthn assertion response.
88

99
## Definition
1010

1111
```ts
12-
interface AssertionResponse {
12+
interface WebAuthnAssertionResponse {
1313
clientDataJSON: Uint8Array;
1414
authenticatorData: Uint8Array;
1515
signature: Uint8Array;

docs/pages/reference/webauthn/AttestationResponse.md docs/pages/reference/passkey/WebAuthnAttestationResponse.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
2-
title: "AttestationResponse"
2+
title: "WebAuthnAttestationResponse"
33
---
44

5-
# `AttestationResponse`
5+
# `WebAuthnAttestationResponse`
66

77
Represents a WebAuthn attestation response.
88

99
## Definition
1010

1111
```ts
12-
interface AttestationResponse {
12+
interface WebAuthnAttestationResponse {
1313
clientDataJSON: Uint8Array;
1414
authenticatorData: Uint8Array;
1515
}

docs/pages/reference/passkey/index.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: "oslo/passkey"
3+
---
4+
5+
# `oslo/passkey`
6+
7+
Provides utilities for working with passkeys using the Web Authentication API.
8+
9+
## Classes
10+
11+
- [`PasskeyController`](/reference/passkey/PasskeyController)
12+
13+
## Interfaces
14+
15+
- [`WebAuthnAssertionResponse`](/reference/passkey/WebAuthnAssertionResponse)
16+
- [`WebAuthnAttestationResponse`](/reference/passkey/WebAuthnAttestationResponse)

docs/pages/reference/webauthn/WebAuthnController/index.md

-22
This file was deleted.

docs/pages/reference/webauthn/WebAuthnController/validateAttestationResponse.md

-39
This file was deleted.

docs/pages/reference/webauthn/index.md

-16
This file was deleted.

package.json

+4-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"./jwt": "./dist/jwt/index.js",
2525
"./oauth2": "./dist/oauth2/index.js",
2626
"./otp": "./dist/otp/index.js",
27-
"./webauthn": "./dist/webauthn/index.js"
27+
"./passkey": "./dist/passkey/index.js"
2828
},
2929
"typesVersions": {
3030
"*": {
@@ -52,8 +52,8 @@
5252
"otp": [
5353
"dist/otp/index.d.ts"
5454
],
55-
"webauthn": [
56-
"dist/webauthn/index.d.ts"
55+
"passkey": [
56+
"dist/passkey/index.d.ts"
5757
]
5858
}
5959
},
@@ -63,6 +63,7 @@
6363
"jwt",
6464
"crypto",
6565
"webauthn",
66+
"passkey",
6667
"otp",
6768
"encoding",
6869
"auth",
@@ -84,9 +85,5 @@
8485
"prettier": "^3.0.3",
8586
"typescript": "^5.2.2",
8687
"vitest": "^0.34.6"
87-
},
88-
"dependencies": {
89-
"@node-rs/argon2": "1.7.0",
90-
"@node-rs/bcrypt": "1.9.0"
9188
}
9289
}

src/webauthn/index.ts src/passkey/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ import { base64url } from "../encoding/index.js";
22
import { compareBytes, concatenateBytes } from "../binary/index.js";
33
import { ECDSA, RSASSAPKCS1v1_5, sha256 } from "../crypto/index.js";
44

5-
export interface AttestationResponse {
5+
export interface WebAuthnAttestationResponse {
66
clientDataJSON: Uint8Array;
77
authenticatorData: Uint8Array;
88
}
99

10-
export interface AssertionResponse {
10+
export interface WebAuthnAssertionResponse {
1111
clientDataJSON: Uint8Array;
1212
authenticatorData: Uint8Array;
1313
signature: Uint8Array;
1414
}
1515

16-
export class WebAuthnController {
16+
export class PasskeyController {
1717
private originURL: URL;
1818
constructor(origin: string) {
1919
this.originURL = new URL(origin);
2020
}
2121

2222
public async validateAttestationResponse(
23-
response: AttestationResponse,
23+
response: WebAuthnAttestationResponse,
2424
challenge: Uint8Array
2525
): Promise<void> {
2626
const validClientDataJSON = this.verifyClientDataJSON(
@@ -41,7 +41,7 @@ export class WebAuthnController {
4141
public async validateAssertionResponse(
4242
algorithm: "ES256" | "RS256",
4343
publicKey: Uint8Array,
44-
response: AssertionResponse,
44+
response: WebAuthnAssertionResponse,
4545
challenge: Uint8Array
4646
): Promise<void> {
4747
const validClientDataJSON = this.verifyClientDataJSON(

0 commit comments

Comments
 (0)