fix token grabbing
This commit is contained in:
parent
64d681edec
commit
fecafb967f
2 changed files with 6 additions and 4 deletions
|
|
@ -9,7 +9,7 @@ export async function getToken(baseUrl: string): Promise<string> {
|
||||||
const indexResponse = await request(baseUrl);
|
const indexResponse = await request(baseUrl);
|
||||||
const indexBody = await indexResponse.body.text();
|
const indexBody = await indexResponse.body.text();
|
||||||
|
|
||||||
const jsRegex = /\/assets\/index-legacy[~-][^/]+\.js/;
|
const jsRegex = /\/assets\/index(?:-legacy)?[~-][^/]+\.js/;
|
||||||
const jsPath = indexBody.match(jsRegex)?.[0];
|
const jsPath = indexBody.match(jsRegex)?.[0];
|
||||||
|
|
||||||
if (!jsPath) {
|
if (!jsPath) {
|
||||||
|
|
@ -20,8 +20,8 @@ export async function getToken(baseUrl: string): Promise<string> {
|
||||||
const jsBody = await jsResponse.body.text();
|
const jsBody = await jsResponse.body.text();
|
||||||
|
|
||||||
// the token is actually a base64-encoded JWT
|
// the token is actually a base64-encoded JWT
|
||||||
// `eyJh` === `{"a`, which is the beginning of a JWT (a is the start of alg)
|
// `eyJh` === `{"`, which is the beginning of a JWT. foolproof? no
|
||||||
const tokenRegex = /eyJh([^"]*)/;
|
const tokenRegex = /eyJ([^"]*)/;
|
||||||
const token = jsBody.match(tokenRegex)?.[0];
|
const token = jsBody.match(tokenRegex)?.[0];
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"baseUrl": "src",
|
"paths": {
|
||||||
|
"*": ["./src/*"]
|
||||||
|
},
|
||||||
"outDir": "dist"
|
"outDir": "dist"
|
||||||
},
|
},
|
||||||
"include": ["**/*"],
|
"include": ["**/*"],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue