@atproto/lex-password-session 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +413 -0
- package/dist/error.d.ts +8 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +14 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lexicons/com/atproto/server/createAccount.d.ts +3 -0
- package/dist/lexicons/com/atproto/server/createAccount.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/createAccount.defs.d.ts +57 -0
- package/dist/lexicons/com/atproto/server/createAccount.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/createAccount.defs.js +43 -0
- package/dist/lexicons/com/atproto/server/createAccount.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/server/createAccount.js +10 -0
- package/dist/lexicons/com/atproto/server/createAccount.js.map +1 -0
- package/dist/lexicons/com/atproto/server/createSession.d.ts +3 -0
- package/dist/lexicons/com/atproto/server/createSession.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/createSession.defs.d.ts +53 -0
- package/dist/lexicons/com/atproto/server/createSession.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/createSession.defs.js +35 -0
- package/dist/lexicons/com/atproto/server/createSession.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/server/createSession.js +10 -0
- package/dist/lexicons/com/atproto/server/createSession.js.map +1 -0
- package/dist/lexicons/com/atproto/server/deleteSession.d.ts +3 -0
- package/dist/lexicons/com/atproto/server/deleteSession.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/deleteSession.defs.d.ts +13 -0
- package/dist/lexicons/com/atproto/server/deleteSession.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/deleteSession.defs.js +19 -0
- package/dist/lexicons/com/atproto/server/deleteSession.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/server/deleteSession.js +10 -0
- package/dist/lexicons/com/atproto/server/deleteSession.js.map +1 -0
- package/dist/lexicons/com/atproto/server/getSession.d.ts +3 -0
- package/dist/lexicons/com/atproto/server/getSession.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/getSession.defs.d.ts +37 -0
- package/dist/lexicons/com/atproto/server/getSession.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/getSession.defs.js +27 -0
- package/dist/lexicons/com/atproto/server/getSession.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/server/getSession.js +10 -0
- package/dist/lexicons/com/atproto/server/getSession.js.map +1 -0
- package/dist/lexicons/com/atproto/server/refreshSession.d.ts +3 -0
- package/dist/lexicons/com/atproto/server/refreshSession.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/refreshSession.defs.d.ts +43 -0
- package/dist/lexicons/com/atproto/server/refreshSession.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server/refreshSession.defs.js +30 -0
- package/dist/lexicons/com/atproto/server/refreshSession.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/server/refreshSession.js +10 -0
- package/dist/lexicons/com/atproto/server/refreshSession.js.map +1 -0
- package/dist/lexicons/com/atproto/server.d.ts +6 -0
- package/dist/lexicons/com/atproto/server.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/server.js +13 -0
- package/dist/lexicons/com/atproto/server.js.map +1 -0
- package/dist/lexicons/com/atproto.d.ts +2 -0
- package/dist/lexicons/com/atproto.d.ts.map +1 -0
- package/dist/lexicons/com/atproto.js +9 -0
- package/dist/lexicons/com/atproto.js.map +1 -0
- package/dist/lexicons/com.d.ts +2 -0
- package/dist/lexicons/com.d.ts.map +1 -0
- package/dist/lexicons/com.js +9 -0
- package/dist/lexicons/com.js.map +1 -0
- package/dist/lexicons/index.d.ts +2 -0
- package/dist/lexicons/index.d.ts.map +1 -0
- package/dist/lexicons/index.js +9 -0
- package/dist/lexicons/index.js.map +1 -0
- package/dist/password-session.d.ts +127 -0
- package/dist/password-session.d.ts.map +1 -0
- package/dist/password-session.js +242 -0
- package/dist/password-session.js.map +1 -0
- package/dist/util.d.ts +5 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +46 -0
- package/dist/util.js.map +1 -0
- package/package.json +52 -0
- package/src/error.ts +14 -0
- package/src/index.ts +2 -0
- package/src/lexicons/com/atproto/server/createAccount.defs.ts +56 -0
- package/src/lexicons/com/atproto/server/createAccount.ts +6 -0
- package/src/lexicons/com/atproto/server/createSession.defs.ts +48 -0
- package/src/lexicons/com/atproto/server/createSession.ts +6 -0
- package/src/lexicons/com/atproto/server/deleteSession.defs.ts +32 -0
- package/src/lexicons/com/atproto/server/deleteSession.ts +6 -0
- package/src/lexicons/com/atproto/server/getSession.defs.ts +36 -0
- package/src/lexicons/com/atproto/server/getSession.ts +6 -0
- package/src/lexicons/com/atproto/server/refreshSession.defs.ts +43 -0
- package/src/lexicons/com/atproto/server/refreshSession.ts +6 -0
- package/src/lexicons/com/atproto/server.ts +9 -0
- package/src/lexicons/com/atproto.ts +5 -0
- package/src/lexicons/com.ts +5 -0
- package/src/lexicons/index.ts +5 -0
- package/src/password-session-utils.test.ts +177 -0
- package/src/password-session.test.ts +416 -0
- package/src/password-session.ts +404 -0
- package/src/util.ts +61 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +7 -0
- package/tsconfig.tests.json +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
# @atproto/lex-password-agent
|
|
2
|
+
|
|
3
|
+
Password-based client authentication for AT Protocol Lexicons. See the [Changelog](./CHANGELOG.md) for version history.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @atproto/lex-password-agent
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
- Session management with automatic token refresh
|
|
10
|
+
- Hooks for persisting and monitoring session state
|
|
11
|
+
- PDS endpoint discovery from DID documents
|
|
12
|
+
- Two-factor authentication support
|
|
13
|
+
|
|
14
|
+
> [!IMPORTANT]
|
|
15
|
+
>
|
|
16
|
+
> This package is currently in **preview**. The API and features are subject to change before the stable release.
|
|
17
|
+
|
|
18
|
+
**What is this?**
|
|
19
|
+
|
|
20
|
+
`@atproto/lex-password-agent` provides a `PasswordAgent` class that implements the `Agent` interface from `@atproto/lex-client`. It handles password-based authentication with AT Protocol services, including:
|
|
21
|
+
|
|
22
|
+
1. Creating sessions with username/password credentials
|
|
23
|
+
2. Automatic token refresh when access tokens expire
|
|
24
|
+
3. Session persistence through lifecycle hooks
|
|
25
|
+
4. Graceful logout with server-side session cleanup
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Client } from '@atproto/lex-client'
|
|
29
|
+
import { PasswordAgent } from '@atproto/lex-password-agent'
|
|
30
|
+
import * as app from './lexicons/app.js'
|
|
31
|
+
|
|
32
|
+
// Login with credentials
|
|
33
|
+
const result = await PasswordAgent.login({
|
|
34
|
+
service: 'https://bsky.social',
|
|
35
|
+
identifier: 'alice.bsky.social',
|
|
36
|
+
password: 'app-password',
|
|
37
|
+
hooks: {
|
|
38
|
+
onRefreshed: (session) => saveToStorage(session),
|
|
39
|
+
onDeleted: (session) => clearStorage(session),
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
if (!result.success) throw result.error
|
|
44
|
+
|
|
45
|
+
const agent = result.value
|
|
46
|
+
const client = new Client(agent)
|
|
47
|
+
|
|
48
|
+
// Make authenticated requests
|
|
49
|
+
const profile = await client.call(app.bsky.actor.getProfile, {
|
|
50
|
+
actor: agent.did,
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
55
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
56
|
+
|
|
57
|
+
- [Quick Start](#quick-start)
|
|
58
|
+
- [PasswordAgent](#passwordagent)
|
|
59
|
+
- [Login](#login)
|
|
60
|
+
- [Two-Factor Authentication](#two-factor-authentication)
|
|
61
|
+
- [Resume Session](#resume-session)
|
|
62
|
+
- [Logout](#logout)
|
|
63
|
+
- [Static Delete](#static-delete)
|
|
64
|
+
- [Session Hooks](#session-hooks)
|
|
65
|
+
- [onRefreshed](#onrefreshed)
|
|
66
|
+
- [onRefreshFailure](#onrefreshfailure)
|
|
67
|
+
- [onDeleted](#ondeleted)
|
|
68
|
+
- [onDeleteFailure](#ondeletefailure)
|
|
69
|
+
- [Session Object](#session-object)
|
|
70
|
+
- [Error Handling](#error-handling)
|
|
71
|
+
- [Using with Client](#using-with-client)
|
|
72
|
+
- [License](#license)
|
|
73
|
+
|
|
74
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
75
|
+
|
|
76
|
+
## Quick Start
|
|
77
|
+
|
|
78
|
+
**1. Install the package**
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install @atproto/lex-password-agent @atproto/lex-client
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**2. Login and make requests**
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { Client } from '@atproto/lex-client'
|
|
88
|
+
import { PasswordAgent } from '@atproto/lex-password-agent'
|
|
89
|
+
|
|
90
|
+
const result = await PasswordAgent.login({
|
|
91
|
+
service: 'https://bsky.social',
|
|
92
|
+
identifier: 'your-handle.bsky.social',
|
|
93
|
+
password: 'your-app-password',
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
if (result.success) {
|
|
97
|
+
const agent = result.value
|
|
98
|
+
const client = new Client(agent)
|
|
99
|
+
|
|
100
|
+
// Make authenticated API calls
|
|
101
|
+
console.log('Logged in as:', agent.did)
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## PasswordAgent
|
|
106
|
+
|
|
107
|
+
The `PasswordAgent` class manages password-based authentication sessions.
|
|
108
|
+
|
|
109
|
+
### Login
|
|
110
|
+
|
|
111
|
+
Create a new session with username and password:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { PasswordAgent } from '@atproto/lex-password-agent'
|
|
115
|
+
|
|
116
|
+
const result = await PasswordAgent.login({
|
|
117
|
+
service: 'https://bsky.social',
|
|
118
|
+
identifier: 'alice.bsky.social', // handle or email
|
|
119
|
+
password: 'app-password',
|
|
120
|
+
hooks: {
|
|
121
|
+
onRefreshed: (session) => {
|
|
122
|
+
// Persist session for later restoration
|
|
123
|
+
localStorage.setItem('session', JSON.stringify(session))
|
|
124
|
+
},
|
|
125
|
+
onDeleted: () => {
|
|
126
|
+
localStorage.removeItem('session')
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
if (result.success) {
|
|
132
|
+
const agent = result.value
|
|
133
|
+
console.log('Logged in as:', agent.did)
|
|
134
|
+
} else {
|
|
135
|
+
console.error('Login failed:', result.error, result.message)
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The `login()` method returns a discriminated union:
|
|
140
|
+
|
|
141
|
+
- On success: `{ success: true, value: PasswordAgent }`
|
|
142
|
+
- On expected errors: `LexRpcResponseError` with `success: false`
|
|
143
|
+
- On unexpected errors: throws the error
|
|
144
|
+
|
|
145
|
+
### Two-Factor Authentication
|
|
146
|
+
|
|
147
|
+
If the account has 2FA enabled, login will return an `AuthFactorTokenRequired` error:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const result = await PasswordAgent.login({
|
|
151
|
+
service: 'https://bsky.social',
|
|
152
|
+
identifier: 'alice.bsky.social',
|
|
153
|
+
password: 'app-password',
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
if (!result.success && result.error === 'AuthFactorTokenRequired') {
|
|
157
|
+
// Prompt user for 2FA code, then retry
|
|
158
|
+
const code = await prompt2FACode()
|
|
159
|
+
|
|
160
|
+
const retryResult = await PasswordAgent.login({
|
|
161
|
+
service: 'https://bsky.social',
|
|
162
|
+
identifier: 'alice.bsky.social',
|
|
163
|
+
password: 'app-password',
|
|
164
|
+
authFactorToken: code,
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Resume Session
|
|
170
|
+
|
|
171
|
+
Restore a previously saved session:
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { PasswordAgent, Session } from '@atproto/lex-password-agent'
|
|
175
|
+
|
|
176
|
+
// Load session from storage
|
|
177
|
+
const savedSession: Session = JSON.parse(localStorage.getItem('session')!)
|
|
178
|
+
|
|
179
|
+
// Resume the session (automatically refreshes tokens)
|
|
180
|
+
const agent = await PasswordAgent.resume(savedSession, {
|
|
181
|
+
hooks: {
|
|
182
|
+
onRefreshed: (session) => {
|
|
183
|
+
localStorage.setItem('session', JSON.stringify(session))
|
|
184
|
+
},
|
|
185
|
+
onDeleted: () => {
|
|
186
|
+
localStorage.removeItem('session')
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
console.log('Session resumed for:', agent.did)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
> [!NOTE]
|
|
195
|
+
>
|
|
196
|
+
> `resume()` automatically calls `refresh()` to ensure the session is valid and tokens are current.
|
|
197
|
+
|
|
198
|
+
### Logout
|
|
199
|
+
|
|
200
|
+
End the session and notify the server:
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
await agent.logout()
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
After logout:
|
|
207
|
+
|
|
208
|
+
- The `onDeleted` hook is called
|
|
209
|
+
- The agent is marked as destroyed (`agent.destroyed === true`)
|
|
210
|
+
- Further requests will throw `'Logged out'`
|
|
211
|
+
|
|
212
|
+
### Static Delete
|
|
213
|
+
|
|
214
|
+
Delete a session without creating an agent instance:
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import { PasswordAgent, Session } from '@atproto/lex-password-agent'
|
|
218
|
+
|
|
219
|
+
const session: Session = JSON.parse(localStorage.getItem('session')!)
|
|
220
|
+
|
|
221
|
+
// Delete the session on the server
|
|
222
|
+
await PasswordAgent.delete(session)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
This is useful for cleanup scenarios where you don't need to make additional requests.
|
|
226
|
+
|
|
227
|
+
## Session Hooks
|
|
228
|
+
|
|
229
|
+
Hooks provide callbacks for session lifecycle events. All hooks receive the agent as `this` context.
|
|
230
|
+
|
|
231
|
+
### onRefreshed
|
|
232
|
+
|
|
233
|
+
Called when tokens are successfully refreshed:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
const result = await PasswordAgent.login({
|
|
237
|
+
service: 'https://bsky.social',
|
|
238
|
+
identifier: 'alice.bsky.social',
|
|
239
|
+
password: 'app-password',
|
|
240
|
+
hooks: {
|
|
241
|
+
onRefreshed(session) {
|
|
242
|
+
// `this` is the PasswordAgent instance
|
|
243
|
+
console.log('Session refreshed for:', this.did)
|
|
244
|
+
|
|
245
|
+
// Persist the updated session
|
|
246
|
+
saveSession(session)
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
})
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
> [!IMPORTANT]
|
|
253
|
+
>
|
|
254
|
+
> Requests are blocked while `onRefreshed` is running. Keep this callback fast to avoid delays.
|
|
255
|
+
|
|
256
|
+
### onRefreshFailure
|
|
257
|
+
|
|
258
|
+
Called when token refresh fails due to transient errors (network issues, server unavailability):
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
hooks: {
|
|
262
|
+
onRefreshFailure(session, error) {
|
|
263
|
+
console.warn('Token refresh failed:', error.message)
|
|
264
|
+
// Session may still be valid - consider retry logic
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### onDeleted
|
|
270
|
+
|
|
271
|
+
Called when the session is terminated (logout or server-side invalidation):
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
hooks: {
|
|
275
|
+
onDeleted(session) {
|
|
276
|
+
console.log('Session ended for:', session.data.did)
|
|
277
|
+
clearPersistedSession(session.data.did)
|
|
278
|
+
redirectToLogin()
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### onDeleteFailure
|
|
284
|
+
|
|
285
|
+
Called when logout fails due to transient errors:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
hooks: {
|
|
289
|
+
onDeleteFailure(session, error) {
|
|
290
|
+
console.error('Logout failed:', error.message)
|
|
291
|
+
// Consider queuing for retry to avoid orphaned sessions
|
|
292
|
+
queueLogoutRetry(session)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
> [!WARNING]
|
|
298
|
+
>
|
|
299
|
+
> Ignoring delete failures can leave sessions active on the server. Implement retry logic for security-sensitive applications.
|
|
300
|
+
|
|
301
|
+
## Session Object
|
|
302
|
+
|
|
303
|
+
The `Session` type contains all data needed to authenticate and restore sessions:
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
type Session = {
|
|
307
|
+
// Session credentials and user info from createSession response
|
|
308
|
+
data: {
|
|
309
|
+
accessJwt: string
|
|
310
|
+
refreshJwt: string
|
|
311
|
+
did: string
|
|
312
|
+
handle: string
|
|
313
|
+
email?: string
|
|
314
|
+
emailConfirmed?: boolean
|
|
315
|
+
didDoc?: object
|
|
316
|
+
// ... other fields from createSession
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// When tokens were last refreshed
|
|
320
|
+
refreshedAt: string // ISO 8601 datetime
|
|
321
|
+
|
|
322
|
+
// PDS URL extracted from DID document (for routing requests)
|
|
323
|
+
pdsUrl: string | null
|
|
324
|
+
|
|
325
|
+
// Original service URL used for login
|
|
326
|
+
service: string
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Error Handling
|
|
331
|
+
|
|
332
|
+
Login errors are returned as `LexRpcResponseError` objects:
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
const result = await PasswordAgent.login({
|
|
336
|
+
service: 'https://bsky.social',
|
|
337
|
+
identifier: 'alice.bsky.social',
|
|
338
|
+
password: 'wrong-password',
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
if (!result.success) {
|
|
342
|
+
switch (result.error) {
|
|
343
|
+
case 'AuthenticationRequired':
|
|
344
|
+
console.error('Invalid credentials')
|
|
345
|
+
break
|
|
346
|
+
case 'AuthFactorTokenRequired':
|
|
347
|
+
console.error('2FA required')
|
|
348
|
+
break
|
|
349
|
+
case 'AccountTakedown':
|
|
350
|
+
console.error('Account has been suspended')
|
|
351
|
+
break
|
|
352
|
+
default:
|
|
353
|
+
console.error('Login failed:', result.message)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Common error codes:
|
|
359
|
+
|
|
360
|
+
| Error Code | Description |
|
|
361
|
+
| ------------------------- | ------------------------------ |
|
|
362
|
+
| `AuthenticationRequired` | Invalid username or password |
|
|
363
|
+
| `AuthFactorTokenRequired` | 2FA code needed |
|
|
364
|
+
| `AccountTakedown` | Account suspended |
|
|
365
|
+
| `ExpiredToken` | Token has expired (on refresh) |
|
|
366
|
+
| `InvalidToken` | Token is invalid |
|
|
367
|
+
|
|
368
|
+
## Using with Client
|
|
369
|
+
|
|
370
|
+
The `PasswordAgent` implements the `Agent` interface and can be used directly with `Client`:
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
import { Client } from '@atproto/lex-client'
|
|
374
|
+
import { PasswordAgent } from '@atproto/lex-password-agent'
|
|
375
|
+
import * as app from './lexicons/app.js'
|
|
376
|
+
|
|
377
|
+
const result = await PasswordAgent.login({
|
|
378
|
+
service: 'https://bsky.social',
|
|
379
|
+
identifier: 'alice.bsky.social',
|
|
380
|
+
password: 'app-password',
|
|
381
|
+
})
|
|
382
|
+
|
|
383
|
+
if (result.success) {
|
|
384
|
+
const client = new Client(result.value)
|
|
385
|
+
|
|
386
|
+
// The client automatically uses the agent for authentication
|
|
387
|
+
const profile = await client.call(app.bsky.actor.getProfile, {
|
|
388
|
+
actor: client.assertDid,
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
// Tokens are automatically refreshed when expired
|
|
392
|
+
const timeline = await client.call(app.bsky.feed.getTimeline, {
|
|
393
|
+
limit: 50,
|
|
394
|
+
})
|
|
395
|
+
|
|
396
|
+
// Create records
|
|
397
|
+
await client.create(app.bsky.feed.post, {
|
|
398
|
+
text: 'Hello from lex-password-agent!',
|
|
399
|
+
createdAt: new Date().toISOString(),
|
|
400
|
+
})
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
The agent handles:
|
|
405
|
+
|
|
406
|
+
- Adding `Authorization` headers to requests
|
|
407
|
+
- Detecting expired tokens (401 responses or `ExpiredToken` errors)
|
|
408
|
+
- Automatically refreshing tokens and retrying failed requests
|
|
409
|
+
- Routing requests to the correct PDS based on DID document
|
|
410
|
+
|
|
411
|
+
## License
|
|
412
|
+
|
|
413
|
+
MIT or Apache2
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LexError, LexRpcResponseError } from '@atproto/lex-client';
|
|
2
|
+
import { com } from './lexicons';
|
|
3
|
+
export declare class LexAuthFactorError extends LexError {
|
|
4
|
+
readonly response: LexRpcResponseError<typeof com.atproto.server.createSession.main>;
|
|
5
|
+
name: string;
|
|
6
|
+
constructor(response: LexRpcResponseError<typeof com.atproto.server.createSession.main>);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAEhC,qBAAa,kBAAmB,SAAQ,QAAQ;IAI5C,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CACpC,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAC7C;IALH,IAAI,SAAuB;gBAGhB,QAAQ,EAAE,mBAAmB,CACpC,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAC7C;CAIJ"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LexAuthFactorError = void 0;
|
|
4
|
+
const lex_client_1 = require("@atproto/lex-client");
|
|
5
|
+
class LexAuthFactorError extends lex_client_1.LexError {
|
|
6
|
+
response;
|
|
7
|
+
name = 'LexAuthFactorError';
|
|
8
|
+
constructor(response) {
|
|
9
|
+
super(response.error, response.message, { cause: response.reason });
|
|
10
|
+
this.response = response;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.LexAuthFactorError = LexAuthFactorError;
|
|
14
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAAA,oDAAmE;AAGnE,MAAa,kBAAmB,SAAQ,qBAAQ;IAInC;IAHX,IAAI,GAAG,oBAAoB,CAAA;IAE3B,YACW,QAER;QAED,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;QAJ1D,aAAQ,GAAR,QAAQ,CAEhB;IAGH,CAAC;CACF;AAVD,gDAUC","sourcesContent":["import { LexError, LexRpcResponseError } from '@atproto/lex-client'\nimport { com } from './lexicons'\n\nexport class LexAuthFactorError extends LexError {\n name = 'LexAuthFactorError'\n\n constructor(\n readonly response: LexRpcResponseError<\n typeof com.atproto.server.createSession.main\n >,\n ) {\n super(response.error, response.message, { cause: response.reason })\n }\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./error.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./password-session.js"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,gEAAqC","sourcesContent":["export * from './error.js'\nexport * from './password-session.js'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAccount.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/server/createAccount.ts"],"names":[],"mappings":"AAIA,cAAc,yBAAyB,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { l } from '@atproto/lex-schema';
|
|
2
|
+
declare const $nsid = "com.atproto.server.createAccount";
|
|
3
|
+
export { $nsid };
|
|
4
|
+
/** Create an account. Implemented by PDS. */
|
|
5
|
+
declare const main: l.Procedure<"com.atproto.server.createAccount", l.ParamsSchema<{}>, l.Payload<"application/json", l.ObjectSchema<{
|
|
6
|
+
readonly email: l.OptionalSchema<string>;
|
|
7
|
+
readonly handle: l.StringSchema<{
|
|
8
|
+
readonly format: "handle";
|
|
9
|
+
}>;
|
|
10
|
+
readonly did: l.OptionalSchema<`did:${string}:${string}`>;
|
|
11
|
+
readonly inviteCode: l.OptionalSchema<string>;
|
|
12
|
+
readonly verificationCode: l.OptionalSchema<string>;
|
|
13
|
+
readonly verificationPhone: l.OptionalSchema<string>;
|
|
14
|
+
readonly password: l.OptionalSchema<string>;
|
|
15
|
+
readonly recoveryKey: l.OptionalSchema<string>;
|
|
16
|
+
readonly plcOp: l.OptionalSchema<import("@atproto/lex-client").LexMap>;
|
|
17
|
+
}>>, l.Payload<"application/json", l.ObjectSchema<{
|
|
18
|
+
readonly accessJwt: l.StringSchema<{}>;
|
|
19
|
+
readonly refreshJwt: l.StringSchema<{}>;
|
|
20
|
+
readonly handle: l.StringSchema<{
|
|
21
|
+
readonly format: "handle";
|
|
22
|
+
}>;
|
|
23
|
+
readonly did: l.StringSchema<{
|
|
24
|
+
readonly format: "did";
|
|
25
|
+
}>;
|
|
26
|
+
readonly didDoc: l.OptionalSchema<import("@atproto/lex-client").LexMap>;
|
|
27
|
+
}>>, readonly ["InvalidHandle", "InvalidPassword", "InvalidInviteCode", "HandleNotAvailable", "UnsupportedDomain", "UnresolvableDid", "IncompatibleDidDoc"]>;
|
|
28
|
+
export { main };
|
|
29
|
+
export type Params = l.InferMethodParams<typeof main>;
|
|
30
|
+
export type Input = l.InferMethodInput<typeof main>;
|
|
31
|
+
export type InputBody = l.InferMethodInputBody<typeof main>;
|
|
32
|
+
export type Output = l.InferMethodOutput<typeof main>;
|
|
33
|
+
export type OutputBody = l.InferMethodOutputBody<typeof main>;
|
|
34
|
+
export declare const $lxm: "com.atproto.server.createAccount", $params: l.ParamsSchema<{}>, $input: l.Payload<"application/json", l.ObjectSchema<{
|
|
35
|
+
readonly email: l.OptionalSchema<string>;
|
|
36
|
+
readonly handle: l.StringSchema<{
|
|
37
|
+
readonly format: "handle";
|
|
38
|
+
}>;
|
|
39
|
+
readonly did: l.OptionalSchema<`did:${string}:${string}`>;
|
|
40
|
+
readonly inviteCode: l.OptionalSchema<string>;
|
|
41
|
+
readonly verificationCode: l.OptionalSchema<string>;
|
|
42
|
+
readonly verificationPhone: l.OptionalSchema<string>;
|
|
43
|
+
readonly password: l.OptionalSchema<string>;
|
|
44
|
+
readonly recoveryKey: l.OptionalSchema<string>;
|
|
45
|
+
readonly plcOp: l.OptionalSchema<import("@atproto/lex-client").LexMap>;
|
|
46
|
+
}>>, $output: l.Payload<"application/json", l.ObjectSchema<{
|
|
47
|
+
readonly accessJwt: l.StringSchema<{}>;
|
|
48
|
+
readonly refreshJwt: l.StringSchema<{}>;
|
|
49
|
+
readonly handle: l.StringSchema<{
|
|
50
|
+
readonly format: "handle";
|
|
51
|
+
}>;
|
|
52
|
+
readonly did: l.StringSchema<{
|
|
53
|
+
readonly format: "did";
|
|
54
|
+
}>;
|
|
55
|
+
readonly didDoc: l.OptionalSchema<import("@atproto/lex-client").LexMap>;
|
|
56
|
+
}>>;
|
|
57
|
+
//# sourceMappingURL=createAccount.defs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAccount.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/server/createAccount.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,QAAA,MAAM,KAAK,qCAAqC,CAAA;AAEhD,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,6CAA6C;AAC7C,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;4JAgCP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,gBAAgB,CAAC,OAAO,IAAI,CAAC,CAAA;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,oBAAoB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC3D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,OAAO,IAAI,CAAC,CAAA;AAE7D,eAAO,MAAM,IAAI,oCAA0B,EACzC,OAAO,oBAAgC,EACvC,MAAM;;;;;;;;;;;;GAA2B,EACjC,OAAO;;;;;;;;;;GAA4B,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.$output = exports.$input = exports.$params = exports.$lxm = exports.main = exports.$nsid = void 0;
|
|
7
|
+
const lex_schema_1 = require("@atproto/lex-schema");
|
|
8
|
+
const $nsid = 'com.atproto.server.createAccount';
|
|
9
|
+
exports.$nsid = $nsid;
|
|
10
|
+
/** Create an account. Implemented by PDS. */
|
|
11
|
+
const main =
|
|
12
|
+
/*#__PURE__*/
|
|
13
|
+
lex_schema_1.l.procedure($nsid,
|
|
14
|
+
/*#__PURE__*/ lex_schema_1.l.params(),
|
|
15
|
+
/*#__PURE__*/ lex_schema_1.l.jsonPayload({
|
|
16
|
+
email: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string()),
|
|
17
|
+
handle: /*#__PURE__*/ lex_schema_1.l.string({ format: 'handle' }),
|
|
18
|
+
did: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string({ format: 'did' })),
|
|
19
|
+
inviteCode: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string()),
|
|
20
|
+
verificationCode: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string()),
|
|
21
|
+
verificationPhone: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string()),
|
|
22
|
+
password: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string()),
|
|
23
|
+
recoveryKey: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string()),
|
|
24
|
+
plcOp: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.unknownObject()),
|
|
25
|
+
}),
|
|
26
|
+
/*#__PURE__*/ lex_schema_1.l.jsonPayload({
|
|
27
|
+
accessJwt: /*#__PURE__*/ lex_schema_1.l.string(),
|
|
28
|
+
refreshJwt: /*#__PURE__*/ lex_schema_1.l.string(),
|
|
29
|
+
handle: /*#__PURE__*/ lex_schema_1.l.string({ format: 'handle' }),
|
|
30
|
+
did: /*#__PURE__*/ lex_schema_1.l.string({ format: 'did' }),
|
|
31
|
+
didDoc: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.unknownObject()),
|
|
32
|
+
}), [
|
|
33
|
+
'InvalidHandle',
|
|
34
|
+
'InvalidPassword',
|
|
35
|
+
'InvalidInviteCode',
|
|
36
|
+
'HandleNotAvailable',
|
|
37
|
+
'UnsupportedDomain',
|
|
38
|
+
'UnresolvableDid',
|
|
39
|
+
'IncompatibleDidDoc',
|
|
40
|
+
]);
|
|
41
|
+
exports.main = main;
|
|
42
|
+
exports.$lxm = main.nsid, exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
|
|
43
|
+
//# sourceMappingURL=createAccount.defs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAccount.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/server/createAccount.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAAuC;AAEvC,MAAM,KAAK,GAAG,kCAAkC,CAAA;AAEvC,sBAAK;AAEd,6CAA6C;AAC7C,MAAM,IAAI;AACR,aAAa;AACb,cAAC,CAAC,SAAS,CACT,KAAK;AACL,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE;AACxB,aAAa,CAAC,cAAC,CAAC,WAAW,CAAC;IAC1B,KAAK,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;IACzD,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACpD,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;IAC9D,gBAAgB,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;IACpE,iBAAiB,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;IACrE,QAAQ,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;IAC5D,WAAW,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;IAC/D,KAAK,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,aAAa,EAAE,CAAC;CACjE,CAAC;AACF,aAAa,CAAC,cAAC,CAAC,WAAW,CAAC;IAC1B,SAAS,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE;IACnC,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE;IACpC,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACpD,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC9C,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,aAAa,EAAE,CAAC;CAClE,CAAC,EACF;IACE,eAAe;IACf,iBAAiB;IACjB,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;IACnB,iBAAiB;IACjB,oBAAoB;CACrB,CACF,CAAA;AACM,oBAAI;AAQA,QAAA,IAAI,GAAiB,IAAI,CAAC,IAAI,EACzC,QAAA,OAAO,GAAiB,IAAI,CAAC,UAAU,EACvC,QAAA,MAAM,GAAiB,IAAI,CAAC,KAAK,EACjC,QAAA,OAAO,GAAiB,IAAI,CAAC,MAAM,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\n\nconst $nsid = 'com.atproto.server.createAccount'\n\nexport { $nsid }\n\n/** Create an account. Implemented by PDS. */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params(),\n /*#__PURE__*/ l.jsonPayload({\n email: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n handle: /*#__PURE__*/ l.string({ format: 'handle' }),\n did: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string({ format: 'did' })),\n inviteCode: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n verificationCode: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n verificationPhone: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n password: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n recoveryKey: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n plcOp: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.unknownObject()),\n }),\n /*#__PURE__*/ l.jsonPayload({\n accessJwt: /*#__PURE__*/ l.string(),\n refreshJwt: /*#__PURE__*/ l.string(),\n handle: /*#__PURE__*/ l.string({ format: 'handle' }),\n did: /*#__PURE__*/ l.string({ format: 'did' }),\n didDoc: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.unknownObject()),\n }),\n [\n 'InvalidHandle',\n 'InvalidPassword',\n 'InvalidInviteCode',\n 'HandleNotAvailable',\n 'UnsupportedDomain',\n 'UnresolvableDid',\n 'IncompatibleDidDoc',\n ],\n )\nexport { main }\n\nexport type Params = l.InferMethodParams<typeof main>\nexport type Input = l.InferMethodInput<typeof main>\nexport type InputBody = l.InferMethodInputBody<typeof main>\nexport type Output = l.InferMethodOutput<typeof main>\nexport type OutputBody = l.InferMethodOutputBody<typeof main>\n\nexport const $lxm = /*#__PURE__*/ main.nsid,\n $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.$defs = void 0;
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
tslib_1.__exportStar(require("./createAccount.defs.js"), exports);
|
|
9
|
+
exports.$defs = tslib_1.__importStar(require("./createAccount.defs.js"));
|
|
10
|
+
//# sourceMappingURL=createAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/server/createAccount.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,kEAAuC;AACvC,yEAAgD","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * from './createAccount.defs.js'\nexport * as $defs from './createAccount.defs.js'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/server/createSession.ts"],"names":[],"mappings":"AAIA,cAAc,yBAAyB,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { l } from '@atproto/lex-schema';
|
|
2
|
+
declare const $nsid = "com.atproto.server.createSession";
|
|
3
|
+
export { $nsid };
|
|
4
|
+
/** Create an authentication session. */
|
|
5
|
+
declare const main: l.Procedure<"com.atproto.server.createSession", l.ParamsSchema<{}>, l.Payload<"application/json", l.ObjectSchema<{
|
|
6
|
+
readonly identifier: l.StringSchema<{}>;
|
|
7
|
+
readonly password: l.StringSchema<{}>;
|
|
8
|
+
readonly authFactorToken: l.OptionalSchema<string>;
|
|
9
|
+
readonly allowTakendown: l.OptionalSchema<boolean>;
|
|
10
|
+
}>>, l.Payload<"application/json", l.ObjectSchema<{
|
|
11
|
+
readonly accessJwt: l.StringSchema<{}>;
|
|
12
|
+
readonly refreshJwt: l.StringSchema<{}>;
|
|
13
|
+
readonly handle: l.StringSchema<{
|
|
14
|
+
readonly format: "handle";
|
|
15
|
+
}>;
|
|
16
|
+
readonly did: l.StringSchema<{
|
|
17
|
+
readonly format: "did";
|
|
18
|
+
}>;
|
|
19
|
+
readonly didDoc: l.OptionalSchema<import("@atproto/lex-client").LexMap>;
|
|
20
|
+
readonly email: l.OptionalSchema<string>;
|
|
21
|
+
readonly emailConfirmed: l.OptionalSchema<boolean>;
|
|
22
|
+
readonly emailAuthFactor: l.OptionalSchema<boolean>;
|
|
23
|
+
readonly active: l.OptionalSchema<boolean>;
|
|
24
|
+
readonly status: l.OptionalSchema<string>;
|
|
25
|
+
}>>, readonly ["AccountTakedown", "AuthFactorTokenRequired"]>;
|
|
26
|
+
export { main };
|
|
27
|
+
export type Params = l.InferMethodParams<typeof main>;
|
|
28
|
+
export type Input = l.InferMethodInput<typeof main>;
|
|
29
|
+
export type InputBody = l.InferMethodInputBody<typeof main>;
|
|
30
|
+
export type Output = l.InferMethodOutput<typeof main>;
|
|
31
|
+
export type OutputBody = l.InferMethodOutputBody<typeof main>;
|
|
32
|
+
export declare const $lxm: "com.atproto.server.createSession", $params: l.ParamsSchema<{}>, $input: l.Payload<"application/json", l.ObjectSchema<{
|
|
33
|
+
readonly identifier: l.StringSchema<{}>;
|
|
34
|
+
readonly password: l.StringSchema<{}>;
|
|
35
|
+
readonly authFactorToken: l.OptionalSchema<string>;
|
|
36
|
+
readonly allowTakendown: l.OptionalSchema<boolean>;
|
|
37
|
+
}>>, $output: l.Payload<"application/json", l.ObjectSchema<{
|
|
38
|
+
readonly accessJwt: l.StringSchema<{}>;
|
|
39
|
+
readonly refreshJwt: l.StringSchema<{}>;
|
|
40
|
+
readonly handle: l.StringSchema<{
|
|
41
|
+
readonly format: "handle";
|
|
42
|
+
}>;
|
|
43
|
+
readonly did: l.StringSchema<{
|
|
44
|
+
readonly format: "did";
|
|
45
|
+
}>;
|
|
46
|
+
readonly didDoc: l.OptionalSchema<import("@atproto/lex-client").LexMap>;
|
|
47
|
+
readonly email: l.OptionalSchema<string>;
|
|
48
|
+
readonly emailConfirmed: l.OptionalSchema<boolean>;
|
|
49
|
+
readonly emailAuthFactor: l.OptionalSchema<boolean>;
|
|
50
|
+
readonly active: l.OptionalSchema<boolean>;
|
|
51
|
+
readonly status: l.OptionalSchema<string>;
|
|
52
|
+
}>>;
|
|
53
|
+
//# sourceMappingURL=createSession.defs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSession.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/server/createSession.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,QAAA,MAAM,KAAK,qCAAqC,CAAA;AAEhD,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,wCAAwC;AACxC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;6DAwBP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,gBAAgB,CAAC,OAAO,IAAI,CAAC,CAAA;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,oBAAoB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC3D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,OAAO,IAAI,CAAC,CAAA;AAE7D,eAAO,MAAM,IAAI,oCAA0B,EACzC,OAAO,oBAAgC,EACvC,MAAM;;;;;GAA2B,EACjC,OAAO;;;;;;;;;;;;;;;GAA4B,CAAA"}
|