@atproto/api 0.6.22 → 0.6.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/api",
3
- "version": "0.6.22",
3
+ "version": "0.6.23",
4
4
  "license": "MIT",
5
5
  "description": "Client library for atproto and Bluesky",
6
6
  "keywords": [
@@ -28,7 +28,7 @@
28
28
  "devDependencies": {
29
29
  "common-tags": "^1.8.2",
30
30
  "@atproto/lex-cli": "^0.2.4",
31
- "@atproto/dev-env": "^0.2.13"
31
+ "@atproto/dev-env": "^0.2.14"
32
32
  },
33
33
  "scripts": {
34
34
  "codegen": "pnpm docgen && node ./scripts/generate-code.mjs && lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
package/src/agent.ts CHANGED
@@ -165,6 +165,7 @@ export class AtpAgent {
165
165
  this.session.email = res.data.email
166
166
  this.session.handle = res.data.handle
167
167
  this.session.emailConfirmed = res.data.emailConfirmed
168
+ this._updateApiEndpoint(res.data.didDoc)
168
169
  return res
169
170
  } catch (e) {
170
171
  this.session = undefined
@@ -3007,6 +3007,9 @@ export const schemaDict = {
3007
3007
  emailConfirmed: {
3008
3008
  type: 'boolean',
3009
3009
  },
3010
+ didDoc: {
3011
+ type: 'unknown',
3012
+ },
3010
3013
  },
3011
3014
  },
3012
3015
  },
@@ -16,6 +16,7 @@ export interface OutputSchema {
16
16
  did: string
17
17
  email?: string
18
18
  emailConfirmed?: boolean
19
+ didDoc?: {}
19
20
  [k: string]: unknown
20
21
  }
21
22
 
@@ -1,5 +1,4 @@
1
1
  import { AppBskyGraphDefs } from '../client/index'
2
- import { AtUri } from '@atproto/syntax'
3
2
  import {
4
3
  Label,
5
4
  LabelPreference,
@@ -1,3 +1,4 @@
1
+ import assert from 'assert'
1
2
  import { defaultFetchHandler } from '@atproto/xrpc'
2
3
  import {
3
4
  AtpAgent,
@@ -6,6 +7,7 @@ import {
6
7
  AtpSessionData,
7
8
  } from '..'
8
9
  import { TestNetworkNoAppView } from '@atproto/dev-env'
10
+ import { getPdsEndpoint, isValidDidDoc } from '@atproto/common-web'
9
11
 
10
12
  describe('agent', () => {
11
13
  let network: TestNetworkNoAppView
@@ -46,16 +48,19 @@ describe('agent', () => {
46
48
  expect(agent.session?.did).toEqual(res.data.did)
47
49
  expect(agent.session?.email).toEqual('user1@test.com')
48
50
  expect(agent.session?.emailConfirmed).toEqual(false)
51
+ assert(isValidDidDoc(res.data.didDoc))
52
+ expect(agent.api.xrpc.uri.origin).toEqual(getPdsEndpoint(res.data.didDoc))
49
53
 
50
54
  const { data: sessionInfo } = await agent.api.com.atproto.server.getSession(
51
55
  {},
52
56
  )
53
- expect(sessionInfo).toEqual({
57
+ expect(sessionInfo).toMatchObject({
54
58
  did: res.data.did,
55
59
  handle: res.data.handle,
56
60
  email: 'user1@test.com',
57
61
  emailConfirmed: false,
58
62
  })
63
+ expect(isValidDidDoc(sessionInfo.didDoc)).toBe(true)
59
64
 
60
65
  expect(events.length).toEqual(1)
61
66
  expect(events[0]).toEqual('create')
@@ -93,15 +98,18 @@ describe('agent', () => {
93
98
  expect(agent2.session?.did).toEqual(res1.data.did)
94
99
  expect(agent2.session?.email).toEqual('user2@test.com')
95
100
  expect(agent2.session?.emailConfirmed).toEqual(false)
101
+ assert(isValidDidDoc(res1.data.didDoc))
102
+ expect(agent2.api.xrpc.uri.origin).toEqual(getPdsEndpoint(res1.data.didDoc))
96
103
 
97
104
  const { data: sessionInfo } =
98
105
  await agent2.api.com.atproto.server.getSession({})
99
- expect(sessionInfo).toEqual({
106
+ expect(sessionInfo).toMatchObject({
100
107
  did: res1.data.did,
101
108
  handle: res1.data.handle,
102
109
  email,
103
110
  emailConfirmed: false,
104
111
  })
112
+ expect(isValidDidDoc(sessionInfo.didDoc)).toBe(true)
105
113
 
106
114
  expect(events.length).toEqual(2)
107
115
  expect(events[0]).toEqual('create')
@@ -136,15 +144,18 @@ describe('agent', () => {
136
144
  expect(agent2.hasSession).toEqual(true)
137
145
  expect(agent2.session?.handle).toEqual(res1.data.handle)
138
146
  expect(agent2.session?.did).toEqual(res1.data.did)
147
+ assert(isValidDidDoc(res1.data.didDoc))
148
+ expect(agent2.api.xrpc.uri.origin).toEqual(getPdsEndpoint(res1.data.didDoc))
139
149
 
140
150
  const { data: sessionInfo } =
141
151
  await agent2.api.com.atproto.server.getSession({})
142
- expect(sessionInfo).toEqual({
152
+ expect(sessionInfo).toMatchObject({
143
153
  did: res1.data.did,
144
154
  handle: res1.data.handle,
145
155
  email: res1.data.email,
146
156
  emailConfirmed: false,
147
157
  })
158
+ expect(isValidDidDoc(sessionInfo.didDoc)).toBe(true)
148
159
 
149
160
  expect(events.length).toEqual(2)
150
161
  expect(events[0]).toEqual('create')