Link-and-sync

This commit is contained in:
Fedor Indutny 2024-10-18 10:15:03 -07:00 committed by GitHub
parent 455ff88918
commit 6565daa5c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 388 additions and 59 deletions

View file

@ -313,8 +313,9 @@ export const groupInvitesRoute = _route('groupInvites', {
* linkDeviceRoute.toAppUrl({
* uuid: "123",
* pubKey: "abc",
* capabilities: "backuo"
* })
* // URL { "sgnl://linkdevice?uuid=123&pub_key=abc" }
* // URL { "sgnl://linkdevice?uuid=123&pub_key=abc&capabilities=backup" }
* ```
*/
export const linkDeviceRoute = _route('linkDevice', {
@ -322,18 +323,21 @@ export const linkDeviceRoute = _route('linkDevice', {
schema: z.object({
uuid: paramSchema, // base64url?
pubKey: paramSchema, // percent-encoded base64 (with padding) of PublicKey with type byte included
capabilities: paramSchema.array(), // comma-separated list of capabilities
}),
parse(result) {
const params = new URLSearchParams(result.search.groups.params);
return {
uuid: params.get('uuid'),
pubKey: params.get('pub_key'),
capabilities: params.get('capabilities')?.split(',') ?? [],
};
},
toAppUrl(args) {
const params = new URLSearchParams({
uuid: args.uuid,
pub_key: args.pubKey,
capabilities: args.capabilities.join(','),
});
return new URL(`sgnl://linkdevice?${params.toString()}`);
},