@atproto/api 0.18.8 → 0.18.10
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 +17 -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 +60 -8
- package/dist/client/lexicons.d.ts.map +1 -1
- package/dist/client/lexicons.js +35 -4
- package/dist/client/lexicons.js.map +1 -1
- package/dist/client/types/app/bsky/unspecced/getSuggestedUsers.d.ts +2 -0
- package/dist/client/types/app/bsky/unspecced/getSuggestedUsers.d.ts.map +1 -1
- package/dist/client/types/app/bsky/unspecced/getSuggestedUsers.js.map +1 -1
- package/dist/client/types/app/bsky/unspecced/getSuggestedUsersSkeleton.d.ts +2 -0
- package/dist/client/types/app/bsky/unspecced/getSuggestedUsersSkeleton.d.ts.map +1 -1
- package/dist/client/types/app/bsky/unspecced/getSuggestedUsersSkeleton.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 +38 -4
- package/src/client/types/app/bsky/unspecced/getSuggestedUsers.ts +2 -0
- package/src/client/types/app/bsky/unspecced/getSuggestedUsersSkeleton.ts +2 -0
- 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
- package/tsconfig.tests.tsbuildinfo +0 -1
package/src/client/lexicons.ts
CHANGED
|
@@ -8012,6 +8012,11 @@ export const schemaDict = {
|
|
|
8012
8012
|
ref: 'lex:app.bsky.actor.defs#profileView',
|
|
8013
8013
|
},
|
|
8014
8014
|
},
|
|
8015
|
+
recId: {
|
|
8016
|
+
type: 'integer',
|
|
8017
|
+
description:
|
|
8018
|
+
'Snowflake for this recommendation, use when submitting recommendation events.',
|
|
8019
|
+
},
|
|
8015
8020
|
},
|
|
8016
8021
|
},
|
|
8017
8022
|
},
|
|
@@ -8060,6 +8065,11 @@ export const schemaDict = {
|
|
|
8060
8065
|
format: 'did',
|
|
8061
8066
|
},
|
|
8062
8067
|
},
|
|
8068
|
+
recId: {
|
|
8069
|
+
type: 'integer',
|
|
8070
|
+
description:
|
|
8071
|
+
'Snowflake for this recommendation, use when submitting recommendation events.',
|
|
8072
|
+
},
|
|
8063
8073
|
},
|
|
8064
8074
|
},
|
|
8065
8075
|
},
|
|
@@ -13019,7 +13029,16 @@ export const schemaDict = {
|
|
|
13019
13029
|
defs: {
|
|
13020
13030
|
main: {
|
|
13021
13031
|
type: 'procedure',
|
|
13022
|
-
description:
|
|
13032
|
+
description:
|
|
13033
|
+
"Delete the current session. Requires auth using the 'refreshJwt' (not the 'accessJwt').",
|
|
13034
|
+
errors: [
|
|
13035
|
+
{
|
|
13036
|
+
name: 'InvalidToken',
|
|
13037
|
+
},
|
|
13038
|
+
{
|
|
13039
|
+
name: 'ExpiredToken',
|
|
13040
|
+
},
|
|
13041
|
+
],
|
|
13023
13042
|
},
|
|
13024
13043
|
},
|
|
13025
13044
|
},
|
|
@@ -13218,6 +13237,9 @@ export const schemaDict = {
|
|
|
13218
13237
|
type: 'string',
|
|
13219
13238
|
format: 'did',
|
|
13220
13239
|
},
|
|
13240
|
+
didDoc: {
|
|
13241
|
+
type: 'unknown',
|
|
13242
|
+
},
|
|
13221
13243
|
email: {
|
|
13222
13244
|
type: 'string',
|
|
13223
13245
|
},
|
|
@@ -13227,9 +13249,6 @@ export const schemaDict = {
|
|
|
13227
13249
|
emailAuthFactor: {
|
|
13228
13250
|
type: 'boolean',
|
|
13229
13251
|
},
|
|
13230
|
-
didDoc: {
|
|
13231
|
-
type: 'unknown',
|
|
13232
|
-
},
|
|
13233
13252
|
active: {
|
|
13234
13253
|
type: 'boolean',
|
|
13235
13254
|
},
|
|
@@ -13323,6 +13342,15 @@ export const schemaDict = {
|
|
|
13323
13342
|
didDoc: {
|
|
13324
13343
|
type: 'unknown',
|
|
13325
13344
|
},
|
|
13345
|
+
email: {
|
|
13346
|
+
type: 'string',
|
|
13347
|
+
},
|
|
13348
|
+
emailConfirmed: {
|
|
13349
|
+
type: 'boolean',
|
|
13350
|
+
},
|
|
13351
|
+
emailAuthFactor: {
|
|
13352
|
+
type: 'boolean',
|
|
13353
|
+
},
|
|
13326
13354
|
active: {
|
|
13327
13355
|
type: 'boolean',
|
|
13328
13356
|
},
|
|
@@ -13339,6 +13367,12 @@ export const schemaDict = {
|
|
|
13339
13367
|
{
|
|
13340
13368
|
name: 'AccountTakedown',
|
|
13341
13369
|
},
|
|
13370
|
+
{
|
|
13371
|
+
name: 'InvalidToken',
|
|
13372
|
+
},
|
|
13373
|
+
{
|
|
13374
|
+
name: 'ExpiredToken',
|
|
13375
|
+
},
|
|
13342
13376
|
],
|
|
13343
13377
|
},
|
|
13344
13378
|
},
|
|
@@ -25,6 +25,8 @@ export type InputSchema = undefined
|
|
|
25
25
|
|
|
26
26
|
export interface OutputSchema {
|
|
27
27
|
actors: AppBskyActorDefs.ProfileView[]
|
|
28
|
+
/** Snowflake for this recommendation, use when submitting recommendation events. */
|
|
29
|
+
recId?: number
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export interface CallOptions {
|
|
@@ -29,6 +29,23 @@ export interface Response {
|
|
|
29
29
|
headers: HeadersMap
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
export class InvalidTokenError extends XRPCError {
|
|
33
|
+
constructor(src: XRPCError) {
|
|
34
|
+
super(src.status, src.error, src.message, src.headers, { cause: src })
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class ExpiredTokenError extends XRPCError {
|
|
39
|
+
constructor(src: XRPCError) {
|
|
40
|
+
super(src.status, src.error, src.message, src.headers, { cause: src })
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
32
44
|
export function toKnownErr(e: any) {
|
|
45
|
+
if (e instanceof XRPCError) {
|
|
46
|
+
if (e.error === 'InvalidToken') return new InvalidTokenError(e)
|
|
47
|
+
if (e.error === 'ExpiredToken') return new ExpiredTokenError(e)
|
|
48
|
+
}
|
|
49
|
+
|
|
33
50
|
return e
|
|
34
51
|
}
|
|
@@ -21,10 +21,10 @@ export type InputSchema = undefined
|
|
|
21
21
|
export interface OutputSchema {
|
|
22
22
|
handle: string
|
|
23
23
|
did: string
|
|
24
|
+
didDoc?: { [_ in string]: unknown }
|
|
24
25
|
email?: string
|
|
25
26
|
emailConfirmed?: boolean
|
|
26
27
|
emailAuthFactor?: boolean
|
|
27
|
-
didDoc?: { [_ in string]: unknown }
|
|
28
28
|
active?: boolean
|
|
29
29
|
/** If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted. */
|
|
30
30
|
status?: 'takendown' | 'suspended' | 'deactivated' | (string & {})
|
|
@@ -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', () => {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./tests/atp-agent.test.ts","./tests/dispatcher.test.ts","./tests/errors.test.ts","./tests/moderation-behaviors.test.ts","./tests/moderation-custom-labels.test.ts","./tests/moderation-mutewords.test.ts","./tests/moderation-prefs.test.ts","./tests/moderation-quoteposts.test.ts","./tests/moderation.test.ts","./tests/rich-text-detection.test.ts","./tests/rich-text-sanitization.test.ts","./tests/rich-text.test.ts","./tests/util/echo-server.ts","./tests/util/moderation-behavior.ts"],"version":"5.8.3"}
|