@atproto-labs/identity-resolver 0.3.5 → 0.4.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 +28 -0
- package/LICENSE.txt +1 -1
- package/dist/atproto-identity-resolver.js +16 -30
- package/dist/atproto-identity-resolver.js.map +1 -1
- package/dist/constants.js +1 -4
- package/dist/constants.js.map +1 -1
- package/dist/create-identity-resolver.js +7 -10
- package/dist/create-identity-resolver.js.map +1 -1
- package/dist/identity-resolver-error.js +2 -11
- package/dist/identity-resolver-error.js.map +1 -1
- package/dist/identity-resolver.d.ts +1 -1
- package/dist/identity-resolver.d.ts.map +1 -1
- package/dist/identity-resolver.js +1 -2
- package/dist/identity-resolver.js.map +1 -1
- package/dist/index.js +6 -22
- package/dist/index.js.map +1 -1
- package/dist/util.js +5 -12
- package/dist/util.js.map +1 -1
- package/package.json +8 -7
- package/src/identity-resolver.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @atproto-labs/identity-resolver
|
|
2
2
|
|
|
3
|
+
## 0.4.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-labs/did-resolver@0.3.0-next.0
|
|
21
|
+
- @atproto-labs/handle-resolver@0.4.0-next.0
|
|
22
|
+
|
|
23
|
+
## 0.3.6
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies []:
|
|
28
|
+
- @atproto-labs/did-resolver@0.2.6
|
|
29
|
+
- @atproto-labs/handle-resolver@0.3.6
|
|
30
|
+
|
|
3
31
|
## 0.3.5
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Dual MIT/Apache-2.0 License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022-
|
|
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,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const constants_js_1 = require("./constants.js");
|
|
6
|
-
const identity_resolver_error_js_1 = require("./identity-resolver-error.js");
|
|
7
|
-
const util_js_1 = require("./util.js");
|
|
1
|
+
import { isAtprotoDid, } from '@atproto-labs/did-resolver';
|
|
2
|
+
import { HANDLE_INVALID } from './constants.js';
|
|
3
|
+
import { IdentityResolverError } from './identity-resolver-error.js';
|
|
4
|
+
import { asNormalizedHandle, extractNormalizedHandle } from './util.js';
|
|
8
5
|
// @TODO Move this to its own package as soon as we have a distinct
|
|
9
6
|
// implementation based on XRPC calls to the
|
|
10
7
|
// "com.atproto.identity.resolveIdentity" method.
|
|
@@ -14,23 +11,13 @@ const util_js_1 = require("./util.js");
|
|
|
14
11
|
* - DID resolution (using the `DidResolver` interface)
|
|
15
12
|
* - Handle resolution (using the `HandleResolver` interface)
|
|
16
13
|
*/
|
|
17
|
-
class AtprotoIdentityResolver {
|
|
14
|
+
export class AtprotoIdentityResolver {
|
|
18
15
|
constructor(didResolver, handleResolver) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: didResolver
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(this, "handleResolver", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: handleResolver
|
|
30
|
-
});
|
|
16
|
+
this.didResolver = didResolver;
|
|
17
|
+
this.handleResolver = handleResolver;
|
|
31
18
|
}
|
|
32
19
|
async resolve(input, options) {
|
|
33
|
-
return
|
|
20
|
+
return isAtprotoDid(input)
|
|
34
21
|
? this.resolveFromDid(input, options)
|
|
35
22
|
: this.resolveFromHandle(input, options);
|
|
36
23
|
}
|
|
@@ -39,7 +26,7 @@ class AtprotoIdentityResolver {
|
|
|
39
26
|
options?.signal?.throwIfAborted();
|
|
40
27
|
// We will only return the document's handle alias if it resolves to the
|
|
41
28
|
// same DID as the input.
|
|
42
|
-
const handle =
|
|
29
|
+
const handle = extractNormalizedHandle(document);
|
|
43
30
|
const resolvedDid = handle
|
|
44
31
|
? await this.handleResolver
|
|
45
32
|
.resolve(handle, options)
|
|
@@ -48,7 +35,7 @@ class AtprotoIdentityResolver {
|
|
|
48
35
|
return {
|
|
49
36
|
did: document.id,
|
|
50
37
|
didDoc: document,
|
|
51
|
-
handle: handle && resolvedDid === did ? handle :
|
|
38
|
+
handle: handle && resolvedDid === did ? handle : HANDLE_INVALID,
|
|
52
39
|
};
|
|
53
40
|
}
|
|
54
41
|
async resolveFromHandle(handle, options) {
|
|
@@ -57,31 +44,30 @@ class AtprotoIdentityResolver {
|
|
|
57
44
|
return {
|
|
58
45
|
did: document.id,
|
|
59
46
|
didDoc: document,
|
|
60
|
-
handle:
|
|
47
|
+
handle: extractNormalizedHandle(document) || HANDLE_INVALID,
|
|
61
48
|
};
|
|
62
49
|
}
|
|
63
50
|
async getDocumentFromDid(did, options) {
|
|
64
51
|
return this.didResolver.resolve(did, options);
|
|
65
52
|
}
|
|
66
53
|
async getDocumentFromHandle(input, options) {
|
|
67
|
-
const handle =
|
|
54
|
+
const handle = asNormalizedHandle(input);
|
|
68
55
|
if (!handle) {
|
|
69
|
-
throw new
|
|
56
|
+
throw new IdentityResolverError(`Invalid handle "${input}" provided.`);
|
|
70
57
|
}
|
|
71
58
|
const did = await this.handleResolver.resolve(handle, options);
|
|
72
59
|
if (!did) {
|
|
73
|
-
throw new
|
|
60
|
+
throw new IdentityResolverError(`Handle "${handle}" does not resolve to a DID`);
|
|
74
61
|
}
|
|
75
62
|
options?.signal?.throwIfAborted();
|
|
76
63
|
// Note: Not using "return this.resolveDid(did, options)" to make the extra
|
|
77
64
|
// check for the handle in the DID document:
|
|
78
65
|
const document = await this.didResolver.resolve(did, options);
|
|
79
66
|
// Enforce bi-directional resolution
|
|
80
|
-
if (handle !==
|
|
81
|
-
throw new
|
|
67
|
+
if (handle !== extractNormalizedHandle(document)) {
|
|
68
|
+
throw new IdentityResolverError(`Did document for "${did}" does not include the handle "${handle}"`);
|
|
82
69
|
}
|
|
83
70
|
return document;
|
|
84
71
|
}
|
|
85
72
|
}
|
|
86
|
-
exports.AtprotoIdentityResolver = AtprotoIdentityResolver;
|
|
87
73
|
//# sourceMappingURL=atproto-identity-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atproto-identity-resolver.js","sourceRoot":"","sources":["../src/atproto-identity-resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"atproto-identity-resolver.js","sourceRoot":"","sources":["../src/atproto-identity-resolver.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n AtprotoDid,\n AtprotoIdentityDidMethods,\n DidDocument,\n DidResolver,\n ResolveDidOptions,\n isAtprotoDid,\n} from '@atproto-labs/did-resolver'\nimport {\n HandleResolver,\n ResolveHandleOptions,\n} from '@atproto-labs/handle-resolver'\nimport { HANDLE_INVALID } from './constants.js'\nimport { IdentityResolverError } from './identity-resolver-error.js'\nimport {\n IdentityInfo,\n IdentityResolver,\n ResolveIdentityOptions,\n} from './identity-resolver.js'\nimport { asNormalizedHandle, extractNormalizedHandle } from './util.js'\n\n// @TODO Move this to its own package as soon as we have a distinct\n// implementation based on XRPC calls to the\n// \"com.atproto.identity.resolveIdentity\" method.\n\n/**\n * Implementation of the official ATPROTO identity resolution strategy.\n * This implementation relies on two primitives:\n * - DID resolution (using the `DidResolver` interface)\n * - Handle resolution (using the `HandleResolver` interface)\n */\nexport class AtprotoIdentityResolver implements IdentityResolver {\n constructor(\n protected readonly didResolver: DidResolver<AtprotoIdentityDidMethods>,\n protected readonly handleResolver: HandleResolver,\n ) {}\n\n public async resolve(\n input: string,\n options?: ResolveIdentityOptions,\n ): Promise<IdentityInfo> {\n return isAtprotoDid(input)\n ? this.resolveFromDid(input, options)\n : this.resolveFromHandle(input, options)\n }\n\n public async resolveFromDid(\n did: AtprotoDid,\n options?: ResolveDidOptions,\n ): Promise<IdentityInfo> {\n const document = await this.getDocumentFromDid(did, options)\n\n options?.signal?.throwIfAborted()\n\n // We will only return the document's handle alias if it resolves to the\n // same DID as the input.\n const handle = extractNormalizedHandle(document)\n const resolvedDid = handle\n ? await this.handleResolver\n .resolve(handle, options)\n .catch(() => undefined) // Ignore errors (temporarily unavailable)\n : undefined\n\n return {\n did: document.id,\n didDoc: document,\n handle: handle && resolvedDid === did ? handle : HANDLE_INVALID,\n }\n }\n\n public async resolveFromHandle(\n handle: string,\n options?: ResolveHandleOptions,\n ): Promise<IdentityInfo> {\n const document = await this.getDocumentFromHandle(handle, options)\n\n // @NOTE bi-directional resolution enforced in getDocumentFromHandle()\n\n return {\n did: document.id,\n didDoc: document,\n handle: extractNormalizedHandle(document) || HANDLE_INVALID,\n }\n }\n\n public async getDocumentFromDid(\n did: AtprotoDid,\n options?: ResolveDidOptions,\n ): Promise<DidDocument<AtprotoIdentityDidMethods>> {\n return this.didResolver.resolve(did, options)\n }\n\n public async getDocumentFromHandle(\n input: string,\n options?: ResolveHandleOptions,\n ): Promise<DidDocument<AtprotoIdentityDidMethods>> {\n const handle = asNormalizedHandle(input)\n if (!handle) {\n throw new IdentityResolverError(`Invalid handle \"${input}\" provided.`)\n }\n\n const did = await this.handleResolver.resolve(handle, options)\n\n if (!did) {\n throw new IdentityResolverError(\n `Handle \"${handle}\" does not resolve to a DID`,\n )\n }\n\n options?.signal?.throwIfAborted()\n\n // Note: Not using \"return this.resolveDid(did, options)\" to make the extra\n // check for the handle in the DID document:\n\n const document = await this.didResolver.resolve(did, options)\n\n // Enforce bi-directional resolution\n if (handle !== extractNormalizedHandle(document)) {\n throw new IdentityResolverError(\n `Did document for \"${did}\" does not include the handle \"${handle}\"`,\n )\n }\n\n return document\n }\n}\n"]}
|
package/dist/constants.js
CHANGED
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAA","sourcesContent":["export const HANDLE_INVALID = 'handle.invalid'\n"]}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const handle_resolver_1 = require("@atproto-labs/handle-resolver");
|
|
6
|
-
const atproto_identity_resolver_js_1 = require("./atproto-identity-resolver.js");
|
|
7
|
-
function createIdentityResolver(options) {
|
|
1
|
+
import { createDidResolver, } from '@atproto-labs/did-resolver';
|
|
2
|
+
import { createHandleResolver, } from '@atproto-labs/handle-resolver';
|
|
3
|
+
import { AtprotoIdentityResolver } from './atproto-identity-resolver.js';
|
|
4
|
+
export function createIdentityResolver(options) {
|
|
8
5
|
if ('identityResolver' in options && options.identityResolver != null) {
|
|
9
6
|
return options.identityResolver;
|
|
10
7
|
}
|
|
11
8
|
if ('handleResolver' in options && options.handleResolver != null) {
|
|
12
|
-
const didResolver =
|
|
13
|
-
const handleResolver =
|
|
14
|
-
return new
|
|
9
|
+
const didResolver = createDidResolver(options);
|
|
10
|
+
const handleResolver = createHandleResolver(options);
|
|
11
|
+
return new AtprotoIdentityResolver(didResolver, handleResolver);
|
|
15
12
|
}
|
|
16
13
|
throw new TypeError('identityResolver or handleResolver option is required');
|
|
17
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-identity-resolver.js","sourceRoot":"","sources":["../src/create-identity-resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-identity-resolver.js","sourceRoot":"","sources":["../src/create-identity-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,GAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAEL,oBAAoB,GACrB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAA;AAOxE,MAAM,UAAU,sBAAsB,CACpC,OAAsC;IAEtC,IAAI,kBAAkB,IAAI,OAAO,IAAI,OAAO,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC;QACtE,OAAO,OAAO,CAAC,gBAAgB,CAAA;IACjC,CAAC;IAED,IAAI,gBAAgB,IAAI,OAAO,IAAI,OAAO,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC;QAClE,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;QAC9C,MAAM,cAAc,GAAG,oBAAoB,CACzC,OAEC,CACF,CAAA;QACD,OAAO,IAAI,uBAAuB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;IACjE,CAAC;IAED,MAAM,IAAI,SAAS,CAAC,uDAAuD,CAAC,CAAA;AAC9E,CAAC","sourcesContent":["import {\n CreateDidResolverOptions,\n createDidResolver,\n} from '@atproto-labs/did-resolver'\nimport {\n CreateHandleResolverOptions,\n createHandleResolver,\n} from '@atproto-labs/handle-resolver'\nimport { AtprotoIdentityResolver } from './atproto-identity-resolver.js'\nimport { IdentityResolver } from './identity-resolver.js'\n\nexport type CreateIdentityResolverOptions = {\n identityResolver?: IdentityResolver\n} & Partial<CreateDidResolverOptions & CreateHandleResolverOptions>\n\nexport function createIdentityResolver(\n options: CreateIdentityResolverOptions,\n): IdentityResolver {\n if ('identityResolver' in options && options.identityResolver != null) {\n return options.identityResolver\n }\n\n if ('handleResolver' in options && options.handleResolver != null) {\n const didResolver = createDidResolver(options)\n const handleResolver = createHandleResolver(\n options as typeof options & {\n handleResolver: NonNullable<(typeof options)['handleResolver']>\n },\n )\n return new AtprotoIdentityResolver(didResolver, handleResolver)\n }\n\n throw new TypeError('identityResolver or handleResolver option is required')\n}\n"]}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IdentityResolverError = void 0;
|
|
4
|
-
class IdentityResolverError extends Error {
|
|
1
|
+
export class IdentityResolverError extends Error {
|
|
5
2
|
constructor() {
|
|
6
3
|
super(...arguments);
|
|
7
|
-
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: 'IdentityResolverError'
|
|
12
|
-
});
|
|
4
|
+
this.name = 'IdentityResolverError';
|
|
13
5
|
}
|
|
14
6
|
}
|
|
15
|
-
exports.IdentityResolverError = IdentityResolverError;
|
|
16
7
|
//# sourceMappingURL=identity-resolver-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-resolver-error.js","sourceRoot":"","sources":["../src/identity-resolver-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identity-resolver-error.js","sourceRoot":"","sources":["../src/identity-resolver-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAAhD;;QACE,SAAI,GAAG,uBAAuB,CAAA;IAChC,CAAC;CAAA","sourcesContent":["export class IdentityResolverError extends Error {\n name = 'IdentityResolverError'\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AtprotoDid, AtprotoDidDocument } from '@atproto-labs/did-resolver';
|
|
2
|
-
import { HANDLE_INVALID } from './constants';
|
|
2
|
+
import { HANDLE_INVALID } from './constants.js';
|
|
3
3
|
export type { AtprotoDid, AtprotoDidDocument };
|
|
4
4
|
export type IdentityInfo = {
|
|
5
5
|
did: AtprotoDid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-resolver.d.ts","sourceRoot":"","sources":["../src/identity-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"identity-resolver.d.ts","sourceRoot":"","sources":["../src/identity-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAA;AAI9C,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,UAAU,CAAA;IACf,MAAM,EAAE,kBAAkB,CAAA;IAE1B;;;;OAIG;IACH,MAAM,EAAE,OAAO,cAAc,GAAG,MAAM,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CACL,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,YAAY,CAAC,CAAA;CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-resolver.js","sourceRoot":"","sources":["../src/identity-resolver.ts"],"names":[],"mappings":"","sourcesContent":["import { AtprotoDid, AtprotoDidDocument } from '@atproto-labs/did-resolver'\nimport { HANDLE_INVALID } from './constants'\n\nexport type { AtprotoDid, AtprotoDidDocument }\n\n// Consistent with `com.atproto.identity.defs#identityInfo` returned by\n// `com.atproto.identity.resolveIdentity` endpoint.\nexport type IdentityInfo = {\n did: AtprotoDid\n didDoc: AtprotoDidDocument\n\n /**\n * Will be 'handle.invalid' if the handle does not resolve to the\n * same DID as the input, or if the handle is not present in the DID\n * document.\n */\n handle: typeof HANDLE_INVALID | string\n}\n\nexport type ResolveIdentityOptions = {\n signal?: AbortSignal\n noCache?: boolean\n}\n\nexport interface IdentityResolver {\n resolve(\n identifier: string,\n options?: ResolveIdentityOptions,\n ): Promise<IdentityInfo>\n}\n"]}
|
|
1
|
+
{"version":3,"file":"identity-resolver.js","sourceRoot":"","sources":["../src/identity-resolver.ts"],"names":[],"mappings":"","sourcesContent":["import { AtprotoDid, AtprotoDidDocument } from '@atproto-labs/did-resolver'\nimport { HANDLE_INVALID } from './constants.js'\n\nexport type { AtprotoDid, AtprotoDidDocument }\n\n// Consistent with `com.atproto.identity.defs#identityInfo` returned by\n// `com.atproto.identity.resolveIdentity` endpoint.\nexport type IdentityInfo = {\n did: AtprotoDid\n didDoc: AtprotoDidDocument\n\n /**\n * Will be 'handle.invalid' if the handle does not resolve to the\n * same DID as the input, or if the handle is not present in the DID\n * document.\n */\n handle: typeof HANDLE_INVALID | string\n}\n\nexport type ResolveIdentityOptions = {\n signal?: AbortSignal\n noCache?: boolean\n}\n\nexport interface IdentityResolver {\n resolve(\n identifier: string,\n options?: ResolveIdentityOptions,\n ): Promise<IdentityInfo>\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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-identity-resolver.js"), exports);
|
|
18
|
-
__exportStar(require("./constants.js"), exports);
|
|
19
|
-
__exportStar(require("./create-identity-resolver.js"), exports);
|
|
20
|
-
__exportStar(require("./identity-resolver-error.js"), exports);
|
|
21
|
-
__exportStar(require("./identity-resolver.js"), exports);
|
|
22
|
-
__exportStar(require("./util.js"), exports);
|
|
1
|
+
export * from './atproto-identity-resolver.js';
|
|
2
|
+
export * from './constants.js';
|
|
3
|
+
export * from './create-identity-resolver.js';
|
|
4
|
+
export * from './identity-resolver-error.js';
|
|
5
|
+
export * from './identity-resolver.js';
|
|
6
|
+
export * from './util.js';
|
|
23
7
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA;AAC9C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,WAAW,CAAA","sourcesContent":["export * from './atproto-identity-resolver.js'\nexport * from './constants.js'\nexport * from './create-identity-resolver.js'\nexport * from './identity-resolver-error.js'\nexport * from './identity-resolver.js'\nexport * from './util.js'\n"]}
|
package/dist/util.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractAtprotoHandle = extractAtprotoHandle;
|
|
4
|
-
exports.extractNormalizedHandle = extractNormalizedHandle;
|
|
5
|
-
exports.asNormalizedHandle = asNormalizedHandle;
|
|
6
|
-
exports.normalizeHandle = normalizeHandle;
|
|
7
|
-
exports.isValidHandle = isValidHandle;
|
|
8
1
|
/**
|
|
9
2
|
* Extract the raw, un-validated, Atproto handle from a DID document.
|
|
10
3
|
*/
|
|
11
|
-
function extractAtprotoHandle(document) {
|
|
4
|
+
export function extractAtprotoHandle(document) {
|
|
12
5
|
if (document.alsoKnownAs) {
|
|
13
6
|
for (const h of document.alsoKnownAs) {
|
|
14
7
|
if (h.startsWith('at://')) {
|
|
@@ -22,20 +15,20 @@ function extractAtprotoHandle(document) {
|
|
|
22
15
|
/**
|
|
23
16
|
* Extracts a validated, normalized Atproto handle from a DID document.
|
|
24
17
|
*/
|
|
25
|
-
function extractNormalizedHandle(document) {
|
|
18
|
+
export function extractNormalizedHandle(document) {
|
|
26
19
|
const handle = extractAtprotoHandle(document);
|
|
27
20
|
if (!handle)
|
|
28
21
|
return undefined;
|
|
29
22
|
return asNormalizedHandle(handle);
|
|
30
23
|
}
|
|
31
|
-
function asNormalizedHandle(input) {
|
|
24
|
+
export function asNormalizedHandle(input) {
|
|
32
25
|
const handle = normalizeHandle(input);
|
|
33
26
|
return isValidHandle(handle) ? handle : undefined;
|
|
34
27
|
}
|
|
35
|
-
function normalizeHandle(handle) {
|
|
28
|
+
export function normalizeHandle(handle) {
|
|
36
29
|
return handle.toLowerCase();
|
|
37
30
|
}
|
|
38
|
-
function isValidHandle(handle) {
|
|
31
|
+
export function isValidHandle(handle) {
|
|
39
32
|
return (handle.length > 0 &&
|
|
40
33
|
handle.length < 254 &&
|
|
41
34
|
/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/.test(handle));
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAgD;IAEhD,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;YACrC,IAAI,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC1B,2BAA2B;gBAC3B,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACnB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAgD;IAEhD,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAC7C,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAA;IAC7B,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IACrC,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,MAAM,CAAC,WAAW,EAAE,CAAA;AAC7B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,CACL,MAAM,CAAC,MAAM,GAAG,CAAC;QACjB,MAAM,CAAC,MAAM,GAAG,GAAG;QACnB,4FAA4F,CAAC,IAAI,CAC/F,MAAM,CACP,CACF,CAAA;AACH,CAAC","sourcesContent":["import {\n AtprotoIdentityDidMethods,\n DidDocument,\n} from '@atproto-labs/did-resolver'\n\n/**\n * Extract the raw, un-validated, Atproto handle from a DID document.\n */\nexport function extractAtprotoHandle(\n document: DidDocument<AtprotoIdentityDidMethods>,\n): string | undefined {\n if (document.alsoKnownAs) {\n for (const h of document.alsoKnownAs) {\n if (h.startsWith('at://')) {\n // strip off \"at://\" prefix\n return h.slice(5)\n }\n }\n }\n return undefined\n}\n\n/**\n * Extracts a validated, normalized Atproto handle from a DID document.\n */\nexport function extractNormalizedHandle(\n document: DidDocument<AtprotoIdentityDidMethods>,\n): string | undefined {\n const handle = extractAtprotoHandle(document)\n if (!handle) return undefined\n return asNormalizedHandle(handle)\n}\n\nexport function asNormalizedHandle(input: string): string | undefined {\n const handle = normalizeHandle(input)\n return isValidHandle(handle) ? handle : undefined\n}\n\nexport function normalizeHandle(handle: string): string {\n return handle.toLowerCase()\n}\n\nexport function isValidHandle(handle: string): boolean {\n return (\n handle.length > 0 &&\n handle.length < 254 &&\n /^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/.test(\n handle,\n )\n )\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto-labs/identity-resolver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-next.0",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=22"
|
|
6
|
+
},
|
|
4
7
|
"license": "MIT",
|
|
5
8
|
"description": "A library resolving ATPROTO identities",
|
|
6
9
|
"keywords": [
|
|
@@ -15,9 +18,7 @@
|
|
|
15
18
|
"url": "https://github.com/bluesky-social/atproto",
|
|
16
19
|
"directory": "packages/internal/identity-resolver"
|
|
17
20
|
},
|
|
18
|
-
"type": "
|
|
19
|
-
"main": "dist/index.js",
|
|
20
|
-
"types": "dist/index.d.ts",
|
|
21
|
+
"type": "module",
|
|
21
22
|
"exports": {
|
|
22
23
|
".": {
|
|
23
24
|
"types": "./dist/index.d.ts",
|
|
@@ -25,11 +26,11 @@
|
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@atproto-labs/did-resolver": "0.
|
|
29
|
-
"@atproto-labs/handle-resolver": "0.
|
|
29
|
+
"@atproto-labs/did-resolver": "^0.3.0-next.0",
|
|
30
|
+
"@atproto-labs/handle-resolver": "^0.4.0-next.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"typescript": "^
|
|
33
|
+
"typescript": "^6.0.3"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
36
|
"build": "tsc --build tsconfig.json"
|
package/src/identity-resolver.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/atproto-identity-resolver.ts","./src/constants.ts","./src/create-identity-resolver.ts","./src/identity-resolver-error.ts","./src/identity-resolver.ts","./src/index.ts","./src/util.ts"],"version":"
|
|
1
|
+
{"root":["./src/atproto-identity-resolver.ts","./src/constants.ts","./src/create-identity-resolver.ts","./src/identity-resolver-error.ts","./src/identity-resolver.ts","./src/index.ts","./src/util.ts"],"version":"6.0.3"}
|