added doga
This commit is contained in:
10
25_02_24/node_modules/@tinyhttp/cookie-signature/dist/index.d.ts
generated
vendored
Normal file
10
25_02_24/node_modules/@tinyhttp/cookie-signature/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Sign the given `val` with `secret`.
|
||||
*/
|
||||
export declare const sign: (val: string, secret: string) => string;
|
||||
/**
|
||||
* Unsign and decode the given `val` with `secret`,
|
||||
* returning `false` if the signature is invalid.
|
||||
*/
|
||||
export declare const unsign: (val: string, secret: string) => string | false;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/cookie-signature/dist/index.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/cookie-signature/dist/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,IAAI,QAAS,MAAM,UAAU,MAAM,KAAG,MACuC,CAAA;AAE1F;;;GAGG;AACH,eAAO,MAAM,MAAM,QAAS,MAAM,UAAU,MAAM,KAAG,MAAM,GAAG,KAQ7D,CAAA"}
|
||||
15
25_02_24/node_modules/@tinyhttp/cookie-signature/dist/index.js
generated
vendored
Normal file
15
25_02_24/node_modules/@tinyhttp/cookie-signature/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { createHmac, timingSafeEqual } from "node:crypto";
|
||||
const sign = (val, secret) => `${val}.${createHmac("sha256", secret).update(val).digest("base64").replace(/=+$/, "")}`;
|
||||
const unsign = (val, secret) => {
|
||||
const str = val.slice(0, val.lastIndexOf("."));
|
||||
const mac = sign(str, secret);
|
||||
const macBuffer = Buffer.from(mac);
|
||||
const valBuffer = Buffer.alloc(macBuffer.length);
|
||||
valBuffer.write(val);
|
||||
return timingSafeEqual(macBuffer, valBuffer) ? str : false;
|
||||
};
|
||||
export {
|
||||
sign,
|
||||
unsign
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/cookie-signature/dist/index.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/cookie-signature/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from 'node:crypto'\n\n/**\n * Sign the given `val` with `secret`.\n */\nexport const sign = (val: string, secret: string): string =>\n `${val}.${createHmac('sha256', secret).update(val).digest('base64').replace(/=+$/, '')}`\n\n/**\n * Unsign and decode the given `val` with `secret`,\n * returning `false` if the signature is invalid.\n */\nexport const unsign = (val: string, secret: string): string | false => {\n const str = val.slice(0, val.lastIndexOf('.'))\n const mac = sign(str, secret)\n const macBuffer = Buffer.from(mac)\n const valBuffer = Buffer.alloc(macBuffer.length)\n\n valBuffer.write(val)\n return timingSafeEqual(macBuffer, valBuffer) ? str : false\n}\n"],"names":[],"mappings":";AAKa,MAAA,OAAO,CAAC,KAAa,WAChC,GAAG,GAAG,IAAI,WAAW,UAAU,MAAM,EAAE,OAAO,GAAG,EAAE,OAAO,QAAQ,EAAE,QAAQ,OAAO,EAAE,CAAC;AAM3E,MAAA,SAAS,CAAC,KAAa,WAAmC;AACrE,QAAM,MAAM,IAAI,MAAM,GAAG,IAAI,YAAY,GAAG,CAAC;AACvC,QAAA,MAAM,KAAK,KAAK,MAAM;AACtB,QAAA,YAAY,OAAO,KAAK,GAAG;AACjC,QAAM,YAAY,OAAO,MAAM,UAAU,MAAM;AAE/C,YAAU,MAAM,GAAG;AACnB,SAAO,gBAAgB,WAAW,SAAS,IAAI,MAAM;AACvD;"}
|
||||
Reference in New Issue
Block a user