summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--package.json4
-rw-r--r--packages/browser/src/methods/startAssertion.test.ts47
2 files changed, 31 insertions, 20 deletions
diff --git a/package.json b/package.json
index c3618f1..cb57499 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,9 @@
"test": "lerna run test",
"build:types": "lerna bootstrap --scope=@simplewebauthn/typescript-types",
"build:browser": "lerna bootstrap --scope=@simplewebauthn/browser",
- "build:server": "lerna bootstrap --scope=@simplewebauthn/server"
+ "build:server": "lerna bootstrap --scope=@simplewebauthn/server",
+ "dev:server": "lerna exec npm run test:watch --scope=@simplewebauthn/server",
+ "dev:browser": "lerna exec npm run test:watch --scope=@simplewebauthn/browser"
},
"devDependencies": {
"@simplewebauthn/typescript-types": "^0.10.0",
diff --git a/packages/browser/src/methods/startAssertion.test.ts b/packages/browser/src/methods/startAssertion.test.ts
index 0a8a16f..c74b88f 100644
--- a/packages/browser/src/methods/startAssertion.test.ts
+++ b/packages/browser/src/methods/startAssertion.test.ts
@@ -39,18 +39,6 @@ const goodOpts2UTF8: PublicKeyCredentialRequestOptionsJSON = {
timeout: 1,
};
-// Without allow credentials
-const goodOpts3: PublicKeyCredentialRequestOptionsJSON = {
- challenge: bufferToBase64URLString(toUint8Array('fizz')),
- timeout: 1,
-};
-
-const goodOpts4: PublicKeyCredentialRequestOptionsJSON = {
- challenge: bufferToBase64URLString(toUint8Array('fizz')),
- timeout: 1,
- allowCredentials: [],
-};
-
beforeEach(() => {
mockNavigatorGet.mockReset();
mockSupportsWebauthn.mockReset();
@@ -99,14 +87,35 @@ test('should support optional allowCredential', async () => {
},
);
- await startAssertion(goodOpts3);
- let allowCredentials = mockNavigatorGet.mock.calls[0][0].allowCredentials;
- expect(allowCredentials).toEqual(undefined);
+ await startAssertion({
+ challenge: bufferToBase64URLString(toUint8Array('fizz')),
+ timeout: 1,
+ });
+
+ expect(mockNavigatorGet.mock.calls[0][0].allowCredentials).toEqual(undefined);
+});
+
+test('should convert allow allowCredential to undefined when empty', async () => {
+ mockSupportsWebauthn.mockReturnValue(true);
+
+ // Stub out a response so the method won't throw
+ mockNavigatorGet.mockImplementation(
+ (): Promise<any> => {
+ return new Promise(resolve => {
+ resolve({
+ response: {},
+ getClientExtensionResults: () => ({}),
+ });
+ });
+ },
+ );
- // Should convert empty array to undefined
- await startAssertion(goodOpts4);
- allowCredentials = mockNavigatorGet.mock.calls[1][0].allowCredentials;
- expect(allowCredentials).toEqual(undefined);
+ await startAssertion({
+ challenge: bufferToBase64URLString(toUint8Array('fizz')),
+ timeout: 1,
+ allowCredentials: [],
+ });
+ expect(mockNavigatorGet.mock.calls[0][0].allowCredentials).toEqual(undefined);
});
test('should return base64url-encoded response values', async done => {