@atproto/api 0.18.7 → 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.
Files changed (66) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/atp-agent.d.ts +8 -2
  3. package/dist/atp-agent.d.ts.map +1 -1
  4. package/dist/atp-agent.js +115 -80
  5. package/dist/atp-agent.js.map +1 -1
  6. package/dist/client/index.d.ts.map +1 -1
  7. package/dist/client/index.js +6 -1
  8. package/dist/client/index.js.map +1 -1
  9. package/dist/client/lexicons.d.ts +142 -52
  10. package/dist/client/lexicons.d.ts.map +1 -1
  11. package/dist/client/lexicons.js +93 -26
  12. package/dist/client/lexicons.js.map +1 -1
  13. package/dist/client/types/app/bsky/contact/dismissMatch.d.ts +4 -1
  14. package/dist/client/types/app/bsky/contact/dismissMatch.d.ts.map +1 -1
  15. package/dist/client/types/app/bsky/contact/dismissMatch.js +13 -5
  16. package/dist/client/types/app/bsky/contact/dismissMatch.js.map +1 -1
  17. package/dist/client/types/app/bsky/contact/getMatches.d.ts +10 -1
  18. package/dist/client/types/app/bsky/contact/getMatches.d.ts.map +1 -1
  19. package/dist/client/types/app/bsky/contact/getMatches.js +29 -5
  20. package/dist/client/types/app/bsky/contact/getMatches.js.map +1 -1
  21. package/dist/client/types/app/bsky/contact/getSyncStatus.d.ts +4 -1
  22. package/dist/client/types/app/bsky/contact/getSyncStatus.d.ts.map +1 -1
  23. package/dist/client/types/app/bsky/contact/getSyncStatus.js +13 -5
  24. package/dist/client/types/app/bsky/contact/getSyncStatus.js.map +1 -1
  25. package/dist/client/types/app/bsky/contact/importContacts.d.ts +13 -1
  26. package/dist/client/types/app/bsky/contact/importContacts.d.ts.map +1 -1
  27. package/dist/client/types/app/bsky/contact/importContacts.js +37 -5
  28. package/dist/client/types/app/bsky/contact/importContacts.js.map +1 -1
  29. package/dist/client/types/app/bsky/contact/removeData.d.ts +4 -1
  30. package/dist/client/types/app/bsky/contact/removeData.d.ts.map +1 -1
  31. package/dist/client/types/app/bsky/contact/removeData.js +13 -5
  32. package/dist/client/types/app/bsky/contact/removeData.js.map +1 -1
  33. package/dist/client/types/app/bsky/contact/startPhoneVerification.d.ts +10 -1
  34. package/dist/client/types/app/bsky/contact/startPhoneVerification.d.ts.map +1 -1
  35. package/dist/client/types/app/bsky/contact/startPhoneVerification.js +29 -5
  36. package/dist/client/types/app/bsky/contact/startPhoneVerification.js.map +1 -1
  37. package/dist/client/types/app/bsky/contact/verifyPhone.d.ts +13 -1
  38. package/dist/client/types/app/bsky/contact/verifyPhone.d.ts.map +1 -1
  39. package/dist/client/types/app/bsky/contact/verifyPhone.js +37 -5
  40. package/dist/client/types/app/bsky/contact/verifyPhone.js.map +1 -1
  41. package/dist/client/types/com/atproto/server/deleteSession.d.ts +7 -1
  42. package/dist/client/types/com/atproto/server/deleteSession.d.ts.map +1 -1
  43. package/dist/client/types/com/atproto/server/deleteSession.js +23 -0
  44. package/dist/client/types/com/atproto/server/deleteSession.js.map +1 -1
  45. package/dist/client/types/com/atproto/server/getSession.d.ts +3 -3
  46. package/dist/client/types/com/atproto/server/getSession.d.ts.map +1 -1
  47. package/dist/client/types/com/atproto/server/getSession.js.map +1 -1
  48. package/dist/client/types/com/atproto/server/refreshSession.d.ts +9 -0
  49. package/dist/client/types/com/atproto/server/refreshSession.d.ts.map +1 -1
  50. package/dist/client/types/com/atproto/server/refreshSession.js +17 -1
  51. package/dist/client/types/com/atproto/server/refreshSession.js.map +1 -1
  52. package/package.json +3 -3
  53. package/src/atp-agent.ts +147 -99
  54. package/src/client/index.ts +5 -6
  55. package/src/client/lexicons.ts +94 -26
  56. package/src/client/types/app/bsky/contact/dismissMatch.ts +9 -2
  57. package/src/client/types/app/bsky/contact/getMatches.ts +23 -2
  58. package/src/client/types/app/bsky/contact/getSyncStatus.ts +9 -2
  59. package/src/client/types/app/bsky/contact/importContacts.ts +30 -2
  60. package/src/client/types/app/bsky/contact/removeData.ts +9 -2
  61. package/src/client/types/app/bsky/contact/startPhoneVerification.ts +23 -2
  62. package/src/client/types/app/bsky/contact/verifyPhone.ts +30 -2
  63. package/src/client/types/com/atproto/server/deleteSession.ts +17 -0
  64. package/src/client/types/com/atproto/server/getSession.ts +1 -1
  65. package/src/client/types/com/atproto/server/refreshSession.ts +17 -0
  66. package/tests/dispatcher.test.ts +13 -10
@@ -1826,7 +1826,7 @@ export const schemaDict = {
1826
1826
  main: {
1827
1827
  type: 'procedure',
1828
1828
  description:
1829
- "WARNING: This is unstable and under active development, don't use it while this warning is here. Removes a match that was found via contact import. It shouldn't appear again if the same contact is re-imported. Requires authentication.",
1829
+ "Removes a match that was found via contact import. It shouldn't appear again if the same contact is re-imported. Requires authentication.",
1830
1830
  input: {
1831
1831
  encoding: 'application/json',
1832
1832
  schema: {
@@ -1850,8 +1850,10 @@ export const schemaDict = {
1850
1850
  },
1851
1851
  errors: [
1852
1852
  {
1853
- name: 'TODO',
1854
- description: 'TODO',
1853
+ name: 'InvalidDid',
1854
+ },
1855
+ {
1856
+ name: 'InternalError',
1855
1857
  },
1856
1858
  ],
1857
1859
  },
@@ -1864,7 +1866,7 @@ export const schemaDict = {
1864
1866
  main: {
1865
1867
  type: 'query',
1866
1868
  description:
1867
- "WARNING: This is unstable and under active development, don't use it while this warning is here. Returns the matched contacts (contacts that were mutually imported). Excludes dismissed matches. Requires authentication.",
1869
+ 'Returns the matched contacts (contacts that were mutually imported). Excludes dismissed matches. Requires authentication.',
1868
1870
  parameters: {
1869
1871
  type: 'params',
1870
1872
  properties: {
@@ -1900,8 +1902,16 @@ export const schemaDict = {
1900
1902
  },
1901
1903
  errors: [
1902
1904
  {
1903
- name: 'TODO',
1904
- description: 'TODO',
1905
+ name: 'InvalidDid',
1906
+ },
1907
+ {
1908
+ name: 'InvalidLimit',
1909
+ },
1910
+ {
1911
+ name: 'InvalidCursor',
1912
+ },
1913
+ {
1914
+ name: 'InternalError',
1905
1915
  },
1906
1916
  ],
1907
1917
  },
@@ -1914,7 +1924,7 @@ export const schemaDict = {
1914
1924
  main: {
1915
1925
  type: 'query',
1916
1926
  description:
1917
- "WARNING: This is unstable and under active development, don't use it while this warning is here. Gets the user's current contact import status. Requires authentication.",
1927
+ "Gets the user's current contact import status. Requires authentication.",
1918
1928
  parameters: {
1919
1929
  type: 'params',
1920
1930
  properties: {},
@@ -1935,8 +1945,10 @@ export const schemaDict = {
1935
1945
  },
1936
1946
  errors: [
1937
1947
  {
1938
- name: 'TODO',
1939
- description: 'TODO',
1948
+ name: 'InvalidDid',
1949
+ },
1950
+ {
1951
+ name: 'InternalError',
1940
1952
  },
1941
1953
  ],
1942
1954
  },
@@ -1949,7 +1961,7 @@ export const schemaDict = {
1949
1961
  main: {
1950
1962
  type: 'procedure',
1951
1963
  description:
1952
- "WARNING: This is unstable and under active development, don't use it while this warning is here. Import contacts for securely matching with other users. This follows the protocol explained in https://docs.bsky.app/blog/contact-import-rfc. Requires authentication.",
1964
+ 'Import contacts for securely matching with other users. This follows the protocol explained in https://docs.bsky.app/blog/contact-import-rfc. Requires authentication.',
1953
1965
  input: {
1954
1966
  encoding: 'application/json',
1955
1967
  schema: {
@@ -1994,8 +2006,19 @@ export const schemaDict = {
1994
2006
  },
1995
2007
  errors: [
1996
2008
  {
1997
- name: 'TODO',
1998
- description: 'TODO',
2009
+ name: 'InvalidDid',
2010
+ },
2011
+ {
2012
+ name: 'InvalidContacts',
2013
+ },
2014
+ {
2015
+ name: 'TooManyContacts',
2016
+ },
2017
+ {
2018
+ name: 'InvalidToken',
2019
+ },
2020
+ {
2021
+ name: 'InternalError',
1999
2022
  },
2000
2023
  ],
2001
2024
  },
@@ -2008,7 +2031,7 @@ export const schemaDict = {
2008
2031
  main: {
2009
2032
  type: 'procedure',
2010
2033
  description:
2011
- "WARNING: This is unstable and under active development, don't use it while this warning is here. Removes all stored hashes used for contact matching, existing matches, and sync status. Requires authentication.",
2034
+ 'Removes all stored hashes used for contact matching, existing matches, and sync status. Requires authentication.',
2012
2035
  input: {
2013
2036
  encoding: 'application/json',
2014
2037
  schema: {
@@ -2025,8 +2048,10 @@ export const schemaDict = {
2025
2048
  },
2026
2049
  errors: [
2027
2050
  {
2028
- name: 'TODO',
2029
- description: 'TODO',
2051
+ name: 'InvalidDid',
2052
+ },
2053
+ {
2054
+ name: 'InternalError',
2030
2055
  },
2031
2056
  ],
2032
2057
  },
@@ -2039,7 +2064,7 @@ export const schemaDict = {
2039
2064
  main: {
2040
2065
  type: 'procedure',
2041
2066
  description:
2042
- "WARNING: This is unstable and under active development, don't use it while this warning is here. System endpoint to send notifications related to contact imports. Requires role authentication.",
2067
+ 'System endpoint to send notifications related to contact imports. Requires role authentication.',
2043
2068
  input: {
2044
2069
  encoding: 'application/json',
2045
2070
  schema: {
@@ -2076,7 +2101,7 @@ export const schemaDict = {
2076
2101
  main: {
2077
2102
  type: 'procedure',
2078
2103
  description:
2079
- "WARNING: This is unstable and under active development, don't use it while this warning is here. Starts a phone verification flow. The phone passed will receive a code via SMS that should be passed to `app.bsky.contact.verifyPhone`. Requires authentication.",
2104
+ 'Starts a phone verification flow. The phone passed will receive a code via SMS that should be passed to `app.bsky.contact.verifyPhone`. Requires authentication.',
2080
2105
  input: {
2081
2106
  encoding: 'application/json',
2082
2107
  schema: {
@@ -2099,8 +2124,16 @@ export const schemaDict = {
2099
2124
  },
2100
2125
  errors: [
2101
2126
  {
2102
- name: 'TODO',
2103
- description: 'TODO',
2127
+ name: 'RateLimitExceeded',
2128
+ },
2129
+ {
2130
+ name: 'InvalidDid',
2131
+ },
2132
+ {
2133
+ name: 'InvalidPhone',
2134
+ },
2135
+ {
2136
+ name: 'InternalError',
2104
2137
  },
2105
2138
  ],
2106
2139
  },
@@ -2113,7 +2146,7 @@ export const schemaDict = {
2113
2146
  main: {
2114
2147
  type: 'procedure',
2115
2148
  description:
2116
- "WARNING: This is unstable and under active development, don't use it while this warning is here. Verifies control over a phone number with a code received via SMS and starts a contact import session. Requires authentication.",
2149
+ 'Verifies control over a phone number with a code received via SMS and starts a contact import session. Requires authentication.',
2117
2150
  input: {
2118
2151
  encoding: 'application/json',
2119
2152
  schema: {
@@ -2149,8 +2182,19 @@ export const schemaDict = {
2149
2182
  },
2150
2183
  errors: [
2151
2184
  {
2152
- name: 'TODO',
2153
- description: 'TODO',
2185
+ name: 'RateLimitExceeded',
2186
+ },
2187
+ {
2188
+ name: 'InvalidDid',
2189
+ },
2190
+ {
2191
+ name: 'InvalidPhone',
2192
+ },
2193
+ {
2194
+ name: 'InvalidCode',
2195
+ },
2196
+ {
2197
+ name: 'InternalError',
2154
2198
  },
2155
2199
  ],
2156
2200
  },
@@ -12975,7 +13019,16 @@ export const schemaDict = {
12975
13019
  defs: {
12976
13020
  main: {
12977
13021
  type: 'procedure',
12978
- description: 'Delete the current session. Requires auth.',
13022
+ description:
13023
+ "Delete the current session. Requires auth using the 'refreshJwt' (not the 'accessJwt').",
13024
+ errors: [
13025
+ {
13026
+ name: 'InvalidToken',
13027
+ },
13028
+ {
13029
+ name: 'ExpiredToken',
13030
+ },
13031
+ ],
12979
13032
  },
12980
13033
  },
12981
13034
  },
@@ -13174,6 +13227,9 @@ export const schemaDict = {
13174
13227
  type: 'string',
13175
13228
  format: 'did',
13176
13229
  },
13230
+ didDoc: {
13231
+ type: 'unknown',
13232
+ },
13177
13233
  email: {
13178
13234
  type: 'string',
13179
13235
  },
@@ -13183,9 +13239,6 @@ export const schemaDict = {
13183
13239
  emailAuthFactor: {
13184
13240
  type: 'boolean',
13185
13241
  },
13186
- didDoc: {
13187
- type: 'unknown',
13188
- },
13189
13242
  active: {
13190
13243
  type: 'boolean',
13191
13244
  },
@@ -13279,6 +13332,15 @@ export const schemaDict = {
13279
13332
  didDoc: {
13280
13333
  type: 'unknown',
13281
13334
  },
13335
+ email: {
13336
+ type: 'string',
13337
+ },
13338
+ emailConfirmed: {
13339
+ type: 'boolean',
13340
+ },
13341
+ emailAuthFactor: {
13342
+ type: 'boolean',
13343
+ },
13282
13344
  active: {
13283
13345
  type: 'boolean',
13284
13346
  },
@@ -13295,6 +13357,12 @@ export const schemaDict = {
13295
13357
  {
13296
13358
  name: 'AccountTakedown',
13297
13359
  },
13360
+ {
13361
+ name: 'InvalidToken',
13362
+ },
13363
+ {
13364
+ name: 'ExpiredToken',
13365
+ },
13298
13366
  ],
13299
13367
  },
13300
13368
  },
@@ -37,7 +37,13 @@ export interface Response {
37
37
  data: OutputSchema
38
38
  }
39
39
 
40
- export class TODOError extends XRPCError {
40
+ export class InvalidDidError extends XRPCError {
41
+ constructor(src: XRPCError) {
42
+ super(src.status, src.error, src.message, src.headers, { cause: src })
43
+ }
44
+ }
45
+
46
+ export class InternalError extends XRPCError {
41
47
  constructor(src: XRPCError) {
42
48
  super(src.status, src.error, src.message, src.headers, { cause: src })
43
49
  }
@@ -45,7 +51,8 @@ export class TODOError extends XRPCError {
45
51
 
46
52
  export function toKnownErr(e: any) {
47
53
  if (e instanceof XRPCError) {
48
- if (e.error === 'TODO') return new TODOError(e)
54
+ if (e.error === 'InvalidDid') return new InvalidDidError(e)
55
+ if (e.error === 'InternalError') return new InternalError(e)
49
56
  }
50
57
 
51
58
  return e
@@ -38,7 +38,25 @@ export interface Response {
38
38
  data: OutputSchema
39
39
  }
40
40
 
41
- export class TODOError extends XRPCError {
41
+ export class InvalidDidError extends XRPCError {
42
+ constructor(src: XRPCError) {
43
+ super(src.status, src.error, src.message, src.headers, { cause: src })
44
+ }
45
+ }
46
+
47
+ export class InvalidLimitError extends XRPCError {
48
+ constructor(src: XRPCError) {
49
+ super(src.status, src.error, src.message, src.headers, { cause: src })
50
+ }
51
+ }
52
+
53
+ export class InvalidCursorError extends XRPCError {
54
+ constructor(src: XRPCError) {
55
+ super(src.status, src.error, src.message, src.headers, { cause: src })
56
+ }
57
+ }
58
+
59
+ export class InternalError extends XRPCError {
42
60
  constructor(src: XRPCError) {
43
61
  super(src.status, src.error, src.message, src.headers, { cause: src })
44
62
  }
@@ -46,7 +64,10 @@ export class TODOError extends XRPCError {
46
64
 
47
65
  export function toKnownErr(e: any) {
48
66
  if (e instanceof XRPCError) {
49
- if (e.error === 'TODO') return new TODOError(e)
67
+ if (e.error === 'InvalidDid') return new InvalidDidError(e)
68
+ if (e.error === 'InvalidLimit') return new InvalidLimitError(e)
69
+ if (e.error === 'InvalidCursor') return new InvalidCursorError(e)
70
+ if (e.error === 'InternalError') return new InternalError(e)
50
71
  }
51
72
 
52
73
  return e
@@ -34,7 +34,13 @@ export interface Response {
34
34
  data: OutputSchema
35
35
  }
36
36
 
37
- export class TODOError extends XRPCError {
37
+ export class InvalidDidError extends XRPCError {
38
+ constructor(src: XRPCError) {
39
+ super(src.status, src.error, src.message, src.headers, { cause: src })
40
+ }
41
+ }
42
+
43
+ export class InternalError extends XRPCError {
38
44
  constructor(src: XRPCError) {
39
45
  super(src.status, src.error, src.message, src.headers, { cause: src })
40
46
  }
@@ -42,7 +48,8 @@ export class TODOError extends XRPCError {
42
48
 
43
49
  export function toKnownErr(e: any) {
44
50
  if (e instanceof XRPCError) {
45
- if (e.error === 'TODO') return new TODOError(e)
51
+ if (e.error === 'InvalidDid') return new InvalidDidError(e)
52
+ if (e.error === 'InternalError') return new InternalError(e)
46
53
  }
47
54
 
48
55
  return e
@@ -43,7 +43,31 @@ export interface Response {
43
43
  data: OutputSchema
44
44
  }
45
45
 
46
- export class TODOError extends XRPCError {
46
+ export class InvalidDidError extends XRPCError {
47
+ constructor(src: XRPCError) {
48
+ super(src.status, src.error, src.message, src.headers, { cause: src })
49
+ }
50
+ }
51
+
52
+ export class InvalidContactsError extends XRPCError {
53
+ constructor(src: XRPCError) {
54
+ super(src.status, src.error, src.message, src.headers, { cause: src })
55
+ }
56
+ }
57
+
58
+ export class TooManyContactsError extends XRPCError {
59
+ constructor(src: XRPCError) {
60
+ super(src.status, src.error, src.message, src.headers, { cause: src })
61
+ }
62
+ }
63
+
64
+ export class InvalidTokenError extends XRPCError {
65
+ constructor(src: XRPCError) {
66
+ super(src.status, src.error, src.message, src.headers, { cause: src })
67
+ }
68
+ }
69
+
70
+ export class InternalError extends XRPCError {
47
71
  constructor(src: XRPCError) {
48
72
  super(src.status, src.error, src.message, src.headers, { cause: src })
49
73
  }
@@ -51,7 +75,11 @@ export class TODOError extends XRPCError {
51
75
 
52
76
  export function toKnownErr(e: any) {
53
77
  if (e instanceof XRPCError) {
54
- if (e.error === 'TODO') return new TODOError(e)
78
+ if (e.error === 'InvalidDid') return new InvalidDidError(e)
79
+ if (e.error === 'InvalidContacts') return new InvalidContactsError(e)
80
+ if (e.error === 'TooManyContacts') return new TooManyContactsError(e)
81
+ if (e.error === 'InvalidToken') return new InvalidTokenError(e)
82
+ if (e.error === 'InternalError') return new InternalError(e)
55
83
  }
56
84
 
57
85
  return e
@@ -34,7 +34,13 @@ export interface Response {
34
34
  data: OutputSchema
35
35
  }
36
36
 
37
- export class TODOError extends XRPCError {
37
+ export class InvalidDidError extends XRPCError {
38
+ constructor(src: XRPCError) {
39
+ super(src.status, src.error, src.message, src.headers, { cause: src })
40
+ }
41
+ }
42
+
43
+ export class InternalError extends XRPCError {
38
44
  constructor(src: XRPCError) {
39
45
  super(src.status, src.error, src.message, src.headers, { cause: src })
40
46
  }
@@ -42,7 +48,8 @@ export class TODOError extends XRPCError {
42
48
 
43
49
  export function toKnownErr(e: any) {
44
50
  if (e instanceof XRPCError) {
45
- if (e.error === 'TODO') return new TODOError(e)
51
+ if (e.error === 'InvalidDid') return new InvalidDidError(e)
52
+ if (e.error === 'InternalError') return new InternalError(e)
46
53
  }
47
54
 
48
55
  return e
@@ -37,7 +37,25 @@ export interface Response {
37
37
  data: OutputSchema
38
38
  }
39
39
 
40
- export class TODOError extends XRPCError {
40
+ export class RateLimitExceededError extends XRPCError {
41
+ constructor(src: XRPCError) {
42
+ super(src.status, src.error, src.message, src.headers, { cause: src })
43
+ }
44
+ }
45
+
46
+ export class InvalidDidError extends XRPCError {
47
+ constructor(src: XRPCError) {
48
+ super(src.status, src.error, src.message, src.headers, { cause: src })
49
+ }
50
+ }
51
+
52
+ export class InvalidPhoneError extends XRPCError {
53
+ constructor(src: XRPCError) {
54
+ super(src.status, src.error, src.message, src.headers, { cause: src })
55
+ }
56
+ }
57
+
58
+ export class InternalError extends XRPCError {
41
59
  constructor(src: XRPCError) {
42
60
  super(src.status, src.error, src.message, src.headers, { cause: src })
43
61
  }
@@ -45,7 +63,10 @@ export class TODOError extends XRPCError {
45
63
 
46
64
  export function toKnownErr(e: any) {
47
65
  if (e instanceof XRPCError) {
48
- if (e.error === 'TODO') return new TODOError(e)
66
+ if (e.error === 'RateLimitExceeded') return new RateLimitExceededError(e)
67
+ if (e.error === 'InvalidDid') return new InvalidDidError(e)
68
+ if (e.error === 'InvalidPhone') return new InvalidPhoneError(e)
69
+ if (e.error === 'InternalError') return new InternalError(e)
49
70
  }
50
71
 
51
72
  return e
@@ -42,7 +42,31 @@ export interface Response {
42
42
  data: OutputSchema
43
43
  }
44
44
 
45
- export class TODOError extends XRPCError {
45
+ export class RateLimitExceededError extends XRPCError {
46
+ constructor(src: XRPCError) {
47
+ super(src.status, src.error, src.message, src.headers, { cause: src })
48
+ }
49
+ }
50
+
51
+ export class InvalidDidError extends XRPCError {
52
+ constructor(src: XRPCError) {
53
+ super(src.status, src.error, src.message, src.headers, { cause: src })
54
+ }
55
+ }
56
+
57
+ export class InvalidPhoneError extends XRPCError {
58
+ constructor(src: XRPCError) {
59
+ super(src.status, src.error, src.message, src.headers, { cause: src })
60
+ }
61
+ }
62
+
63
+ export class InvalidCodeError extends XRPCError {
64
+ constructor(src: XRPCError) {
65
+ super(src.status, src.error, src.message, src.headers, { cause: src })
66
+ }
67
+ }
68
+
69
+ export class InternalError extends XRPCError {
46
70
  constructor(src: XRPCError) {
47
71
  super(src.status, src.error, src.message, src.headers, { cause: src })
48
72
  }
@@ -50,7 +74,11 @@ export class TODOError extends XRPCError {
50
74
 
51
75
  export function toKnownErr(e: any) {
52
76
  if (e instanceof XRPCError) {
53
- if (e.error === 'TODO') return new TODOError(e)
77
+ if (e.error === 'RateLimitExceeded') return new RateLimitExceededError(e)
78
+ if (e.error === 'InvalidDid') return new InvalidDidError(e)
79
+ if (e.error === 'InvalidPhone') return new InvalidPhoneError(e)
80
+ if (e.error === 'InvalidCode') return new InvalidCodeError(e)
81
+ if (e.error === 'InternalError') return new InternalError(e)
54
82
  }
55
83
 
56
84
  return e
@@ -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
@@ -355,12 +355,13 @@ describe('AtpAgent', () => {
355
355
  expect(typeof sessions[1]).toEqual('undefined')
356
356
  })
357
357
 
358
- it('does not modify or persist the session on a failed refresh', async () => {
359
- const events: string[] = []
360
- const sessions: (AtpSessionData | undefined)[] = []
361
- const persistSession = (evt: AtpSessionEvent, sess?: AtpSessionData) => {
362
- events.push(evt)
363
- sessions.push(sess)
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(1)
411
- expect(events[0]).toEqual('create')
412
- expect(sessions.length).toEqual(1)
413
- expect(sessions[0]?.accessJwt).toEqual(origAccessJwt)
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', () => {