2
0
mirror of https://github.com/tribufu/sdk-js synced 2025-06-19 03:54:19 +00:00

Merge mintaka lib

This commit is contained in:
2024-03-06 19:39:31 -03:00
parent b4d074420a
commit c6136b6e21
15 changed files with 747 additions and 23 deletions

28
src/http/headers.ts Normal file

@ -0,0 +1,28 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import { RawStringMap, StringMap } from "../collections/string_map";
/**
* Http Header Map
*
* Helper type to represent HTTP headers.
*/
export type HttpHeaderMap = RawStringMap<string>;
/**
* Http Headers
*
* Helper class to manage HTTP headers.
*/
export class HttpHeaders extends StringMap<string> {
public static parseAuthorizationHeader(value: string): { scheme: string, token: string } {
const parts = value.split(" ");
if (parts.length !== 2) {
throw new Error("Invalid authorization header");
}
return { scheme: parts[0], token: parts[1] };
}
}