@atproto/did
Version:
DID resolution and verification library
287 lines • 14.5 kB
TypeScript
import { z } from 'zod';
import { Did } from './did.js';
/**
* Each service map MUST contain id, type, and serviceEndpoint properties.
* @see {@link https://www.w3.org/TR/did-core/#services}
*/
declare const didServiceSchema: z.ZodObject<{
id: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>]>;
type: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
serviceEndpoint: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>, "atleastone">]>;
}, "strip", z.ZodTypeAny, {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}, {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}>;
export type DidService = z.infer<typeof didServiceSchema>;
/**
* @note This schema is incomplete
* @see {@link https://www.w3.org/TR/did-core/#production-0}
*/
export declare const didDocumentSchema: z.ZodObject<{
'@context': z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"https://www.w3.org/ns/did/v1">, z.ZodEffects<z.ZodArray<z.ZodString, "atleastone">, [string, ...string[]], [string, ...string[]]>]>>;
id: z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>;
controller: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, z.ZodArray<z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, "many">]>>;
alsoKnownAs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>]>;
type: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
serviceEndpoint: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>, "atleastone">]>;
}, "strip", z.ZodTypeAny, {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}, {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}>, "many">>;
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<{
id: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>]>;
type: z.ZodString;
controller: z.ZodUnion<[z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, z.ZodArray<z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, "many">]>;
publicKeyJwk: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
publicKeyMultibase: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}, {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}>]>, "many">>;
verificationMethod: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>]>;
type: z.ZodString;
controller: z.ZodUnion<[z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, z.ZodArray<z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, "many">]>;
publicKeyJwk: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
publicKeyMultibase: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}, {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}>, "many">>;
}, "strip", z.ZodTypeAny, {
id: `did:${string}:${string}`;
controller?: `did:${string}:${string}` | `did:${string}:${string}`[] | undefined;
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
alsoKnownAs?: string[] | undefined;
service?: {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}[] | undefined;
authentication?: (string | {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
})[] | undefined;
verificationMethod?: {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}[] | undefined;
}, {
id: string;
controller?: string | string[] | undefined;
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
alsoKnownAs?: string[] | undefined;
service?: {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}[] | undefined;
authentication?: (string | {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
})[] | undefined;
verificationMethod?: {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}[] | undefined;
}>;
export type DidDocument<Method extends string = string> = z.infer<typeof didDocumentSchema> & {
id: Did<Method>;
};
export declare const didDocumentValidator: z.ZodEffects<z.ZodObject<{
'@context': z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"https://www.w3.org/ns/did/v1">, z.ZodEffects<z.ZodArray<z.ZodString, "atleastone">, [string, ...string[]], [string, ...string[]]>]>>;
id: z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>;
controller: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, z.ZodArray<z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, "many">]>>;
alsoKnownAs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>]>;
type: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
serviceEndpoint: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>, "atleastone">]>;
}, "strip", z.ZodTypeAny, {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}, {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}>, "many">>;
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<{
id: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>]>;
type: z.ZodString;
controller: z.ZodUnion<[z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, z.ZodArray<z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, "many">]>;
publicKeyJwk: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
publicKeyMultibase: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}, {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}>]>, "many">>;
verificationMethod: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>]>;
type: z.ZodString;
controller: z.ZodUnion<[z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, z.ZodArray<z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>, "many">]>;
publicKeyJwk: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
publicKeyMultibase: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}, {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}>, "many">>;
}, "strip", z.ZodTypeAny, {
id: `did:${string}:${string}`;
controller?: `did:${string}:${string}` | `did:${string}:${string}`[] | undefined;
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
alsoKnownAs?: string[] | undefined;
service?: {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}[] | undefined;
authentication?: (string | {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
})[] | undefined;
verificationMethod?: {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}[] | undefined;
}, {
id: string;
controller?: string | string[] | undefined;
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
alsoKnownAs?: string[] | undefined;
service?: {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}[] | undefined;
authentication?: (string | {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
})[] | undefined;
verificationMethod?: {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}[] | undefined;
}>, {
id: `did:${string}:${string}`;
controller?: `did:${string}:${string}` | `did:${string}:${string}`[] | undefined;
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
alsoKnownAs?: string[] | undefined;
service?: {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}[] | undefined;
authentication?: (string | {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
})[] | undefined;
verificationMethod?: {
type: string;
id: string;
controller: `did:${string}:${string}` | `did:${string}:${string}`[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}[] | undefined;
}, {
id: string;
controller?: string | string[] | undefined;
'@context'?: "https://www.w3.org/ns/did/v1" | [string, ...string[]] | undefined;
alsoKnownAs?: string[] | undefined;
service?: {
type: string | string[];
id: string;
serviceEndpoint: string | Record<string, string> | [string | Record<string, string>, ...(string | Record<string, string>)[]];
}[] | undefined;
authentication?: (string | {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
})[] | undefined;
verificationMethod?: {
type: string;
id: string;
controller: string | string[];
publicKeyJwk?: Record<string, unknown> | undefined;
publicKeyMultibase?: string | undefined;
}[] | undefined;
}>;
export {};
//# sourceMappingURL=did-document.d.ts.map