Version packages ()

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot] 2024-08-12 22:55:19 -04:00 committed by GitHub
parent 22af354a5d
commit cf988a5b4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 156 additions and 103 deletions

@ -1,5 +0,0 @@
---
"@atproto/api": patch
---
Export AtpAgentOptions type to better support extending AtpAgent.

@ -1,5 +1,11 @@
# @atproto/api
## 0.13.1
### Patch Changes
- [#2708](https://github.com/bluesky-social/atproto/pull/2708) [`22af354a5`](https://github.com/bluesky-social/atproto/commit/22af354a5db595d7cbc0e65f02601de3565337e1) Thanks [@devinivy](https://github.com/devinivy)! - Export AtpAgentOptions type to better support extending AtpAgent.
## 0.13.0
### Minor Changes
@ -42,7 +48,7 @@
`AtpAgent`.
```ts
import { Agent, AtpAgent } from '@atproto/api'
import { Agent, AtpAgent } from "@atproto/api";
async function setupAgent(
service: string,
@ -54,30 +60,30 @@
persistSession: (evt, session) => {
// handle session update
},
})
});
await agent.login(username, password)
await agent.login(username, password);
return agent
return agent;
}
```
```ts
import { Agent } from '@atproto/api'
import { Agent } from "@atproto/api";
async function doStuffWithAgent(agent: Agent, arg: string) {
return agent.resolveHandle(arg)
return agent.resolveHandle(arg);
}
```
```ts
import { Agent, AtpAgent } from '@atproto/api'
import { Agent, AtpAgent } from "@atproto/api";
class MyClass {
agent: Agent
agent: Agent;
constructor() {
this.agent = new AtpAgent()
this.agent = new AtpAgent();
}
}
```
@ -155,24 +161,24 @@
<td>
```ts
import { AtpBaseClient, ComAtprotoSyncSubscribeRepos } from '@atproto/api'
import { AtpBaseClient, ComAtprotoSyncSubscribeRepos } from "@atproto/api";
const baseClient = new AtpBaseClient()
const baseClient = new AtpBaseClient();
baseClient.xrpc.lex.assertValidXrpcMessage('io.example.doStuff', {
baseClient.xrpc.lex.assertValidXrpcMessage("io.example.doStuff", {
// ...
})
});
```
</td>
<td>
```ts
import { lexicons } from '@atproto/api'
import { lexicons } from "@atproto/api";
lexicons.assertValidXrpcMessage('io.example.doStuff', {
lexicons.assertValidXrpcMessage("io.example.doStuff", {
// ...
})
});
```
</td>
@ -189,23 +195,23 @@
<td>
```ts
import { BskyAgent } from '@atproto/api'
import { BskyAgent } from "@atproto/api";
class MyAgent extends BskyAgent {
private accessToken?: string
private accessToken?: string;
async createOrRefreshSession(identifier: string, password: string) {
// custom logic here
this.accessToken = 'my-access-jwt'
this.accessToken = "my-access-jwt";
}
async doStuff() {
return this.call('io.example.doStuff', {
return this.call("io.example.doStuff", {
headers: {
Authorization: this.accessToken && `Bearer ${this.accessToken}`,
},
})
});
}
}
```
@ -214,11 +220,11 @@
<td>
```ts
import { Agent } from '@atproto/api'
import { Agent } from "@atproto/api";
class MyAgent extends Agent {
private accessToken?: string
public did?: string
private accessToken?: string;
public did?: string;
constructor(private readonly service: string | URL) {
super({
@ -227,21 +233,21 @@
Authorization: () =>
this.accessToken ? `Bearer ${this.accessToken}` : null,
},
})
});
}
clone(): MyAgent {
const agent = new MyAgent(this.service)
agent.accessToken = this.accessToken
agent.did = this.did
return this.copyInto(agent)
const agent = new MyAgent(this.service);
agent.accessToken = this.accessToken;
agent.did = this.did;
return this.copyInto(agent);
}
async createOrRefreshSession(identifier: string, password: string) {
// custom logic here
this.did = 'did:example:123'
this.accessToken = 'my-access-jwt'
this.did = "did:example:123";
this.accessToken = "my-access-jwt";
}
}
```
@ -260,38 +266,38 @@
<td>
```ts
import { BskyAgent } from '@atproto/api'
import { RateLimitThreshold } from 'rate-limit-threshold'
import { BskyAgent } from "@atproto/api";
import { RateLimitThreshold } from "rate-limit-threshold";
const agent = new BskyAgent()
const limiter = new RateLimitThreshold(3000, 300_000)
const agent = new BskyAgent();
const limiter = new RateLimitThreshold(3000, 300_000);
const origCall = agent.api.xrpc.call
const origCall = agent.api.xrpc.call;
agent.api.xrpc.call = async function (...args) {
await limiter.wait()
return origCall.call(this, ...args)
}
await limiter.wait();
return origCall.call(this, ...args);
};
```
</td>
<td>
```ts
import { AtpAgent } from '@atproto/api'
import { RateLimitThreshold } from 'rate-limit-threshold'
import { AtpAgent } from "@atproto/api";
import { RateLimitThreshold } from "rate-limit-threshold";
class LimitedAtpAgent extends AtpAgent {
constructor(options: AtpAgentOptions) {
const fetch: typeof globalThis.fetch = options.fetch ?? globalThis.fetch
const limiter = new RateLimitThreshold(3000, 300_000)
const fetch: typeof globalThis.fetch = options.fetch ?? globalThis.fetch;
const limiter = new RateLimitThreshold(3000, 300_000);
super({
...options,
fetch: async (...args) => {
await limiter.wait()
return fetch(...args)
await limiter.wait();
return fetch(...args);
},
})
});
}
}
```
@ -312,40 +318,40 @@
<td>
```ts
import { BskyAgent, defaultFetchHandler } from '@atproto/api'
import { BskyAgent, defaultFetchHandler } from "@atproto/api";
BskyAgent.configure({
fetch: async (httpUri, httpMethod, httpHeaders, httpReqBody) => {
const ua = httpHeaders['User-Agent']
const ua = httpHeaders["User-Agent"];
httpHeaders['User-Agent'] = ua ? `${ua} ${userAgent}` : userAgent
httpHeaders["User-Agent"] = ua ? `${ua} ${userAgent}` : userAgent;
return defaultFetchHandler(httpUri, httpMethod, httpHeaders, httpReqBody)
return defaultFetchHandler(httpUri, httpMethod, httpHeaders, httpReqBody);
},
})
});
```
</td>
<td>
```ts
import { AtpAgent } from '@atproto/api'
import { AtpAgent } from "@atproto/api";
class MyAtpAgent extends AtpAgent {
constructor(options: AtpAgentOptions) {
const fetch = options.fetch ?? globalThis.fetch
const fetch = options.fetch ?? globalThis.fetch;
super({
...options,
fetch: async (url, init) => {
const headers = new Headers(init.headers)
const headers = new Headers(init.headers);
const ua = headersList.get('User-Agent')
headersList.set('User-Agent', ua ? `${ua} ${userAgent}` : userAgent)
const ua = headersList.get("User-Agent");
headersList.set("User-Agent", ua ? `${ua} ${userAgent}` : userAgent);
return fetch(url, { ...init, headers })
return fetch(url, { ...init, headers });
},
})
});
}
}
```
@ -404,7 +410,7 @@
*/
url: string,
init: RequestInit,
) => Promise<Response>
) => Promise<Response>;
```
A noticeable change that has been introduced is that the `uri` field of the
@ -442,7 +448,7 @@
<td>
```ts
import client, { defaultFetchHandler } from '@atproto/xrpc'
import client, { defaultFetchHandler } from "@atproto/xrpc";
client.fetch = function (
httpUri: string,
@ -451,50 +457,50 @@
httpReqBody: unknown,
) {
// Custom logic here
return defaultFetchHandler(httpUri, httpMethod, httpHeaders, httpReqBody)
}
return defaultFetchHandler(httpUri, httpMethod, httpHeaders, httpReqBody);
};
client.addLexicon({
lexicon: 1,
id: 'io.example.doStuff',
id: "io.example.doStuff",
defs: {},
})
});
const instance = client.service('http://my-service.com')
const instance = client.service("http://my-service.com");
instance.setHeader('my-header', 'my-value')
instance.setHeader("my-header", "my-value");
await instance.call('io.example.doStuff')
await instance.call("io.example.doStuff");
```
</td>
<td>
```ts
import { XrpcClient } from '@atproto/xrpc'
import { XrpcClient } from "@atproto/xrpc";
const instance = new XrpcClient(
async (url, init) => {
const headers = new Headers(init.headers)
const headers = new Headers(init.headers);
headers.set('my-header', 'my-value')
headers.set("my-header", "my-value");
// Custom logic here
const fullUrl = new URL(url, 'http://my-service.com')
const fullUrl = new URL(url, "http://my-service.com");
return fetch(fullUrl, { ...init, headers })
return fetch(fullUrl, { ...init, headers });
},
[
{
lexicon: 1,
id: 'io.example.doStuff',
id: "io.example.doStuff",
defs: {},
},
],
)
);
await instance.call('io.example.doStuff')
await instance.call("io.example.doStuff");
```
</td>
@ -506,62 +512,62 @@
previous example can be simplified to:
```ts
import { XrpcClient } from '@atproto/xrpc'
import { XrpcClient } from "@atproto/xrpc";
const instance = new XrpcClient('http://my-service.com', [
const instance = new XrpcClient("http://my-service.com", [
{
lexicon: 1,
id: 'io.example.doStuff',
id: "io.example.doStuff",
defs: {},
},
])
]);
```
If you need to add static headers to all requests, you can instead instantiate
the `XrpcClient` as follows:
```ts
import { XrpcClient } from '@atproto/xrpc'
import { XrpcClient } from "@atproto/xrpc";
const instance = new XrpcClient(
{
service: 'http://my-service.com',
service: "http://my-service.com",
headers: {
'my-header': 'my-value',
"my-header": "my-value",
},
},
[
{
lexicon: 1,
id: 'io.example.doStuff',
id: "io.example.doStuff",
defs: {},
},
],
)
);
```
If you need the headers or service url to be dynamic, you can define them using
functions:
```ts
import { XrpcClient } from '@atproto/xrpc'
import { XrpcClient } from "@atproto/xrpc";
const instance = new XrpcClient(
{
service: () => 'http://my-service.com',
service: () => "http://my-service.com",
headers: {
'my-header': () => 'my-value',
'my-ignored-header': () => null, // ignored
"my-header": () => "my-value",
"my-ignored-header": () => null, // ignored
},
},
[
{
lexicon: 1,
id: 'io.example.doStuff',
id: "io.example.doStuff",
defs: {},
},
],
)
);
```
- [#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.

@ -1,6 +1,6 @@
{
"name": "@atproto/api",
"version": "0.13.0",
"version": "0.13.1",
"license": "MIT",
"description": "Client library for atproto and Bluesky",
"keywords": [

@ -1,5 +1,12 @@
# @atproto/bsky
## 0.0.75
### Patch Changes
- Updated dependencies [[`22af354a5`](https://github.com/bluesky-social/atproto/commit/22af354a5db595d7cbc0e65f02601de3565337e1)]:
- @atproto/api@0.13.1
## 0.0.74
### Patch Changes

@ -1,6 +1,6 @@
{
"name": "@atproto/bsky",
"version": "0.0.74",
"version": "0.0.75",
"license": "MIT",
"description": "Reference implementation of app.bsky App View (Bluesky API)",
"keywords": [

@ -1,5 +1,15 @@
# @atproto/dev-env
## 0.3.40
### Patch Changes
- Updated dependencies [[`22af354a5`](https://github.com/bluesky-social/atproto/commit/22af354a5db595d7cbc0e65f02601de3565337e1)]:
- @atproto/api@0.13.1
- @atproto/bsky@0.0.75
- @atproto/ozone@0.1.37
- @atproto/pds@0.4.49
## 0.3.39
### Patch Changes

@ -1,6 +1,6 @@
{
"name": "@atproto/dev-env",
"version": "0.3.39",
"version": "0.3.40",
"license": "MIT",
"description": "Local development environment helper for atproto development",
"keywords": [

@ -1,5 +1,12 @@
# @atproto/oauth-client-browser
## 0.1.3
### Patch Changes
- Updated dependencies []:
- @atproto/oauth-client@0.1.3
## 0.1.2
### Patch Changes

@ -1,6 +1,6 @@
{
"name": "@atproto/oauth-client-browser",
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"description": "ATPROTO OAuth client for the browser (relies on WebCrypto & Indexed DB)",
"keywords": [

@ -1,5 +1,12 @@
# @atproto/oauth-client-node
## 0.0.3
### Patch Changes
- Updated dependencies []:
- @atproto/oauth-client@0.1.3
## 0.0.2
### Patch Changes

@ -1,6 +1,6 @@
{
"name": "@atproto/oauth-client-node",
"version": "0.0.2",
"version": "0.0.3",
"license": "MIT",
"description": "ATPROTO OAuth client for the NodeJS",
"keywords": [

@ -1,5 +1,12 @@
# @atproto/oauth-client
## 0.1.3
### Patch Changes
- Updated dependencies [[`22af354a5`](https://github.com/bluesky-social/atproto/commit/22af354a5db595d7cbc0e65f02601de3565337e1)]:
- @atproto/api@0.13.1
## 0.1.2
### Patch Changes

@ -1,6 +1,6 @@
{
"name": "@atproto/oauth-client",
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"description": "OAuth client for ATPROTO PDS. This package serves as common base for environment-specific implementations (NodeJS, Browser, React-Native).",
"keywords": [

@ -1,5 +1,12 @@
# @atproto/ozone
## 0.1.37
### Patch Changes
- Updated dependencies [[`22af354a5`](https://github.com/bluesky-social/atproto/commit/22af354a5db595d7cbc0e65f02601de3565337e1)]:
- @atproto/api@0.13.1
## 0.1.36
### Patch Changes

@ -1,6 +1,6 @@
{
"name": "@atproto/ozone",
"version": "0.1.36",
"version": "0.1.37",
"license": "MIT",
"description": "Backend service for moderating the Bluesky network.",
"keywords": [

@ -1,5 +1,12 @@
# @atproto/pds
## 0.4.49
### Patch Changes
- Updated dependencies [[`22af354a5`](https://github.com/bluesky-social/atproto/commit/22af354a5db595d7cbc0e65f02601de3565337e1)]:
- @atproto/api@0.13.1
## 0.4.48
### Patch Changes

@ -1,6 +1,6 @@
{
"name": "@atproto/pds",
"version": "0.4.48",
"version": "0.4.49",
"license": "MIT",
"description": "Reference implementation of atproto Personal Data Server (PDS)",
"keywords": [