@atproto/identity 0.4.10 → 0.4.12

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,20 @@
1
1
  # @atproto/identity
2
2
 
3
+ ## 0.4.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4669](https://github.com/bluesky-social/atproto/pull/4669) [`dc9644b`](https://github.com/bluesky-social/atproto/commit/dc9644bbeb1892931809568895162d823e4743d2) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Fix lint warning
8
+
9
+ ## 0.4.11
10
+
11
+ ### Patch Changes
12
+
13
+ - [#4609](https://github.com/bluesky-social/atproto/pull/4609) [`00e6dbd`](https://github.com/bluesky-social/atproto/commit/00e6dbdcea295cfa3dff7eb7517420039cc3e821) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Fix `method.resolveNoCheck is not a function` error when using speciallt forged did method
14
+
15
+ - Updated dependencies []:
16
+ - @atproto/common-web@0.4.16
17
+
3
18
  ## 0.4.10
4
19
 
5
20
  ### Patch Changes
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  Dual MIT/Apache-2.0 License
2
2
 
3
- Copyright (c) 2022-2025 Bluesky Social PBC, and Contributors
3
+ Copyright (c) 2022-2026 Bluesky Social PBC, and Contributors
4
4
 
5
5
  Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { DidResolverOpts } from '../types';
2
2
  import { BaseResolver } from './base-resolver';
3
3
  export declare class DidResolver extends BaseResolver {
4
- methods: Record<string, BaseResolver>;
4
+ methods: Map<string, BaseResolver>;
5
5
  constructor(opts: DidResolverOpts);
6
6
  resolveNoCheck(did: string): Promise<unknown>;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"did-resolver.d.ts","sourceRoot":"","sources":["../../src/did/did-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAI9C,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;gBAEzB,IAAI,EAAE,eAAe;IAU3B,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAWpD"}
1
+ {"version":3,"file":"did-resolver.d.ts","sourceRoot":"","sources":["../../src/did/did-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAI9C,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;gBAEtB,IAAI,EAAE,eAAe;IAU3B,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAepD"}
@@ -16,17 +16,21 @@ class DidResolver extends base_resolver_1.BaseResolver {
16
16
  });
17
17
  const { timeout = 3000, plcUrl = 'https://plc.directory' } = opts;
18
18
  // do not pass cache to sub-methods or we will be double caching
19
- this.methods = {
20
- plc: new plc_resolver_1.DidPlcResolver(plcUrl, timeout),
21
- web: new web_resolver_1.DidWebResolver(timeout),
22
- };
19
+ this.methods = new Map([
20
+ ['plc', new plc_resolver_1.DidPlcResolver(plcUrl, timeout)],
21
+ ['web', new web_resolver_1.DidWebResolver(timeout)],
22
+ ]);
23
23
  }
24
24
  async resolveNoCheck(did) {
25
- const split = did.split(':');
26
- if (split[0] !== 'did') {
25
+ if (!did.startsWith('did:')) {
27
26
  throw new errors_1.PoorlyFormattedDidError(did);
28
27
  }
29
- const method = this.methods[split[1]];
28
+ const methodSepIdx = did.indexOf(':', 4);
29
+ if (methodSepIdx === -1) {
30
+ throw new errors_1.PoorlyFormattedDidError(did);
31
+ }
32
+ const methodName = did.slice(4, methodSepIdx);
33
+ const method = this.methods.get(methodName);
30
34
  if (!method) {
31
35
  throw new errors_1.UnsupportedDidMethodError(did);
32
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"did-resolver.js","sourceRoot":"","sources":["../../src/did/did-resolver.ts"],"names":[],"mappings":";;;AAAA,sCAA8E;AAE9E,mDAA8C;AAC9C,iDAA+C;AAC/C,iDAA+C;AAE/C,MAAa,WAAY,SAAQ,4BAAY;IAG3C,YAAY,IAAqB;QAC/B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAHtB;;;;;WAAqC;QAInC,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,MAAM,GAAG,uBAAuB,EAAE,GAAG,IAAI,CAAA;QACjE,gEAAgE;QAChE,IAAI,CAAC,OAAO,GAAG;YACb,GAAG,EAAE,IAAI,6BAAc,CAAC,MAAM,EAAE,OAAO,CAAC;YACxC,GAAG,EAAE,IAAI,6BAAc,CAAC,OAAO,CAAC;SACjC,CAAA;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,GAAW;QAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC;YACvB,MAAM,IAAI,gCAAuB,CAAC,GAAG,CAAC,CAAA;QACxC,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QACrC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,kCAAyB,CAAC,GAAG,CAAC,CAAA;QAC1C,CAAC;QACD,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;IACnC,CAAC;CACF;AAxBD,kCAwBC","sourcesContent":["import { PoorlyFormattedDidError, UnsupportedDidMethodError } from '../errors'\nimport { DidResolverOpts } from '../types'\nimport { BaseResolver } from './base-resolver'\nimport { DidPlcResolver } from './plc-resolver'\nimport { DidWebResolver } from './web-resolver'\n\nexport class DidResolver extends BaseResolver {\n methods: Record<string, BaseResolver>\n\n constructor(opts: DidResolverOpts) {\n super(opts.didCache)\n const { timeout = 3000, plcUrl = 'https://plc.directory' } = opts\n // do not pass cache to sub-methods or we will be double caching\n this.methods = {\n plc: new DidPlcResolver(plcUrl, timeout),\n web: new DidWebResolver(timeout),\n }\n }\n\n async resolveNoCheck(did: string): Promise<unknown> {\n const split = did.split(':')\n if (split[0] !== 'did') {\n throw new PoorlyFormattedDidError(did)\n }\n const method = this.methods[split[1]]\n if (!method) {\n throw new UnsupportedDidMethodError(did)\n }\n return method.resolveNoCheck(did)\n }\n}\n"]}
1
+ {"version":3,"file":"did-resolver.js","sourceRoot":"","sources":["../../src/did/did-resolver.ts"],"names":[],"mappings":";;;AAAA,sCAA8E;AAE9E,mDAA8C;AAC9C,iDAA+C;AAC/C,iDAA+C;AAE/C,MAAa,WAAY,SAAQ,4BAAY;IAG3C,YAAY,IAAqB;QAC/B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAHtB;;;;;WAAkC;QAIhC,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,MAAM,GAAG,uBAAuB,EAAE,GAAG,IAAI,CAAA;QACjE,gEAAgE;QAChE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC;YACrB,CAAC,KAAK,EAAE,IAAI,6BAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5C,CAAC,KAAK,EAAE,IAAI,6BAAc,CAAC,OAAO,CAAC,CAAC;SACrC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,GAAW;QAC9B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,gCAAuB,CAAC,GAAG,CAAC,CAAA;QACxC,CAAC;QACD,MAAM,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QACxC,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,gCAAuB,CAAC,GAAG,CAAC,CAAA;QACxC,CAAC;QACD,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,kCAAyB,CAAC,GAAG,CAAC,CAAA;QAC1C,CAAC;QACD,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;IACnC,CAAC;CACF;AA5BD,kCA4BC","sourcesContent":["import { PoorlyFormattedDidError, UnsupportedDidMethodError } from '../errors'\nimport { DidResolverOpts } from '../types'\nimport { BaseResolver } from './base-resolver'\nimport { DidPlcResolver } from './plc-resolver'\nimport { DidWebResolver } from './web-resolver'\n\nexport class DidResolver extends BaseResolver {\n methods: Map<string, BaseResolver>\n\n constructor(opts: DidResolverOpts) {\n super(opts.didCache)\n const { timeout = 3000, plcUrl = 'https://plc.directory' } = opts\n // do not pass cache to sub-methods or we will be double caching\n this.methods = new Map([\n ['plc', new DidPlcResolver(plcUrl, timeout)],\n ['web', new DidWebResolver(timeout)],\n ])\n }\n\n async resolveNoCheck(did: string): Promise<unknown> {\n if (!did.startsWith('did:')) {\n throw new PoorlyFormattedDidError(did)\n }\n const methodSepIdx = did.indexOf(':', 4)\n if (methodSepIdx === -1) {\n throw new PoorlyFormattedDidError(did)\n }\n const methodName = did.slice(4, methodSepIdx)\n const method = this.methods.get(methodName)\n if (!method) {\n throw new UnsupportedDidMethodError(did)\n }\n return method.resolveNoCheck(did)\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/identity",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "license": "MIT",
5
5
  "description": "Library for decentralized identities in atproto using DIDs and handles",
6
6
  "keywords": [
@@ -20,8 +20,8 @@
20
20
  "node": ">=18.7.0"
21
21
  },
22
22
  "dependencies": {
23
- "@atproto/common-web": "^0.4.4",
24
- "@atproto/crypto": "^0.4.4"
23
+ "@atproto/common-web": "^0.4.17",
24
+ "@atproto/crypto": "^0.4.5"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@did-plc/lib": "^0.0.1",
@@ -5,24 +5,28 @@ import { DidPlcResolver } from './plc-resolver'
5
5
  import { DidWebResolver } from './web-resolver'
6
6
 
7
7
  export class DidResolver extends BaseResolver {
8
- methods: Record<string, BaseResolver>
8
+ methods: Map<string, BaseResolver>
9
9
 
10
10
  constructor(opts: DidResolverOpts) {
11
11
  super(opts.didCache)
12
12
  const { timeout = 3000, plcUrl = 'https://plc.directory' } = opts
13
13
  // do not pass cache to sub-methods or we will be double caching
14
- this.methods = {
15
- plc: new DidPlcResolver(plcUrl, timeout),
16
- web: new DidWebResolver(timeout),
17
- }
14
+ this.methods = new Map([
15
+ ['plc', new DidPlcResolver(plcUrl, timeout)],
16
+ ['web', new DidWebResolver(timeout)],
17
+ ])
18
18
  }
19
19
 
20
20
  async resolveNoCheck(did: string): Promise<unknown> {
21
- const split = did.split(':')
22
- if (split[0] !== 'did') {
21
+ if (!did.startsWith('did:')) {
22
+ throw new PoorlyFormattedDidError(did)
23
+ }
24
+ const methodSepIdx = did.indexOf(':', 4)
25
+ if (methodSepIdx === -1) {
23
26
  throw new PoorlyFormattedDidError(did)
24
27
  }
25
- const method = this.methods[split[1]]
28
+ const methodName = did.slice(4, methodSepIdx)
29
+ const method = this.methods.get(methodName)
26
30
  if (!method) {
27
31
  throw new UnsupportedDidMethodError(did)
28
32
  }
@@ -1,12 +1,12 @@
1
1
  import http from 'node:http'
2
2
  import cors from 'cors'
3
- import express from 'express'
3
+ import express, { Router, json } from 'express'
4
4
  import { DidDocument } from '../../src'
5
5
  import { DidWebDb } from './db'
6
6
 
7
7
  const DOC_PATH = '/.well-known/did.json'
8
8
 
9
- const routes = express.Router()
9
+ const routes = Router()
10
10
 
11
11
  // Get DID Doc
12
12
  routes.get('/*', async (req, res) => {
@@ -60,7 +60,7 @@ export class DidWebServer {
60
60
  const app = express()
61
61
 
62
62
  app.use(cors())
63
- app.use(express.json())
63
+ app.use(json())
64
64
  app.use((_req, res, next) => {
65
65
  res.locals.db = db
66
66
  next()
@@ -1 +0,0 @@
1
- {"root":["./tests/did-cache.test.ts","./tests/did-document.test.ts","./tests/did-resolver.test.ts","./tests/handle-resolver.test.ts","./tests/web/db.ts","./tests/web/server.ts"],"version":"5.8.3"}