{"_id":"@atcute/password-session","_rev":"5-2dbc5757f1fc382f53c90a0d67e26ab4","name":"@atcute/password-session","dist-tags":{"latest":"1.0.2"},"versions":{"0.1.0":{"name":"@atcute/password-session","version":"0.1.0","license":"0BSD","_id":"@atcute/password-session@0.1.0","maintainers":[{"name":"externdefs","email":"hi@mary.my.id"}],"homepage":"https://github.com/mary-ext/atcute#readme","bugs":{"url":"https://github.com/mary-ext/atcute/issues"},"dist":{"shasum":"784d3c3103d7f37ff5e82c75734dacf4c1e14f9b","tarball":"https://registry.npmjs.org/@atcute/password-session/-/password-session-0.1.0.tgz","fileCount":13,"integrity":"sha512-r4iUNT7aQ1J6XXGO+pu39037hFQd0GYEhOuw/aykoNI3HHFLX2t5YyrxWTu5uKMGECk3s7zEgc8B8ol9JsMjRA==","signatures":[{"sig":"MEQCIAo1D9D3uGPkR0BdaC3h0zfNOgtX8X9aBPXA/51B3co2AiBaL6hF5o0RB9Qtnak8R8tOV/oDcPzsqqRqUsy08kRR4Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53732},"type":"module","_from":"file:atcute-password-session-0.1.0.tgz","exports":{".":"./dist/index.js"},"scripts":{"test":"vitest run","build":"tsgo --project tsconfig.build.json","prepublish":"rm -rf dist; pnpm run build"},"_npmUser":{"name":"externdefs","email":"hi@mary.my.id"},"_resolved":"/tmp/c20aa3a09b55efa622e463ed5cdd0e0e/atcute-password-session-0.1.0.tgz","_integrity":"sha512-r4iUNT7aQ1J6XXGO+pu39037hFQd0GYEhOuw/aykoNI3HHFLX2t5YyrxWTu5uKMGECk3s7zEgc8B8ol9JsMjRA==","repository":{"url":"git+https://github.com/mary-ext/atcute.git","directory":"packages/clients/password-session"},"_npmVersion":"10.9.4","description":"password-based session management for AT Protocol","directories":{},"_nodeVersion":"22.22.0","dependencies":{"@atcute/client":"^4.2.1","@atcute/identity":"^1.1.3","@atcute/lexicons":"^1.2.9"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.0.18","@atcute/atproto":"^3.1.10","@atcute/bluesky":"^3.2.19","@atcute/internal-dev-env":"^1.0.2"},"_npmOperationalInternal":{"tmp":"tmp/password-session_0.1.0_1771925347822_0.1386798312259403","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@atcute/password-session","version":"0.1.1","license":"0BSD","_id":"@atcute/password-session@0.1.1","maintainers":[{"name":"externdefs","email":"hi@mary.my.id"}],"dist":{"shasum":"4cf7a0ba4239f394ee94fe930cc9551d566b5d10","tarball":"https://registry.npmjs.org/@atcute/password-session/-/password-session-0.1.1.tgz","fileCount":13,"integrity":"sha512-uVz2PNa4KDRmtkqJ88Kvszol20Osdm6WSqcBsroGzMOw185RCpONrlja8uGbFoPDp/dU3rk0oTd2Me3aSzRkcA==","signatures":[{"sig":"MEUCIDZ39BGVBhnfsrP3gNh6qoAMATiaseQ1ADPrVebXl8xgAiEAigrj5/Rvc23QVil+uVHlDTBXD7Tt2iOoT9kWL2JYhkA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53688},"type":"module","exports":{".":"./dist/index.js"},"scripts":{"test":"vitest run","build":"tsgo","prepublish":"rm -rf dist; pnpm run build"},"_npmUser":{"name":"externdefs","email":"hi@mary.my.id"},"repository":{"url":"https://github.com/mary-ext/atcute","directory":"packages/clients/password-session"},"description":"password-based session management for AT Protocol","directories":{},"_nodeVersion":"26.0.0","dependencies":{"@atcute/client":"^4.2.2","@atcute/identity":"^1.1.5","@atcute/lexicons":"^1.3.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","@atcute/atproto":"^3.1.12","@atcute/bluesky":"^3.3.4","@atcute/internal-dev-env":"^1.0.2"},"peerDependencies":{"@atcute/identity":"^1.0.0","@atcute/lexicons":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/password-session_0.1.1_1778205624529_0.03953688237441333","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@atcute/password-session","version":"1.0.0","license":"0BSD","_id":"@atcute/password-session@1.0.0","maintainers":[{"name":"externdefs","email":"hi@mary.my.id"}],"dist":{"shasum":"65605bd25de45d02230e7e26927144f2a5445143","tarball":"https://registry.npmjs.org/@atcute/password-session/-/password-session-1.0.0.tgz","fileCount":13,"integrity":"sha512-yUYkLnYjQMOjKV6jHlE5oBAIDuRn18nTptNjLaF3LrTtsBVEXziwC5ByKkl65MLDHm27iUkzTehB4giqnwQnIA==","signatures":[{"sig":"MEUCIQCzTldGU9c/aC1K8Vxd5XmsHnBB71j1COb9aiKOOZMkRQIgAYhyyU5s/bVcmo9sIhqmGqIpfsde0w2wwA7gd1tX8ZY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53687},"type":"module","exports":{".":"./dist/index.js"},"scripts":{"test":"vitest run","build":"tsgo","prepublish":"rm -rf dist; pnpm run build"},"_npmUser":{"name":"externdefs","email":"hi@mary.my.id"},"repository":{"url":"https://github.com/mary-ext/atcute","directory":"packages/clients/password-session"},"description":"password-based session management for AT Protocol","directories":{},"_nodeVersion":"26.0.0","dependencies":{"@atcute/client":"^5.0.0","@atcute/identity":"^2.0.0","@atcute/lexicons":"^2.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","@atcute/atproto":"^4.0.0","@atcute/bluesky":"^4.0.0","@atcute/internal-dev-env":"^1.0.2"},"peerDependencies":{"@atcute/identity":"^2.0.0","@atcute/lexicons":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/password-session_1.0.0_1778312818330_0.7820116673214326","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@atcute/password-session","version":"1.0.1","license":"0BSD","_id":"@atcute/password-session@1.0.1","maintainers":[{"name":"externdefs","email":"hi@mary.my.id"}],"dist":{"shasum":"c850f40416c969bcabf1066ae07912fcd0cd3051","tarball":"https://registry.npmjs.org/@atcute/password-session/-/password-session-1.0.1.tgz","fileCount":7,"integrity":"sha512-AH9lUVutB1SH7hwdbSJHh0iYeIBWlFrKqp7hEQ5eYb6czBVo5tOEcbBeoO+sAPazzrdykPGxbP1zftsdGMloJA==","signatures":[{"sig":"MEYCIQDEdVVNLPPNi2ksQt3CoC3Q1i+tP3youSWgLrLkMmmJ3AIhANYPqvCh3TS2YQvSqATSu3DW/4NpsC/2Y18WGBU4wE0Z","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24651},"type":"module","exports":{".":"./dist/index.js"},"scripts":{"test":"vitest run","build":"tsgo","prepublish":"rm -rf dist; pnpm run build"},"_npmUser":{"name":"externdefs","email":"hi@mary.my.id"},"repository":{"url":"https://github.com/mary-ext/atcute","directory":"packages/clients/password-session"},"description":"password-based session management for AT Protocol","directories":{},"_nodeVersion":"26.0.0","dependencies":{"@atcute/client":"^5.1.1","@atcute/identity":"^2.0.1","@atcute/lexicons":"^2.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.9","@atcute/atproto":"^4.0.3","@atcute/bluesky":"^4.0.12","@atcute/internal-dev-env":"^1.0.2"},"peerDependencies":{"@atcute/identity":"^2.0.0","@atcute/lexicons":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/password-session_1.0.1_1782777142339_0.4041568688440851","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@atcute/password-session","version":"1.0.2","description":"password-based session management for AT Protocol","license":"0BSD","repository":{"url":"https://github.com/mary-ext/atcute","directory":"packages/clients/password-session"},"type":"module","exports":{".":"./dist/index.js"},"publishConfig":{"access":"public"},"dependencies":{"@atcute/client":"^5.1.1","@atcute/lexicons":"^2.0.3","@atcute/identity":"^2.0.2"},"devDependencies":{"vitest":"^4.1.10","@atcute/bluesky":"^4.0.14","@atcute/atproto":"^4.0.3","@atcute/internal-dev-env":"^1.0.2"},"peerDependencies":{"@atcute/identity":"^2.0.0","@atcute/lexicons":"^2.0.0"},"scripts":{"build":"tsc","test":"vitest run","prepublish":"rm -rf dist; pnpm run build"},"_nodeVersion":"26.0.0","_id":"@atcute/password-session@1.0.2","dist":{"integrity":"sha512-BJo9e9AJFiUOmoswTJ3tmH4nv2WiWpzZ4gC89Zhq5Uh52OefZy1r+WTis1xcz1mCdIWEmPoJe76CKgHVGYzhJw==","shasum":"09805567a39bc9b1f376a33d91f07138c8a5895d","tarball":"https://registry.npmjs.org/@atcute/password-session/-/password-session-1.0.2.tgz","fileCount":7,"unpackedSize":25202,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC4EiHIClWSXgteMV6hyX8m+wbtWO4daDLSY9/OfUjSrQIgIghOj2mh+Kik8i2MZxjJz/7PU5QeciMNa/17muf4tD8="}]},"_npmUser":{"name":"externdefs","email":"hi@mary.my.id"},"directories":{},"maintainers":[{"name":"externdefs","email":"hi@mary.my.id"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/password-session_1.0.2_1784160626610_0.9812083255002739"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-24T09:29:07.704Z","modified":"2026-07-16T00:10:26.961Z","0.1.0":"2026-02-24T09:29:07.957Z","0.1.1":"2026-05-08T02:00:24.666Z","1.0.0":"2026-05-09T07:46:58.469Z","1.0.1":"2026-06-29T23:52:22.491Z","1.0.2":"2026-07-16T00:10:26.758Z"},"license":"0BSD","repository":{"url":"https://github.com/mary-ext/atcute","directory":"packages/clients/password-session"},"description":"password-based session management for AT Protocol","maintainers":[{"name":"externdefs","email":"hi@mary.my.id"}],"readme":"# @atcute/password-session\n\npassword-based session management for AT Protocol services. manages access/refresh token lifecycle,\nautomatic refresh on 401, and session persistence via callbacks.\n\nfor browser-based applications, prefer OAuth-based authentication. when using password auth, use app\npasswords rather than main account credentials.\n\n```sh\nnpm install @atcute/password-session @atcute/client @atcute/bluesky\n```\n\n## usage\n\n### login\n\n```ts\nimport { Client, ok } from '@atcute/client';\nimport { PasswordSession } from '@atcute/password-session';\n\nimport type {} from '@atcute/bluesky';\n\nconst session = await PasswordSession.login(\n\t{ service: 'https://bsky.social', identifier: 'you.bsky.social', password: 'your-app-password' },\n\t{\n\t\tonUpdate(data) {\n\t\t\t// called on login and token refresh — persist the session\n\t\t\tlocalStorage.setItem('session', JSON.stringify(data));\n\t\t},\n\t\tonDelete(data) {\n\t\t\t// called on logout or session invalidation — clean up\n\t\t\tlocalStorage.removeItem('session');\n\t\t},\n\t},\n);\n\nconst rpc = new Client({ handler: session });\n\nconst data = await ok(rpc.get('com.atproto.server.getSession'));\nconsole.log(data.did);\n```\n\n### URL shorthand\n\nfor bots and scripts, use URL shorthand with `await using` for automatic logout:\n\n```ts\nawait using session = await PasswordSession.login('https://handle:app-pass@bsky.social');\nconst rpc = new Client({ handler: session });\n```\n\n### resuming sessions\n\nresume a persisted session without re-entering credentials:\n\n```ts\nconst saved = localStorage.getItem('session');\nif (saved) {\n\tconst session = await PasswordSession.resume(JSON.parse(saved), {\n\t\tonUpdate(data) {\n\t\t\tlocalStorage.setItem('session', JSON.stringify(data));\n\t\t},\n\t\tonDelete(data) {\n\t\t\tlocalStorage.removeItem('session');\n\t\t},\n\t});\n\tconst rpc = new Client({ handler: session });\n}\n```\n\n### cached session with credential fallback\n\nfor bots with both stored credentials and cached sessions, `login()` can try the cached session\nfirst and fall back to fresh authentication:\n\n```ts\nconst session = await PasswordSession.login('https://handle:app-pass@bsky.social', {\n\tsession: loadFromDisk(),\n\tonUpdate(data) {\n\t\tsaveToDisk(data);\n\t},\n});\n```\n\n### lazy construction\n\nif you don't need upfront validation, construct directly — tokens refresh lazily on 401:\n\n```ts\nconst session = new PasswordSession(savedData, { onUpdate, onDelete });\nconst rpc = new Client({ handler: session });\n```\n\n### cleanup\n\ndelete an orphaned session server-side without resuming:\n\n```ts\nawait PasswordSession.delete(savedData);\n```\n\n## callbacks\n\n| callback          | when                                        | session state      |\n| ----------------- | ------------------------------------------- | ------------------ |\n| `onUpdate`        | login succeeds, tokens refresh successfully | active (updated)   |\n| `onUpdateFailure` | token refresh fails transiently (network)   | active (preserved) |\n| `onDelete`        | logout succeeds, session invalidated        | destroyed          |\n| `onDeleteFailure` | logout fails transiently (network)          | active (preserved) |\n\nall callbacks receive `this: PasswordSession` context and must not throw.\n","readmeFilename":""}