-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom ttl options for App Check
- Loading branch information
1 parent
f09bd64
commit 8dab1b2
Showing
9 changed files
with
206 additions
and
40 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
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
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 |
---|---|---|
|
@@ -190,3 +190,29 @@ export function generateUpdateMask( | |
} | ||
return updateMask; | ||
} | ||
|
||
/** | ||
* Transforms milliseconds to a protobuf Duration type string. | ||
* Returns the duration in seconds with up to nine fractional | ||
* digits, terminated by 's'. Example: "3 seconds 0 nano seconds as 3s, | ||
* 3 seconds 1 nano seconds as 3.000000001s". | ||
* | ||
* @param milliseconds The duration in milliseconds. | ||
* @returns The resulting formatted string in seconds with up to nine fractional | ||
* digits, terminated by 's'. | ||
*/ | ||
export function transformMillisecondsToSecondsString(milliseconds: number): string { | ||
let duration: string; | ||
const seconds = Math.floor(milliseconds / 1000); | ||
const nanos = Math.round((milliseconds - seconds * 1000) * 1000000); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lahirumaramba
Author
Member
|
||
if (nanos > 0) { | ||
let nanoString = nanos.toString(); | ||
while (nanoString.length < 9) { | ||
nanoString = '0' + nanoString; | ||
} | ||
duration = `${seconds}.${nanoString}s`; | ||
} else { | ||
duration = `${seconds}s`; | ||
} | ||
return duration; | ||
} |
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
Oops, something went wrong.
This doesn't matter in practice at all, but we can use
floor
here so that technically we never mint a token with a TTL that's longer than requested.