Skip to content

Commit b562f0a

Browse files
committed
meshblu 1.30.1 definitions
1 parent 6f6e5c7 commit b562f0a

File tree

1 file changed

+281
-0
lines changed

1 file changed

+281
-0
lines changed

meshblu/meshblu.d.ts

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
// Type definitions for meshblu.js 1.30.1
2+
// Project: https://github.com/octoblu/meshblu-npm
3+
// Definitions by: Felipe Nipo <https://github.com/fnipo>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
///<reference path='../node/node.d.ts' />
7+
8+
declare module 'meshblu' {
9+
var Meshblu: MeshbluStatic;
10+
11+
export = Meshblu;
12+
}
13+
14+
interface MeshbluStatic {
15+
16+
/**
17+
* Establish a secure socket.io connection to Meshblu.
18+
* @param opt
19+
* @returns A Meshblu Connection.
20+
*/
21+
createConnection(opt: Meshblu.ConnectionOptions): Meshblu.Connection;
22+
23+
}
24+
25+
declare module Meshblu {
26+
27+
interface Connection {
28+
29+
/**
30+
*
31+
* @param uuid
32+
* @param fn The callback to be called. It should take one parameter, err,
33+
* which will be null if there was no problem, and one parameter, publicKey,
34+
* of type NodeRSA.
35+
*/
36+
getPublicKey(uuid: string, fn:(err: Error, publicKey: any) => void): void;
37+
38+
/**
39+
* Authenticate with Meshblu.
40+
* @returns This Connection.
41+
*/
42+
identify(): Connection;
43+
44+
/**
45+
* @param data {string|number|object|array|Buffer} - data for signing.
46+
*/
47+
sign(data: any): string;
48+
49+
/**
50+
* @param message {string|number|object|array|Buffer} - signed data.
51+
* @param signature
52+
* @returns {*}
53+
*/
54+
verify(message: any, signature: any): any;
55+
56+
/**
57+
* @param uuid
58+
* @param message {string|number|object|array|Buffer} - data for encrypting.
59+
* @param options
60+
* @param fn The callback to be called. It should take one parameter, result,
61+
* which is an object containing a property "error".
62+
* @returns This Connection.
63+
*/
64+
encryptMessage(uuid: string, message: any, options: Meshblu.ConnectionOptions, fn:(result: any) => void): Connection;
65+
66+
/**
67+
* Send a meshblu message.
68+
* @param payload An array of devices UUIDs.
69+
* @param fn The callback to be called. It should take one parameter, result,
70+
* which is an object containing a property "error".
71+
* @returns This Connection.
72+
*/
73+
message(payload: MessagePayload, fn:(result: any) => void): Connection;
74+
75+
/**
76+
* Update a device record.
77+
* @param data
78+
* @param fn The callback to be called. It should take one parameter, result.
79+
* @returns This Connection.
80+
*/
81+
update(data: UpdateData, fn:(result: UpdateSuccess) => void): Connection;
82+
83+
/**
84+
* Register a new device record.
85+
* @param data
86+
* @param fn The callback to be called. It should take one parameter, result.
87+
* @returns This Connection.
88+
*/
89+
register(data: RegisterData, fn:(result: RegisterResponse) => void): Connection;
90+
91+
/**
92+
* Removes a device record.
93+
* @param data
94+
* @param fn The callback to be called. It should take one parameter, result.
95+
* @returns This Connection.
96+
*/
97+
unregister(data: Device, fn:(result: Device) => void): Connection;
98+
99+
/**
100+
* Get my device info.
101+
* @param data
102+
* @param fn The callback to be called. It should take one parameter, result.
103+
* @returns This Connection.
104+
*/
105+
whoami(data: any, fn:(result: DeviceResponse) => void): Connection;
106+
107+
/**
108+
* Find a Meshblu device.
109+
* @param data
110+
* @param fn The callback to be called. It should take one parameter, result.
111+
* @returns This Connection.
112+
*/
113+
device(data: Device, fn:(result: DeviceResponse) => void): Connection
114+
115+
/**
116+
* Find Meshblu devices.
117+
* @param data
118+
* @param fn The callback to be called. It should take one parameter, result.
119+
* @returns This Connection.
120+
*/
121+
devices(data: Color, fn:(result: DeviceResponse[]) => void): Connection
122+
123+
/**
124+
* Returns device messages as they are sent and received.
125+
* @param data
126+
* @param fn The callback to be called. It should take one parameter, result.
127+
* @returns This Connection.
128+
*/
129+
subscribe(data: SubscribeData, fn:(result: any) => void): Connection
130+
131+
/**
132+
* Cancels device subscription.
133+
* @param data
134+
* @param fn The callback to be called. It should take one parameter, result.
135+
* @returns This Connection.
136+
*/
137+
unsubscribe(data: UnsubscribeData, fn:(result: any) => void): Connection
138+
139+
/**
140+
* Send a meshblu data message.
141+
* @param data
142+
* @param fn The callback to be called. It should take one parameter, result.
143+
* @returns This Connection.
144+
*/
145+
data(data: DataInput, fn:(result: any) => void): Connection
146+
147+
/**
148+
* Get a meshblu data for a device.
149+
* @param data
150+
* @param fn The callback to be called. It should take one parameter, result.
151+
* @returns This Connection.
152+
*/
153+
getdata(data: GetDataInput, fn:(result: any) => void): Connection
154+
155+
/**
156+
* Generate a new session token for a device.
157+
* @param data
158+
* @param fn The callback to be called. It should take one parameter, result.
159+
*/
160+
generateAndStoreToken(data: Device, fn:(result: ConnectionOptions) => void): void
161+
162+
/**
163+
* Remove a session token from a device.
164+
* @param data
165+
* @param fn The callback to be called. It should take one parameter, result.
166+
*/
167+
revokeToken(data: ConnectionOptions, fn:(result: Device) => void): void
168+
169+
/*
170+
* Lack of documentation about these api functions.
171+
*/
172+
send(text: string): Connection;
173+
bufferedSocketEmit(): void;
174+
parseUrl(serverUrl: string, port: string): string;
175+
generateKeyPair(): KeyPair;
176+
setPrivateKey(privateKey: string): void;
177+
setup(): Connection;
178+
connect(): void;
179+
reconnect(): void;
180+
claimdevice(data: Device, fn:(result: Device) => void): Connection;
181+
mydevices(data: any, fn:(result: any) => void): Connection
182+
status(data: any): Connection
183+
authenticate(data: any, fn:(result: any) => void): Connection
184+
events(data: any, fn:(result: any) => void): Connection
185+
localdevices(fn:(result: any) => void): Connection
186+
unclaimeddevices(data: any, fn:(result: any) => void): Connection
187+
textBroadcast(data: any): Connection
188+
directText(data: any): Connection
189+
subscribeText(data: any, fn:(result: any) => void): Connection
190+
unsubscribeText(data: any, fn:(result: any) => void): Connection
191+
close(fn:(result: any) => void): Connection
192+
resetToken(data: any, fn:(result: any) => void): void
193+
}
194+
195+
/**
196+
* Contains the primary means of identifying a device.
197+
*/
198+
interface ConnectionOptions {
199+
uuid: string;
200+
token: string;
201+
}
202+
203+
interface KeyPair {
204+
privateKey: string;
205+
publicKey: string;
206+
}
207+
208+
interface MessagePayload {
209+
devices: string[];
210+
topic: string;
211+
payload: any;
212+
qos?: number;
213+
}
214+
215+
interface UpdateData {
216+
uuid: string;
217+
color: string;
218+
}
219+
220+
interface UpdateSuccess {
221+
uuid: string;
222+
token: string;
223+
status: string;
224+
}
225+
226+
interface RegisterData {
227+
type: string;
228+
}
229+
230+
interface RegisterResponse {
231+
uuid: string;
232+
token: string;
233+
type: string;
234+
}
235+
236+
interface Device {
237+
uuid: string;
238+
}
239+
240+
interface DeviceResponse {
241+
uuid: string;
242+
online: boolean;
243+
color: string;
244+
}
245+
246+
interface Color {
247+
color: string;
248+
}
249+
250+
interface SubscribeData {
251+
uuid: string;
252+
types?: string[];
253+
topics?: string[];
254+
}
255+
256+
interface UnsubscribeData {
257+
uuid: string;
258+
types?: string[];
259+
}
260+
261+
interface DataInput {
262+
uuid: string;
263+
online: boolean;
264+
x: number;
265+
y: number;
266+
}
267+
268+
interface GetDataInput {
269+
uuid: string;
270+
start: string;
271+
finish: string;
272+
limit: number;
273+
}
274+
275+
interface IdentifySuccess {
276+
uuid: string;
277+
token: string;
278+
status: string;
279+
}
280+
281+
}

0 commit comments

Comments
 (0)