Skip to content

Commit 4fe6392

Browse files
authored
Merge pull request #655 from MasterKale/feat/654-deno-docs-improvements
feat/654-deno-docs-improvements
2 parents ff45a3b + 1876a0e commit 4fe6392

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1682
-394
lines changed

HANDBOOK.md

-13
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Update `"version"` in the following **deno.json** files for each package that ne
2828

2929
- **@simplewebauthn/browser**: [packages/browser/deno.json](./packages/browser/deno.json)
3030
- **@simplewebauthn/server**: [packages/server/deno.json](./packages/server/deno.json)
31-
- **@simplewebauthn/types**: [packages/types/deno.json](./packages/types/deno.json)
3231

3332
Continue using your best judgement on what an appropriate new version number should be.
3433

@@ -46,12 +45,6 @@ The following commands can be run from the root of the monorepo to build the res
4645
then **publish it to both [NPM](https://www.npmjs.com/search?q=%40simplewebauthn) and
4746
[JSR](https://jsr.io/@simplewebauthn)**.
4847

49-
#### Need to publish @simplewebauthn/types?
50-
51-
```
52-
deno task publish:types
53-
```
54-
5548
#### Need to publish @simplewebauthn/browser?
5649

5750
```
@@ -60,12 +53,6 @@ deno task publish:browser
6053

6154
#### Need to publish @simplewebauthn/server?
6255

63-
1.
64-
- [ ] Make sure the correct version of **@simplewebauthn/types** is on NPM
65-
- The `npm install` step that dnt performs while building **@simplewebauthn/server** pulls from
66-
NPM. The build will fail if the version of **@simplewebauthn/types** specified in
67-
[packages/types/deno.json](./packages/types/deno.json) is unavailable on NPM.
68-
6956
```
7057
deno task publish:server
7158
```

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ incorporate WebAuthn into a website. The following packages are maintained here:
2020
- [@simplewebauthn/server](https://github.com/MasterKale/SimpleWebAuthn/tree/master/packages/server)
2121
- [@simplewebauthn/browser](https://github.com/MasterKale/SimpleWebAuthn/tree/master/packages/browser)
2222

23-
An additional package is also included that contains shared TypeScript definitions:
24-
25-
- [@simplewebauthn/types](https://github.com/MasterKale/SimpleWebAuthn/tree/master/packages/types/)
26-
2723
## Installation
2824

2925
SimpleWebAuthn can be installed from **[NPM](https://www.npmjs.com/search?q=%40simplewebauthn)** and

deno.json

+13-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,19 @@
2222
]
2323
},
2424
"test:coverage:collect": "deno test -A --coverage=cov_profile",
25-
"build:types": "(cd packages/types; deno task build)",
26-
"build:browser": "(cd packages/browser; deno task build)",
27-
"build:server": "(cd packages/server; deno task build)",
28-
"publish:types": "(cd packages/types; deno task publish)",
25+
"codegen:types": "(cd packages/types; deno task codegen)",
26+
"build:browser": {
27+
"command": "(cd packages/browser; deno task build)",
28+
"dependencies": [
29+
"codegen:types"
30+
]
31+
},
32+
"build:server": {
33+
"command": "(cd packages/server; deno task build)",
34+
"dependencies": [
35+
"codegen:types"
36+
]
37+
},
2938
"publish:browser": "(cd packages/browser; deno task publish)",
3039
"publish:server": "(cd packages/server; deno task publish)"
3140
},

packages/browser/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ and **[JSR](https://jsr.io/@simplewebauthn/browser)**:
2222
### Node LTS 20.x and higher
2323

2424
```sh
25-
npm install @simplewebauthn/browser @simplewebauthn/types
25+
npm install @simplewebauthn/browser
2626
```
2727

2828
### Deno v1.43 and higher
2929

3030
```sh
31-
deno add jsr:@simplewebauthn/browser jsr:@simplewebauthn/types
31+
deno add jsr:@simplewebauthn/browser
3232
```
3333

3434
### UMD

packages/browser/build_npm.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ async function buildESMAndCJS() {
5757
'umd',
5858
],
5959
unpkg: 'dist/bundle/index.umd.min.js',
60-
dependencies: {
61-
// Deno workspaces maps this identifier locally, make sure it's defined in the NPM package
62-
'@simplewebauthn/types': `^${typesDenoJSON.version}`,
63-
},
60+
dependencies: {},
6461
},
6562
// Map from Deno package to NPM package for Node build
6663
mappings: {},

packages/browser/deno.json

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
},
1212
"test": "deno test -A src/",
1313
"test:watch": "deno test -A --watch src/",
14+
"docs:serve": {
15+
"command": "deno run -A jsr:@std/http/file-server --host 127.0.0.1 docs/",
16+
"dependencies": [
17+
"docs:html"
18+
]
19+
},
20+
"docs:html": "deno doc --html src/index.ts",
21+
"docs:lint": "deno doc --lint src/index.ts",
1422
"publish": {
1523
"command": "deno task publish:jsr && deno task publish:npm",
1624
"dependencies": [

packages/browser/src/helpers/browserSupportsWebAuthn.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ export function browserSupportsWebAuthn(): boolean {
88
);
99
}
1010

11-
// Make it possible to stub the return value during testing
11+
/**
12+
* Make it possible to stub the return value during testing
13+
* @ignore Don't include this in docs output
14+
*/
1215
export const _browserSupportsWebAuthnInternals = {
1316
stubThis: (value: boolean) => value,
1417
};

packages/browser/src/helpers/browserSupportsWebAuthnAutofill.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { PublicKeyCredentialFuture } from '@simplewebauthn/types';
2-
1+
import type { PublicKeyCredentialFuture } from '../types/index.ts';
32
import { browserSupportsWebAuthn } from './browserSupportsWebAuthn.ts';
43

54
/**

packages/browser/src/helpers/toAuthenticatorAttachment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AuthenticatorAttachment } from '@simplewebauthn/types';
1+
import type { AuthenticatorAttachment } from '../types/index.ts';
22

33
const attachments: AuthenticatorAttachment[] = ['cross-platform', 'platform'];
44

packages/browser/src/helpers/toPublicKeyCredentialDescriptor.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import type {
22
AuthenticatorTransport,
33
PublicKeyCredentialDescriptor,
44
PublicKeyCredentialDescriptorJSON,
5-
} from '@simplewebauthn/types';
6-
5+
} from '../types/index.ts';
76
import { base64URLStringToBuffer } from './base64URLStringToBuffer.ts';
87

98
export function toPublicKeyCredentialDescriptor(

packages/browser/src/helpers/webAuthnAbortService.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
interface WebAuthnAbortService {
2+
/**
3+
* Prepare an abort signal that will help support multiple auth attempts without needing to
4+
* reload the page. This is automatically called whenever `startRegistration()` and
5+
* `startAuthentication()` are called.
6+
*/
27
createNewAbortSignal(): AbortSignal;
8+
/**
9+
* Manually cancel any active WebAuthn registration or authentication attempt.
10+
*/
311
cancelCeremony(): void;
412
}
513

614
class BaseWebAuthnAbortService implements WebAuthnAbortService {
715
private controller: AbortController | undefined;
816

9-
/**
10-
* Prepare an abort signal that will help support multiple auth attempts without needing to
11-
* reload the page. This is automatically called whenever `startRegistration()` and
12-
* `startAuthentication()` are called.
13-
*/
1417
createNewAbortSignal(): AbortSignal {
1518
// Abort any existing calls to navigator.credentials.create() or navigator.credentials.get()
1619
if (this.controller) {
@@ -27,9 +30,6 @@ class BaseWebAuthnAbortService implements WebAuthnAbortService {
2730
return newController.signal;
2831
}
2932

30-
/**
31-
* Manually cancel any active WebAuthn registration or authentication attempt.
32-
*/
3333
cancelCeremony(): void {
3434
if (this.controller) {
3535
const abortError = new Error(

packages/browser/src/index.ts

+10-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
1-
/**
2-
* @packageDocumentation
3-
* @module @simplewebauthn/browser
4-
*/
5-
import { startRegistration } from './methods/startRegistration.ts';
6-
import { startAuthentication } from './methods/startAuthentication.ts';
7-
import { browserSupportsWebAuthn } from './helpers/browserSupportsWebAuthn.ts';
8-
import { platformAuthenticatorIsAvailable } from './helpers/platformAuthenticatorIsAvailable.ts';
9-
import { browserSupportsWebAuthnAutofill } from './helpers/browserSupportsWebAuthnAutofill.ts';
10-
import { base64URLStringToBuffer } from './helpers/base64URLStringToBuffer.ts';
11-
import { bufferToBase64URLString } from './helpers/bufferToBase64URLString.ts';
12-
import { WebAuthnAbortService } from './helpers/webAuthnAbortService.ts';
13-
import { WebAuthnError } from './helpers/webAuthnError.ts';
14-
15-
export {
16-
base64URLStringToBuffer,
17-
browserSupportsWebAuthn,
18-
browserSupportsWebAuthnAutofill,
19-
bufferToBase64URLString,
20-
platformAuthenticatorIsAvailable,
21-
startAuthentication,
22-
startRegistration,
23-
WebAuthnAbortService,
24-
WebAuthnError,
25-
};
26-
27-
export type { WebAuthnErrorCode } from './helpers/webAuthnError.ts';
1+
export * from './methods/startRegistration.ts';
2+
export * from './methods/startAuthentication.ts';
3+
export * from './helpers/browserSupportsWebAuthn.ts';
4+
export * from './helpers/platformAuthenticatorIsAvailable.ts';
5+
export * from './helpers/browserSupportsWebAuthnAutofill.ts';
6+
export * from './helpers/base64URLStringToBuffer.ts';
7+
export * from './helpers/bufferToBase64URLString.ts';
8+
export * from './helpers/webAuthnAbortService.ts';
9+
export * from './helpers/webAuthnError.ts';
10+
export * from './types/index.ts';

packages/browser/src/methods/startAuthentication.test.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ import {
77
assertRejects,
88
assertStringIncludes,
99
} from '@std/assert';
10-
import { assertSpyCalls, type Spy, spy, stub } from '@std/testing/mock';
10+
import { assertSpyCalls, type Spy, spy } from '@std/testing/mock';
1111
import { afterEach, beforeEach, describe, it } from '@std/testing/bdd';
1212
import { JSDOM } from 'jsdom';
13-
import {
14-
AuthenticationCredential,
13+
import type {
1514
AuthenticationExtensionsClientInputs,
1615
AuthenticationExtensionsClientOutputs,
1716
PublicKeyCredentialRequestOptionsJSON,
18-
} from '@simplewebauthn/types';
17+
} from '../types/index.ts';
1918

2019
import { _browserSupportsWebAuthnInternals } from '../helpers/browserSupportsWebAuthn.ts';
2120
import { _browserSupportsWebAuthnAutofillInternals } from '../helpers/browserSupportsWebAuthnAutofill.ts';
22-
import { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.ts';
2321
import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.ts';
2422
import { WebAuthnError } from '../helpers/webAuthnError.ts';
2523
import { generateCustomError } from '../helpers/__jest__/generateCustomError.ts';

packages/browser/src/methods/startAuthentication.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import {
1+
import type {
22
AuthenticationCredential,
33
AuthenticationResponseJSON,
44
PublicKeyCredentialRequestOptionsJSON,
5-
} from '@simplewebauthn/types';
6-
5+
} from '../types/index.ts';
76
import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.ts';
87
import { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.ts';
98
import { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.ts';
@@ -13,11 +12,7 @@ import { identifyAuthenticationError } from '../helpers/identifyAuthenticationEr
1312
import { WebAuthnAbortService } from '../helpers/webAuthnAbortService.ts';
1413
import { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.ts';
1514

16-
export type StartAuthenticationOpts = {
17-
optionsJSON: PublicKeyCredentialRequestOptionsJSON;
18-
useBrowserAutofill?: boolean;
19-
verifyBrowserAutofillInput?: boolean;
20-
};
15+
export type StartAuthenticationOpts = Parameters<typeof startAuthentication>[0];
2116

2217
/**
2318
* Begin authenticator "login" via WebAuthn assertion
@@ -27,7 +22,11 @@ export type StartAuthenticationOpts = {
2722
* @param verifyBrowserAutofillInput (Optional) Ensure a suitable `<input>` element is present when `useBrowserAutofill` is `true`. Defaults to `true`.
2823
*/
2924
export async function startAuthentication(
30-
options: StartAuthenticationOpts,
25+
options: {
26+
optionsJSON: PublicKeyCredentialRequestOptionsJSON;
27+
useBrowserAutofill?: boolean;
28+
verifyBrowserAutofillInput?: boolean;
29+
},
3130
): Promise<AuthenticationResponseJSON> {
3231
const {
3332
optionsJSON,

packages/browser/src/methods/startRegistration.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import { assertEquals, assertInstanceOf, assertRejects, assertStringIncludes } from '@std/assert';
33
import { assertSpyCalls, type Spy, spy, stub } from '@std/testing/mock';
44
import { afterEach, beforeEach, describe, it } from '@std/testing/bdd';
5-
import {
5+
import type {
66
AuthenticationExtensionsClientInputs,
77
AuthenticationExtensionsClientOutputs,
88
PublicKeyCredentialCreationOptionsJSON,
9-
} from '@simplewebauthn/types';
9+
} from '../types/index.ts';
1010

1111
import { generateCustomError } from '../helpers/__jest__/generateCustomError.ts';
1212
import { _browserSupportsWebAuthnInternals } from '../helpers/browserSupportsWebAuthn.ts';

packages/browser/src/methods/startRegistration.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import {
1+
import type {
22
AuthenticatorTransportFuture,
33
PublicKeyCredentialCreationOptionsJSON,
44
RegistrationCredential,
55
RegistrationResponseJSON,
6-
} from '@simplewebauthn/types';
7-
6+
} from '../types/index.ts';
87
import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.ts';
98
import { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.ts';
109
import { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.ts';
@@ -13,10 +12,7 @@ import { identifyRegistrationError } from '../helpers/identifyRegistrationError.
1312
import { WebAuthnAbortService } from '../helpers/webAuthnAbortService.ts';
1413
import { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.ts';
1514

16-
export type StartRegistrationOpts = {
17-
optionsJSON: PublicKeyCredentialCreationOptionsJSON;
18-
useAutoRegister?: boolean;
19-
};
15+
export type StartRegistrationOpts = Parameters<typeof startRegistration>[0];
2016

2117
/**
2218
* Begin authenticator "registration" via WebAuthn attestation
@@ -25,7 +21,10 @@ export type StartRegistrationOpts = {
2521
* @param useAutoRegister (Optional) Try to silently create a passkey with the password manager that the user just signed in with. Defaults to `false`.
2622
*/
2723
export async function startRegistration(
28-
options: StartRegistrationOpts,
24+
options: {
25+
optionsJSON: PublicKeyCredentialCreationOptionsJSON;
26+
useAutoRegister?: boolean;
27+
},
2928
): Promise<RegistrationResponseJSON> {
3029
const { optionsJSON, useAutoRegister = false } = options;
3130

0 commit comments

Comments
 (0)