@atcute/identity 1.1.3 → 1.1.4
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/README.md +184 -1
- package/dist/did.d.ts +3 -4
- package/dist/did.d.ts.map +1 -1
- package/dist/did.js +1 -1
- package/dist/did.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/methods/key.d.ts +1 -2
- package/dist/methods/key.d.ts.map +1 -1
- package/dist/methods/plc.d.ts +1 -2
- package/dist/methods/plc.d.ts.map +1 -1
- package/dist/methods/web.d.ts +5 -6
- package/dist/methods/web.d.ts.map +1 -1
- package/dist/methods/web.js +3 -3
- package/dist/methods/web.js.map +1 -1
- package/dist/typedefs.d.ts +1 -1
- package/dist/typedefs.d.ts.map +1 -1
- package/dist/typedefs.js +3 -2
- package/dist/typedefs.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +3 -4
- package/dist/utils.d.ts.map +1 -1
- package/lib/did.ts +3 -3
- package/lib/index.ts +7 -7
- package/lib/methods/web.ts +3 -3
- package/lib/typedefs.ts +6 -4
- package/lib/types.ts +1 -1
- package/lib/utils.ts +1 -1
- package/package.json +12 -8
package/README.md
CHANGED
|
@@ -1,3 +1,186 @@
|
|
|
1
1
|
# @atcute/identity
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
types, schemas, and utilities for working with AT Protocol identities.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @atcute/identity
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
in AT Protocol, users are identified by [DIDs](https://www.w3.org/TR/did-core/) (decentralized
|
|
10
|
+
identifiers). this package provides tools for working with DIDs and DID documents - the documents
|
|
11
|
+
that describe a user's identity, including their handle, PDS location, and cryptographic keys.
|
|
12
|
+
|
|
13
|
+
for resolving handles and DIDs (fetching their documents), see `@atcute/identity-resolver`.
|
|
14
|
+
|
|
15
|
+
## usage
|
|
16
|
+
|
|
17
|
+
### checking DID types
|
|
18
|
+
|
|
19
|
+
AT Protocol supports two DID methods: `did:plc` and `did:web`. use the type guards to check which
|
|
20
|
+
method a DID uses:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { isPlcDid, isWebDid, isAtprotoDid } from '@atcute/identity';
|
|
24
|
+
|
|
25
|
+
const did = 'did:plc:z72i7hdynmk6r22z27h6tvur';
|
|
26
|
+
|
|
27
|
+
if (isPlcDid(did)) {
|
|
28
|
+
// did:plc identifier
|
|
29
|
+
console.log('PLC DID');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isWebDid(did)) {
|
|
33
|
+
// did:web identifier (general, includes custom paths)
|
|
34
|
+
console.log('Web DID');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isAtprotoDid(did)) {
|
|
38
|
+
// either did:plc or atproto-compatible did:web
|
|
39
|
+
console.log('AT Protocol DID');
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`isAtprotoDid` checks for DIDs that are valid in AT Protocol - this excludes did:web identifiers
|
|
44
|
+
with custom paths, which atproto doesn't support.
|
|
45
|
+
|
|
46
|
+
### extracting the DID method
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { extractDidMethod } from '@atcute/identity';
|
|
50
|
+
|
|
51
|
+
const method = extractDidMethod('did:plc:z72i7hdynmk6r22z27h6tvur');
|
|
52
|
+
// -> "plc"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### working with did:web
|
|
56
|
+
|
|
57
|
+
convert a did:web identifier to its DID document URL:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { webDidToDocumentUrl, normalizeWebDid } from '@atcute/identity';
|
|
61
|
+
|
|
62
|
+
// simple domain
|
|
63
|
+
const url = webDidToDocumentUrl('did:web:example.com');
|
|
64
|
+
// -> URL { href: "https://example.com/.well-known/did.json" }
|
|
65
|
+
|
|
66
|
+
// with path
|
|
67
|
+
const url2 = webDidToDocumentUrl('did:web:example.com:users:alice');
|
|
68
|
+
// -> URL { href: "https://example.com/users/alice/did.json" }
|
|
69
|
+
|
|
70
|
+
// normalize for comparison
|
|
71
|
+
const normalized = normalizeWebDid('did:web:EXAMPLE.COM');
|
|
72
|
+
// -> "did:web:example.com"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### reading DID documents
|
|
76
|
+
|
|
77
|
+
once you have a DID document (from a resolver or API), extract information using the utility
|
|
78
|
+
functions:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import {
|
|
82
|
+
getPdsEndpoint,
|
|
83
|
+
getAtprotoHandle,
|
|
84
|
+
getAtprotoVerificationMaterial,
|
|
85
|
+
getLabelerEndpoint,
|
|
86
|
+
} from '@atcute/identity';
|
|
87
|
+
import type { DidDocument } from '@atcute/identity';
|
|
88
|
+
|
|
89
|
+
const doc: DidDocument = {
|
|
90
|
+
'@context': ['https://www.w3.org/ns/did/v1'],
|
|
91
|
+
id: 'did:plc:z72i7hdynmk6r22z27h6tvur',
|
|
92
|
+
alsoKnownAs: ['at://bsky.app'],
|
|
93
|
+
verificationMethod: [
|
|
94
|
+
{
|
|
95
|
+
id: 'did:plc:z72i7hdynmk6r22z27h6tvur#atproto',
|
|
96
|
+
type: 'Multikey',
|
|
97
|
+
controller: 'did:plc:z72i7hdynmk6r22z27h6tvur',
|
|
98
|
+
publicKeyMultibase: 'zDnaek...',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
service: [
|
|
102
|
+
{
|
|
103
|
+
id: '#atproto_pds',
|
|
104
|
+
type: 'AtprotoPersonalDataServer',
|
|
105
|
+
serviceEndpoint: 'https://morel.us-east.host.bsky.network',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// get the user's PDS URL
|
|
111
|
+
const pds = getPdsEndpoint(doc);
|
|
112
|
+
// -> "https://morel.us-east.host.bsky.network"
|
|
113
|
+
|
|
114
|
+
// get the user's handle
|
|
115
|
+
const handle = getAtprotoHandle(doc);
|
|
116
|
+
// -> "bsky.app"
|
|
117
|
+
|
|
118
|
+
// get the signing key material
|
|
119
|
+
const key = getAtprotoVerificationMaterial(doc);
|
|
120
|
+
// -> { type: "Multikey", publicKeyMultibase: "zDnaek..." }
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### service endpoint helpers
|
|
124
|
+
|
|
125
|
+
extract specific service endpoints from DID documents:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import {
|
|
129
|
+
getPdsEndpoint,
|
|
130
|
+
getLabelerEndpoint,
|
|
131
|
+
getBlueskyChatEndpoint,
|
|
132
|
+
getBlueskyFeedgenEndpoint,
|
|
133
|
+
getBlueskyNotificationEndpoint,
|
|
134
|
+
getAtprotoServiceEndpoint,
|
|
135
|
+
} from '@atcute/identity';
|
|
136
|
+
|
|
137
|
+
// standard helpers for common services
|
|
138
|
+
const pds = getPdsEndpoint(doc); // #atproto_pds
|
|
139
|
+
const labeler = getLabelerEndpoint(doc); // #atproto_labeler
|
|
140
|
+
const chat = getBlueskyChatEndpoint(doc); // #bsky_chat
|
|
141
|
+
const feedgen = getBlueskyFeedgenEndpoint(doc); // #bsky_fg
|
|
142
|
+
const notif = getBlueskyNotificationEndpoint(doc); // #bsky_notif
|
|
143
|
+
|
|
144
|
+
// or use the generic helper for custom services
|
|
145
|
+
const custom = getAtprotoServiceEndpoint(doc, {
|
|
146
|
+
id: '#my_service',
|
|
147
|
+
type: 'MyServiceType', // optional type filter
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### validating DID documents
|
|
152
|
+
|
|
153
|
+
use the validation schemas to check if a DID document is well-formed:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { defs } from '@atcute/identity';
|
|
157
|
+
|
|
158
|
+
const result = defs.didDocument.try(unknownData);
|
|
159
|
+
if (result.ok) {
|
|
160
|
+
// result.value is a validated DidDocument
|
|
161
|
+
console.log(result.value.id);
|
|
162
|
+
} else {
|
|
163
|
+
// validation failed
|
|
164
|
+
console.error('invalid DID document');
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
the schema validates:
|
|
169
|
+
|
|
170
|
+
- required fields (`@context`, `id`)
|
|
171
|
+
- DID string format
|
|
172
|
+
- verification method structure and key formats
|
|
173
|
+
- service endpoint URLs
|
|
174
|
+
- no duplicate entries in arrays
|
|
175
|
+
|
|
176
|
+
### type definitions
|
|
177
|
+
|
|
178
|
+
the package exports TypeScript types for DID document structures:
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
import type { DidDocument, VerificationMethod, Service } from '@atcute/identity';
|
|
182
|
+
|
|
183
|
+
// DidDocument - the full DID document
|
|
184
|
+
// VerificationMethod - a verification method entry
|
|
185
|
+
// Service - a service endpoint entry
|
|
186
|
+
```
|
package/dist/did.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { AtprotoAudience, AtprotoDid, Did } from '@atcute/lexicons/syntax';
|
|
2
1
|
/**
|
|
3
2
|
* checks if it's a DID identifier that is supported by atproto
|
|
4
3
|
*/
|
|
5
|
-
export declare const isAtprotoDid: (input: string) => input is
|
|
6
|
-
export declare const isAtprotoAudience: (input: string) => input is
|
|
4
|
+
export declare const isAtprotoDid: (input: string) => input is `did:plc:${string}` | `did:web:${string}`;
|
|
5
|
+
export declare const isAtprotoAudience: (input: string) => input is `did:plc:${string}#${string}` | `did:web:${string}#${string}`;
|
|
7
6
|
/**
|
|
8
7
|
* returns the DID's method
|
|
9
8
|
*/
|
|
10
|
-
export declare const extractDidMethod: <M extends string>(did:
|
|
9
|
+
export declare const extractDidMethod: <M extends string>(did: `did:${M}:${string}`) => M;
|
|
11
10
|
//# sourceMappingURL=did.d.ts.map
|
package/dist/did.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../lib/did.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../lib/did.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,eAAO,MAAM,YAAY,uEAExB,CAAC;AAEF,eAAO,MAAM,iBAAiB,2FAY7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,gDAIjC,CAAC"}
|
package/dist/did.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPlcDid } from './methods/plc.js';
|
|
2
2
|
import { isAtprotoWebDid } from './methods/web.js';
|
|
3
|
-
const FRAGMENT_RE = /^(?:[A-Za-z0-9\-._~!$&'()
|
|
3
|
+
const FRAGMENT_RE = /^(?:[A-Za-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*$/;
|
|
4
4
|
/**
|
|
5
5
|
* checks if it's a DID identifier that is supported by atproto
|
|
6
6
|
*/
|
package/dist/did.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did.js","sourceRoot":"","sources":["../lib/did.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"did.js","sourceRoot":"","sources":["../lib/did.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,GAAG,wDAAwD,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAuB,EAAE;IAClE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAA4B,EAAE;IAC5E,mBAAmB;IACnB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACpC,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACtF,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAmB,GAAW,EAAK,EAAE;IACpE,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAClC,OAAO,MAAW,CAAC;AACpB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * as defs from './typedefs.
|
|
2
|
-
export * from './types.
|
|
3
|
-
export * from './utils.
|
|
4
|
-
export * from './did.
|
|
5
|
-
export * from './methods/key.
|
|
6
|
-
export * from './methods/plc.
|
|
7
|
-
export * from './methods/web.
|
|
1
|
+
export * as defs from './typedefs.ts';
|
|
2
|
+
export * from './types.ts';
|
|
3
|
+
export * from './utils.ts';
|
|
4
|
+
export * from './did.ts';
|
|
5
|
+
export * from './methods/key.ts';
|
|
6
|
+
export * from './methods/plc.ts';
|
|
7
|
+
export * from './methods/web.ts';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/methods/key.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Did } from '@atcute/lexicons';
|
|
2
1
|
/**
|
|
3
2
|
* checks if input is a did:key identifier
|
|
4
3
|
*/
|
|
5
|
-
export declare const isKeyDid: (input: string) => input is
|
|
4
|
+
export declare const isKeyDid: (input: string) => input is `did:key:${string}`;
|
|
6
5
|
//# sourceMappingURL=key.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../lib/methods/key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../lib/methods/key.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,QAAQ,iDAEpB,CAAC"}
|
package/dist/methods/plc.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Did } from '@atcute/lexicons/syntax';
|
|
2
1
|
/** @deprecated use `isPlcDid` instead */
|
|
3
2
|
export declare const PLC_DID_RE: RegExp;
|
|
4
3
|
/**
|
|
5
4
|
* checks if input is a did:plc identifier
|
|
6
5
|
*/
|
|
7
|
-
export declare const isPlcDid: (input: string) => input is
|
|
6
|
+
export declare const isPlcDid: (input: string) => input is `did:plc:${string}`;
|
|
8
7
|
//# sourceMappingURL=plc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plc.d.ts","sourceRoot":"","sources":["../../lib/methods/plc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plc.d.ts","sourceRoot":"","sources":["../../lib/methods/plc.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,eAAO,MAAM,UAAU,QAA6B,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,QAAQ,iDAEpB,CAAC"}
|
package/dist/methods/web.d.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import type { Did } from '@atcute/lexicons/syntax';
|
|
2
1
|
/** @deprecated use `isWebDid` instead */
|
|
3
2
|
export declare const WEB_DID_RE: RegExp;
|
|
4
3
|
/** @deprecated use `isAtprotoWebDid` instead */
|
|
5
4
|
export declare const ATPROTO_WEB_DID_RE: RegExp;
|
|
6
5
|
/**
|
|
7
6
|
* checks if input is a did:web identifier, note that you should probably use
|
|
8
|
-
* `
|
|
7
|
+
* `isAtprotoWebDid` for atproto-related cases as atproto only supports a subset
|
|
9
8
|
* of the did:web specification (namely, no custom paths)
|
|
10
9
|
*/
|
|
11
|
-
export declare const isWebDid: (input: string) => input is
|
|
10
|
+
export declare const isWebDid: (input: string) => input is `did:web:${string}`;
|
|
12
11
|
/**
|
|
13
12
|
* checks if input is a did:web identifier that is supported by atproto
|
|
14
13
|
*/
|
|
15
|
-
export declare const isAtprotoWebDid: (input: string) => input is
|
|
14
|
+
export declare const isAtprotoWebDid: (input: string) => input is `did:web:${string}`;
|
|
16
15
|
/**
|
|
17
16
|
* normalize a did:web identifier
|
|
18
17
|
*/
|
|
19
|
-
export declare const normalizeWebDid: (did:
|
|
18
|
+
export declare const normalizeWebDid: (did: `did:web:${string}`) => `did:web:${string}`;
|
|
20
19
|
/**
|
|
21
20
|
* converts did:web identifier into the DID document's URL
|
|
22
21
|
*/
|
|
23
|
-
export declare const webDidToDocumentUrl: (did:
|
|
22
|
+
export declare const webDidToDocumentUrl: (did: `did:web:${string}`) => URL;
|
|
24
23
|
//# sourceMappingURL=web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../lib/methods/web.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../lib/methods/web.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,eAAO,MAAM,UAAU,QAC4E,CAAC;AAEpG,gDAAgD;AAChD,eAAO,MAAM,kBAAkB,QAC2D,CAAC;AAE3F;;;;GAIG;AACH,eAAO,MAAM,QAAQ,iDAEpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,iDAE3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,mDAS3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,mCAgB/B,CAAC"}
|
package/dist/methods/web.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** @deprecated use `isWebDid` instead */
|
|
2
|
-
export const WEB_DID_RE = /^did:web:([a-zA-Z0-9
|
|
2
|
+
export const WEB_DID_RE = /^did:web:([a-zA-Z0-9%-]+(?:(?:\.[a-zA-Z0-9%-]+)*(?:\.[a-zA-Z]{2,}))?)?((?::[a-zA-Z0-9\-%.]+)+)?$/;
|
|
3
3
|
/** @deprecated use `isAtprotoWebDid` instead */
|
|
4
|
-
export const ATPROTO_WEB_DID_RE = /^did:web:([a-zA-Z0-9
|
|
4
|
+
export const ATPROTO_WEB_DID_RE = /^did:web:([a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*(?:\.[a-zA-Z]{2,})|localhost(?:%3[aA]\d+)?)$/;
|
|
5
5
|
/**
|
|
6
6
|
* checks if input is a did:web identifier, note that you should probably use
|
|
7
|
-
* `
|
|
7
|
+
* `isAtprotoWebDid` for atproto-related cases as atproto only supports a subset
|
|
8
8
|
* of the did:web specification (namely, no custom paths)
|
|
9
9
|
*/
|
|
10
10
|
export const isWebDid = (input) => {
|
package/dist/methods/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../lib/methods/web.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,MAAM,CAAC,MAAM,UAAU,GACtB,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../lib/methods/web.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,MAAM,CAAC,MAAM,UAAU,GACtB,kGAAkG,CAAC;AAEpG,gDAAgD;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAC9B,yFAAyF,C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AAC;QACtB,QAAQ,GAAG,uBAAuB,CAAC;IACpC,CAAC;SAAM,CAAC;QACP,QAAQ,IAAI,WAAW,CAAC;IACzB,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,IAAI,GAAG,QAAQ,EAAE,CAAC,CAAC;IAClD,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QAClC,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC"}
|
package/dist/typedefs.d.ts
CHANGED
package/dist/typedefs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AAEhC,kBAAkB;AAClB,eAAO,MAAM,WAAW,QAAa,CAAC;AACtC,kBAAkB;AAClB,eAAO,MAAM,YAAY,QAA6B,CAAC;AAEvD,eAAO,MAAM,gBAAgB,gBAEV,CAAC;AAEpB,eAAO,MAAM,cAAc,gBAEK,CAAC;AAEjC,eAAO,MAAM,eAAe,gBAEI,CAAC;AAEjC,eAAO,MAAM,SAAS,mCAA4C,CAAC;AAEnE,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,CA4BzD,CAAC;AAEJ,eAAO,MAAM,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CASpC,CAAC;AAEH,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAqF3C,CAAC"}
|
package/dist/typedefs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as v from '@badrap/valita';
|
|
2
1
|
import { isDid } from '@atcute/lexicons/syntax';
|
|
2
|
+
import * as v from '@badrap/valita';
|
|
3
3
|
import * as t from './types.js';
|
|
4
4
|
/** @deprecated */
|
|
5
5
|
export const FRAGMENT_RE = /^#[^#]+$/;
|
|
@@ -49,7 +49,7 @@ export const service = v.object({
|
|
|
49
49
|
});
|
|
50
50
|
export const didDocument = v
|
|
51
51
|
.object({
|
|
52
|
-
'@context': v.array(rfc3968UriSchema),
|
|
52
|
+
'@context': v.array(rfc3968UriSchema).optional(),
|
|
53
53
|
id: didString,
|
|
54
54
|
alsoKnownAs: v
|
|
55
55
|
.array(rfc3968UriSchema)
|
|
@@ -94,6 +94,7 @@ export const didDocument = v
|
|
|
94
94
|
const { id: did, service: services } = input;
|
|
95
95
|
if (services?.length) {
|
|
96
96
|
const len = services.length;
|
|
97
|
+
// oxlint-disable-next-line no-new-array
|
|
97
98
|
const identifiers = new Array(len);
|
|
98
99
|
for (let i = 0; i < len; i++) {
|
|
99
100
|
const service = services[i];
|
package/dist/typedefs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typedefs.js","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"typedefs.js","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AAEhC,kBAAkB;AAClB,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AACtC,kBAAkB;AAClB,MAAM,CAAC,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAA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AC,EAAE,EAAE,CAAC;gBAC5B,IAAI,EAAE,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC3B,OAAO,CAAC,CAAC,GAAG,CAAC;wBACZ,OAAO,EAAE,cAAc,EAAE,WAAW;wBACpC,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC;qBAC1B,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface Service {
|
|
|
12
12
|
serviceEndpoint: string | Record<string, string> | (string | Record<string, string>)[];
|
|
13
13
|
}
|
|
14
14
|
export interface DidDocument {
|
|
15
|
-
'@context'
|
|
15
|
+
'@context'?: string[];
|
|
16
16
|
id: Did;
|
|
17
17
|
controller?: Did | Did[];
|
|
18
18
|
alsoKnownAs?: string[];
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,GAAG,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,OAAO;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;CACvF;AAED,MAAM,WAAW,WAAW;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,GAAG,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,OAAO;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;CACvF;AAED,MAAM,WAAW,WAAW;IAC3B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,EAAE,EAAE,GAAG,CAAC;IACR,UAAU,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC1C,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IACjD,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as t from './types.js';
|
|
1
|
+
import * as t from './types.ts';
|
|
3
2
|
export interface VerificationMaterial {
|
|
4
3
|
type: string;
|
|
5
4
|
publicKeyMultibase: string;
|
|
@@ -8,10 +7,10 @@ export declare const isAtprotoServiceEndpoint: (input: string) => boolean;
|
|
|
8
7
|
export declare const getVerificationMaterial: (doc: t.DidDocument, id: `#${string}`) => VerificationMaterial | undefined;
|
|
9
8
|
export declare const getAtprotoVerificationMaterial: (doc: t.DidDocument) => VerificationMaterial | undefined;
|
|
10
9
|
export declare const getAtprotoLabelerVerificationMaterial: (doc: t.DidDocument) => VerificationMaterial | undefined;
|
|
11
|
-
export declare const getAtprotoHandle: (doc: t.DidDocument) =>
|
|
10
|
+
export declare const getAtprotoHandle: (doc: t.DidDocument) => `${string}.${string}` | null | undefined;
|
|
12
11
|
export declare const getAtprotoServiceEndpoint: (doc: t.DidDocument, predicate: {
|
|
13
12
|
id: `#${string}`;
|
|
14
|
-
type?: string;
|
|
13
|
+
type?: string | undefined;
|
|
15
14
|
}) => string | undefined;
|
|
16
15
|
export declare const getPdsEndpoint: (doc: t.DidDocument) => string | undefined;
|
|
17
16
|
export declare const getLabelerEndpoint: (doc: t.DidDocument) => string | undefined;
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../lib/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../lib/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AAEhC,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,MAAM,CAAC;CAC3B;AAID,eAAO,MAAM,wBAAwB,4BAiBpC,CAAC;AAEF,eAAO,MAAM,uBAAuB,4EAwBnC,CAAC;AAEF,eAAO,MAAM,8BAA8B,0DAE1C,CAAC;AAEF,eAAO,MAAM,qCAAqC,0DAIjD,CAAC;AAEF,eAAO,MAAM,gBAAgB,kEAyB5B,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;wBAkCrC,CAAC;AAEF,eAAO,MAAM,cAAc,4CAK1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,4CAK9B,CAAC;AAEF,eAAO,MAAM,sBAAsB,4CAKlC,CAAC;AAEF,eAAO,MAAM,yBAAyB,4CAKrC,CAAC;AAEF,eAAO,MAAM,8BAA8B,4CAK1C,CAAC"}
|
package/lib/did.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AtprotoAudience, AtprotoDid, Did } from '@atcute/lexicons/syntax';
|
|
2
2
|
|
|
3
|
-
import { isPlcDid } from './methods/plc.
|
|
4
|
-
import { isAtprotoWebDid } from './methods/web.
|
|
3
|
+
import { isPlcDid } from './methods/plc.ts';
|
|
4
|
+
import { isAtprotoWebDid } from './methods/web.ts';
|
|
5
5
|
|
|
6
|
-
const FRAGMENT_RE = /^(?:[A-Za-z0-9\-._~!$&'()
|
|
6
|
+
const FRAGMENT_RE = /^(?:[A-Za-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*$/;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* checks if it's a DID identifier that is supported by atproto
|
package/lib/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * as defs from './typedefs.
|
|
2
|
-
export * from './types.
|
|
1
|
+
export * as defs from './typedefs.ts';
|
|
2
|
+
export * from './types.ts';
|
|
3
3
|
|
|
4
|
-
export * from './utils.
|
|
4
|
+
export * from './utils.ts';
|
|
5
5
|
|
|
6
|
-
export * from './did.
|
|
7
|
-
export * from './methods/key.
|
|
8
|
-
export * from './methods/plc.
|
|
9
|
-
export * from './methods/web.
|
|
6
|
+
export * from './did.ts';
|
|
7
|
+
export * from './methods/key.ts';
|
|
8
|
+
export * from './methods/plc.ts';
|
|
9
|
+
export * from './methods/web.ts';
|
package/lib/methods/web.ts
CHANGED
|
@@ -2,15 +2,15 @@ import type { Did } from '@atcute/lexicons/syntax';
|
|
|
2
2
|
|
|
3
3
|
/** @deprecated use `isWebDid` instead */
|
|
4
4
|
export const WEB_DID_RE =
|
|
5
|
-
/^did:web:([a-zA-Z0-9
|
|
5
|
+
/^did:web:([a-zA-Z0-9%-]+(?:(?:\.[a-zA-Z0-9%-]+)*(?:\.[a-zA-Z]{2,}))?)?((?::[a-zA-Z0-9\-%.]+)+)?$/;
|
|
6
6
|
|
|
7
7
|
/** @deprecated use `isAtprotoWebDid` instead */
|
|
8
8
|
export const ATPROTO_WEB_DID_RE =
|
|
9
|
-
/^did:web:([a-zA-Z0-9
|
|
9
|
+
/^did:web:([a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*(?:\.[a-zA-Z]{2,})|localhost(?:%3[aA]\d+)?)$/;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* checks if input is a did:web identifier, note that you should probably use
|
|
13
|
-
* `
|
|
13
|
+
* `isAtprotoWebDid` for atproto-related cases as atproto only supports a subset
|
|
14
14
|
* of the did:web specification (namely, no custom paths)
|
|
15
15
|
*/
|
|
16
16
|
export const isWebDid = (input: string): input is Did<'web'> => {
|
package/lib/typedefs.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as v from '@badrap/valita';
|
|
2
|
-
|
|
3
1
|
import { isDid } from '@atcute/lexicons/syntax';
|
|
4
2
|
|
|
5
|
-
import * as
|
|
3
|
+
import * as v from '@badrap/valita';
|
|
4
|
+
|
|
5
|
+
import * as t from './types.ts';
|
|
6
6
|
|
|
7
7
|
/** @deprecated */
|
|
8
8
|
export const FRAGMENT_RE = /^#[^#]+$/;
|
|
@@ -66,7 +66,7 @@ export const service: v.Type<t.Service> = v.object({
|
|
|
66
66
|
|
|
67
67
|
export const didDocument: v.Type<t.DidDocument> = v
|
|
68
68
|
.object({
|
|
69
|
-
'@context': v.array(rfc3968UriSchema),
|
|
69
|
+
'@context': v.array(rfc3968UriSchema).optional(),
|
|
70
70
|
|
|
71
71
|
id: didString,
|
|
72
72
|
|
|
@@ -119,6 +119,8 @@ export const didDocument: v.Type<t.DidDocument> = v
|
|
|
119
119
|
|
|
120
120
|
if (services?.length) {
|
|
121
121
|
const len = services.length;
|
|
122
|
+
|
|
123
|
+
// oxlint-disable-next-line no-new-array
|
|
122
124
|
const identifiers = new Array(len);
|
|
123
125
|
|
|
124
126
|
for (let i = 0; i < len; i++) {
|
package/lib/types.ts
CHANGED
package/lib/utils.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"type": "module",
|
|
3
2
|
"name": "@atcute/identity",
|
|
4
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
5
4
|
"description": "syntax, type definitions and schemas for atproto handles, DIDs and DID documents",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"atproto",
|
|
@@ -18,20 +17,25 @@
|
|
|
18
17
|
"!lib/**/*.bench.ts",
|
|
19
18
|
"!lib/**/*.test.ts"
|
|
20
19
|
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
21
22
|
"exports": {
|
|
22
23
|
".": "./dist/index.js"
|
|
23
24
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"@types/bun": "^1.3.1"
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@badrap/valita": "^0.4.6",
|
|
30
|
-
"@atcute/lexicons": "^1.2.
|
|
30
|
+
"@atcute/lexicons": "^1.2.9"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
34
|
+
"vitest": "^4.1.0"
|
|
31
35
|
},
|
|
32
36
|
"scripts": {
|
|
33
|
-
"build": "
|
|
34
|
-
"test": "
|
|
37
|
+
"build": "tsgo --project tsconfig.build.json",
|
|
38
|
+
"test": "vitest",
|
|
35
39
|
"prepublish": "rm -rf dist; pnpm run build"
|
|
36
40
|
}
|
|
37
41
|
}
|