@atproto/oauth-client
Version:
OAuth client for ATPROTO PDS. This package serves as common base for environment-specific implementations (NodeJS, Browser, React-Native).
31 lines • 1.35 kB
JavaScript
import { OAuthServerAgent } from './oauth-server-agent.js';
export class OAuthServerFactory {
constructor(clientMetadata, runtime, resolver, fetch, keyset, dpopNonceCache) {
this.clientMetadata = clientMetadata;
this.runtime = runtime;
this.resolver = resolver;
this.fetch = fetch;
this.keyset = keyset;
this.dpopNonceCache = dpopNonceCache;
}
/**
* @param authMethod `undefined` means that we are restoring a session that
* was created before we started storing the `authMethod` in the session. In
* that case, we will use the first key from the keyset.
*
* Support for this might be removed in the future.
*
* @throws see {@link OAuthServerFactory.fromMetadata}
*/
async fromIssuer(issuer, authMethod, dpopKey, options) {
const serverMetadata = await this.resolver.getAuthorizationServerMetadata(issuer, options);
return this.fromMetadata(serverMetadata, authMethod, dpopKey);
}
/**
* @throws see {@link OAuthServerAgent}
*/
async fromMetadata(serverMetadata, authMethod, dpopKey) {
return new OAuthServerAgent(authMethod, dpopKey, serverMetadata, this.clientMetadata, this.dpopNonceCache, this.resolver, this.runtime, this.keyset, this.fetch);
}
}
//# sourceMappingURL=oauth-server-factory.js.map