Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Specifying a custom timeout causes an error #178

Open
0xdeafcafe opened this issue Jan 30, 2019 · 3 comments
Open

Specifying a custom timeout causes an error #178

0xdeafcafe opened this issue Jan 30, 2019 · 3 comments

Comments

@0xdeafcafe
Copy link

I'm specifying a custom timeout like so:

const customTimeout = 60;

window.u2f.sign(appId, challenge, registeredKeys, res => {
	const signRes = res as SignResponse;

	if (signRes.clientData) {
		resolve(signRes);

		return;
	}

	const err = log.info('u2f_signing_failed', null, res);

	reject(err);
}, customTimeout);

However, when the timeout is hit it throws this error to the console:
Error in event handler for (unknown): TypeError: Cannot read property 'write' of undefined

@cpiper
Copy link
Member

cpiper commented Jan 30, 2019

I'm not familiar with the 'as SignResponse' syntax, but simplifying your example to:

window.u2f.sign('https://u2fdemo.appspot.com', 'asdf', [], res => {console.log(res)}, 2);

seems to work and logs the timeout error after 2 seconds.

@0xdeafcafe
Copy link
Author

The SignResponse is just from typescript definitions (from https://github.com/lgarron/u2f-api-polyfill.d.ts) however as these are just definitions they should have no impact on the logic.

I'll try setting it to 2 tomorrow, but when I tried setting it to anything it was just failing.

@cpiper
Copy link
Member

cpiper commented Jan 30, 2019

Ok, not really knowing Typescript, it seems like SignResponse only covers success cases, and this is a failure case so none of the fields match what you are assigning it to.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants