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

Commit

Permalink
rename webauthn to passkey
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper committed Apr 26, 2024
1 parent a125398 commit ed1bad2
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 106 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A collection of auth-related utilities, including:
- `oslo/jwt`: Create and verify JWTs
- `oslo/oauth2`: OAuth2 helpers
- `oslo/otp`: HOTP, TOTP
- `oslo/webauthn`: Verify Web Authentication API attestations and assertions
- `oslo/passkey`: Verify Web Authentication API attestations and assertions for passkeys

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

Expand Down
2 changes: 1 addition & 1 deletion docs/malta.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
["oslo/jwt", "/reference/jwt"],
["oslo/oauth2", "/reference/oauth2"],
["oslo/otp", "/reference/otp"],
["oslo/webauthn", "/reference/webauthn"]
["oslo/passkey", "/reference/passkey"]
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A collection of auth-related utilities, including:
- `oslo/jwt`: Create and verify JWTs
- `oslo/oauth2`: OAuth2 helpers
- `oslo/otp`: HOTP, TOTP
- `oslo/webauthn`: Verify Web Authentication API attestations and assertions
- `oslo/passkey`: Verify Web Authentication API attestations and assertions for passkeys

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

Expand Down
22 changes: 22 additions & 0 deletions docs/pages/reference/passkey/PasskeyController/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: "PasskeyController"
---

# `PasskeyController`

Provides methods for validating WebAuthn attestation and assertion responses for passkeys. Supports ES256 (algorithm id `-7`) and RS256 (algorithm id `-257`).

## Constructor

```ts
function constructor(origin: string): this;
```

### Parameters

- `origin`: Where the frontend is hosted (full url)

## Methods

- [`validateAssertionResponse()`](/reference/passkey/PasskeyController/validateAssertionResponse)
- [`validateAttestationResponse()`](/reference/passkey/PasskeyController/validateAttestationResponse)
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
title: "WebAuthnController.validateAssertionResponse()"
title: "PasskeyController.validateAssertionResponse()"
---

# `WebAuthnController.validateAssertionResponse()`
# `PasskeyController.validateAssertionResponse()`

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

## Definition

```ts
//$ AssertionResponse=/reference/webauthn/AssertionResponse
//$ WebAuthnAssertionResponse=/reference/passkey/WebAuthnAssertionResponse
function validateAssertionResponse(
algorithm: "ES256" | "RS256",
publicKey: Uint8Array,
response: $$AssertionResponse,
response: $$WebAuthnAssertionResponse,
challenge: Uint8Array
): Promise<void>;
```
Expand All @@ -28,15 +28,15 @@ function validateAssertionResponse(
## Example

```ts
//$ AssertionResponse=/reference/webauthn/AssertionResponse
//$ webAuthnController=/reference/webauthn/WebAuthnController
//$ WebAuthnAssertionResponse=/reference/passkey/WebAuthnAssertionResponse
//$ passkeyController=/reference/passkey/PasskeyController
try {
const response: $$AssertionResponse = {
const response: $$WebAuthnAssertionResponse = {
clientDataJSON,
authenticatorData,
signature
};
await $$webAuthnController.validateAssertionResponse("ES256", publicKey, response, challenge);
await $$passkeyController.validateAssertionResponse("ES256", publicKey, response, challenge);
} catch {
// failed to validate
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: "PasskeyController.validateAssertionResponse()"
---

# `PasskeyController.validateAttestationResponse()`

Validates a WebAuthn attestation response, including the signature, but not the attestation certificate. Throws an error on invalid response.

## Definition

```ts
//$ WebAuthnAttestationResponse=/reference/passkey/WebAuthnAttestationResponse
function validateAttestationResponse(
response: $$WebAuthnAttestationResponse,
challenge: Uint8Array
): Promise<void>;
```

### Parameters

- `response`: Attestation response
- `challenge`: Challenge used for creating the signature

## Example

```ts
//$ WebAuthnAttestationResponse=/reference/passkey/WebAuthnAttestationResponse
//$ passkeyController=/reference/passkey/PasskeyController
try {
const response: $$WebAuthnAttestationResponse = {
clientDataJSON,
authenticatorData
};
await $$passkeyController.validateAttestationResponse(response, challenge);
} catch {
// failed to validate
}
```
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: "AssertionResponse"
title: "WebAuthnAssertionResponse"
---

# `AssertionResponse`
# `WebAuthnAssertionResponse`

Represents a WebAuthn assertion response.

## Definition

```ts
interface AssertionResponse {
interface WebAuthnAssertionResponse {
clientDataJSON: Uint8Array;
authenticatorData: Uint8Array;
signature: Uint8Array;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: "AttestationResponse"
title: "WebAuthnAttestationResponse"
---

# `AttestationResponse`
# `WebAuthnAttestationResponse`

Represents a WebAuthn attestation response.

## Definition

```ts
interface AttestationResponse {
interface WebAuthnAttestationResponse {
clientDataJSON: Uint8Array;
authenticatorData: Uint8Array;
}
Expand Down
16 changes: 16 additions & 0 deletions docs/pages/reference/passkey/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "oslo/passkey"
---

# `oslo/passkey`

Provides utilities for working with passkeys using the Web Authentication API.

## Classes

- [`PasskeyController`](/reference/passkey/PasskeyController)

## Interfaces

- [`WebAuthnAssertionResponse`](/reference/passkey/WebAuthnAssertionResponse)
- [`WebAuthnAttestationResponse`](/reference/passkey/WebAuthnAttestationResponse)
22 changes: 0 additions & 22 deletions docs/pages/reference/webauthn/WebAuthnController/index.md

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions docs/pages/reference/webauthn/index.md

This file was deleted.

11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"./jwt": "./dist/jwt/index.js",
"./oauth2": "./dist/oauth2/index.js",
"./otp": "./dist/otp/index.js",
"./webauthn": "./dist/webauthn/index.js"
"./passkey": "./dist/passkey/index.js"
},
"typesVersions": {
"*": {
Expand Down Expand Up @@ -52,8 +52,8 @@
"otp": [
"dist/otp/index.d.ts"
],
"webauthn": [
"dist/webauthn/index.d.ts"
"passkey": [
"dist/passkey/index.d.ts"
]
}
},
Expand All @@ -63,6 +63,7 @@
"jwt",
"crypto",
"webauthn",
"passkey",
"otp",
"encoding",
"auth",
Expand All @@ -84,9 +85,5 @@
"prettier": "^3.0.3",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
},
"dependencies": {
"@node-rs/argon2": "1.7.0",
"@node-rs/bcrypt": "1.9.0"
}
}
10 changes: 5 additions & 5 deletions src/webauthn/index.ts → src/passkey/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import { base64url } from "../encoding/index.js";
import { compareBytes, concatenateBytes } from "../binary/index.js";
import { ECDSA, RSASSAPKCS1v1_5, sha256 } from "../crypto/index.js";

export interface AttestationResponse {
export interface WebAuthnAttestationResponse {
clientDataJSON: Uint8Array;
authenticatorData: Uint8Array;
}

export interface AssertionResponse {
export interface WebAuthnAssertionResponse {
clientDataJSON: Uint8Array;
authenticatorData: Uint8Array;
signature: Uint8Array;
}

export class WebAuthnController {
export class PasskeyController {
private originURL: URL;
constructor(origin: string) {
this.originURL = new URL(origin);
}

public async validateAttestationResponse(
response: AttestationResponse,
response: WebAuthnAttestationResponse,
challenge: Uint8Array
): Promise<void> {
const validClientDataJSON = this.verifyClientDataJSON(
Expand All @@ -41,7 +41,7 @@ export class WebAuthnController {
public async validateAssertionResponse(
algorithm: "ES256" | "RS256",
publicKey: Uint8Array,
response: AssertionResponse,
response: WebAuthnAssertionResponse,
challenge: Uint8Array
): Promise<void> {
const validClientDataJSON = this.verifyClientDataJSON(
Expand Down

0 comments on commit ed1bad2

Please sign in to comment.