@atproto/api 0.6.19 → 0.6.20
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 +12 -0
- package/dist/client/index.d.ts +12 -0
- package/dist/client/lexicons.d.ts +99 -0
- package/dist/client/types/com/atproto/server/confirmEmail.d.ts +30 -0
- package/dist/client/types/com/atproto/server/createSession.d.ts +1 -0
- package/dist/client/types/com/atproto/server/getSession.d.ts +1 -0
- package/dist/client/types/com/atproto/server/requestEmailConfirmation.d.ts +13 -0
- package/dist/client/types/com/atproto/server/requestEmailUpdate.d.ts +18 -0
- package/dist/client/types/com/atproto/server/updateEmail.d.ts +27 -0
- package/dist/index.js +472 -230
- package/dist/index.js.map +3 -3
- package/dist/types.d.ts +1 -0
- package/package.json +7 -7
- package/src/agent.ts +4 -0
- package/src/client/index.ts +52 -0
- package/src/client/lexicons.ts +122 -0
- package/src/client/types/com/atproto/server/confirmEmail.ts +61 -0
- package/src/client/types/com/atproto/server/createSession.ts +1 -0
- package/src/client/types/com/atproto/server/getSession.ts +1 -0
- package/src/client/types/com/atproto/server/requestEmailConfirmation.ts +28 -0
- package/src/client/types/com/atproto/server/requestEmailUpdate.ts +34 -0
- package/src/client/types/com/atproto/server/updateEmail.ts +55 -0
- package/src/types.ts +1 -0
- package/tests/agent.test.ts +9 -0
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface AtpSessionData {
|
|
|
6
6
|
handle: string;
|
|
7
7
|
did: string;
|
|
8
8
|
email?: string;
|
|
9
|
+
emailConfirmed?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare type AtpPersistSessionHandler = (evt: AtpSessionEvent, session: AtpSessionData | undefined) => void | Promise<void>;
|
|
11
12
|
export interface AtpAgentOpts {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/api",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Client library for atproto and Bluesky",
|
|
6
6
|
"keywords": [
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"multiformats": "^9.9.0",
|
|
20
20
|
"tlds": "^1.234.0",
|
|
21
21
|
"typed-emitter": "^2.1.0",
|
|
22
|
-
"@atproto/common-web": "^0.2.
|
|
23
|
-
"@atproto/lexicon": "^0.2.
|
|
24
|
-
"@atproto/syntax": "^0.1.
|
|
25
|
-
"@atproto/xrpc": "^0.3.
|
|
22
|
+
"@atproto/common-web": "^0.2.1",
|
|
23
|
+
"@atproto/lexicon": "^0.2.2",
|
|
24
|
+
"@atproto/syntax": "^0.1.2",
|
|
25
|
+
"@atproto/xrpc": "^0.3.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"common-tags": "^1.8.2",
|
|
29
|
-
"@atproto/lex-cli": "^0.2.
|
|
30
|
-
"@atproto/pds": "^0.1.
|
|
29
|
+
"@atproto/lex-cli": "^0.2.2",
|
|
30
|
+
"@atproto/pds": "^0.1.20"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"codegen": "pnpm docgen && node ./scripts/generate-code.mjs && lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
|
package/src/agent.ts
CHANGED
|
@@ -95,6 +95,7 @@ export class AtpAgent {
|
|
|
95
95
|
handle: res.data.handle,
|
|
96
96
|
did: res.data.did,
|
|
97
97
|
email: opts.email,
|
|
98
|
+
emailConfirmed: false,
|
|
98
99
|
}
|
|
99
100
|
return res
|
|
100
101
|
} catch (e) {
|
|
@@ -126,6 +127,7 @@ export class AtpAgent {
|
|
|
126
127
|
handle: res.data.handle,
|
|
127
128
|
did: res.data.did,
|
|
128
129
|
email: res.data.email,
|
|
130
|
+
emailConfirmed: res.data.emailConfirmed,
|
|
129
131
|
}
|
|
130
132
|
return res
|
|
131
133
|
} catch (e) {
|
|
@@ -154,6 +156,7 @@ export class AtpAgent {
|
|
|
154
156
|
}
|
|
155
157
|
this.session.email = res.data.email
|
|
156
158
|
this.session.handle = res.data.handle
|
|
159
|
+
this.session.emailConfirmed = res.data.emailConfirmed
|
|
157
160
|
return res
|
|
158
161
|
} catch (e) {
|
|
159
162
|
this.session = undefined
|
|
@@ -268,6 +271,7 @@ export class AtpAgent {
|
|
|
268
271
|
} else if (isNewSessionObject(this._baseClient, res.body)) {
|
|
269
272
|
// succeeded, update the session
|
|
270
273
|
this.session = {
|
|
274
|
+
...(this.session || {}),
|
|
271
275
|
accessJwt: res.body.accessJwt,
|
|
272
276
|
refreshJwt: res.body.refreshJwt,
|
|
273
277
|
handle: res.body.handle,
|
package/src/client/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ import * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords
|
|
|
41
41
|
import * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord'
|
|
42
42
|
import * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef'
|
|
43
43
|
import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
|
|
44
|
+
import * as ComAtprotoServerConfirmEmail from './types/com/atproto/server/confirmEmail'
|
|
44
45
|
import * as ComAtprotoServerCreateAccount from './types/com/atproto/server/createAccount'
|
|
45
46
|
import * as ComAtprotoServerCreateAppPassword from './types/com/atproto/server/createAppPassword'
|
|
46
47
|
import * as ComAtprotoServerCreateInviteCode from './types/com/atproto/server/createInviteCode'
|
|
@@ -55,9 +56,12 @@ import * as ComAtprotoServerGetSession from './types/com/atproto/server/getSessi
|
|
|
55
56
|
import * as ComAtprotoServerListAppPasswords from './types/com/atproto/server/listAppPasswords'
|
|
56
57
|
import * as ComAtprotoServerRefreshSession from './types/com/atproto/server/refreshSession'
|
|
57
58
|
import * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/server/requestAccountDelete'
|
|
59
|
+
import * as ComAtprotoServerRequestEmailConfirmation from './types/com/atproto/server/requestEmailConfirmation'
|
|
60
|
+
import * as ComAtprotoServerRequestEmailUpdate from './types/com/atproto/server/requestEmailUpdate'
|
|
58
61
|
import * as ComAtprotoServerRequestPasswordReset from './types/com/atproto/server/requestPasswordReset'
|
|
59
62
|
import * as ComAtprotoServerResetPassword from './types/com/atproto/server/resetPassword'
|
|
60
63
|
import * as ComAtprotoServerRevokeAppPassword from './types/com/atproto/server/revokeAppPassword'
|
|
64
|
+
import * as ComAtprotoServerUpdateEmail from './types/com/atproto/server/updateEmail'
|
|
61
65
|
import * as ComAtprotoSyncGetBlob from './types/com/atproto/sync/getBlob'
|
|
62
66
|
import * as ComAtprotoSyncGetBlocks from './types/com/atproto/sync/getBlocks'
|
|
63
67
|
import * as ComAtprotoSyncGetCheckout from './types/com/atproto/sync/getCheckout'
|
|
@@ -170,6 +174,7 @@ export * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords
|
|
|
170
174
|
export * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord'
|
|
171
175
|
export * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef'
|
|
172
176
|
export * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
|
|
177
|
+
export * as ComAtprotoServerConfirmEmail from './types/com/atproto/server/confirmEmail'
|
|
173
178
|
export * as ComAtprotoServerCreateAccount from './types/com/atproto/server/createAccount'
|
|
174
179
|
export * as ComAtprotoServerCreateAppPassword from './types/com/atproto/server/createAppPassword'
|
|
175
180
|
export * as ComAtprotoServerCreateInviteCode from './types/com/atproto/server/createInviteCode'
|
|
@@ -184,9 +189,12 @@ export * as ComAtprotoServerGetSession from './types/com/atproto/server/getSessi
|
|
|
184
189
|
export * as ComAtprotoServerListAppPasswords from './types/com/atproto/server/listAppPasswords'
|
|
185
190
|
export * as ComAtprotoServerRefreshSession from './types/com/atproto/server/refreshSession'
|
|
186
191
|
export * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/server/requestAccountDelete'
|
|
192
|
+
export * as ComAtprotoServerRequestEmailConfirmation from './types/com/atproto/server/requestEmailConfirmation'
|
|
193
|
+
export * as ComAtprotoServerRequestEmailUpdate from './types/com/atproto/server/requestEmailUpdate'
|
|
187
194
|
export * as ComAtprotoServerRequestPasswordReset from './types/com/atproto/server/requestPasswordReset'
|
|
188
195
|
export * as ComAtprotoServerResetPassword from './types/com/atproto/server/resetPassword'
|
|
189
196
|
export * as ComAtprotoServerRevokeAppPassword from './types/com/atproto/server/revokeAppPassword'
|
|
197
|
+
export * as ComAtprotoServerUpdateEmail from './types/com/atproto/server/updateEmail'
|
|
190
198
|
export * as ComAtprotoSyncGetBlob from './types/com/atproto/sync/getBlob'
|
|
191
199
|
export * as ComAtprotoSyncGetBlocks from './types/com/atproto/sync/getBlocks'
|
|
192
200
|
export * as ComAtprotoSyncGetCheckout from './types/com/atproto/sync/getCheckout'
|
|
@@ -712,6 +720,17 @@ export class ServerNS {
|
|
|
712
720
|
this._service = service
|
|
713
721
|
}
|
|
714
722
|
|
|
723
|
+
confirmEmail(
|
|
724
|
+
data?: ComAtprotoServerConfirmEmail.InputSchema,
|
|
725
|
+
opts?: ComAtprotoServerConfirmEmail.CallOptions,
|
|
726
|
+
): Promise<ComAtprotoServerConfirmEmail.Response> {
|
|
727
|
+
return this._service.xrpc
|
|
728
|
+
.call('com.atproto.server.confirmEmail', opts?.qp, data, opts)
|
|
729
|
+
.catch((e) => {
|
|
730
|
+
throw ComAtprotoServerConfirmEmail.toKnownErr(e)
|
|
731
|
+
})
|
|
732
|
+
}
|
|
733
|
+
|
|
715
734
|
createAccount(
|
|
716
735
|
data?: ComAtprotoServerCreateAccount.InputSchema,
|
|
717
736
|
opts?: ComAtprotoServerCreateAccount.CallOptions,
|
|
@@ -855,6 +874,28 @@ export class ServerNS {
|
|
|
855
874
|
})
|
|
856
875
|
}
|
|
857
876
|
|
|
877
|
+
requestEmailConfirmation(
|
|
878
|
+
data?: ComAtprotoServerRequestEmailConfirmation.InputSchema,
|
|
879
|
+
opts?: ComAtprotoServerRequestEmailConfirmation.CallOptions,
|
|
880
|
+
): Promise<ComAtprotoServerRequestEmailConfirmation.Response> {
|
|
881
|
+
return this._service.xrpc
|
|
882
|
+
.call('com.atproto.server.requestEmailConfirmation', opts?.qp, data, opts)
|
|
883
|
+
.catch((e) => {
|
|
884
|
+
throw ComAtprotoServerRequestEmailConfirmation.toKnownErr(e)
|
|
885
|
+
})
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
requestEmailUpdate(
|
|
889
|
+
data?: ComAtprotoServerRequestEmailUpdate.InputSchema,
|
|
890
|
+
opts?: ComAtprotoServerRequestEmailUpdate.CallOptions,
|
|
891
|
+
): Promise<ComAtprotoServerRequestEmailUpdate.Response> {
|
|
892
|
+
return this._service.xrpc
|
|
893
|
+
.call('com.atproto.server.requestEmailUpdate', opts?.qp, data, opts)
|
|
894
|
+
.catch((e) => {
|
|
895
|
+
throw ComAtprotoServerRequestEmailUpdate.toKnownErr(e)
|
|
896
|
+
})
|
|
897
|
+
}
|
|
898
|
+
|
|
858
899
|
requestPasswordReset(
|
|
859
900
|
data?: ComAtprotoServerRequestPasswordReset.InputSchema,
|
|
860
901
|
opts?: ComAtprotoServerRequestPasswordReset.CallOptions,
|
|
@@ -887,6 +928,17 @@ export class ServerNS {
|
|
|
887
928
|
throw ComAtprotoServerRevokeAppPassword.toKnownErr(e)
|
|
888
929
|
})
|
|
889
930
|
}
|
|
931
|
+
|
|
932
|
+
updateEmail(
|
|
933
|
+
data?: ComAtprotoServerUpdateEmail.InputSchema,
|
|
934
|
+
opts?: ComAtprotoServerUpdateEmail.CallOptions,
|
|
935
|
+
): Promise<ComAtprotoServerUpdateEmail.Response> {
|
|
936
|
+
return this._service.xrpc
|
|
937
|
+
.call('com.atproto.server.updateEmail', opts?.qp, data, opts)
|
|
938
|
+
.catch((e) => {
|
|
939
|
+
throw ComAtprotoServerUpdateEmail.toKnownErr(e)
|
|
940
|
+
})
|
|
941
|
+
}
|
|
890
942
|
}
|
|
891
943
|
|
|
892
944
|
export class SyncNS {
|
package/src/client/lexicons.ts
CHANGED
|
@@ -2242,6 +2242,46 @@ export const schemaDict = {
|
|
|
2242
2242
|
},
|
|
2243
2243
|
},
|
|
2244
2244
|
},
|
|
2245
|
+
ComAtprotoServerConfirmEmail: {
|
|
2246
|
+
lexicon: 1,
|
|
2247
|
+
id: 'com.atproto.server.confirmEmail',
|
|
2248
|
+
defs: {
|
|
2249
|
+
main: {
|
|
2250
|
+
type: 'procedure',
|
|
2251
|
+
description:
|
|
2252
|
+
'Confirm an email using a token from com.atproto.server.requestEmailConfirmation.',
|
|
2253
|
+
input: {
|
|
2254
|
+
encoding: 'application/json',
|
|
2255
|
+
schema: {
|
|
2256
|
+
type: 'object',
|
|
2257
|
+
required: ['email', 'token'],
|
|
2258
|
+
properties: {
|
|
2259
|
+
email: {
|
|
2260
|
+
type: 'string',
|
|
2261
|
+
},
|
|
2262
|
+
token: {
|
|
2263
|
+
type: 'string',
|
|
2264
|
+
},
|
|
2265
|
+
},
|
|
2266
|
+
},
|
|
2267
|
+
},
|
|
2268
|
+
errors: [
|
|
2269
|
+
{
|
|
2270
|
+
name: 'AccountNotFound',
|
|
2271
|
+
},
|
|
2272
|
+
{
|
|
2273
|
+
name: 'ExpiredToken',
|
|
2274
|
+
},
|
|
2275
|
+
{
|
|
2276
|
+
name: 'InvalidToken',
|
|
2277
|
+
},
|
|
2278
|
+
{
|
|
2279
|
+
name: 'InvalidEmail',
|
|
2280
|
+
},
|
|
2281
|
+
],
|
|
2282
|
+
},
|
|
2283
|
+
},
|
|
2284
|
+
},
|
|
2245
2285
|
ComAtprotoServerCreateAccount: {
|
|
2246
2286
|
lexicon: 1,
|
|
2247
2287
|
id: 'com.atproto.server.createAccount',
|
|
@@ -2526,6 +2566,9 @@ export const schemaDict = {
|
|
|
2526
2566
|
email: {
|
|
2527
2567
|
type: 'string',
|
|
2528
2568
|
},
|
|
2569
|
+
emailConfirmed: {
|
|
2570
|
+
type: 'boolean',
|
|
2571
|
+
},
|
|
2529
2572
|
},
|
|
2530
2573
|
},
|
|
2531
2574
|
},
|
|
@@ -2756,6 +2799,9 @@ export const schemaDict = {
|
|
|
2756
2799
|
email: {
|
|
2757
2800
|
type: 'string',
|
|
2758
2801
|
},
|
|
2802
|
+
emailConfirmed: {
|
|
2803
|
+
type: 'boolean',
|
|
2804
|
+
},
|
|
2759
2805
|
},
|
|
2760
2806
|
},
|
|
2761
2807
|
},
|
|
@@ -2854,6 +2900,39 @@ export const schemaDict = {
|
|
|
2854
2900
|
},
|
|
2855
2901
|
},
|
|
2856
2902
|
},
|
|
2903
|
+
ComAtprotoServerRequestEmailConfirmation: {
|
|
2904
|
+
lexicon: 1,
|
|
2905
|
+
id: 'com.atproto.server.requestEmailConfirmation',
|
|
2906
|
+
defs: {
|
|
2907
|
+
main: {
|
|
2908
|
+
type: 'procedure',
|
|
2909
|
+
description:
|
|
2910
|
+
'Request an email with a code to confirm ownership of email',
|
|
2911
|
+
},
|
|
2912
|
+
},
|
|
2913
|
+
},
|
|
2914
|
+
ComAtprotoServerRequestEmailUpdate: {
|
|
2915
|
+
lexicon: 1,
|
|
2916
|
+
id: 'com.atproto.server.requestEmailUpdate',
|
|
2917
|
+
defs: {
|
|
2918
|
+
main: {
|
|
2919
|
+
type: 'procedure',
|
|
2920
|
+
description: 'Request a token in order to update email.',
|
|
2921
|
+
output: {
|
|
2922
|
+
encoding: 'application/json',
|
|
2923
|
+
schema: {
|
|
2924
|
+
type: 'object',
|
|
2925
|
+
required: ['tokenRequired'],
|
|
2926
|
+
properties: {
|
|
2927
|
+
tokenRequired: {
|
|
2928
|
+
type: 'boolean',
|
|
2929
|
+
},
|
|
2930
|
+
},
|
|
2931
|
+
},
|
|
2932
|
+
},
|
|
2933
|
+
},
|
|
2934
|
+
},
|
|
2935
|
+
},
|
|
2857
2936
|
ComAtprotoServerRequestPasswordReset: {
|
|
2858
2937
|
lexicon: 1,
|
|
2859
2938
|
id: 'com.atproto.server.requestPasswordReset',
|
|
@@ -2931,6 +3010,44 @@ export const schemaDict = {
|
|
|
2931
3010
|
},
|
|
2932
3011
|
},
|
|
2933
3012
|
},
|
|
3013
|
+
ComAtprotoServerUpdateEmail: {
|
|
3014
|
+
lexicon: 1,
|
|
3015
|
+
id: 'com.atproto.server.updateEmail',
|
|
3016
|
+
defs: {
|
|
3017
|
+
main: {
|
|
3018
|
+
type: 'procedure',
|
|
3019
|
+
description: "Update an account's email.",
|
|
3020
|
+
input: {
|
|
3021
|
+
encoding: 'application/json',
|
|
3022
|
+
schema: {
|
|
3023
|
+
type: 'object',
|
|
3024
|
+
required: ['email'],
|
|
3025
|
+
properties: {
|
|
3026
|
+
email: {
|
|
3027
|
+
type: 'string',
|
|
3028
|
+
},
|
|
3029
|
+
token: {
|
|
3030
|
+
type: 'string',
|
|
3031
|
+
description:
|
|
3032
|
+
"Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed.",
|
|
3033
|
+
},
|
|
3034
|
+
},
|
|
3035
|
+
},
|
|
3036
|
+
},
|
|
3037
|
+
errors: [
|
|
3038
|
+
{
|
|
3039
|
+
name: 'ExpiredToken',
|
|
3040
|
+
},
|
|
3041
|
+
{
|
|
3042
|
+
name: 'InvalidToken',
|
|
3043
|
+
},
|
|
3044
|
+
{
|
|
3045
|
+
name: 'TokenRequired',
|
|
3046
|
+
},
|
|
3047
|
+
],
|
|
3048
|
+
},
|
|
3049
|
+
},
|
|
3050
|
+
},
|
|
2934
3051
|
ComAtprotoSyncGetBlob: {
|
|
2935
3052
|
lexicon: 1,
|
|
2936
3053
|
id: 'com.atproto.sync.getBlob',
|
|
@@ -7240,6 +7357,7 @@ export const ids = {
|
|
|
7240
7357
|
ComAtprotoRepoPutRecord: 'com.atproto.repo.putRecord',
|
|
7241
7358
|
ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef',
|
|
7242
7359
|
ComAtprotoRepoUploadBlob: 'com.atproto.repo.uploadBlob',
|
|
7360
|
+
ComAtprotoServerConfirmEmail: 'com.atproto.server.confirmEmail',
|
|
7243
7361
|
ComAtprotoServerCreateAccount: 'com.atproto.server.createAccount',
|
|
7244
7362
|
ComAtprotoServerCreateAppPassword: 'com.atproto.server.createAppPassword',
|
|
7245
7363
|
ComAtprotoServerCreateInviteCode: 'com.atproto.server.createInviteCode',
|
|
@@ -7256,10 +7374,14 @@ export const ids = {
|
|
|
7256
7374
|
ComAtprotoServerRefreshSession: 'com.atproto.server.refreshSession',
|
|
7257
7375
|
ComAtprotoServerRequestAccountDelete:
|
|
7258
7376
|
'com.atproto.server.requestAccountDelete',
|
|
7377
|
+
ComAtprotoServerRequestEmailConfirmation:
|
|
7378
|
+
'com.atproto.server.requestEmailConfirmation',
|
|
7379
|
+
ComAtprotoServerRequestEmailUpdate: 'com.atproto.server.requestEmailUpdate',
|
|
7259
7380
|
ComAtprotoServerRequestPasswordReset:
|
|
7260
7381
|
'com.atproto.server.requestPasswordReset',
|
|
7261
7382
|
ComAtprotoServerResetPassword: 'com.atproto.server.resetPassword',
|
|
7262
7383
|
ComAtprotoServerRevokeAppPassword: 'com.atproto.server.revokeAppPassword',
|
|
7384
|
+
ComAtprotoServerUpdateEmail: 'com.atproto.server.updateEmail',
|
|
7263
7385
|
ComAtprotoSyncGetBlob: 'com.atproto.sync.getBlob',
|
|
7264
7386
|
ComAtprotoSyncGetBlocks: 'com.atproto.sync.getBlocks',
|
|
7265
7387
|
ComAtprotoSyncGetCheckout: 'com.atproto.sync.getCheckout',
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {}
|
|
11
|
+
|
|
12
|
+
export interface InputSchema {
|
|
13
|
+
email: string
|
|
14
|
+
token: string
|
|
15
|
+
[k: string]: unknown
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CallOptions {
|
|
19
|
+
headers?: Headers
|
|
20
|
+
qp?: QueryParams
|
|
21
|
+
encoding: 'application/json'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Response {
|
|
25
|
+
success: boolean
|
|
26
|
+
headers: Headers
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class AccountNotFoundError extends XRPCError {
|
|
30
|
+
constructor(src: XRPCError) {
|
|
31
|
+
super(src.status, src.error, src.message, src.headers)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class ExpiredTokenError extends XRPCError {
|
|
36
|
+
constructor(src: XRPCError) {
|
|
37
|
+
super(src.status, src.error, src.message, src.headers)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class InvalidTokenError extends XRPCError {
|
|
42
|
+
constructor(src: XRPCError) {
|
|
43
|
+
super(src.status, src.error, src.message, src.headers)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class InvalidEmailError extends XRPCError {
|
|
48
|
+
constructor(src: XRPCError) {
|
|
49
|
+
super(src.status, src.error, src.message, src.headers)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function toKnownErr(e: any) {
|
|
54
|
+
if (e instanceof XRPCError) {
|
|
55
|
+
if (e.error === 'AccountNotFound') return new AccountNotFoundError(e)
|
|
56
|
+
if (e.error === 'ExpiredToken') return new ExpiredTokenError(e)
|
|
57
|
+
if (e.error === 'InvalidToken') return new InvalidTokenError(e)
|
|
58
|
+
if (e.error === 'InvalidEmail') return new InvalidEmailError(e)
|
|
59
|
+
}
|
|
60
|
+
return e
|
|
61
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {}
|
|
11
|
+
|
|
12
|
+
export type InputSchema = undefined
|
|
13
|
+
|
|
14
|
+
export interface CallOptions {
|
|
15
|
+
headers?: Headers
|
|
16
|
+
qp?: QueryParams
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Response {
|
|
20
|
+
success: boolean
|
|
21
|
+
headers: Headers
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function toKnownErr(e: any) {
|
|
25
|
+
if (e instanceof XRPCError) {
|
|
26
|
+
}
|
|
27
|
+
return e
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {}
|
|
11
|
+
|
|
12
|
+
export type InputSchema = undefined
|
|
13
|
+
|
|
14
|
+
export interface OutputSchema {
|
|
15
|
+
tokenRequired: boolean
|
|
16
|
+
[k: string]: unknown
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CallOptions {
|
|
20
|
+
headers?: Headers
|
|
21
|
+
qp?: QueryParams
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Response {
|
|
25
|
+
success: boolean
|
|
26
|
+
headers: Headers
|
|
27
|
+
data: OutputSchema
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function toKnownErr(e: any) {
|
|
31
|
+
if (e instanceof XRPCError) {
|
|
32
|
+
}
|
|
33
|
+
return e
|
|
34
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {}
|
|
11
|
+
|
|
12
|
+
export interface InputSchema {
|
|
13
|
+
email: string
|
|
14
|
+
/** Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed. */
|
|
15
|
+
token?: string
|
|
16
|
+
[k: string]: unknown
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CallOptions {
|
|
20
|
+
headers?: Headers
|
|
21
|
+
qp?: QueryParams
|
|
22
|
+
encoding: 'application/json'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Response {
|
|
26
|
+
success: boolean
|
|
27
|
+
headers: Headers
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class ExpiredTokenError extends XRPCError {
|
|
31
|
+
constructor(src: XRPCError) {
|
|
32
|
+
super(src.status, src.error, src.message, src.headers)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class InvalidTokenError extends XRPCError {
|
|
37
|
+
constructor(src: XRPCError) {
|
|
38
|
+
super(src.status, src.error, src.message, src.headers)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class TokenRequiredError extends XRPCError {
|
|
43
|
+
constructor(src: XRPCError) {
|
|
44
|
+
super(src.status, src.error, src.message, src.headers)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function toKnownErr(e: any) {
|
|
49
|
+
if (e instanceof XRPCError) {
|
|
50
|
+
if (e.error === 'ExpiredToken') return new ExpiredTokenError(e)
|
|
51
|
+
if (e.error === 'InvalidToken') return new InvalidTokenError(e)
|
|
52
|
+
if (e.error === 'TokenRequired') return new TokenRequiredError(e)
|
|
53
|
+
}
|
|
54
|
+
return e
|
|
55
|
+
}
|
package/src/types.ts
CHANGED
package/tests/agent.test.ts
CHANGED
|
@@ -48,6 +48,7 @@ describe('agent', () => {
|
|
|
48
48
|
expect(agent.session?.handle).toEqual(res.data.handle)
|
|
49
49
|
expect(agent.session?.did).toEqual(res.data.did)
|
|
50
50
|
expect(agent.session?.email).toEqual('user1@test.com')
|
|
51
|
+
expect(agent.session?.emailConfirmed).toEqual(false)
|
|
51
52
|
|
|
52
53
|
const { data: sessionInfo } = await agent.api.com.atproto.server.getSession(
|
|
53
54
|
{},
|
|
@@ -56,6 +57,7 @@ describe('agent', () => {
|
|
|
56
57
|
did: res.data.did,
|
|
57
58
|
handle: res.data.handle,
|
|
58
59
|
email: 'user1@test.com',
|
|
60
|
+
emailConfirmed: false,
|
|
59
61
|
})
|
|
60
62
|
|
|
61
63
|
expect(events.length).toEqual(1)
|
|
@@ -93,6 +95,7 @@ describe('agent', () => {
|
|
|
93
95
|
expect(agent2.session?.handle).toEqual(res1.data.handle)
|
|
94
96
|
expect(agent2.session?.did).toEqual(res1.data.did)
|
|
95
97
|
expect(agent2.session?.email).toEqual('user2@test.com')
|
|
98
|
+
expect(agent2.session?.emailConfirmed).toEqual(false)
|
|
96
99
|
|
|
97
100
|
const { data: sessionInfo } =
|
|
98
101
|
await agent2.api.com.atproto.server.getSession({})
|
|
@@ -100,6 +103,7 @@ describe('agent', () => {
|
|
|
100
103
|
did: res1.data.did,
|
|
101
104
|
handle: res1.data.handle,
|
|
102
105
|
email,
|
|
106
|
+
emailConfirmed: false,
|
|
103
107
|
})
|
|
104
108
|
|
|
105
109
|
expect(events.length).toEqual(2)
|
|
@@ -142,6 +146,7 @@ describe('agent', () => {
|
|
|
142
146
|
did: res1.data.did,
|
|
143
147
|
handle: res1.data.handle,
|
|
144
148
|
email: res1.data.email,
|
|
149
|
+
emailConfirmed: false,
|
|
145
150
|
})
|
|
146
151
|
|
|
147
152
|
expect(events.length).toEqual(2)
|
|
@@ -206,6 +211,8 @@ describe('agent', () => {
|
|
|
206
211
|
expect(agent.session?.refreshJwt).not.toEqual(session1.refreshJwt)
|
|
207
212
|
expect(agent.session?.handle).toEqual(session1.handle)
|
|
208
213
|
expect(agent.session?.did).toEqual(session1.did)
|
|
214
|
+
expect(agent.session?.email).toEqual(session1.email)
|
|
215
|
+
expect(agent.session?.emailConfirmed).toEqual(session1.emailConfirmed)
|
|
209
216
|
|
|
210
217
|
expect(events.length).toEqual(2)
|
|
211
218
|
expect(events[0]).toEqual('create')
|
|
@@ -283,6 +290,8 @@ describe('agent', () => {
|
|
|
283
290
|
expect(agent.session?.refreshJwt).not.toEqual(session1.refreshJwt)
|
|
284
291
|
expect(agent.session?.handle).toEqual(session1.handle)
|
|
285
292
|
expect(agent.session?.did).toEqual(session1.did)
|
|
293
|
+
expect(agent.session?.email).toEqual(session1.email)
|
|
294
|
+
expect(agent.session?.emailConfirmed).toEqual(session1.emailConfirmed)
|
|
286
295
|
|
|
287
296
|
expect(events.length).toEqual(2)
|
|
288
297
|
expect(events[0]).toEqual('create')
|