-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathget.mjs
38 lines (33 loc) · 1003 Bytes
/
get.mjs
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
/* eslint-disable no-console */
import {
PangeaConfig,
AuditService,
VaultService,
PangeaErrors,
} from "pangea-node-sdk";
const token = process.env.PANGEA_VAULT_TOKEN;
const audit_token_id = process.env.PANGEA_AUDIT_TOKEN_ID;
const config = new PangeaConfig({ domain: process.env.PANGEA_DOMAIN });
const vault = new VaultService(token, config);
(async () => {
try {
console.log("Fetch the audit token...");
const storeResponse = await vault.getItem({
id: audit_token_id,
});
const audit_token = storeResponse.result.item_versions[0].secret;
console.log("Create audit instance...");
var audit = new AuditService(audit_token, config);
const data = {
message: "Hello, World!",
};
const logResponse = await audit.log(data, { verbose: true });
console.log("Response: %s", logResponse.result);
} catch (err) {
if (err instanceof PangeaErrors.APIError) {
console.log(err.toString());
} else {
throw err;
}
}
})();