@learncard/types 5.18.3 → 5.20.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/src/vc.ts CHANGED
@@ -188,7 +188,7 @@ export type UnsignedVC = z.infer<typeof UnsignedVCValidator>;
188
188
  export const ProofValidator = z
189
189
  .object({
190
190
  type: z.string(),
191
- created: z.string(),
191
+ created: z.string().optional(),
192
192
  challenge: z.string().optional(),
193
193
  domain: z.string().optional(),
194
194
  nonce: z.string().optional(),
@@ -196,7 +196,19 @@ export const ProofValidator = z
196
196
  verificationMethod: z.string(),
197
197
  jws: z.string().optional(),
198
198
  })
199
- .catchall(z.any());
199
+ .catchall(z.any())
200
+ .superRefine((proof, ctx) => {
201
+ if (
202
+ proof.created === undefined &&
203
+ (proof.type !== 'DataIntegrityProof' || proof.cryptosuite !== 'ecdsa-rdfc-2019')
204
+ ) {
205
+ ctx.addIssue({
206
+ code: 'custom',
207
+ path: ['created'],
208
+ message: 'created is required for this proof suite',
209
+ });
210
+ }
211
+ });
200
212
  export type Proof = z.infer<typeof ProofValidator>;
201
213
 
202
214
  export const VCValidator = UnsignedVCValidator.extend({