@fgv/ts-extras-webauthn 5.1.0-27 → 5.1.0-28

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.
@@ -0,0 +1,30 @@
1
+ Start time: Wed May 13 2026 09:53:05 GMT+0000 (Coordinated Universal Time)
2
+ Invoking "/usr/bin/tar -c -f /home/runner/work/fgv/fgv/common/temp/build-cache/c734cf2c164700a2a2cb43905416aaa929325f8f-0754e2c57dbb2d12.temp -z --files-from=-"
3
+
4
+ ======= BEGIN PROCESS INPUT ======
5
+ .rush/temp/operation/build/all.log
6
+ .rush/temp/operation/build/log-chunks.jsonl
7
+ .rush/temp/operation/build/state.json
8
+ dist/index.js
9
+ dist/index.js.map
10
+ dist/test/unit/webauthn.test.js
11
+ dist/test/unit/webauthn.test.js.map
12
+ dist/ts-extras-webauthn.d.ts
13
+ dist/tsdoc-metadata.json
14
+ lib/index.d.ts
15
+ lib/index.d.ts.map
16
+ lib/index.js
17
+ lib/index.js.map
18
+ lib/test/unit/webauthn.test.d.ts
19
+ lib/test/unit/webauthn.test.d.ts.map
20
+ lib/test/unit/webauthn.test.js
21
+ lib/test/unit/webauthn.test.js.map
22
+ temp/build/lint/_eslint-5eVG3S6w.json
23
+ temp/build/typescript/ts_8nwakTlr.json
24
+ temp/ts-extras-webauthn.api.json
25
+ temp/ts-extras-webauthn.api.md
26
+ ======== END PROCESS INPUT =======
27
+ ======= BEGIN PROCESS OUTPUT =======
28
+ ======== END PROCESS OUTPUT ========
29
+
30
+ Exited with code "0"
@@ -0,0 +1,9 @@
1
+ {"kind":"O","text":"Invoking: heft build --clean \n"}
2
+ {"kind":"O","text":" ---- build started ---- \n"}
3
+ {"kind":"O","text":"[build:typescript] The TypeScript compiler version 5.9.3 is newer than the latest version that was tested with Heft (5.8); it may not work correctly.\n"}
4
+ {"kind":"O","text":"[build:typescript] Using TypeScript version 5.9.3\n"}
5
+ {"kind":"O","text":"[build:lint] Using ESLint version 9.39.4\n"}
6
+ {"kind":"O","text":"[build:api-extractor] Using API Extractor version 7.58.7\n"}
7
+ {"kind":"O","text":"[build:api-extractor] Analysis will use the bundled TypeScript version 5.9.3\n"}
8
+ {"kind":"O","text":" ---- build finished (15.034s) ---- \n"}
9
+ {"kind":"O","text":"-------------------- Finished (15.037s) --------------------\n"}
@@ -0,0 +1,9 @@
1
+ Invoking: heft build --clean
2
+ ---- build started ----
3
+ [build:typescript] The TypeScript compiler version 5.9.3 is newer than the latest version that was tested with Heft (5.8); it may not work correctly.
4
+ [build:typescript] Using TypeScript version 5.9.3
5
+ [build:lint] Using ESLint version 9.39.4
6
+ [build:api-extractor] Using API Extractor version 7.58.7
7
+ [build:api-extractor] Analysis will use the bundled TypeScript version 5.9.3
8
+ ---- build finished (15.034s) ----
9
+ -------------------- Finished (15.037s) --------------------
@@ -0,0 +1,9 @@
1
+ {"kind":"O","text":"Invoking: heft build --clean \n"}
2
+ {"kind":"O","text":" ---- build started ---- \n"}
3
+ {"kind":"O","text":"[build:typescript] The TypeScript compiler version 5.9.3 is newer than the latest version that was tested with Heft (5.8); it may not work correctly.\n"}
4
+ {"kind":"O","text":"[build:typescript] Using TypeScript version 5.9.3\n"}
5
+ {"kind":"O","text":"[build:lint] Using ESLint version 9.39.4\n"}
6
+ {"kind":"O","text":"[build:api-extractor] Using API Extractor version 7.58.7\n"}
7
+ {"kind":"O","text":"[build:api-extractor] Analysis will use the bundled TypeScript version 5.9.3\n"}
8
+ {"kind":"O","text":" ---- build finished (15.034s) ---- \n"}
9
+ {"kind":"O","text":"-------------------- Finished (15.037s) --------------------\n"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "nonCachedDurationMs": 15535.471293000002
3
+ }
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ import { generateRegistrationOptions as _generateRegistrationOptions, verifyRegistrationResponse as _verifyRegistrationResponse, generateAuthenticationOptions as _generateAuthenticationOptions, verifyAuthenticationResponse as _verifyAuthenticationResponse } from '@simplewebauthn/server';
2
+ import { captureAsyncResult } from '@fgv/ts-utils';
3
+ /**
4
+ * Result-integration wrapper around `@simplewebauthn/server`'s `generateRegistrationOptions`.
5
+ * Returns `Promise<Result<PublicKeyCredentialCreationOptionsJSON>>`; upstream errors are captured
6
+ * as `Failure` with the original message.
7
+ * @see https://simplewebauthn.dev/docs/packages/server
8
+ * @public
9
+ */
10
+ export async function generateRegistrationOptions(options) {
11
+ return captureAsyncResult(() => _generateRegistrationOptions(options));
12
+ }
13
+ /**
14
+ * Result-integration wrapper around `@simplewebauthn/server`'s `verifyRegistrationResponse`.
15
+ * Returns `Promise<Result<VerifiedRegistrationResponse>>`; upstream errors are captured
16
+ * as `Failure` with the original message.
17
+ * @see https://simplewebauthn.dev/docs/packages/server
18
+ * @public
19
+ */
20
+ export async function verifyRegistrationResponse(options) {
21
+ return captureAsyncResult(() => _verifyRegistrationResponse(options));
22
+ }
23
+ /**
24
+ * Result-integration wrapper around `@simplewebauthn/server`'s `generateAuthenticationOptions`.
25
+ * Returns `Promise<Result<PublicKeyCredentialRequestOptionsJSON>>`; upstream errors are captured
26
+ * as `Failure` with the original message.
27
+ * @see https://simplewebauthn.dev/docs/packages/server
28
+ * @public
29
+ */
30
+ export async function generateAuthenticationOptions(options) {
31
+ return captureAsyncResult(() => _generateAuthenticationOptions(options));
32
+ }
33
+ /**
34
+ * Result-integration wrapper around `@simplewebauthn/server`'s `verifyAuthenticationResponse`.
35
+ * Returns `Promise<Result<VerifiedAuthenticationResponse>>`; upstream errors are captured
36
+ * as `Failure` with the original message.
37
+ * @see https://simplewebauthn.dev/docs/packages/server
38
+ * @public
39
+ */
40
+ export async function verifyAuthenticationResponse(options) {
41
+ return captureAsyncResult(() => _verifyAuthenticationResponse(options));
42
+ }
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,IAAI,4BAA4B,EAC3D,0BAA0B,IAAI,2BAA2B,EACzD,6BAA6B,IAAI,8BAA8B,EAC/D,4BAA4B,IAAI,6BAA6B,EAC9D,MAAM,wBAAwB,CAAC;AAchC,OAAO,EAAE,kBAAkB,EAAe,MAAM,eAAe,CAAC;AAgBhE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAwC;IAExC,OAAO,kBAAkB,CAAC,GAAG,EAAE,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,OAAuC;IAEvC,OAAO,kBAAkB,CAAC,GAAG,EAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAA0C;IAE1C,OAAO,kBAAkB,CAAC,GAAG,EAAE,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,OAAyC;IAEzC,OAAO,kBAAkB,CAAC,GAAG,EAAE,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import {\n generateRegistrationOptions as _generateRegistrationOptions,\n verifyRegistrationResponse as _verifyRegistrationResponse,\n generateAuthenticationOptions as _generateAuthenticationOptions,\n verifyAuthenticationResponse as _verifyAuthenticationResponse\n} from '@simplewebauthn/server';\nimport type {\n GenerateRegistrationOptionsOpts,\n PublicKeyCredentialCreationOptionsJSON,\n VerifyRegistrationResponseOpts,\n VerifiedRegistrationResponse,\n GenerateAuthenticationOptionsOpts,\n PublicKeyCredentialRequestOptionsJSON,\n VerifyAuthenticationResponseOpts,\n VerifiedAuthenticationResponse,\n WebAuthnCredential,\n RegistrationResponseJSON,\n AuthenticationResponseJSON\n} from '@simplewebauthn/server';\nimport { captureAsyncResult, type Result } from '@fgv/ts-utils';\n\nexport type {\n GenerateRegistrationOptionsOpts,\n PublicKeyCredentialCreationOptionsJSON,\n VerifyRegistrationResponseOpts,\n VerifiedRegistrationResponse,\n GenerateAuthenticationOptionsOpts,\n PublicKeyCredentialRequestOptionsJSON,\n VerifyAuthenticationResponseOpts,\n VerifiedAuthenticationResponse,\n WebAuthnCredential,\n RegistrationResponseJSON,\n AuthenticationResponseJSON\n};\n\n/**\n * Result-integration wrapper around `@simplewebauthn/server`'s `generateRegistrationOptions`.\n * Returns `Promise<Result<PublicKeyCredentialCreationOptionsJSON>>`; upstream errors are captured\n * as `Failure` with the original message.\n * @see https://simplewebauthn.dev/docs/packages/server\n * @public\n */\nexport async function generateRegistrationOptions(\n options: GenerateRegistrationOptionsOpts\n): Promise<Result<PublicKeyCredentialCreationOptionsJSON>> {\n return captureAsyncResult(() => _generateRegistrationOptions(options));\n}\n\n/**\n * Result-integration wrapper around `@simplewebauthn/server`'s `verifyRegistrationResponse`.\n * Returns `Promise<Result<VerifiedRegistrationResponse>>`; upstream errors are captured\n * as `Failure` with the original message.\n * @see https://simplewebauthn.dev/docs/packages/server\n * @public\n */\nexport async function verifyRegistrationResponse(\n options: VerifyRegistrationResponseOpts\n): Promise<Result<VerifiedRegistrationResponse>> {\n return captureAsyncResult(() => _verifyRegistrationResponse(options));\n}\n\n/**\n * Result-integration wrapper around `@simplewebauthn/server`'s `generateAuthenticationOptions`.\n * Returns `Promise<Result<PublicKeyCredentialRequestOptionsJSON>>`; upstream errors are captured\n * as `Failure` with the original message.\n * @see https://simplewebauthn.dev/docs/packages/server\n * @public\n */\nexport async function generateAuthenticationOptions(\n options: GenerateAuthenticationOptionsOpts\n): Promise<Result<PublicKeyCredentialRequestOptionsJSON>> {\n return captureAsyncResult(() => _generateAuthenticationOptions(options));\n}\n\n/**\n * Result-integration wrapper around `@simplewebauthn/server`'s `verifyAuthenticationResponse`.\n * Returns `Promise<Result<VerifiedAuthenticationResponse>>`; upstream errors are captured\n * as `Failure` with the original message.\n * @see https://simplewebauthn.dev/docs/packages/server\n * @public\n */\nexport async function verifyAuthenticationResponse(\n options: VerifyAuthenticationResponseOpts\n): Promise<Result<VerifiedAuthenticationResponse>> {\n return captureAsyncResult(() => _verifyAuthenticationResponse(options));\n}\n"]}
@@ -0,0 +1,115 @@
1
+ jest.mock('@simplewebauthn/server');
2
+ import '@fgv/ts-utils-jest';
3
+ import * as upstream from '@simplewebauthn/server';
4
+ import { generateAuthenticationOptions, generateRegistrationOptions, verifyAuthenticationResponse, verifyRegistrationResponse } from '../../index';
5
+ describe('generateRegistrationOptions', () => {
6
+ const mockOpts = {
7
+ rpName: 'Test RP',
8
+ rpID: 'test.example.com',
9
+ userName: 'user@test.com'
10
+ };
11
+ beforeEach(() => {
12
+ jest.resetAllMocks();
13
+ });
14
+ test('returns Success wrapping upstream result on success', async () => {
15
+ const mockResult = { challenge: 'abc123' };
16
+ jest.mocked(upstream.generateRegistrationOptions).mockResolvedValueOnce(mockResult);
17
+ expect(await generateRegistrationOptions(mockOpts)).toSucceedWith(mockResult);
18
+ });
19
+ test('returns Failure capturing upstream error message on throw', async () => {
20
+ jest
21
+ .mocked(upstream.generateRegistrationOptions)
22
+ .mockRejectedValueOnce(new Error('Challenge is not in the correct format'));
23
+ expect(await generateRegistrationOptions(mockOpts)).toFailWith(/challenge is not in the correct format/i);
24
+ });
25
+ });
26
+ describe('verifyRegistrationResponse', () => {
27
+ const mockOpts = {
28
+ response: {
29
+ id: 'cred-id',
30
+ rawId: 'cred-raw-id',
31
+ response: {
32
+ clientDataJSON: 'client-data',
33
+ attestationObject: 'attestation-object'
34
+ },
35
+ clientExtensionResults: {},
36
+ type: 'public-key'
37
+ },
38
+ expectedChallenge: 'challenge123',
39
+ expectedOrigin: 'https://test.example.com',
40
+ expectedRPID: 'test.example.com'
41
+ };
42
+ beforeEach(() => {
43
+ jest.resetAllMocks();
44
+ });
45
+ test('returns Success wrapping upstream result on success', async () => {
46
+ const mockResult = { verified: true };
47
+ jest.mocked(upstream.verifyRegistrationResponse).mockResolvedValueOnce(mockResult);
48
+ expect(await verifyRegistrationResponse(mockOpts)).toSucceedWith(mockResult);
49
+ });
50
+ test('returns Failure capturing upstream error message on throw', async () => {
51
+ jest
52
+ .mocked(upstream.verifyRegistrationResponse)
53
+ .mockRejectedValueOnce(new Error('The authenticator response contained invalid attestation'));
54
+ expect(await verifyRegistrationResponse(mockOpts)).toFailWith(/invalid attestation/i);
55
+ });
56
+ });
57
+ describe('generateAuthenticationOptions', () => {
58
+ const mockOpts = {
59
+ rpID: 'test.example.com'
60
+ };
61
+ beforeEach(() => {
62
+ jest.resetAllMocks();
63
+ });
64
+ test('returns Success wrapping upstream result on success', async () => {
65
+ const mockResult = { challenge: 'xyz789' };
66
+ jest.mocked(upstream.generateAuthenticationOptions).mockResolvedValueOnce(mockResult);
67
+ expect(await generateAuthenticationOptions(mockOpts)).toSucceedWith(mockResult);
68
+ });
69
+ test('returns Failure capturing upstream error message on throw', async () => {
70
+ jest
71
+ .mocked(upstream.generateAuthenticationOptions)
72
+ .mockRejectedValueOnce(new Error('Unexpected authentication response type'));
73
+ expect(await generateAuthenticationOptions(mockOpts)).toFailWith(/unexpected authentication response type/i);
74
+ });
75
+ });
76
+ describe('verifyAuthenticationResponse', () => {
77
+ const mockCredential = {
78
+ id: 'cred-id',
79
+ publicKey: new Uint8Array([1, 2, 3]),
80
+ counter: 0,
81
+ transports: ['usb']
82
+ };
83
+ const mockOpts = {
84
+ response: {
85
+ id: 'cred-id',
86
+ rawId: 'cred-raw-id',
87
+ response: {
88
+ clientDataJSON: 'client-data',
89
+ authenticatorData: 'auth-data',
90
+ signature: 'sig'
91
+ },
92
+ clientExtensionResults: {},
93
+ type: 'public-key'
94
+ },
95
+ expectedChallenge: 'challenge123',
96
+ expectedOrigin: 'https://test.example.com',
97
+ expectedRPID: 'test.example.com',
98
+ credential: mockCredential
99
+ };
100
+ beforeEach(() => {
101
+ jest.resetAllMocks();
102
+ });
103
+ test('returns Success wrapping upstream result on success', async () => {
104
+ const mockResult = { verified: true };
105
+ jest.mocked(upstream.verifyAuthenticationResponse).mockResolvedValueOnce(mockResult);
106
+ expect(await verifyAuthenticationResponse(mockOpts)).toSucceedWith(mockResult);
107
+ });
108
+ test('returns Failure capturing upstream error message on throw', async () => {
109
+ jest
110
+ .mocked(upstream.verifyAuthenticationResponse)
111
+ .mockRejectedValueOnce(new Error('Credential counter value for given response must be larger than 0'));
112
+ expect(await verifyAuthenticationResponse(mockOpts)).toFailWith(/credential counter value/i);
113
+ });
114
+ });
115
+ //# sourceMappingURL=webauthn.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthn.test.js","sourceRoot":"","sources":["../../../src/test/unit/webauthn.test.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAEpC,OAAO,oBAAoB,CAAC;AAC5B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAY3B,MAAM,aAAa,CAAC;AAErB,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,MAAM,QAAQ,GAAoC;QAChD,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,kBAAkB;QACxB,QAAQ,EAAE,eAAe;KAC1B,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;QACrE,MAAM,UAAU,GAAG,EAAE,SAAS,EAAE,QAAQ,EAA4C,CAAC;QACrF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,2BAA2B,CAAC,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QACpF,MAAM,CAAC,MAAM,2BAA2B,CAAC,QAAQ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,CAAC","sourcesContent":["jest.mock('@simplewebauthn/server');\n\nimport '@fgv/ts-utils-jest';\nimport * as upstream from '@simplewebauthn/server';\nimport {\n generateAuthenticationOptions,\n generateRegistrationOptions,\n verifyAuthenticationResponse,\n verifyRegistrationResponse,\n type AuthenticationResponseJSON,\n type GenerateAuthenticationOptionsOpts,\n type GenerateRegistrationOptionsOpts,\n type PublicKeyCredentialCreationOptionsJSON,\n type PublicKeyCredentialRequestOptionsJSON,\n type RegistrationResponseJSON,\n type VerifiedAuthenticationResponse,\n type VerifiedRegistrationResponse,\n type VerifyAuthenticationResponseOpts,\n type VerifyRegistrationResponseOpts,\n type WebAuthnCredential\n} from '../../index';\n\ndescribe('generateRegistrationOptions', () => {\n const mockOpts: GenerateRegistrationOptionsOpts = {\n rpName: 'Test RP',\n rpID: 'test.example.com',\n userName: 'user@test.com'\n };\n\n beforeEach(() => {\n jest.resetAllMocks();\n });\n\n test('returns Success wrapping upstream result on success', async () => {\n const mockResult = { challenge: 'abc123' } as PublicKeyCredentialCreationOptionsJSON;\n jest.mocked(upstream.generateRegistrationOptions).mockResolvedValueOnce(mockResult);\n expect(await generateRegistrationOptions(mockOpts)).toSucceedWith(mockResult);\n });\n\n test('returns Failure capturing upstream error message on throw', async () => {\n jest\n .mocked(upstream.generateRegistrationOptions)\n .mockRejectedValueOnce(new Error('Challenge is not in the correct format'));\n expect(await generateRegistrationOptions(mockOpts)).toFailWith(/challenge is not in the correct format/i);\n });\n});\n\ndescribe('verifyRegistrationResponse', () => {\n const mockOpts: VerifyRegistrationResponseOpts = {\n response: {\n id: 'cred-id',\n rawId: 'cred-raw-id',\n response: {\n clientDataJSON: 'client-data',\n attestationObject: 'attestation-object'\n },\n clientExtensionResults: {},\n type: 'public-key'\n } as RegistrationResponseJSON,\n expectedChallenge: 'challenge123',\n expectedOrigin: 'https://test.example.com',\n expectedRPID: 'test.example.com'\n };\n\n beforeEach(() => {\n jest.resetAllMocks();\n });\n\n test('returns Success wrapping upstream result on success', async () => {\n const mockResult = { verified: true } as VerifiedRegistrationResponse;\n jest.mocked(upstream.verifyRegistrationResponse).mockResolvedValueOnce(mockResult);\n expect(await verifyRegistrationResponse(mockOpts)).toSucceedWith(mockResult);\n });\n\n test('returns Failure capturing upstream error message on throw', async () => {\n jest\n .mocked(upstream.verifyRegistrationResponse)\n .mockRejectedValueOnce(new Error('The authenticator response contained invalid attestation'));\n expect(await verifyRegistrationResponse(mockOpts)).toFailWith(/invalid attestation/i);\n });\n});\n\ndescribe('generateAuthenticationOptions', () => {\n const mockOpts: GenerateAuthenticationOptionsOpts = {\n rpID: 'test.example.com'\n };\n\n beforeEach(() => {\n jest.resetAllMocks();\n });\n\n test('returns Success wrapping upstream result on success', async () => {\n const mockResult = { challenge: 'xyz789' } as PublicKeyCredentialRequestOptionsJSON;\n jest.mocked(upstream.generateAuthenticationOptions).mockResolvedValueOnce(mockResult);\n expect(await generateAuthenticationOptions(mockOpts)).toSucceedWith(mockResult);\n });\n\n test('returns Failure capturing upstream error message on throw', async () => {\n jest\n .mocked(upstream.generateAuthenticationOptions)\n .mockRejectedValueOnce(new Error('Unexpected authentication response type'));\n expect(await generateAuthenticationOptions(mockOpts)).toFailWith(\n /unexpected authentication response type/i\n );\n });\n});\n\ndescribe('verifyAuthenticationResponse', () => {\n const mockCredential: WebAuthnCredential = {\n id: 'cred-id',\n publicKey: new Uint8Array([1, 2, 3]),\n counter: 0,\n transports: ['usb']\n };\n\n const mockOpts: VerifyAuthenticationResponseOpts = {\n response: {\n id: 'cred-id',\n rawId: 'cred-raw-id',\n response: {\n clientDataJSON: 'client-data',\n authenticatorData: 'auth-data',\n signature: 'sig'\n },\n clientExtensionResults: {},\n type: 'public-key'\n } as AuthenticationResponseJSON,\n expectedChallenge: 'challenge123',\n expectedOrigin: 'https://test.example.com',\n expectedRPID: 'test.example.com',\n credential: mockCredential\n };\n\n beforeEach(() => {\n jest.resetAllMocks();\n });\n\n test('returns Success wrapping upstream result on success', async () => {\n const mockResult = { verified: true } as unknown as VerifiedAuthenticationResponse;\n jest.mocked(upstream.verifyAuthenticationResponse).mockResolvedValueOnce(mockResult);\n expect(await verifyAuthenticationResponse(mockOpts)).toSucceedWith(mockResult);\n });\n\n test('returns Failure capturing upstream error message on throw', async () => {\n jest\n .mocked(upstream.verifyAuthenticationResponse)\n .mockRejectedValueOnce(new Error('Credential counter value for given response must be larger than 0'));\n expect(await verifyAuthenticationResponse(mockOpts)).toFailWith(/credential counter value/i);\n });\n});\n"]}
@@ -0,0 +1,72 @@
1
+ import type { AuthenticationResponseJSON } from '@simplewebauthn/server';
2
+ import type { GenerateAuthenticationOptionsOpts } from '@simplewebauthn/server';
3
+ import type { GenerateRegistrationOptionsOpts } from '@simplewebauthn/server';
4
+ import type { PublicKeyCredentialCreationOptionsJSON as PublicKeyCredentialCreationOptionsJSON_2 } from '@simplewebauthn/server';
5
+ import type { PublicKeyCredentialRequestOptionsJSON as PublicKeyCredentialRequestOptionsJSON_2 } from '@simplewebauthn/server';
6
+ import type { RegistrationResponseJSON } from '@simplewebauthn/server';
7
+ import { Result } from '@fgv/ts-utils';
8
+ import type { VerifiedAuthenticationResponse } from '@simplewebauthn/server';
9
+ import type { VerifiedRegistrationResponse } from '@simplewebauthn/server';
10
+ import type { VerifyAuthenticationResponseOpts } from '@simplewebauthn/server';
11
+ import type { VerifyRegistrationResponseOpts } from '@simplewebauthn/server';
12
+ import type { WebAuthnCredential } from '@simplewebauthn/server';
13
+
14
+ export { AuthenticationResponseJSON }
15
+
16
+ /**
17
+ * Result-integration wrapper around `@simplewebauthn/server`'s `generateAuthenticationOptions`.
18
+ * Returns `Promise<Result<PublicKeyCredentialRequestOptionsJSON>>`; upstream errors are captured
19
+ * as `Failure` with the original message.
20
+ * @see https://simplewebauthn.dev/docs/packages/server
21
+ * @public
22
+ */
23
+ export declare function generateAuthenticationOptions(options: GenerateAuthenticationOptionsOpts): Promise<Result<PublicKeyCredentialRequestOptionsJSON_2>>;
24
+
25
+ export { GenerateAuthenticationOptionsOpts }
26
+
27
+ /**
28
+ * Result-integration wrapper around `@simplewebauthn/server`'s `generateRegistrationOptions`.
29
+ * Returns `Promise<Result<PublicKeyCredentialCreationOptionsJSON>>`; upstream errors are captured
30
+ * as `Failure` with the original message.
31
+ * @see https://simplewebauthn.dev/docs/packages/server
32
+ * @public
33
+ */
34
+ export declare function generateRegistrationOptions(options: GenerateRegistrationOptionsOpts): Promise<Result<PublicKeyCredentialCreationOptionsJSON_2>>;
35
+
36
+ export { GenerateRegistrationOptionsOpts }
37
+
38
+ export { PublicKeyCredentialCreationOptionsJSON_2 as PublicKeyCredentialCreationOptionsJSON }
39
+
40
+ export { PublicKeyCredentialRequestOptionsJSON_2 as PublicKeyCredentialRequestOptionsJSON }
41
+
42
+ export { RegistrationResponseJSON }
43
+
44
+ export { VerifiedAuthenticationResponse }
45
+
46
+ export { VerifiedRegistrationResponse }
47
+
48
+ /**
49
+ * Result-integration wrapper around `@simplewebauthn/server`'s `verifyAuthenticationResponse`.
50
+ * Returns `Promise<Result<VerifiedAuthenticationResponse>>`; upstream errors are captured
51
+ * as `Failure` with the original message.
52
+ * @see https://simplewebauthn.dev/docs/packages/server
53
+ * @public
54
+ */
55
+ export declare function verifyAuthenticationResponse(options: VerifyAuthenticationResponseOpts): Promise<Result<VerifiedAuthenticationResponse>>;
56
+
57
+ export { VerifyAuthenticationResponseOpts }
58
+
59
+ /**
60
+ * Result-integration wrapper around `@simplewebauthn/server`'s `verifyRegistrationResponse`.
61
+ * Returns `Promise<Result<VerifiedRegistrationResponse>>`; upstream errors are captured
62
+ * as `Failure` with the original message.
63
+ * @see https://simplewebauthn.dev/docs/packages/server
64
+ * @public
65
+ */
66
+ export declare function verifyRegistrationResponse(options: VerifyRegistrationResponseOpts): Promise<Result<VerifiedRegistrationResponse>>;
67
+
68
+ export { VerifyRegistrationResponseOpts }
69
+
70
+ export { WebAuthnCredential }
71
+
72
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.58.7"
9
+ }
10
+ ]
11
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ import type { GenerateRegistrationOptionsOpts, PublicKeyCredentialCreationOptionsJSON, VerifyRegistrationResponseOpts, VerifiedRegistrationResponse, GenerateAuthenticationOptionsOpts, PublicKeyCredentialRequestOptionsJSON, VerifyAuthenticationResponseOpts, VerifiedAuthenticationResponse, WebAuthnCredential, RegistrationResponseJSON, AuthenticationResponseJSON } from '@simplewebauthn/server';
2
+ import { type Result } from '@fgv/ts-utils';
3
+ export type { GenerateRegistrationOptionsOpts, PublicKeyCredentialCreationOptionsJSON, VerifyRegistrationResponseOpts, VerifiedRegistrationResponse, GenerateAuthenticationOptionsOpts, PublicKeyCredentialRequestOptionsJSON, VerifyAuthenticationResponseOpts, VerifiedAuthenticationResponse, WebAuthnCredential, RegistrationResponseJSON, AuthenticationResponseJSON };
4
+ /**
5
+ * Result-integration wrapper around `@simplewebauthn/server`'s `generateRegistrationOptions`.
6
+ * Returns `Promise<Result<PublicKeyCredentialCreationOptionsJSON>>`; upstream errors are captured
7
+ * as `Failure` with the original message.
8
+ * @see https://simplewebauthn.dev/docs/packages/server
9
+ * @public
10
+ */
11
+ export declare function generateRegistrationOptions(options: GenerateRegistrationOptionsOpts): Promise<Result<PublicKeyCredentialCreationOptionsJSON>>;
12
+ /**
13
+ * Result-integration wrapper around `@simplewebauthn/server`'s `verifyRegistrationResponse`.
14
+ * Returns `Promise<Result<VerifiedRegistrationResponse>>`; upstream errors are captured
15
+ * as `Failure` with the original message.
16
+ * @see https://simplewebauthn.dev/docs/packages/server
17
+ * @public
18
+ */
19
+ export declare function verifyRegistrationResponse(options: VerifyRegistrationResponseOpts): Promise<Result<VerifiedRegistrationResponse>>;
20
+ /**
21
+ * Result-integration wrapper around `@simplewebauthn/server`'s `generateAuthenticationOptions`.
22
+ * Returns `Promise<Result<PublicKeyCredentialRequestOptionsJSON>>`; upstream errors are captured
23
+ * as `Failure` with the original message.
24
+ * @see https://simplewebauthn.dev/docs/packages/server
25
+ * @public
26
+ */
27
+ export declare function generateAuthenticationOptions(options: GenerateAuthenticationOptionsOpts): Promise<Result<PublicKeyCredentialRequestOptionsJSON>>;
28
+ /**
29
+ * Result-integration wrapper around `@simplewebauthn/server`'s `verifyAuthenticationResponse`.
30
+ * Returns `Promise<Result<VerifiedAuthenticationResponse>>`; upstream errors are captured
31
+ * as `Failure` with the original message.
32
+ * @see https://simplewebauthn.dev/docs/packages/server
33
+ * @public
34
+ */
35
+ export declare function verifyAuthenticationResponse(options: VerifyAuthenticationResponseOpts): Promise<Result<VerifiedAuthenticationResponse>>;
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,+BAA+B,EAC/B,sCAAsC,EACtC,8BAA8B,EAC9B,4BAA4B,EAC5B,iCAAiC,EACjC,qCAAqC,EACrC,gCAAgC,EAChC,8BAA8B,EAC9B,kBAAkB,EAClB,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAsB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAEhE,YAAY,EACV,+BAA+B,EAC/B,sCAAsC,EACtC,8BAA8B,EAC9B,4BAA4B,EAC5B,iCAAiC,EACjC,qCAAqC,EACrC,gCAAgC,EAChC,8BAA8B,EAC9B,kBAAkB,EAClB,wBAAwB,EACxB,0BAA0B,EAC3B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,MAAM,CAAC,sCAAsC,CAAC,CAAC,CAEzD;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC,CAE/C;AAED;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,iCAAiC,GACzC,OAAO,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAExD;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,MAAM,CAAC,8BAA8B,CAAC,CAAC,CAEjD"}
package/lib/index.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateRegistrationOptions = generateRegistrationOptions;
4
+ exports.verifyRegistrationResponse = verifyRegistrationResponse;
5
+ exports.generateAuthenticationOptions = generateAuthenticationOptions;
6
+ exports.verifyAuthenticationResponse = verifyAuthenticationResponse;
7
+ const server_1 = require("@simplewebauthn/server");
8
+ const ts_utils_1 = require("@fgv/ts-utils");
9
+ /**
10
+ * Result-integration wrapper around `@simplewebauthn/server`'s `generateRegistrationOptions`.
11
+ * Returns `Promise<Result<PublicKeyCredentialCreationOptionsJSON>>`; upstream errors are captured
12
+ * as `Failure` with the original message.
13
+ * @see https://simplewebauthn.dev/docs/packages/server
14
+ * @public
15
+ */
16
+ async function generateRegistrationOptions(options) {
17
+ return (0, ts_utils_1.captureAsyncResult)(() => (0, server_1.generateRegistrationOptions)(options));
18
+ }
19
+ /**
20
+ * Result-integration wrapper around `@simplewebauthn/server`'s `verifyRegistrationResponse`.
21
+ * Returns `Promise<Result<VerifiedRegistrationResponse>>`; upstream errors are captured
22
+ * as `Failure` with the original message.
23
+ * @see https://simplewebauthn.dev/docs/packages/server
24
+ * @public
25
+ */
26
+ async function verifyRegistrationResponse(options) {
27
+ return (0, ts_utils_1.captureAsyncResult)(() => (0, server_1.verifyRegistrationResponse)(options));
28
+ }
29
+ /**
30
+ * Result-integration wrapper around `@simplewebauthn/server`'s `generateAuthenticationOptions`.
31
+ * Returns `Promise<Result<PublicKeyCredentialRequestOptionsJSON>>`; upstream errors are captured
32
+ * as `Failure` with the original message.
33
+ * @see https://simplewebauthn.dev/docs/packages/server
34
+ * @public
35
+ */
36
+ async function generateAuthenticationOptions(options) {
37
+ return (0, ts_utils_1.captureAsyncResult)(() => (0, server_1.generateAuthenticationOptions)(options));
38
+ }
39
+ /**
40
+ * Result-integration wrapper around `@simplewebauthn/server`'s `verifyAuthenticationResponse`.
41
+ * Returns `Promise<Result<VerifiedAuthenticationResponse>>`; upstream errors are captured
42
+ * as `Failure` with the original message.
43
+ * @see https://simplewebauthn.dev/docs/packages/server
44
+ * @public
45
+ */
46
+ async function verifyAuthenticationResponse(options) {
47
+ return (0, ts_utils_1.captureAsyncResult)(() => (0, server_1.verifyAuthenticationResponse)(options));
48
+ }
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AA0CA,kEAIC;AASD,gEAIC;AASD,sEAIC;AASD,oEAIC;AArFD,mDAKgC;AAchC,4CAAgE;AAgBhE;;;;;;GAMG;AACI,KAAK,UAAU,2BAA2B,CAC/C,OAAwC;IAExC,OAAO,IAAA,6BAAkB,EAAC,GAAG,EAAE,CAAC,IAAA,oCAA4B,EAAC,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,0BAA0B,CAC9C,OAAuC;IAEvC,OAAO,IAAA,6BAAkB,EAAC,GAAG,EAAE,CAAC,IAAA,mCAA2B,EAAC,OAAO,CAAC,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,6BAA6B,CACjD,OAA0C;IAE1C,OAAO,IAAA,6BAAkB,EAAC,GAAG,EAAE,CAAC,IAAA,sCAA8B,EAAC,OAAO,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,4BAA4B,CAChD,OAAyC;IAEzC,OAAO,IAAA,6BAAkB,EAAC,GAAG,EAAE,CAAC,IAAA,qCAA6B,EAAC,OAAO,CAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import {\n generateRegistrationOptions as _generateRegistrationOptions,\n verifyRegistrationResponse as _verifyRegistrationResponse,\n generateAuthenticationOptions as _generateAuthenticationOptions,\n verifyAuthenticationResponse as _verifyAuthenticationResponse\n} from '@simplewebauthn/server';\nimport type {\n GenerateRegistrationOptionsOpts,\n PublicKeyCredentialCreationOptionsJSON,\n VerifyRegistrationResponseOpts,\n VerifiedRegistrationResponse,\n GenerateAuthenticationOptionsOpts,\n PublicKeyCredentialRequestOptionsJSON,\n VerifyAuthenticationResponseOpts,\n VerifiedAuthenticationResponse,\n WebAuthnCredential,\n RegistrationResponseJSON,\n AuthenticationResponseJSON\n} from '@simplewebauthn/server';\nimport { captureAsyncResult, type Result } from '@fgv/ts-utils';\n\nexport type {\n GenerateRegistrationOptionsOpts,\n PublicKeyCredentialCreationOptionsJSON,\n VerifyRegistrationResponseOpts,\n VerifiedRegistrationResponse,\n GenerateAuthenticationOptionsOpts,\n PublicKeyCredentialRequestOptionsJSON,\n VerifyAuthenticationResponseOpts,\n VerifiedAuthenticationResponse,\n WebAuthnCredential,\n RegistrationResponseJSON,\n AuthenticationResponseJSON\n};\n\n/**\n * Result-integration wrapper around `@simplewebauthn/server`'s `generateRegistrationOptions`.\n * Returns `Promise<Result<PublicKeyCredentialCreationOptionsJSON>>`; upstream errors are captured\n * as `Failure` with the original message.\n * @see https://simplewebauthn.dev/docs/packages/server\n * @public\n */\nexport async function generateRegistrationOptions(\n options: GenerateRegistrationOptionsOpts\n): Promise<Result<PublicKeyCredentialCreationOptionsJSON>> {\n return captureAsyncResult(() => _generateRegistrationOptions(options));\n}\n\n/**\n * Result-integration wrapper around `@simplewebauthn/server`'s `verifyRegistrationResponse`.\n * Returns `Promise<Result<VerifiedRegistrationResponse>>`; upstream errors are captured\n * as `Failure` with the original message.\n * @see https://simplewebauthn.dev/docs/packages/server\n * @public\n */\nexport async function verifyRegistrationResponse(\n options: VerifyRegistrationResponseOpts\n): Promise<Result<VerifiedRegistrationResponse>> {\n return captureAsyncResult(() => _verifyRegistrationResponse(options));\n}\n\n/**\n * Result-integration wrapper around `@simplewebauthn/server`'s `generateAuthenticationOptions`.\n * Returns `Promise<Result<PublicKeyCredentialRequestOptionsJSON>>`; upstream errors are captured\n * as `Failure` with the original message.\n * @see https://simplewebauthn.dev/docs/packages/server\n * @public\n */\nexport async function generateAuthenticationOptions(\n options: GenerateAuthenticationOptionsOpts\n): Promise<Result<PublicKeyCredentialRequestOptionsJSON>> {\n return captureAsyncResult(() => _generateAuthenticationOptions(options));\n}\n\n/**\n * Result-integration wrapper around `@simplewebauthn/server`'s `verifyAuthenticationResponse`.\n * Returns `Promise<Result<VerifiedAuthenticationResponse>>`; upstream errors are captured\n * as `Failure` with the original message.\n * @see https://simplewebauthn.dev/docs/packages/server\n * @public\n */\nexport async function verifyAuthenticationResponse(\n options: VerifyAuthenticationResponseOpts\n): Promise<Result<VerifiedAuthenticationResponse>> {\n return captureAsyncResult(() => _verifyAuthenticationResponse(options));\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import '@fgv/ts-utils-jest';
2
+ //# sourceMappingURL=webauthn.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthn.test.d.ts","sourceRoot":"","sources":["../../../src/test/unit/webauthn.test.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,CAAC"}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ jest.mock('@simplewebauthn/server');
37
+ require("@fgv/ts-utils-jest");
38
+ const upstream = __importStar(require("@simplewebauthn/server"));
39
+ const index_1 = require("../../index");
40
+ describe('generateRegistrationOptions', () => {
41
+ const mockOpts = {
42
+ rpName: 'Test RP',
43
+ rpID: 'test.example.com',
44
+ userName: 'user@test.com'
45
+ };
46
+ beforeEach(() => {
47
+ jest.resetAllMocks();
48
+ });
49
+ test('returns Success wrapping upstream result on success', async () => {
50
+ const mockResult = { challenge: 'abc123' };
51
+ jest.mocked(upstream.generateRegistrationOptions).mockResolvedValueOnce(mockResult);
52
+ expect(await (0, index_1.generateRegistrationOptions)(mockOpts)).toSucceedWith(mockResult);
53
+ });
54
+ test('returns Failure capturing upstream error message on throw', async () => {
55
+ jest
56
+ .mocked(upstream.generateRegistrationOptions)
57
+ .mockRejectedValueOnce(new Error('Challenge is not in the correct format'));
58
+ expect(await (0, index_1.generateRegistrationOptions)(mockOpts)).toFailWith(/challenge is not in the correct format/i);
59
+ });
60
+ });
61
+ describe('verifyRegistrationResponse', () => {
62
+ const mockOpts = {
63
+ response: {
64
+ id: 'cred-id',
65
+ rawId: 'cred-raw-id',
66
+ response: {
67
+ clientDataJSON: 'client-data',
68
+ attestationObject: 'attestation-object'
69
+ },
70
+ clientExtensionResults: {},
71
+ type: 'public-key'
72
+ },
73
+ expectedChallenge: 'challenge123',
74
+ expectedOrigin: 'https://test.example.com',
75
+ expectedRPID: 'test.example.com'
76
+ };
77
+ beforeEach(() => {
78
+ jest.resetAllMocks();
79
+ });
80
+ test('returns Success wrapping upstream result on success', async () => {
81
+ const mockResult = { verified: true };
82
+ jest.mocked(upstream.verifyRegistrationResponse).mockResolvedValueOnce(mockResult);
83
+ expect(await (0, index_1.verifyRegistrationResponse)(mockOpts)).toSucceedWith(mockResult);
84
+ });
85
+ test('returns Failure capturing upstream error message on throw', async () => {
86
+ jest
87
+ .mocked(upstream.verifyRegistrationResponse)
88
+ .mockRejectedValueOnce(new Error('The authenticator response contained invalid attestation'));
89
+ expect(await (0, index_1.verifyRegistrationResponse)(mockOpts)).toFailWith(/invalid attestation/i);
90
+ });
91
+ });
92
+ describe('generateAuthenticationOptions', () => {
93
+ const mockOpts = {
94
+ rpID: 'test.example.com'
95
+ };
96
+ beforeEach(() => {
97
+ jest.resetAllMocks();
98
+ });
99
+ test('returns Success wrapping upstream result on success', async () => {
100
+ const mockResult = { challenge: 'xyz789' };
101
+ jest.mocked(upstream.generateAuthenticationOptions).mockResolvedValueOnce(mockResult);
102
+ expect(await (0, index_1.generateAuthenticationOptions)(mockOpts)).toSucceedWith(mockResult);
103
+ });
104
+ test('returns Failure capturing upstream error message on throw', async () => {
105
+ jest
106
+ .mocked(upstream.generateAuthenticationOptions)
107
+ .mockRejectedValueOnce(new Error('Unexpected authentication response type'));
108
+ expect(await (0, index_1.generateAuthenticationOptions)(mockOpts)).toFailWith(/unexpected authentication response type/i);
109
+ });
110
+ });
111
+ describe('verifyAuthenticationResponse', () => {
112
+ const mockCredential = {
113
+ id: 'cred-id',
114
+ publicKey: new Uint8Array([1, 2, 3]),
115
+ counter: 0,
116
+ transports: ['usb']
117
+ };
118
+ const mockOpts = {
119
+ response: {
120
+ id: 'cred-id',
121
+ rawId: 'cred-raw-id',
122
+ response: {
123
+ clientDataJSON: 'client-data',
124
+ authenticatorData: 'auth-data',
125
+ signature: 'sig'
126
+ },
127
+ clientExtensionResults: {},
128
+ type: 'public-key'
129
+ },
130
+ expectedChallenge: 'challenge123',
131
+ expectedOrigin: 'https://test.example.com',
132
+ expectedRPID: 'test.example.com',
133
+ credential: mockCredential
134
+ };
135
+ beforeEach(() => {
136
+ jest.resetAllMocks();
137
+ });
138
+ test('returns Success wrapping upstream result on success', async () => {
139
+ const mockResult = { verified: true };
140
+ jest.mocked(upstream.verifyAuthenticationResponse).mockResolvedValueOnce(mockResult);
141
+ expect(await (0, index_1.verifyAuthenticationResponse)(mockOpts)).toSucceedWith(mockResult);
142
+ });
143
+ test('returns Failure capturing upstream error message on throw', async () => {
144
+ jest
145
+ .mocked(upstream.verifyAuthenticationResponse)
146
+ .mockRejectedValueOnce(new Error('Credential counter value for given response must be larger than 0'));
147
+ expect(await (0, index_1.verifyAuthenticationResponse)(mockOpts)).toFailWith(/credential counter value/i);
148
+ });
149
+ });
150
+ //# sourceMappingURL=webauthn.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthn.test.js","sourceRoot":"","sources":["../../../src/test/unit/webauthn.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAEpC,8BAA4B;AAC5B,iEAAmD;AACnD,uCAgBqB;AAErB,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,MAAM,QAAQ,GAAoC;QAChD,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,kBAAkB;QAC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AC,MAAM,IAAA,oCAA4B,EAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QAC3E,IAAI;aACD,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAC;aAC7C,qBAAqB,CAAC,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC,CAAC;QACzG,MAAM,CAAC,MAAM,IAAA,oCAA4B,EAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["jest.mock('@simplewebauthn/server');\n\nimport '@fgv/ts-utils-jest';\nimport * as upstream from '@simplewebauthn/server';\nimport {\n generateAuthenticationOptions,\n generateRegistrationOptions,\n verifyAuthenticationResponse,\n verifyRegistrationResponse,\n type AuthenticationResponseJSON,\n type GenerateAuthenticationOptionsOpts,\n type GenerateRegistrationOptionsOpts,\n type PublicKeyCredentialCreationOptionsJSON,\n type PublicKeyCredentialRequestOptionsJSON,\n type RegistrationResponseJSON,\n type VerifiedAuthenticationResponse,\n type VerifiedRegistrationResponse,\n type VerifyAuthenticationResponseOpts,\n type VerifyRegistrationResponseOpts,\n type WebAuthnCredential\n} from '../../index';\n\ndescribe('generateRegistrationOptions', () => {\n const mockOpts: GenerateRegistrationOptionsOpts = {\n rpName: 'Test RP',\n rpID: 'test.example.com',\n userName: 'user@test.com'\n };\n\n beforeEach(() => {\n jest.resetAllMocks();\n });\n\n test('returns Success wrapping upstream result on success', async () => {\n const mockResult = { challenge: 'abc123' } as PublicKeyCredentialCreationOptionsJSON;\n jest.mocked(upstream.generateRegistrationOptions).mockResolvedValueOnce(mockResult);\n expect(await generateRegistrationOptions(mockOpts)).toSucceedWith(mockResult);\n });\n\n test('returns Failure capturing upstream error message on throw', async () => {\n jest\n .mocked(upstream.generateRegistrationOptions)\n .mockRejectedValueOnce(new Error('Challenge is not in the correct format'));\n expect(await generateRegistrationOptions(mockOpts)).toFailWith(/challenge is not in the correct format/i);\n });\n});\n\ndescribe('verifyRegistrationResponse', () => {\n const mockOpts: VerifyRegistrationResponseOpts = {\n response: {\n id: 'cred-id',\n rawId: 'cred-raw-id',\n response: {\n clientDataJSON: 'client-data',\n attestationObject: 'attestation-object'\n },\n clientExtensionResults: {},\n type: 'public-key'\n } as RegistrationResponseJSON,\n expectedChallenge: 'challenge123',\n expectedOrigin: 'https://test.example.com',\n expectedRPID: 'test.example.com'\n };\n\n beforeEach(() => {\n jest.resetAllMocks();\n });\n\n test('returns Success wrapping upstream result on success', async () => {\n const mockResult = { verified: true } as VerifiedRegistrationResponse;\n jest.mocked(upstream.verifyRegistrationResponse).mockResolvedValueOnce(mockResult);\n expect(await verifyRegistrationResponse(mockOpts)).toSucceedWith(mockResult);\n });\n\n test('returns Failure capturing upstream error message on throw', async () => {\n jest\n .mocked(upstream.verifyRegistrationResponse)\n .mockRejectedValueOnce(new Error('The authenticator response contained invalid attestation'));\n expect(await verifyRegistrationResponse(mockOpts)).toFailWith(/invalid attestation/i);\n });\n});\n\ndescribe('generateAuthenticationOptions', () => {\n const mockOpts: GenerateAuthenticationOptionsOpts = {\n rpID: 'test.example.com'\n };\n\n beforeEach(() => {\n jest.resetAllMocks();\n });\n\n test('returns Success wrapping upstream result on success', async () => {\n const mockResult = { challenge: 'xyz789' } as PublicKeyCredentialRequestOptionsJSON;\n jest.mocked(upstream.generateAuthenticationOptions).mockResolvedValueOnce(mockResult);\n expect(await generateAuthenticationOptions(mockOpts)).toSucceedWith(mockResult);\n });\n\n test('returns Failure capturing upstream error message on throw', async () => {\n jest\n .mocked(upstream.generateAuthenticationOptions)\n .mockRejectedValueOnce(new Error('Unexpected authentication response type'));\n expect(await generateAuthenticationOptions(mockOpts)).toFailWith(\n /unexpected authentication response type/i\n );\n });\n});\n\ndescribe('verifyAuthenticationResponse', () => {\n const mockCredential: WebAuthnCredential = {\n id: 'cred-id',\n publicKey: new Uint8Array([1, 2, 3]),\n counter: 0,\n transports: ['usb']\n };\n\n const mockOpts: VerifyAuthenticationResponseOpts = {\n response: {\n id: 'cred-id',\n rawId: 'cred-raw-id',\n response: {\n clientDataJSON: 'client-data',\n authenticatorData: 'auth-data',\n signature: 'sig'\n },\n clientExtensionResults: {},\n type: 'public-key'\n } as AuthenticationResponseJSON,\n expectedChallenge: 'challenge123',\n expectedOrigin: 'https://test.example.com',\n expectedRPID: 'test.example.com',\n credential: mockCredential\n };\n\n beforeEach(() => {\n jest.resetAllMocks();\n });\n\n test('returns Success wrapping upstream result on success', async () => {\n const mockResult = { verified: true } as unknown as VerifiedAuthenticationResponse;\n jest.mocked(upstream.verifyAuthenticationResponse).mockResolvedValueOnce(mockResult);\n expect(await verifyAuthenticationResponse(mockOpts)).toSucceedWith(mockResult);\n });\n\n test('returns Failure capturing upstream error message on throw', async () => {\n jest\n .mocked(upstream.verifyAuthenticationResponse)\n .mockRejectedValueOnce(new Error('Credential counter value for given response must be larger than 0'));\n expect(await verifyAuthenticationResponse(mockOpts)).toFailWith(/credential counter value/i);\n });\n});\n"]}