personal web client for Bluesky
typescript solidjs bluesky atcute

refactor: upgrade oauth client

mary.my.id c68068a6 cbba3669

verified
Changed files
+91 -30
src
components
+2 -1
package.json
··· 17 17 "@atcute/cbor": "^2.2.4", 18 18 "@atcute/cid": "^2.2.3", 19 19 "@atcute/client": "^4.0.3", 20 + "@atcute/identity": "^1.1.0", 20 21 "@atcute/lexicons": "^1.1.0", 21 - "@atcute/oauth-browser-client": "^1.0.26", 22 + "@atcute/oauth-browser-client": "2.0.0-next.0", 22 23 "@atcute/tid": "^1.0.2", 23 24 "@atlaskit/pragmatic-drag-and-drop": "1.6.0", 24 25 "@atlaskit/pragmatic-drag-and-drop-hitbox": "1.0.3",
+42 -12
pnpm-lock.yaml
··· 57 57 '@atcute/client': 58 58 specifier: ^4.0.3 59 59 version: 4.0.3 60 + '@atcute/identity': 61 + specifier: ^1.1.0 62 + version: 1.1.0 60 63 '@atcute/lexicons': 61 64 specifier: ^1.1.0 62 65 version: 1.1.0 63 66 '@atcute/oauth-browser-client': 64 - specifier: ^1.0.26 65 - version: 1.0.26 67 + specifier: 2.0.0-next.0 68 + version: 2.0.0-next.0 66 69 '@atcute/tid': 67 70 specifier: ^1.0.2 68 71 version: 1.0.2 ··· 213 216 '@atcute/client@4.0.3': 214 217 resolution: {integrity: sha512-RIOZWFVLca/HiPAAUDqQPOdOreCxTbL5cb+WUf5yqQOKIu5yEAP3eksinmlLmgIrlr5qVOE7brazUUzaskFCfw==} 215 218 216 - '@atcute/identity@1.0.3': 217 - resolution: {integrity: sha512-mNMxbKHFGys03A8JXKk0KfMBzdd0vrYMzZZWjpw1nYTs0+ea6bo5S1hwqVUZxHdo1gFHSe/t63jxQIF4yL9aKw==} 219 + '@atcute/identity-resolver@1.1.3': 220 + resolution: {integrity: sha512-KZgGgg99CWaV7Df3+h3X/WMrDzTPQVfsaoIVbTNLx2B56BvCL2EmaxPSVw/7BFUJMZHlVU4rtoEB4lyvNyMswA==} 221 + peerDependencies: 222 + '@atcute/identity': ^1.0.0 223 + 224 + '@atcute/identity@1.1.0': 225 + resolution: {integrity: sha512-6vRvRqJatDB+JUQsb+UswYmtBGQnSZcqC3a2y6H5DB/v5KcIh+6nFFtc17G0+3W9rxdk7k9M4KkgkdKf/YDNoQ==} 218 226 219 227 '@atcute/lexicons@1.1.0': 220 228 resolution: {integrity: sha512-LFqwnria78xLYb62Ri/+WwQpUTgZp2DuyolNGIIOV1dpiKhFFFh//nscHMA6IExFLQRqWDs3tTjy7zv0h3sf1Q==} 221 229 230 + '@atcute/lexicons@1.1.1': 231 + resolution: {integrity: sha512-k6qy5p3j9fJJ6ekaMPfEfp3ni4TW/XNuH9ZmsuwC0fi0tOjp+Fa8ZQakHwnqOzFt/cVBfGcmYE/lKNAbeTjgUg==} 232 + 222 233 '@atcute/multibase@1.1.4': 223 234 resolution: {integrity: sha512-NUf5AeeSOmuZHGU+4GAaMtISJoG+ZHtW/vUVA4lK/YDt/7LODAW0Fd0NNIIUPVUoW0xJS6zSEIWvwLLuxmEHhA==} 224 235 225 - '@atcute/oauth-browser-client@1.0.26': 226 - resolution: {integrity: sha512-z8VUmwRO1sFu5Dq1qYQOQLenkTSNaOyzlUZhVwFR41ru+AP84MS5UHHW/NsdC1xJAq1v6mlLySJ+pjxdDW8IYA==} 236 + '@atcute/oauth-browser-client@2.0.0-next.0': 237 + resolution: {integrity: sha512-BaVU0Mu5ACerdWdMok6kvwwAuPJunbQQk0C51zpxNLpT0P/SYnun+3xX7bcrbtDG1lXn+r+Qld88P+zonY1wPA==} 227 238 228 239 '@atcute/tid@1.0.2': 229 240 resolution: {integrity: sha512-ahmjroNyeDPJhtuf3+HTJropaH04HmJ8fhntDu73Gpz/RkAF7+nkz6kcP2QTgfvMCgMPAJUdskAAP82GPDTY9w==} 230 241 231 242 '@atcute/uint8array@1.0.3': 232 243 resolution: {integrity: sha512-M/K+ihiVW8Pl2PFLzaC4E3l4JaZ1IH05Q0AbPWUC4cVHnd/gZ/1kAF5ngdtGvJeDMirHZ2VAy7OmAsPwR/2nlA==} 244 + 245 + '@atcute/util-fetch@1.0.1': 246 + resolution: {integrity: sha512-Clc0E/5ufyGBVfYBUwWNlHONlZCoblSr4Ho50l1LhmRPGB1Wu/AQ9Sz+rsBg7fdaW/auve8ulmwhRhnX2cGRow==} 233 247 234 248 '@atlaskit/pragmatic-drag-and-drop-hitbox@1.0.3': 235 249 resolution: {integrity: sha512-/Sbu/HqN2VGLYBhnsG7SbRNg98XKkbF6L7XDdBi+izRybfaK1FeMfodPpm/xnBHPJzwYMdkE0qtLyv6afhgMUA==} ··· 2767 2781 2768 2782 '@atcute/client@4.0.3': 2769 2783 dependencies: 2770 - '@atcute/identity': 1.0.3 2784 + '@atcute/identity': 1.1.0 2771 2785 '@atcute/lexicons': 1.1.0 2772 2786 2773 - '@atcute/identity@1.0.3': 2787 + '@atcute/identity-resolver@1.1.3(@atcute/identity@1.1.0)': 2774 2788 dependencies: 2775 - '@atcute/lexicons': 1.1.0 2789 + '@atcute/identity': 1.1.0 2790 + '@atcute/lexicons': 1.1.1 2791 + '@atcute/util-fetch': 1.0.1 2792 + '@badrap/valita': 0.4.5 2793 + 2794 + '@atcute/identity@1.1.0': 2795 + dependencies: 2796 + '@atcute/lexicons': 1.1.1 2776 2797 '@badrap/valita': 0.4.5 2777 2798 2778 2799 '@atcute/lexicons@1.1.0': 2779 2800 dependencies: 2780 2801 esm-env: 1.2.2 2781 2802 2803 + '@atcute/lexicons@1.1.1': 2804 + dependencies: 2805 + esm-env: 1.2.2 2806 + 2782 2807 '@atcute/multibase@1.1.4': 2783 2808 dependencies: 2784 2809 '@atcute/uint8array': 1.0.3 2785 2810 2786 - '@atcute/oauth-browser-client@1.0.26': 2811 + '@atcute/oauth-browser-client@2.0.0-next.0': 2787 2812 dependencies: 2788 2813 '@atcute/client': 4.0.3 2789 - '@atcute/identity': 1.0.3 2790 - '@atcute/lexicons': 1.1.0 2814 + '@atcute/identity': 1.1.0 2815 + '@atcute/identity-resolver': 1.1.3(@atcute/identity@1.1.0) 2816 + '@atcute/lexicons': 1.1.1 2791 2817 '@atcute/multibase': 1.1.4 2792 2818 '@atcute/uint8array': 1.0.3 2793 2819 nanoid: 5.1.5 ··· 2795 2821 '@atcute/tid@1.0.2': {} 2796 2822 2797 2823 '@atcute/uint8array@1.0.3': {} 2824 + 2825 + '@atcute/util-fetch@1.0.1': 2826 + dependencies: 2827 + '@badrap/valita': 0.4.5 2798 2828 2799 2829 '@atlaskit/pragmatic-drag-and-drop-hitbox@1.0.3': 2800 2830 dependencies:
+6 -11
src/components/main/sign-in-dialog.tsx
··· 1 1 import { Match, Switch, createSignal, onMount } from 'solid-js'; 2 2 3 - import type { Did } from '@atcute/lexicons'; 3 + import type { ActorIdentifier, Did } from '@atcute/lexicons'; 4 4 import { 5 - type AuthorizationServerMetadata, 6 - type IdentityMetadata, 5 + type AuthorizeTargetOptions, 7 6 OAuthResponseError, 8 7 ResolverError, 9 8 createAuthorizationUrl, 10 - resolveFromIdentity, 11 - resolveFromService, 12 9 } from '@atcute/oauth-browser-client'; 13 10 import { createMutation } from '@mary/solid-query'; 14 11 ··· 42 39 async mutationFn({ identifier, pds }: { identifier?: string; pds?: string }) { 43 40 setPending(`Resolving your identity`); 44 41 45 - let metadata: AuthorizationServerMetadata; 46 - let identity: IdentityMetadata | undefined; 42 + let target: AuthorizeTargetOptions; 47 43 48 44 if (identifier) { 49 - ({ metadata, identity } = await resolveFromIdentity(identifier)); 45 + target = { type: 'account', identifier: identifier as ActorIdentifier }; 50 46 } else if (pds) { 51 - ({ metadata } = await resolveFromService(pds)); 47 + target = { type: 'pds', serviceUrl: pds }; 52 48 } else { 53 49 assert(false); 54 50 } ··· 56 52 setPending(`Contacting your data server`); 57 53 58 54 const authUrl = await createAuthorizationUrl({ 59 - metadata: metadata, 60 - identity: identity, 55 + target: target, 61 56 scope: import.meta.env.VITE_OAUTH_SCOPE, 62 57 }); 63 58
+41 -6
src/main.tsx
··· 2 2 import { type JSX, createSignal, onMount } from 'solid-js'; 3 3 import { render } from 'solid-js/web'; 4 4 5 + import { Client, ok, simpleFetchHandler } from '@atcute/client'; 6 + import type { DidDocument } from '@atcute/identity'; 5 7 import type { Did } from '@atcute/lexicons'; 6 8 import { configureOAuth } from '@atcute/oauth-browser-client'; 7 9 ··· 32 34 }); 33 35 34 36 // Configure OAuth 35 - configureOAuth({ 36 - metadata: { 37 - client_id: import.meta.env.VITE_OAUTH_CLIENT_ID, 38 - redirect_uri: import.meta.env.VITE_OAUTH_REDIRECT_URL, 39 - }, 40 - }); 37 + { 38 + const resolver = new Client({ 39 + handler: simpleFetchHandler({ service: 'https://identitas.kelinci.deno.net' }), 40 + }); 41 + 42 + configureOAuth({ 43 + metadata: { 44 + client_id: import.meta.env.VITE_OAUTH_CLIENT_ID, 45 + redirect_uri: import.meta.env.VITE_OAUTH_REDIRECT_URL, 46 + }, 47 + 48 + didDocumentResolver: { 49 + async resolve(did) { 50 + const data = await ok( 51 + resolver.get('com.atproto.identity.resolveDid', { 52 + params: { 53 + did: did, 54 + }, 55 + }), 56 + ); 57 + 58 + return data.didDoc as unknown as DidDocument; 59 + }, 60 + }, 61 + handleResolver: { 62 + async resolve(handle) { 63 + const data = await ok( 64 + resolver.get('com.atproto.identity.resolveHandle', { 65 + params: { 66 + handle: handle, 67 + }, 68 + }), 69 + ); 70 + 71 + return data.did as Did<'plc' | 'web'>; 72 + }, 73 + }, 74 + }); 75 + } 41 76 42 77 const InnerApp = () => { 43 78 const [ready, setReady] = createSignal(false);