@atproto-labs/did-resolver 0.2.6 → 0.3.0-next.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atproto-labs/did-resolver
2
2
 
3
+ ## 0.3.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`bb7491c`](https://github.com/bluesky-social/atproto/commit/bb7491c29e06181e1d2f8cf6eb454f9bb8ab961b) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Drop support for Node.js 18 and 20. Node.js 22 is now the minimum supported version. Docker images now use Node.js 24.
8
+
9
+ - [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`07ae5d4`](https://github.com/bluesky-social/atproto/commit/07ae5d4452df51e045e0239da7a04cf0bc154028) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Convert to pure ESM. All packages now ship `"type": "module"` with ES module output and Node16 module resolution.
10
+
11
+ Node.js 22's `require()` compatibility layer can still load these packages in CommonJS code.
12
+
13
+ - [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`042df15`](https://github.com/bluesky-social/atproto/commit/042df15087c0e62cd1e715fcbf58852fab875af9) Thanks [@devinivy](https://github.com/devinivy)! - Build with TypeScript 6.0. Emitted `.d.ts` files now use TypeScript 6's stricter `Uint8Array<ArrayBuffer>` typing in places where Web/Node APIs require buffer-backed (not shared-memory) byte arrays. Consumers compiling against these types on older TypeScript should see no runtime impact, but may need to widen or cast in spots that previously relied on `Uint8Array` defaulting to `<ArrayBufferLike>`.
14
+
15
+ Internal: tsconfig `moduleResolution: "node"` is silenced via `ignoreDeprecations: "6.0"` for now; the proper migration to `node16`/`bundler` resolution is deferred.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [[`bb7491c`](https://github.com/bluesky-social/atproto/commit/bb7491c29e06181e1d2f8cf6eb454f9bb8ab961b), [`07ae5d4`](https://github.com/bluesky-social/atproto/commit/07ae5d4452df51e045e0239da7a04cf0bc154028), [`042df15`](https://github.com/bluesky-social/atproto/commit/042df15087c0e62cd1e715fcbf58852fab875af9)]:
20
+ - @atproto/did@0.4.0-next.0
21
+ - @atproto-labs/fetch@0.3.0-next.0
22
+ - @atproto-labs/pipe@0.2.0-next.0
23
+ - @atproto-labs/simple-store@0.4.0-next.0
24
+ - @atproto-labs/simple-store-memory@0.2.0-next.0
25
+
3
26
  ## 0.2.6
4
27
 
5
28
  ### Patch Changes
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDidResolver = createDidResolver;
4
- const did_cache_js_1 = require("./did-cache.js");
5
- const did_resolver_common_js_1 = require("./did-resolver-common.js");
6
- function createDidResolver(options) {
1
+ import { DidResolverCached } from './did-cache.js';
2
+ import { DidResolverCommon, } from './did-resolver-common.js';
3
+ export function createDidResolver(options) {
7
4
  const { didResolver, didCache } = options;
8
- if (didResolver instanceof did_cache_js_1.DidResolverCached && !didCache) {
5
+ if (didResolver instanceof DidResolverCached && !didCache) {
9
6
  return didResolver;
10
7
  }
11
- return new did_cache_js_1.DidResolverCached(didResolver ?? new did_resolver_common_js_1.DidResolverCommon(options), didCache);
8
+ return new DidResolverCached(didResolver ?? new DidResolverCommon(options), didCache);
12
9
  }
13
10
  //# sourceMappingURL=create-did-resolver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-did-resolver.js","sourceRoot":"","sources":["../src/create-did-resolver.ts"],"names":[],"mappings":";;AAeA,8CAaC;AA3BD,iDAA4D;AAC5D,qEAGiC;AAUjC,SAAgB,iBAAiB,CAC/B,OAAiC;IAEjC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAEzC,IAAI,WAAW,YAAY,gCAAiB,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC1D,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,OAAO,IAAI,gCAAiB,CAC1B,WAAW,IAAI,IAAI,0CAAiB,CAAC,OAAO,CAAC,EAC7C,QAAQ,CACT,CAAA;AACH,CAAC","sourcesContent":["import { AtprotoIdentityDidMethods } from '@atproto/did'\nimport { DidCache, DidResolverCached } from './did-cache.js'\nimport {\n DidResolverCommon,\n DidResolverCommonOptions,\n} from './did-resolver-common.js'\nimport { DidResolver } from './did-resolver.js'\n\nexport type { AtprotoIdentityDidMethods }\n\nexport type CreateDidResolverOptions = {\n didResolver?: DidResolver<AtprotoIdentityDidMethods>\n didCache?: DidCache\n} & Partial<DidResolverCommonOptions>\n\nexport function createDidResolver(\n options: CreateDidResolverOptions,\n): DidResolver<AtprotoIdentityDidMethods> {\n const { didResolver, didCache } = options\n\n if (didResolver instanceof DidResolverCached && !didCache) {\n return didResolver\n }\n\n return new DidResolverCached(\n didResolver ?? new DidResolverCommon(options),\n didCache,\n )\n}\n"]}
1
+ {"version":3,"file":"create-did-resolver.js","sourceRoot":"","sources":["../src/create-did-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,EACL,iBAAiB,GAElB,MAAM,0BAA0B,CAAA;AAUjC,MAAM,UAAU,iBAAiB,CAC/B,OAAiC;IAEjC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAEzC,IAAI,WAAW,YAAY,iBAAiB,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC1D,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,OAAO,IAAI,iBAAiB,CAC1B,WAAW,IAAI,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAC7C,QAAQ,CACT,CAAA;AACH,CAAC","sourcesContent":["import { AtprotoIdentityDidMethods } from '@atproto/did'\nimport { DidCache, DidResolverCached } from './did-cache.js'\nimport {\n DidResolverCommon,\n DidResolverCommonOptions,\n} from './did-resolver-common.js'\nimport { DidResolver } from './did-resolver.js'\n\nexport type { AtprotoIdentityDidMethods }\n\nexport type CreateDidResolverOptions = {\n didResolver?: DidResolver<AtprotoIdentityDidMethods>\n didCache?: DidCache\n} & Partial<DidResolverCommonOptions>\n\nexport function createDidResolver(\n options: CreateDidResolverOptions,\n): DidResolver<AtprotoIdentityDidMethods> {\n const { didResolver, didCache } = options\n\n if (didResolver instanceof DidResolverCached && !didCache) {\n return didResolver\n }\n\n return new DidResolverCached(\n didResolver ?? new DidResolverCommon(options),\n didCache,\n )\n}\n"]}
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DidCacheMemory = void 0;
4
- const simple_store_memory_1 = require("@atproto-labs/simple-store-memory");
1
+ import { SimpleStoreMemory, } from '@atproto-labs/simple-store-memory';
5
2
  const DEFAULT_TTL = 3600 * 1000; // 1 hour
6
3
  const DEFAULT_MAX_SIZE = 50 * 1024 * 1024; // ~50MB
7
- class DidCacheMemory extends simple_store_memory_1.SimpleStoreMemory {
4
+ export class DidCacheMemory extends SimpleStoreMemory {
8
5
  constructor(options) {
9
6
  super(options?.max == null
10
7
  ? { ttl: DEFAULT_TTL, maxSize: DEFAULT_MAX_SIZE, ...options }
11
8
  : { ttl: DEFAULT_TTL, ...options });
12
9
  }
13
10
  }
14
- exports.DidCacheMemory = DidCacheMemory;
15
11
  //# sourceMappingURL=did-cache-memory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"did-cache-memory.js","sourceRoot":"","sources":["../src/did-cache-memory.ts"],"names":[],"mappings":";;;AACA,2EAG0C;AAG1C,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAA,CAAC,SAAS;AACzC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA,CAAC,QAAQ;AAIlD,MAAa,cACX,SAAQ,uCAAmC;IAG3C,YAAY,OAA+B;QACzC,KAAK,CACH,OAAO,EAAE,GAAG,IAAI,IAAI;YAClB,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,OAAO,EAAE;YAC7D,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CACrC,CAAA;IACH,CAAC;CACF;AAXD,wCAWC","sourcesContent":["import { Did, DidDocument } from '@atproto/did'\nimport {\n SimpleStoreMemory,\n SimpleStoreMemoryOptions,\n} from '@atproto-labs/simple-store-memory'\nimport { DidCache } from './did-cache.js'\n\nconst DEFAULT_TTL = 3600 * 1000 // 1 hour\nconst DEFAULT_MAX_SIZE = 50 * 1024 * 1024 // ~50MB\n\nexport type DidCacheMemoryOptions = SimpleStoreMemoryOptions<Did, DidDocument>\n\nexport class DidCacheMemory\n extends SimpleStoreMemory<Did, DidDocument>\n implements DidCache\n{\n constructor(options?: DidCacheMemoryOptions) {\n super(\n options?.max == null\n ? { ttl: DEFAULT_TTL, maxSize: DEFAULT_MAX_SIZE, ...options }\n : { ttl: DEFAULT_TTL, ...options },\n )\n }\n}\n"]}
1
+ {"version":3,"file":"did-cache-memory.js","sourceRoot":"","sources":["../src/did-cache-memory.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,GAElB,MAAM,mCAAmC,CAAA;AAG1C,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAA,CAAC,SAAS;AACzC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA,CAAC,QAAQ;AAIlD,MAAM,OAAO,cACX,SAAQ,iBAAmC;IAG3C,YAAY,OAA+B;QACzC,KAAK,CACH,OAAO,EAAE,GAAG,IAAI,IAAI;YAClB,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,OAAO,EAAE;YAC7D,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CACrC,CAAA;IACH,CAAC;CACF","sourcesContent":["import { Did, DidDocument } from '@atproto/did'\nimport {\n SimpleStoreMemory,\n SimpleStoreMemoryOptions,\n} from '@atproto-labs/simple-store-memory'\nimport { DidCache } from './did-cache.js'\n\nconst DEFAULT_TTL = 3600 * 1000 // 1 hour\nconst DEFAULT_MAX_SIZE = 50 * 1024 * 1024 // ~50MB\n\nexport type DidCacheMemoryOptions = SimpleStoreMemoryOptions<Did, DidDocument>\n\nexport class DidCacheMemory\n extends SimpleStoreMemory<Did, DidDocument>\n implements DidCache\n{\n constructor(options?: DidCacheMemoryOptions) {\n super(\n options?.max == null\n ? { ttl: DEFAULT_TTL, maxSize: DEFAULT_MAX_SIZE, ...options }\n : { ttl: DEFAULT_TTL, ...options },\n )\n }\n}\n"]}
package/dist/did-cache.js CHANGED
@@ -1,21 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DidResolverCached = void 0;
4
- const simple_store_1 = require("@atproto-labs/simple-store");
5
- const did_cache_memory_js_1 = require("./did-cache-memory.js");
6
- class DidResolverCached {
7
- constructor(resolver, cache = new did_cache_memory_js_1.DidCacheMemory()) {
8
- Object.defineProperty(this, "getter", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: void 0
13
- });
14
- this.getter = new simple_store_1.CachedGetter((did, options) => resolver.resolve(did, options), cache);
1
+ import { CachedGetter } from '@atproto-labs/simple-store';
2
+ import { DidCacheMemory } from './did-cache-memory.js';
3
+ export class DidResolverCached {
4
+ constructor(resolver, cache = new DidCacheMemory()) {
5
+ this.getter = new CachedGetter((did, options) => resolver.resolve(did, options), cache);
15
6
  }
16
7
  async resolve(did, options) {
17
8
  return this.getter.get(did, options);
18
9
  }
19
10
  }
20
- exports.DidResolverCached = DidResolverCached;
21
11
  //# sourceMappingURL=did-cache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"did-cache.js","sourceRoot":"","sources":["../src/did-cache.ts"],"names":[],"mappings":";;;AACA,6DAAsE;AACtE,+DAAsD;AAUtD,MAAa,iBAAiB;IAI5B,YACE,QAAwB,EACxB,QAAkB,IAAI,oCAAc,EAAE;QAHrB;;;;;WAAsC;QAKvD,IAAI,CAAC,MAAM,GAAG,IAAI,2BAAY,CAC5B,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,EAChD,KAAK,CACN,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,OAAO,CAAgB,GAAM,EAAE,OAA2B;QACrE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAoC,CAAA;IACzE,CAAC;CACF;AAjBD,8CAiBC","sourcesContent":["import { Did, DidDocument } from '@atproto/did'\nimport { CachedGetter, SimpleStore } from '@atproto-labs/simple-store'\nimport { DidCacheMemory } from './did-cache-memory.js'\nimport { DidMethod, ResolveDidOptions } from './did-method.js'\nimport { DidResolver, ResolvedDocument } from './did-resolver.js'\n\nexport type { DidMethod, ResolveDidOptions, ResolvedDocument }\n\nexport type DidCache = SimpleStore<Did, DidDocument>\n\nexport type DidResolverCachedOptions = { cache?: DidCache }\n\nexport class DidResolverCached<M extends string = string>\n implements DidResolver<M>\n{\n protected readonly getter: CachedGetter<Did, DidDocument>\n constructor(\n resolver: DidResolver<M>,\n cache: DidCache = new DidCacheMemory(),\n ) {\n this.getter = new CachedGetter<Did, DidDocument>(\n (did, options) => resolver.resolve(did, options),\n cache,\n )\n }\n\n public async resolve<D extends Did>(did: D, options?: ResolveDidOptions) {\n return this.getter.get(did, options) as Promise<ResolvedDocument<D, M>>\n }\n}\n"]}
1
+ {"version":3,"file":"did-cache.js","sourceRoot":"","sources":["../src/did-cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAe,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAUtD,MAAM,OAAO,iBAAiB;IAI5B,YACE,QAAwB,EACxB,QAAkB,IAAI,cAAc,EAAE;QAEtC,IAAI,CAAC,MAAM,GAAG,IAAI,YAAY,CAC5B,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,EAChD,KAAK,CACN,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,OAAO,CAAgB,GAAM,EAAE,OAA2B;QACrE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAoC,CAAA;IACzE,CAAC;CACF","sourcesContent":["import { Did, DidDocument } from '@atproto/did'\nimport { CachedGetter, SimpleStore } from '@atproto-labs/simple-store'\nimport { DidCacheMemory } from './did-cache-memory.js'\nimport { DidMethod, ResolveDidOptions } from './did-method.js'\nimport { DidResolver, ResolvedDocument } from './did-resolver.js'\n\nexport type { DidMethod, ResolveDidOptions, ResolvedDocument }\n\nexport type DidCache = SimpleStore<Did, DidDocument>\n\nexport type DidResolverCachedOptions = { cache?: DidCache }\n\nexport class DidResolverCached<M extends string = string>\n implements DidResolver<M>\n{\n protected readonly getter: CachedGetter<Did, DidDocument>\n constructor(\n resolver: DidResolver<M>,\n cache: DidCache = new DidCacheMemory(),\n ) {\n this.getter = new CachedGetter<Did, DidDocument>(\n (did, options) => resolver.resolve(did, options),\n cache,\n )\n }\n\n public async resolve<D extends Did>(did: D, options?: ResolveDidOptions) {\n return this.getter.get(did, options) as Promise<ResolvedDocument<D, M>>\n }\n}\n"]}
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=did-method.js.map
@@ -1,47 +1,37 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DidResolverBase = void 0;
4
- const zod_1 = require("zod");
5
- const did_1 = require("@atproto/did");
6
- const fetch_1 = require("@atproto-labs/fetch");
7
- class DidResolverBase {
1
+ import { ZodError } from 'zod';
2
+ import { DidError, extractDidMethod } from '@atproto/did';
3
+ import { FetchError, FetchResponseError } from '@atproto-labs/fetch';
4
+ export class DidResolverBase {
8
5
  constructor(methods) {
9
- Object.defineProperty(this, "methods", {
10
- enumerable: true,
11
- configurable: true,
12
- writable: true,
13
- value: void 0
14
- });
15
6
  this.methods = new Map(Object.entries(methods));
16
7
  }
17
8
  async resolve(did, options) {
18
9
  options?.signal?.throwIfAborted();
19
- const method = (0, did_1.extractDidMethod)(did);
10
+ const method = extractDidMethod(did);
20
11
  const resolver = this.methods.get(method);
21
12
  if (!resolver) {
22
- throw new did_1.DidError(did, `Unsupported DID method`, 'did-method-invalid', 400);
13
+ throw new DidError(did, `Unsupported DID method`, 'did-method-invalid', 400);
23
14
  }
24
15
  try {
25
16
  const document = await resolver.resolve(did, options);
26
17
  if (document.id !== did) {
27
- throw new did_1.DidError(did, `DID document id (${document.id}) does not match DID`, 'did-document-id-mismatch', 400);
18
+ throw new DidError(did, `DID document id (${document.id}) does not match DID`, 'did-document-id-mismatch', 400);
28
19
  }
29
20
  return document;
30
21
  }
31
22
  catch (err) {
32
- if (err instanceof fetch_1.FetchResponseError) {
23
+ if (err instanceof FetchResponseError) {
33
24
  const status = err.response.status >= 500 ? 502 : err.response.status;
34
- throw new did_1.DidError(did, err.message, 'did-fetch-error', status, err);
25
+ throw new DidError(did, err.message, 'did-fetch-error', status, err);
35
26
  }
36
- if (err instanceof fetch_1.FetchError) {
37
- throw new did_1.DidError(did, err.message, 'did-fetch-error', 400, err);
27
+ if (err instanceof FetchError) {
28
+ throw new DidError(did, err.message, 'did-fetch-error', 400, err);
38
29
  }
39
- if (err instanceof zod_1.ZodError) {
40
- throw new did_1.DidError(did, err.message, 'did-document-format-error', 503, err);
30
+ if (err instanceof ZodError) {
31
+ throw new DidError(did, err.message, 'did-document-format-error', 503, err);
41
32
  }
42
- throw did_1.DidError.from(err, did);
33
+ throw DidError.from(err, did);
43
34
  }
44
35
  }
45
36
  }
46
- exports.DidResolverBase = DidResolverBase;
47
37
  //# sourceMappingURL=did-resolver-base.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"did-resolver-base.js","sourceRoot":"","sources":["../src/did-resolver-base.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAC9B,sCAA8D;AAC9D,+CAAoE;AAMpE,MAAa,eAAe;IAK1B,YAAY,OAAsB;QAFf;;;;;WAAkC;QAGnD,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;IACjD,CAAC;IAED,KAAK,CAAC,OAAO,CACX,GAAM,EACN,OAA2B;QAE3B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA;QAEjC,MAAM,MAAM,GAAG,IAAA,sBAAgB,EAAC,GAAG,CAAC,CAAA;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,cAAQ,CAChB,GAAG,EACH,wBAAwB,EACxB,oBAAoB,EACpB,GAAG,CACJ,CAAA;QACH,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAa,EAAE,OAAO,CAAC,CAAA;YAC/D,IAAI,QAAQ,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC;gBACxB,MAAM,IAAI,cAAQ,CAChB,GAAG,EACH,oBAAoB,QAAQ,CAAC,EAAE,sBAAsB,EACrD,0BAA0B,EAC1B,GAAG,CACJ,CAAA;YACH,CAAC;YAED,OAAO,QAAkC,CAAA;QAC3C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,0BAAkB,EAAE,CAAC;gBACtC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAA;gBACrE,MAAM,IAAI,cAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;YACtE,CAAC;YAED,IAAI,GAAG,YAAY,kBAAU,EAAE,CAAC;gBAC9B,MAAM,IAAI,cAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;YACnE,CAAC;YAED,IAAI,GAAG,YAAY,cAAQ,EAAE,CAAC;gBAC5B,MAAM,IAAI,cAAQ,CAChB,GAAG,EACH,GAAG,CAAC,OAAO,EACX,2BAA2B,EAC3B,GAAG,EACH,GAAG,CACJ,CAAA;YACH,CAAC;YAED,MAAM,cAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;CACF;AA7DD,0CA6DC","sourcesContent":["import { ZodError } from 'zod'\nimport { Did, DidError, extractDidMethod } from '@atproto/did'\nimport { FetchError, FetchResponseError } from '@atproto-labs/fetch'\nimport { DidMethod, DidMethods, ResolveDidOptions } from './did-method.js'\nimport { DidResolver, ResolvedDocument } from './did-resolver.js'\n\nexport type { DidMethod, ResolveDidOptions, ResolvedDocument }\n\nexport class DidResolverBase<M extends string = string>\n implements DidResolver<M>\n{\n protected readonly methods: Map<string, DidMethod<M>>\n\n constructor(methods: DidMethods<M>) {\n this.methods = new Map(Object.entries(methods))\n }\n\n async resolve<D extends Did>(\n did: D,\n options?: ResolveDidOptions,\n ): Promise<ResolvedDocument<D, M>> {\n options?.signal?.throwIfAborted()\n\n const method = extractDidMethod(did)\n const resolver = this.methods.get(method)\n if (!resolver) {\n throw new DidError(\n did,\n `Unsupported DID method`,\n 'did-method-invalid',\n 400,\n )\n }\n\n try {\n const document = await resolver.resolve(did as Did<M>, options)\n if (document.id !== did) {\n throw new DidError(\n did,\n `DID document id (${document.id}) does not match DID`,\n 'did-document-id-mismatch',\n 400,\n )\n }\n\n return document as ResolvedDocument<D, M>\n } catch (err) {\n if (err instanceof FetchResponseError) {\n const status = err.response.status >= 500 ? 502 : err.response.status\n throw new DidError(did, err.message, 'did-fetch-error', status, err)\n }\n\n if (err instanceof FetchError) {\n throw new DidError(did, err.message, 'did-fetch-error', 400, err)\n }\n\n if (err instanceof ZodError) {\n throw new DidError(\n did,\n err.message,\n 'did-document-format-error',\n 503,\n err,\n )\n }\n\n throw DidError.from(err, did)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"did-resolver-base.js","sourceRoot":"","sources":["../src/did-resolver-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AAC9B,OAAO,EAAO,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAMpE,MAAM,OAAO,eAAe;IAK1B,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;IACjD,CAAC;IAED,KAAK,CAAC,OAAO,CACX,GAAM,EACN,OAA2B;QAE3B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA;QAEjC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,QAAQ,CAChB,GAAG,EACH,wBAAwB,EACxB,oBAAoB,EACpB,GAAG,CACJ,CAAA;QACH,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAa,EAAE,OAAO,CAAC,CAAA;YAC/D,IAAI,QAAQ,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC;gBACxB,MAAM,IAAI,QAAQ,CAChB,GAAG,EACH,oBAAoB,QAAQ,CAAC,EAAE,sBAAsB,EACrD,0BAA0B,EAC1B,GAAG,CACJ,CAAA;YACH,CAAC;YAED,OAAO,QAAkC,CAAA;QAC3C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;gBACtC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAA;gBACrE,MAAM,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;YACtE,CAAC;YAED,IAAI,GAAG,YAAY,UAAU,EAAE,CAAC;gBAC9B,MAAM,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;YACnE,CAAC;YAED,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;gBAC5B,MAAM,IAAI,QAAQ,CAChB,GAAG,EACH,GAAG,CAAC,OAAO,EACX,2BAA2B,EAC3B,GAAG,EACH,GAAG,CACJ,CAAA;YACH,CAAC;YAED,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;CACF","sourcesContent":["import { ZodError } from 'zod'\nimport { Did, DidError, extractDidMethod } from '@atproto/did'\nimport { FetchError, FetchResponseError } from '@atproto-labs/fetch'\nimport { DidMethod, DidMethods, ResolveDidOptions } from './did-method.js'\nimport { DidResolver, ResolvedDocument } from './did-resolver.js'\n\nexport type { DidMethod, ResolveDidOptions, ResolvedDocument }\n\nexport class DidResolverBase<M extends string = string>\n implements DidResolver<M>\n{\n protected readonly methods: Map<string, DidMethod<M>>\n\n constructor(methods: DidMethods<M>) {\n this.methods = new Map(Object.entries(methods))\n }\n\n async resolve<D extends Did>(\n did: D,\n options?: ResolveDidOptions,\n ): Promise<ResolvedDocument<D, M>> {\n options?.signal?.throwIfAborted()\n\n const method = extractDidMethod(did)\n const resolver = this.methods.get(method)\n if (!resolver) {\n throw new DidError(\n did,\n `Unsupported DID method`,\n 'did-method-invalid',\n 400,\n )\n }\n\n try {\n const document = await resolver.resolve(did as Did<M>, options)\n if (document.id !== did) {\n throw new DidError(\n did,\n `DID document id (${document.id}) does not match DID`,\n 'did-document-id-mismatch',\n 400,\n )\n }\n\n return document as ResolvedDocument<D, M>\n } catch (err) {\n if (err instanceof FetchResponseError) {\n const status = err.response.status >= 500 ? 502 : err.response.status\n throw new DidError(did, err.message, 'did-fetch-error', status, err)\n }\n\n if (err instanceof FetchError) {\n throw new DidError(did, err.message, 'did-fetch-error', 400, err)\n }\n\n if (err instanceof ZodError) {\n throw new DidError(\n did,\n err.message,\n 'did-document-format-error',\n 503,\n err,\n )\n }\n\n throw DidError.from(err, did)\n }\n }\n}\n"]}
@@ -1,16 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DidResolverCommon = void 0;
4
- const did_resolver_base_js_1 = require("./did-resolver-base.js");
5
- const plc_js_1 = require("./methods/plc.js");
6
- const web_js_1 = require("./methods/web.js");
7
- class DidResolverCommon extends did_resolver_base_js_1.DidResolverBase {
1
+ import { DidResolverBase } from './did-resolver-base.js';
2
+ import { DidPlcMethod } from './methods/plc.js';
3
+ import { DidWebMethod } from './methods/web.js';
4
+ export class DidResolverCommon extends DidResolverBase {
8
5
  constructor(options) {
9
6
  super({
10
- plc: new plc_js_1.DidPlcMethod(options),
11
- web: new web_js_1.DidWebMethod(options),
7
+ plc: new DidPlcMethod(options),
8
+ web: new DidWebMethod(options),
12
9
  });
13
10
  }
14
11
  }
15
- exports.DidResolverCommon = DidResolverCommon;
16
12
  //# sourceMappingURL=did-resolver-common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"did-resolver-common.js","sourceRoot":"","sources":["../src/did-resolver-common.ts"],"names":[],"mappings":";;;AAAA,iEAAwD;AACxD,6CAAoE;AACpE,6CAAoE;AAOpE,MAAa,iBACX,SAAQ,sCAA8B;IAGtC,YAAY,OAAkC;QAC5C,KAAK,CAAC;YACJ,GAAG,EAAE,IAAI,qBAAY,CAAC,OAAO,CAAC;YAC9B,GAAG,EAAE,IAAI,qBAAY,CAAC,OAAO,CAAC;SAC/B,CAAC,CAAA;IACJ,CAAC;CACF;AAVD,8CAUC","sourcesContent":["import { DidResolverBase } from './did-resolver-base.js'\nimport { DidPlcMethod, DidPlcMethodOptions } from './methods/plc.js'\nimport { DidWebMethod, DidWebMethodOptions } from './methods/web.js'\nimport { Simplify } from './util.js'\n\nexport type DidResolverCommonOptions = Simplify<\n DidPlcMethodOptions & DidWebMethodOptions\n>\n\nexport class DidResolverCommon\n extends DidResolverBase<'plc' | 'web'>\n implements DidResolverBase<'plc' | 'web'>\n{\n constructor(options?: DidResolverCommonOptions) {\n super({\n plc: new DidPlcMethod(options),\n web: new DidWebMethod(options),\n })\n }\n}\n"]}
1
+ {"version":3,"file":"did-resolver-common.js","sourceRoot":"","sources":["../src/did-resolver-common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAuB,MAAM,kBAAkB,CAAA;AACpE,OAAO,EAAE,YAAY,EAAuB,MAAM,kBAAkB,CAAA;AAOpE,MAAM,OAAO,iBACX,SAAQ,eAA8B;IAGtC,YAAY,OAAkC;QAC5C,KAAK,CAAC;YACJ,GAAG,EAAE,IAAI,YAAY,CAAC,OAAO,CAAC;YAC9B,GAAG,EAAE,IAAI,YAAY,CAAC,OAAO,CAAC;SAC/B,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { DidResolverBase } from './did-resolver-base.js'\nimport { DidPlcMethod, DidPlcMethodOptions } from './methods/plc.js'\nimport { DidWebMethod, DidWebMethodOptions } from './methods/web.js'\nimport { Simplify } from './util.js'\n\nexport type DidResolverCommonOptions = Simplify<\n DidPlcMethodOptions & DidWebMethodOptions\n>\n\nexport class DidResolverCommon\n extends DidResolverBase<'plc' | 'web'>\n implements DidResolverBase<'plc' | 'web'>\n{\n constructor(options?: DidResolverCommonOptions) {\n super({\n plc: new DidPlcMethod(options),\n web: new DidWebMethod(options),\n })\n }\n}\n"]}
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=did-resolver.js.map
package/dist/index.js CHANGED
@@ -1,25 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("@atproto/did"), exports);
18
- __exportStar(require("./create-did-resolver.js"), exports);
19
- __exportStar(require("./did-cache-memory.js"), exports);
20
- __exportStar(require("./did-cache.js"), exports);
21
- __exportStar(require("./did-method.js"), exports);
22
- __exportStar(require("./did-resolver-common.js"), exports);
23
- __exportStar(require("./did-resolver.js"), exports);
24
- __exportStar(require("./methods.js"), exports);
1
+ export * from '@atproto/did';
2
+ export * from './create-did-resolver.js';
3
+ export * from './did-cache-memory.js';
4
+ export * from './did-cache.js';
5
+ export * from './did-method.js';
6
+ export * from './did-resolver-common.js';
7
+ export * from './did-resolver.js';
8
+ export * from './methods.js';
25
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAE5B,2DAAwC;AACxC,wDAAqC;AACrC,iDAA8B;AAC9B,kDAA+B;AAC/B,2DAAwC;AACxC,oDAAiC;AACjC,+CAA4B","sourcesContent":["export * from '@atproto/did'\n\nexport * from './create-did-resolver.js'\nexport * from './did-cache-memory.js'\nexport * from './did-cache.js'\nexport * from './did-method.js'\nexport * from './did-resolver-common.js'\nexport * from './did-resolver.js'\nexport * from './methods.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAE5B,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA","sourcesContent":["export * from '@atproto/did'\n\nexport * from './create-did-resolver.js'\nexport * from './did-cache-memory.js'\nexport * from './did-cache.js'\nexport * from './did-method.js'\nexport * from './did-resolver-common.js'\nexport * from './did-resolver.js'\nexport * from './methods.js'\n"]}
@@ -1,31 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DidPlcMethod = void 0;
4
- const did_1 = require("@atproto/did");
5
- const fetch_1 = require("@atproto-labs/fetch");
6
- const pipe_1 = require("@atproto-labs/pipe");
7
- const fetchSuccessHandler = (0, pipe_1.pipe)((0, fetch_1.fetchOkProcessor)(), (0, fetch_1.fetchJsonProcessor)(/^application\/(did\+ld\+)?json$/), (0, fetch_1.fetchJsonZodProcessor)(did_1.didDocumentValidator));
8
- class DidPlcMethod {
1
+ import { assertDidPlc, didDocumentValidator } from '@atproto/did';
2
+ import { bindFetch, fetchJsonProcessor, fetchJsonZodProcessor, fetchOkProcessor, } from '@atproto-labs/fetch';
3
+ import { pipe } from '@atproto-labs/pipe';
4
+ const fetchSuccessHandler = pipe(fetchOkProcessor(), fetchJsonProcessor(/^application\/(did\+ld\+)?json$/), fetchJsonZodProcessor(didDocumentValidator));
5
+ export class DidPlcMethod {
9
6
  constructor(options) {
10
- Object.defineProperty(this, "fetch", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: void 0
15
- });
16
- Object.defineProperty(this, "plcDirectoryUrl", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: void 0
21
- });
22
7
  this.plcDirectoryUrl = new URL(options?.plcDirectoryUrl || 'https://plc.directory/');
23
- this.fetch = (0, fetch_1.bindFetch)(options?.fetch);
8
+ this.fetch = bindFetch(options?.fetch);
24
9
  }
25
10
  async resolve(did, options) {
26
11
  // Although the did should start with `did:plc:` (thanks to typings), we
27
12
  // should still check if the msid is valid.
28
- (0, did_1.assertDidPlc)(did);
13
+ assertDidPlc(did);
29
14
  // Should never throw
30
15
  const url = new URL(`/${encodeURIComponent(did)}`, this.plcDirectoryUrl);
31
16
  return this.fetch(url, {
@@ -35,5 +20,4 @@ class DidPlcMethod {
35
20
  }).then(fetchSuccessHandler);
36
21
  }
37
22
  }
38
- exports.DidPlcMethod = DidPlcMethod;
39
23
  //# sourceMappingURL=plc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plc.js","sourceRoot":"","sources":["../../src/methods/plc.ts"],"names":[],"mappings":";;;AAAA,sCAAsE;AACtE,+CAM4B;AAC5B,6CAAyC;AAGzC,MAAM,mBAAmB,GAAG,IAAA,WAAI,EAC9B,IAAA,wBAAgB,GAAE,EAClB,IAAA,0BAAkB,EAAC,iCAAiC,CAAC,EACrD,IAAA,6BAAqB,EAAC,0BAAoB,CAAC,CAC5C,CAAA;AAcD,MAAa,YAAY;IAKvB,YAAY,OAA6B;QAJtB;;;;;WAAqB;QAExB;;;;;WAAoB;QAGlC,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,CAC5B,OAAO,EAAE,eAAe,IAAI,wBAAwB,CACrD,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,IAAA,iBAAS,EAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAe,EAAE,OAA2B;QACxD,wEAAwE;QACxE,2CAA2C;QAC3C,IAAA,kBAAY,EAAC,GAAG,CAAC,CAAA;QAEjB,qBAAqB;QACrB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;QAExE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YACrB,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,EAAE,MAAM,EAAE,0CAA0C,EAAE;YAC/D,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IAC9B,CAAC;CACF;AA1BD,oCA0BC","sourcesContent":["import { Did, assertDidPlc, didDocumentValidator } from '@atproto/did'\nimport {\n Fetch,\n bindFetch,\n fetchJsonProcessor,\n fetchJsonZodProcessor,\n fetchOkProcessor,\n} from '@atproto-labs/fetch'\nimport { pipe } from '@atproto-labs/pipe'\nimport { DidMethod, ResolveDidOptions } from '../did-method.js'\n\nconst fetchSuccessHandler = pipe(\n fetchOkProcessor(),\n fetchJsonProcessor(/^application\\/(did\\+ld\\+)?json$/),\n fetchJsonZodProcessor(didDocumentValidator),\n)\n\nexport type DidPlcMethodOptions = {\n /**\n * @default globalThis.fetch\n */\n fetch?: Fetch\n\n /**\n * @default 'https://plc.directory/'\n */\n plcDirectoryUrl?: string | URL\n}\n\nexport class DidPlcMethod implements DidMethod<'plc'> {\n protected readonly fetch: Fetch<unknown>\n\n public readonly plcDirectoryUrl: URL\n\n constructor(options?: DidPlcMethodOptions) {\n this.plcDirectoryUrl = new URL(\n options?.plcDirectoryUrl || 'https://plc.directory/',\n )\n this.fetch = bindFetch(options?.fetch)\n }\n\n async resolve(did: Did<'plc'>, options?: ResolveDidOptions) {\n // Although the did should start with `did:plc:` (thanks to typings), we\n // should still check if the msid is valid.\n assertDidPlc(did)\n\n // Should never throw\n const url = new URL(`/${encodeURIComponent(did)}`, this.plcDirectoryUrl)\n\n return this.fetch(url, {\n redirect: 'error',\n headers: { accept: 'application/did+ld+json,application/json' },\n signal: options?.signal,\n }).then(fetchSuccessHandler)\n }\n}\n"]}
1
+ {"version":3,"file":"plc.js","sourceRoot":"","sources":["../../src/methods/plc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,YAAY,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAEL,SAAS,EACT,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAGzC,MAAM,mBAAmB,GAAG,IAAI,CAC9B,gBAAgB,EAAE,EAClB,kBAAkB,CAAC,iCAAiC,CAAC,EACrD,qBAAqB,CAAC,oBAAoB,CAAC,CAC5C,CAAA;AAcD,MAAM,OAAO,YAAY;IAKvB,YAAY,OAA6B;QACvC,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,CAC5B,OAAO,EAAE,eAAe,IAAI,wBAAwB,CACrD,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAe,EAAE,OAA2B;QACxD,wEAAwE;QACxE,2CAA2C;QAC3C,YAAY,CAAC,GAAG,CAAC,CAAA;QAEjB,qBAAqB;QACrB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;QAExE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YACrB,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,EAAE,MAAM,EAAE,0CAA0C,EAAE;YAC/D,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["import { Did, assertDidPlc, didDocumentValidator } from '@atproto/did'\nimport {\n Fetch,\n bindFetch,\n fetchJsonProcessor,\n fetchJsonZodProcessor,\n fetchOkProcessor,\n} from '@atproto-labs/fetch'\nimport { pipe } from '@atproto-labs/pipe'\nimport { DidMethod, ResolveDidOptions } from '../did-method.js'\n\nconst fetchSuccessHandler = pipe(\n fetchOkProcessor(),\n fetchJsonProcessor(/^application\\/(did\\+ld\\+)?json$/),\n fetchJsonZodProcessor(didDocumentValidator),\n)\n\nexport type DidPlcMethodOptions = {\n /**\n * @default globalThis.fetch\n */\n fetch?: Fetch\n\n /**\n * @default 'https://plc.directory/'\n */\n plcDirectoryUrl?: string | URL\n}\n\nexport class DidPlcMethod implements DidMethod<'plc'> {\n protected readonly fetch: Fetch<unknown>\n\n public readonly plcDirectoryUrl: URL\n\n constructor(options?: DidPlcMethodOptions) {\n this.plcDirectoryUrl = new URL(\n options?.plcDirectoryUrl || 'https://plc.directory/',\n )\n this.fetch = bindFetch(options?.fetch)\n }\n\n async resolve(did: Did<'plc'>, options?: ResolveDidOptions) {\n // Although the did should start with `did:plc:` (thanks to typings), we\n // should still check if the msid is valid.\n assertDidPlc(did)\n\n // Should never throw\n const url = new URL(`/${encodeURIComponent(did)}`, this.plcDirectoryUrl)\n\n return this.fetch(url, {\n redirect: 'error',\n headers: { accept: 'application/did+ld+json,application/json' },\n signal: options?.signal,\n }).then(fetchSuccessHandler)\n }\n}\n"]}
@@ -1,32 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DidWebMethod = void 0;
4
- exports.buildDidWebDocumentUrl = buildDidWebDocumentUrl;
5
- const did_1 = require("@atproto/did");
6
- const fetch_1 = require("@atproto-labs/fetch");
7
- const pipe_1 = require("@atproto-labs/pipe");
8
- const fetchSuccessHandler = (0, pipe_1.pipe)((0, fetch_1.fetchOkProcessor)(), (0, fetch_1.fetchJsonProcessor)(/^application\/(did\+ld\+)?json$/), (0, fetch_1.fetchJsonZodProcessor)(did_1.didDocumentValidator));
9
- class DidWebMethod {
1
+ import { DidError, didDocumentValidator, didWebToUrl } from '@atproto/did';
2
+ import { bindFetch, fetchJsonProcessor, fetchJsonZodProcessor, fetchOkProcessor, } from '@atproto-labs/fetch';
3
+ import { pipe } from '@atproto-labs/pipe';
4
+ const fetchSuccessHandler = pipe(fetchOkProcessor(), fetchJsonProcessor(/^application\/(did\+ld\+)?json$/), fetchJsonZodProcessor(didDocumentValidator));
5
+ export class DidWebMethod {
10
6
  constructor({ fetch = globalThis.fetch, allowHttp = true, } = {}) {
11
- Object.defineProperty(this, "fetch", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: void 0
16
- });
17
- Object.defineProperty(this, "allowHttp", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: void 0
22
- });
23
- this.fetch = (0, fetch_1.bindFetch)(fetch);
7
+ this.fetch = bindFetch(fetch);
24
8
  this.allowHttp = allowHttp;
25
9
  }
26
10
  async resolve(did, options) {
27
11
  const didDocumentUrl = buildDidWebDocumentUrl(did);
28
12
  if (!this.allowHttp && didDocumentUrl.protocol === 'http:') {
29
- throw new did_1.DidError(did, 'Resolution of "http" did:web is not allowed', 'did-web-http-not-allowed');
13
+ throw new DidError(did, 'Resolution of "http" did:web is not allowed', 'did-web-http-not-allowed');
30
14
  }
31
15
  // Note we do not explicitly check for "localhost" here. Instead, we rely on
32
16
  // the injected 'fetch' function to handle the URL. If the URL is
@@ -39,13 +23,12 @@ class DidWebMethod {
39
23
  }).then(fetchSuccessHandler);
40
24
  }
41
25
  }
42
- exports.DidWebMethod = DidWebMethod;
43
26
  /**
44
27
  * @see {@link https://datatracker.ietf.org/doc/html/rfc8615}
45
28
  * @see {@link https://w3c-ccg.github.io/did-method-web/#create-register}
46
29
  */
47
- function buildDidWebDocumentUrl(did) {
48
- const url = (0, did_1.didWebToUrl)(did); // Will throw if the DID is invalid
30
+ export function buildDidWebDocumentUrl(did) {
31
+ const url = didWebToUrl(did); // Will throw if the DID is invalid
49
32
  // Note: DID cannot end with an `:`, so they cannot end with a `/`. This is
50
33
  // true unless when there is no path at all, in which case the URL constructor
51
34
  // will set the pathname to `/`.
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/methods/web.ts"],"names":[],"mappings":";;;AA+DA,wDAaC;AA5ED,sCAA+E;AAC/E,+CAM4B;AAC5B,6CAAyC;AAGzC,MAAM,mBAAmB,GAAG,IAAA,WAAI,EAC9B,IAAA,wBAAgB,GAAE,EAClB,IAAA,0BAAkB,EAAC,iCAAiC,CAAC,EACrD,IAAA,6BAAqB,EAAC,0BAAoB,CAAC,CAC5C,CAAA;AAQD,MAAa,YAAY;IAIvB,YAAY,EACV,KAAK,GAAG,UAAU,CAAC,KAAK,EACxB,SAAS,GAAG,IAAI,MACO,EAAE;QANR;;;;;WAAqB;QACrB;;;;;WAAkB;QAMnC,IAAI,CAAC,KAAK,GAAG,IAAA,iBAAS,EAAC,KAAK,CAAC,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAe,EAAE,OAA2B;QACxD,MAAM,cAAc,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAA;QAElD,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,cAAc,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YAC3D,MAAM,IAAI,cAAQ,CAChB,GAAG,EACH,6CAA6C,EAC7C,0BAA0B,CAC3B,CAAA;QACH,CAAC;QAED,4EAA4E;QAC5E,iEAAiE;QACjE,0EAA0E;QAC1E,+BAA+B;QAE/B,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;YAChC,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,EAAE,MAAM,EAAE,0CAA0C,EAAE;YAC/D,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IAC9B,CAAC;CACF;AAlCD,oCAkCC;AAED;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,GAAe;IACpD,MAAM,GAAG,GAAG,IAAA,iBAAW,EAAC,GAAG,CAAC,CAAA,CAAC,mCAAmC;IAEhE,2EAA2E;IAC3E,8EAA8E;IAC9E,gCAAgC;IAEhC,yDAAyD;IACzD,IAAI,GAAG,CAAC,QAAQ,KAAK,GAAG,EAAE,CAAC;QACzB,OAAO,IAAI,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,WAAW,EAAE,GAAG,CAAC,CAAA;IACjD,CAAC;AACH,CAAC","sourcesContent":["import { Did, DidError, didDocumentValidator, didWebToUrl } from '@atproto/did'\nimport {\n Fetch,\n bindFetch,\n fetchJsonProcessor,\n fetchJsonZodProcessor,\n fetchOkProcessor,\n} from '@atproto-labs/fetch'\nimport { pipe } from '@atproto-labs/pipe'\nimport { DidMethod, ResolveDidOptions } from '../did-method.js'\n\nconst fetchSuccessHandler = pipe(\n fetchOkProcessor(),\n fetchJsonProcessor(/^application\\/(did\\+ld\\+)?json$/),\n fetchJsonZodProcessor(didDocumentValidator),\n)\n\nexport type DidWebMethodOptions = {\n fetch?: Fetch\n /** @default true */\n allowHttp?: boolean\n}\n\nexport class DidWebMethod implements DidMethod<'web'> {\n protected readonly fetch: Fetch<unknown>\n protected readonly allowHttp: boolean\n\n constructor({\n fetch = globalThis.fetch,\n allowHttp = true,\n }: DidWebMethodOptions = {}) {\n this.fetch = bindFetch(fetch)\n this.allowHttp = allowHttp\n }\n\n async resolve(did: Did<'web'>, options?: ResolveDidOptions) {\n const didDocumentUrl = buildDidWebDocumentUrl(did)\n\n if (!this.allowHttp && didDocumentUrl.protocol === 'http:') {\n throw new DidError(\n did,\n 'Resolution of \"http\" did:web is not allowed',\n 'did-web-http-not-allowed',\n )\n }\n\n // Note we do not explicitly check for \"localhost\" here. Instead, we rely on\n // the injected 'fetch' function to handle the URL. If the URL is\n // \"localhost\", or resolves to a private IP address, the fetch function is\n // responsible for handling it.\n\n return this.fetch(didDocumentUrl, {\n redirect: 'error',\n headers: { accept: 'application/did+ld+json,application/json' },\n signal: options?.signal,\n }).then(fetchSuccessHandler)\n }\n}\n\n/**\n * @see {@link https://datatracker.ietf.org/doc/html/rfc8615}\n * @see {@link https://w3c-ccg.github.io/did-method-web/#create-register}\n */\nexport function buildDidWebDocumentUrl(did: Did<'web'>) {\n const url = didWebToUrl(did) // Will throw if the DID is invalid\n\n // Note: DID cannot end with an `:`, so they cannot end with a `/`. This is\n // true unless when there is no path at all, in which case the URL constructor\n // will set the pathname to `/`.\n\n // https://w3c-ccg.github.io/did-method-web/#read-resolve\n if (url.pathname === '/') {\n return new URL(`/.well-known/did.json`, url)\n } else {\n return new URL(`${url.pathname}/did.json`, url)\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/methods/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/E,OAAO,EAEL,SAAS,EACT,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAGzC,MAAM,mBAAmB,GAAG,IAAI,CAC9B,gBAAgB,EAAE,EAClB,kBAAkB,CAAC,iCAAiC,CAAC,EACrD,qBAAqB,CAAC,oBAAoB,CAAC,CAC5C,CAAA;AAQD,MAAM,OAAO,YAAY;IAIvB,YAAY,EACV,KAAK,GAAG,UAAU,CAAC,KAAK,EACxB,SAAS,GAAG,IAAI,MACO,EAAE;QACzB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAe,EAAE,OAA2B;QACxD,MAAM,cAAc,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAA;QAElD,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,cAAc,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YAC3D,MAAM,IAAI,QAAQ,CAChB,GAAG,EACH,6CAA6C,EAC7C,0BAA0B,CAC3B,CAAA;QACH,CAAC;QAED,4EAA4E;QAC5E,iEAAiE;QACjE,0EAA0E;QAC1E,+BAA+B;QAE/B,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;YAChC,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,EAAE,MAAM,EAAE,0CAA0C,EAAE;YAC/D,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IAC9B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAe;IACpD,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA,CAAC,mCAAmC;IAEhE,2EAA2E;IAC3E,8EAA8E;IAC9E,gCAAgC;IAEhC,yDAAyD;IACzD,IAAI,GAAG,CAAC,QAAQ,KAAK,GAAG,EAAE,CAAC;QACzB,OAAO,IAAI,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,WAAW,EAAE,GAAG,CAAC,CAAA;IACjD,CAAC;AACH,CAAC","sourcesContent":["import { Did, DidError, didDocumentValidator, didWebToUrl } from '@atproto/did'\nimport {\n Fetch,\n bindFetch,\n fetchJsonProcessor,\n fetchJsonZodProcessor,\n fetchOkProcessor,\n} from '@atproto-labs/fetch'\nimport { pipe } from '@atproto-labs/pipe'\nimport { DidMethod, ResolveDidOptions } from '../did-method.js'\n\nconst fetchSuccessHandler = pipe(\n fetchOkProcessor(),\n fetchJsonProcessor(/^application\\/(did\\+ld\\+)?json$/),\n fetchJsonZodProcessor(didDocumentValidator),\n)\n\nexport type DidWebMethodOptions = {\n fetch?: Fetch\n /** @default true */\n allowHttp?: boolean\n}\n\nexport class DidWebMethod implements DidMethod<'web'> {\n protected readonly fetch: Fetch<unknown>\n protected readonly allowHttp: boolean\n\n constructor({\n fetch = globalThis.fetch,\n allowHttp = true,\n }: DidWebMethodOptions = {}) {\n this.fetch = bindFetch(fetch)\n this.allowHttp = allowHttp\n }\n\n async resolve(did: Did<'web'>, options?: ResolveDidOptions) {\n const didDocumentUrl = buildDidWebDocumentUrl(did)\n\n if (!this.allowHttp && didDocumentUrl.protocol === 'http:') {\n throw new DidError(\n did,\n 'Resolution of \"http\" did:web is not allowed',\n 'did-web-http-not-allowed',\n )\n }\n\n // Note we do not explicitly check for \"localhost\" here. Instead, we rely on\n // the injected 'fetch' function to handle the URL. If the URL is\n // \"localhost\", or resolves to a private IP address, the fetch function is\n // responsible for handling it.\n\n return this.fetch(didDocumentUrl, {\n redirect: 'error',\n headers: { accept: 'application/did+ld+json,application/json' },\n signal: options?.signal,\n }).then(fetchSuccessHandler)\n }\n}\n\n/**\n * @see {@link https://datatracker.ietf.org/doc/html/rfc8615}\n * @see {@link https://w3c-ccg.github.io/did-method-web/#create-register}\n */\nexport function buildDidWebDocumentUrl(did: Did<'web'>) {\n const url = didWebToUrl(did) // Will throw if the DID is invalid\n\n // Note: DID cannot end with an `:`, so they cannot end with a `/`. This is\n // true unless when there is no path at all, in which case the URL constructor\n // will set the pathname to `/`.\n\n // https://w3c-ccg.github.io/did-method-web/#read-resolve\n if (url.pathname === '/') {\n return new URL(`/.well-known/did.json`, url)\n } else {\n return new URL(`${url.pathname}/did.json`, url)\n }\n}\n"]}
package/dist/methods.js CHANGED
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./methods/plc.js"), exports);
18
- __exportStar(require("./methods/web.js"), exports);
1
+ export * from './methods/plc.js';
2
+ export * from './methods/web.js';
19
3
  //# sourceMappingURL=methods.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"methods.js","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,mDAAgC","sourcesContent":["export * from './methods/plc.js'\nexport * from './methods/web.js'\n"]}
1
+ {"version":3,"file":"methods.js","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA","sourcesContent":["export * from './methods/plc.js'\nexport * from './methods/web.js'\n"]}
package/dist/util.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=util.js.map
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@atproto-labs/did-resolver",
3
- "version": "0.2.6",
3
+ "version": "0.3.0-next.0",
4
+ "engines": {
5
+ "node": ">=22"
6
+ },
4
7
  "license": "MIT",
5
8
  "description": "DID resolution and verification library",
6
9
  "keywords": [
@@ -14,9 +17,7 @@
14
17
  "url": "https://github.com/bluesky-social/atproto",
15
18
  "directory": "packages/internal/did-resolver"
16
19
  },
17
- "type": "commonjs",
18
- "main": "dist/index.js",
19
- "types": "dist/index.d.ts",
20
+ "type": "module",
20
21
  "exports": {
21
22
  ".": {
22
23
  "types": "./dist/index.d.ts",
@@ -25,14 +26,14 @@
25
26
  },
26
27
  "dependencies": {
27
28
  "zod": "^3.23.8",
28
- "@atproto-labs/fetch": "0.2.3",
29
- "@atproto-labs/pipe": "0.1.1",
30
- "@atproto-labs/simple-store": "0.3.0",
31
- "@atproto-labs/simple-store-memory": "0.1.4",
32
- "@atproto/did": "0.3.0"
29
+ "@atproto-labs/fetch": "^0.3.0-next.0",
30
+ "@atproto-labs/pipe": "^0.2.0-next.0",
31
+ "@atproto-labs/simple-store": "^0.4.0-next.0",
32
+ "@atproto/did": "^0.4.0-next.0",
33
+ "@atproto-labs/simple-store-memory": "^0.2.0-next.0"
33
34
  },
34
35
  "devDependencies": {
35
- "typescript": "^5.6.3"
36
+ "typescript": "^6.0.3"
36
37
  },
37
38
  "scripts": {
38
39
  "build": "tsc --build tsconfig.build.json"
@@ -1 +1 @@
1
- {"root":["./src/create-did-resolver.ts","./src/did-cache-memory.ts","./src/did-cache.ts","./src/did-method.ts","./src/did-resolver-base.ts","./src/did-resolver-common.ts","./src/did-resolver.ts","./src/index.ts","./src/methods.ts","./src/util.ts","./src/methods/plc.ts","./src/methods/web.ts"],"version":"5.8.2"}
1
+ {"root":["./src/create-did-resolver.ts","./src/did-cache-memory.ts","./src/did-cache.ts","./src/did-method.ts","./src/did-resolver-base.ts","./src/did-resolver-common.ts","./src/did-resolver.ts","./src/index.ts","./src/methods.ts","./src/util.ts","./src/methods/plc.ts","./src/methods/web.ts"],"version":"6.0.3"}