From 7c50fba4d838601e43ac7612115724d603046f56 Mon Sep 17 00:00:00 2001 From: Devin Ivy Date: Tue, 27 Aug 2024 22:31:36 -0400 Subject: [PATCH] compat w/ oauth dev preview. update deps. --- package-lock.json | 208 ++++++++++++++++++-------------------------- package.json | 9 +- src/auth/client.ts | 2 +- src/auth/session.ts | 8 +- src/routes.ts | 18 ++-- 5 files changed, 107 insertions(+), 138 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6dd24a7..52cc443 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,12 +9,13 @@ "version": "0.0.1", "license": "MIT", "dependencies": { + "@atproto/api": "^0.13.4", "@atproto/identity": "^0.4.0", - "@atproto/lexicon": "0.4.1-rc.0", - "@atproto/oauth-client-node": "0.0.2-rc.2", - "@atproto/repo": "0.4.2-rc.0", + "@atproto/lexicon": "^0.4.1", + "@atproto/oauth-client-node": "^0.1.0", + "@atproto/repo": "^0.4.3", "@atproto/syntax": "^0.3.0", - "@atproto/xrpc-server": "0.5.4-rc.0", + "@atproto/xrpc-server": "^0.6.3", "better-sqlite3": "^11.1.2", "dotenv": "^16.4.5", "envalid": "^8.0.0", @@ -23,7 +24,6 @@ "kysely": "^0.27.4", "multiformats": "^9.9.0", "pino": "^9.3.2", - "pino-http": "^10.0.0", "uhtml": "^4.5.9" }, "devDependencies": { @@ -39,15 +39,15 @@ } }, "node_modules/@atproto-labs/did-resolver": { - "version": "0.1.2-rc.0", - "resolved": "https://registry.npmjs.org/@atproto-labs/did-resolver/-/did-resolver-0.1.2-rc.0.tgz", - "integrity": "sha512-5lVxhLG9P1G1XjGXQr7fhk6mBM5vpbCalrfuVXqU5xQADvObLjEtpxpJuLheAacaV2pUMFDml+53ZLYWXCgFIg==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@atproto-labs/did-resolver/-/did-resolver-0.1.2.tgz", + "integrity": "sha512-d/nQHoieDo0tf0OX45LJcLQlSuyzVOV5lND7krlSxeAyD3pO5Fx1G8FtmkoPlMt4LT1OCIIQNmjh42pOcGH3WA==", "dependencies": { "@atproto-labs/fetch": "0.1.0", "@atproto-labs/pipe": "0.1.0", "@atproto-labs/simple-store": "0.1.1", "@atproto-labs/simple-store-memory": "0.1.1", - "@atproto/did": "0.1.1-rc.0", + "@atproto/did": "0.1.1", "zod": "^3.23.8" } }, @@ -75,33 +75,33 @@ } }, "node_modules/@atproto-labs/handle-resolver": { - "version": "0.1.2-rc.0", - "resolved": "https://registry.npmjs.org/@atproto-labs/handle-resolver/-/handle-resolver-0.1.2-rc.0.tgz", - "integrity": "sha512-sxk/Zr1hWyBBcg1HhZ8N/Tw1Iue/6+V6bzu2c8zYhO9VfKgCBp3FFU1/i3MpgR2AlsEqZpcjv6zj4KAnMHiLUg==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@atproto-labs/handle-resolver/-/handle-resolver-0.1.2.tgz", + "integrity": "sha512-0D8d1QpGqyp0DLYnKpAFJ5YaIgiRUHMqKnbd1d0reOuJoa7ebwxMolNhP3RnKlOQ/9gaL3Y3ORZFeEjXK+eRqg==", "dependencies": { "@atproto-labs/simple-store": "0.1.1", "@atproto-labs/simple-store-memory": "0.1.1", - "@atproto/did": "0.1.1-rc.0", + "@atproto/did": "0.1.1", "zod": "^3.23.8" } }, "node_modules/@atproto-labs/handle-resolver-node": { - "version": "0.1.2-rc.0", - "resolved": "https://registry.npmjs.org/@atproto-labs/handle-resolver-node/-/handle-resolver-node-0.1.2-rc.0.tgz", - "integrity": "sha512-wP1c0fqxdhnIQVxFgD3Z6fiToq1ri9ECTCSPoy/1zbNJ+KWrr0V6BSONF/I5MytEbQaICBh8bvZuurvX0OjbNw==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@atproto-labs/handle-resolver-node/-/handle-resolver-node-0.1.2.tgz", + "integrity": "sha512-T+QApSezlb71+VLUua3bEmaDN4umvfzEzw/iS1BAZC7BwmGxOg/MBRdE9n6fPU4ul0ekG+6vRhpW4owCS20x3Q==", "dependencies": { "@atproto-labs/fetch-node": "0.1.0", - "@atproto-labs/handle-resolver": "0.1.2-rc.0", - "@atproto/did": "0.1.1-rc.0" + "@atproto-labs/handle-resolver": "0.1.2", + "@atproto/did": "0.1.1" } }, "node_modules/@atproto-labs/identity-resolver": { - "version": "0.1.2-rc.0", - "resolved": "https://registry.npmjs.org/@atproto-labs/identity-resolver/-/identity-resolver-0.1.2-rc.0.tgz", - "integrity": "sha512-4TLjNRbufeGduac3c/No4teJ411qNgyBQck7eY5e2K8XrzS2a/xX/bq3JP91DrvERHiP3yE22PB6ATQkuALgXA==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@atproto-labs/identity-resolver/-/identity-resolver-0.1.2.tgz", + "integrity": "sha512-166XTfq/gvdzmJT6tMvMvsT4h9yVyse8yJVn534j5GPGTqPtyky57/SNyO+R8QbOr4ffG0NQRO+OAazsVR0mVw==", "dependencies": { - "@atproto-labs/did-resolver": "0.1.2-rc.0", - "@atproto-labs/handle-resolver": "0.1.2-rc.0", + "@atproto-labs/did-resolver": "0.1.2", + "@atproto-labs/handle-resolver": "0.1.2", "@atproto/syntax": "0.3.0" } }, @@ -125,14 +125,14 @@ } }, "node_modules/@atproto/api": { - "version": "0.13.0-rc.1", - "resolved": "https://registry.npmjs.org/@atproto/api/-/api-0.13.0-rc.1.tgz", - "integrity": "sha512-h2+M6OoMLnNzqf2KDxsbRkg3/1k2IMWH33PQI31GkiQHIdt3B+MIXvJwXePu0KnMUL/Lvv2Zk01BKiDnjd4LEw==", + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/@atproto/api/-/api-0.13.4.tgz", + "integrity": "sha512-Fwn37hP+Xr9YjA/hadvn7ZKbUPQhJiUus1+govgNKF3/jNdyk2ICoEe0z+hxaO3xX8LCU5yARbgt3SRoXbIwrg==", "dependencies": { "@atproto/common-web": "^0.3.0", - "@atproto/lexicon": "^0.4.1-rc.0", + "@atproto/lexicon": "^0.4.1", "@atproto/syntax": "^0.3.0", - "@atproto/xrpc": "^0.6.0-rc.0", + "@atproto/xrpc": "^0.6.1", "await-lock": "^2.2.2", "multiformats": "^9.9.0", "tlds": "^1.234.0" @@ -210,9 +210,9 @@ } }, "node_modules/@atproto/crypto": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@atproto/crypto/-/crypto-0.4.0.tgz", - "integrity": "sha512-Kj/4VgJ7hzzXvE42L0rjzP6lM0tai+OfPnP1rxJ+UZg/YUDtuewL4uapnVoWXvlNceKgaLZH98g5n9gXBVTe5Q==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@atproto/crypto/-/crypto-0.4.1.tgz", + "integrity": "sha512-7pQNHWYyx8jGhYdPbmcuPD9W73nd/5v3mfBlncO0sBzxnPbmA6aXAWOz+fNVZwHwBJPeb/Gzf/FT/uDx7/eYFg==", "dependencies": { "@noble/curves": "^1.1.0", "@noble/hashes": "^1.3.1", @@ -220,9 +220,9 @@ } }, "node_modules/@atproto/did": { - "version": "0.1.1-rc.0", - "resolved": "https://registry.npmjs.org/@atproto/did/-/did-0.1.1-rc.0.tgz", - "integrity": "sha512-rbO6kQv/bKsMGqAqr1M4o7cmJf893gYzabr1CmJ0rr/FNdXHfr0b9s2lRphA6zCS0wPdT4/mw6/LWiCrnBmi9w==", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@atproto/did/-/did-0.1.1.tgz", + "integrity": "sha512-FA+U8C8ACQLjG/TSgtaQyjvXxzOYzwK0+T6FJ1oj2BtKUixq4t8zpvo4zdIrnVimXeGQWo1/U1ghke58SmRpmQ==", "dependencies": { "zod": "^3.23.8" } @@ -247,21 +247,21 @@ } }, "node_modules/@atproto/jwk-jose": { - "version": "0.1.2-rc.0", - "resolved": "https://registry.npmjs.org/@atproto/jwk-jose/-/jwk-jose-0.1.2-rc.0.tgz", - "integrity": "sha512-guqGhgQjOx6OxxDWBENRa30G3CJ91Rqw+5NEwiv4GfhmmM/szS983kZIydmXpySpyyZhGAPZfkOfHai+HrLsXg==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@atproto/jwk-jose/-/jwk-jose-0.1.2.tgz", + "integrity": "sha512-lDwc/6lLn2aZ/JpyyggyjLFsJPMntrVzryyGUx5aNpuTS8SIuc4Ky0REhxqfLopQXJJZCuRRjagHG3uP05/moQ==", "dependencies": { "@atproto/jwk": "0.1.1", "jose": "^5.2.0" } }, "node_modules/@atproto/jwk-webcrypto": { - "version": "0.1.2-rc.0", - "resolved": "https://registry.npmjs.org/@atproto/jwk-webcrypto/-/jwk-webcrypto-0.1.2-rc.0.tgz", - "integrity": "sha512-TlLaJulKDWDhXQ8Wujte4l2RPe/Ym+jAnFR/+lwZbcGQHAUsatBMCKzvYVv3TtqXL3B5gIC9ry12+C7oQ5yE/Q==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@atproto/jwk-webcrypto/-/jwk-webcrypto-0.1.2.tgz", + "integrity": "sha512-vTBUbUZXh0GI+6KJiPGukmI4BQEHFAij8fJJ4WnReF/hefAs3ISZtrWZHGBebz+q2EcExYlnhhlmxvDzV7veGw==", "dependencies": { "@atproto/jwk": "0.1.1", - "@atproto/jwk-jose": "0.1.2-rc.0" + "@atproto/jwk-jose": "0.1.2" } }, "node_modules/@atproto/lex-cli": { @@ -283,23 +283,10 @@ "lex": "dist/index.js" } }, - "node_modules/@atproto/lex-cli/node_modules/@atproto/lexicon": { + "node_modules/@atproto/lexicon": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@atproto/lexicon/-/lexicon-0.4.1.tgz", "integrity": "sha512-bzyr+/VHXLQWbumViX5L7h1NKQObfs8Z+XZJl43OUK8nYFUI4e/sW1IZKRNfw7Wvi5YVNK+J+yP3DWIBZhkCYA==", - "dev": true, - "dependencies": { - "@atproto/common-web": "^0.3.0", - "@atproto/syntax": "^0.3.0", - "iso-datestring-validator": "^2.2.2", - "multiformats": "^9.9.0", - "zod": "^3.23.8" - } - }, - "node_modules/@atproto/lexicon": { - "version": "0.4.1-rc.0", - "resolved": "https://registry.npmjs.org/@atproto/lexicon/-/lexicon-0.4.1-rc.0.tgz", - "integrity": "sha512-CSYO8MWbxTXTLQMEJ1mTXD2pDxIXO2oCK/FVw9T/BeXLMcvwmeVgKAaytd1AGFkapX8IMAAtjBB3cnaltuHwbg==", "dependencies": { "@atproto/common-web": "^0.3.0", "@atproto/syntax": "^0.3.0", @@ -309,59 +296,58 @@ } }, "node_modules/@atproto/oauth-client": { - "version": "0.1.2-rc.2", - "resolved": "https://registry.npmjs.org/@atproto/oauth-client/-/oauth-client-0.1.2-rc.2.tgz", - "integrity": "sha512-FBYyEKEU1BFoW1ASFzsmw1oOpVPj/nkoR753OZItgNwl9i+Tr4kAA9TqeXGa6Ol3dh7K67oaxHw7DChdEqbtSg==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@atproto/oauth-client/-/oauth-client-0.2.0.tgz", + "integrity": "sha512-J8NaQ45jIa7e/VXKUwtGnW91p8mM8yWvqhlBxNvVXQ2t5yo6rxYdIVam+2Ffy3SANxqe+sl5QFmCdaJQGX0yNQ==", "dependencies": { - "@atproto-labs/did-resolver": "0.1.2-rc.0", + "@atproto-labs/did-resolver": "0.1.2", "@atproto-labs/fetch": "0.1.0", - "@atproto-labs/handle-resolver": "0.1.2-rc.0", - "@atproto-labs/identity-resolver": "0.1.2-rc.0", + "@atproto-labs/handle-resolver": "0.1.2", + "@atproto-labs/identity-resolver": "0.1.2", "@atproto-labs/simple-store": "0.1.1", "@atproto-labs/simple-store-memory": "0.1.1", - "@atproto/api": "0.13.0-rc.1", - "@atproto/did": "0.1.1-rc.0", + "@atproto/did": "0.1.1", "@atproto/jwk": "0.1.1", - "@atproto/oauth-types": "0.1.2-rc.0", - "@atproto/xrpc": "0.6.0-rc.0", + "@atproto/oauth-types": "0.1.4", + "@atproto/xrpc": "0.6.1", "multiformats": "^9.9.0", "zod": "^3.23.8" } }, "node_modules/@atproto/oauth-client-node": { - "version": "0.0.2-rc.2", - "resolved": "https://registry.npmjs.org/@atproto/oauth-client-node/-/oauth-client-node-0.0.2-rc.2.tgz", - "integrity": "sha512-MxR2C84h6XjTB28RpXfctKLvB6Ot68tiOlsOSigeSTKnNJ5SRD2wISz2647P8dxOec81ugMu8wa5BKcZ5Ry7nw==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@atproto/oauth-client-node/-/oauth-client-node-0.1.0.tgz", + "integrity": "sha512-F+bhXBaTAQuOViVjr9I+9iVVPTgnXh4EbquMazhoyAcH1T+v8oPkzV7tqVBvsbolgRDILJTAgRCtF140fC2wAg==", "dependencies": { - "@atproto-labs/did-resolver": "0.1.2-rc.0", - "@atproto-labs/handle-resolver-node": "0.1.2-rc.0", + "@atproto-labs/did-resolver": "0.1.2", + "@atproto-labs/handle-resolver-node": "0.1.2", "@atproto-labs/simple-store": "0.1.1", - "@atproto/did": "0.1.1-rc.0", + "@atproto/did": "0.1.1", "@atproto/jwk": "0.1.1", - "@atproto/jwk-jose": "0.1.2-rc.0", - "@atproto/jwk-webcrypto": "0.1.2-rc.0", - "@atproto/oauth-client": "0.1.2-rc.2", - "@atproto/oauth-types": "0.1.2-rc.0" + "@atproto/jwk-jose": "0.1.2", + "@atproto/jwk-webcrypto": "0.1.2", + "@atproto/oauth-client": "0.2.0", + "@atproto/oauth-types": "0.1.4" } }, "node_modules/@atproto/oauth-types": { - "version": "0.1.2-rc.0", - "resolved": "https://registry.npmjs.org/@atproto/oauth-types/-/oauth-types-0.1.2-rc.0.tgz", - "integrity": "sha512-q/AxPSdLf2xTgC4K1cU35HVl6T4T0LJ/QJmvqXwjpbiNWEqooIQIP9sTp2CqqSLsWpe26z3fIoA3R+oTR1EJsA==", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@atproto/oauth-types/-/oauth-types-0.1.4.tgz", + "integrity": "sha512-B5lFXMvsx9PtO0wwCqwaoRVG8vKxvB742vO4Ze5OMJJsps6ebGskaYmkFHP9DnvDSLRzIHpJJ7jN6ri71V+xng==", "dependencies": { "@atproto/jwk": "0.1.1", "zod": "^3.23.8" } }, "node_modules/@atproto/repo": { - "version": "0.4.2-rc.0", - "resolved": "https://registry.npmjs.org/@atproto/repo/-/repo-0.4.2-rc.0.tgz", - "integrity": "sha512-y8zXAR23r6qlsTmbzXaBEHYjvlgeNlAKj9eJ6V17JtT+4FVdW246alhsgSsglJ2Uv/e24RC1r90yNJNRxqDzXw==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@atproto/repo/-/repo-0.4.3.tgz", + "integrity": "sha512-9w4TlyxExLfFL9BysvXq4vhIsYsnmGi0uelmxJjlRXBICgLpqjqQVqhS8OBqE25ZTYvgXUi7nNqpo2llCHhOvQ==", "dependencies": { "@atproto/common": "^0.4.1", "@atproto/common-web": "^0.3.0", - "@atproto/crypto": "^0.4.0", - "@atproto/lexicon": "^0.4.1-rc.0", + "@atproto/crypto": "^0.4.1", + "@atproto/lexicon": "^0.4.1", "@ipld/car": "^3.2.3", "@ipld/dag-cbor": "^7.0.0", "multiformats": "^9.9.0", @@ -375,23 +361,23 @@ "integrity": "sha512-Weq0ZBxffGHDXHl9U7BQc2BFJi/e23AL+k+i5+D9hUq/bzT4yjGsrCejkjq0xt82xXDjmhhvQSZ0LqxyZ5woxA==" }, "node_modules/@atproto/xrpc": { - "version": "0.6.0-rc.0", - "resolved": "https://registry.npmjs.org/@atproto/xrpc/-/xrpc-0.6.0-rc.0.tgz", - "integrity": "sha512-TOmynXvbA57Y6KR050UeiDfdzQoAnmgB0zu0qrvhYiu7oeg64fYzvOa7stWxSIP1nhrGqgexxICR1CnOnCEHjg==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/@atproto/xrpc/-/xrpc-0.6.1.tgz", + "integrity": "sha512-Zy5ydXEdk6sY7FDUZcEVfCL1jvbL4tXu5CcdPqbEaW6LQtk9GLds/DK1bCX9kswTGaBC88EMuqQMfkxOhp2t4A==", "dependencies": { - "@atproto/lexicon": "^0.4.1-rc.0", + "@atproto/lexicon": "^0.4.1", "zod": "^3.23.8" } }, "node_modules/@atproto/xrpc-server": { - "version": "0.5.4-rc.0", - "resolved": "https://registry.npmjs.org/@atproto/xrpc-server/-/xrpc-server-0.5.4-rc.0.tgz", - "integrity": "sha512-Vrx1gEoZfJtYoZhSxkbWQsU2r0DuJO/BuvMQGw9Nd66owmF5nPDVvYVd0pJhIDoaSxImTTIEeDWlNNl3WCSBPA==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/@atproto/xrpc-server/-/xrpc-server-0.6.3.tgz", + "integrity": "sha512-0YXeBM9NjiIlR5eXWo8qzArRcBOKhwVimpH+ajKgZzlncPO53brVZ9+3BUnD5J1PG8mEQFRERi+Jt77QyF89qA==", "dependencies": { "@atproto/common": "^0.4.1", - "@atproto/crypto": "^0.4.0", - "@atproto/lexicon": "^0.4.1-rc.0", - "@atproto/xrpc": "^0.6.0-rc.0", + "@atproto/crypto": "^0.4.1", + "@atproto/lexicon": "^0.4.1", + "@atproto/xrpc": "^0.6.1", "cbor-x": "^1.5.1", "express": "^4.17.2", "http-errors": "^2.0.0", @@ -1944,14 +1930,6 @@ "resolved": "https://registry.npmjs.org/gc-hook/-/gc-hook-0.3.1.tgz", "integrity": "sha512-E5M+O/h2o7eZzGhzRZGex6hbB3k4NWqO0eA+OzLRLXxhdbYPajZnynPwAtphnh+cRHPwsj5Z80dqZlfI4eK55A==" }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, "node_modules/get-intrinsic": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", @@ -2300,9 +2278,9 @@ } }, "node_modules/jose": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/jose/-/jose-5.6.3.tgz", - "integrity": "sha512-1Jh//hEEwMhNYPDDLwXHa2ePWgWiFNNUadVmguAAw2IJ6sj9mNxV5tGXJNqlMkJAybF6Lgw1mISDxTePP/187g==", + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/jose/-/jose-5.8.0.tgz", + "integrity": "sha512-E7CqYpL/t7MMnfGnK/eg416OsFCVUrU/Y3Vwe7QjKhu/BkS1Ms455+2xsqZQVN57/U2MHMBvEb5SrmAZWAIntA==", "funding": { "url": "https://github.com/sponsors/panva" } @@ -2749,22 +2727,6 @@ "split2": "^4.0.0" } }, - "node_modules/pino-http": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/pino-http/-/pino-http-10.2.0.tgz", - "integrity": "sha512-am03BxnV3Ckx68OkbH0iZs3indsrH78wncQ6w1w51KroIbvJZNImBKX2X1wjdY8lSyaJ0UrX/dnO2DY3cTeCRw==", - "dependencies": { - "get-caller-file": "^2.0.5", - "pino": "^9.0.0", - "pino-std-serializers": "^7.0.0", - "process-warning": "^3.0.0" - } - }, - "node_modules/pino-http/node_modules/process-warning": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-3.0.0.tgz", - "integrity": "sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==" - }, "node_modules/pino-pretty": { "version": "11.2.2", "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-11.2.2.tgz", @@ -4059,9 +4021,9 @@ "integrity": "sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==" }, "node_modules/undici": { - "version": "6.19.7", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.7.tgz", - "integrity": "sha512-HR3W/bMGPSr90i8AAp2C4DM3wChFdJPLrWYpIS++LxS8K+W535qftjt+4MyjNYHeWabMj1nvtmLIi7l++iq91A==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.8.tgz", + "integrity": "sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==", "engines": { "node": ">=18.17" } diff --git a/package.json b/package.json index 5bd68ef..37eb1a2 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,13 @@ "clean": "rimraf dist coverage" }, "dependencies": { + "@atproto/api": "^0.13.4", "@atproto/identity": "^0.4.0", - "@atproto/lexicon": "0.4.1-rc.0", - "@atproto/oauth-client-node": "0.0.2-rc.2", - "@atproto/repo": "0.4.2-rc.0", + "@atproto/lexicon": "^0.4.1", + "@atproto/oauth-client-node": "^0.1.0", + "@atproto/repo": "^0.4.3", "@atproto/syntax": "^0.3.0", - "@atproto/xrpc-server": "0.5.4-rc.0", + "@atproto/xrpc-server": "^0.6.3", "better-sqlite3": "^11.1.2", "dotenv": "^16.4.5", "envalid": "^8.0.0", diff --git a/src/auth/client.ts b/src/auth/client.ts index 372513a..2228fea 100644 --- a/src/auth/client.ts +++ b/src/auth/client.ts @@ -14,7 +14,7 @@ export const createClient = async (db: Database) => { : `http://localhost?redirect_uri=${encodeURIComponent(`${url}/oauth/callback`)}`, client_uri: url, redirect_uris: [`${url}/oauth/callback`], - scope: 'profile offline_access', + scope: 'atproto transition:generic', grant_types: ['authorization_code', 'refresh_token'], response_types: ['code'], application_type: 'web', diff --git a/src/auth/session.ts b/src/auth/session.ts index 632479e..91b97f9 100644 --- a/src/auth/session.ts +++ b/src/auth/session.ts @@ -1,6 +1,7 @@ import assert from 'node:assert' import type { IncomingMessage, ServerResponse } from 'node:http' import { getIronSession } from 'iron-session' +import { Agent } from '@atproto/api' import { env } from '#/lib/env' import { AppContext } from '#/index' @@ -43,11 +44,14 @@ export async function getSessionAgent( ) { const session = await getSessionRaw(req, res) if (!session.did) return null - return await ctx.oauthClient.restore(session.did).catch(async (err) => { + try { + const oauthSession = await ctx.oauthClient.restore(session.did) + return oauthSession ? new Agent(oauthSession) : null + } catch (err) { ctx.logger.warn({ err }, 'oauth restore failed') await destroySession(req, res) return null - }) + } } async function getSessionRaw( diff --git a/src/routes.ts b/src/routes.ts index 6d70daa..0ebad97 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -44,8 +44,8 @@ export const createRouter = (ctx: AppContext) => { handler(async (req, res) => { const params = new URLSearchParams(req.originalUrl.split('?')[1]) try { - const { agent } = await ctx.oauthClient.callback(params) - await createSession(req, res, agent.accountDid) + const { session } = await ctx.oauthClient.callback(params) + await createSession(req, res, session.did) } catch (err) { ctx.logger.error({ err }, 'oauth callback failed') return res.redirect('/?error') @@ -74,7 +74,9 @@ export const createRouter = (ctx: AppContext) => { // Initiate the OAuth flow try { - const url = await ctx.oauthClient.authorize(handle) + const url = await ctx.oauthClient.authorize(handle, { + scope: 'atproto transition:generic' + }) return res.redirect(url.toString()) } catch (err) { ctx.logger.error({ err }, 'oauth authorize failed') @@ -119,7 +121,7 @@ export const createRouter = (ctx: AppContext) => { ? await ctx.db .selectFrom('status') .selectAll() - .where('authorDid', '=', agent.accountDid) + .where('authorDid', '=', agent.assertDid) .executeTakeFirst() : undefined @@ -135,9 +137,9 @@ export const createRouter = (ctx: AppContext) => { // Fetch additional information about the logged-in user const { data: profile } = await agent.getProfile({ - actor: agent.accountDid, + actor: agent.assertDid, }) - didHandleMap[profile.handle] = agent.accountDid + didHandleMap[profile.handle] = agent.assertDid // Serve the logged-in view return res @@ -169,7 +171,7 @@ export const createRouter = (ctx: AppContext) => { try { // Write the status record to the user's repository await agent.com.atproto.repo.putRecord({ - repo: agent.accountDid, + repo: agent.assertDid, collection: 'com.example.status', rkey: 'self', record, @@ -188,7 +190,7 @@ export const createRouter = (ctx: AppContext) => { await ctx.db .insertInto('status') .values({ - authorDid: agent.accountDid, + authorDid: agent.assertDid, status: record.status, updatedAt: record.updatedAt, indexedAt: new Date().toISOString(), -- 2.51.2