forked from ascorbic/secrets-test
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlib.ts
More file actions
21 lines (18 loc) · 668 Bytes
/
Copy pathlib.ts
File metadata and controls
21 lines (18 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// This function replaces all but the last four digits of a string with zeroes
const sanitizeToken = (str: string, length = 16): string => {
const len = str.length;
const displayed = len > 4 ? str.substr(len - 4, len) : str;
const padLength = length - displayed.length;
return displayed.padStart(padLength, "*");
};
export const formatSecret = (secret: any): any => {
if (!secret) {
return;
}
return {
bearerToken: secret.bearerToken ? sanitizeToken(secret.bearerToken) : null,
friendlyServiceName: secret.friendlyServiceName,
service: secret.service,
grantedScopes: secret.grantedScopes?.map((scope: any) => scope.scope),
};
};