diff options
author | Hayden Young <hi@hbjy.dev> | 2021-10-15 09:42:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 09:42:31 +0000 |
commit | 865389d0d054a221950c944cd535964ca009d131 (patch) | |
tree | d3019344601c12892e28b0584513b6127b608fc1 /api/src/test/jwt.ts | |
parent | fix: don't set location by default (diff) | |
parent | :bug: fix migration + autojoin (diff) | |
download | server-865389d0d054a221950c944cd535964ca009d131.tar.xz |
chore: merge master into cdn-s3
Diffstat (limited to 'api/src/test/jwt.ts')
-rw-r--r-- | api/src/test/jwt.ts | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/api/src/test/jwt.ts b/api/src/test/jwt.ts deleted file mode 100644 index bdad513b..00000000 --- a/api/src/test/jwt.ts +++ /dev/null @@ -1,37 +0,0 @@ -const jwa = require("jwa"); - -var STR64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""); - -function base64url(string: string, encoding: string) { - // @ts-ignore - return Buffer.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); -} - -function to64String(input: number, current = ""): string { - if (input < 0 && current.length == 0) { - input = input * -1; - } - var modify = input % 64; - var remain = Math.floor(input / 64); - var result = STR64[modify] + current; - return remain <= 0 ? result : to64String(remain, result); -} - -function to64Parse(input: string) { - var result = 0; - var toProc = input.split(""); - var e; - for (e in toProc) { - result = result * 64 + STR64.indexOf(toProc[e]); - } - return result; -} - -// @ts-ignore -const start = `${base64url("311129357362135041")}.${to64String(Date.now())}`; -const signature = jwa("HS256").sign(start, `test`); -const token = `${start}.${signature}`; -console.log(token); - -// MzExMTI5MzU3MzYyMTM1MDQx.XdQb_rA.907VgF60kocnOTl32MSUWGSSzbAytQ0jbt36KjLaxuY -// MzExMTI5MzU3MzYyMTM1MDQx.XdQbaPy.4vGx4L7IuFJGsRe6IL3BeybLIvbx4Vauvx12pwNsy2U |