This repository has been archived by the owner on Aug 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow user to automatically roll tokens
- Loading branch information
1 parent
a1a3a53
commit 03e4cd6
Showing
4 changed files
with
32 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
import { randomBytes } from 'crypto' | ||
|
||
function main() { | ||
console.log(randomBytes(48).toString('base64url')) | ||
async function main() { | ||
const generated_token = randomBytes(48).toString('base64url') | ||
console.log(`[+] Your generated token is ${generated_token}`) | ||
const save = prompt('[?] Would you like to use this token? (y/N)\n')?.toLowerCase() | ||
|
||
if (save !== 'y') { | ||
return | ||
} | ||
|
||
const process = Bun.spawn(['npx', 'wrangler', 'secret', 'put', 'TOKEN'], { | ||
stdin: new TextEncoder().encode(generated_token) | ||
}) | ||
|
||
const response = await new Response(process.stdout).text() | ||
console.log(response) | ||
} | ||
|
||
main() | ||
void main() |