forked from passportxyz/passport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdidkit.js
39 lines (34 loc) · 811 Bytes
/
didkit.js
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
39
const keyToDID = jest.fn(() => Promise.resolve("did:key:PUBLIC_KEY"));
const keyToVerificationMethod = jest.fn(() => Promise.resolve("did:key:PUBLIC_KEY#PUBLIC_KEY"));
const issueCredential = jest.fn((credential) =>
Promise.resolve(
JSON.stringify({
...JSON.parse(credential),
proof: {},
})
)
);
const verifyCredential = jest.fn(() =>
Promise.resolve(
JSON.stringify({
checks: [],
warnings: [],
errors: [],
})
)
);
const clearDidkitMocks = () => {
keyToDID.mockClear();
keyToVerificationMethod.mockClear();
issueCredential.mockClear();
verifyCredential.mockClear();
};
// ---- Generate & Verify methods
module.exports = {
keyToDID,
keyToVerificationMethod,
issueCredential,
verifyCredential,
/* Mock helpers */
clearDidkitMocks,
};