@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/CHANGELOG.md +6 -0
- package/dist/client/lexicons.d.ts +3 -0
- package/dist/client/types/com/atproto/server/getSession.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
- package/src/agent.ts +1 -0
- package/src/client/lexicons.ts +3 -0
- package/src/client/types/com/atproto/server/getSession.ts +1 -0
- package/src/moderation/accumulator.ts +0 -1
- package/tests/agent.test.ts +14 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/api",
|
|
3
|
-
"version": "0.6.
|
|
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.
|
|
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
|
package/src/client/lexicons.ts
CHANGED
package/tests/agent.test.ts
CHANGED
|
@@ -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).
|
|
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).
|
|
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).
|
|
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')
|