forked from cloudflare/privacypass-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
38 lines (32 loc) · 1.28 KB
/
Copy pathindex.ts
File metadata and controls
38 lines (32 loc) · 1.28 KB
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
35
36
37
38
// Copyright (c) 2023 Cloudflare, Inc.
// Licensed under the Apache-2.0 license found in the LICENSE file or at https://opensource.org/licenses/Apache-2.0
import { webcrypto } from 'node:crypto';
import { genericBatchedTokens } from './generic_batched.example.js';
import { publicVerifiableTokensPSS, publicVerifiableTokensPSSZero } from './pub_verif.example.js';
import {
publicVerifiableWithMetadataTokensPSS,
publicVerifiableWithMetadataTokensPSSZero,
} from './pub_verif_metadata.example.js';
import { privateVerifiableTokens } from './priv_verif.example.js';
if (typeof crypto === 'undefined') {
Object.assign(global, { crypto: webcrypto });
}
async function isOk(fn: () => Promise<boolean>) {
if (!(await fn())) {
console.error(`[Error] ${fn} example failed`);
process.exitCode = 1;
}
}
async function examples() {
await isOk(genericBatchedTokens);
await isOk(privateVerifiableTokens);
await isOk(publicVerifiableTokensPSS);
await isOk(publicVerifiableTokensPSSZero);
await isOk(publicVerifiableWithMetadataTokensPSS);
await isOk(publicVerifiableWithMetadataTokensPSSZero);
}
examples().catch((e: unknown) => {
console.log(`Error: ${(e as Error).message}`);
console.log(`Stack: ${(e as Error).stack}`);
process.exit(1);
});