1 | import * as http from "http";
|
2 | import * as request from "request";
|
3 | import * as Crypto from "./crypto";
|
4 |
|
5 | export interface Credentials {
|
6 | algorithm: "sha1" | "sha256";
|
7 | id: string;
|
8 | key: string;
|
9 | }
|
10 |
|
11 | export interface HeaderOptions {
|
12 |
|
13 | app?: string | undefined;
|
14 |
|
15 | contentType?: string | undefined;
|
16 | credentials: Credentials;
|
17 |
|
18 | dlg?: string | undefined;
|
19 |
|
20 | ext?: string | undefined;
|
21 |
|
22 | hash?: string | undefined;
|
23 |
|
24 | localtimeOffsetMsec?: number | undefined;
|
25 |
|
26 | nonce?: string | undefined;
|
27 |
|
28 | payload?: string | undefined;
|
29 |
|
30 | timestamp?: number | undefined;
|
31 | }
|
32 |
|
33 | export interface Header {
|
34 | header: string;
|
35 | artifacts: Crypto.Artifacts;
|
36 | }
|
37 |
|
38 | export interface AuthenticateOptions {
|
39 |
|
40 | payload?: string | undefined;
|
41 |
|
42 | required?: boolean | undefined;
|
43 | }
|
44 |
|
45 | export interface Authentication {
|
46 | headers: Record<string, string>;
|
47 | }
|
48 |
|
49 | export interface BewitOptions {
|
50 | credentials: Credentials;
|
51 |
|
52 | ext?: string | undefined;
|
53 |
|
54 | localtimeOffsetMsec: number;
|
55 |
|
56 | ttlSec: number;
|
57 | }
|
58 |
|
59 | export interface MessageOptions {
|
60 | credentials: Credentials;
|
61 |
|
62 | localtimeOffsetMsec: number;
|
63 |
|
64 | nonce: string;
|
65 |
|
66 | timestamp: number;
|
67 | }
|
68 |
|
69 | export interface Message {
|
70 | hash: string;
|
71 | id: string;
|
72 | mac: string;
|
73 | nonce: string;
|
74 | ts: string;
|
75 | }
|
76 |
|
77 | export function authenticate(
|
78 | res: http.IncomingMessage | request.Response,
|
79 | credentials: Credentials,
|
80 | artifacts: Crypto.Artifacts,
|
81 | options?: AuthenticateOptions,
|
82 | ): Authentication;
|
83 |
|
84 | export function getBewit(uri: string, options: BewitOptions): string;
|
85 |
|
86 | export function header(uri: string, method: string, options?: HeaderOptions): Header;
|
87 |
|
88 | export function message(host: string, port: number, message: string, options?: MessageOptions): Message;
|