Fix formatting and trailing whitespace
This commit is contained in:
parent
da59efa23a
commit
f784e45d86
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import OperationError from "../errors/OperationError.mjs";
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
import { fromBase64 } from "../lib/Base64.mjs"
|
import { fromBase64 } from "../lib/Base64.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flask Session Decode operation
|
* Flask Session Decode operation
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class FlaskSessionSign extends Operation {
|
|||||||
const view = new DataView(buffer);
|
const view = new DataView(buffer);
|
||||||
view.setInt32(0, currentTimeStamp, false);
|
view.setInt32(0, currentTimeStamp, false);
|
||||||
const bytes = new Uint8Array(buffer);
|
const bytes = new Uint8Array(buffer);
|
||||||
let binary = '';
|
let binary = "";
|
||||||
bytes.forEach(b => binary += String.fromCharCode(b));
|
bytes.forEach(b => binary += String.fromCharCode(b));
|
||||||
const timeB64 = toBase64(Utils.strToByteArray(binary));
|
const timeB64 = toBase64(Utils.strToByteArray(binary));
|
||||||
const time = timeB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
const time = timeB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class FlaskSessionVerify extends Operation {
|
|||||||
const parts = input.split(".");
|
const parts = input.split(".");
|
||||||
|
|
||||||
if (parts.length !== 3) {
|
if (parts.length !== 3) {
|
||||||
throw new OperationError("Invalid Flask token format. Expected payload.timestamp.signature");
|
throw new OperationError("Invalid Flask token format. Expected payload.timestamp.signature");
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = Utils.convertToByteString(parts[0] + "." + parts[1], "utf8");
|
const data = Utils.convertToByteString(parts[0] + "." + parts[1], "utf8");
|
||||||
@ -91,7 +91,7 @@ class FlaskSessionVerify extends Operation {
|
|||||||
const signB64 = toBase64(sign.finalize());
|
const signB64 = toBase64(sign.finalize());
|
||||||
const sign64 = signB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
const sign64 = signB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
||||||
|
|
||||||
if (sign64 !== parts[2]){
|
if (sign64 !== parts[2]) {
|
||||||
throw new OperationError("Invalid signature!");
|
throw new OperationError("Invalid signature!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,12 +13,12 @@ const validKey = "mysecretkey";
|
|||||||
const outputObject = {
|
const outputObject = {
|
||||||
user: "admin",
|
user: "admin",
|
||||||
role: "superuser",
|
role: "superuser",
|
||||||
}
|
};
|
||||||
|
|
||||||
const outputVerify = {
|
const outputVerify = {
|
||||||
valid: true,
|
valid: true,
|
||||||
payload: outputObject,
|
payload: outputObject,
|
||||||
}
|
};
|
||||||
|
|
||||||
TestRegister.addTests([
|
TestRegister.addTests([
|
||||||
{
|
{
|
||||||
@ -53,4 +53,4 @@ TestRegister.addTests([
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
])
|
]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user