From 567657e3fab839bdeb535ea23c6593cbc8ce7588 Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Thu, 19 Jan 2017 15:29:50 +0300 Subject: [PATCH 01/43] Added types for SIP.js --- SIP.js/SIP.js-tests.ts | 99 ++++++++++++ SIP.js/index.d.ts | 354 +++++++++++++++++++++++++++++++++++++++++ SIP.js/tsconfig.json | 23 +++ SIP.js/tslint.json | 1 + 4 files changed, 477 insertions(+) create mode 100644 SIP.js/SIP.js-tests.ts create mode 100644 SIP.js/index.d.ts create mode 100644 SIP.js/tsconfig.json create mode 100644 SIP.js/tslint.json diff --git a/SIP.js/SIP.js-tests.ts b/SIP.js/SIP.js-tests.ts new file mode 100644 index 0000000000..f688fe67ae --- /dev/null +++ b/SIP.js/SIP.js-tests.ts @@ -0,0 +1,99 @@ +import SIP = require("./index"); + +let ua: SIP.UA = new SIP.UA(); + +const mediaHandler = (session: SIP.Session, options: SIP.WebRTC.Options) => new SIP.WebRTC.MediaHandler(); +const logConnector = (level: string, category: string, label: string, content: string) => null; + +const uaWithConfig: SIP.UA = new SIP.UA({ + uri: "wss://uri", + wsServers: ["s1", "s2"], + allowLegacyNotifications: true, + authenticationFactory: mediaHandler, + authorizationUser: "user", + autostart: true, + connectionRecoveryMaxInterval: 1, + connectionRecoveryMinInterval: 1, + displayName: "name", + hackCleanJitsiSdpImageattr: true, + hackStripTcp: true, + hackIpInContact: true, + hackViaTcp: true, + hackWssInTransport: true, + iceCheckingTimeout: 1, + instanceId: "id", + log: { + builtinEnabled: true, + level: 1, + connector: logConnector + }, + mediaHandlerFactory: mediaHandler, + noAnswerTimeout: 1, + password: "", + register: true, + registerExpires: 1, + registrarServer: "sip:registrar.mydomain.com", + rel100: "", + replaces: "", + stunServers: ["", ""], + turnServers: [ + { + password: "", + username: "", + urls: ["", ""] + } + ], + usePreloadedRoute: true, + userAgentString: "", + wsServerMaxReconnection: 1, + wsServerReconnectionTimeout: 1 +}); + +ua.start(); +ua.stop(); + +ua.register(); +ua = ua.register({ extraHeaders: [""] }); + +ua.unregister() +ua.unregister({ extraHeaders: [""], all: true }); + +const isConnected: boolean = ua.isConnected(); +const isRegistered: boolean = ua.isRegistered(); + +const message: SIP.Message = ua.message("", "", { contentType: "" }); + +ua.subscribe("", "", { expires: 1, extraHeaders: [""]}); +const subscription: SIP.Subscription = ua.subscribe(new SIP.URI(), "", { expires: 1, extraHeaders: [""]}); + +let session = ua.invite("", new HTMLVideoElement()); + +const inviteOptions: SIP.InviteOptions = { + media: { + constraints: { audio: true, video: false }, + stream: new MediaStream(), + render: { remote: new Element(), local: new Element() }, + }, + anonymous: true, + rel100: "", + inviteWithoutSdp: true, + RTCConstraints: new RTCPeerConnection() +} + +session = ua.invite("", inviteOptions); + +ua.on('connected', (args: SIP.UA.EventArgs.ConnectedArgs) => {}); +ua.on('disconnected', () => {}); +ua.on('registered', () => {}); +ua.on('unregistered', (args: SIP.UA.EventArgs.UnregisteredArgs) => {}); +ua.on('registrationFailed', (args: SIP.UA.EventArgs.RegistrationFailedArgs) => {}); +ua.on('invite', (session: SIP.Session) => { + session.on('progress', (response) => { + }); + session.on('accepted', (response) => { + }); + session.on('rejected', (response) => { + }); + +}); +ua.on('message', (message: SIP.Message) => {}); diff --git a/SIP.js/index.d.ts b/SIP.js/index.d.ts new file mode 100644 index 0000000000..0eaabb9b48 --- /dev/null +++ b/SIP.js/index.d.ts @@ -0,0 +1,354 @@ +// Type definitions for SIP.js v0.7.6 +// Project: https://sipjs.com/ +// Definitions by: Kir Dergachev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = SIP; + +declare namespace SIP { + + class URI { + constructor( + scheme?: string, + user?: string, + host?: string, + port?: number, + parameters?: string[], + headers?: string[]); + + scheme?: string; + user?: string; + host?: string; + port?: number; + + setParam(key: string, value?: string): void; + getParam(key: string): string; + hasParam(key: string): string; + deleteParam(key: string): string; + clearParams(): void; + setHeader(name: string, value: string): void; + getHeader(name: string): string[]; + hasHeader(name: string): boolean; + deleteHeader(name: string): string[]; + clearHeaders(): void; + clone(): URI; + toString(): string; + + static parse(uri: string): URI; + } + + namespace UA.EventArgs { + interface ConnectedArgs { attempts: number } + interface UnregisteredArgs { response: string; cause: string; } + interface RegistrationFailedArgs extends UnregisteredArgs { } + } + + class UA { + constructor(configuration?: ConfigurationParameters); + start(): void; + stop(): void; + register(options?: ExtraHeadersOptions): UA; + unregister(options?: UnregisterOptions): void; + isRegistered(): boolean; + isConnected(): boolean; + message(target: string | URI, body: string, options?: MessageOptions): Message; + subscribe(target: string | URI, event: string, options?: SubscribeOptions): Subscription; + invite(target: string | URI, options?: InviteOptions): Session; + invite(target: string | URI, element?: HTMLAudioElement | HTMLVideoElement): Session; + request(method: string, target: string | URI, options?: RequestOptions): ClientContext; + + on(name: 'connected', callback: (args: UA.EventArgs.ConnectedArgs) => void): void; + on(name: 'disconnected' | 'registered', callback: () => void): void; + on(name: 'unregistered', callback: (args: UA.EventArgs.UnregisteredArgs) => void): void; + on(name: 'registrationFailed', callback: (args: UA.EventArgs.RegistrationFailedArgs) => void): void; + on(name: 'invite', callback: (session: Session) => void): void; + on(name: 'message', callback: (message: Message) => void): void; + } + + namespace UA.C { + class supported { + REQUIRED: string; + SUPPORTED: string; + UNSUPPORTED: string; + } + + class causes { + INVALID_TARGET: string; + CONNECTION_ERROR: string; + REQUEST_TIMEOUT: string; + SIP_FAILURE_CODE: string; + } + } + + class Session { + startTime?: Date; + endTime?: Date; + ua?: UA; + method?: string; + mediaHandler?: WebRTC.MediaHandler; + request?: IncomingRequest | OutgoingRequest; + localIdentity?: NameAddrHeader; + remoteIdentity?: NameAddrHeader; + data: ClientContext | ServerContext; + + dtmf(tone: string | number, options?: Session.DtmfOptions): Session; + terminate(options?: Session.CommonOptions): Session; + bye(options?: Session.CommonOptions): Session; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + refer(target: string | Session, options?: ExtraHeadersOptions): Session; + mute(options?: ExtraHeadersOptions): void; + unmute(options?: ExtraHeadersOptions): void; + cancel(options?: Session.CommonOptions): void; + progress(options?: Session.ProgressOptions): void; + accept(options?: Session.AcceptOptions): void; + reject(options?: Session.CommonOptions): void; + reply(options?: Session.CommonOptions): void; + followRefer(callback: Function): void; + + on(name: 'progress', callback: (response: IncomingResponse) => void): void; + on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void; + on(name: 'rejected', callback: (response: IncomingResponse, cause: string) => void): void; + on(name: 'failed', callback: (response: IncomingResponse, cause: string) => void): void; + on(name: 'terminated', callback: (message: IncomingResponse, cause: string) => void): void; + on(name: 'refer', callback: (request: IncomingRequest) => void): void; + on(name: 'cancel', callback: () => void): void; + on(name: 'replaced', callback: (newSession: Session) => void): void; + on(name: 'dtmf', callback: (request: IncomingRequest, dtmf: Session.DTMF) => void): void; + on(name: 'muted', callback: (data: Session.Muted) => void): void; + on(name: 'unmuted', callback: (data: Session.Muted) => void): void; + on(name: 'bye', callback: (request: IncomingRequest) => void): void; + } + + namespace Session { + interface DtmfOptions extends ExtraHeadersOptions { + duration?: number; + interToneGap?: number; + } + + interface CommonOptions extends ExtraHeadersOptions { + status_code?: number; + reason_phrase?: string; + body?: string; + } + + interface ProgressOptions extends ExtraHeadersOptions { + rel100?: boolean; + media?: MediaConstraints; + } + + interface AcceptOptions { + RTCConstraints?: RTCPeerConnection; + media?: MediaOptions; + } + + interface DTMF { + } + + interface Muted { + audio?: boolean; + video?: boolean + } + } + + interface RenderHint { + remote?: Element; + local?: Element + } + + interface MediaConstraints { + audio: boolean; + video: boolean; + } + + interface TurnServer { + urls?: string | string[]; + username?: string; + password?: string; + } + + namespace WebRTC { + + interface Options { + stunServers?: string | string[]; + turnServers?: TurnServer | TurnServer[]; + RTCConstraints?: RTCPeerConnection; + } + + type MediaHandlerFactory = (session: Session, options: Options) => MediaHandler; + + class MediaHandler { + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + render(renderHint: RenderHint): void; + + on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void; + on(name: 'userMedia', callback: (stream: MediaStream) => void): void; + on(name: 'userMediaFailed', callback: (error: string) => void): void; + on(name: 'iceGathering', callback: () => void): void; + on(name: 'iceCandidate', callback: (candidate: RTCIceCandidate) => void): void; + on(name: 'iceGatheringComplete', callback: () => void): void; + on(name: 'iceConnection', callback: () => void): void; + on(name: 'iceConnectionChecking', callback: () => void): void; + on(name: 'iceConnectionConnected', callback: () => void): void; + on(name: 'iceConnectionCompleted', callback: () => void): void; + on(name: 'iceConnectionFailed', callback: () => void): void; + on(name: 'iceConnectionDisconnected', callback: () => void): void; + on(name: 'iceConnectionClosed', callback: () => void): void; + on(name: 'getDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; + on(name: 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; + on(name: 'dataChannel', callback: () => void): void; + on(name: 'addStream', callback: (stream: MediaStream) => void): void; + } + } + + /* Parameters */ + interface ConfigurationParameters { + uri?: string; + wsServers?: string | string[] | { ws_uri: string; weigth: number }[]; + allowLegacyNotifications?: boolean; + authenticationFactory?: WebRTC.MediaHandlerFactory; + authorizationUser?: string; + autostart?: boolean; + connectionRecoveryMaxInterval?: number; + connectionRecoveryMinInterval?: number; + displayName?: string; + hackCleanJitsiSdpImageattr?: boolean; + hackStripTcp?: boolean; + hackIpInContact?: boolean; + hackViaTcp?: boolean; + hackWssInTransport?: boolean; + iceCheckingTimeout?: number; + instanceId?: string; + log?: { + builtinEnabled?: boolean; + level?: number | string; + connector?: (level: string, category: string, label: string, content: string) => void; + }; + mediaHandlerFactory?: WebRTC.MediaHandlerFactory; + noAnswerTimeout?: number; + password?: string; + register?: boolean; + registerExpires?: number; + registrarServer?: string; + rel100?: string; + replaces?: string; + stunServers?: string | string[]; + traceSip?: boolean; + turnServers?: TurnServer | TurnServer[]; + usePreloadedRoute?: boolean; + userAgentString?: string; + wsServerMaxReconnection?: number; + wsServerReconnectionTimeout?: number; + } + + /* Options */ + interface ExtraHeadersOptions { + extraHeaders?: string[]; + } + + interface UnregisterOptions extends ExtraHeadersOptions { + all?: boolean; + } + + interface MessageOptions extends ExtraHeadersOptions { + contentType?: string; + } + + interface SubscribeOptions extends ExtraHeadersOptions { + expires?: number; + } + + interface MediaOptions { + constraints?: MediaConstraints; + stream?: MediaStream; + render?: RenderHint; + } + + interface InviteOptions extends ExtraHeadersOptions { + media?: MediaOptions; + anonymous?: boolean; + rel100?: string; + inviteWithoutSdp?: boolean; + RTCConstraints?: RTCPeerConnection; + } + + interface RequestOptions extends ExtraHeadersOptions { + body?: string; + } + + /* Contexts */ + interface Message extends ClientContext { + body: string; + } + + interface Subscription extends ClientContext { + id: string; + state: string; + event: string; + dialog: string; + timers: Object; + errorCodes: number[]; + subscribe(): Subscription; + unsubscribe(): void; + close(): void; + } + + /* Context */ + interface Context { + ua: UA; + method: string; + request: OutgoingRequest; + localIdentity: NameAddrHeader; + remoteIdentity: NameAddrHeader; + data: {}; + + on(name: 'progress', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'accepted', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'rejected', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'failed', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'notify', callback: (request: IncomingRequest) => void): void; + } + + interface ClientContext extends Context { + cancel(options?: { status_code?: number, reason_phrase?: string }): ClientContext; + } + + interface ServerContext extends Context { + progress(options?: Session.ProgressOptions): void; + accept(options?: Session.AcceptOptions): void; + reject(options?: Session.CommonOptions): void; + reply(options?: Session.CommonOptions): void; + } + + /* Request */ + interface Request extends Context { + } + + interface IncomingRequest extends Request { + } + + interface OutgoingRequest extends Request { + } + + interface IncomingResponse extends Request { + } + + interface IncomingMessage extends Request { + } + + /* Header */ + class NameAddrHeader { + constructor(uri: string | URI, displayName: string, parameters: { key: string, value: string }[]); + + uri: string | URI; + displayName: string; + + setParam(key: string, value?: string): void; + getParam(key: string): string; + deleteParam(key: string): string; + clearParams(): void; + + static parse(name_addr_header: string): NameAddrHeader; + } +} diff --git a/SIP.js/tsconfig.json b/SIP.js/tsconfig.json new file mode 100644 index 0000000000..93cce57ffb --- /dev/null +++ b/SIP.js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": ["webrtc"], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "SIP.js-tests.ts" + ] +} diff --git a/SIP.js/tslint.json b/SIP.js/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/SIP.js/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 3de4a245bdc0dab48b91b51c3937391d04ef2902 Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 12:14:28 +0300 Subject: [PATCH 02/43] Fixed package case --- {SIP.js => sip.js}/index.d.ts | 0 SIP.js/SIP.js-tests.ts => sip.js/sip.js-tests.ts | 0 {SIP.js => sip.js}/tsconfig.json | 2 +- {SIP.js => sip.js}/tslint.json | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename {SIP.js => sip.js}/index.d.ts (100%) rename SIP.js/SIP.js-tests.ts => sip.js/sip.js-tests.ts (100%) rename {SIP.js => sip.js}/tsconfig.json (94%) rename {SIP.js => sip.js}/tslint.json (100%) diff --git a/SIP.js/index.d.ts b/sip.js/index.d.ts similarity index 100% rename from SIP.js/index.d.ts rename to sip.js/index.d.ts diff --git a/SIP.js/SIP.js-tests.ts b/sip.js/sip.js-tests.ts similarity index 100% rename from SIP.js/SIP.js-tests.ts rename to sip.js/sip.js-tests.ts diff --git a/SIP.js/tsconfig.json b/sip.js/tsconfig.json similarity index 94% rename from SIP.js/tsconfig.json rename to sip.js/tsconfig.json index 93cce57ffb..8c84c6273e 100644 --- a/SIP.js/tsconfig.json +++ b/sip.js/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "SIP.js-tests.ts" + "sip.js-tests.ts" ] } diff --git a/SIP.js/tslint.json b/sip.js/tslint.json similarity index 100% rename from SIP.js/tslint.json rename to sip.js/tslint.json From f0f803116b25f321fca2755a4e6c96129e6c4a7a Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 12:52:59 +0300 Subject: [PATCH 03/43] Move references from tsconfig --- sip.js/index.d.ts | 2 ++ sip.js/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index 0eaabb9b48..3af04495c9 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + export = SIP; declare namespace SIP { diff --git a/sip.js/tsconfig.json b/sip.js/tsconfig.json index 8c84c6273e..b6532e5674 100644 --- a/sip.js/tsconfig.json +++ b/sip.js/tsconfig.json @@ -12,7 +12,7 @@ "typeRoots": [ "../" ], - "types": ["webrtc"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, From cb6ec66ca995549337896b3e38dc79a097b50c08 Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 13:22:30 +0300 Subject: [PATCH 04/43] Fix lint error --- sip.js/index.d.ts | 48 ++++++++++++++-------------------------------- sip.js/tslint.json | 7 ++++++- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index 3af04495c9..8c7a297613 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -40,7 +40,7 @@ declare namespace SIP { } namespace UA.EventArgs { - interface ConnectedArgs { attempts: number } + interface ConnectedArgs { attempts: number; } interface UnregisteredArgs { response: string; cause: string; } interface RegistrationFailedArgs extends UnregisteredArgs { } } @@ -55,8 +55,7 @@ declare namespace SIP { isConnected(): boolean; message(target: string | URI, body: string, options?: MessageOptions): Message; subscribe(target: string | URI, event: string, options?: SubscribeOptions): Subscription; - invite(target: string | URI, options?: InviteOptions): Session; - invite(target: string | URI, element?: HTMLAudioElement | HTMLVideoElement): Session; + invite(target: string | URI, element?: InviteOptions | HTMLAudioElement | HTMLVideoElement): Session; request(method: string, target: string | URI, options?: RequestOptions): ClientContext; on(name: 'connected', callback: (args: UA.EventArgs.ConnectedArgs) => void): void; @@ -110,16 +109,13 @@ declare namespace SIP { on(name: 'progress', callback: (response: IncomingResponse) => void): void; on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void; - on(name: 'rejected', callback: (response: IncomingResponse, cause: string) => void): void; - on(name: 'failed', callback: (response: IncomingResponse, cause: string) => void): void; + on(name: 'failed' | 'rejected', callback: (response: IncomingResponse, cause: string) => void): void; on(name: 'terminated', callback: (message: IncomingResponse, cause: string) => void): void; - on(name: 'refer', callback: (request: IncomingRequest) => void): void; on(name: 'cancel', callback: () => void): void; on(name: 'replaced', callback: (newSession: Session) => void): void; on(name: 'dtmf', callback: (request: IncomingRequest, dtmf: Session.DTMF) => void): void; - on(name: 'muted', callback: (data: Session.Muted) => void): void; - on(name: 'unmuted', callback: (data: Session.Muted) => void): void; - on(name: 'bye', callback: (request: IncomingRequest) => void): void; + on(name: 'muted' | 'unmuted', callback: (data: Session.Muted) => void): void; + on(name: 'refer' | 'bye', callback: (request: IncomingRequest) => void): void; } namespace Session { @@ -144,18 +140,17 @@ declare namespace SIP { media?: MediaOptions; } - interface DTMF { - } + interface DTMF extends Object {} interface Muted { audio?: boolean; - video?: boolean + video?: boolean; } } interface RenderHint { remote?: Element; - local?: Element + local?: Element; } interface MediaConstraints { @@ -185,29 +180,18 @@ declare namespace SIP { render(renderHint: RenderHint): void; on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void; - on(name: 'userMedia', callback: (stream: MediaStream) => void): void; + on(name: 'addStream' | 'userMedia', callback: (stream: MediaStream) => void): void; on(name: 'userMediaFailed', callback: (error: string) => void): void; - on(name: 'iceGathering', callback: () => void): void; on(name: 'iceCandidate', callback: (candidate: RTCIceCandidate) => void): void; - on(name: 'iceGatheringComplete', callback: () => void): void; - on(name: 'iceConnection', callback: () => void): void; - on(name: 'iceConnectionChecking', callback: () => void): void; - on(name: 'iceConnectionConnected', callback: () => void): void; - on(name: 'iceConnectionCompleted', callback: () => void): void; - on(name: 'iceConnectionFailed', callback: () => void): void; - on(name: 'iceConnectionDisconnected', callback: () => void): void; - on(name: 'iceConnectionClosed', callback: () => void): void; - on(name: 'getDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; - on(name: 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; - on(name: 'dataChannel', callback: () => void): void; - on(name: 'addStream', callback: (stream: MediaStream) => void): void; + on(name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | 'iceConnectionDisconnected' | 'iceConnectionClosed', callback: () => void): void; + on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; } } /* Parameters */ interface ConfigurationParameters { uri?: string; - wsServers?: string | string[] | { ws_uri: string; weigth: number }[]; + wsServers?: string | string[] | Array<{ ws_uri: string; weigth: number }>; allowLegacyNotifications?: boolean; authenticationFactory?: WebRTC.MediaHandlerFactory; authorizationUser?: string; @@ -304,11 +288,7 @@ declare namespace SIP { localIdentity: NameAddrHeader; remoteIdentity: NameAddrHeader; data: {}; - - on(name: 'progress', callback: (response: IncomingMessage, cause: string) => void): void; - on(name: 'accepted', callback: (response: IncomingMessage, cause: string) => void): void; - on(name: 'rejected', callback: (response: IncomingMessage, cause: string) => void): void; - on(name: 'failed', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'progress' | 'accepted' | 'rejected' | 'failed', callback: (response: IncomingMessage, cause: string) => void): void; on(name: 'notify', callback: (request: IncomingRequest) => void): void; } @@ -341,7 +321,7 @@ declare namespace SIP { /* Header */ class NameAddrHeader { - constructor(uri: string | URI, displayName: string, parameters: { key: string, value: string }[]); + constructor(uri: string | URI, displayName: string, parameters: Array<{ key: string, value: string }>); uri: string | URI; displayName: string; diff --git a/sip.js/tslint.json b/sip.js/tslint.json index 377cc837d4..105f5736e6 100644 --- a/sip.js/tslint.json +++ b/sip.js/tslint.json @@ -1 +1,6 @@ -{ "extends": "../tslint.json" } +{ + "extends": "../tslint.json", + "rules": { + "no-empty-interface": false + } +} From 2cc1c6e25dc4fd757dc98503f985678ebf4a21ef Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 13:58:52 +0300 Subject: [PATCH 05/43] Fix type definition test errors --- sip.js/index.d.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index 8c7a297613..a8d2b3c8db 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -1,13 +1,11 @@ -// Type definitions for SIP.js v0.7.6 +// Type definitions for SIP.js 0.7 // Project: https://sipjs.com/ // Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -export = SIP; - -declare namespace SIP { +export declare namespace SIP { class URI { constructor( @@ -105,7 +103,7 @@ declare namespace SIP { accept(options?: Session.AcceptOptions): void; reject(options?: Session.CommonOptions): void; reply(options?: Session.CommonOptions): void; - followRefer(callback: Function): void; + followRefer(callback: () => void): void; on(name: 'progress', callback: (response: IncomingResponse) => void): void; on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void; @@ -273,7 +271,7 @@ declare namespace SIP { state: string; event: string; dialog: string; - timers: Object; + timers: {}; errorCodes: number[]; subscribe(): Subscription; unsubscribe(): void; From 1c753b2c69e2df6a45a06cdfa2568a30f7d655ba Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 14:40:08 +0300 Subject: [PATCH 06/43] Fix tslint errors, configure rules --- sip.js/index.d.ts | 10 ++++++---- sip.js/tslint.json | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index a8d2b3c8db..942a0d22b3 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -1,11 +1,13 @@ -// Type definitions for SIP.js 0.7 -// Project: https://sipjs.com/ -// Definitions by: Kir Dergachev +// Type definitions for sip.js 0.7 +// Project: http://sipjs.com +// Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -export declare namespace SIP { +export = SIP; + +declare namespace SIP { class URI { constructor( diff --git a/sip.js/tslint.json b/sip.js/tslint.json index 105f5736e6..c78c443ad2 100644 --- a/sip.js/tslint.json +++ b/sip.js/tslint.json @@ -1,6 +1,7 @@ { "extends": "../tslint.json", "rules": { - "no-empty-interface": false + "no-empty-interface": false, + "export-just-namespace": false } } From d2be90a50693461d0e2e4dd20c3d578533a779db Mon Sep 17 00:00:00 2001 From: mkollers Date: Mon, 23 Jan 2017 10:26:59 +0100 Subject: [PATCH 07/43] added group to Node http://visjs.org/docs/network/nodes.html# --- vis/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/vis/index.d.ts b/vis/index.d.ts index 92b6ea6a08..3ee00ba03a 100644 --- a/vis/index.d.ts +++ b/vis/index.d.ts @@ -1497,6 +1497,7 @@ export interface Data { } export interface Node { + group?: string; id?: IdType; label?: string; x?: number; From ff113b3b1cfb2b7c98e2efd6e10ddb04d43bc031 Mon Sep 17 00:00:00 2001 From: darlin Date: Mon, 23 Jan 2017 20:14:41 +0800 Subject: [PATCH 08/43] add sub module export --- crypto-js/index.d.ts | 237 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 234 insertions(+), 3 deletions(-) diff --git a/crypto-js/index.d.ts b/crypto-js/index.d.ts index 5fdf193254..a2c0ee381d 100644 --- a/crypto-js/index.d.ts +++ b/crypto-js/index.d.ts @@ -3,9 +3,6 @@ // Definitions by: Michael Zabka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = CryptoJS; -export as namespace CryptoJS; - declare var CryptoJS: CryptoJS.Hashes; declare namespace CryptoJS { type Hash = (message: string, key?: string, ...options: any[]) => string; @@ -113,5 +110,239 @@ declare namespace CryptoJS { NoPadding: Padding; }; } + } +declare module "crypto-js" { + var CryptoJS: CryptoJS.Hashes; + export = CryptoJS; +} + +/* --------------------------------- */ +declare module "crypto-js/core" { + var core: any; + export = core; +} + +declare module "crypto-js/x64-core" { + var x64: any; + export = x64; +} + +declare module "crypto-js/lib-typedarrays" { + var libWordArray: any; + export = libWordArray; +} + +/* --------------------------------- */ +declare module "crypto-js/md5" { + var MD5: CryptoJS.Hash; + export = MD5; +} + +declare module "crypto-js/sha1" { + var SHA1: CryptoJS.Hash; + export = SHA1; +} + +declare module "crypto-js/sha256" { + var SHA256: CryptoJS.Hash; + export = SHA256; +} + +declare module "crypto-js/sha224" { + var SHA224: CryptoJS.Hash; + export = SHA224; +} + +declare module "crypto-js/sha512" { + var SHA512: CryptoJS.Hash; + export = SHA512; +} + +declare module "crypto-js/sha384" { + var SHA384: CryptoJS.Hash; + export = SHA384; +} + +declare module "crypto-js/sha3" { + var SHA3: CryptoJS.Hash; + export = SHA3; +} + +declare module "crypto-js/ripemd160" { + var RIPEMD160: CryptoJS.Hash; + export = RIPEMD160; +} + +/* --------------------------------- */ +declare module "crypto-js/hmac-md5" { + var HmacMD5: CryptoJS.Hash; + export = HmacMD5; +} + +declare module "crypto-js/hmac-sha1" { + var HmacSHA1: CryptoJS.Hash; + export = HmacSHA1; +} + +declare module "crypto-js/hmac-sha256" { + var HmacSHA256: CryptoJS.Hash; + export = HmacSHA256; +} + +declare module "crypto-js/hmac-sha224" { + var HmacSHA224: CryptoJS.Hash; + export = HmacSHA224; +} + +declare module "crypto-js/hmac-sha512" { + var HmacSHA512: CryptoJS.Hash; + export = HmacSHA512; +} + +declare module "crypto-js/hmac-sha384" { + var HmacSHA384: CryptoJS.Hash; + export = HmacSHA384; +} + +declare module "crypto-js/hmac-sha3" { + var HmacSHA3: CryptoJS.Hash; + export = HmacSHA3; +} + +declare module "crypto-js/hmac-ripemd160" { + var HmacRIPEMD160: CryptoJS.Hash; + export = HmacRIPEMD160; +} + +/* --------------------------------- */ +declare module "crypto-js/pbkdf2" { + var PBKDF2: CryptoJS.Hash; + export = PBKDF2; +} + +/* --------------------------------- */ +declare module "crypto-js/aes" { + var AES: CryptoJS.Cipher; + export = AES; +} + +declare module "crypto-js/tripledes" { + var TripleDES: CryptoJS.Cipher; + export = TripleDES; +} + +declare module "crypto-js/rc4" { + var RC4: CryptoJS.Cipher; + export = RC4; +} + +declare module "crypto-js/rabbit" { + var Rabbit: CryptoJS.Cipher; + export = Rabbit; +} + +declare module "crypto-js/rabbit-legacy" { + var RabbitLegacy: CryptoJS.Cipher; + export = RabbitLegacy; +} + +declare module "crypto-js/evpkdf" { + var EvpKDF: CryptoJS.Cipher; + export = EvpKDF; +} + +/* --------------------------------- */ +declare module "crypto-js/format-openssl" { + var FormatOpenssl: any; + export = FormatOpenssl; +} + +declare module "crypto-js/format-hex" { + var FormatHex: any; + export = FormatHex; +} + +/* --------------------------------- */ +declare module "crypto-js/enc-latin1" { + var encLatin1: CryptoJS.Encoder; + export = encLatin1; +} + +declare module "crypto-js/enc-utf8" { + var encUtf8: CryptoJS.Encoder; + export = encUtf8; +} + +declare module "crypto-js/enc-hex" { + var encHex: CryptoJS.Encoder; + export = encHex; +} + +declare module "crypto-js/enc-utf16" { + var encUtf16: CryptoJS.Encoder; + export = encUtf16; +} + +declare module "crypto-js/enc-base64" { + var encBase64: CryptoJS.Encoder; + export = encBase64; +} + +/* --------------------------------- */ +declare module "crypto-js/mode-cfb" { + var modeCFB: CryptoJS.Mode; + export = modeCFB; +} + +declare module "crypto-js/mode-ctr" { + var modeCTR: CryptoJS.Mode; + export = modeCTR; +} + +declare module "crypto-js/mode-ctr-gladman" { + var modeCTRGladman: CryptoJS.Mode; + export = modeCTRGladman; +} + +declare module "crypto-js/mode-ofb" { + var modeOFB: CryptoJS.Mode; + export = modeOFB; +} + +declare module "crypto-js/mode-ecb" { + var modeECB: CryptoJS.Mode; + export = modeECB; +} + +/* --------------------------------- */ +declare module "crypto-js/pad-pkcs7" { + var padPkcs7: CryptoJS.Padding; + export = padPkcs7; +} + +declare module "crypto-js/pad-ansix923" { + var padAnsiX923: CryptoJS.Padding; + export = padAnsiX923; +} + +declare module "crypto-js/pad-iso10126" { + var padIso10126: CryptoJS.Padding; + export = padIso10126; +} + +declare module "crypto-js/pad-iso97971" { + var padIso97971: CryptoJS.Padding; + export = padIso97971; +} + +declare module "crypto-js/pad-zeropadding" { + var padZeroPadding: CryptoJS.Padding; + export = padZeroPadding; +} + +declare module "crypto-js/pad-nopadding" { + var padNoPadding: CryptoJS.Padding; + export = padNoPadding; +} From fc6a9729df46769b7a50cffe4414dc913ba6da28 Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Mon, 23 Jan 2017 16:14:33 +0300 Subject: [PATCH 09/43] Fixes errors references. Removes references to webrtc --- sip.js/index.d.ts | 68 ++++++++++++++++++++---------------------- sip.js/sip.js-tests.ts | 36 +++++++++++----------- sip.js/tslint.json | 3 +- 3 files changed, 51 insertions(+), 56 deletions(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index 942a0d22b3..be01cd3682 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -3,21 +3,23 @@ // Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +declare interface SIP { + UA: { + new (configuration?: sipjs.ConfigurationParameters): sipjs.UA; + }; + URI: { + new (scheme?: string, user?: string, host?: string, port?: number, parameters?: string[], headers?: string[]): sipjs.URI; + parse(uri: string): sipjs.URI; + }; + NameAddrHeader: { + new (uri: string | sipjs.URI, displayName: string, parameters: Array<{ key: string, value: string }>): sipjs.NameAddrHeader; + parse(name_addr_header: string): sipjs.NameAddrHeader; + }; +} -export = SIP; - -declare namespace SIP { - - class URI { - constructor( - scheme?: string, - user?: string, - host?: string, - port?: number, - parameters?: string[], - headers?: string[]); +declare namespace sipjs { + interface URI { scheme?: string; user?: string; host?: string; @@ -35,8 +37,6 @@ declare namespace SIP { clearHeaders(): void; clone(): URI; toString(): string; - - static parse(uri: string): URI; } namespace UA.EventArgs { @@ -45,8 +45,7 @@ declare namespace SIP { interface RegistrationFailedArgs extends UnregisteredArgs { } } - class UA { - constructor(configuration?: ConfigurationParameters); + interface UA { start(): void; stop(): void; register(options?: ExtraHeadersOptions): UA; @@ -59,7 +58,7 @@ declare namespace SIP { request(method: string, target: string | URI, options?: RequestOptions): ClientContext; on(name: 'connected', callback: (args: UA.EventArgs.ConnectedArgs) => void): void; - on(name: 'disconnected' | 'registered', callback: () => void): void; + on(name: 'disconnected' | 'registered' | string, callback: () => void): void; on(name: 'unregistered', callback: (args: UA.EventArgs.UnregisteredArgs) => void): void; on(name: 'registrationFailed', callback: (args: UA.EventArgs.RegistrationFailedArgs) => void): void; on(name: 'invite', callback: (session: Session) => void): void; @@ -81,7 +80,7 @@ declare namespace SIP { } } - class Session { + interface Session { startTime?: Date; endTime?: Date; ua?: UA; @@ -95,8 +94,8 @@ declare namespace SIP { dtmf(tone: string | number, options?: Session.DtmfOptions): Session; terminate(options?: Session.CommonOptions): Session; bye(options?: Session.CommonOptions): Session; - getLocalStreams(): MediaStream[]; - getRemoteStreams(): MediaStream[]; + getLocalStreams(): any[]; + getRemoteStreams(): any[]; refer(target: string | Session, options?: ExtraHeadersOptions): Session; mute(options?: ExtraHeadersOptions): void; unmute(options?: ExtraHeadersOptions): void; @@ -111,7 +110,7 @@ declare namespace SIP { on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void; on(name: 'failed' | 'rejected', callback: (response: IncomingResponse, cause: string) => void): void; on(name: 'terminated', callback: (message: IncomingResponse, cause: string) => void): void; - on(name: 'cancel', callback: () => void): void; + on(name: 'cancel' | string, callback: () => void): void; on(name: 'replaced', callback: (newSession: Session) => void): void; on(name: 'dtmf', callback: (request: IncomingRequest, dtmf: Session.DTMF) => void): void; on(name: 'muted' | 'unmuted', callback: (data: Session.Muted) => void): void; @@ -136,7 +135,7 @@ declare namespace SIP { } interface AcceptOptions { - RTCConstraints?: RTCPeerConnection; + RTCConstraints?: any; media?: MediaOptions; } @@ -169,21 +168,21 @@ declare namespace SIP { interface Options { stunServers?: string | string[]; turnServers?: TurnServer | TurnServer[]; - RTCConstraints?: RTCPeerConnection; + RTCConstraints?: any; } type MediaHandlerFactory = (session: Session, options: Options) => MediaHandler; class MediaHandler { - getLocalStreams(): MediaStream[]; - getRemoteStreams(): MediaStream[]; + getLocalStreams(): any[]; + getRemoteStreams(): any[]; render(renderHint: RenderHint): void; on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void; - on(name: 'addStream' | 'userMedia', callback: (stream: MediaStream) => void): void; + on(name: 'addStream' | 'userMedia', callback: (stream: any) => void): void; on(name: 'userMediaFailed', callback: (error: string) => void): void; - on(name: 'iceCandidate', callback: (candidate: RTCIceCandidate) => void): void; - on(name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | 'iceConnectionDisconnected' | 'iceConnectionClosed', callback: () => void): void; + on(name: 'iceCandidate', callback: (candidate: any) => void): void; + on(name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | 'iceConnectionDisconnected' | 'iceConnectionClosed' | string, callback: () => void): void; on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; } } @@ -247,7 +246,7 @@ declare namespace SIP { interface MediaOptions { constraints?: MediaConstraints; - stream?: MediaStream; + stream?: any; render?: RenderHint; } @@ -256,7 +255,7 @@ declare namespace SIP { anonymous?: boolean; rel100?: string; inviteWithoutSdp?: boolean; - RTCConstraints?: RTCPeerConnection; + RTCConstraints?: any; } interface RequestOptions extends ExtraHeadersOptions { @@ -290,6 +289,7 @@ declare namespace SIP { data: {}; on(name: 'progress' | 'accepted' | 'rejected' | 'failed', callback: (response: IncomingMessage, cause: string) => void): void; on(name: 'notify', callback: (request: IncomingRequest) => void): void; + on(name: string, callback: () => void): void; } interface ClientContext extends Context { @@ -320,9 +320,7 @@ declare namespace SIP { } /* Header */ - class NameAddrHeader { - constructor(uri: string | URI, displayName: string, parameters: Array<{ key: string, value: string }>); - + interface NameAddrHeader { uri: string | URI; displayName: string; @@ -330,7 +328,5 @@ declare namespace SIP { getParam(key: string): string; deleteParam(key: string): string; clearParams(): void; - - static parse(name_addr_header: string): NameAddrHeader; } } diff --git a/sip.js/sip.js-tests.ts b/sip.js/sip.js-tests.ts index f688fe67ae..524caf1827 100644 --- a/sip.js/sip.js-tests.ts +++ b/sip.js/sip.js-tests.ts @@ -1,11 +1,11 @@ -import SIP = require("./index"); +declare var sip: SIP; -let ua: SIP.UA = new SIP.UA(); +let ua: sipjs.UA = new sip.UA(); -const mediaHandler = (session: SIP.Session, options: SIP.WebRTC.Options) => new SIP.WebRTC.MediaHandler(); +const mediaHandler = (session: sipjs.Session, options: sipjs.WebRTC.Options) => new sipjs.WebRTC.MediaHandler(); const logConnector = (level: string, category: string, label: string, content: string) => null; -const uaWithConfig: SIP.UA = new SIP.UA({ +const uaWithConfig: sipjs.UA = new sip.UA({ uri: "wss://uri", wsServers: ["s1", "s2"], allowLegacyNotifications: true, @@ -38,7 +38,7 @@ const uaWithConfig: SIP.UA = new SIP.UA({ stunServers: ["", ""], turnServers: [ { - password: "", + password: "", username: "", urls: ["", ""] } @@ -61,15 +61,15 @@ ua.unregister({ extraHeaders: [""], all: true }); const isConnected: boolean = ua.isConnected(); const isRegistered: boolean = ua.isRegistered(); -const message: SIP.Message = ua.message("", "", { contentType: "" }); +const message: sipjs.Message = ua.message("", "", { contentType: "" }); -ua.subscribe("", "", { expires: 1, extraHeaders: [""]}); -const subscription: SIP.Subscription = ua.subscribe(new SIP.URI(), "", { expires: 1, extraHeaders: [""]}); +ua.subscribe("", "", { expires: 1, extraHeaders: [""] }); +const subscription: sipjs.Subscription = ua.subscribe(new sip.URI(), "", { expires: 1, extraHeaders: [""] }); let session = ua.invite("", new HTMLVideoElement()); -const inviteOptions: SIP.InviteOptions = { - media: { +const inviteOptions: sipjs.InviteOptions = { + media: { constraints: { audio: true, video: false }, stream: new MediaStream(), render: { remote: new Element(), local: new Element() }, @@ -77,17 +77,17 @@ const inviteOptions: SIP.InviteOptions = { anonymous: true, rel100: "", inviteWithoutSdp: true, - RTCConstraints: new RTCPeerConnection() + RTCConstraints: {} } session = ua.invite("", inviteOptions); -ua.on('connected', (args: SIP.UA.EventArgs.ConnectedArgs) => {}); -ua.on('disconnected', () => {}); -ua.on('registered', () => {}); -ua.on('unregistered', (args: SIP.UA.EventArgs.UnregisteredArgs) => {}); -ua.on('registrationFailed', (args: SIP.UA.EventArgs.RegistrationFailedArgs) => {}); -ua.on('invite', (session: SIP.Session) => { +ua.on('connected', (args: sipjs.UA.EventArgs.ConnectedArgs) => { }); +ua.on('disconnected', () => { }); +ua.on('registered', () => { }); +ua.on('unregistered', (args: sipjs.UA.EventArgs.UnregisteredArgs) => { }); +ua.on('registrationFailed', (args: sipjs.UA.EventArgs.RegistrationFailedArgs) => { }); +ua.on('invite', (session: sipjs.Session) => { session.on('progress', (response) => { }); session.on('accepted', (response) => { @@ -96,4 +96,4 @@ ua.on('invite', (session: SIP.Session) => { }); }); -ua.on('message', (message: SIP.Message) => {}); +ua.on('message', (message: sipjs.Message) => { }); diff --git a/sip.js/tslint.json b/sip.js/tslint.json index c78c443ad2..105f5736e6 100644 --- a/sip.js/tslint.json +++ b/sip.js/tslint.json @@ -1,7 +1,6 @@ { "extends": "../tslint.json", "rules": { - "no-empty-interface": false, - "export-just-namespace": false + "no-empty-interface": false } } From a6e94fdb0a80fbeacea1786d60cc0a67deaf9d6b Mon Sep 17 00:00:00 2001 From: Shun Date: Tue, 24 Jan 2017 21:54:20 -0800 Subject: [PATCH 10/43] Add module --- forever-monitor/forever-monitor-tests.ts | 0 forever-monitor/index.d.ts | 104 +++++++++++++++++++++++ forever-monitor/tsconfig.json | 20 +++++ forever-monitor/tslint.json | 1 + 4 files changed, 125 insertions(+) create mode 100644 forever-monitor/forever-monitor-tests.ts create mode 100644 forever-monitor/index.d.ts create mode 100644 forever-monitor/tsconfig.json create mode 100644 forever-monitor/tslint.json diff --git a/forever-monitor/forever-monitor-tests.ts b/forever-monitor/forever-monitor-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/forever-monitor/index.d.ts b/forever-monitor/index.d.ts new file mode 100644 index 0000000000..b22905cae2 --- /dev/null +++ b/forever-monitor/index.d.ts @@ -0,0 +1,104 @@ +// Type definitions for forever-monitor 1.7 +// Project: https://github.com/nodejitsu/forever-monitor#readme +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +interface spawnWith { + customFds: number[]; + setsid: boolean; + uid: number; + gid: number; +} + +interface parserArgs { + command: string; + args: string[]; +} + +interface Options { + silent?: boolean; + uid?: "autogen" | string; + pidFile?: string; + max?: number; + killTree?: boolean; + minUptime?: number; + spinSleepTime?: number; + command?: "node" | string; + args?: string[]; + sourceDir?: string; + watch?: boolean; + watchIgnoreDotFiles?: boolean; + watchIgnorePatters?: string[]; + watchDirectory?: string; + spawnWith?: spawnWith; + env?: { [envKey: string]: string; }; + cwd?: string; + logFile?: string; + outFile?: string; + errFile?: string; + parser?: (command: string, args: string[]) => { command: string, args: string[] }; +} + + +export declare class Monitor extends NodeJS.EventEmitter { + + /** + * @param script - Location of the target script to run. + * @param [options] - Configuration for this instance. + */ + constructor(script: string, options?: Options); + + /** + * @description Start the process that this instance is configured for + * @param [restart] - Value indicating whether this is a restart. + */ + public start(restart?: boolean): this; + + /** + * @description Tries to spawn the target Forever child process. + */ + public trySpawn(): boolean; + + /** + * @description Restarts the target script associated with this instance. + */ + public restart(): this; + + /** + * @description Stops the target script associated with this instance. Prevents it from auto-respawning + */ + public stop(): this; + + /** + * @description Kills the ChildProcess object associated with this instance + * @param [forceStop] - Value indicating whether short circuit forever auto-restart + */ + public kill(forceStop?: boolean): this; + + /** + * @description Sends a message to a forked ChildProcess object associated with this instance + */ + public send(msg?: any): this; + + /** + * respond with JSON for this instance + */ + public toString(): string; + + /** + * @param command - Command string to parse + * @param args - Additional default arguments + */ + public parseCommand(command: string, args?: string[]): (false | { command: string, args?: string[]}); +} + +interface forever { + Monitor: Monitor; + start: (script: string, options: Options) => Monitor; + kill: (pid: number, killTree?: boolean, signal?: string, callback?: () => any) => void; + checkProcess: (pid: number) => boolean; + version: string; +} + +export default forever; diff --git a/forever-monitor/tsconfig.json b/forever-monitor/tsconfig.json new file mode 100644 index 0000000000..8c6d4986b5 --- /dev/null +++ b/forever-monitor/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "forever-monitor-tests.ts" + ] +} diff --git a/forever-monitor/tslint.json b/forever-monitor/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/forever-monitor/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 1ca0a1b3f98ad5ce8713543791b97014d5250bd6 Mon Sep 17 00:00:00 2001 From: darlin Date: Wed, 25 Jan 2017 14:26:11 +0800 Subject: [PATCH 11/43] update submodule --- crypto-js/aes/index.d.ts | 3 + crypto-js/core/index.d.ts | 3 + crypto-js/enc-base64/index.d.ts | 4 + crypto-js/enc-hex/index.d.ts | 4 + crypto-js/enc-latin1/index.d.ts | 4 + crypto-js/enc-utf16/index.d.ts | 4 + crypto-js/enc-utf8/index.d.ts | 4 + crypto-js/evpkdf/index.d.ts | 3 + crypto-js/format-hex/index.d.ts | 4 + crypto-js/format-openssl/index.d.ts | 4 + crypto-js/hmac-md5/index.d.ts | 3 + crypto-js/hmac-ripemd160/index.d.ts | 3 + crypto-js/hmac-sha1/index.d.ts | 3 + crypto-js/hmac-sha224/index.d.ts | 3 + crypto-js/hmac-sha256/index.d.ts | 3 + crypto-js/hmac-sha3/index.d.ts | 3 + crypto-js/hmac-sha384/index.d.ts | 3 + crypto-js/hmac-sha512/index.d.ts | 3 + crypto-js/index.d.ts | 237 +------------------------- crypto-js/lib-typedarrays/index.d.ts | 2 + crypto-js/md5/index.d.ts | 3 + crypto-js/mode-cfb/index.d.ts | 4 + crypto-js/mode-ctr-gladman/index.d.ts | 4 + crypto-js/mode-ctr/index.d.ts | 4 + crypto-js/mode-ecb/index.d.ts | 4 + crypto-js/mode-ofb/index.d.ts | 4 + crypto-js/pad-ansix923/index.d.ts | 4 + crypto-js/pad-iso10126/index.d.ts | 4 + crypto-js/pad-iso97971/index.d.ts | 4 + crypto-js/pad-nopadding/index.d.ts | 4 + crypto-js/pad-pkcs7/index.d.ts | 4 + crypto-js/pad-zeropadding/index.d.ts | 4 + crypto-js/pbkdf2/index.d.ts | 3 + crypto-js/rabbit-legacy/index.d.ts | 3 + crypto-js/rabbit/index.d.ts | 3 + crypto-js/rc4/index.d.ts | 3 + crypto-js/ripemd160/index.d.ts | 3 + crypto-js/sha1/index.d.ts | 3 + crypto-js/sha224/index.d.ts | 3 + crypto-js/sha256/index.d.ts | 3 + crypto-js/sha3/index.d.ts | 3 + crypto-js/sha384/index.d.ts | 3 + crypto-js/sha512/index.d.ts | 3 + crypto-js/tripledes/index.d.ts | 3 + crypto-js/x64-core/index.d.ts | 3 + 45 files changed, 152 insertions(+), 234 deletions(-) create mode 100644 crypto-js/aes/index.d.ts create mode 100644 crypto-js/core/index.d.ts create mode 100644 crypto-js/enc-base64/index.d.ts create mode 100644 crypto-js/enc-hex/index.d.ts create mode 100644 crypto-js/enc-latin1/index.d.ts create mode 100644 crypto-js/enc-utf16/index.d.ts create mode 100644 crypto-js/enc-utf8/index.d.ts create mode 100644 crypto-js/evpkdf/index.d.ts create mode 100644 crypto-js/format-hex/index.d.ts create mode 100644 crypto-js/format-openssl/index.d.ts create mode 100644 crypto-js/hmac-md5/index.d.ts create mode 100644 crypto-js/hmac-ripemd160/index.d.ts create mode 100644 crypto-js/hmac-sha1/index.d.ts create mode 100644 crypto-js/hmac-sha224/index.d.ts create mode 100644 crypto-js/hmac-sha256/index.d.ts create mode 100644 crypto-js/hmac-sha3/index.d.ts create mode 100644 crypto-js/hmac-sha384/index.d.ts create mode 100644 crypto-js/hmac-sha512/index.d.ts create mode 100644 crypto-js/lib-typedarrays/index.d.ts create mode 100644 crypto-js/md5/index.d.ts create mode 100644 crypto-js/mode-cfb/index.d.ts create mode 100644 crypto-js/mode-ctr-gladman/index.d.ts create mode 100644 crypto-js/mode-ctr/index.d.ts create mode 100644 crypto-js/mode-ecb/index.d.ts create mode 100644 crypto-js/mode-ofb/index.d.ts create mode 100644 crypto-js/pad-ansix923/index.d.ts create mode 100644 crypto-js/pad-iso10126/index.d.ts create mode 100644 crypto-js/pad-iso97971/index.d.ts create mode 100644 crypto-js/pad-nopadding/index.d.ts create mode 100644 crypto-js/pad-pkcs7/index.d.ts create mode 100644 crypto-js/pad-zeropadding/index.d.ts create mode 100644 crypto-js/pbkdf2/index.d.ts create mode 100644 crypto-js/rabbit-legacy/index.d.ts create mode 100644 crypto-js/rabbit/index.d.ts create mode 100644 crypto-js/rc4/index.d.ts create mode 100644 crypto-js/ripemd160/index.d.ts create mode 100644 crypto-js/sha1/index.d.ts create mode 100644 crypto-js/sha224/index.d.ts create mode 100644 crypto-js/sha256/index.d.ts create mode 100644 crypto-js/sha3/index.d.ts create mode 100644 crypto-js/sha384/index.d.ts create mode 100644 crypto-js/sha512/index.d.ts create mode 100644 crypto-js/tripledes/index.d.ts create mode 100644 crypto-js/x64-core/index.d.ts diff --git a/crypto-js/aes/index.d.ts b/crypto-js/aes/index.d.ts new file mode 100644 index 0000000000..4f435688c5 --- /dev/null +++ b/crypto-js/aes/index.d.ts @@ -0,0 +1,3 @@ +import { AES } from '../index'; + +export = AES; diff --git a/crypto-js/core/index.d.ts b/crypto-js/core/index.d.ts new file mode 100644 index 0000000000..c5d6e00410 --- /dev/null +++ b/crypto-js/core/index.d.ts @@ -0,0 +1,3 @@ +import * as Core from '../index'; + +export = Core; diff --git a/crypto-js/enc-base64/index.d.ts b/crypto-js/enc-base64/index.d.ts new file mode 100644 index 0000000000..55001a7115 --- /dev/null +++ b/crypto-js/enc-base64/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Base64: typeof enc.Base64; +export = Base64; diff --git a/crypto-js/enc-hex/index.d.ts b/crypto-js/enc-hex/index.d.ts new file mode 100644 index 0000000000..3718860123 --- /dev/null +++ b/crypto-js/enc-hex/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Hex: typeof enc.Hex; +export = Hex; diff --git a/crypto-js/enc-latin1/index.d.ts b/crypto-js/enc-latin1/index.d.ts new file mode 100644 index 0000000000..7f27822daf --- /dev/null +++ b/crypto-js/enc-latin1/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Latin1: typeof enc.Latin1; +export = Latin1; diff --git a/crypto-js/enc-utf16/index.d.ts b/crypto-js/enc-utf16/index.d.ts new file mode 100644 index 0000000000..76fa98774a --- /dev/null +++ b/crypto-js/enc-utf16/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Utf16: typeof enc.Utf16; +export = Utf16; diff --git a/crypto-js/enc-utf8/index.d.ts b/crypto-js/enc-utf8/index.d.ts new file mode 100644 index 0000000000..828dcb9391 --- /dev/null +++ b/crypto-js/enc-utf8/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Utf8: typeof enc.Utf8; +export = Utf8; diff --git a/crypto-js/evpkdf/index.d.ts b/crypto-js/evpkdf/index.d.ts new file mode 100644 index 0000000000..8946b9d3a1 --- /dev/null +++ b/crypto-js/evpkdf/index.d.ts @@ -0,0 +1,3 @@ +import { EvpKDF } from '../index'; + +export = EvpKDF; diff --git a/crypto-js/format-hex/index.d.ts b/crypto-js/format-hex/index.d.ts new file mode 100644 index 0000000000..1b0f573824 --- /dev/null +++ b/crypto-js/format-hex/index.d.ts @@ -0,0 +1,4 @@ +import { format } from '../index'; + +declare const Hex: typeof format.Hex; +export = Hex; diff --git a/crypto-js/format-openssl/index.d.ts b/crypto-js/format-openssl/index.d.ts new file mode 100644 index 0000000000..02c35a3688 --- /dev/null +++ b/crypto-js/format-openssl/index.d.ts @@ -0,0 +1,4 @@ +import { format } from '../index'; + +declare const OpenSSL: typeof format.OpenSSL; +export = OpenSSL; diff --git a/crypto-js/hmac-md5/index.d.ts b/crypto-js/hmac-md5/index.d.ts new file mode 100644 index 0000000000..7240576710 --- /dev/null +++ b/crypto-js/hmac-md5/index.d.ts @@ -0,0 +1,3 @@ +import { HmacMD5 } from '../index'; + +export = HmacMD5; diff --git a/crypto-js/hmac-ripemd160/index.d.ts b/crypto-js/hmac-ripemd160/index.d.ts new file mode 100644 index 0000000000..6c371e9435 --- /dev/null +++ b/crypto-js/hmac-ripemd160/index.d.ts @@ -0,0 +1,3 @@ +import { HmacRIPEMD160 } from '../index'; + +export = HmacRIPEMD160; diff --git a/crypto-js/hmac-sha1/index.d.ts b/crypto-js/hmac-sha1/index.d.ts new file mode 100644 index 0000000000..1995cf87f6 --- /dev/null +++ b/crypto-js/hmac-sha1/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA1 } from '../index'; + +export = HmacSHA1; diff --git a/crypto-js/hmac-sha224/index.d.ts b/crypto-js/hmac-sha224/index.d.ts new file mode 100644 index 0000000000..f25334c64c --- /dev/null +++ b/crypto-js/hmac-sha224/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA224 } from '../index'; + +export = HmacSHA224; diff --git a/crypto-js/hmac-sha256/index.d.ts b/crypto-js/hmac-sha256/index.d.ts new file mode 100644 index 0000000000..ca1a1ca267 --- /dev/null +++ b/crypto-js/hmac-sha256/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA256 } from '../index'; + +export = HmacSHA256; diff --git a/crypto-js/hmac-sha3/index.d.ts b/crypto-js/hmac-sha3/index.d.ts new file mode 100644 index 0000000000..0fa0db9321 --- /dev/null +++ b/crypto-js/hmac-sha3/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA3 } from '../index'; + +export = HmacSHA3; diff --git a/crypto-js/hmac-sha384/index.d.ts b/crypto-js/hmac-sha384/index.d.ts new file mode 100644 index 0000000000..2e17420c1b --- /dev/null +++ b/crypto-js/hmac-sha384/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA384 } from '../index'; + +export = HmacSHA384; diff --git a/crypto-js/hmac-sha512/index.d.ts b/crypto-js/hmac-sha512/index.d.ts new file mode 100644 index 0000000000..439b2ffd5e --- /dev/null +++ b/crypto-js/hmac-sha512/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA512 } from '../index'; + +export = HmacSHA512; diff --git a/crypto-js/index.d.ts b/crypto-js/index.d.ts index a2c0ee381d..a8068161e1 100644 --- a/crypto-js/index.d.ts +++ b/crypto-js/index.d.ts @@ -3,6 +3,9 @@ // Definitions by: Michael Zabka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = CryptoJS; +export as namespace CryptoJS; + declare var CryptoJS: CryptoJS.Hashes; declare namespace CryptoJS { type Hash = (message: string, key?: string, ...options: any[]) => string; @@ -112,237 +115,3 @@ declare namespace CryptoJS { } } - -declare module "crypto-js" { - var CryptoJS: CryptoJS.Hashes; - export = CryptoJS; -} - -/* --------------------------------- */ -declare module "crypto-js/core" { - var core: any; - export = core; -} - -declare module "crypto-js/x64-core" { - var x64: any; - export = x64; -} - -declare module "crypto-js/lib-typedarrays" { - var libWordArray: any; - export = libWordArray; -} - -/* --------------------------------- */ -declare module "crypto-js/md5" { - var MD5: CryptoJS.Hash; - export = MD5; -} - -declare module "crypto-js/sha1" { - var SHA1: CryptoJS.Hash; - export = SHA1; -} - -declare module "crypto-js/sha256" { - var SHA256: CryptoJS.Hash; - export = SHA256; -} - -declare module "crypto-js/sha224" { - var SHA224: CryptoJS.Hash; - export = SHA224; -} - -declare module "crypto-js/sha512" { - var SHA512: CryptoJS.Hash; - export = SHA512; -} - -declare module "crypto-js/sha384" { - var SHA384: CryptoJS.Hash; - export = SHA384; -} - -declare module "crypto-js/sha3" { - var SHA3: CryptoJS.Hash; - export = SHA3; -} - -declare module "crypto-js/ripemd160" { - var RIPEMD160: CryptoJS.Hash; - export = RIPEMD160; -} - -/* --------------------------------- */ -declare module "crypto-js/hmac-md5" { - var HmacMD5: CryptoJS.Hash; - export = HmacMD5; -} - -declare module "crypto-js/hmac-sha1" { - var HmacSHA1: CryptoJS.Hash; - export = HmacSHA1; -} - -declare module "crypto-js/hmac-sha256" { - var HmacSHA256: CryptoJS.Hash; - export = HmacSHA256; -} - -declare module "crypto-js/hmac-sha224" { - var HmacSHA224: CryptoJS.Hash; - export = HmacSHA224; -} - -declare module "crypto-js/hmac-sha512" { - var HmacSHA512: CryptoJS.Hash; - export = HmacSHA512; -} - -declare module "crypto-js/hmac-sha384" { - var HmacSHA384: CryptoJS.Hash; - export = HmacSHA384; -} - -declare module "crypto-js/hmac-sha3" { - var HmacSHA3: CryptoJS.Hash; - export = HmacSHA3; -} - -declare module "crypto-js/hmac-ripemd160" { - var HmacRIPEMD160: CryptoJS.Hash; - export = HmacRIPEMD160; -} - -/* --------------------------------- */ -declare module "crypto-js/pbkdf2" { - var PBKDF2: CryptoJS.Hash; - export = PBKDF2; -} - -/* --------------------------------- */ -declare module "crypto-js/aes" { - var AES: CryptoJS.Cipher; - export = AES; -} - -declare module "crypto-js/tripledes" { - var TripleDES: CryptoJS.Cipher; - export = TripleDES; -} - -declare module "crypto-js/rc4" { - var RC4: CryptoJS.Cipher; - export = RC4; -} - -declare module "crypto-js/rabbit" { - var Rabbit: CryptoJS.Cipher; - export = Rabbit; -} - -declare module "crypto-js/rabbit-legacy" { - var RabbitLegacy: CryptoJS.Cipher; - export = RabbitLegacy; -} - -declare module "crypto-js/evpkdf" { - var EvpKDF: CryptoJS.Cipher; - export = EvpKDF; -} - -/* --------------------------------- */ -declare module "crypto-js/format-openssl" { - var FormatOpenssl: any; - export = FormatOpenssl; -} - -declare module "crypto-js/format-hex" { - var FormatHex: any; - export = FormatHex; -} - -/* --------------------------------- */ -declare module "crypto-js/enc-latin1" { - var encLatin1: CryptoJS.Encoder; - export = encLatin1; -} - -declare module "crypto-js/enc-utf8" { - var encUtf8: CryptoJS.Encoder; - export = encUtf8; -} - -declare module "crypto-js/enc-hex" { - var encHex: CryptoJS.Encoder; - export = encHex; -} - -declare module "crypto-js/enc-utf16" { - var encUtf16: CryptoJS.Encoder; - export = encUtf16; -} - -declare module "crypto-js/enc-base64" { - var encBase64: CryptoJS.Encoder; - export = encBase64; -} - -/* --------------------------------- */ -declare module "crypto-js/mode-cfb" { - var modeCFB: CryptoJS.Mode; - export = modeCFB; -} - -declare module "crypto-js/mode-ctr" { - var modeCTR: CryptoJS.Mode; - export = modeCTR; -} - -declare module "crypto-js/mode-ctr-gladman" { - var modeCTRGladman: CryptoJS.Mode; - export = modeCTRGladman; -} - -declare module "crypto-js/mode-ofb" { - var modeOFB: CryptoJS.Mode; - export = modeOFB; -} - -declare module "crypto-js/mode-ecb" { - var modeECB: CryptoJS.Mode; - export = modeECB; -} - -/* --------------------------------- */ -declare module "crypto-js/pad-pkcs7" { - var padPkcs7: CryptoJS.Padding; - export = padPkcs7; -} - -declare module "crypto-js/pad-ansix923" { - var padAnsiX923: CryptoJS.Padding; - export = padAnsiX923; -} - -declare module "crypto-js/pad-iso10126" { - var padIso10126: CryptoJS.Padding; - export = padIso10126; -} - -declare module "crypto-js/pad-iso97971" { - var padIso97971: CryptoJS.Padding; - export = padIso97971; -} - -declare module "crypto-js/pad-zeropadding" { - var padZeroPadding: CryptoJS.Padding; - export = padZeroPadding; -} - -declare module "crypto-js/pad-nopadding" { - var padNoPadding: CryptoJS.Padding; - export = padNoPadding; -} diff --git a/crypto-js/lib-typedarrays/index.d.ts b/crypto-js/lib-typedarrays/index.d.ts new file mode 100644 index 0000000000..91c5a7933b --- /dev/null +++ b/crypto-js/lib-typedarrays/index.d.ts @@ -0,0 +1,2 @@ +declare const libWordArray: any; +export = libWordArray; diff --git a/crypto-js/md5/index.d.ts b/crypto-js/md5/index.d.ts new file mode 100644 index 0000000000..faa064511e --- /dev/null +++ b/crypto-js/md5/index.d.ts @@ -0,0 +1,3 @@ +import { MD5 } from '../index'; + +export = MD5; diff --git a/crypto-js/mode-cfb/index.d.ts b/crypto-js/mode-cfb/index.d.ts new file mode 100644 index 0000000000..74c5c6e3d1 --- /dev/null +++ b/crypto-js/mode-cfb/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const CFB: typeof mode.CFB; +export = CFB; diff --git a/crypto-js/mode-ctr-gladman/index.d.ts b/crypto-js/mode-ctr-gladman/index.d.ts new file mode 100644 index 0000000000..3ca8f8b367 --- /dev/null +++ b/crypto-js/mode-ctr-gladman/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const CTRGladman: typeof mode.CTRGladman; +export = CTRGladman; diff --git a/crypto-js/mode-ctr/index.d.ts b/crypto-js/mode-ctr/index.d.ts new file mode 100644 index 0000000000..6007a4ca88 --- /dev/null +++ b/crypto-js/mode-ctr/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const CTR: typeof mode.CTR; +export = CTR; diff --git a/crypto-js/mode-ecb/index.d.ts b/crypto-js/mode-ecb/index.d.ts new file mode 100644 index 0000000000..569d2b2286 --- /dev/null +++ b/crypto-js/mode-ecb/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const ECB: typeof mode.ECB; +export = ECB; diff --git a/crypto-js/mode-ofb/index.d.ts b/crypto-js/mode-ofb/index.d.ts new file mode 100644 index 0000000000..484406979d --- /dev/null +++ b/crypto-js/mode-ofb/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const OFB: typeof mode.OFB; +export = OFB; diff --git a/crypto-js/pad-ansix923/index.d.ts b/crypto-js/pad-ansix923/index.d.ts new file mode 100644 index 0000000000..2bb6c2dffb --- /dev/null +++ b/crypto-js/pad-ansix923/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const AnsiX923: typeof pad.AnsiX923; +export = AnsiX923; diff --git a/crypto-js/pad-iso10126/index.d.ts b/crypto-js/pad-iso10126/index.d.ts new file mode 100644 index 0000000000..6e52e96197 --- /dev/null +++ b/crypto-js/pad-iso10126/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const Iso10126: typeof pad.Iso10126; +export = Iso10126; diff --git a/crypto-js/pad-iso97971/index.d.ts b/crypto-js/pad-iso97971/index.d.ts new file mode 100644 index 0000000000..0ab1cecbfb --- /dev/null +++ b/crypto-js/pad-iso97971/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const Iso97971: typeof pad.Iso97971; +export = Iso97971; diff --git a/crypto-js/pad-nopadding/index.d.ts b/crypto-js/pad-nopadding/index.d.ts new file mode 100644 index 0000000000..f71bb2de73 --- /dev/null +++ b/crypto-js/pad-nopadding/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const NoPadding: typeof pad.NoPadding; +export = NoPadding; diff --git a/crypto-js/pad-pkcs7/index.d.ts b/crypto-js/pad-pkcs7/index.d.ts new file mode 100644 index 0000000000..1b194673a2 --- /dev/null +++ b/crypto-js/pad-pkcs7/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const Pkcs7: typeof pad.Pkcs7; +export = Pkcs7; diff --git a/crypto-js/pad-zeropadding/index.d.ts b/crypto-js/pad-zeropadding/index.d.ts new file mode 100644 index 0000000000..cf481402ab --- /dev/null +++ b/crypto-js/pad-zeropadding/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const ZeroPadding: typeof pad.ZeroPadding; +export = ZeroPadding; diff --git a/crypto-js/pbkdf2/index.d.ts b/crypto-js/pbkdf2/index.d.ts new file mode 100644 index 0000000000..e242e6fe05 --- /dev/null +++ b/crypto-js/pbkdf2/index.d.ts @@ -0,0 +1,3 @@ +import { PBKDF2 } from '../index'; + +export = PBKDF2; diff --git a/crypto-js/rabbit-legacy/index.d.ts b/crypto-js/rabbit-legacy/index.d.ts new file mode 100644 index 0000000000..6befe37563 --- /dev/null +++ b/crypto-js/rabbit-legacy/index.d.ts @@ -0,0 +1,3 @@ +import { RabbitLegacy } from '../index'; + +export = RabbitLegacy; diff --git a/crypto-js/rabbit/index.d.ts b/crypto-js/rabbit/index.d.ts new file mode 100644 index 0000000000..f708a6f20b --- /dev/null +++ b/crypto-js/rabbit/index.d.ts @@ -0,0 +1,3 @@ +import { Rabbit } from '../index'; + +export = Rabbit; diff --git a/crypto-js/rc4/index.d.ts b/crypto-js/rc4/index.d.ts new file mode 100644 index 0000000000..38a929f490 --- /dev/null +++ b/crypto-js/rc4/index.d.ts @@ -0,0 +1,3 @@ +import { RC4 } from '../index'; + +export = RC4; diff --git a/crypto-js/ripemd160/index.d.ts b/crypto-js/ripemd160/index.d.ts new file mode 100644 index 0000000000..90e3e770ce --- /dev/null +++ b/crypto-js/ripemd160/index.d.ts @@ -0,0 +1,3 @@ +import { RIPEMD160 } from '../index'; + +export = RIPEMD160; diff --git a/crypto-js/sha1/index.d.ts b/crypto-js/sha1/index.d.ts new file mode 100644 index 0000000000..14fb4d2a6b --- /dev/null +++ b/crypto-js/sha1/index.d.ts @@ -0,0 +1,3 @@ +import { SHA1 } from '../index'; + +export = SHA1; diff --git a/crypto-js/sha224/index.d.ts b/crypto-js/sha224/index.d.ts new file mode 100644 index 0000000000..3ff1ff4596 --- /dev/null +++ b/crypto-js/sha224/index.d.ts @@ -0,0 +1,3 @@ +import { SHA224 } from '../index'; + +export = SHA224; diff --git a/crypto-js/sha256/index.d.ts b/crypto-js/sha256/index.d.ts new file mode 100644 index 0000000000..59781b01f3 --- /dev/null +++ b/crypto-js/sha256/index.d.ts @@ -0,0 +1,3 @@ +import { SHA256 } from '../index'; + +export = SHA256; diff --git a/crypto-js/sha3/index.d.ts b/crypto-js/sha3/index.d.ts new file mode 100644 index 0000000000..241574a711 --- /dev/null +++ b/crypto-js/sha3/index.d.ts @@ -0,0 +1,3 @@ +import { SHA3 } from '../index'; + +export = SHA3; diff --git a/crypto-js/sha384/index.d.ts b/crypto-js/sha384/index.d.ts new file mode 100644 index 0000000000..5bad55498a --- /dev/null +++ b/crypto-js/sha384/index.d.ts @@ -0,0 +1,3 @@ +import { SHA384 } from '../index'; + +export = SHA384; diff --git a/crypto-js/sha512/index.d.ts b/crypto-js/sha512/index.d.ts new file mode 100644 index 0000000000..0f764329e2 --- /dev/null +++ b/crypto-js/sha512/index.d.ts @@ -0,0 +1,3 @@ +import { SHA512 } from '../index'; + +export = SHA512; diff --git a/crypto-js/tripledes/index.d.ts b/crypto-js/tripledes/index.d.ts new file mode 100644 index 0000000000..ea22173d98 --- /dev/null +++ b/crypto-js/tripledes/index.d.ts @@ -0,0 +1,3 @@ +import { TripleDES } from '../index'; + +export = TripleDES; diff --git a/crypto-js/x64-core/index.d.ts b/crypto-js/x64-core/index.d.ts new file mode 100644 index 0000000000..1ef7a67477 --- /dev/null +++ b/crypto-js/x64-core/index.d.ts @@ -0,0 +1,3 @@ +import * as X64Core from '../index'; + +export = X64Core; From 9be29e7b530932ecc1b0165713a1e49936de78a1 Mon Sep 17 00:00:00 2001 From: darlin Date: Wed, 25 Jan 2017 15:10:10 +0800 Subject: [PATCH 12/43] add files in tsconfig --- crypto-js/lib-typedarrays/index.d.ts | 4 +-- crypto-js/tsconfig.json | 48 ++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/crypto-js/lib-typedarrays/index.d.ts b/crypto-js/lib-typedarrays/index.d.ts index 91c5a7933b..761e38b1cd 100644 --- a/crypto-js/lib-typedarrays/index.d.ts +++ b/crypto-js/lib-typedarrays/index.d.ts @@ -1,2 +1,2 @@ -declare const libWordArray: any; -export = libWordArray; +declare const LibTypedarrays: any; +export = LibTypedarrays; diff --git a/crypto-js/tsconfig.json b/crypto-js/tsconfig.json index 94793c83ae..7fc335c24a 100644 --- a/crypto-js/tsconfig.json +++ b/crypto-js/tsconfig.json @@ -18,6 +18,50 @@ }, "files": [ "index.d.ts", - "crypto-js-tests.ts" + "crypto-js-tests.ts", + "core/index.d.ts", + "x64-core/index.d.ts", + "lib-typedarrays/index.d.ts", + "md5/index.d.ts", + "sha1/index.d.ts", + "sha256/index.d.ts", + "sha224/index.d.ts", + "sha512/index.d.ts", + "sha384/index.d.ts", + "sha3/index.d.ts", + "ripemd160/index.d.ts", + "hmac-md5/index.d.ts", + "hmac-sha1/index.d.ts", + "hmac-sha256/index.d.ts", + "hmac-sha224/index.d.ts", + "hmac-sha512/index.d.ts", + "hmac-sha384/index.d.ts", + "hmac-sha3/index.d.ts", + "hmac-ripemd160/index.d.ts", + "pbkdf2/index.d.ts", + "aes/index.d.ts", + "tripledes/index.d.ts", + "rc4/index.d.ts", + "rabbit/index.d.ts", + "rabbit-legacy/index.d.ts", + "evpkdf/index.d.ts", + "format-openssl/index.d.ts", + "format-hex/index.d.ts", + "enc-latin1/index.d.ts", + "enc-utf8/index.d.ts", + "enc-hex/index.d.ts", + "enc-utf16/index.d.ts", + "enc-base64/index.d.ts", + "mode-cfb/index.d.ts", + "mode-ctr/index.d.ts", + "mode-ctr-gladman/index.d.ts", + "mode-ofb/index.d.ts", + "mode-ecb/index.d.ts", + "pad-pkcs7/index.d.ts", + "pad-ansix923/index.d.ts", + "pad-iso10126/index.d.ts", + "pad-iso97971/index.d.ts", + "pad-zeropadding/index.d.ts", + "pad-nopadding/index.d.ts" ] -} \ No newline at end of file +} From d2febcc480606fab9d8564fd6e2d77f576ae39d7 Mon Sep 17 00:00:00 2001 From: darlin Date: Wed, 25 Jan 2017 16:03:50 +0800 Subject: [PATCH 13/43] add submodule tests --- crypto-js/index.d.ts | 1 - crypto-js/test/submodule-tests.ts | 184 ++++++++++++++++++++++++++++++ crypto-js/tsconfig.json | 1 + 3 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 crypto-js/test/submodule-tests.ts diff --git a/crypto-js/index.d.ts b/crypto-js/index.d.ts index a8068161e1..07a8d18dfc 100644 --- a/crypto-js/index.d.ts +++ b/crypto-js/index.d.ts @@ -113,5 +113,4 @@ declare namespace CryptoJS { NoPadding: Padding; }; } - } diff --git a/crypto-js/test/submodule-tests.ts b/crypto-js/test/submodule-tests.ts new file mode 100644 index 0000000000..0cfd8cd83f --- /dev/null +++ b/crypto-js/test/submodule-tests.ts @@ -0,0 +1,184 @@ +import Core = require('../core'); +import X64Core = require('../x64-core'); +import LibTypedarrays = require('../lib-typedarrays'); +// --- +import MD5 = require('../md5'); +import SHA1 = require('../sha1'); +import SHA256 = require('../sha256'); +import SHA224 = require('../sha224'); +import SHA512 = require('../sha512'); +import SHA384 = require('../sha384'); +import SHA3 = require('../sha3'); +import RIPEMD160 = require('../ripemd160'); +// --- +import HmacMD5 = require('../hmac-md5'); +import HmacSHA1 = require('../hmac-sha1'); +import HmacSHA256 = require('../hmac-sha256'); +import HmacSHA224 = require('../hmac-sha224'); +import HmacSHA512 = require('../hmac-sha512'); +import HmacSHA384 = require('../hmac-sha384'); +import HmacSHA3 = require('../hmac-sha3'); +import HmacRIPEMD160 = require('../hmac-ripemd160'); +// --- +import PBKDF2 = require('../pbkdf2'); +// --- +import AES = require('../aes'); +import TripleDES = require('../tripledes'); +import RC4 = require('../rc4'); +import Rabbit = require('../rabbit'); +import RabbitLegacy = require('../rabbit-legacy'); +import EvpKDF = require('../evpkdf'); +// --- +import FormatOpenSSL = require('../format-openssl'); +import FormatHex = require('../format-hex'); +// --- +import EncLatin1 = require('../enc-latin1'); +import EncUtf8 = require('../enc-utf8'); +import EncHex = require('../enc-hex'); +import EncUtf16 = require('../enc-utf16'); +import EncBase64 = require('../enc-base64'); +// --- +import ModeCFB = require('../mode-cfb'); +import ModeCTR = require('../mode-ctr'); +import ModeCTRGladman = require('../mode-ctr-gladman'); +import ModeOFB = require('../mode-ofb'); +import ModeECB = require('../mode-ecb'); +// --- +import PadPkcs7 = require('../pad-pkcs7'); +import PadAnsiX923 = require('../pad-ansix923'); +import PadIso10126 = require('../pad-iso10126'); +import PadIso97971 = require('../pad-iso97971'); +import PadZeroPadding = require('../pad-zeropadding'); +import PadNoPadding = require('../pad-nopadding'); + +// Hashers +var str: string; +str = MD5('some message'); +str = MD5('some message', 'some key'); + +str = SHA1('some message'); +str = SHA1('some message', 'some key', { any: true }); + +str = FormatOpenSSL('some message'); +str = FormatOpenSSL('some message', 'some key'); + + +// Ciphers +var encrypted: CryptoJS.WordArray; +var decrypted: CryptoJS.DecryptedMessage; + +encrypted = AES.encrypt("Message", "Secret Passphrase"); +decrypted = AES.decrypt(encrypted, "Secret Passphrase"); + +encrypted = Core.DES.encrypt("Message", "Secret Passphrase"); +decrypted = Core.DES.decrypt(encrypted, "Secret Passphrase"); + +encrypted = TripleDES.encrypt("Message", "Secret Passphrase"); +decrypted = TripleDES.decrypt(encrypted, "Secret Passphrase"); + + +encrypted = Rabbit.encrypt("Message", "Secret Passphrase"); +decrypted = Rabbit.decrypt(encrypted, "Secret Passphrase"); + +encrypted = RC4.encrypt("Message", "Secret Passphrase"); +decrypted = RC4.decrypt(encrypted, "Secret Passphrase"); + +encrypted = Core.RC4Drop.encrypt("Message", "Secret Passphrase"); +encrypted = Core.RC4Drop.encrypt("Message", "Secret Passphrase", { drop: 3072 / 4 }); +decrypted = Core.RC4Drop.decrypt(encrypted, "Secret Passphrase", { drop: 3072 / 4 }); + +var key = EncHex.parse('000102030405060708090a0b0c0d0e0f'); +var iv = EncHex.parse('101112131415161718191a1b1c1d1e1f'); +encrypted = AES.encrypt("Message", key, { iv: iv }); + +encrypted = AES.encrypt("Message", "Secret Passphrase", { + mode: ModeCFB, + padding: PadAnsiX923 +}); + + +// The Cipher Output +encrypted = AES.encrypt("Message", "Secret Passphrase"); +alert(encrypted.key); +// 74eb593087a982e2a6f5dded54ecd96d1fd0f3d44a58728cdcd40c55227522223 +alert(encrypted.iv); +// 7781157e2629b094f0e3dd48c4d786115 +alert(encrypted.salt); +// 7a25f9132ec6a8b34 +alert(encrypted.ciphertext); +// 73e54154a15d1beeb509d9e12f1e462a0 +alert(encrypted); +// U2FsdGVkX1+iX5Ey7GqLND5UFUoV0b7rUJ2eEvHkYqA= + +var JsonFormatter = { + stringify: function(cipherParams: any) { + // create json object with ciphertext + var jsonObj: any = { + ct: cipherParams.ciphertext.toString(EncBase64) + }; + // optionally add iv and salt + if (cipherParams.iv) { + jsonObj.iv = cipherParams.iv.toString(); + } + if (cipherParams.salt) { + jsonObj.s = cipherParams.salt.toString(); + } + // stringify json object + return JSON.stringify(jsonObj); + }, + parse: function (jsonStr: any) { + // parse json string + var jsonObj = JSON.parse(jsonStr); + // extract ciphertext from json object, and create cipher params object + var cipherParams = (Core).lib.CipherParams.create({ + ciphertext: EncBase64.parse(jsonObj.ct) + }); + // optionally extract iv and salt + if (jsonObj.iv) { + cipherParams.iv = EncHex.parse(jsonObj.iv); + } + if (jsonObj.s) { + cipherParams.salt = EncHex.parse(jsonObj.s); + } return cipherParams; + } +}; +encrypted = AES.encrypt("Message", "Secret Passphrase", { + format: JsonFormatter +}); +alert(encrypted); +// {"ct":"tZ4MsEnfbcDOwqau68aOrQ==","iv":"8a8c8fd8fe33743d3638737ea4a00698","s":"ba06373c8f57179c"} +decrypted = AES.decrypt(encrypted, "Secret Passphrase", { + format: JsonFormatter +}); +alert(decrypted.toString(EncUtf8)); // Message + + +// Progressive Ciphering +var key = EncHex.parse('000102030405060708090a0b0c0d0e0f'); +var iv = EncHex.parse('101112131415161718191a1b1c1d1e1f'); +var aesEncryptor = Core.algo.AES.createEncryptor(key, { iv: iv }); +var ciphertextPart1 = aesEncryptor.process("Message Part 1"); +var ciphertextPart2 = aesEncryptor.process("Message Part 2"); +var ciphertextPart3 = aesEncryptor.process("Message Part 3"); +var ciphertextPart4 = aesEncryptor.finalize(); +var aesDecryptor = Core.algo.AES.createDecryptor(key, { iv: iv }); +var plaintextPart1 = aesDecryptor.process(ciphertextPart1); +var plaintextPart2 = aesDecryptor.process(ciphertextPart2); +var plaintextPart3 = aesDecryptor.process(ciphertextPart3); +var plaintextPart4 = aesDecryptor.process(ciphertextPart4); +var plaintextPart5 = aesDecryptor.finalize(); + + +// Encoders +var words = EncBase64.parse('SGVsbG8sIFdvcmxkIQ=='); +var base64 = EncBase64.stringify(words); +var words = EncLatin1.parse('Hello, World!'); +var latin1 = EncLatin1.stringify(words); +var words = EncHex.parse('48656c6c6f2c20576f726c6421'); +var hex = EncHex.stringify(words); +var words = EncUtf8.parse('𤭢'); +var utf8 = EncUtf8.stringify(words); +var words = EncUtf16.parse('Hello, World!'); +var utf16 = EncUtf16.stringify(words); +var words = Core.enc.Utf16LE.parse('Hello, World!'); +var utf16 = Core.enc.Utf16LE.stringify(words); diff --git a/crypto-js/tsconfig.json b/crypto-js/tsconfig.json index 7fc335c24a..10865613d3 100644 --- a/crypto-js/tsconfig.json +++ b/crypto-js/tsconfig.json @@ -19,6 +19,7 @@ "files": [ "index.d.ts", "crypto-js-tests.ts", + "test/submodule-tests.ts", "core/index.d.ts", "x64-core/index.d.ts", "lib-typedarrays/index.d.ts", From 201dab6133daa473861a04631e2e6bc1abe914a8 Mon Sep 17 00:00:00 2001 From: york yao Date: Wed, 25 Jan 2017 23:58:49 +0800 Subject: [PATCH 14/43] add types of node-zookeeper-client --- node-zookeeper-client/index.d.ts | 168 ++++++++++++ .../node-zookeeper-client-tests.ts | 253 ++++++++++++++++++ node-zookeeper-client/tsconfig.json | 22 ++ node-zookeeper-client/tslint.json | 1 + 4 files changed, 444 insertions(+) create mode 100644 node-zookeeper-client/index.d.ts create mode 100644 node-zookeeper-client/node-zookeeper-client-tests.ts create mode 100644 node-zookeeper-client/tsconfig.json create mode 100644 node-zookeeper-client/tslint.json diff --git a/node-zookeeper-client/index.d.ts b/node-zookeeper-client/index.d.ts new file mode 100644 index 0000000000..f405aeffc7 --- /dev/null +++ b/node-zookeeper-client/index.d.ts @@ -0,0 +1,168 @@ +// Type definitions for Jasmine 2.5 +// Project: https://github.com/alexguan/node-zookeeper-client +// Definitions by: York Yao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as EventEmitter from "events"; + +export class Id { + scheme: string; + id: string; + constructor(scheme: string, id: string); +} + +export class ACL { + perms: number; + id: Id; + constructor(perms: number, id: Id); +} + +export const Permission: { + READ: number, + WRITE: number, + CREATE: number, + DELETE: number, + ADMIN: number, + ALL: number, +}; + +export interface Stat { + czxid: number; + mzxid: number; + ctime: number; + mtime: number; + version: number; + cversion: number; + aversion: number; + ephemeralOwner: number; + dataLength: number; + numChildren: number; + pzxid: number; +} + +export class State { + static DISCONNECTED: State; + static SYNC_CONNECTED: State; + static AUTH_FAILED: State; + static CONNECTED_READ_ONLY: State; + static SASL_AUTHENTICATED: State; + static EXPIRED: State; + + name: string; + code: number; + constructor(name: string, code: number); + toString(): string; +} + +export class Event { + static NODE_CREATED: number; + static NODE_DELETED: number; + static NODE_DATA_CHANGED: number; + static NODE_CHILDREN_CHANGED: number; + type: string; + name: string; + path: string; + constructor(type: string, name: string, path: string); + toString(): string; + getType(): string; + getName(): string; + getPath(): string; +} + +export class Transaction { + create(path: string, dataOrAclsOrmode1?: Buffer | ACL[] | number, dataOrAclsOrmode2?: Buffer | ACL[] | number, dataOrAclsOrmode3?: Buffer | ACL[] | number): this; + setData(path: string, data: Buffer | null, version?: number): this; + check(path: string, version?: number): this; + remove(path: string, version?: number): this; + commit(callback: (error: Error | Exception, results: any) => void): void; +} + +export class Client extends EventEmitter { + connect(): void; + close(): void; + create(path: string, callback: (error: Error | Exception, path: string) => void): void; + create(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + create(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, dataOrAclsOrmode2: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + create(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, dataOrAclsOrmode2: Buffer | ACL[] | number, dataOrAclsOrmode3: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + remove(path: string, callback: (error: Error | Exception) => void): void; + remove(path: string, version: number, callback: (error: Error | Exception) => void): void; + exists(path: string, callback: (error: Error | Exception, stat: Stat) => void): void; + exists(path: string, watcher: (event: Event) => void, callback: (error: Error | Exception, stat: Stat) => void): void; + getChildren(path: string, callback: (error: Error | Exception, children: string[], stat: Stat) => void): void; + getChildren(path: string, watcher: (event: Event) => void, callback: (error: Error | Exception, children: string[], stat: Stat) => void): void; + getData(path: string, callback: (error: Error | Exception, data: Buffer, stat: Stat) => void): void; + getData(path: string, watcher: (event: Event) => void, callback: (error: Error | Exception, data: Buffer, stat: Stat) => void): void; + setData(path: string, data: Buffer | null, callback: (error: Error | Exception, stat: Stat) => void): void; + setData(path: string, data: Buffer | null, version: number, callback: (error: Error | Exception, stat: Stat) => void): void; + getACL(path: string, callback: (error: Error | Exception, acls: ACL[], stat: Stat) => void): void; + setACL(path: string, acls: ACL[], callback: (error: Error | Exception, stat: Stat) => void): void; + setACL(path: string, acls: ACL[], version: number, callback: (error: Error | Exception, stat: Stat) => void): void; + transaction(): Transaction; + mkdirp(path: string, callback: (error: Error | Exception, path: string) => void): void; + mkdirp(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + mkdirp(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, dataOrAclsOrmode2: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + mkdirp(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, dataOrAclsOrmode2: Buffer | ACL[] | number, dataOrAclsOrmode3: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + addAuthInfo(scheme: string, auth: Buffer): void; + getState(): State; + getSessionId(): Buffer; + getSessionPassword(): Buffer; + getSessionTimeout(): number; + + on(event: "state", cb: (state: State) => void): this; + on(event: "connected" | "connectedReadOnly" | "disconnected" | "expired" | "authenticationFailed" | string, cb: () => void): this; + + once(event: "state", cb: (state: State) => void): this; + once(event: "connected" | "connectedReadOnly" | "disconnected" | "expired" | "authenticationFailed" | string, cb: () => void): this; + + addListener(event: "state", cb: (state: State) => void): this; + addListener(event: "connected" | "connectedReadOnly" | "disconnected" | "expired" | "authenticationFailed" | string, cb: () => void): this; +} + +export interface Option { + sessionTimeout: number; + spinDelay: number; + retries: number; +} + +export function createClient(connectionString: string, options?: Partial