Suite of AT Protocol TypeScript libraries built on web standards
21
fork

Configure Feed

Select the types of activity you want to include in your feed.

identity explicit types

+26 -5
+26 -5
common/did-doc.ts
··· 87 87 export const getServiceEndpoint = ( 88 88 doc: DidDocument, 89 89 opts: { id: string; type?: string }, 90 - ) => { 90 + ): string | undefined => { 91 91 // /!\ Hot path 92 92 93 93 const service = findItemById(doc, "service", opts.id); ··· 166 166 // Types 167 167 // -------- 168 168 169 - const verificationMethod = z.object({ 169 + const verificationMethod: VerificationMethod = z.object({ 170 170 id: z.string(), 171 171 type: z.string(), 172 172 controller: z.string(), 173 173 publicKeyMultibase: z.string().optional(), 174 174 }); 175 175 176 - const service = z.object({ 176 + type VerificationMethod = z.ZodObject<{ 177 + id: z.ZodString; 178 + type: z.ZodString; 179 + controller: z.ZodString; 180 + publicKeyMultibase: z.ZodOptional<z.ZodString>; 181 + }, z.core.$strip>; 182 + 183 + const service: Service = z.object({ 177 184 id: z.string(), 178 185 type: z.string(), 179 186 serviceEndpoint: z.union([z.string(), z.record(z.string(), z.unknown())]), 180 187 }); 181 188 182 - export const didDocument = z.object({ 189 + type Service = z.ZodObject<{ 190 + id: z.ZodString; 191 + type: z.ZodString; 192 + serviceEndpoint: z.ZodUnion< 193 + readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>] 194 + >; 195 + }, z.core.$strip>; 196 + 197 + export const didDocument: DidDocumentType = z.object({ 183 198 id: z.string(), 184 199 alsoKnownAs: z.array(z.string()).optional(), 185 200 verificationMethod: z.array(verificationMethod).optional(), 186 201 service: z.array(service).optional(), 187 202 }); 203 + type DidDocumentType = z.ZodObject<{ 204 + id: z.ZodString; 205 + alsoKnownAs: z.ZodOptional<z.ZodArray<z.ZodString>>; 206 + verificationMethod: z.ZodOptional<z.ZodArray<VerificationMethod>>; 207 + service: z.ZodOptional<z.ZodArray<Service>>; 208 + }, z.core.$strip>; 188 209 189 - export type DidDocument = z.infer<typeof didDocument>; 210 + export type DidDocument = z.infer<DidDocumentType>;