@ohos-ports/genesys-cloud-streaming-client 20.1.0-beta.1

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.
Files changed (176) hide show
  1. package/README.md +47 -0
  2. package/dist/cjs/alerting-leader.d.ts +29 -0
  3. package/dist/cjs/alerting-leader.js +163 -0
  4. package/dist/cjs/client.d.ts +84 -0
  5. package/dist/cjs/client.js +680 -0
  6. package/dist/cjs/connection-manager.d.ts +18 -0
  7. package/dist/cjs/connection-manager.js +120 -0
  8. package/dist/cjs/connection-transfer.d.ts +7 -0
  9. package/dist/cjs/connection-transfer.js +20 -0
  10. package/dist/cjs/http-client.d.ts +18 -0
  11. package/dist/cjs/http-client.js +230 -0
  12. package/dist/cjs/index.d.ts +10 -0
  13. package/dist/cjs/index.js +31 -0
  14. package/dist/cjs/messenger.d.ts +37 -0
  15. package/dist/cjs/messenger.js +54 -0
  16. package/dist/cjs/notifications.d.ts +94 -0
  17. package/dist/cjs/notifications.js +495 -0
  18. package/dist/cjs/ping.d.ts +21 -0
  19. package/dist/cjs/ping.js +60 -0
  20. package/dist/cjs/polyfills.d.ts +0 -0
  21. package/dist/cjs/polyfills.js +6 -0
  22. package/dist/cjs/server-monitor.d.ts +16 -0
  23. package/dist/cjs/server-monitor.js +44 -0
  24. package/dist/cjs/stanza-definitions/webrtc-signaling.d.ts +29 -0
  25. package/dist/cjs/stanza-definitions/webrtc-signaling.js +113 -0
  26. package/dist/cjs/stanza-definitions/xep0051.d.ts +19 -0
  27. package/dist/cjs/stanza-definitions/xep0051.js +28 -0
  28. package/dist/cjs/stats-formatter.d.ts +6 -0
  29. package/dist/cjs/stats-formatter.js +63 -0
  30. package/dist/cjs/types/genesys-cloud-media-session.d.ts +64 -0
  31. package/dist/cjs/types/genesys-cloud-media-session.js +353 -0
  32. package/dist/cjs/types/interfaces.d.ts +310 -0
  33. package/dist/cjs/types/interfaces.js +22 -0
  34. package/dist/cjs/types/libs.d.ts +32 -0
  35. package/dist/cjs/types/libs.js +1 -0
  36. package/dist/cjs/types/media-session.d.ts +76 -0
  37. package/dist/cjs/types/media-session.js +2 -0
  38. package/dist/cjs/types/named-agent.d.ts +13 -0
  39. package/dist/cjs/types/named-agent.js +2 -0
  40. package/dist/cjs/types/offline-error.d.ts +2 -0
  41. package/dist/cjs/types/offline-error.js +5 -0
  42. package/dist/cjs/types/sasl-error.d.ts +8 -0
  43. package/dist/cjs/types/sasl-error.js +12 -0
  44. package/dist/cjs/types/stanza-media-session.d.ts +56 -0
  45. package/dist/cjs/types/stanza-media-session.js +255 -0
  46. package/dist/cjs/types/streaming-client-extension.d.ts +14 -0
  47. package/dist/cjs/types/streaming-client-extension.js +2 -0
  48. package/dist/cjs/types/timeout-error.d.ts +3 -0
  49. package/dist/cjs/types/timeout-error.js +9 -0
  50. package/dist/cjs/types/user-cancelled-error.d.ts +2 -0
  51. package/dist/cjs/types/user-cancelled-error.js +5 -0
  52. package/dist/cjs/utils.d.ts +34 -0
  53. package/dist/cjs/utils.js +202 -0
  54. package/dist/cjs/webrtc.d.ts +126 -0
  55. package/dist/cjs/webrtc.js +891 -0
  56. package/dist/deploy-info.json +21 -0
  57. package/dist/es/alerting-leader.d.ts +29 -0
  58. package/dist/es/alerting-leader.js +177 -0
  59. package/dist/es/client.d.ts +84 -0
  60. package/dist/es/client.js +699 -0
  61. package/dist/es/connection-manager.d.ts +18 -0
  62. package/dist/es/connection-manager.js +124 -0
  63. package/dist/es/connection-transfer.d.ts +7 -0
  64. package/dist/es/connection-transfer.js +16 -0
  65. package/dist/es/http-client.d.ts +18 -0
  66. package/dist/es/http-client.js +194 -0
  67. package/dist/es/index.bundle.js +39629 -0
  68. package/dist/es/index.d.ts +10 -0
  69. package/dist/es/index.js +10 -0
  70. package/dist/es/messenger.d.ts +37 -0
  71. package/dist/es/messenger.js +62 -0
  72. package/dist/es/notifications.d.ts +94 -0
  73. package/dist/es/notifications.js +507 -0
  74. package/dist/es/ping.d.ts +21 -0
  75. package/dist/es/ping.js +68 -0
  76. package/dist/es/polyfills.d.ts +0 -0
  77. package/dist/es/polyfills.js +6 -0
  78. package/dist/es/server-monitor.d.ts +16 -0
  79. package/dist/es/server-monitor.js +41 -0
  80. package/dist/es/stanza-definitions/webrtc-signaling.d.ts +29 -0
  81. package/dist/es/stanza-definitions/webrtc-signaling.js +110 -0
  82. package/dist/es/stanza-definitions/xep0051.d.ts +19 -0
  83. package/dist/es/stanza-definitions/xep0051.js +25 -0
  84. package/dist/es/stats-formatter.d.ts +6 -0
  85. package/dist/es/stats-formatter.js +54 -0
  86. package/dist/es/types/genesys-cloud-media-session.d.ts +64 -0
  87. package/dist/es/types/genesys-cloud-media-session.js +379 -0
  88. package/dist/es/types/interfaces.d.ts +310 -0
  89. package/dist/es/types/interfaces.js +19 -0
  90. package/dist/es/types/libs.d.ts +32 -0
  91. package/dist/es/types/libs.js +1 -0
  92. package/dist/es/types/media-session.d.ts +76 -0
  93. package/dist/es/types/media-session.js +1 -0
  94. package/dist/es/types/named-agent.d.ts +13 -0
  95. package/dist/es/types/named-agent.js +1 -0
  96. package/dist/es/types/offline-error.d.ts +2 -0
  97. package/dist/es/types/offline-error.js +2 -0
  98. package/dist/es/types/sasl-error.d.ts +8 -0
  99. package/dist/es/types/sasl-error.js +9 -0
  100. package/dist/es/types/stanza-media-session.d.ts +56 -0
  101. package/dist/es/types/stanza-media-session.js +264 -0
  102. package/dist/es/types/streaming-client-extension.d.ts +14 -0
  103. package/dist/es/types/streaming-client-extension.js +1 -0
  104. package/dist/es/types/timeout-error.d.ts +3 -0
  105. package/dist/es/types/timeout-error.js +5 -0
  106. package/dist/es/types/user-cancelled-error.d.ts +2 -0
  107. package/dist/es/types/user-cancelled-error.js +2 -0
  108. package/dist/es/utils.d.ts +34 -0
  109. package/dist/es/utils.js +192 -0
  110. package/dist/es/webrtc.d.ts +126 -0
  111. package/dist/es/webrtc.js +917 -0
  112. package/dist/manifest.json +19 -0
  113. package/dist/npm/CHANGELOG.md +637 -0
  114. package/dist/npm/README.md +47 -0
  115. package/dist/npm/alerting-leader.d.ts +29 -0
  116. package/dist/npm/alerting-leader.js +163 -0
  117. package/dist/npm/client.d.ts +84 -0
  118. package/dist/npm/client.js +680 -0
  119. package/dist/npm/connection-manager.d.ts +18 -0
  120. package/dist/npm/connection-manager.js +120 -0
  121. package/dist/npm/connection-transfer.d.ts +7 -0
  122. package/dist/npm/connection-transfer.js +20 -0
  123. package/dist/npm/http-client.d.ts +18 -0
  124. package/dist/npm/http-client.js +230 -0
  125. package/dist/npm/index.d.ts +10 -0
  126. package/dist/npm/index.js +31 -0
  127. package/dist/npm/messenger.d.ts +37 -0
  128. package/dist/npm/messenger.js +54 -0
  129. package/dist/npm/module.js +10 -0
  130. package/dist/npm/notifications.d.ts +94 -0
  131. package/dist/npm/notifications.js +495 -0
  132. package/dist/npm/ping.d.ts +21 -0
  133. package/dist/npm/ping.js +60 -0
  134. package/dist/npm/polyfills.d.ts +0 -0
  135. package/dist/npm/polyfills.js +6 -0
  136. package/dist/npm/server-monitor.d.ts +16 -0
  137. package/dist/npm/server-monitor.js +44 -0
  138. package/dist/npm/stanza-definitions/webrtc-signaling.d.ts +29 -0
  139. package/dist/npm/stanza-definitions/webrtc-signaling.js +113 -0
  140. package/dist/npm/stanza-definitions/xep0051.d.ts +19 -0
  141. package/dist/npm/stanza-definitions/xep0051.js +28 -0
  142. package/dist/npm/stats-formatter.d.ts +6 -0
  143. package/dist/npm/stats-formatter.js +63 -0
  144. package/dist/npm/types/genesys-cloud-media-session.d.ts +64 -0
  145. package/dist/npm/types/genesys-cloud-media-session.js +353 -0
  146. package/dist/npm/types/interfaces.d.ts +310 -0
  147. package/dist/npm/types/interfaces.js +22 -0
  148. package/dist/npm/types/libs.d.ts +32 -0
  149. package/dist/npm/types/libs.js +1 -0
  150. package/dist/npm/types/media-session.d.ts +76 -0
  151. package/dist/npm/types/media-session.js +2 -0
  152. package/dist/npm/types/named-agent.d.ts +13 -0
  153. package/dist/npm/types/named-agent.js +2 -0
  154. package/dist/npm/types/offline-error.d.ts +2 -0
  155. package/dist/npm/types/offline-error.js +5 -0
  156. package/dist/npm/types/sasl-error.d.ts +8 -0
  157. package/dist/npm/types/sasl-error.js +12 -0
  158. package/dist/npm/types/stanza-media-session.d.ts +56 -0
  159. package/dist/npm/types/stanza-media-session.js +255 -0
  160. package/dist/npm/types/streaming-client-extension.d.ts +14 -0
  161. package/dist/npm/types/streaming-client-extension.js +2 -0
  162. package/dist/npm/types/timeout-error.d.ts +3 -0
  163. package/dist/npm/types/timeout-error.js +9 -0
  164. package/dist/npm/types/user-cancelled-error.d.ts +2 -0
  165. package/dist/npm/types/user-cancelled-error.js +5 -0
  166. package/dist/npm/utils.d.ts +34 -0
  167. package/dist/npm/utils.js +207 -0
  168. package/dist/npm/webrtc.d.ts +126 -0
  169. package/dist/npm/webrtc.js +893 -0
  170. package/dist/streaming-client.browser.js +2 -0
  171. package/dist/streaming-client.browser.js.LICENSE.txt +12 -0
  172. package/dist/v20/streaming-client.browser.js +2 -0
  173. package/dist/v20/streaming-client.browser.js.LICENSE.txt +12 -0
  174. package/dist/v20.1.0/streaming-client.browser.js +2 -0
  175. package/dist/v20.1.0/streaming-client.browser.js.LICENSE.txt +12 -0
  176. package/package.json +132 -0
@@ -0,0 +1,10 @@
1
+ /// <reference path="types/libs.d.ts" />
2
+ import { Client } from './client';
3
+ export * from './types/genesys-cloud-media-session';
4
+ export * from './types/stanza-media-session';
5
+ export * from './types/media-session';
6
+ export * from './types/interfaces';
7
+ export * from './messenger';
8
+ export { HttpClient } from './http-client';
9
+ export { StreamingClientError, StreamingSubscriptionError, parseJwt } from './utils';
10
+ export default Client;
@@ -0,0 +1,10 @@
1
+ /// <reference path="types/libs.ts" />
2
+ import { Client } from './client';
3
+ export * from './types/genesys-cloud-media-session';
4
+ export * from './types/stanza-media-session';
5
+ export * from './types/media-session';
6
+ export * from './types/interfaces';
7
+ export * from './messenger';
8
+ export { HttpClient } from './http-client';
9
+ export { StreamingClientError, StreamingSubscriptionError, parseJwt } from './utils';
10
+ export default Client;
@@ -0,0 +1,37 @@
1
+ import { ReceivedMessage } from 'stanza/protocol';
2
+ import { Client } from './client';
3
+ import { NamedAgent } from './types/named-agent';
4
+ import { GenesysMediaMessage, StreamingClientExtension } from './types/interfaces';
5
+ import { Emitter } from 'strict-event-emitter';
6
+ declare type MessageWithMediaMessage = {
7
+ from?: string;
8
+ id?: string;
9
+ to?: string;
10
+ mediaMessage: GenesysMediaMessage;
11
+ };
12
+ export declare type MediaMessageEvent = MessageWithMediaMessage & {
13
+ fromMyUser: boolean;
14
+ fromMyClient: boolean;
15
+ };
16
+ export declare type MessengerEvents = {
17
+ mediaMessage: [MediaMessageEvent];
18
+ };
19
+ export declare class MessengerExtension extends Emitter<MessengerEvents> implements StreamingClientExtension {
20
+ private client;
21
+ private stanzaInstance;
22
+ constructor(client: Client, stanzaInstance: NamedAgent);
23
+ get bareJid(): string;
24
+ handleStanzaInstanceChange(stanzaInstance: NamedAgent): void;
25
+ isMediaMessage(msg: any): msg is MessageWithMediaMessage;
26
+ handleMessage(msg: ReceivedMessage): void;
27
+ /**
28
+ * @param msg
29
+ * @returns Promise<messageId>
30
+ */
31
+ broadcastMessage(msg: MessageWithMediaMessage): Promise<string>;
32
+ get expose(): MessengerExtensionApi;
33
+ }
34
+ export interface MessengerExtensionApi extends Pick<Emitter<MessengerEvents>, 'on' | 'off' | 'once' | 'addListener' | 'removeListener'> {
35
+ broadcastMessage(msg: MessageWithMediaMessage): Promise<string>;
36
+ }
37
+ export {};
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import { Emitter } from 'strict-event-emitter';
12
+ import { toBare } from 'stanza/JID';
13
+ export class MessengerExtension extends Emitter {
14
+ constructor(client, stanzaInstance) {
15
+ super();
16
+ this.client = client;
17
+ this.stanzaInstance = stanzaInstance;
18
+ }
19
+ get bareJid() {
20
+ return toBare(this.stanzaInstance.jid);
21
+ }
22
+ handleStanzaInstanceChange(stanzaInstance) {
23
+ this.stanzaInstance = stanzaInstance;
24
+ }
25
+ isMediaMessage(msg) {
26
+ return !!msg.mediaMessage;
27
+ }
28
+ handleMessage(msg) {
29
+ if (!this.isMediaMessage(msg)) {
30
+ return;
31
+ }
32
+ const fromMyClient = msg.from === this.stanzaInstance.jid;
33
+ const fromMyUser = toBare(msg.from) === this.bareJid;
34
+ this.emit('mediaMessage', Object.assign(Object.assign({}, msg), { fromMyClient, fromMyUser }));
35
+ }
36
+ /**
37
+ * @param msg
38
+ * @returns Promise<messageId>
39
+ */
40
+ broadcastMessage(msg) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const id = globalThis.crypto.randomUUID();
43
+ msg.id = id;
44
+ msg.from = this.stanzaInstance.jid;
45
+ if (!msg.to) {
46
+ msg.to = this.bareJid;
47
+ }
48
+ yield this.stanzaInstance.send('message', msg);
49
+ return id;
50
+ });
51
+ }
52
+ get expose() {
53
+ return {
54
+ broadcastMessage: this.broadcastMessage.bind(this),
55
+ on: this.on.bind(this),
56
+ once: this.once.bind(this),
57
+ off: this.off.bind(this),
58
+ removeListener: this.removeListener.bind(this),
59
+ addListener: this.addListener.bind(this)
60
+ };
61
+ }
62
+ }
@@ -0,0 +1,94 @@
1
+ import { PubsubEvent, PubsubSubscription, PubsubSubscriptionWithOptions } from 'stanza/protocol';
2
+ import { Client } from './client';
3
+ import { IClientOptions, StreamingClientExtension } from './types/interfaces';
4
+ import { NamedAgent } from './types/named-agent';
5
+ import { AxiosResponse } from 'axios';
6
+ export declare class Notifications implements StreamingClientExtension {
7
+ client: Client;
8
+ stanzaInstance?: NamedAgent;
9
+ subscriptions: any;
10
+ bulkSubscriptions: any;
11
+ topicPriorities: any;
12
+ debouncedResubscribe: () => Promise<BulkSubscribeResult>;
13
+ enablePartialBulkResubscribe: boolean;
14
+ private internalSubscriptions;
15
+ private pendingBulkSubscribeRetry?;
16
+ private pendingConnectedWait?;
17
+ constructor(client: any, options?: IClientOptions);
18
+ get pubsubHost(): string;
19
+ handleStanzaInstanceChange(stanza: NamedAgent): void;
20
+ topicHandlers(topic: string): Array<(obj?: any) => void>;
21
+ pubsubEvent({ pubsub }: {
22
+ pubsub: PubsubEvent;
23
+ }): void;
24
+ xmppSubscribe(topic: string): Promise<PubsubSubscriptionWithOptions | void>;
25
+ xmppUnsubscribe(topic: string): Promise<PubsubSubscription | void>;
26
+ mapCombineTopics(topics: string[]): Array<{
27
+ id: string;
28
+ }>;
29
+ prioritizeTopicList(topics: Array<{
30
+ id: string;
31
+ }>): Array<{
32
+ id: string;
33
+ }>;
34
+ getTopicPriority(topic: string, returnDefault?: boolean): number;
35
+ truncateTopicList(topics: Array<{
36
+ id: string;
37
+ }>): Array<{
38
+ id: string;
39
+ }>;
40
+ makeBulkSubscribeRequest(topics: string[], options: any): Promise<AxiosResponse<ChannelTopicsEntityListing>>;
41
+ createSubscription(topic: string, handler: (obj?: any) => void): void;
42
+ removeSubscription(topic: string, handler: (obj?: any) => void): void;
43
+ removeTopicPriority(topic: string): void;
44
+ getActiveIndividualTopics(): string[];
45
+ resubscribe(): Promise<BulkSubscribeResult>;
46
+ subscriptionsKeepAlive(): void;
47
+ getTopicParts(topic: string): {
48
+ prefix: string;
49
+ postfixes: string[];
50
+ };
51
+ setTopicPriorities(priorities?: {}): void;
52
+ subscribe(topic: string, handler?: (..._: any[]) => void, immediate?: boolean, priority?: number): Promise<TopicSubscribeResult>;
53
+ /**
54
+ * Use `_subscribeInternal` when subscribing to a topic from within streaming-client itself.
55
+ * Internal subscriptions won't be overwritten by subscriptions from consumers and will be prioritized
56
+ * over subscriptions from consumers.
57
+ */
58
+ _subscribeInternal(topic: string): Promise<PubsubSubscriptionWithOptions | void>;
59
+ unsubscribe(topic: string, handler?: (..._: any[]) => void, immediate?: boolean): Promise<any>;
60
+ bulkSubscribe(topics: string[], options?: BulkSubscribeOpts, priorities?: {
61
+ [topicName: string]: number;
62
+ }): Promise<BulkSubscribeResult>;
63
+ get expose(): NotificationsAPI;
64
+ }
65
+ export interface NotificationsAPI {
66
+ subscribe(topic: string, handler?: (..._: any[]) => void, immediate?: boolean, priority?: number): Promise<any>;
67
+ unsubscribe(topic: string, handler?: (..._: any[]) => void, immediate?: boolean): Promise<any>;
68
+ bulkSubscribe(topics: string[], options?: BulkSubscribeOpts, priorities?: {
69
+ [topicName: string]: number;
70
+ }): Promise<any>;
71
+ }
72
+ export interface BulkSubscribeOpts {
73
+ replace?: boolean;
74
+ force?: boolean;
75
+ }
76
+ export interface BulkSubscribeResult {
77
+ [topic: string]: TopicSubscribeResult;
78
+ }
79
+ export interface TopicSubscribeResult {
80
+ topic: string;
81
+ state: 'Permitted' | 'Rejected' | 'Unknown';
82
+ rejectionReason?: string;
83
+ missingPermissions?: string[];
84
+ }
85
+ export interface ChannelTopicResponseEntity {
86
+ id: string;
87
+ state: 'Permitted' | 'Rejected';
88
+ rejectionReason?: string;
89
+ missingPermissions?: string[];
90
+ selfUri?: string;
91
+ }
92
+ export interface ChannelTopicsEntityListing {
93
+ entities: ChannelTopicResponseEntity[];
94
+ }