mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 20:23:08 +02:00
Create type definition for 'http-signature' (#4049)
* Create type definition for 'http-signature' * Follow lint
This commit is contained in:
parent
2f72c38516
commit
40e177fa96
4 changed files with 78 additions and 3 deletions
75
src/@types/http-signature.d.ts
vendored
Normal file
75
src/@types/http-signature.d.ts
vendored
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
declare module 'http-signature' {
|
||||||
|
import { IncomingMessage, ClientRequest } from 'http';
|
||||||
|
|
||||||
|
interface ISignature {
|
||||||
|
keyId: string;
|
||||||
|
algorithm: string;
|
||||||
|
headers: string[];
|
||||||
|
signature: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IOptions {
|
||||||
|
headers?: string[];
|
||||||
|
algorithm?: string;
|
||||||
|
strict?: boolean;
|
||||||
|
authorizationHeaderName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IParseRequestOptions extends IOptions {
|
||||||
|
clockSkew?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IParsedSignature {
|
||||||
|
scheme: string;
|
||||||
|
params: ISignature;
|
||||||
|
signingString: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type RequestSignerConstructorOptions =
|
||||||
|
IRequestSignerConstructorOptionsFromProperties |
|
||||||
|
IRequestSignerConstructorOptionsFromFunction;
|
||||||
|
|
||||||
|
interface IRequestSignerConstructorOptionsFromProperties {
|
||||||
|
keyId: string;
|
||||||
|
key: string | Buffer;
|
||||||
|
algorithm?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IRequestSignerConstructorOptionsFromFunction {
|
||||||
|
sign?: (data: string, cb: (err: any, sig: ISignature) => void) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
class RequestSigner {
|
||||||
|
constructor(options: RequestSignerConstructorOptions);
|
||||||
|
|
||||||
|
public writeHeader(header: string, value: string): string;
|
||||||
|
|
||||||
|
public writeDateHeader(): string;
|
||||||
|
|
||||||
|
public writeTarget(method: string, path: string): void;
|
||||||
|
|
||||||
|
public sign(cb: (err: any, authz: string) => void): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ISignRequestOptions extends IOptions {
|
||||||
|
keyId: string;
|
||||||
|
key: string;
|
||||||
|
httpVersion?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parse(request: IncomingMessage, options?: IParseRequestOptions): IParsedSignature;
|
||||||
|
export function parseRequest(request: IncomingMessage, options?: IParseRequestOptions): IParsedSignature;
|
||||||
|
|
||||||
|
export function sign(request: ClientRequest, options: ISignRequestOptions): boolean;
|
||||||
|
export function signRequest(request: ClientRequest, options: ISignRequestOptions): boolean;
|
||||||
|
export function createSigner(): RequestSigner;
|
||||||
|
export function isSigner(obj: any): obj is RequestSigner;
|
||||||
|
|
||||||
|
export function sshKeyToPEM(key: string): string;
|
||||||
|
export function sshKeyFingerprint(key: string): string;
|
||||||
|
export function pemToRsaSSHKey(pem: string, comment: string): string;
|
||||||
|
|
||||||
|
export function verify(parsedSignature: IParsedSignature, pubkey: string | Buffer): boolean;
|
||||||
|
export function verifySignature(parsedSignature: IParsedSignature, pubkey: string | Buffer): boolean;
|
||||||
|
export function verifyHMAC(parsedSignature: IParsedSignature, secret: string): boolean;
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
import * as bq from 'bee-queue';
|
import * as bq from 'bee-queue';
|
||||||
import * as debug from 'debug';
|
import * as debug from 'debug';
|
||||||
|
|
||||||
const httpSignature = require('http-signature');
|
import * as httpSignature from 'http-signature';
|
||||||
import parseAcct from '../../../misc/acct/parse';
|
import parseAcct from '../../../misc/acct/parse';
|
||||||
import User, { IRemoteUser } from '../../../models/user';
|
import User, { IRemoteUser } from '../../../models/user';
|
||||||
import perform from '../../../remote/activitypub/perform';
|
import perform from '../../../remote/activitypub/perform';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { request } from 'https';
|
import { request } from 'https';
|
||||||
const { sign } = require('http-signature');
|
import { sign } from 'http-signature';
|
||||||
import { URL } from 'url';
|
import { URL } from 'url';
|
||||||
import * as debug from 'debug';
|
import * as debug from 'debug';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
import * as Router from 'koa-router';
|
import * as Router from 'koa-router';
|
||||||
const json = require('koa-json-body');
|
const json = require('koa-json-body');
|
||||||
const httpSignature = require('http-signature');
|
import * as httpSignature from 'http-signature';
|
||||||
|
|
||||||
import { createHttpJob } from '../queue';
|
import { createHttpJob } from '../queue';
|
||||||
import { renderActivity } from '../remote/activitypub/renderer';
|
import { renderActivity } from '../remote/activitypub/renderer';
|
||||||
|
|
Loading…
Reference in a new issue