forked from ascorbic/secrets-test
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump to new netlify-functions package with better TypeScript defs, sh…
…ow metaprogramming for auth scope detection at runtime.
- Loading branch information
Sean Grove
authored and
Sean Grove
committed
Aug 2, 2021
1 parent
59eacdc
commit 76342ae
Showing
7 changed files
with
66 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Hi there!</h1> |