@atproto/did 0.5.0 → 0.5.1
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 +6 -0
- package/dist/atproto.js +2 -2
- package/dist/atproto.js.map +1 -1
- package/dist/did-document.d.ts +51 -51
- package/dist/did-error.d.ts.map +1 -1
- package/dist/did-error.js.map +1 -1
- package/dist/did-ref.d.ts.map +1 -1
- package/dist/methods/web.d.ts +1 -1
- package/package.json +3 -4
- package/tsconfig.build.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atproto/did
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4967](https://github.com/bluesky-social/atproto/pull/4967) [`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use TypeScript 7 to build package
|
|
8
|
+
|
|
3
9
|
## 0.5.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/atproto.js
CHANGED
|
@@ -77,8 +77,8 @@ export function extractAtprotoData(document) {
|
|
|
77
77
|
return {
|
|
78
78
|
did: document.id,
|
|
79
79
|
aka: document.alsoKnownAs?.find(isAtprotoAka)?.slice(5),
|
|
80
|
-
key: document.verificationMethod?.find(
|
|
81
|
-
pds: document.service?.find(
|
|
80
|
+
key: document.verificationMethod?.find(isAtprotoVerificationMethod, document),
|
|
81
|
+
pds: document.service?.find(isAtprotoPersonalDataServerService, document),
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
export function extractPdsUrl(document) {
|
package/dist/atproto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atproto.js","sourceRoot":"","sources":["../src/atproto.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C3C,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC;QACjC,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,CACtD,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7D,mCAAmC;IACnC,mCAAmC;IACnC,UAAU;CACF,CAAC,CAAA;AAaX,MAAM,UAAU,2BAA2B,CAIzC,MAG6D;IAE7D,OAAO,CACL,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,EAAE,kBAAkB,KAAK,QAAQ;QAC7C,iCAAwD,CAAC,QAAQ,CAChE,MAAM,CAAC,IAAI,CACZ;QACD,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CACjD,CAAA;AACH,CAAC;AAOD,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC1C,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACzD,CAAC","sourcesContent":["import { z } from 'zod'\nimport { DidDocument, DidService } from './did-document.js'\nimport { DidError, InvalidDidError } from './did-error.js'\nimport { DidRefAbsolute, isDidRefAbsolute } from './did-ref.js'\nimport { Did } from './did.js'\nimport { canParse } from './lib/uri.js'\nimport {\n DID_PLC_PREFIX,\n DID_WEB_PREFIX,\n assertDidPlc,\n assertDidWeb,\n isDidPlc,\n isDidWeb,\n} from './methods.js'\nimport { Identifier, matchesIdentifier } from './utils.js'\n\n// This file contains atproto-specific DID validation utilities.\n\nexport type AtprotoIdentityDidMethods = 'plc' | 'web'\nexport type AtprotoDid = Did<AtprotoIdentityDidMethods>\nexport type AtprotoDidDocument = DidDocument<AtprotoIdentityDidMethods>\n\nexport const atprotoDidSchema = z\n .string()\n .refine(isAtprotoDid, `Atproto only allows \"plc\" and \"web\" DID methods`)\n\nexport function isAtprotoDid(input: unknown): input is AtprotoDid {\n return isDidPlc(input) || isAtprotoDidWeb(input)\n}\n\nexport function asAtprotoDid<T>(input: T) {\n assertAtprotoDid(input)\n return input\n}\n\nexport function assertAtprotoDid(input: unknown): asserts input is AtprotoDid {\n if (typeof input !== 'string') {\n throw new InvalidDidError(typeof input, `DID must be a string`)\n } else if (input.startsWith(DID_PLC_PREFIX)) {\n assertDidPlc(input)\n } else if (input.startsWith(DID_WEB_PREFIX)) {\n assertAtprotoDidWeb(input)\n } else {\n throw new InvalidDidError(\n input,\n `Atproto only allows \"plc\" and \"web\" DID methods`,\n )\n }\n}\n\nexport function assertAtprotoDidWeb(\n input: unknown,\n): asserts input is Did<'web'> {\n assertDidWeb(input)\n\n if (isDidWebWithPath(input)) {\n throw new InvalidDidError(\n input,\n `Atproto does not allow path components in Web DIDs`,\n )\n }\n\n if (isDidWebWithHttpsPort(input)) {\n throw new InvalidDidError(\n input,\n `Atproto does not allow port numbers in Web DIDs, except for localhost`,\n )\n }\n}\n\n/**\n * @see {@link https://atproto.com/specs/did#blessed-did-methods}\n */\nexport function isAtprotoDidWeb(input: unknown): input is Did<'web'> {\n if (!isDidWeb(input)) {\n return false\n }\n\n if (isDidWebWithPath(input)) {\n return false\n }\n\n if (isDidWebWithHttpsPort(input)) {\n return false\n }\n\n return true\n}\n\nfunction isDidWebWithPath(did: Did<'web'>): boolean {\n return did.includes(':', DID_WEB_PREFIX.length)\n}\n\nfunction isLocalhostDid(did: Did<'web'>): boolean {\n return (\n did === 'did:web:localhost' ||\n did.startsWith('did:web:localhost:') ||\n did.startsWith('did:web:localhost%3A')\n )\n}\n\nfunction isDidWebWithHttpsPort(did: Did<'web'>): boolean {\n if (isLocalhostDid(did)) return false\n\n const pathIdx = did.indexOf(':', DID_WEB_PREFIX.length)\n\n const hasPort =\n pathIdx === -1\n ? // No path component, check if there's a port separator anywhere after\n // the \"did:web:\" prefix\n did.includes('%3A', DID_WEB_PREFIX.length)\n : // There is a path component; if there is an encoded colon *before* it,\n // then there is a port number\n did.lastIndexOf('%3A', pathIdx) !== -1\n\n return hasPort\n}\n\nexport type AtprotoData<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n> = {\n did: Did<M>\n aka?: string\n key?: AtprotoVerificationMethod<M>\n pds?: AtprotoPersonalDataServerService<M>\n}\n\nexport function extractAtprotoData<M extends AtprotoIdentityDidMethods>(\n document: DidDocument<M>,\n): AtprotoData<M> {\n return {\n did: document.id,\n aka: document.alsoKnownAs?.find(isAtprotoAka)?.slice(5),\n key: document.verificationMethod?.find(\n isAtprotoVerificationMethod<M>,\n document,\n ),\n pds: document.service?.find(\n isAtprotoPersonalDataServerService<M>,\n document,\n ),\n }\n}\n\nexport function extractPdsUrl(document: AtprotoDidDocument): URL {\n const service = document.service?.find(\n isAtprotoPersonalDataServerService,\n document,\n )\n\n if (!service) {\n throw new DidError(\n document.id,\n `Document ${document.id} does not contain a (valid) #atproto_pds service URL`,\n 'did-service-not-found',\n )\n }\n\n return new URL(service.serviceEndpoint)\n}\n\nexport type AtprotoAka = `at://${string}`\nexport function isAtprotoAka(value: string): value is AtprotoAka {\n return value.startsWith('at://')\n}\n\nexport type AtprotoPersonalDataServerService<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n> = DidService & {\n id: Identifier<Did<M>, 'atproto_pds'>\n type: 'AtprotoPersonalDataServer'\n serviceEndpoint: string\n}\n\nexport function isAtprotoPersonalDataServerService<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n>(\n this: DidDocument<M>,\n service: null | undefined | DidService,\n): service is AtprotoPersonalDataServerService<M> {\n return (\n service?.type === 'AtprotoPersonalDataServer' &&\n typeof service.serviceEndpoint === 'string' &&\n canParse(service.serviceEndpoint) &&\n matchesIdentifier(this.id, 'atproto_pds', service.id)\n )\n}\n\nexport const ATPROTO_VERIFICATION_METHOD_TYPES = Object.freeze([\n 'EcdsaSecp256r1VerificationKey2019',\n 'EcdsaSecp256k1VerificationKey2019',\n 'Multikey',\n] as const)\nexport type SupportedAtprotoVerificationMethodType =\n (typeof ATPROTO_VERIFICATION_METHOD_TYPES)[number]\n\ntype VerificationMethod = NonNullable<DidDocument['verificationMethod']>[number]\nexport type AtprotoVerificationMethod<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n> = Extract<VerificationMethod, object> & {\n id: Identifier<Did<M>, 'atproto'>\n type: SupportedAtprotoVerificationMethodType\n publicKeyMultibase: string\n}\n\nexport function isAtprotoVerificationMethod<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n>(\n this: DidDocument<M>,\n method:\n | null\n | undefined\n | NonNullable<DidDocument<M>['verificationMethod']>[number],\n): method is AtprotoVerificationMethod<M> {\n return (\n typeof method === 'object' &&\n typeof method?.publicKeyMultibase === 'string' &&\n (ATPROTO_VERIFICATION_METHOD_TYPES as readonly unknown[]).includes(\n method.type,\n ) &&\n matchesIdentifier(this.id, 'atproto', method.id)\n )\n}\n\n/**\n * An atproto-constrained absolute DID reference: `${AtprotoDid}#${fragment}`.\n */\nexport type AtprotoDidRefAbsolute = DidRefAbsolute<AtprotoIdentityDidMethods>\n\nexport function isAtprotoDidRefAbsolute(\n value: unknown,\n): value is AtprotoDidRefAbsolute {\n if (!isDidRefAbsolute(value)) return false\n return isAtprotoDid(value.slice(0, value.indexOf('#')))\n}\n"]}
|
|
1
|
+
{"version":3,"file":"atproto.js","sourceRoot":"","sources":["../src/atproto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAkB,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAA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AC,CAAA;AAaX,MAAM,UAAU,2BAA2B,CAIzC,MAG6D;IAE7D,OAAO,CACL,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,EAAE,kBAAkB,KAAK,QAAQ;QAC7C,iCAAwD,CAAC,QAAQ,CAChE,MAAM,CAAC,IAAI,CACZ;QACD,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CACjD,CAAA;AACH,CAAC;AAOD,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC1C,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACzD,CAAC","sourcesContent":["import { z } from 'zod'\nimport { DidDocument, DidService } from './did-document.js'\nimport { DidError, InvalidDidError } from './did-error.js'\nimport { DidRefAbsolute, isDidRefAbsolute } from './did-ref.js'\nimport { Did } from './did.js'\nimport { canParse } from './lib/uri.js'\nimport {\n DID_PLC_PREFIX,\n DID_WEB_PREFIX,\n assertDidPlc,\n assertDidWeb,\n isDidPlc,\n isDidWeb,\n} from './methods.js'\nimport { Identifier, matchesIdentifier } from './utils.js'\n\n// This file contains atproto-specific DID validation utilities.\n\nexport type AtprotoIdentityDidMethods = 'plc' | 'web'\nexport type AtprotoDid = Did<AtprotoIdentityDidMethods>\nexport type AtprotoDidDocument = DidDocument<AtprotoIdentityDidMethods>\n\nexport const atprotoDidSchema = z\n .string()\n .refine(isAtprotoDid, `Atproto only allows \"plc\" and \"web\" DID methods`)\n\nexport function isAtprotoDid(input: unknown): input is AtprotoDid {\n return isDidPlc(input) || isAtprotoDidWeb(input)\n}\n\nexport function asAtprotoDid<T>(input: T) {\n assertAtprotoDid(input)\n return input\n}\n\nexport function assertAtprotoDid(input: unknown): asserts input is AtprotoDid {\n if (typeof input !== 'string') {\n throw new InvalidDidError(typeof input, `DID must be a string`)\n } else if (input.startsWith(DID_PLC_PREFIX)) {\n assertDidPlc(input)\n } else if (input.startsWith(DID_WEB_PREFIX)) {\n assertAtprotoDidWeb(input)\n } else {\n throw new InvalidDidError(\n input,\n `Atproto only allows \"plc\" and \"web\" DID methods`,\n )\n }\n}\n\nexport function assertAtprotoDidWeb(\n input: unknown,\n): asserts input is Did<'web'> {\n assertDidWeb(input)\n\n if (isDidWebWithPath(input)) {\n throw new InvalidDidError(\n input,\n `Atproto does not allow path components in Web DIDs`,\n )\n }\n\n if (isDidWebWithHttpsPort(input)) {\n throw new InvalidDidError(\n input,\n `Atproto does not allow port numbers in Web DIDs, except for localhost`,\n )\n }\n}\n\n/**\n * @see {@link https://atproto.com/specs/did#blessed-did-methods}\n */\nexport function isAtprotoDidWeb(input: unknown): input is Did<'web'> {\n if (!isDidWeb(input)) {\n return false\n }\n\n if (isDidWebWithPath(input)) {\n return false\n }\n\n if (isDidWebWithHttpsPort(input)) {\n return false\n }\n\n return true\n}\n\nfunction isDidWebWithPath(did: Did<'web'>): boolean {\n return did.includes(':', DID_WEB_PREFIX.length)\n}\n\nfunction isLocalhostDid(did: Did<'web'>): boolean {\n return (\n did === 'did:web:localhost' ||\n did.startsWith('did:web:localhost:') ||\n did.startsWith('did:web:localhost%3A')\n )\n}\n\nfunction isDidWebWithHttpsPort(did: Did<'web'>): boolean {\n if (isLocalhostDid(did)) return false\n\n const pathIdx = did.indexOf(':', DID_WEB_PREFIX.length)\n\n const hasPort =\n pathIdx === -1\n ? // No path component, check if there's a port separator anywhere after\n // the \"did:web:\" prefix\n did.includes('%3A', DID_WEB_PREFIX.length)\n : // There is a path component; if there is an encoded colon *before* it,\n // then there is a port number\n did.lastIndexOf('%3A', pathIdx) !== -1\n\n return hasPort\n}\n\nexport type AtprotoData<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n> = {\n did: Did<M>\n aka?: string\n key?: AtprotoVerificationMethod<M>\n pds?: AtprotoPersonalDataServerService<M>\n}\n\nexport function extractAtprotoData<M extends AtprotoIdentityDidMethods>(\n document: DidDocument<M>,\n): AtprotoData<M> {\n return {\n did: document.id,\n aka: document.alsoKnownAs?.find(isAtprotoAka)?.slice(5),\n key: document.verificationMethod?.find(\n isAtprotoVerificationMethod<M>,\n document,\n ),\n pds: document.service?.find(\n isAtprotoPersonalDataServerService<M>,\n document,\n ),\n }\n}\n\nexport function extractPdsUrl(document: AtprotoDidDocument): URL {\n const service = document.service?.find(\n isAtprotoPersonalDataServerService,\n document,\n )\n\n if (!service) {\n throw new DidError(\n document.id,\n `Document ${document.id} does not contain a (valid) #atproto_pds service URL`,\n 'did-service-not-found',\n )\n }\n\n return new URL(service.serviceEndpoint)\n}\n\nexport type AtprotoAka = `at://${string}`\nexport function isAtprotoAka(value: string): value is AtprotoAka {\n return value.startsWith('at://')\n}\n\nexport type AtprotoPersonalDataServerService<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n> = DidService & {\n id: Identifier<Did<M>, 'atproto_pds'>\n type: 'AtprotoPersonalDataServer'\n serviceEndpoint: string\n}\n\nexport function isAtprotoPersonalDataServerService<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n>(\n this: DidDocument<M>,\n service: null | undefined | DidService,\n): service is AtprotoPersonalDataServerService<M> {\n return (\n service?.type === 'AtprotoPersonalDataServer' &&\n typeof service.serviceEndpoint === 'string' &&\n canParse(service.serviceEndpoint) &&\n matchesIdentifier(this.id, 'atproto_pds', service.id)\n )\n}\n\nexport const ATPROTO_VERIFICATION_METHOD_TYPES = Object.freeze([\n 'EcdsaSecp256r1VerificationKey2019',\n 'EcdsaSecp256k1VerificationKey2019',\n 'Multikey',\n] as const)\nexport type SupportedAtprotoVerificationMethodType =\n (typeof ATPROTO_VERIFICATION_METHOD_TYPES)[number]\n\ntype VerificationMethod = NonNullable<DidDocument['verificationMethod']>[number]\nexport type AtprotoVerificationMethod<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n> = Extract<VerificationMethod, object> & {\n id: Identifier<Did<M>, 'atproto'>\n type: SupportedAtprotoVerificationMethodType\n publicKeyMultibase: string\n}\n\nexport function isAtprotoVerificationMethod<\n M extends AtprotoIdentityDidMethods = AtprotoIdentityDidMethods,\n>(\n this: DidDocument<M>,\n method:\n | null\n | undefined\n | NonNullable<DidDocument<M>['verificationMethod']>[number],\n): method is AtprotoVerificationMethod<M> {\n return (\n typeof method === 'object' &&\n typeof method?.publicKeyMultibase === 'string' &&\n (ATPROTO_VERIFICATION_METHOD_TYPES as readonly unknown[]).includes(\n method.type,\n ) &&\n matchesIdentifier(this.id, 'atproto', method.id)\n )\n}\n\n/**\n * An atproto-constrained absolute DID reference: `${AtprotoDid}#${fragment}`.\n */\nexport type AtprotoDidRefAbsolute = DidRefAbsolute<AtprotoIdentityDidMethods>\n\nexport function isAtprotoDidRefAbsolute(\n value: unknown,\n): value is AtprotoDidRefAbsolute {\n if (!isDidRefAbsolute(value)) return false\n return isAtprotoDid(value.slice(0, value.indexOf('#')))\n}\n"]}
|
package/dist/did-document.d.ts
CHANGED
|
@@ -9,12 +9,12 @@ declare const didServiceSchema: z.ZodObject<{
|
|
|
9
9
|
type: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
10
10
|
serviceEndpoint: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>, "atleastone">]>;
|
|
11
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
type: string | string[];
|
|
13
12
|
id: string;
|
|
13
|
+
type: string | string[];
|
|
14
14
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
15
15
|
}, {
|
|
16
|
-
type: string | string[];
|
|
17
16
|
id: string;
|
|
17
|
+
type: string | string[];
|
|
18
18
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
19
19
|
}>;
|
|
20
20
|
export type DidService = z.infer<typeof didServiceSchema>;
|
|
@@ -32,12 +32,12 @@ export declare const didDocumentSchema: z.ZodObject<{
|
|
|
32
32
|
type: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
33
33
|
serviceEndpoint: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>, "atleastone">]>;
|
|
34
34
|
}, "strip", z.ZodTypeAny, {
|
|
35
|
-
type: string | string[];
|
|
36
35
|
id: string;
|
|
36
|
+
type: string | string[];
|
|
37
37
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
38
38
|
}, {
|
|
39
|
-
type: string | string[];
|
|
40
39
|
id: string;
|
|
40
|
+
type: string | string[];
|
|
41
41
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
42
42
|
}>, "many">>;
|
|
43
43
|
authentication: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>]>, z.ZodObject<{
|
|
@@ -47,14 +47,14 @@ export declare const didDocumentSchema: z.ZodObject<{
|
|
|
47
47
|
publicKeyJwk: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
48
48
|
publicKeyMultibase: z.ZodOptional<z.ZodString>;
|
|
49
49
|
}, "strip", z.ZodTypeAny, {
|
|
50
|
-
type: string;
|
|
51
50
|
id: string;
|
|
52
|
-
|
|
51
|
+
type: string;
|
|
52
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
53
53
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
54
54
|
publicKeyMultibase?: string | undefined;
|
|
55
55
|
}, {
|
|
56
|
-
type: string;
|
|
57
56
|
id: string;
|
|
57
|
+
type: string;
|
|
58
58
|
controller: string | string[];
|
|
59
59
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
60
60
|
publicKeyMultibase?: string | undefined;
|
|
@@ -66,62 +66,62 @@ export declare const didDocumentSchema: z.ZodObject<{
|
|
|
66
66
|
publicKeyJwk: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
67
67
|
publicKeyMultibase: z.ZodOptional<z.ZodString>;
|
|
68
68
|
}, "strip", z.ZodTypeAny, {
|
|
69
|
-
type: string;
|
|
70
69
|
id: string;
|
|
71
|
-
|
|
70
|
+
type: string;
|
|
71
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
72
72
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
73
73
|
publicKeyMultibase?: string | undefined;
|
|
74
74
|
}, {
|
|
75
|
-
type: string;
|
|
76
75
|
id: string;
|
|
76
|
+
type: string;
|
|
77
77
|
controller: string | string[];
|
|
78
78
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
79
79
|
publicKeyMultibase?: string | undefined;
|
|
80
80
|
}>, "many">>;
|
|
81
81
|
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
id: `did:${string}:${string}`;
|
|
83
|
-
controller?: `did:${string}:${string}` | `did:${string}:${string}`[] | undefined;
|
|
84
82
|
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
|
|
83
|
+
id: `did:${string}:${string}`;
|
|
84
|
+
controller?: `did:${string}:${string}`[] | `did:${string}:${string}` | undefined;
|
|
85
85
|
alsoKnownAs?: string[] | undefined;
|
|
86
86
|
service?: {
|
|
87
|
-
type: string | string[];
|
|
88
87
|
id: string;
|
|
88
|
+
type: string | string[];
|
|
89
89
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
90
90
|
}[] | undefined;
|
|
91
91
|
authentication?: (string | {
|
|
92
|
-
type: string;
|
|
93
92
|
id: string;
|
|
94
|
-
|
|
93
|
+
type: string;
|
|
94
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
95
95
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
96
96
|
publicKeyMultibase?: string | undefined;
|
|
97
97
|
})[] | undefined;
|
|
98
98
|
verificationMethod?: {
|
|
99
|
-
type: string;
|
|
100
99
|
id: string;
|
|
101
|
-
|
|
100
|
+
type: string;
|
|
101
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
102
102
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
103
103
|
publicKeyMultibase?: string | undefined;
|
|
104
104
|
}[] | undefined;
|
|
105
105
|
}, {
|
|
106
|
+
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
|
|
106
107
|
id: string;
|
|
107
108
|
controller?: string | string[] | undefined;
|
|
108
|
-
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
|
|
109
109
|
alsoKnownAs?: string[] | undefined;
|
|
110
110
|
service?: {
|
|
111
|
-
type: string | string[];
|
|
112
111
|
id: string;
|
|
112
|
+
type: string | string[];
|
|
113
113
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
114
114
|
}[] | undefined;
|
|
115
115
|
authentication?: (string | {
|
|
116
|
-
type: string;
|
|
117
116
|
id: string;
|
|
117
|
+
type: string;
|
|
118
118
|
controller: string | string[];
|
|
119
119
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
120
120
|
publicKeyMultibase?: string | undefined;
|
|
121
121
|
})[] | undefined;
|
|
122
122
|
verificationMethod?: {
|
|
123
|
-
type: string;
|
|
124
123
|
id: string;
|
|
124
|
+
type: string;
|
|
125
125
|
controller: string | string[];
|
|
126
126
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
127
127
|
publicKeyMultibase?: string | undefined;
|
|
@@ -140,12 +140,12 @@ export declare const didDocumentValidator: z.ZodEffects<z.ZodObject<{
|
|
|
140
140
|
type: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
141
141
|
serviceEndpoint: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>, "atleastone">]>;
|
|
142
142
|
}, "strip", z.ZodTypeAny, {
|
|
143
|
-
type: string | string[];
|
|
144
143
|
id: string;
|
|
144
|
+
type: string | string[];
|
|
145
145
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
146
146
|
}, {
|
|
147
|
-
type: string | string[];
|
|
148
147
|
id: string;
|
|
148
|
+
type: string | string[];
|
|
149
149
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
150
150
|
}>, "many">>;
|
|
151
151
|
authentication: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>]>, z.ZodObject<{
|
|
@@ -155,14 +155,14 @@ export declare const didDocumentValidator: z.ZodEffects<z.ZodObject<{
|
|
|
155
155
|
publicKeyJwk: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
156
156
|
publicKeyMultibase: z.ZodOptional<z.ZodString>;
|
|
157
157
|
}, "strip", z.ZodTypeAny, {
|
|
158
|
-
type: string;
|
|
159
158
|
id: string;
|
|
160
|
-
|
|
159
|
+
type: string;
|
|
160
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
161
161
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
162
162
|
publicKeyMultibase?: string | undefined;
|
|
163
163
|
}, {
|
|
164
|
-
type: string;
|
|
165
164
|
id: string;
|
|
165
|
+
type: string;
|
|
166
166
|
controller: string | string[];
|
|
167
167
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
168
168
|
publicKeyMultibase?: string | undefined;
|
|
@@ -174,110 +174,110 @@ export declare const didDocumentValidator: z.ZodEffects<z.ZodObject<{
|
|
|
174
174
|
publicKeyJwk: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
175
175
|
publicKeyMultibase: z.ZodOptional<z.ZodString>;
|
|
176
176
|
}, "strip", z.ZodTypeAny, {
|
|
177
|
-
type: string;
|
|
178
177
|
id: string;
|
|
179
|
-
|
|
178
|
+
type: string;
|
|
179
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
180
180
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
181
181
|
publicKeyMultibase?: string | undefined;
|
|
182
182
|
}, {
|
|
183
|
-
type: string;
|
|
184
183
|
id: string;
|
|
184
|
+
type: string;
|
|
185
185
|
controller: string | string[];
|
|
186
186
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
187
187
|
publicKeyMultibase?: string | undefined;
|
|
188
188
|
}>, "many">>;
|
|
189
189
|
}, "strip", z.ZodTypeAny, {
|
|
190
|
-
id: `did:${string}:${string}`;
|
|
191
|
-
controller?: `did:${string}:${string}` | `did:${string}:${string}`[] | undefined;
|
|
192
190
|
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
|
|
191
|
+
id: `did:${string}:${string}`;
|
|
192
|
+
controller?: `did:${string}:${string}`[] | `did:${string}:${string}` | undefined;
|
|
193
193
|
alsoKnownAs?: string[] | undefined;
|
|
194
194
|
service?: {
|
|
195
|
-
type: string | string[];
|
|
196
195
|
id: string;
|
|
196
|
+
type: string | string[];
|
|
197
197
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
198
198
|
}[] | undefined;
|
|
199
199
|
authentication?: (string | {
|
|
200
|
-
type: string;
|
|
201
200
|
id: string;
|
|
202
|
-
|
|
201
|
+
type: string;
|
|
202
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
203
203
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
204
204
|
publicKeyMultibase?: string | undefined;
|
|
205
205
|
})[] | undefined;
|
|
206
206
|
verificationMethod?: {
|
|
207
|
-
type: string;
|
|
208
207
|
id: string;
|
|
209
|
-
|
|
208
|
+
type: string;
|
|
209
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
210
210
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
211
211
|
publicKeyMultibase?: string | undefined;
|
|
212
212
|
}[] | undefined;
|
|
213
213
|
}, {
|
|
214
|
+
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
|
|
214
215
|
id: string;
|
|
215
216
|
controller?: string | string[] | undefined;
|
|
216
|
-
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
|
|
217
217
|
alsoKnownAs?: string[] | undefined;
|
|
218
218
|
service?: {
|
|
219
|
-
type: string | string[];
|
|
220
219
|
id: string;
|
|
220
|
+
type: string | string[];
|
|
221
221
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
222
222
|
}[] | undefined;
|
|
223
223
|
authentication?: (string | {
|
|
224
|
-
type: string;
|
|
225
224
|
id: string;
|
|
225
|
+
type: string;
|
|
226
226
|
controller: string | string[];
|
|
227
227
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
228
228
|
publicKeyMultibase?: string | undefined;
|
|
229
229
|
})[] | undefined;
|
|
230
230
|
verificationMethod?: {
|
|
231
|
-
type: string;
|
|
232
231
|
id: string;
|
|
232
|
+
type: string;
|
|
233
233
|
controller: string | string[];
|
|
234
234
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
235
235
|
publicKeyMultibase?: string | undefined;
|
|
236
236
|
}[] | undefined;
|
|
237
237
|
}>, {
|
|
238
|
-
id: `did:${string}:${string}`;
|
|
239
|
-
controller?: `did:${string}:${string}` | `did:${string}:${string}`[] | undefined;
|
|
240
238
|
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
|
|
239
|
+
id: `did:${string}:${string}`;
|
|
240
|
+
controller?: `did:${string}:${string}`[] | `did:${string}:${string}` | undefined;
|
|
241
241
|
alsoKnownAs?: string[] | undefined;
|
|
242
242
|
service?: {
|
|
243
|
-
type: string | string[];
|
|
244
243
|
id: string;
|
|
244
|
+
type: string | string[];
|
|
245
245
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
246
246
|
}[] | undefined;
|
|
247
247
|
authentication?: (string | {
|
|
248
|
-
type: string;
|
|
249
248
|
id: string;
|
|
250
|
-
|
|
249
|
+
type: string;
|
|
250
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
251
251
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
252
252
|
publicKeyMultibase?: string | undefined;
|
|
253
253
|
})[] | undefined;
|
|
254
254
|
verificationMethod?: {
|
|
255
|
-
type: string;
|
|
256
255
|
id: string;
|
|
257
|
-
|
|
256
|
+
type: string;
|
|
257
|
+
controller: `did:${string}:${string}`[] | `did:${string}:${string}`;
|
|
258
258
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
259
259
|
publicKeyMultibase?: string | undefined;
|
|
260
260
|
}[] | undefined;
|
|
261
261
|
}, {
|
|
262
|
+
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
|
|
262
263
|
id: string;
|
|
263
264
|
controller?: string | string[] | undefined;
|
|
264
|
-
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
|
|
265
265
|
alsoKnownAs?: string[] | undefined;
|
|
266
266
|
service?: {
|
|
267
|
-
type: string | string[];
|
|
268
267
|
id: string;
|
|
268
|
+
type: string | string[];
|
|
269
269
|
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
|
|
270
270
|
}[] | undefined;
|
|
271
271
|
authentication?: (string | {
|
|
272
|
-
type: string;
|
|
273
272
|
id: string;
|
|
273
|
+
type: string;
|
|
274
274
|
controller: string | string[];
|
|
275
275
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
276
276
|
publicKeyMultibase?: string | undefined;
|
|
277
277
|
})[] | undefined;
|
|
278
278
|
verificationMethod?: {
|
|
279
|
-
type: string;
|
|
280
279
|
id: string;
|
|
280
|
+
type: string;
|
|
281
281
|
controller: string | string[];
|
|
282
282
|
publicKeyJwk?: Record<string, unknown> | undefined;
|
|
283
283
|
publicKeyMultibase?: string | undefined;
|
package/dist/did-error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-error.d.ts","sourceRoot":"","sources":["../src/did-error.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;aAEf,GAAG,EAAE,MAAM;aAEX,IAAI,EAAE,MAAM;aACZ,MAAM;
|
|
1
|
+
{"version":3,"file":"did-error.d.ts","sourceRoot":"","sources":["../src/did-error.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;aAEf,GAAG,EAAE,MAAM;aAEX,IAAI,EAAE,MAAM;aACZ,MAAM;IAJxB,YACkB,GAAG,EAAE,MAAM,EAC3B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,MAAM,SAAM,EAC5B,KAAK,CAAC,EAAE,OAAO,EAGhB;IAED;;OAEG;IACH,IAAI,UAAU,WAEb;IAEQ,QAAQ,WAEhB;IAED,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAmBjD;CACF;AAED,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAExD;CACF"}
|
package/dist/did-error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-error.js","sourceRoot":"","sources":["../src/did-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,YACkB,GAAW,EAC3B,OAAe,EACC,IAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"did-error.js","sourceRoot":"","sources":["../src/did-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,YACkB,GAAW,EAC3B,OAAe,EACC,IAAY,EACZ,MAAM,GAAG,GAAG,EAC5B,KAAe;QAEf,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;mBANT,GAAG;oBAEH,IAAI;sBACJ,MAAM;IAIxB,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAEQ,QAAQ;QACf,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;IAC/E,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,KAAc,EAAE,GAAW;QACrC,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,OAAO,GACX,KAAK,YAAY,KAAK;YACpB,CAAC,CAAC,KAAK,CAAC,OAAO;YACf,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ;gBACzB,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,2BAA2B,CAAA;QAEnC,MAAM,MAAM,GACV,CAAC,OAAO,KAAK,EAAE,CAAC,YAAY,CAAC,KAAK,QAAQ;YACxC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;YACrB,CAAC,CAAC,SAAS,CAAC;YACd,CAAC,OAAO,KAAK,EAAE,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QAEvE,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;IACvE,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,GAAW,EAAE,OAAe,EAAE,KAAe;QACvD,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IAChD,CAAC;CACF","sourcesContent":["export class DidError extends Error {\n constructor(\n public readonly did: string,\n message: string,\n public readonly code: string,\n public readonly status = 400,\n cause?: unknown,\n ) {\n super(message, { cause })\n }\n\n /**\n * For compatibility with error handlers in common HTTP frameworks.\n */\n get statusCode() {\n return this.status\n }\n\n override toString() {\n return `${this.constructor.name} ${this.code} (${this.did}): ${this.message}`\n }\n\n static from(cause: unknown, did: string): DidError {\n if (cause instanceof DidError) {\n return cause\n }\n\n const message =\n cause instanceof Error\n ? cause.message\n : typeof cause === 'string'\n ? cause\n : 'An unknown error occurred'\n\n const status =\n (typeof cause?.['statusCode'] === 'number'\n ? cause['statusCode']\n : undefined) ??\n (typeof cause?.['status'] === 'number' ? cause['status'] : undefined)\n\n return new DidError(did, message, 'did-unknown-error', status, cause)\n }\n}\n\nexport class InvalidDidError extends DidError {\n constructor(did: string, message: string, cause?: unknown) {\n super(did, message, 'did-invalid', 400, cause)\n }\n}\n"]}
|
package/dist/did-ref.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-ref.d.ts","sourceRoot":"","sources":["../src/did-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAS,MAAM,UAAU,CAAA;AAGrC;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAA;AAE7E,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"did-ref.d.ts","sourceRoot":"","sources":["../src/did-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAS,MAAM,UAAU,CAAA;AAGrC;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAA;AAE7E,eAAO,MAAM,gBAAgB,UAAW,OAAO,KAAG,KAAK,IAAI,cAO1D,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,IAAI,CAAC,EAAE,CAAA;AAE/D,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACxD,KAAK,EAAE,OAAO,EACd,EAAE,CAAC,EAAE,CAAC,GACL,KAAK,IAAI,cAAc,CAAC,CAAC,CAAC,CAQ5B"}
|
package/dist/methods/web.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function isDidWeb(input: unknown): input is Did<'web'>;
|
|
|
7
7
|
export declare function asDidWeb<T>(input: T): T & `did:web:${string}`;
|
|
8
8
|
export declare function assertDidWeb(input: unknown): asserts input is Did<'web'>;
|
|
9
9
|
export declare function didWebToUrl(did: Did<'web'>): URL & {
|
|
10
|
-
protocol:
|
|
10
|
+
protocol: 'http:' | 'https:';
|
|
11
11
|
};
|
|
12
12
|
export declare function urlToDidWeb(url: URL): Did<'web'>;
|
|
13
13
|
export declare function buildDidWebUrl(did: Did<'web'>): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/did",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22"
|
|
6
6
|
},
|
|
@@ -30,11 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@swc/jest": "^0.2.24",
|
|
33
|
-
"jest": "^30.0.0"
|
|
34
|
-
"typescript": "^6.0.3"
|
|
33
|
+
"jest": "^30.0.0"
|
|
35
34
|
},
|
|
36
35
|
"scripts": {
|
|
37
|
-
"build": "
|
|
36
|
+
"build": "tsgo --build tsconfig.build.json",
|
|
38
37
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
|
|
39
38
|
}
|
|
40
39
|
}
|
package/tsconfig.build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/atproto.ts","./src/did-document.ts","./src/did-error.ts","./src/did-ref.ts","./src/did.ts","./src/index.ts","./src/methods.ts","./src/utils.ts","./src/lib/uri.ts","./src/methods/plc.ts","./src/methods/web.ts"]
|
|
1
|
+
{"version":"7.0.0-dev.20260614.1","root":["./src/atproto.ts","./src/did-document.ts","./src/did-error.ts","./src/did-ref.ts","./src/did.ts","./src/index.ts","./src/methods.ts","./src/utils.ts","./src/lib/uri.ts","./src/methods/plc.ts","./src/methods/web.ts"]}
|
package/tsconfig.json
CHANGED