@atcute/identity-resolver 0.1.0

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.
Files changed (47) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +66 -0
  3. package/dist/did/composite.d.ts +12 -0
  4. package/dist/did/composite.js +17 -0
  5. package/dist/did/composite.js.map +1 -0
  6. package/dist/did/methods/plc.d.ts +12 -0
  7. package/dist/did/methods/plc.js +34 -0
  8. package/dist/did/methods/plc.js.map +1 -0
  9. package/dist/did/methods/web.d.ts +15 -0
  10. package/dist/did/methods/web.js +63 -0
  11. package/dist/did/methods/web.js.map +1 -0
  12. package/dist/did/utils.d.ts +1 -0
  13. package/dist/did/utils.js +4 -0
  14. package/dist/did/utils.js.map +1 -0
  15. package/dist/errors.d.ts +47 -0
  16. package/dist/errors.js +75 -0
  17. package/dist/errors.js.map +1 -0
  18. package/dist/handle/composite.d.ts +15 -0
  19. package/dist/handle/composite.js +62 -0
  20. package/dist/handle/composite.js.map +1 -0
  21. package/dist/handle/methods/doh-json.d.ts +12 -0
  22. package/dist/handle/methods/doh-json.js +105 -0
  23. package/dist/handle/methods/doh-json.js.map +1 -0
  24. package/dist/handle/methods/well-known.d.ts +10 -0
  25. package/dist/handle/methods/well-known.js +35 -0
  26. package/dist/handle/methods/well-known.js.map +1 -0
  27. package/dist/handle/methods/xrpc.d.ts +12 -0
  28. package/dist/handle/methods/xrpc.js +38 -0
  29. package/dist/handle/methods/xrpc.js.map +1 -0
  30. package/dist/index.d.ts +9 -0
  31. package/dist/index.js +10 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/types.d.ts +15 -0
  34. package/dist/types.js +2 -0
  35. package/dist/types.js.map +1 -0
  36. package/lib/did/composite.ts +27 -0
  37. package/lib/did/methods/plc.ts +51 -0
  38. package/lib/did/methods/web.ts +85 -0
  39. package/lib/did/utils.ts +8 -0
  40. package/lib/errors.ts +86 -0
  41. package/lib/handle/composite.ts +94 -0
  42. package/lib/handle/methods/doh-json.ts +138 -0
  43. package/lib/handle/methods/well-known.ts +50 -0
  44. package/lib/handle/methods/xrpc.ts +65 -0
  45. package/lib/index.ts +11 -0
  46. package/lib/types.ts +19 -0
  47. package/package.json +41 -0
package/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2
+ of this software and associated documentation files (the "Software"), to deal
3
+ in the Software without restriction, including without limitation the rights
4
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ copies of the Software, and to permit persons to whom the Software is
6
+ furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all
9
+ copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @atcute/identity-resolver
2
+
3
+ atproto handle and DID document resolution
4
+
5
+ ```ts
6
+ // handle resolution
7
+ const handleResolver = new CompositeHandleResolver({
8
+ strategy: 'race',
9
+ methods: {
10
+ dns: new DohJsonHandleResolver({ dohUrl: 'https://mozilla.cloudflare-dns.com/dns-query' }),
11
+ http: new WellKnownHandleResolver(),
12
+ },
13
+ });
14
+
15
+ try {
16
+ const handle = await handleResolver.resolve('bsky.app');
17
+ // ^? 'did:plc:z72i7hdynmk6r22z27h6tvur'
18
+ } catch (err) {
19
+ if (err instanceof DidNotFoundError) {
20
+ // handle returned no did
21
+ }
22
+ if (err instanceof InvalidResolvedHandleError) {
23
+ // handle returned a did, but isn't a valid atproto did
24
+ }
25
+ if (err instanceof AmbiguousHandleError) {
26
+ // handle returned multiple did values
27
+ }
28
+ if (err instanceof FailedHandleResolutionError) {
29
+ // handle resolution had thrown something unexpected (fetch error)
30
+ }
31
+
32
+ if (err instanceof HandleResolutionError) {
33
+ // the errors above extend this class, so you can do a catch-all.
34
+ }
35
+ }
36
+
37
+ // DID document resolution
38
+ const docResolver = new CompositeDidDocumentResolver({
39
+ methods: {
40
+ plc: new PlcDidDocumentResolver(),
41
+ web: new WebDidDocumentResolver(),
42
+ },
43
+ });
44
+
45
+ try {
46
+ const doc = await docResolver.resolve('did:plc:z72i7hdynmk6r22z27h6tvur');
47
+ // ^? { '@context': [...], id: 'did:plc:z72i7hdynmk6r22z27h6tvur', ... }
48
+ } catch (err) {
49
+ if (err instanceof DocumentNotFoundError) {
50
+ // did returned no document
51
+ }
52
+ if (err instanceof UnsupportedDidMethodError) {
53
+ // resolver doesn't support did method (composite resolver)
54
+ }
55
+ if (err instanceof ImproperDidError) {
56
+ // resolver considers did as invalid (atproto did:web)
57
+ }
58
+ if (err instanceof FailedDocumentResolutionError) {
59
+ // document resolution had thrown something unexpected (fetch error)
60
+ }
61
+
62
+ if (err instanceof HandleResolutionError) {
63
+ // the errors above extend this class, so you can do a catch-all.
64
+ }
65
+ }
66
+ ```
@@ -0,0 +1,12 @@
1
+ import { type Did, type DidDocument } from '@atcute/identity';
2
+ import type { DidDocumentResolver, ResolveDidDocumentOptions } from '../types.js';
3
+ export interface CompositeDidDocumentResolverOptions<M extends string> {
4
+ methods: {
5
+ [K in M]: DidDocumentResolver<K>;
6
+ };
7
+ }
8
+ export declare class CompositeDidDocumentResolver<M extends string> implements DidDocumentResolver<M> {
9
+ #private;
10
+ constructor({ methods }: CompositeDidDocumentResolverOptions<M>);
11
+ resolve(did: Did<M>, options?: ResolveDidDocumentOptions): Promise<DidDocument>;
12
+ }
@@ -0,0 +1,17 @@
1
+ import { extractDidMethod } from '@atcute/identity';
2
+ import * as err from '../errors.js';
3
+ export class CompositeDidDocumentResolver {
4
+ #methods;
5
+ constructor({ methods }) {
6
+ this.#methods = new Map(Object.entries(methods));
7
+ }
8
+ async resolve(did, options) {
9
+ const method = extractDidMethod(did);
10
+ const resolver = this.#methods.get(method);
11
+ if (resolver === undefined) {
12
+ throw new err.UnsupportedDidMethodError(did);
13
+ }
14
+ return await resolver.resolve(did, options);
15
+ }
16
+ }
17
+ //# sourceMappingURL=composite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composite.js","sourceRoot":"","sources":["../../lib/did/composite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA8B,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAOpC,MAAM,OAAO,4BAA4B;IACxC,QAAQ,CAAsC;IAE9C,YAAY,EAAE,OAAO,EAA0C;QAC9D,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,OAAmC;QAC7D,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAErC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;CACD"}
@@ -0,0 +1,12 @@
1
+ import { type Did, type DidDocument } from '@atcute/identity';
2
+ import type { DidDocumentResolver, ResolveDidDocumentOptions } from '../../types.js';
3
+ export interface PlcDidDocumentResolverOptions {
4
+ apiUrl?: string;
5
+ fetch?: typeof fetch;
6
+ }
7
+ export declare class PlcDidDocumentResolver implements DidDocumentResolver<'plc'> {
8
+ #private;
9
+ readonly apiUrl: string;
10
+ constructor({ apiUrl, fetch: fetchThis, }?: PlcDidDocumentResolverOptions);
11
+ resolve(did: Did<'plc'>, options?: ResolveDidDocumentOptions): Promise<DidDocument>;
12
+ }
@@ -0,0 +1,34 @@
1
+ import {} from '@atcute/identity';
2
+ import { FailedResponseError } from '@atcute/util-fetch';
3
+ import * as err from '../../errors.js';
4
+ import { fetchDocHandler } from '../utils.js';
5
+ export class PlcDidDocumentResolver {
6
+ apiUrl;
7
+ #fetch;
8
+ constructor({ apiUrl = 'https://plc.directory', fetch: fetchThis = fetch, } = {}) {
9
+ this.apiUrl = apiUrl;
10
+ this.#fetch = fetchThis;
11
+ }
12
+ async resolve(did, options) {
13
+ let json;
14
+ try {
15
+ const url = new URL(`/${encodeURIComponent(did)}`, this.apiUrl);
16
+ const response = await (0, this.#fetch)(url, {
17
+ signal: options?.signal,
18
+ cache: options?.noCache ? 'no-cache' : 'default',
19
+ redirect: 'error',
20
+ headers: { accept: 'application/did+ld+json,application/json' },
21
+ });
22
+ const handled = await fetchDocHandler(response);
23
+ json = handled.json;
24
+ }
25
+ catch (cause) {
26
+ if (cause instanceof FailedResponseError && cause.status === 404) {
27
+ throw new err.DocumentNotFoundError(did);
28
+ }
29
+ throw new err.FailedDocumentResolutionError(did, { cause });
30
+ }
31
+ return json;
32
+ }
33
+ }
34
+ //# sourceMappingURL=plc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plc.js","sourceRoot":"","sources":["../../../lib/did/methods/plc.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAEv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CAAC;IACb,CAAC;CACD"}
@@ -0,0 +1,15 @@
1
+ import { type Did, type DidDocument } from '@atcute/identity';
2
+ import type { DidDocumentResolver, ResolveDidDocumentOptions } from '../../types.js';
3
+ export interface WebDidDocumentResolverOptions {
4
+ fetch?: typeof fetch;
5
+ }
6
+ export declare class WebDidDocumentResolver implements DidDocumentResolver<'web'> {
7
+ #private;
8
+ constructor({ fetch: fetchThis }?: WebDidDocumentResolverOptions);
9
+ resolve(did: Did<'web'>, options?: ResolveDidDocumentOptions): Promise<DidDocument>;
10
+ }
11
+ export declare class AtprotoWebDidDocumentResolver implements DidDocumentResolver<'web'> {
12
+ #private;
13
+ constructor({ fetch: fetchThis }?: WebDidDocumentResolverOptions);
14
+ resolve(did: Did<'web'>, options?: ResolveDidDocumentOptions): Promise<DidDocument>;
15
+ }
@@ -0,0 +1,63 @@
1
+ import { webDidToDocumentUrl } from '@atcute/identity';
2
+ import { FailedResponseError } from '@atcute/util-fetch';
3
+ import * as err from '../../errors.js';
4
+ import { fetchDocHandler } from '../utils.js';
5
+ export class WebDidDocumentResolver {
6
+ #fetch;
7
+ constructor({ fetch: fetchThis = fetch } = {}) {
8
+ this.#fetch = fetchThis;
9
+ }
10
+ async resolve(did, options) {
11
+ let json;
12
+ try {
13
+ const url = webDidToDocumentUrl(did);
14
+ const response = await (0, this.#fetch)(url, {
15
+ signal: options?.signal,
16
+ cache: options?.noCache ? 'no-cache' : 'default',
17
+ redirect: 'error',
18
+ headers: { accept: 'application/did+ld+json,application/json' },
19
+ });
20
+ const handled = await fetchDocHandler(response);
21
+ json = handled.json;
22
+ }
23
+ catch (cause) {
24
+ if (cause instanceof FailedResponseError && cause.status === 404) {
25
+ throw new err.DocumentNotFoundError(did);
26
+ }
27
+ throw new err.FailedDocumentResolutionError(did, { cause });
28
+ }
29
+ return json;
30
+ }
31
+ }
32
+ export class AtprotoWebDidDocumentResolver {
33
+ #fetch;
34
+ constructor({ fetch: fetchThis = fetch } = {}) {
35
+ this.#fetch = fetchThis;
36
+ }
37
+ async resolve(did, options) {
38
+ const [host, ...paths] = did.slice(8).split(':').map(decodeURIComponent);
39
+ const url = new URL(`https://${host}/.well-known/did.json`);
40
+ if (paths.length > 0) {
41
+ throw new err.ImproperDidError(did);
42
+ }
43
+ let json;
44
+ try {
45
+ const response = await (0, this.#fetch)(url, {
46
+ signal: options?.signal,
47
+ cache: options?.noCache ? 'no-cache' : 'default',
48
+ redirect: 'error',
49
+ headers: { accept: 'application/did+ld+json,application/json' },
50
+ });
51
+ const handled = await fetchDocHandler(response);
52
+ json = handled.json;
53
+ }
54
+ catch (cause) {
55
+ if (cause instanceof FailedResponseError && cause.status === 404) {
56
+ throw new err.DocumentNotFoundError(did);
57
+ }
58
+ throw new err.FailedDocumentResolutionError(did, { cause });
59
+ }
60
+ return json;
61
+ }
62
+ }
63
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../../lib/did/methods/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA8B,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAM9C,MAAM,OAAO,sBAAsB;IAClC,MAAM,CAAe;IAErB,YAAY,EAAE,KAAK,EAAE,SAAS,GAAG,KAAK,KAAoC,EAAE;QAC3E,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAe,EAAE,OAAmC;QACjE,IAAI,IAAiB,CAAC;QAEtB,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;YAErC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAA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AAC;QAED,IAAI,IAAiB,CAAC;QAEtB,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE;gBAC5C,MAAM,EAAE,OAAO,EAAE,MAAM;gBACvB,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;gBAChD,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,EAAE,MAAM,EAAE,0CAA0C,EAAE;aAC/D,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;YAEhD,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,KAAK,YAAY,mBAAmB,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAClE,MAAM,IAAI,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YAC1C,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,6BAA6B,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7D,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
@@ -0,0 +1 @@
1
+ export declare const fetchDocHandler: (input: Response) => Promise<import("@atcute/util-fetch").ParsedJsonResponse<import("@atcute/identity").DidDocument>>;
@@ -0,0 +1,4 @@
1
+ import { defs } from '@atcute/identity';
2
+ import { isResponseOk, parseResponseAsJson, pipe, validateJsonWith } from '@atcute/util-fetch';
3
+ export const fetchDocHandler = pipe(isResponseOk, parseResponseAsJson(/^application\/(did\+ld\+)?json$/, 20 * 1024), validateJsonWith(defs.didDocument, { mode: 'passthrough' }));
4
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/did/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE/F,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAClC,YAAY,EACZ,mBAAmB,CAAC,iCAAiC,EAAE,EAAE,GAAG,IAAI,CAAC,EACjE,gBAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAC3D,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { Did } from '@atcute/identity';
2
+ export declare class DidDocumentResolutionError extends Error {
3
+ name: string;
4
+ }
5
+ export declare class UnsupportedDidMethodError extends DidDocumentResolutionError {
6
+ did: Did;
7
+ name: string;
8
+ constructor(did: Did);
9
+ }
10
+ export declare class ImproperDidError extends DidDocumentResolutionError {
11
+ did: Did;
12
+ name: string;
13
+ constructor(did: Did);
14
+ }
15
+ export declare class DocumentNotFoundError extends DidDocumentResolutionError {
16
+ did: Did;
17
+ name: string;
18
+ constructor(did: Did);
19
+ }
20
+ export declare class FailedDocumentResolutionError extends DidDocumentResolutionError {
21
+ did: Did;
22
+ name: string;
23
+ constructor(did: Did, options?: ErrorOptions);
24
+ }
25
+ export declare class HandleResolutionError extends Error {
26
+ name: string;
27
+ }
28
+ export declare class DidNotFoundError extends HandleResolutionError {
29
+ handle: string;
30
+ name: string;
31
+ constructor(handle: string);
32
+ }
33
+ export declare class FailedHandleResolutionError extends HandleResolutionError {
34
+ handle: string;
35
+ name: string;
36
+ constructor(handle: string, options?: ErrorOptions);
37
+ }
38
+ export declare class InvalidResolvedHandleError extends HandleResolutionError {
39
+ handle: string;
40
+ did: string;
41
+ name: string;
42
+ constructor(handle: string, did: string);
43
+ }
44
+ export declare class AmbiguousHandleError extends HandleResolutionError {
45
+ name: string;
46
+ constructor(handle: string);
47
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,75 @@
1
+ // #region DID document resolution errors
2
+ export class DidDocumentResolutionError extends Error {
3
+ name = 'DidResolutionError';
4
+ }
5
+ export class UnsupportedDidMethodError extends DidDocumentResolutionError {
6
+ did;
7
+ name = 'UnsupportedDidMethodError';
8
+ constructor(did) {
9
+ super(`unsupported did method; did=${did}`);
10
+ this.did = did;
11
+ }
12
+ }
13
+ export class ImproperDidError extends DidDocumentResolutionError {
14
+ did;
15
+ name = 'ImproperDidError';
16
+ constructor(did) {
17
+ super(`improper did; did=${did}`);
18
+ this.did = did;
19
+ }
20
+ }
21
+ export class DocumentNotFoundError extends DidDocumentResolutionError {
22
+ did;
23
+ name = 'DocumentNotFoundError';
24
+ constructor(did) {
25
+ super(`did document not found; did=${did}`);
26
+ this.did = did;
27
+ }
28
+ }
29
+ export class FailedDocumentResolutionError extends DidDocumentResolutionError {
30
+ did;
31
+ name = 'FailedDocumentResolutionError';
32
+ constructor(did, options) {
33
+ super(`failed to resolve did document; did=${did}`, options);
34
+ this.did = did;
35
+ }
36
+ }
37
+ // #endregion
38
+ // #region Handle resolution errors
39
+ export class HandleResolutionError extends Error {
40
+ name = 'HandleResolutionError';
41
+ }
42
+ export class DidNotFoundError extends HandleResolutionError {
43
+ handle;
44
+ name = 'DidNotFoundError';
45
+ constructor(handle) {
46
+ super(`handle returned no did; handle=${handle}`);
47
+ this.handle = handle;
48
+ }
49
+ }
50
+ export class FailedHandleResolutionError extends HandleResolutionError {
51
+ handle;
52
+ name = 'FailedHandleResolutionError';
53
+ constructor(handle, options) {
54
+ super(`failed to resolve handle; handle=${handle}`, options);
55
+ this.handle = handle;
56
+ }
57
+ }
58
+ export class InvalidResolvedHandleError extends HandleResolutionError {
59
+ handle;
60
+ did;
61
+ name = 'InvalidResolvedHandleError';
62
+ constructor(handle, did) {
63
+ super(`handle returned invalid did; handle=${handle}; did=${did}`);
64
+ this.handle = handle;
65
+ this.did = did;
66
+ }
67
+ }
68
+ export class AmbiguousHandleError extends HandleResolutionError {
69
+ name = 'AmbiguousHandleError';
70
+ constructor(handle) {
71
+ super(`handle returned multiple did values; handle=${handle}`);
72
+ }
73
+ }
74
+ // #endregion
75
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC3C,IAAI,GAAG,oBAAoB,CAAC;CACrC;AAED,MAAM,OAAO,yBAA0B,SAAQ,0BAA0B;IAGrD;IAFV,IAAI,GAAG,2BAA2B,CAAC;IAE5C,YAAmB,GAAQ;QAC1B,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;QAD1B,QAAG,GAAH,GAAG,CAAK;IAE3B,CAAC;CACD;AAED,MAAM,OAAO,gBAAiB,SAAQ,0BAA0B;IAG5C;IAFV,IAAI,GAAG,kBAAkB,CAAC;IAEnC,YAAmB,GAAQ;QAC1B,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;QADhB,QAAG,GAAH,GAAG,CAAK;IAE3B,CAAC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,0BAA0B;IAGjD;IAFV,IAAI,GAAG,uBAAuB,CAAC;IAExC,YAAmB,GAAQ;QAC1B,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;QAD1B,QAAG,GAAH,GAAG,CAAK;IAE3B,CAAC;CACD;AAED,MAAM,OAAO,6BAA8B,SAAQ,0BAA0B;IAIpE;IAHC,IAAI,GAAG,+BAA+B,CAAC;IAEhD,YACQ,GAAQ,EACf,OAAsB;QAEtB,KAAK,CAAC,uCAAuC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;QAHtD,QAAG,GAAH,GAAG,CAAK;IAIhB,CAAC;CACD;AACD,aAAa;AAEb,mCAAmC;AACnC,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACtC,IAAI,GAAG,uBAAuB,CAAC;CACxC;AAED,MAAM,OAAO,gBAAiB,SAAQ,qBAAqB;IAGvC;IAFV,IAAI,GAAG,kBAAkB,CAAC;IAEnC,YAAmB,MAAc;QAChC,KAAK,CAAC,kCAAkC,MAAM,EAAE,CAAC,CAAC;QADhC,WAAM,GAAN,MAAM,CAAQ;IAEjC,CAAC;CACD;AAED,MAAM,OAAO,2BAA4B,SAAQ,qBAAqB;IAI7D;IAHC,IAAI,GAAG,6BAA6B,CAAC;IAE9C,YACQ,MAAc,EACrB,OAAsB;QAEtB,KAAK,CAAC,oCAAoC,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;QAHtD,WAAM,GAAN,MAAM,CAAQ;IAItB,CAAC;CACD;AAED,MAAM,OAAO,0BAA2B,SAAQ,qBAAqB;IAI5D;IACA;IAJC,IAAI,GAAG,4BAA4B,CAAC;IAE7C,YACQ,MAAc,EACd,GAAW;QAElB,KAAK,CAAC,uCAAuC,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC;QAH5D,WAAM,GAAN,MAAM,CAAQ;QACd,QAAG,GAAH,GAAG,CAAQ;IAGnB,CAAC;CACD;AAED,MAAM,OAAO,oBAAqB,SAAQ,qBAAqB;IACrD,IAAI,GAAG,sBAAsB,CAAC;IAEvC,YAAY,MAAc;QACzB,KAAK,CAAC,+CAA+C,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;CACD;AACD,aAAa"}
@@ -0,0 +1,15 @@
1
+ import type { AtprotoDid, Handle } from '@atcute/identity';
2
+ import type { HandleResolver, ResolveHandleOptions } from '../types.js';
3
+ export type CompositeStrategy = 'http-first' | 'dns-first' | 'race' | 'both';
4
+ export interface CompositeHandleResolverOptions {
5
+ /** controls how the resolution is done, defaults to 'race' */
6
+ strategy?: CompositeStrategy;
7
+ /** the methods to use for resolving the handle. */
8
+ methods: Record<'http' | 'dns', HandleResolver>;
9
+ }
10
+ export declare class CompositeHandleResolver implements HandleResolver {
11
+ #private;
12
+ strategy: CompositeStrategy;
13
+ constructor({ methods, strategy }: CompositeHandleResolverOptions);
14
+ resolve(handle: Handle, options?: ResolveHandleOptions): Promise<AtprotoDid>;
15
+ }
@@ -0,0 +1,62 @@
1
+ import * as err from '../errors.js';
2
+ export class CompositeHandleResolver {
3
+ #methods;
4
+ strategy;
5
+ constructor({ methods, strategy = 'race' }) {
6
+ this.#methods = methods;
7
+ this.strategy = strategy;
8
+ }
9
+ async resolve(handle, options) {
10
+ const { http, dns } = this.#methods;
11
+ const parentSignal = options?.signal;
12
+ const controller = new AbortController();
13
+ if (parentSignal) {
14
+ parentSignal.addEventListener('abort', () => controller.abort(), { signal: controller.signal });
15
+ }
16
+ const dnsPromise = dns.resolve(handle, { ...options, signal: controller.signal });
17
+ const httpPromise = http.resolve(handle, { ...options, signal: controller.signal });
18
+ switch (this.strategy) {
19
+ case 'race': {
20
+ return new Promise((resolve) => {
21
+ dnsPromise.then((did) => {
22
+ controller.abort();
23
+ resolve(did);
24
+ }, () => resolve(httpPromise));
25
+ httpPromise.then((did) => {
26
+ controller.abort();
27
+ resolve(did);
28
+ }, () => resolve(dnsPromise));
29
+ });
30
+ }
31
+ case 'dns-first': {
32
+ httpPromise.catch(noop);
33
+ const resolved = await dnsPromise.catch(noop);
34
+ if (resolved) {
35
+ controller.abort();
36
+ return resolved;
37
+ }
38
+ return httpPromise;
39
+ }
40
+ case 'http-first': {
41
+ dnsPromise.catch(noop);
42
+ const resolved = await httpPromise.catch(noop);
43
+ if (resolved) {
44
+ controller.abort();
45
+ return resolved;
46
+ }
47
+ return dnsPromise;
48
+ }
49
+ case 'both': {
50
+ const [dnsResponse, httpResponse] = await Promise.allSettled([dnsPromise, httpPromise]);
51
+ const dnsDid = dnsResponse.status === 'fulfilled' ? dnsResponse.value : undefined;
52
+ const httpDid = httpResponse.status === 'fulfilled' ? httpResponse.value : undefined;
53
+ if (dnsDid && httpDid && dnsDid !== httpDid) {
54
+ throw new err.AmbiguousHandleError(handle);
55
+ }
56
+ return dnsDid || httpDid || dnsPromise;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ const noop = () => { };
62
+ //# sourceMappingURL=composite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composite.js","sourceRoot":"","sources":["../../lib/handle/composite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAYpC,MAAM,OAAO,uBAAuB;IACnC,QAAQ,CAAyC;IACjD,QAAQ,CAAoB;IAE5B,YAAY,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,EAAkC;QACzE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAA8B;QAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QAEpC,MAAM,YAAY,GAAG,OAAO,EAAE,MAAM,CAAC;QACrC,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,IAAI,YAAY,EAAE,CAAC;YAClB,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QACjG,CAAC;QAED,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAClF,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAEpF,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;YACvB,KAAK,MAAM,CAAC,CAAC,CAAC;gBACb,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;oBAC9B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AAM,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBAClF,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBAErF,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;oBAC7C,MAAM,IAAI,GAAG,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;gBAC5C,CAAC;gBAED,OAAO,MAAM,IAAI,OAAO,IAAI,UAAU,CAAC;YACxC,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAED,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type AtprotoDid, type Handle } from '@atcute/identity';
2
+ import type { HandleResolver, ResolveHandleOptions } from '../../types.js';
3
+ export interface DohJsonHandleResolverOptions {
4
+ dohUrl: string;
5
+ fetch?: typeof fetch;
6
+ }
7
+ export declare class DohJsonHandleResolver implements HandleResolver {
8
+ #private;
9
+ readonly dohUrl: string;
10
+ constructor({ dohUrl, fetch: fetchThis }: DohJsonHandleResolverOptions);
11
+ resolve(handle: Handle, options?: ResolveHandleOptions): Promise<AtprotoDid>;
12
+ }
@@ -0,0 +1,105 @@
1
+ import * as v from '@badrap/valita';
2
+ import { isAtprotoDid } from '@atcute/identity';
3
+ import { isResponseOk, parseResponseAsJson, pipe, validateJsonWith } from '@atcute/util-fetch';
4
+ import * as err from '../../errors.js';
5
+ const uint32 = v.number().assert((input) => Number.isInteger(input) && input >= 0 && input <= 2 ** 32 - 1);
6
+ const question = v.object({
7
+ name: v.string(),
8
+ type: v.literal(16), // TXT
9
+ });
10
+ const answer = v.object({
11
+ name: v.string(),
12
+ type: v.literal(16), // TXT
13
+ TTL: uint32,
14
+ data: v.string().chain((input) => {
15
+ return v.ok(input.replace(/^"|"$/g, '').replace(/\\"/g, '"'));
16
+ }),
17
+ });
18
+ const authority = v.object({
19
+ name: v.string(),
20
+ type: uint32,
21
+ TTL: uint32,
22
+ data: v.string(),
23
+ });
24
+ const result = v.object({
25
+ /** DNS response code */
26
+ Status: uint32,
27
+ /** Whether response is truncated */
28
+ TC: v.boolean(),
29
+ /** Whether recursive desired bit is set, always true for Google and Cloudflare DoH */
30
+ RD: v.boolean(),
31
+ /** Whether recursive available bit is set, always true for Google and Cloudflare DoH */
32
+ RA: v.boolean(),
33
+ /** Whether response data was validated with DNSSEC */
34
+ AD: v.boolean(),
35
+ /** Whether client asked to disable DNSSEC validation */
36
+ CD: v.boolean(),
37
+ /** Requested records */
38
+ Question: v.tuple([question]),
39
+ /** Answers */
40
+ Answer: v.array(answer).optional(() => []),
41
+ /** Authority */
42
+ Authority: v.array(authority).optional(),
43
+ /** Comment from the DNS server */
44
+ Comment: v.string().optional(),
45
+ });
46
+ const SUBDOMAIN = '_atproto';
47
+ const PREFIX = 'did=';
48
+ const fetchDohJsonHandler = pipe(isResponseOk, parseResponseAsJson(/^application\/(dns-)?json$/, 16 * 1024), validateJsonWith(result, { mode: 'passthrough' }));
49
+ export class DohJsonHandleResolver {
50
+ dohUrl;
51
+ #fetch;
52
+ constructor({ dohUrl, fetch: fetchThis = fetch }) {
53
+ this.dohUrl = dohUrl;
54
+ this.#fetch = fetchThis;
55
+ }
56
+ async resolve(handle, options) {
57
+ let json;
58
+ try {
59
+ const url = new URL(this.dohUrl);
60
+ url.searchParams.set('name', `${SUBDOMAIN}.${handle}`);
61
+ url.searchParams.set('type', 'TXT');
62
+ const response = await (0, this.#fetch)(url, {
63
+ signal: options?.signal,
64
+ cache: options?.noCache ? 'no-cache' : 'default',
65
+ headers: { accept: 'application/dns-json' },
66
+ });
67
+ const handled = await fetchDohJsonHandler(response);
68
+ json = handled.json;
69
+ }
70
+ catch (cause) {
71
+ throw new err.FailedHandleResolutionError(handle, { cause });
72
+ }
73
+ const status = json.Status;
74
+ const answers = json.Answer;
75
+ if (status !== 0 /* NOERROR */) {
76
+ if (status === 3 /* NXDOMAIN */) {
77
+ throw new err.DidNotFoundError(handle);
78
+ }
79
+ throw new err.FailedHandleResolutionError(handle, {
80
+ cause: new TypeError(`dns returned ${status}`),
81
+ });
82
+ }
83
+ for (let i = 0, il = answers.length; i < il; i++) {
84
+ const answer = answers[i];
85
+ const data = answer.data;
86
+ if (!data.startsWith(PREFIX)) {
87
+ continue;
88
+ }
89
+ for (let j = i + 1; j < il; j++) {
90
+ const data = answers[j].data;
91
+ if (data.startsWith(PREFIX)) {
92
+ throw new err.AmbiguousHandleError(handle);
93
+ }
94
+ }
95
+ const did = data.slice(PREFIX.length);
96
+ if (!isAtprotoDid(did)) {
97
+ throw new err.InvalidResolvedHandleError(handle, did);
98
+ }
99
+ return did;
100
+ }
101
+ // theoretically this shouldn't happen, it should've returned NXDOMAIN
102
+ throw new err.DidNotFoundError(handle);
103
+ }
104
+ }
105
+ //# sourceMappingURL=doh-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doh-json.js","sourceRoot":"","sources":["../../../lib/handle/methods/doh-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAgC,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE/F,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAGvC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AAE3G,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,IAAI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EAAE,EAAE,CAAC;gBACjC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC7B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC7B,MAAM,IAAI,GAAG,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;gBAC5C,CAAC;YACF,CAAC;YAED,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACtC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,GAAG,CAAC,0BAA0B,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YACvD,CAAC;YAED,OAAO,GAAG,CAAC;QACZ,CAAC;QAED,sEAAsE;QACtE,MAAM,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;CACD"}
@@ -0,0 +1,10 @@
1
+ import { type AtprotoDid, type Handle } from '@atcute/identity';
2
+ import type { HandleResolver, ResolveHandleOptions } from '../../types.js';
3
+ export interface WellKnownHandleResolverOptions {
4
+ fetch?: typeof fetch;
5
+ }
6
+ export declare class WellKnownHandleResolver implements HandleResolver {
7
+ #private;
8
+ constructor({ fetch: fetchThis }?: WellKnownHandleResolverOptions);
9
+ resolve(handle: Handle, options?: ResolveHandleOptions): Promise<AtprotoDid>;
10
+ }