mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-29 04:00:09 +00:00
Initial commit of eigent-main
This commit is contained in:
commit
723df5a03e
1144 changed files with 103478 additions and 0 deletions
60
package/@stackframe/stack-shared/dist/esm/utils/http.js
vendored
Normal file
60
package/@stackframe/stack-shared/dist/esm/utils/http.js
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
// src/utils/http.tsx
|
||||
import { decodeBase64, encodeBase64, isBase64 } from "./bytes";
|
||||
var HTTP_METHODS = {
|
||||
"GET": {
|
||||
safe: true,
|
||||
idempotent: true
|
||||
},
|
||||
"POST": {
|
||||
safe: false,
|
||||
idempotent: false
|
||||
},
|
||||
"PUT": {
|
||||
safe: false,
|
||||
idempotent: true
|
||||
},
|
||||
"DELETE": {
|
||||
safe: false,
|
||||
idempotent: true
|
||||
},
|
||||
"PATCH": {
|
||||
safe: false,
|
||||
idempotent: false
|
||||
},
|
||||
"OPTIONS": {
|
||||
safe: true,
|
||||
idempotent: true
|
||||
},
|
||||
"HEAD": {
|
||||
safe: true,
|
||||
idempotent: true
|
||||
},
|
||||
"TRACE": {
|
||||
safe: true,
|
||||
idempotent: true
|
||||
},
|
||||
"CONNECT": {
|
||||
safe: false,
|
||||
idempotent: false
|
||||
}
|
||||
};
|
||||
function decodeBasicAuthorizationHeader(value) {
|
||||
const [type, encoded, ...rest] = value.split(" ");
|
||||
if (rest.length > 0) return null;
|
||||
if (!encoded) return null;
|
||||
if (type !== "Basic") return null;
|
||||
if (!isBase64(encoded)) return null;
|
||||
const decoded = new TextDecoder().decode(decodeBase64(encoded));
|
||||
const split = decoded.split(":");
|
||||
return [split[0], split.slice(1).join(":")];
|
||||
}
|
||||
function encodeBasicAuthorizationHeader(id, password) {
|
||||
if (id.includes(":")) throw new Error("Basic authorization header id cannot contain ':'");
|
||||
return `Basic ${encodeBase64(new TextEncoder().encode(`${id}:${password}`))}`;
|
||||
}
|
||||
export {
|
||||
HTTP_METHODS,
|
||||
decodeBasicAuthorizationHeader,
|
||||
encodeBasicAuthorizationHeader
|
||||
};
|
||||
//# sourceMappingURL=http.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue