generated from Open-Attestation/react-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
types.ts
34 lines (29 loc) · 972 Bytes
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Literal, Record, String } from "runtypes";
import { CodedError } from "@govtechsg/oa-verify";
export type VerificationStatus = "PENDING" | "VERIFIED" | "REJECTED";
export const EncryptionDocumentRecord = Record({
cipherText: String,
iv: String,
tag: String,
type: String,
key: String.optional(),
});
// https://github.com/Open-Attestation/adr/blob/master/universal_actions.md
export const ActionUrlQueryRecord = Record({
type: Literal("DOCUMENT").optional(),
payload: Record({
uri: String,
key: String.optional(),
}),
});
// https://github.com/Open-Attestation/adr/blob/master/universal_actions.md
export const ActionUrlAnchorRecord = Record({
key: String,
}).optional();
/**
* Type guard for CodedError from oa-verify
* @param e
* @returns
*/
export const isVerifyCodedError = (e: any): e is CodedError =>
typeof e.message === "string" && typeof e.code === "number" && typeof e.codeString === "string" && e instanceof Error;