@atproto/api 0.18.2 → 0.18.3

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atproto/api
2
2
 
3
+ ## 0.18.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4347](https://github.com/bluesky-social/atproto/pull/4347) [`69f53d6`](https://github.com/bluesky-social/atproto/commit/69f53d632d84f255cafa8b10698184048a71b97b) Thanks [@bnewbold](https://github.com/bnewbold)! - lexicon updates to have fully-qualified token refs in knownValue lists
8
+
9
+ - Updated dependencies []:
10
+ - @atproto/common-web@0.4.5
11
+
3
12
  ## 0.18.2
4
13
 
5
14
  ### Patch Changes
@@ -866,7 +875,7 @@
866
875
  `AtpAgent`.
867
876
 
868
877
  ```ts
869
- import { Agent, AtpAgent } from "@atproto/api";
878
+ import { Agent, AtpAgent } from '@atproto/api'
870
879
 
871
880
  async function setupAgent(
872
881
  service: string,
@@ -878,30 +887,30 @@
878
887
  persistSession: (evt, session) => {
879
888
  // handle session update
880
889
  },
881
- });
890
+ })
882
891
 
883
- await agent.login(username, password);
892
+ await agent.login(username, password)
884
893
 
885
- return agent;
894
+ return agent
886
895
  }
887
896
  ```
888
897
 
889
898
  ```ts
890
- import { Agent } from "@atproto/api";
899
+ import { Agent } from '@atproto/api'
891
900
 
892
901
  async function doStuffWithAgent(agent: Agent, arg: string) {
893
- return agent.resolveHandle(arg);
902
+ return agent.resolveHandle(arg)
894
903
  }
895
904
  ```
896
905
 
897
906
  ```ts
898
- import { Agent, AtpAgent } from "@atproto/api";
907
+ import { Agent, AtpAgent } from '@atproto/api'
899
908
 
900
909
  class MyClass {
901
- agent: Agent;
910
+ agent: Agent
902
911
 
903
912
  constructor() {
904
- this.agent = new AtpAgent();
913
+ this.agent = new AtpAgent()
905
914
  }
906
915
  }
907
916
  ```
@@ -979,24 +988,24 @@
979
988
  <td>
980
989
 
981
990
  ```ts
982
- import { AtpBaseClient, ComAtprotoSyncSubscribeRepos } from "@atproto/api";
991
+ import { AtpBaseClient, ComAtprotoSyncSubscribeRepos } from '@atproto/api'
983
992
 
984
- const baseClient = new AtpBaseClient();
993
+ const baseClient = new AtpBaseClient()
985
994
 
986
- baseClient.xrpc.lex.assertValidXrpcMessage("io.example.doStuff", {
995
+ baseClient.xrpc.lex.assertValidXrpcMessage('io.example.doStuff', {
987
996
  // ...
988
- });
997
+ })
989
998
  ```
990
999
 
991
1000
  </td>
992
1001
  <td>
993
1002
 
994
1003
  ```ts
995
- import { lexicons } from "@atproto/api";
1004
+ import { lexicons } from '@atproto/api'
996
1005
 
997
- lexicons.assertValidXrpcMessage("io.example.doStuff", {
1006
+ lexicons.assertValidXrpcMessage('io.example.doStuff', {
998
1007
  // ...
999
- });
1008
+ })
1000
1009
  ```
1001
1010
 
1002
1011
  </td>
@@ -1013,23 +1022,23 @@
1013
1022
  <td>
1014
1023
 
1015
1024
  ```ts
1016
- import { BskyAgent } from "@atproto/api";
1025
+ import { BskyAgent } from '@atproto/api'
1017
1026
 
1018
1027
  class MyAgent extends BskyAgent {
1019
- private accessToken?: string;
1028
+ private accessToken?: string
1020
1029
 
1021
1030
  async createOrRefreshSession(identifier: string, password: string) {
1022
1031
  // custom logic here
1023
1032
 
1024
- this.accessToken = "my-access-jwt";
1033
+ this.accessToken = 'my-access-jwt'
1025
1034
  }
1026
1035
 
1027
1036
  async doStuff() {
1028
- return this.call("io.example.doStuff", {
1037
+ return this.call('io.example.doStuff', {
1029
1038
  headers: {
1030
1039
  Authorization: this.accessToken && `Bearer ${this.accessToken}`,
1031
1040
  },
1032
- });
1041
+ })
1033
1042
  }
1034
1043
  }
1035
1044
  ```
@@ -1038,11 +1047,11 @@
1038
1047
  <td>
1039
1048
 
1040
1049
  ```ts
1041
- import { Agent } from "@atproto/api";
1050
+ import { Agent } from '@atproto/api'
1042
1051
 
1043
1052
  class MyAgent extends Agent {
1044
- private accessToken?: string;
1045
- public did?: string;
1053
+ private accessToken?: string
1054
+ public did?: string
1046
1055
 
1047
1056
  constructor(private readonly service: string | URL) {
1048
1057
  super({
@@ -1051,21 +1060,21 @@
1051
1060
  Authorization: () =>
1052
1061
  this.accessToken ? `Bearer ${this.accessToken}` : null,
1053
1062
  },
1054
- });
1063
+ })
1055
1064
  }
1056
1065
 
1057
1066
  clone(): MyAgent {
1058
- const agent = new MyAgent(this.service);
1059
- agent.accessToken = this.accessToken;
1060
- agent.did = this.did;
1061
- return this.copyInto(agent);
1067
+ const agent = new MyAgent(this.service)
1068
+ agent.accessToken = this.accessToken
1069
+ agent.did = this.did
1070
+ return this.copyInto(agent)
1062
1071
  }
1063
1072
 
1064
1073
  async createOrRefreshSession(identifier: string, password: string) {
1065
1074
  // custom logic here
1066
1075
 
1067
- this.did = "did:example:123";
1068
- this.accessToken = "my-access-jwt";
1076
+ this.did = 'did:example:123'
1077
+ this.accessToken = 'my-access-jwt'
1069
1078
  }
1070
1079
  }
1071
1080
  ```
@@ -1084,38 +1093,38 @@
1084
1093
  <td>
1085
1094
 
1086
1095
  ```ts
1087
- import { BskyAgent } from "@atproto/api";
1088
- import { RateLimitThreshold } from "rate-limit-threshold";
1096
+ import { BskyAgent } from '@atproto/api'
1097
+ import { RateLimitThreshold } from 'rate-limit-threshold'
1089
1098
 
1090
- const agent = new BskyAgent();
1091
- const limiter = new RateLimitThreshold(3000, 300_000);
1099
+ const agent = new BskyAgent()
1100
+ const limiter = new RateLimitThreshold(3000, 300_000)
1092
1101
 
1093
- const origCall = agent.api.xrpc.call;
1102
+ const origCall = agent.api.xrpc.call
1094
1103
  agent.api.xrpc.call = async function (...args) {
1095
- await limiter.wait();
1096
- return origCall.call(this, ...args);
1097
- };
1104
+ await limiter.wait()
1105
+ return origCall.call(this, ...args)
1106
+ }
1098
1107
  ```
1099
1108
 
1100
1109
  </td>
1101
1110
  <td>
1102
1111
 
1103
1112
  ```ts
1104
- import { AtpAgent } from "@atproto/api";
1105
- import { RateLimitThreshold } from "rate-limit-threshold";
1113
+ import { AtpAgent } from '@atproto/api'
1114
+ import { RateLimitThreshold } from 'rate-limit-threshold'
1106
1115
 
1107
1116
  class LimitedAtpAgent extends AtpAgent {
1108
1117
  constructor(options: AtpAgentOptions) {
1109
- const fetch: typeof globalThis.fetch = options.fetch ?? globalThis.fetch;
1110
- const limiter = new RateLimitThreshold(3000, 300_000);
1118
+ const fetch: typeof globalThis.fetch = options.fetch ?? globalThis.fetch
1119
+ const limiter = new RateLimitThreshold(3000, 300_000)
1111
1120
 
1112
1121
  super({
1113
1122
  ...options,
1114
1123
  fetch: async (...args) => {
1115
- await limiter.wait();
1116
- return fetch(...args);
1124
+ await limiter.wait()
1125
+ return fetch(...args)
1117
1126
  },
1118
- });
1127
+ })
1119
1128
  }
1120
1129
  }
1121
1130
  ```
@@ -1136,40 +1145,40 @@
1136
1145
  <td>
1137
1146
 
1138
1147
  ```ts
1139
- import { BskyAgent, defaultFetchHandler } from "@atproto/api";
1148
+ import { BskyAgent, defaultFetchHandler } from '@atproto/api'
1140
1149
 
1141
1150
  BskyAgent.configure({
1142
1151
  fetch: async (httpUri, httpMethod, httpHeaders, httpReqBody) => {
1143
- const ua = httpHeaders["User-Agent"];
1152
+ const ua = httpHeaders['User-Agent']
1144
1153
 
1145
- httpHeaders["User-Agent"] = ua ? `${ua} ${userAgent}` : userAgent;
1154
+ httpHeaders['User-Agent'] = ua ? `${ua} ${userAgent}` : userAgent
1146
1155
 
1147
- return defaultFetchHandler(httpUri, httpMethod, httpHeaders, httpReqBody);
1156
+ return defaultFetchHandler(httpUri, httpMethod, httpHeaders, httpReqBody)
1148
1157
  },
1149
- });
1158
+ })
1150
1159
  ```
1151
1160
 
1152
1161
  </td>
1153
1162
  <td>
1154
1163
 
1155
1164
  ```ts
1156
- import { AtpAgent } from "@atproto/api";
1165
+ import { AtpAgent } from '@atproto/api'
1157
1166
 
1158
1167
  class MyAtpAgent extends AtpAgent {
1159
1168
  constructor(options: AtpAgentOptions) {
1160
- const fetch = options.fetch ?? globalThis.fetch;
1169
+ const fetch = options.fetch ?? globalThis.fetch
1161
1170
 
1162
1171
  super({
1163
1172
  ...options,
1164
1173
  fetch: async (url, init) => {
1165
- const headers = new Headers(init.headers);
1174
+ const headers = new Headers(init.headers)
1166
1175
 
1167
- const ua = headersList.get("User-Agent");
1168
- headersList.set("User-Agent", ua ? `${ua} ${userAgent}` : userAgent);
1176
+ const ua = headersList.get('User-Agent')
1177
+ headersList.set('User-Agent', ua ? `${ua} ${userAgent}` : userAgent)
1169
1178
 
1170
- return fetch(url, { ...init, headers });
1179
+ return fetch(url, { ...init, headers })
1171
1180
  },
1172
- });
1181
+ })
1173
1182
  }
1174
1183
  }
1175
1184
  ```
@@ -1228,7 +1237,7 @@
1228
1237
  */
1229
1238
  url: string,
1230
1239
  init: RequestInit,
1231
- ) => Promise<Response>;
1240
+ ) => Promise<Response>
1232
1241
  ```
1233
1242
 
1234
1243
  A noticeable change that has been introduced is that the `uri` field of the
@@ -1266,7 +1275,7 @@
1266
1275
  <td>
1267
1276
 
1268
1277
  ```ts
1269
- import client, { defaultFetchHandler } from "@atproto/xrpc";
1278
+ import client, { defaultFetchHandler } from '@atproto/xrpc'
1270
1279
 
1271
1280
  client.fetch = function (
1272
1281
  httpUri: string,
@@ -1275,50 +1284,50 @@
1275
1284
  httpReqBody: unknown,
1276
1285
  ) {
1277
1286
  // Custom logic here
1278
- return defaultFetchHandler(httpUri, httpMethod, httpHeaders, httpReqBody);
1279
- };
1287
+ return defaultFetchHandler(httpUri, httpMethod, httpHeaders, httpReqBody)
1288
+ }
1280
1289
 
1281
1290
  client.addLexicon({
1282
1291
  lexicon: 1,
1283
- id: "io.example.doStuff",
1292
+ id: 'io.example.doStuff',
1284
1293
  defs: {},
1285
- });
1294
+ })
1286
1295
 
1287
- const instance = client.service("http://my-service.com");
1296
+ const instance = client.service('http://my-service.com')
1288
1297
 
1289
- instance.setHeader("my-header", "my-value");
1298
+ instance.setHeader('my-header', 'my-value')
1290
1299
 
1291
- await instance.call("io.example.doStuff");
1300
+ await instance.call('io.example.doStuff')
1292
1301
  ```
1293
1302
 
1294
1303
  </td>
1295
1304
  <td>
1296
1305
 
1297
1306
  ```ts
1298
- import { XrpcClient } from "@atproto/xrpc";
1307
+ import { XrpcClient } from '@atproto/xrpc'
1299
1308
 
1300
1309
  const instance = new XrpcClient(
1301
1310
  async (url, init) => {
1302
- const headers = new Headers(init.headers);
1311
+ const headers = new Headers(init.headers)
1303
1312
 
1304
- headers.set("my-header", "my-value");
1313
+ headers.set('my-header', 'my-value')
1305
1314
 
1306
1315
  // Custom logic here
1307
1316
 
1308
- const fullUrl = new URL(url, "http://my-service.com");
1317
+ const fullUrl = new URL(url, 'http://my-service.com')
1309
1318
 
1310
- return fetch(fullUrl, { ...init, headers });
1319
+ return fetch(fullUrl, { ...init, headers })
1311
1320
  },
1312
1321
  [
1313
1322
  {
1314
1323
  lexicon: 1,
1315
- id: "io.example.doStuff",
1324
+ id: 'io.example.doStuff',
1316
1325
  defs: {},
1317
1326
  },
1318
1327
  ],
1319
- );
1328
+ )
1320
1329
 
1321
- await instance.call("io.example.doStuff");
1330
+ await instance.call('io.example.doStuff')
1322
1331
  ```
1323
1332
 
1324
1333
  </td>
@@ -1330,62 +1339,62 @@
1330
1339
  previous example can be simplified to:
1331
1340
 
1332
1341
  ```ts
1333
- import { XrpcClient } from "@atproto/xrpc";
1342
+ import { XrpcClient } from '@atproto/xrpc'
1334
1343
 
1335
- const instance = new XrpcClient("http://my-service.com", [
1344
+ const instance = new XrpcClient('http://my-service.com', [
1336
1345
  {
1337
1346
  lexicon: 1,
1338
- id: "io.example.doStuff",
1347
+ id: 'io.example.doStuff',
1339
1348
  defs: {},
1340
1349
  },
1341
- ]);
1350
+ ])
1342
1351
  ```
1343
1352
 
1344
1353
  If you need to add static headers to all requests, you can instead instantiate
1345
1354
  the `XrpcClient` as follows:
1346
1355
 
1347
1356
  ```ts
1348
- import { XrpcClient } from "@atproto/xrpc";
1357
+ import { XrpcClient } from '@atproto/xrpc'
1349
1358
 
1350
1359
  const instance = new XrpcClient(
1351
1360
  {
1352
- service: "http://my-service.com",
1361
+ service: 'http://my-service.com',
1353
1362
  headers: {
1354
- "my-header": "my-value",
1363
+ 'my-header': 'my-value',
1355
1364
  },
1356
1365
  },
1357
1366
  [
1358
1367
  {
1359
1368
  lexicon: 1,
1360
- id: "io.example.doStuff",
1369
+ id: 'io.example.doStuff',
1361
1370
  defs: {},
1362
1371
  },
1363
1372
  ],
1364
- );
1373
+ )
1365
1374
  ```
1366
1375
 
1367
1376
  If you need the headers or service url to be dynamic, you can define them using
1368
1377
  functions:
1369
1378
 
1370
1379
  ```ts
1371
- import { XrpcClient } from "@atproto/xrpc";
1380
+ import { XrpcClient } from '@atproto/xrpc'
1372
1381
 
1373
1382
  const instance = new XrpcClient(
1374
1383
  {
1375
- service: () => "http://my-service.com",
1384
+ service: () => 'http://my-service.com',
1376
1385
  headers: {
1377
- "my-header": () => "my-value",
1378
- "my-ignored-header": () => null, // ignored
1386
+ 'my-header': () => 'my-value',
1387
+ 'my-ignored-header': () => null, // ignored
1379
1388
  },
1380
1389
  },
1381
1390
  [
1382
1391
  {
1383
1392
  lexicon: 1,
1384
- id: "io.example.doStuff",
1393
+ id: 'io.example.doStuff',
1385
1394
  defs: {},
1386
1395
  },
1387
1396
  ],
1388
- );
1397
+ )
1389
1398
  ```
1390
1399
 
1391
1400
  - [#2483](https://github.com/bluesky-social/atproto/pull/2483) [`b934b396b`](https://github.com/bluesky-social/atproto/commit/b934b396b13ba32bf2bf7e75ecdf6871e5f310dd) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add the ability to use `fetch()` compatible `BodyInit` body when making XRPC calls.
@@ -14050,7 +14050,7 @@ export declare const schemaDict: {
14050
14050
  };
14051
14051
  readonly subjectReviewState: {
14052
14052
  readonly type: "string";
14053
- readonly knownValues: ["lex:tools.ozone.moderation.defs#reviewOpen", "lex:tools.ozone.moderation.defs#reviewEscalated", "lex:tools.ozone.moderation.defs#reviewClosed", "lex:tools.ozone.moderation.defs#reviewNone"];
14053
+ readonly knownValues: ["tools.ozone.moderation.defs#reviewOpen", "tools.ozone.moderation.defs#reviewEscalated", "tools.ozone.moderation.defs#reviewClosed", "tools.ozone.moderation.defs#reviewNone"];
14054
14054
  };
14055
14055
  readonly reviewOpen: {
14056
14056
  readonly type: "token";
@@ -17457,7 +17457,7 @@ export declare const schemaDict: {
17457
17457
  };
17458
17458
  readonly role: {
17459
17459
  readonly type: "string";
17460
- readonly knownValues: ["lex:tools.ozone.team.defs#roleAdmin", "lex:tools.ozone.team.defs#roleModerator", "lex:tools.ozone.team.defs#roleTriage", "lex:tools.ozone.team.defs#roleVerifier"];
17460
+ readonly knownValues: ["tools.ozone.team.defs#roleAdmin", "tools.ozone.team.defs#roleModerator", "tools.ozone.team.defs#roleTriage", "tools.ozone.team.defs#roleVerifier"];
17461
17461
  };
17462
17462
  };
17463
17463
  };
@@ -31725,7 +31725,7 @@ export declare const schemas: ({
31725
31725
  };
31726
31726
  readonly subjectReviewState: {
31727
31727
  readonly type: "string";
31728
- readonly knownValues: ["lex:tools.ozone.moderation.defs#reviewOpen", "lex:tools.ozone.moderation.defs#reviewEscalated", "lex:tools.ozone.moderation.defs#reviewClosed", "lex:tools.ozone.moderation.defs#reviewNone"];
31728
+ readonly knownValues: ["tools.ozone.moderation.defs#reviewOpen", "tools.ozone.moderation.defs#reviewEscalated", "tools.ozone.moderation.defs#reviewClosed", "tools.ozone.moderation.defs#reviewNone"];
31729
31729
  };
31730
31730
  readonly reviewOpen: {
31731
31731
  readonly type: "token";
@@ -35093,7 +35093,7 @@ export declare const schemas: ({
35093
35093
  };
35094
35094
  readonly role: {
35095
35095
  readonly type: "string";
35096
- readonly knownValues: ["lex:tools.ozone.team.defs#roleAdmin", "lex:tools.ozone.team.defs#roleModerator", "lex:tools.ozone.team.defs#roleTriage", "lex:tools.ozone.team.defs#roleVerifier"];
35096
+ readonly knownValues: ["tools.ozone.team.defs#roleAdmin", "tools.ozone.team.defs#roleModerator", "tools.ozone.team.defs#roleTriage", "tools.ozone.team.defs#roleVerifier"];
35097
35097
  };
35098
35098
  };
35099
35099
  };
@@ -14720,10 +14720,10 @@ exports.schemaDict = {
14720
14720
  subjectReviewState: {
14721
14721
  type: 'string',
14722
14722
  knownValues: [
14723
- 'lex:tools.ozone.moderation.defs#reviewOpen',
14724
- 'lex:tools.ozone.moderation.defs#reviewEscalated',
14725
- 'lex:tools.ozone.moderation.defs#reviewClosed',
14726
- 'lex:tools.ozone.moderation.defs#reviewNone',
14723
+ 'tools.ozone.moderation.defs#reviewOpen',
14724
+ 'tools.ozone.moderation.defs#reviewEscalated',
14725
+ 'tools.ozone.moderation.defs#reviewClosed',
14726
+ 'tools.ozone.moderation.defs#reviewNone',
14727
14727
  ],
14728
14728
  },
14729
14729
  reviewOpen: {
@@ -18384,10 +18384,10 @@ exports.schemaDict = {
18384
18384
  role: {
18385
18385
  type: 'string',
18386
18386
  knownValues: [
18387
- 'lex:tools.ozone.team.defs#roleAdmin',
18388
- 'lex:tools.ozone.team.defs#roleModerator',
18389
- 'lex:tools.ozone.team.defs#roleTriage',
18390
- 'lex:tools.ozone.team.defs#roleVerifier',
18387
+ 'tools.ozone.team.defs#roleAdmin',
18388
+ 'tools.ozone.team.defs#roleModerator',
18389
+ 'tools.ozone.team.defs#roleTriage',
18390
+ 'tools.ozone.team.defs#roleVerifier',
18391
18391
  ],
18392
18392
  },
18393
18393
  },