@openfin/cloud-interop-core-api 0.0.1-alpha.6d7b62b → 0.0.1-alpha.72529c1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +59 -0
- package/dist/controllers/event.controller.d.ts +8 -0
- package/dist/controllers/index.d.ts +2 -0
- package/dist/controllers/intent.controller.d.ts +13 -0
- package/dist/errors/api.error.d.ts +7 -0
- package/dist/index.cjs +10 -4
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +14 -2
- package/dist/interfaces/connect.interface.d.ts +85 -0
- package/dist/interfaces/event.interface.d.ts +15 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/intents.interface.d.ts +22 -0
- package/dist/utils.d.ts +25 -0
- package/package.json +8 -18
- package/dist/LICENSE.md +0 -4
- package/dist/README.md +0 -14
- package/dist/bundle.d.ts +0 -796
- package/dist/package.json +0 -18
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AppIdentifier, AppIntent, IntentResult } from '@openfin/shared-utils';
|
|
2
|
+
import mqtt from 'mqtt';
|
|
3
|
+
import { CloudInteropSettings, ConnectParameters, CreateSessionResponse } from './interfaces/connect.interface';
|
|
4
|
+
import { EventMap, RaiseIntentAPIOptions, StartIntentDiscoveryOptions } from './interfaces';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a single connection to a Cloud Interop service
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @class CloudInteropAPI
|
|
10
|
+
* @implements {Client}
|
|
11
|
+
*/
|
|
12
|
+
export declare class CloudInteropAPI {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(cloudInteropSettings: CloudInteropSettings);
|
|
15
|
+
get sessionDetails(): CreateSessionResponse | undefined;
|
|
16
|
+
get mqttClient(): mqtt.MqttClient | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Connects and creates a session on the Cloud Interop service
|
|
19
|
+
*
|
|
20
|
+
* @param {ConnectParameters} parameters - The parameters to use to connect
|
|
21
|
+
* @return {*} {Promise<void>}
|
|
22
|
+
* @memberof CloudInteropAPI
|
|
23
|
+
* @throws {CloudInteropAPIError} - If an error occurs during connection
|
|
24
|
+
* @throws {AuthorizationError} - If the connection is unauthorized
|
|
25
|
+
*/
|
|
26
|
+
connect(parameters: ConnectParameters): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Disconnects from the Cloud Interop service
|
|
29
|
+
*
|
|
30
|
+
* @return {*} {Promise<void>}
|
|
31
|
+
* @memberof CloudInteropAPI
|
|
32
|
+
* @throws {CloudInteropAPIError} - If an error occurs during disconnection
|
|
33
|
+
*/
|
|
34
|
+
disconnect(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Publishes a new context for the given context group to the other connected sessions
|
|
37
|
+
*
|
|
38
|
+
* @param {string} contextGroup - The context group to publish to
|
|
39
|
+
* @param {object} context - The context to publish
|
|
40
|
+
* @return {*} {Promise<void>}
|
|
41
|
+
* @memberof CloudInteropAPI
|
|
42
|
+
*/
|
|
43
|
+
setContext(contextGroup: string, context: object): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Starts an intent discovery operation
|
|
46
|
+
*
|
|
47
|
+
* @return {*} {Promise<void>}
|
|
48
|
+
* @memberof CloudInteropAPI
|
|
49
|
+
* @throws {CloudInteropAPIError} - If an error occurs during intent discovery
|
|
50
|
+
*/
|
|
51
|
+
startIntentDiscovery(options: StartIntentDiscoveryOptions): Promise<void>;
|
|
52
|
+
raiseIntent(options: RaiseIntentAPIOptions): Promise<void>;
|
|
53
|
+
reportAppIntents(discoveryId: string, intents: AppIntent[]): Promise<boolean>;
|
|
54
|
+
sendIntentResult(initiatingSessionId: string, result: IntentResult): Promise<void>;
|
|
55
|
+
parseSessionId(appId: AppIdentifier | string): string;
|
|
56
|
+
addEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
|
|
57
|
+
removeEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
|
|
58
|
+
once<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EventMap } from '../interfaces';
|
|
2
|
+
export declare class EventController {
|
|
3
|
+
#private;
|
|
4
|
+
addEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
|
|
5
|
+
removeEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
|
|
6
|
+
once<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
|
|
7
|
+
emitEvent<K extends keyof EventMap>(type: K, ...args: Parameters<EventMap[K]>): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppIntent, CommandMessage, IntentResult } from '@openfin/shared-utils';
|
|
2
|
+
import mqtt from 'mqtt';
|
|
3
|
+
import { CloudInteropLogger, ConnectParameters, CreateSessionResponse, RaiseIntentAPIOptions, StartIntentDiscoveryOptions } from '../interfaces';
|
|
4
|
+
import { EventController } from './event.controller';
|
|
5
|
+
export declare class IntentController {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(url: string, mqttClient: mqtt.MqttClient, sessionDetails: CreateSessionResponse, connectionParameters: ConnectParameters, events: EventController, logger: CloudInteropLogger);
|
|
8
|
+
startIntentDiscovery(options: StartIntentDiscoveryOptions): Promise<void>;
|
|
9
|
+
raiseIntent({ raiseOptions, appId }: RaiseIntentAPIOptions): Promise<void>;
|
|
10
|
+
reportAppIntents(discoveryId: string, intents: AppIntent[]): Promise<boolean>;
|
|
11
|
+
sendIntentResult(initiatingSessionId: string, result: IntentResult): Promise<void>;
|
|
12
|
+
handleCommandMessage(message: CommandMessage): void;
|
|
13
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var buffer = require('buffer');
|
|
4
3
|
var mqtt = require('mqtt');
|
|
4
|
+
var sharedUtils = require('@openfin/shared-utils');
|
|
5
5
|
|
|
6
6
|
class CloudInteropAPIError extends Error {
|
|
7
7
|
code;
|
|
@@ -57,11 +57,11 @@ const getRequestHeaders = (connectionParameters) => {
|
|
|
57
57
|
}
|
|
58
58
|
headers['x-of-auth-id'] = connectionParameters.jwtAuthenticationParameters.authenticationId;
|
|
59
59
|
headers['Authorization'] =
|
|
60
|
-
typeof tokenResult === 'string' ? `Bearer ${tokenResult}` : `Bearer ${
|
|
60
|
+
typeof tokenResult === 'string' ? `Bearer ${tokenResult}` : `Bearer ${Buffer.from(JSON.stringify(tokenResult)).toString('base64')}`;
|
|
61
61
|
}
|
|
62
62
|
if (connectionParameters.authenticationType === 'basic' && connectionParameters.basicAuthenticationParameters) {
|
|
63
63
|
const { username, password } = connectionParameters.basicAuthenticationParameters;
|
|
64
|
-
headers['Authorization'] = `Basic ${
|
|
64
|
+
headers['Authorization'] = `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`;
|
|
65
65
|
}
|
|
66
66
|
return headers;
|
|
67
67
|
};
|
|
@@ -379,7 +379,7 @@ class CloudInteropAPI {
|
|
|
379
379
|
// The server can then tidy up. So it needs every for this client to do that, the session details is perfect
|
|
380
380
|
will: {
|
|
381
381
|
topic: 'interop/lastwill',
|
|
382
|
-
payload:
|
|
382
|
+
payload: Buffer.from(JSON.stringify(this.#sessionDetails)),
|
|
383
383
|
qos: 0,
|
|
384
384
|
retain: false,
|
|
385
385
|
},
|
|
@@ -628,3 +628,9 @@ class CloudInteropAPI {
|
|
|
628
628
|
exports.AuthorizationError = AuthorizationError;
|
|
629
629
|
exports.CloudInteropAPI = CloudInteropAPI;
|
|
630
630
|
exports.CloudInteropAPIError = CloudInteropAPIError;
|
|
631
|
+
Object.keys(sharedUtils).forEach(function (k) {
|
|
632
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
633
|
+
enumerable: true,
|
|
634
|
+
get: function () { return sharedUtils[k]; }
|
|
635
|
+
});
|
|
636
|
+
});
|
package/dist/index.d.ts
ADDED