@fgv/ts-extras-webauthn 5.1.0-47 → 5.1.0-49
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/LICENSE +21 -0
- package/package.json +15 -5
- package/.rush/temp/57dde6ce15c75613fcbe248ad019bbbcafdaf01d.tar.log +0 -30
- package/.rush/temp/chunked-rush-logs/ts-extras-webauthn.build.chunks.jsonl +0 -9
- package/.rush/temp/operation/build/all.log +0 -9
- package/.rush/temp/operation/build/log-chunks.jsonl +0 -9
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/shrinkwrap-deps.json +0 -703
- package/config/api-extractor.json +0 -38
- package/config/jest.config.json +0 -13
- package/config/rig.json +0 -10
- package/dist/test/unit/webauthn.test.js +0 -115
- package/dist/test/unit/webauthn.test.js.map +0 -1
- package/eslint.config.js +0 -16
- package/etc/ts-extras-webauthn.api.md +0 -56
- package/lib/test/unit/webauthn.test.d.ts +0 -2
- package/lib/test/unit/webauthn.test.d.ts.map +0 -1
- package/lib/test/unit/webauthn.test.js +0 -150
- package/lib/test/unit/webauthn.test.js.map +0 -1
- package/rush-logs/ts-extras-webauthn.build.cache.log +0 -3
- package/rush-logs/ts-extras-webauthn.build.log +0 -9
- package/src/index.ts +0 -86
- package/src/test/unit/webauthn.test.ts +0 -150
- package/temp/build/lint/_eslint-5eVG3S6w.json +0 -14
- package/temp/build/typescript/ts_8nwakTlr.json +0 -1
- package/temp/ts-extras-webauthn.api.json +0 -470
- package/temp/ts-extras-webauthn.api.md +0 -56
- package/tsconfig.json +0 -7
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"projectFolder": "..",
|
|
4
|
-
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
|
|
5
|
-
"bundledPackages": [],
|
|
6
|
-
"compiler": {},
|
|
7
|
-
"apiReport": {
|
|
8
|
-
"enabled": true
|
|
9
|
-
},
|
|
10
|
-
"docModel": {
|
|
11
|
-
"enabled": true
|
|
12
|
-
},
|
|
13
|
-
"dtsRollup": {
|
|
14
|
-
"enabled": true
|
|
15
|
-
},
|
|
16
|
-
"tsdocMetadata": {},
|
|
17
|
-
"messages": {
|
|
18
|
-
"compilerMessageReporting": {
|
|
19
|
-
"default": {
|
|
20
|
-
"logLevel": "warning"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"extractorMessageReporting": {
|
|
24
|
-
"default": {
|
|
25
|
-
"logLevel": "warning"
|
|
26
|
-
},
|
|
27
|
-
"ae-unresolved-link": {
|
|
28
|
-
"logLevel": "none",
|
|
29
|
-
"addToApiReportFile": true
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"tsdocMessageReporting": {
|
|
33
|
-
"default": {
|
|
34
|
-
"logLevel": "warning"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
package/config/jest.config.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@fgv/heft-dual-rig/profiles/default/config/jest.config.json",
|
|
3
|
-
"coverageThreshold": {
|
|
4
|
-
"global": {
|
|
5
|
-
"branches": 100,
|
|
6
|
-
"functions": 100,
|
|
7
|
-
"lines": 100,
|
|
8
|
-
"statements": 100
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"collectCoverage": true,
|
|
12
|
-
"coverageReporters": ["text", "lcov", "html"]
|
|
13
|
-
}
|
package/config/rig.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// The "rig.json" file directs tools to look for their config files in an external package.
|
|
2
|
-
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
|
3
|
-
{
|
|
4
|
-
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
|
5
|
-
/**
|
|
6
|
-
* (Required) The name of the rig package to inherit from.
|
|
7
|
-
* It should be an NPM package name with the "-rig" suffix.
|
|
8
|
-
*/
|
|
9
|
-
"rigPackageName": "@fgv/heft-dual-rig"
|
|
10
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webauthn.test.js","sourceRoot":"","sources":["../../../src/test/unit/web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EAAE,cAAc;KAC3B,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,QAAQ,EAAE,IAAI,EAA+C,CAAC;QACnF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QACrF,MAAM,CAAC,MAAM,4BAA4B,CAAC,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,4BAA4B,CAAC,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"]}
|
package/eslint.config.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// ESLint 9 flat config
|
|
2
|
-
const nodeProfile = require('@rushstack/eslint-config/flat/profile/node');
|
|
3
|
-
const packletsPlugin = require('@rushstack/eslint-config/flat/mixins/packlets');
|
|
4
|
-
const tsdocPlugin = require('@rushstack/eslint-config/flat/mixins/tsdoc');
|
|
5
|
-
|
|
6
|
-
module.exports = [
|
|
7
|
-
...nodeProfile,
|
|
8
|
-
packletsPlugin,
|
|
9
|
-
...tsdocPlugin,
|
|
10
|
-
{
|
|
11
|
-
// Override specific rules if needed
|
|
12
|
-
rules: {
|
|
13
|
-
'@rushstack/packlets/mechanics': 'warn'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
];
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
## API Report File for "@fgv/ts-extras-webauthn"
|
|
2
|
-
|
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
|
|
7
|
-
import type { AuthenticationResponseJSON } from '@simplewebauthn/server';
|
|
8
|
-
import type { GenerateAuthenticationOptionsOpts } from '@simplewebauthn/server';
|
|
9
|
-
import type { GenerateRegistrationOptionsOpts } from '@simplewebauthn/server';
|
|
10
|
-
import type { PublicKeyCredentialCreationOptionsJSON as PublicKeyCredentialCreationOptionsJSON_2 } from '@simplewebauthn/server';
|
|
11
|
-
import type { PublicKeyCredentialRequestOptionsJSON as PublicKeyCredentialRequestOptionsJSON_2 } from '@simplewebauthn/server';
|
|
12
|
-
import type { RegistrationResponseJSON } from '@simplewebauthn/server';
|
|
13
|
-
import { Result } from '@fgv/ts-utils';
|
|
14
|
-
import type { VerifiedAuthenticationResponse } from '@simplewebauthn/server';
|
|
15
|
-
import type { VerifiedRegistrationResponse } from '@simplewebauthn/server';
|
|
16
|
-
import type { VerifyAuthenticationResponseOpts } from '@simplewebauthn/server';
|
|
17
|
-
import type { VerifyRegistrationResponseOpts } from '@simplewebauthn/server';
|
|
18
|
-
import type { WebAuthnCredential } from '@simplewebauthn/server';
|
|
19
|
-
|
|
20
|
-
export { AuthenticationResponseJSON }
|
|
21
|
-
|
|
22
|
-
// @public
|
|
23
|
-
export function generateAuthenticationOptions(options: GenerateAuthenticationOptionsOpts): Promise<Result<PublicKeyCredentialRequestOptionsJSON_2>>;
|
|
24
|
-
|
|
25
|
-
export { GenerateAuthenticationOptionsOpts }
|
|
26
|
-
|
|
27
|
-
// @public
|
|
28
|
-
export function generateRegistrationOptions(options: GenerateRegistrationOptionsOpts): Promise<Result<PublicKeyCredentialCreationOptionsJSON_2>>;
|
|
29
|
-
|
|
30
|
-
export { GenerateRegistrationOptionsOpts }
|
|
31
|
-
|
|
32
|
-
export { PublicKeyCredentialCreationOptionsJSON_2 as PublicKeyCredentialCreationOptionsJSON }
|
|
33
|
-
|
|
34
|
-
export { PublicKeyCredentialRequestOptionsJSON_2 as PublicKeyCredentialRequestOptionsJSON }
|
|
35
|
-
|
|
36
|
-
export { RegistrationResponseJSON }
|
|
37
|
-
|
|
38
|
-
export { VerifiedAuthenticationResponse }
|
|
39
|
-
|
|
40
|
-
export { VerifiedRegistrationResponse }
|
|
41
|
-
|
|
42
|
-
// @public
|
|
43
|
-
export function verifyAuthenticationResponse(options: VerifyAuthenticationResponseOpts): Promise<Result<VerifiedAuthenticationResponse>>;
|
|
44
|
-
|
|
45
|
-
export { VerifyAuthenticationResponseOpts }
|
|
46
|
-
|
|
47
|
-
// @public
|
|
48
|
-
export function verifyRegistrationResponse(options: VerifyRegistrationResponseOpts): Promise<Result<VerifiedRegistrationResponse>>;
|
|
49
|
-
|
|
50
|
-
export { VerifyRegistrationResponseOpts }
|
|
51
|
-
|
|
52
|
-
export { WebAuthnCredential }
|
|
53
|
-
|
|
54
|
-
// (No @packageDocumentation comment for this package)
|
|
55
|
-
|
|
56
|
-
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webauthn.test.d.ts","sourceRoot":"","sources":["../../../src/test/unit/webauthn.test.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,CAAC"}
|
|
@@ -1,150 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;QACj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AAC,CAAC;QACrF,MAAM,CAAC,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"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
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.5
|
|
6
|
-
[build:api-extractor] Using API Extractor version 7.58.9
|
|
7
|
-
[build:api-extractor] Analysis will use the bundled TypeScript version 5.9.3
|
|
8
|
-
---- build finished (12.908s) ----
|
|
9
|
-
-------------------- Finished (12.914s) --------------------
|
package/src/index.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
generateRegistrationOptions as _generateRegistrationOptions,
|
|
3
|
-
verifyRegistrationResponse as _verifyRegistrationResponse,
|
|
4
|
-
generateAuthenticationOptions as _generateAuthenticationOptions,
|
|
5
|
-
verifyAuthenticationResponse as _verifyAuthenticationResponse
|
|
6
|
-
} from '@simplewebauthn/server';
|
|
7
|
-
import type {
|
|
8
|
-
GenerateRegistrationOptionsOpts,
|
|
9
|
-
PublicKeyCredentialCreationOptionsJSON,
|
|
10
|
-
VerifyRegistrationResponseOpts,
|
|
11
|
-
VerifiedRegistrationResponse,
|
|
12
|
-
GenerateAuthenticationOptionsOpts,
|
|
13
|
-
PublicKeyCredentialRequestOptionsJSON,
|
|
14
|
-
VerifyAuthenticationResponseOpts,
|
|
15
|
-
VerifiedAuthenticationResponse,
|
|
16
|
-
WebAuthnCredential,
|
|
17
|
-
RegistrationResponseJSON,
|
|
18
|
-
AuthenticationResponseJSON
|
|
19
|
-
} from '@simplewebauthn/server';
|
|
20
|
-
import { captureAsyncResult, type Result } from '@fgv/ts-utils';
|
|
21
|
-
|
|
22
|
-
export type {
|
|
23
|
-
GenerateRegistrationOptionsOpts,
|
|
24
|
-
PublicKeyCredentialCreationOptionsJSON,
|
|
25
|
-
VerifyRegistrationResponseOpts,
|
|
26
|
-
VerifiedRegistrationResponse,
|
|
27
|
-
GenerateAuthenticationOptionsOpts,
|
|
28
|
-
PublicKeyCredentialRequestOptionsJSON,
|
|
29
|
-
VerifyAuthenticationResponseOpts,
|
|
30
|
-
VerifiedAuthenticationResponse,
|
|
31
|
-
WebAuthnCredential,
|
|
32
|
-
RegistrationResponseJSON,
|
|
33
|
-
AuthenticationResponseJSON
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Result-integration wrapper around `@simplewebauthn/server`'s `generateRegistrationOptions`.
|
|
38
|
-
* Returns `Promise<Result<PublicKeyCredentialCreationOptionsJSON>>`; upstream errors are captured
|
|
39
|
-
* as `Failure` with the original message.
|
|
40
|
-
* @see https://simplewebauthn.dev/docs/packages/server
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export async function generateRegistrationOptions(
|
|
44
|
-
options: GenerateRegistrationOptionsOpts
|
|
45
|
-
): Promise<Result<PublicKeyCredentialCreationOptionsJSON>> {
|
|
46
|
-
return captureAsyncResult(() => _generateRegistrationOptions(options));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Result-integration wrapper around `@simplewebauthn/server`'s `verifyRegistrationResponse`.
|
|
51
|
-
* Returns `Promise<Result<VerifiedRegistrationResponse>>`; upstream errors are captured
|
|
52
|
-
* as `Failure` with the original message.
|
|
53
|
-
* @see https://simplewebauthn.dev/docs/packages/server
|
|
54
|
-
* @public
|
|
55
|
-
*/
|
|
56
|
-
export async function verifyRegistrationResponse(
|
|
57
|
-
options: VerifyRegistrationResponseOpts
|
|
58
|
-
): Promise<Result<VerifiedRegistrationResponse>> {
|
|
59
|
-
return captureAsyncResult(() => _verifyRegistrationResponse(options));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Result-integration wrapper around `@simplewebauthn/server`'s `generateAuthenticationOptions`.
|
|
64
|
-
* Returns `Promise<Result<PublicKeyCredentialRequestOptionsJSON>>`; upstream errors are captured
|
|
65
|
-
* as `Failure` with the original message.
|
|
66
|
-
* @see https://simplewebauthn.dev/docs/packages/server
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
export async function generateAuthenticationOptions(
|
|
70
|
-
options: GenerateAuthenticationOptionsOpts
|
|
71
|
-
): Promise<Result<PublicKeyCredentialRequestOptionsJSON>> {
|
|
72
|
-
return captureAsyncResult(() => _generateAuthenticationOptions(options));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Result-integration wrapper around `@simplewebauthn/server`'s `verifyAuthenticationResponse`.
|
|
77
|
-
* Returns `Promise<Result<VerifiedAuthenticationResponse>>`; upstream errors are captured
|
|
78
|
-
* as `Failure` with the original message.
|
|
79
|
-
* @see https://simplewebauthn.dev/docs/packages/server
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
export async function verifyAuthenticationResponse(
|
|
83
|
-
options: VerifyAuthenticationResponseOpts
|
|
84
|
-
): Promise<Result<VerifiedAuthenticationResponse>> {
|
|
85
|
-
return captureAsyncResult(() => _verifyAuthenticationResponse(options));
|
|
86
|
-
}
|