diff options
author | Matthew Miller <matthew@millerti.me> | 2022-04-27 22:15:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-27 22:15:50 -0700 |
commit | 76383fddef93d4ce4e9f9f7b4b8c3ce4cb685f79 (patch) | |
tree | f4d88f5208689e752b699ddaf19526eae40e9e24 /packages/browser/src/methods/startRegistration.test.ts | |
parent | db2d9b2ab4df4c00566951107657a211cef74c90 (diff) | |
parent | 02396a1789fbcae2145e607d8f808f6268a759a2 (diff) |
Merge pull request #198 from MasterKale/feat/cable-take-2
feat/cable-take-2
Diffstat (limited to 'packages/browser/src/methods/startRegistration.test.ts')
-rw-r--r-- | packages/browser/src/methods/startRegistration.test.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/browser/src/methods/startRegistration.test.ts b/packages/browser/src/methods/startRegistration.test.ts index 360884e..fcd4a2c 100644 --- a/packages/browser/src/methods/startRegistration.test.ts +++ b/packages/browser/src/methods/startRegistration.test.ts @@ -176,6 +176,41 @@ test('should include extension results when no extensions specified', async () = expect(response.clientExtensionResults).toEqual({}); }); +test('should support "cable" transport in excludeCredentials', async () => { + const opts: PublicKeyCredentialCreationOptionsJSON = { + ...goodOpts1, + excludeCredentials: [ + { + ...goodOpts1.excludeCredentials![0], + transports: ["cable"], + }, + ] + }; + + await startRegistration(opts); + + expect(mockNavigatorCreate.mock.calls[0][0].publicKey.excludeCredentials[0].transports[0]) + .toEqual("cable"); +}); + +test('should return "cable" transport from response', async () => { + mockNavigatorCreate.mockResolvedValue({ + id: 'foobar', + rawId: utf8StringToBuffer('foobar'), + response: { + attestationObject: Buffer.from(mockAttestationObject, 'ascii'), + clientDataJSON: Buffer.from(mockClientDataJSON, 'ascii'), + getTransports: () => (["cable"]), + }, + getClientExtensionResults: () => ({}), + type: 'webauthn.create', + }); + + const response = await startRegistration(goodOpts1); + + expect(response.transports).toEqual(["cable"]); +}); + describe('WebAuthnError', () => { describe('AbortError', () => { const AbortError = generateCustomError('AbortError'); |