-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! feat(oauth): add oauth provider & client libs
- Loading branch information
1 parent
1c9d30e
commit 5f7493f
Showing
42 changed files
with
769 additions
and
611 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,43 @@ | ||
import { Did, DidDocument } from '@atproto/did' | ||
import { CachedGetter } from '@atproto-labs/simple-store' | ||
import { Did, DidDocument } from '@atproto/did' | ||
|
||
import { DidCacheMemory } from './did-cache-memory.js' | ||
import { DidCache } from './did-cache.js' | ||
import { DidMethod, DidMethods, ResolveOptions } from './did-method.js' | ||
import { DidMethod, ResolveOptions } from './did-method.js' | ||
import { DidResolverBase, ResolvedDocument } from './did-resolver-base.js' | ||
import { DidPlcMethod, DidPlcMethodOptions } from './methods/plc.js' | ||
import { DidWebMethod, DidWebMethodOptions } from './methods/web.js' | ||
import { Simplify } from './util.js' | ||
|
||
export type { DidMethod, ResolveOptions, ResolvedDocument } | ||
|
||
export type DidResolverOptions = { | ||
cache?: DidCache | ||
} | ||
export type MethodsOptions = Simplify<DidPlcMethodOptions & DidWebMethodOptions> | ||
export type DidResolverOptions = Simplify<{ cache?: DidCache } & MethodsOptions> | ||
|
||
export class DidResolver<M extends string = string> extends DidResolverBase<M> { | ||
readonly #getter: CachedGetter<Did, DidDocument> | ||
export class DidResolver extends DidResolverBase<'plc' | 'web'> { | ||
private readonly getter: CachedGetter<Did, DidDocument> | ||
|
||
constructor(methods: DidMethods<M>, options?: DidResolverOptions) { | ||
super(methods) | ||
constructor({ | ||
cache = new DidCacheMemory(), | ||
...methodsOptions | ||
}: DidResolverOptions = {}) { | ||
super({ | ||
plc: new DidPlcMethod(methodsOptions), | ||
web: new DidWebMethod(methodsOptions), | ||
}) | ||
|
||
this.#getter = new CachedGetter<Did, DidDocument>( | ||
this.getter = new CachedGetter<Did, DidDocument>( | ||
(did, options) => super.resolve(did, options), | ||
options?.cache ?? new DidCacheMemory(), | ||
cache, | ||
) | ||
} | ||
|
||
async resolve<D extends Did>( | ||
did: D, | ||
options?: ResolveOptions, | ||
): Promise<ResolvedDocument<D, M>> | ||
async resolve(did: Did, options?: ResolveOptions): Promise<DidDocument> { | ||
return this.#getter.get(did, options) | ||
): Promise<ResolvedDocument<D, 'plc' | 'web'>> { | ||
return this.getter.get(did, options) as Promise< | ||
ResolvedDocument<D, 'plc' | 'web'> | ||
> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
packages/internal/did-resolver/src/isomorphic-did-resolver.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.