Update to new provisioning URL scheme
This commit is contained in:
parent
a67335272c
commit
8064560a5f
2 changed files with 10 additions and 7 deletions
|
@ -8,6 +8,10 @@ import { typedArrayToArrayBuffer } from '../../Crypto';
|
||||||
|
|
||||||
import { getProvisioningUrl } from '../../util/getProvisioningUrl';
|
import { getProvisioningUrl } from '../../util/getProvisioningUrl';
|
||||||
|
|
||||||
|
// It'd be nice to run these tests in the renderer, too, but [Chromium's `URL` doesn't
|
||||||
|
// handle `sgnl:` links correctly][0].
|
||||||
|
//
|
||||||
|
// [0]: https://bugs.chromium.org/p/chromium/issues/detail?id=869291
|
||||||
describe('getProvisioningUrl', () => {
|
describe('getProvisioningUrl', () => {
|
||||||
it('returns a URL with a UUID and public key', () => {
|
it('returns a URL with a UUID and public key', () => {
|
||||||
const uuid = 'a08bf1fd-1799-427f-a551-70af747e3956';
|
const uuid = 'a08bf1fd-1799-427f-a551-70af747e3956';
|
||||||
|
@ -16,8 +20,8 @@ describe('getProvisioningUrl', () => {
|
||||||
const result = getProvisioningUrl(uuid, typedArrayToArrayBuffer(publicKey));
|
const result = getProvisioningUrl(uuid, typedArrayToArrayBuffer(publicKey));
|
||||||
const resultUrl = new URL(result);
|
const resultUrl = new URL(result);
|
||||||
|
|
||||||
assert(result.startsWith('tsdevice:/?'));
|
assert.strictEqual(resultUrl.protocol, 'sgnl:');
|
||||||
assert.strictEqual(resultUrl.protocol, 'tsdevice:');
|
assert.strictEqual(resultUrl.host, 'linkdevice');
|
||||||
assert.strictEqual(size(resultUrl.searchParams.entries()), 2);
|
assert.strictEqual(size(resultUrl.searchParams.entries()), 2);
|
||||||
assert.strictEqual(resultUrl.searchParams.get('uuid'), uuid);
|
assert.strictEqual(resultUrl.searchParams.get('uuid'), uuid);
|
||||||
assert.strictEqual(resultUrl.searchParams.get('pub_key'), 'CQgHBgUEAw==');
|
assert.strictEqual(resultUrl.searchParams.get('pub_key'), 'CQgHBgUEAw==');
|
|
@ -7,9 +7,8 @@ export function getProvisioningUrl(
|
||||||
uuid: string,
|
uuid: string,
|
||||||
publicKey: ArrayBuffer
|
publicKey: ArrayBuffer
|
||||||
): string {
|
): string {
|
||||||
const params = new URLSearchParams({
|
const url = new URL('sgnl://linkdevice');
|
||||||
uuid,
|
url.searchParams.set('uuid', uuid);
|
||||||
pub_key: arrayBufferToBase64(publicKey),
|
url.searchParams.set('pub_key', arrayBufferToBase64(publicKey));
|
||||||
});
|
return url.toString();
|
||||||
return `tsdevice:/?${params.toString()}`;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue