-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version packages #2706
Version packages #2706
Conversation
packages/api/CHANGELOG.md
Outdated
class MyAgent extends BskyAgent { | ||
private accessToken?: string; | ||
|
||
async createOrRefleshSession(identifier: string, password: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async createOrRefleshSession(identifier: string, password: string) { | |
async createOrRefreshSession(identifier: string, password: string) { |
I think there's a typo here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks!
packages/api/CHANGELOG.md
Outdated
</tr> | ||
</table> | ||
|
||
If you are monkey patching the the `xrpc` service client to perform client-side rate limiting, you can now do this in the `FetchHandler` function: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are monkey patching the the `xrpc` service client to perform client-side rate limiting, you can now do this in the `FetchHandler` function: | |
If you are monkey patching the `xrpc` service client to perform client-side rate limiting, you can now do this in the `FetchHandler` function: |
the
is repeated
packages/api/CHANGELOG.md
Outdated
Since its use has completely changed, the `FetchHandler` type has also | ||
completely changed. The new `FetchHandler` type is now a function that receives | ||
a `url` pathname and a `RequestInit` object and returns a `Promise<Response>`. | ||
This function is responsible from making the actual request to the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is responsible from making the actual request to the server. | |
This function is responsible for making the actual request to the server. |
This sounds like it should be for
?
e9f90eb
to
9db352b
Compare
* origin/main: Provide a ponyfill for CustomEvent (#2710) Ensure presence of DPoP related response headers (#2711) prettier ignore changelogs, as changesets not resolving prettier config properly Version packages (#2709) Export `AtpAgentOptions` type from @atproto/api (#2708) tidy Version packages (#2706) Update changeset to better reflect changes (#2707) Client SDK rework (#2483) Allow aud of pds or entryway for service auth tokens on pds (#2694) Version packages (#2692) Lex-cli prettier changes changeset (#2691) Version packages (#2689) PDS - inspect bearer tokens (#2688) Version packages (#2685) Service auth method binding - PDS (#2668) minor typos in descriptions and comments (#2681) Fix run-dev-env-logged command (#2682) Version packages (#2677) Tweak some wording in `oauth-client-browser` readme (#2678)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@atproto/api@0.13.0
Minor Changes
#2483
b934b396b
Thanks @matthieusieben! - ## MotivationThe motivation for these changes is the need to make the
@atproto/api
packagecompatible with OAuth session management. We don't have OAuth client support
"launched" and documented quite yet, so you can keep using the current app
password authentication system. When we do "launch" OAuth support and begin
encouraging its usage in the near future (see the OAuth
Roadmap), these
changes will make it easier to migrate.
In addition, the redesigned session management system fixes a bug that could
cause the session data to become invalid when Agent clones are created (e.g.
using
agent.withProxy()
).New Features
We've restructured the
XrpcClient
HTTP fetch handler to be specified duringthe instantiation of the XRPC client, through the constructor, instead of using
a default implementation (which was statically defined).
With this refactor, the XRPC client is now more modular and reusable. Session
management, retries, cryptographic signing, and other request-specific logic can
be implemented in the fetch handler itself rather than by the calling code.
A new abstract class named
Agent
, has been added to@atproto/api
. This classwill be the base class for all Bluesky agents classes in the
@atproto
ecosystem. It is meant to be extended by implementations that provide session
management and fetch handling.
As you adapt your code to these changes, make sure to use the
Agent
typewherever you expect to receive an agent, and use the
AtpAgent
type (class)only to instantiate your client. The reason for this is to be forward compatible
with the OAuth agent implementation that will also extend
Agent
, and notAtpAgent
.Breaking changes
Most of the changes introduced in this version are backward-compatible. However,
there are a couple of breaking changes you should be aware of:
fetch
: The ability to customize thefetch: FetchHandler
property of
@atproto/xrpc
'sClient
and@atproto/api
'sAtpAgent
classeshas been removed. Previously, the
fetch
property could be set to a functionthat would be used as the fetch handler for that instance, and was initialized
to a default fetch handler. That property is still accessible in a read-only
fashion through the
fetchHandler
property and can only be set during theinstance creation. Attempting to set/get the
fetch
property will now resultin an error.
fetch()
method, as well as WhatWG compliantRequest
andHeaders
constructors, must be globally available in your environment. Use a polyfill
if necessary.
AtpBaseClient
has been removed. TheAtpServiceClient
has been renamedAtpBaseClient
. Any code using either of these classes will need to beupdated.
XrpcClient
in itsxrpc
property, theAtpBaseClient
(formerlyAtpServiceClient
) class - created throughlex-cli
- now extends theXrpcClient
class. This means that a clientinstance now passes the
instanceof XrpcClient
check. Thexrpc
property nowreturns the instance itself and has been deprecated.
setSessionPersistHandler
is no longer available on theAtpAgent
orBskyAgent
classes. The session handler can only be set though thepersistSession
options of theAtpAgent
constructor.BskyAgent
extendsAtpAgent
: but add no functionality (hence itsdeprecation).
AtpAgent
extendsAgent
: adds password based session management.Agent
extendsAtpBaseClient
: this abstract class that adds syntactic sugarmethods
app.bsky
lexicons. It also adds abstract session managementmethods and adds atproto specific utilities
(
labelers
&proxy
headers, cloning capability)AtpBaseClient
extendsXrpcClient
: automatically code that adds fullytyped lexicon defined namespaces (
instance.app.bsky.feed.getPosts()
) tothe
XrpcClient
.XrpcClient
is the base class.Non-breaking changes
com.*
andapp.*
namespaces have been made directly available to everyAgent
instances.Deprecations
@atproto/xrpc
package has been deprecated. Usenamed exports instead.
Client
andServiceClient
classes are now deprecated. They are replaced by a singleXrpcClient
class.@atproto/api
package has been deprecated. Usenamed exports instead.
BskyAgent
has been deprecated. Use theAtpAgent
class instead.xrpc
property of theAtpClient
instances has been deprecated. Theinstance itself should be used as the XRPC client.
api
property of theAtpAgent
andBskyAgent
instances has beendeprecated. Use the instance itself instead.
Migration
The
@atproto/api
packageIf you were relying on the
AtpBaseClient
solely to perform validation, usethis:
If you are extending the
BskyAgent
to perform customsession
manipulation, define your ownAgent
subclass instead:If you are monkey patching the
xrpc
service client to perform client-side rate limiting, you can now do this in theFetchHandler
function:If you configure a static
fetch
handler on theBskyAgent
class - for exampleto modify the headers of every request - you can now do this by providing your
own
fetch
function:The
@atproto/xrpc
packageThe
Client
andServiceClient
classes are now deprecated. If you need alexicon based client, you should update the code to use the
XrpcClient
classinstead.
The deprecated
ServiceClient
class now extends the newXrpcClient
class.Because of this, the
fetch
FetchHandler
can no longer be configured on theClient
instances (including the default export of the package). If you are notrelying on the
fetch
FetchHandler
, the new changes should have no impact onyour code. Beware that the deprecated classes will eventually be removed in a
future version.
Since its use has completely changed, the
FetchHandler
type has alsocompletely changed. The new
FetchHandler
type is now a function that receivesa
url
pathname and aRequestInit
object and returns aPromise<Response>
.This function is responsible for making the actual request to the server.
A noticeable change that has been introduced is that the
uri
field of theServiceClient
class has not been ported to the newXrpcClient
class. It isnow the responsibility of the
FetchHandler
to determine the full URL to makethe request to. The same goes for the
headers
, which should now be set throughthe
FetchHandler
function.If you do rely on the legacy
Client.fetch
property to perform custom logicupon request, you will need to migrate your code to use the new
XrpcClient
class. The
XrpcClient
class has a similar API to the oldServiceClient
class, but with a few differences:
The
Client
+ServiceClient
duality was removed in favor of a singleXrpcClient
class. This means that:lexicon registry, you can maintain one yourself using a
new Lexicons
(from@atproto/lexicon
).FetchHandler
is no longer a statically defined property of theClient
class. Instead, it is passed as an argument to theXrpcClient
constructor.
The
XrpcClient
constructor now requires aFetchHandler
function as thefirst argument, and an optional
Lexicon
instance as the second argument.The
setHeader
andunsetHeader
methods were not ported to the newXrpcClient
class. If you need to set or unset headers, you should do so inthe
FetchHandler
function provided in the constructor arg.If your fetch handler does not require any "custom logic", and all you need is
an
XrpcClient
that makes its HTTP requests towards a static service URL, theprevious example can be simplified to:
If you need to add static headers to all requests, you can instead instantiate
the
XrpcClient
as follows:If you need the headers or service url to be dynamic, you can define them using
functions:
#2483
b934b396b
Thanks @matthieusieben! - Add the ability to usefetch()
compatibleBodyInit
body when making XRPC calls.Patch Changes
b934b396b
,2bdf75d7a
,b934b396b
,b934b396b
]:@atproto/lex-cli@0.5.0
Minor Changes
2bdf75d7a
Thanks @matthieusieben! - The generated client implementation uses the newXrpcClient
class from@atproto/xrpc
, instead of the deprecatedClient
andServiceClient
class.Patch Changes
b934b396b
,2bdf75d7a
]:@atproto/xrpc@0.6.0
Minor Changes
#2483
b934b396b
Thanks @matthieusieben! - ## MotivationThe motivation for these changes is the need to make the
@atproto/api
packagecompatible with OAuth session management. We don't have OAuth client support
"launched" and documented quite yet, so you can keep using the current app
password authentication system. When we do "launch" OAuth support and begin
encouraging its usage in the near future (see the OAuth
Roadmap), these
changes will make it easier to migrate.
In addition, the redesigned session management system fixes a bug that could
cause the session data to become invalid when Agent clones are created (e.g.
using
agent.withProxy()
).New Features
We've restructured the
XrpcClient
HTTP fetch handler to be specified duringthe instantiation of the XRPC client, through the constructor, instead of using
a default implementation (which was statically defined).
With this refactor, the XRPC client is now more modular and reusable. Session
management, retries, cryptographic signing, and other request-specific logic can
be implemented in the fetch handler itself rather than by the calling code.
A new abstract class named
Agent
, has been added to@atproto/api
. This classwill be the base class for all Bluesky agents classes in the
@atproto
ecosystem. It is meant to be extended by implementations that provide session
management and fetch handling.
As you adapt your code to these changes, make sure to use the
Agent
typewherever you expect to receive an agent, and use the
AtpAgent
type (class)only to instantiate your client. The reason for this is to be forward compatible
with the OAuth agent implementation that will also extend
Agent
, and notAtpAgent
.Breaking changes
Most of the changes introduced in this version are backward-compatible. However,
there are a couple of breaking changes you should be aware of:
fetch
: The ability to customize thefetch: FetchHandler
property of
@atproto/xrpc
'sClient
and@atproto/api
'sAtpAgent
classeshas been removed. Previously, the
fetch
property could be set to a functionthat would be used as the fetch handler for that instance, and was initialized
to a default fetch handler. That property is still accessible in a read-only
fashion through the
fetchHandler
property and can only be set during theinstance creation. Attempting to set/get the
fetch
property will now resultin an error.
fetch()
method, as well as WhatWG compliantRequest
andHeaders
constructors, must be globally available in your environment. Use a polyfill
if necessary.
AtpBaseClient
has been removed. TheAtpServiceClient
has been renamedAtpBaseClient
. Any code using either of these classes will need to beupdated.
XrpcClient
in itsxrpc
property, theAtpBaseClient
(formerlyAtpServiceClient
) class - created throughlex-cli
- now extends theXrpcClient
class. This means that a clientinstance now passes the
instanceof XrpcClient
check. Thexrpc
property nowreturns the instance itself and has been deprecated.
setSessionPersistHandler
is no longer available on theAtpAgent
orBskyAgent
classes. The session handler can only be set though thepersistSession
options of theAtpAgent
constructor.BskyAgent
extendsAtpAgent
: but add no functionality (hence itsdeprecation).
AtpAgent
extendsAgent
: adds password based session management.Agent
extendsAtpBaseClient
: this abstract class that adds syntactic sugarmethods
app.bsky
lexicons. It also adds abstract session managementmethods and adds atproto specific utilities
(
labelers
&proxy
headers, cloning capability)AtpBaseClient
extendsXrpcClient
: automatically code that adds fullytyped lexicon defined namespaces (
instance.app.bsky.feed.getPosts()
) tothe
XrpcClient
.XrpcClient
is the base class.Non-breaking changes
com.*
andapp.*
namespaces have been made directly available to everyAgent
instances.Deprecations
@atproto/xrpc
package has been deprecated. Usenamed exports instead.
Client
andServiceClient
classes are now deprecated. They are replaced by a singleXrpcClient
class.@atproto/api
package has been deprecated. Usenamed exports instead.
BskyAgent
has been deprecated. Use theAtpAgent
class instead.xrpc
property of theAtpClient
instances has been deprecated. Theinstance itself should be used as the XRPC client.
api
property of theAtpAgent
andBskyAgent
instances has beendeprecated. Use the instance itself instead.
Migration
The
@atproto/api
packageIf you were relying on the
AtpBaseClient
solely to perform validation, usethis:
If you are extending the
BskyAgent
to perform customsession
manipulation, define your ownAgent
subclass instead:If you are monkey patching the
xrpc
service client to perform client-side rate limiting, you can now do this in theFetchHandler
function:If you configure a static
fetch
handler on theBskyAgent
class - for exampleto modify the headers of every request - you can now do this by providing your
own
fetch
function:The
@atproto/xrpc
packageThe
Client
andServiceClient
classes are now deprecated. If you need alexicon based client, you should update the code to use the
XrpcClient
classinstead.
The deprecated
ServiceClient
class now extends the newXrpcClient
class.Because of this, the
fetch
FetchHandler
can no longer be configured on theClient
instances (including the default export of the package). If you are notrelying on the
fetch
FetchHandler
, the new changes should have no impact onyour code. Beware that the deprecated classes will eventually be removed in a
future version.
Since its use has completely changed, the
FetchHandler
type has alsocompletely changed. The new
FetchHandler
type is now a function that receivesa
url
pathname and aRequestInit
object and returns aPromise<Response>
.This function is responsible for making the actual request to the server.
A noticeable change that has been introduced is that the
uri
field of theServiceClient
class has not been ported to the newXrpcClient
class. It isnow the responsibility of the
FetchHandler
to determine the full URL to makethe request to. The same goes for the
headers
, which should now be set throughthe
FetchHandler
function.If you do rely on the legacy
Client.fetch
property to perform custom logicupon request, you will need to migrate your code to use the new
XrpcClient
class. The
XrpcClient
class has a similar API to the oldServiceClient
class, but with a few differences:
The
Client
+ServiceClient
duality was removed in favor of a singleXrpcClient
class. This means that:lexicon registry, you can maintain one yourself using a
new Lexicons
(from@atproto/lexicon
).FetchHandler
is no longer a statically defined property of theClient
class. Instead, it is passed as an argument to theXrpcClient
constructor.
The
XrpcClient
constructor now requires aFetchHandler
function as thefirst argument, and an optional
Lexicon
instance as the second argument.The
setHeader
andunsetHeader
methods were not ported to the newXrpcClient
class. If you need to set or unset headers, you should do so inthe
FetchHandler
function provided in the constructor arg.If your fetch handler does not require any "custom logic", and all you need is
an
XrpcClient
that makes its HTTP requests towards a static service URL, theprevious example can be simplified to:
If you need to add static headers to all requests, you can instead instantiate
the
XrpcClient
as follows:If you need the headers or service url to be dynamic, you can define them using
functions:
#2483
b934b396b
Thanks @matthieusieben! - Add the ability to usefetch()
compatibleBodyInit
body when making XRPC calls.Patch Changes
b934b396b
,2bdf75d7a
]:@atproto/aws@0.2.2
Patch Changes
@atproto/bsky@0.0.74
Patch Changes
b934b396b
,2bdf75d7a
,b934b396b
,b934b396b
]:@atproto/dev-env@0.3.39
Patch Changes
b934b396b
,2bdf75d7a
,b934b396b
,b934b396b
]:@atproto/did@0.1.1
Patch Changes
b934b396b
Thanks @matthieusieben! - Expose atproto specific types and utilities@atproto-labs/did-resolver@0.1.2
Patch Changes
b934b396b
]:@atproto-labs/handle-resolver@0.1.2
Patch Changes
#2483
b934b396b
Thanks @matthieusieben! - Updated to use "AtprotoDid" utils from @atproto/didUpdated dependencies [
b934b396b
]:@atproto-labs/handle-resolver-node@0.1.2
Patch Changes
b934b396b
,b934b396b
]:@atproto-labs/identity-resolver@0.1.2
Patch Changes
#2483
b934b396b
Thanks @matthieusieben! - Expose getDocumentFromDid and getDocumentFromHandle as public methods on IdentityResolverUpdated dependencies [
b934b396b
]:@atproto/lexicon@0.4.1
Patch Changes
#2483
b934b396b
Thanks @matthieusieben! - Add the ability to instantiate a Lexicon from an iterable, and to use a Lexicon as iterable.#2707
2bdf75d7a
Thanks @matthieusieben! - Remove internal circular dependency.@atproto/jwk-jose@0.1.2
Patch Changes
#2483
b934b396b
Thanks @matthieusieben! - Misc fixes for confidential client usage#2483
b934b396b
Thanks @matthieusieben! - Allow importing JoseKey without specifying a kid@atproto/jwk-webcrypto@0.1.2
Patch Changes
b934b396b
,b934b396b
]:@atproto/oauth-client@0.1.2
Patch Changes
#2483
b934b396b
Thanks @matthieusieben! - Misc fixes for confidential client usage#2483
b934b396b
Thanks @matthieusieben! - Better implement aptroto OAuth specUpdated dependencies [
b934b396b
,b934b396b
,b934b396b
,b934b396b
,b934b396b
,b934b396b
]:@atproto/oauth-client-browser@0.1.2
Patch Changes
b934b396b
,b934b396b
,b934b396b
,b934b396b
]:@atproto/oauth-client-node@0.0.2
Patch Changes
#2483
b934b396b
Thanks @matthieusieben! - Better implement aptroto OAuth specUpdated dependencies [
b934b396b
,b934b396b
,b934b396b
,b934b396b
]:@atproto/oauth-provider@0.1.2
Patch Changes
#2483
b934b396b
Thanks @matthieusieben! - Remove unused fileUpdated dependencies [
b934b396b
,b934b396b
,b934b396b
]:@atproto/oauth-types@0.1.2
Patch Changes
b934b396b
Thanks @matthieusieben! - Better implement aptroto OAuth spec@atproto/ozone@0.1.36
Patch Changes
b934b396b
,2bdf75d7a
,b934b396b
,b934b396b
]:@atproto/pds@0.4.48
Patch Changes
b934b396b
,2bdf75d7a
,b934b396b
,b934b396b
,b934b396b
]:@atproto/repo@0.4.2
Patch Changes
b934b396b
,2bdf75d7a
]:@atproto/xrpc-server@0.6.1
Patch Changes
b934b396b
,2bdf75d7a
,b934b396b
,b934b396b
]: