@atproto/api 0.18.8 → 0.18.9
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/CHANGELOG.md +11 -0
- package/dist/atp-agent.d.ts +8 -2
- package/dist/atp-agent.d.ts.map +1 -1
- package/dist/atp-agent.js +115 -80
- package/dist/atp-agent.js.map +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +6 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/lexicons.d.ts +44 -8
- package/dist/client/lexicons.d.ts.map +1 -1
- package/dist/client/lexicons.js +27 -4
- package/dist/client/lexicons.js.map +1 -1
- package/dist/client/types/com/atproto/server/deleteSession.d.ts +7 -1
- package/dist/client/types/com/atproto/server/deleteSession.d.ts.map +1 -1
- package/dist/client/types/com/atproto/server/deleteSession.js +23 -0
- package/dist/client/types/com/atproto/server/deleteSession.js.map +1 -1
- package/dist/client/types/com/atproto/server/getSession.d.ts +3 -3
- package/dist/client/types/com/atproto/server/getSession.d.ts.map +1 -1
- package/dist/client/types/com/atproto/server/getSession.js.map +1 -1
- package/dist/client/types/com/atproto/server/refreshSession.d.ts +9 -0
- package/dist/client/types/com/atproto/server/refreshSession.d.ts.map +1 -1
- package/dist/client/types/com/atproto/server/refreshSession.js +17 -1
- package/dist/client/types/com/atproto/server/refreshSession.js.map +1 -1
- package/package.json +2 -2
- package/src/atp-agent.ts +147 -99
- package/src/client/index.ts +5 -6
- package/src/client/lexicons.ts +28 -4
- package/src/client/types/com/atproto/server/deleteSession.ts +17 -0
- package/src/client/types/com/atproto/server/getSession.ts +1 -1
- package/src/client/types/com/atproto/server/refreshSession.ts +17 -0
- package/tests/dispatcher.test.ts +13 -10
|
@@ -24,6 +24,9 @@ export interface OutputSchema {
|
|
|
24
24
|
handle: string
|
|
25
25
|
did: string
|
|
26
26
|
didDoc?: { [_ in string]: unknown }
|
|
27
|
+
email?: string
|
|
28
|
+
emailConfirmed?: boolean
|
|
29
|
+
emailAuthFactor?: boolean
|
|
27
30
|
active?: boolean
|
|
28
31
|
/** Hosting status of the account. If not specified, then assume 'active'. */
|
|
29
32
|
status?: 'takendown' | 'suspended' | 'deactivated' | (string & {})
|
|
@@ -47,9 +50,23 @@ export class AccountTakedownError extends XRPCError {
|
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
export class InvalidTokenError extends XRPCError {
|
|
54
|
+
constructor(src: XRPCError) {
|
|
55
|
+
super(src.status, src.error, src.message, src.headers, { cause: src })
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class ExpiredTokenError extends XRPCError {
|
|
60
|
+
constructor(src: XRPCError) {
|
|
61
|
+
super(src.status, src.error, src.message, src.headers, { cause: src })
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
export function toKnownErr(e: any) {
|
|
51
66
|
if (e instanceof XRPCError) {
|
|
52
67
|
if (e.error === 'AccountTakedown') return new AccountTakedownError(e)
|
|
68
|
+
if (e.error === 'InvalidToken') return new InvalidTokenError(e)
|
|
69
|
+
if (e.error === 'ExpiredToken') return new ExpiredTokenError(e)
|
|
53
70
|
}
|
|
54
71
|
|
|
55
72
|
return e
|
package/tests/dispatcher.test.ts
CHANGED
|
@@ -355,12 +355,13 @@ describe('AtpAgent', () => {
|
|
|
355
355
|
expect(typeof sessions[1]).toEqual('undefined')
|
|
356
356
|
})
|
|
357
357
|
|
|
358
|
-
it('does not modify
|
|
359
|
-
const events: string[] = []
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
358
|
+
it('does not modify the session on a failed refresh', async () => {
|
|
359
|
+
const events: { event: string; session: AtpSessionData | undefined }[] = []
|
|
360
|
+
const persistSession = (
|
|
361
|
+
event: AtpSessionEvent,
|
|
362
|
+
session?: AtpSessionData,
|
|
363
|
+
) => {
|
|
364
|
+
events.push({ event, session: session && { ...session } })
|
|
364
365
|
}
|
|
365
366
|
|
|
366
367
|
const agent = new AtpAgent({ service: network.pds.url, persistSession })
|
|
@@ -407,10 +408,12 @@ describe('AtpAgent', () => {
|
|
|
407
408
|
// still has session because it wasn't invalidated
|
|
408
409
|
expect(agent.hasSession).toEqual(true)
|
|
409
410
|
|
|
410
|
-
expect(events.length).toEqual(
|
|
411
|
-
|
|
412
|
-
expect(
|
|
413
|
-
expect(
|
|
411
|
+
expect(events.length).toEqual(2)
|
|
412
|
+
|
|
413
|
+
expect(events[0].event).toEqual('create')
|
|
414
|
+
expect(events[0].session?.accessJwt).toEqual(origAccessJwt)
|
|
415
|
+
expect(events[1].event).toEqual('network-error')
|
|
416
|
+
expect(events[1].session?.accessJwt).toEqual(origAccessJwt)
|
|
414
417
|
})
|
|
415
418
|
|
|
416
419
|
describe('createAccount', () => {
|