From c53fe624c909940ac0e3679474efbbc6d0fe6f84 Mon Sep 17 00:00:00 2001 From: Il Harper Date: Mon, 4 Mar 2024 00:41:54 +0800 Subject: [PATCH] feat(shell): add token utils --- packages/shell/src/utils/token.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 packages/shell/src/utils/token.ts diff --git a/packages/shell/src/utils/token.ts b/packages/shell/src/utils/token.ts new file mode 100644 index 0000000..d00c1c5 --- /dev/null +++ b/packages/shell/src/utils/token.ts @@ -0,0 +1,9 @@ +import { randomBytes } from 'node:crypto' + +export const generateToken = () => randomBytes(32).toString('hex') +export const generateToken16 = () => randomBytes(16).toString('hex') + +export const buildEventIdCounter = () => { + let i = 0 + return () => ++i +}