actually prettier

This commit is contained in:
Toshit Chawda 2024-07-14 16:22:34 -07:00
parent fb53b44869
commit 56767f5b31
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
41 changed files with 1914 additions and 1919 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,48 +1,48 @@
import { enc, dec } from "./aes";
import { enc, dec } from "./aes"
// for some reason eslint was parsing the type inside of the function params as a variable
export interface Codec {
// eslint-disable-next-line
encode: (str: string | undefined) => string;
// eslint-disable-next-line
decode: (str: string | undefined) => string;
// eslint-disable-next-line
encode: (str: string | undefined) => string
// eslint-disable-next-line
decode: (str: string | undefined) => string
}
const xor = {
encode: (str: string | undefined, key: number = 2) => {
if (!str) return str;
encode: (str: string | undefined, key: number = 2) => {
if (!str) return str
return encodeURIComponent(
str
.split("")
.map((e, i) =>
i % key ? String.fromCharCode(e.charCodeAt(0) ^ key) : e,
)
.join(""),
);
},
decode: (str: string | undefined, key: number = 2) => {
if (!str) return str;
return encodeURIComponent(
str
.split("")
.map((e, i) =>
i % key ? String.fromCharCode(e.charCodeAt(0) ^ key) : e
)
.join("")
)
},
decode: (str: string | undefined, key: number = 2) => {
if (!str) return str
return decodeURIComponent(str)
.split("")
.map((e, i) => (i % key ? String.fromCharCode(e.charCodeAt(0) ^ key) : e))
.join("");
},
};
return decodeURIComponent(str)
.split("")
.map((e, i) => (i % key ? String.fromCharCode(e.charCodeAt(0) ^ key) : e))
.join("")
},
}
const plain = {
encode: (str: string | undefined) => {
if (!str) return str;
encode: (str: string | undefined) => {
if (!str) return str
return encodeURIComponent(str);
},
decode: (str: string | undefined) => {
if (!str) return str;
return encodeURIComponent(str)
},
decode: (str: string | undefined) => {
if (!str) return str
return decodeURIComponent(str);
},
};
return decodeURIComponent(str)
},
}
/*
const aes = {
@ -60,30 +60,30 @@ const aes = {
*/
const none = {
encode: (str: string | undefined) => str,
decode: (str: string | undefined) => str,
};
encode: (str: string | undefined) => str,
decode: (str: string | undefined) => str,
}
const base64 = {
encode: (str: string | undefined) => {
if (!str) return str;
encode: (str: string | undefined) => {
if (!str) return str
return decodeURIComponent(btoa(str));
},
decode: (str: string | undefined) => {
if (!str) return str;
return decodeURIComponent(btoa(str))
},
decode: (str: string | undefined) => {
if (!str) return str
return atob(str);
},
};
return atob(str)
},
}
if (!self.$scramjet) {
//@ts-expect-error really dumb workaround
self.$scramjet = {};
//@ts-expect-error really dumb workaround
self.$scramjet = {}
}
self.$scramjet.codecs = {
none,
plain,
base64,
xor,
};
none,
plain,
base64,
xor,
}