http-signature/000755 001751 000177 0000000000 14710246531015520 5ustar00runner000000 000000 1471024653114710246531http-signature/LICENSE000644 001751 000177 0000002165 14710246531016531 0ustar00runner000000 000000 1471024653114710246531 MIT License Copyright (c) Microsoft Corporation. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE http-signature/README.md000644 001751 000177 0000001057 14710246531017002 0ustar00runner000000 000000 1471024653114710246531# Installation > `npm install --save @types/http-signature` # Summary This package contains type definitions for http-signature (https://github.com/joyent/node-http-signature). # Details Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-signature. ### Additional Details * Last updated: Tue, 29 Oct 2024 21:02:17 GMT * Dependencies: [@types/node](https://npmjs.com/package/@types/node) # Credits These definitions were written by [Adam Thompson-Sharpe](https://github.com/MysteryBlokHed). http-signature/index.d.ts000644 001751 000177 0000000757 14710246531017432 0ustar00runner000000 000000 1471024653114710246531/// export { ParseOptions, parseRequest, parseRequest as parse, ParseResponse } from "./lib/parser"; export { createSigner, isSigner, RequestSigner, RequestSignerOptions, Signature, SignOptions, signRequest, signRequest as sign, } from "./lib/signer"; export { fingerprint as sshKeyFingerprint, pemToRsaSSHKey, sshKeyToPEM } from "./lib/utils"; export { verifyHMAC, verifySignature, verifySignature as verify } from "./lib/verify"; http-signature/lib/000755 001751 000177 0000000000 14710246531016266 5ustar00runner000000 000000 1471024653114710246531http-signature/package.json000644 001751 000177 0000001576 14710246531020017 0ustar00runner000000 000000 1471024653114710246531{ "name": "@types/http-signature", "version": "1.4.0", "description": "TypeScript definitions for http-signature", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-signature", "license": "MIT", "contributors": [ { "name": "Adam Thompson-Sharpe", "githubUsername": "MysteryBlokHed", "url": "https://github.com/MysteryBlokHed" } ], "main": "", "types": "index.d.ts", "repository": { "type": "git", "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", "directory": "types/http-signature" }, "scripts": {}, "dependencies": { "@types/node": "*" }, "peerDependencies": {}, "typesPublisherContentHash": "ec13c1fc5c8677381e907d8841bbae0d49f313d36511f7f5eb5cb4331320bea5", "typeScriptVersion": "4.8" }http-signature/lib/parser.d.ts000644 001751 000177 0000003305 14710246531020355 0ustar00runner000000 000000 1471024653114710246531import { ClientRequest } from "node:http"; import { Signature } from "./signer"; export interface ParseOptions { /** * Allowed clock skew in seconds * @default 300 */ clockSkew?: number | undefined; /** Required header names */ headers?: readonly string[] | undefined; /** Algorithms to support. Defaults to all */ algorithms?: readonly string[] | undefined; /** * Whether to enforce latest spec parsing * @default false */ strict?: boolean | undefined; } export interface ParseResponse { scheme: string; params: Signature; signingString: string; } /** * Parses the 'Authorization' header out of an http.ServerRequest object. * * Note that this API will fully validate the Authorization header, and throw * on any error. It will not however check the signature, or the keyId format * as those are specific to your environment. You can use the options object * to pass in extra constraints * * @param request The ClientRequest * @param options Optional options * * @throws {TypeError} Nn invalid input * @throws {InvalidHeaderError} On an invalid Authorization header error * @throws {InvalidParamsError} If the params in the scheme are invalid * @throws {MissingHeaderError} If the params indicate a header not present, * Either in the request headers from the params, * or not in the params from a required header in options * @throws {StrictParsingError} If old attributes are used in strict parsing mode * @throws {ExpiredRequestError} If the value of date or x-date exceeds skew */ export function parseRequest(request: ClientRequest, options?: ParseOptions): ParseResponse; http-signature/lib/signer.d.ts000644 001751 000177 0000006517 14710246531020360 0ustar00runner000000 000000 1471024653114710246531import { ClientRequest } from "node:http"; import { Transform } from "node:stream"; export interface Signature { keyId: string; algorithm: string; headers: string[]; signature: string; } export type RequestSignerOptions = | { keyId: string; key: string | Buffer; /** Required for HMAC */ algorithm?: string | undefined; /** Not required for HMAC */ keyPassphrase?: string | undefined; } | { sign(data: string, callback: (error: any, sig?: Signature) => void): void; }; /** @see {@link createSigner} */ declare class _RequestSigner { rs_alg: [string, string, string]; rs_signFunc?: ((error: any, sig?: Signature) => void) | undefined; rs_keyId?: string | undefined; rs_signer?: Transform | undefined; rs_headers: string[]; rs_lines: string[]; constructor(options: RequestSignerOptions); /** Adds a header to be signed alongside its value */ writeHeader(header: string, value: string): string; writeDateHeader(): string; /** * Add the request target to be signed * @param method HTTP mehod (i.e. `"get"`, `"post"`, `"put"`) */ writeTarget(method: string, path: string): void; /** Calculate the value for the Authorization header on this request asynchronously */ sign(callback: (error: any, authorization: string) => void): void; } /** @see {@link createSigner} */ export type RequestSigner = _RequestSigner; /** Identifies whether a given object is a request signer or not */ export function isSigner(obj: any): obj is RequestSigner; /** * Creates a request signer, used to asynchronously build a signature * for a request (does not have to be a {@link ClientRequest}) * @param options Options for the constructor * @see {@link RequestSigner} */ export function createSigner(options: RequestSignerOptions): RequestSigner; export interface SignOptions { keyId: string; /** Either a PEM or HMAC key */ key: string; /** * @default ["date"] */ headers?: readonly string[] | undefined; /** * **Required** if the {@link key} is HMAC. * Default is the same as the sshpk signing algorithm * for the type of key given */ algorithm?: string | undefined; /** * @default "1.1" */ httpVersion?: string | undefined; /** * @default false */ strict?: boolean | undefined; /** * How many seconds until the signature expires * @default 60 */ expiresIn?: number | undefined; /** * The passphrase to pass to sshpk to parse the private key. * Does nothing if the key is HMAC */ keyPassphrase?: string | undefined; } /** * Adds an 'Authorization' header to a {@link ClientRequest} object. * * Note that this API will add a Date header if it's not already set. Any * other headers in the `options.headers` array MUST be present, or this * will throw * * @throws {TypeError} On bad parameter types (input) * @throws {InvalidAlgorithmError} If algorithm was bad or incompatible with the given key * @throws {sshpk.KeyParseError} If key was bad * @throws {MissingHeaderError} If a header to be signed was specified but was not present */ export function signRequest(request: ClientRequest, options: SignOptions): boolean; // To avoid exporting _RequestSigner (not actually exposed by the library) export {}; http-signature/lib/utils.d.ts000644 001751 000177 0000002431 14710246531020220 0ustar00runner000000 000000 1471024653114710246531export const HASH_ALGOS: Record<"sha1" | "sha256" | "sha512", boolean>; export const PK_ALGOS: Record<"rsa" | "dsa" | "ecdsa" | "ed25519", boolean>; export const HEADER: Record; export class HttpSignatureError extends Error { constructor(message: any, caller: (...args: any) => any); } export class InvalidAlgorithmError extends Error {} /** * Converts an OpenSSH public key (rsa only) to a PKCS#8 PEM file. * The reverse of {@link fingerprint}. * * The intent of this module is to interoperate with OpenSSL only, * specifically the node crypto module's `verify` method * * @param key An OpenSSH public key * @return PEM-encoded form of the RSA public key * @throws {TypeError} On bad input * @throws {Error} On invalid ssh key formatted data */ export function sshKeyToPEM(key: string): string; /** * Generates an OpenSSH fingerprint from an ssh public key * * @param key An OpenSSH public key * @return Key fingerprint * @throws {TypeError} On bad input * @throws {Error} If what was passed doesn't look like an ssh public key */ export function fingerprint(key: string): string; /** * Converts a PKGCS#8 PEM file to an OpenSSH public key (rsa). * The reverse of {@link sshKeyToPEM} */ export function pemToRsaSSHKey(pem: string, comment: string): string; http-signature/lib/verify.d.ts000644 001751 000177 0000001620 14710246531020363 0ustar00runner000000 000000 1471024653114710246531import { ParseResponse } from "./parser"; /** * Verify RSA/DSA signature against public key. * You are expected to pass in an object that was returned from `parse()` * * @param parsedSignature The return value of `parse()` * @param pubkey RSA/DSA private key PEM * @returns True if valid, false otherwise * @throws {TypeError} For bad arguments * @throws {InvalidAlgorithmError} */ export function verifySignature(parsedSignature: ParseResponse, pubkey: string): boolean; /** * Verify HMAC against shared secret. * You are expected to pass in an object that was returned from `parse()` * * @param parsedSignature The return value of `parse()` * @param buffer HMAC shared secret * @returns True if valid, false otherwise * @throws {TypeError} For bad arguments * @throws {InvalidAlgorithmError} */ export function verifyHMAC(parsedSignature: ParseResponse, secret: string | Buffer): boolean;