@dolbyio/dolbyio-rest-apis-client 3.4.4 → 3.5.0

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 (40) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +41 -2
  3. package/dist/communications/remix.js +8 -6
  4. package/dist/communications/streaming.d.ts +4 -2
  5. package/dist/communications/streaming.js +14 -10
  6. package/dist/index.d.ts +2 -1
  7. package/dist/index.js +4 -2
  8. package/dist/internal/httpHelpers.d.ts +8 -0
  9. package/dist/internal/httpHelpers.js +36 -2
  10. package/dist/streaming/cluster.d.ts +3 -0
  11. package/dist/streaming/cluster.js +78 -0
  12. package/dist/streaming/director.d.ts +24 -0
  13. package/dist/streaming/director.js +107 -0
  14. package/dist/streaming/geo.d.ts +27 -0
  15. package/dist/streaming/geo.js +110 -0
  16. package/dist/streaming/index.d.ts +7 -0
  17. package/dist/streaming/index.js +21 -0
  18. package/dist/streaming/internal/httpHelpers.d.ts +41 -0
  19. package/dist/streaming/internal/httpHelpers.js +172 -0
  20. package/dist/streaming/internal/urls.d.ts +2 -0
  21. package/dist/streaming/internal/urls.js +10 -0
  22. package/dist/streaming/publishToken.d.ts +9 -0
  23. package/dist/streaming/publishToken.js +284 -0
  24. package/dist/streaming/stream.d.ts +2 -0
  25. package/dist/streaming/stream.js +76 -0
  26. package/dist/streaming/subscribeToken.d.ts +6 -0
  27. package/dist/streaming/subscribeToken.js +182 -0
  28. package/dist/streaming/types/cluster.d.ts +14 -0
  29. package/dist/streaming/types/cluster.js +5 -0
  30. package/dist/streaming/types/core.d.ts +4 -0
  31. package/dist/streaming/types/core.js +5 -0
  32. package/dist/streaming/types/director.d.ts +14 -0
  33. package/dist/streaming/types/director.js +5 -0
  34. package/dist/streaming/types/geo.d.ts +4 -0
  35. package/dist/streaming/types/geo.js +5 -0
  36. package/dist/streaming/types/publishToken.d.ts +63 -0
  37. package/dist/streaming/types/publishToken.js +5 -0
  38. package/dist/streaming/types/subscribeToken.d.ts +43 -0
  39. package/dist/streaming/types/subscribeToken.js +5 -0
  40. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Dolby Laboratories
3
+ Copyright (c) 2023 Dolby Laboratories
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,6 +1,11 @@
1
- # Dolby.io REST APIs
1
+ [![Build Package](https://github.com/DolbyIO/dolbyio-rest-apis-client-node/actions/workflows/build-package.yml/badge.svg)](https://github.com/DolbyIO/dolbyio-rest-apis-client-node/actions/workflows/build-package.yml)
2
+ [![Publish Package](https://github.com/DolbyIO/dolbyio-rest-apis-client-node/actions/workflows/publish-package.yml/badge.svg)](https://github.com/DolbyIO/dolbyio-rest-apis-client-node/actions/workflows/publish-package.yml)
3
+ ![npm](https://img.shields.io/npm/v/@dolbyio/dolbyio-rest-apis-client)
4
+ [![License](https://img.shields.io/github/license/DolbyIO/dolbyio-rest-apis-client-node)](LICENSE)
2
5
 
3
- Node.JS wrapper for the dolby.io REST [Communications](https://docs.dolby.io/communications-apis/reference/authentication-api) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs.
6
+ # Dolby.io REST APIs Client for Node.JS
7
+
8
+ Node.JS wrapper for the dolby.io REST [Communications](https://docs.dolby.io/communications-apis/reference/authentication-api), [Streaming](https://docs.dolby.io/streaming-apis/reference) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs.
4
9
 
5
10
  ## Install this project
6
11
 
@@ -75,6 +80,40 @@ const conference = await dolbyio.communications.conference.createConference(jwt,
75
80
  console.log(`Conference created: ${conference.conferenceId}`);
76
81
  ```
77
82
 
83
+ ## Real-time Streaming Examples
84
+
85
+ ### Create a publish token
86
+
87
+ ```javascript
88
+ const dolbyio = require('@dolbyio/dolbyio-rest-apis-client');
89
+
90
+ const publishToken = await dolbyio.streaming.publishToken.create('api_secret', {
91
+ label: 'My token',
92
+ streams: [
93
+ {
94
+ streamName: 'feedA',
95
+ },
96
+ ],
97
+ });
98
+ console.log(publishToken);
99
+ ```
100
+
101
+ ### Create a subscribe token
102
+
103
+ ```javascript
104
+ const dolbyio = require('@dolbyio/dolbyio-rest-apis-client');
105
+
106
+ const subscribeToken = await dolbyio.streaming.subscribeToken.create('api_secret', {
107
+ label: 'My token',
108
+ streams: [
109
+ {
110
+ streamName: 'feedA',
111
+ },
112
+ ],
113
+ });
114
+ console.log(subscribeToken);
115
+ ```
116
+
78
117
  ## Media Examples
79
118
 
80
119
  ### Start an enhance job
@@ -23,11 +23,12 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
23
23
  * - `null`: uses the layout URL configured in the dashboard (if no URL is set in the dashboard, then uses the Dolby.io default);
24
24
  * - `default`: uses the Dolby.io default layout;
25
25
  * - URL string: uses this layout URL
26
+ * @param layoutName Defines a name for the given layout URL, which makes layout identification easier for customers especially when the layout URL is not explicit.
26
27
  *
27
28
  * @returns A `RemixStatus` object through a `Promise`.
28
29
  */
29
30
  var start = /*#__PURE__*/function () {
30
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(accessToken, conferenceId, layoutUrl) {
31
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(accessToken, conferenceId, layoutUrl, layoutName) {
31
32
  var body, options, response;
32
33
  return _regeneratorRuntime().wrap(function _callee$(_context) {
33
34
  while (1) {
@@ -35,6 +36,7 @@ var start = /*#__PURE__*/function () {
35
36
  case 0:
36
37
  body = {};
37
38
  if (layoutUrl) body['layoutUrl'] = layoutUrl;
39
+ if (layoutName) body['layoutName'] = layoutName;
38
40
  options = {
39
41
  hostname: _urls.COMMS_HOSTNAME,
40
42
  path: "/v2/conferences/mix/".concat(conferenceId, "/remix/start"),
@@ -45,19 +47,19 @@ var start = /*#__PURE__*/function () {
45
47
  },
46
48
  body: JSON.stringify(body)
47
49
  };
48
- _context.next = 5;
50
+ _context.next = 6;
49
51
  return (0, _httpHelpers.sendPost)(options);
50
- case 5:
52
+ case 6:
51
53
  response = _context.sent;
52
54
  return _context.abrupt("return", response);
53
- case 7:
55
+ case 8:
54
56
  case "end":
55
57
  return _context.stop();
56
58
  }
57
59
  }
58
60
  }, _callee);
59
61
  }));
60
- return function start(_x, _x2, _x3) {
62
+ return function start(_x, _x2, _x3, _x4) {
61
63
  return _ref.apply(this, arguments);
62
64
  };
63
65
  }();
@@ -100,7 +102,7 @@ var getStatus = /*#__PURE__*/function () {
100
102
  }
101
103
  }, _callee2);
102
104
  }));
103
- return function getStatus(_x4, _x5) {
105
+ return function getStatus(_x5, _x6) {
104
106
  return _ref2.apply(this, arguments);
105
107
  };
106
108
  }();
@@ -13,8 +13,9 @@ import JwtToken from '../types/jwtToken';
13
13
  * - `null`: uses the layout URL configured in the dashboard (if no URL is set in the dashboard, then uses the Dolby.io default);
14
14
  * - `default`: uses the Dolby.io default layout;
15
15
  * - URL string: uses this layout URL
16
+ * @param layoutName Defines a name for the given layout URL, which makes layout identification easier for customers especially when the layout URL is not explicit.
16
17
  */
17
- export declare const startRtmp: (accessToken: JwtToken, conferenceId: string, rtmpUrl: string, layoutUrl?: string) => Promise<void>;
18
+ export declare const startRtmp: (accessToken: JwtToken, conferenceId: string, rtmpUrl: string, layoutUrl?: string, layoutName?: string) => Promise<void>;
18
19
  /**
19
20
  * Stops the RTMP stream of the specified conference.
20
21
  *
@@ -37,8 +38,9 @@ export declare const stopRtmp: (accessToken: JwtToken, conferenceId: string) =>
37
38
  * - `null`: uses the layout URL configured in the dashboard (if no URL is set in the dashboard, then uses the Dolby.io default);
38
39
  * - `default`: uses the Dolby.io default layout;
39
40
  * - URL string: uses this layout URL
41
+ * @param layoutName Defines a name for the given layout URL, which makes layout identification easier for customers especially when the layout URL is not explicit.
40
42
  */
41
- export declare const startRts: (accessToken: JwtToken, conferenceId: string, streamName: string, publishingToken: string, layoutUrl?: string) => Promise<void>;
43
+ export declare const startRts: (accessToken: JwtToken, conferenceId: string, streamName: string, publishingToken: string, layoutUrl?: string, layoutName?: string) => Promise<void>;
42
44
  /**
43
45
  * Stops real-time streaming to Dolby.io Real-time Streaming services.
44
46
  *
@@ -24,9 +24,10 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
24
24
  * - `null`: uses the layout URL configured in the dashboard (if no URL is set in the dashboard, then uses the Dolby.io default);
25
25
  * - `default`: uses the Dolby.io default layout;
26
26
  * - URL string: uses this layout URL
27
+ * @param layoutName Defines a name for the given layout URL, which makes layout identification easier for customers especially when the layout URL is not explicit.
27
28
  */
28
29
  var startRtmp = /*#__PURE__*/function () {
29
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(accessToken, conferenceId, rtmpUrl, layoutUrl) {
30
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(accessToken, conferenceId, rtmpUrl, layoutUrl, layoutName) {
30
31
  var body, options;
31
32
  return _regeneratorRuntime().wrap(function _callee$(_context) {
32
33
  while (1) {
@@ -36,6 +37,7 @@ var startRtmp = /*#__PURE__*/function () {
36
37
  uri: rtmpUrl
37
38
  };
38
39
  if (layoutUrl) body['layoutUrl'] = layoutUrl;
40
+ if (layoutName) body['layoutName'] = layoutName;
39
41
  options = {
40
42
  hostname: _urls.COMMS_HOSTNAME,
41
43
  path: "/v2/conferences/mix/".concat(conferenceId, "/rtmp/start"),
@@ -46,16 +48,16 @@ var startRtmp = /*#__PURE__*/function () {
46
48
  },
47
49
  body: JSON.stringify(body)
48
50
  };
49
- _context.next = 5;
51
+ _context.next = 6;
50
52
  return (0, _httpHelpers.sendPost)(options);
51
- case 5:
53
+ case 6:
52
54
  case "end":
53
55
  return _context.stop();
54
56
  }
55
57
  }
56
58
  }, _callee);
57
59
  }));
58
- return function startRtmp(_x, _x2, _x3, _x4) {
60
+ return function startRtmp(_x, _x2, _x3, _x4, _x5) {
59
61
  return _ref.apply(this, arguments);
60
62
  };
61
63
  }();
@@ -94,7 +96,7 @@ var stopRtmp = /*#__PURE__*/function () {
94
96
  }
95
97
  }, _callee2);
96
98
  }));
97
- return function stopRtmp(_x5, _x6) {
99
+ return function stopRtmp(_x6, _x7) {
98
100
  return _ref2.apply(this, arguments);
99
101
  };
100
102
  }();
@@ -112,10 +114,11 @@ var stopRtmp = /*#__PURE__*/function () {
112
114
  * - `null`: uses the layout URL configured in the dashboard (if no URL is set in the dashboard, then uses the Dolby.io default);
113
115
  * - `default`: uses the Dolby.io default layout;
114
116
  * - URL string: uses this layout URL
117
+ * @param layoutName Defines a name for the given layout URL, which makes layout identification easier for customers especially when the layout URL is not explicit.
115
118
  */
116
119
  exports.stopRtmp = stopRtmp;
117
120
  var startRts = /*#__PURE__*/function () {
118
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(accessToken, conferenceId, streamName, publishingToken, layoutUrl) {
121
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(accessToken, conferenceId, streamName, publishingToken, layoutUrl, layoutName) {
119
122
  var body, options;
120
123
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
121
124
  while (1) {
@@ -126,6 +129,7 @@ var startRts = /*#__PURE__*/function () {
126
129
  publishingToken: publishingToken
127
130
  };
128
131
  if (layoutUrl) body['layoutUrl'] = layoutUrl;
132
+ if (layoutName) body['layoutName'] = layoutName;
129
133
  options = {
130
134
  hostname: _urls.COMMS_HOSTNAME,
131
135
  path: "/v2/conferences/mix/".concat(conferenceId, "/rts/start"),
@@ -136,16 +140,16 @@ var startRts = /*#__PURE__*/function () {
136
140
  },
137
141
  body: JSON.stringify(body)
138
142
  };
139
- _context3.next = 5;
143
+ _context3.next = 6;
140
144
  return (0, _httpHelpers.sendPost)(options);
141
- case 5:
145
+ case 6:
142
146
  case "end":
143
147
  return _context3.stop();
144
148
  }
145
149
  }
146
150
  }, _callee3);
147
151
  }));
148
- return function startRts(_x7, _x8, _x9, _x10, _x11) {
152
+ return function startRts(_x8, _x9, _x10, _x11, _x12, _x13) {
149
153
  return _ref3.apply(this, arguments);
150
154
  };
151
155
  }();
@@ -184,7 +188,7 @@ var stopRts = /*#__PURE__*/function () {
184
188
  }
185
189
  }, _callee4);
186
190
  }));
187
- return function stopRts(_x12, _x13) {
191
+ return function stopRts(_x14, _x15) {
188
192
  return _ref4.apply(this, arguments);
189
193
  };
190
194
  }();
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as authentication from './authentication';
2
2
  import * as communications from './communications';
3
3
  import * as media from './media';
4
+ import * as streaming from './streaming';
4
5
  declare const version: string;
5
- export { authentication, communications, media, version };
6
+ export { authentication, communications, media, streaming, version };
package/dist/index.js CHANGED
@@ -4,14 +4,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.version = exports.media = exports.communications = exports.authentication = void 0;
7
+ exports.version = exports.streaming = exports.media = exports.communications = exports.authentication = void 0;
8
8
  var authentication = _interopRequireWildcard(require("./authentication"));
9
9
  exports.authentication = authentication;
10
10
  var communications = _interopRequireWildcard(require("./communications"));
11
11
  exports.communications = communications;
12
12
  var media = _interopRequireWildcard(require("./media"));
13
13
  exports.media = media;
14
+ var streaming = _interopRequireWildcard(require("./streaming"));
15
+ exports.streaming = streaming;
14
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
- var version = "3.4.4";
18
+ var version = "3.5.0";
17
19
  exports.version = version;
@@ -40,6 +40,14 @@ export declare const sendPut: (options: RequestOptions) => Promise<any>;
40
40
  * @returns A JSON payload object through a Promise.
41
41
  */
42
42
  export declare const sendDelete: (options: RequestOptions) => Promise<any>;
43
+ /**
44
+ * Sends a PATCH request.
45
+ *
46
+ * @param options Request options.
47
+ *
48
+ * @returns A JSON payload object through a Promise.
49
+ */
50
+ export declare const sendPatch: (options: RequestOptions) => Promise<any>;
43
51
  /**
44
52
  * Download a file.
45
53
  *
@@ -4,7 +4,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.sendPut = exports.sendPost = exports.sendGet = exports.sendDelete = exports.download = void 0;
7
+ exports.sendPut = exports.sendPost = exports.sendPatch = exports.sendGet = exports.sendDelete = exports.download = void 0;
8
8
  var _fs = _interopRequireDefault(require("fs"));
9
9
  var _followRedirects = require("follow-redirects");
10
10
  var _url = require("url");
@@ -159,13 +159,47 @@ var sendDelete = /*#__PURE__*/function () {
159
159
  };
160
160
  }();
161
161
 
162
+ /**
163
+ * Sends a PATCH request.
164
+ *
165
+ * @param options Request options.
166
+ *
167
+ * @returns A JSON payload object through a Promise.
168
+ */
169
+ exports.sendDelete = sendDelete;
170
+ var sendPatch = /*#__PURE__*/function () {
171
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
172
+ var sendRequestOptions;
173
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
174
+ while (1) {
175
+ switch (_context2.prev = _context2.next) {
176
+ case 0:
177
+ sendRequestOptions = _objectSpread({
178
+ method: 'PATCH'
179
+ }, options);
180
+ _context2.next = 3;
181
+ return sendRequest(sendRequestOptions);
182
+ case 3:
183
+ return _context2.abrupt("return", _context2.sent);
184
+ case 4:
185
+ case "end":
186
+ return _context2.stop();
187
+ }
188
+ }
189
+ }, _callee2);
190
+ }));
191
+ return function sendPatch(_x2) {
192
+ return _ref2.apply(this, arguments);
193
+ };
194
+ }();
195
+
162
196
  /**
163
197
  * Download a file.
164
198
  *
165
199
  * @param filepath Where to save the file.
166
200
  * @param options Request options.
167
201
  */
168
- exports.sendDelete = sendDelete;
202
+ exports.sendPatch = sendPatch;
169
203
  var download = function download(filepath, options) {
170
204
  var sendRequestOptions = _objectSpread({
171
205
  method: 'GET'
@@ -0,0 +1,3 @@
1
+ import { ClusterResponse } from './types/cluster';
2
+ export declare const read: (apiSecret: string) => Promise<ClusterResponse>;
3
+ export declare const update: (apiSecret: string, defaultCluster: string) => Promise<ClusterResponse>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.update = exports.read = void 0;
8
+ var _httpHelpers = require("./internal/httpHelpers");
9
+ var _urls = require("./internal/urls");
10
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
11
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
+ var read = /*#__PURE__*/function () {
14
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(apiSecret) {
15
+ var options;
16
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
17
+ while (1) {
18
+ switch (_context.prev = _context.next) {
19
+ case 0:
20
+ options = {
21
+ hostname: _urls.SAPI_HOSTNAME,
22
+ path: '/api/cluster',
23
+ headers: {
24
+ Accept: 'application/json',
25
+ Authorization: "Bearer ".concat(apiSecret)
26
+ }
27
+ };
28
+ _context.next = 3;
29
+ return (0, _httpHelpers.sendGet)(options);
30
+ case 3:
31
+ return _context.abrupt("return", _context.sent);
32
+ case 4:
33
+ case "end":
34
+ return _context.stop();
35
+ }
36
+ }
37
+ }, _callee);
38
+ }));
39
+ return function read(_x) {
40
+ return _ref.apply(this, arguments);
41
+ };
42
+ }();
43
+ exports.read = read;
44
+ var update = /*#__PURE__*/function () {
45
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(apiSecret, defaultCluster) {
46
+ var body, options;
47
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
48
+ while (1) {
49
+ switch (_context2.prev = _context2.next) {
50
+ case 0:
51
+ body = {
52
+ defaultCluster: defaultCluster
53
+ };
54
+ options = {
55
+ hostname: _urls.SAPI_HOSTNAME,
56
+ path: '/api/cluster',
57
+ headers: {
58
+ Accept: 'application/json',
59
+ Authorization: "Bearer ".concat(apiSecret)
60
+ },
61
+ body: JSON.stringify(body)
62
+ };
63
+ _context2.next = 4;
64
+ return (0, _httpHelpers.sendPut)(options);
65
+ case 4:
66
+ return _context2.abrupt("return", _context2.sent);
67
+ case 5:
68
+ case "end":
69
+ return _context2.stop();
70
+ }
71
+ }
72
+ }, _callee2);
73
+ }));
74
+ return function update(_x2, _x3) {
75
+ return _ref2.apply(this, arguments);
76
+ };
77
+ }();
78
+ exports.update = update;
@@ -0,0 +1,24 @@
1
+ import { PublishResponse, SubscribeResponse } from './types/director';
2
+ /**
3
+ * Request for url and authorization to publish a stream.
4
+ *
5
+ * @link https://docs.dolby.io/streaming-apis/reference/director_publish
6
+ *
7
+ * @param publishingToken The publishing token.
8
+ * @param streamName The name of the stream.
9
+ *
10
+ * @returns A `PublishResponse` object through a `Promise`.
11
+ */
12
+ export declare const publish: (publishingToken: string, streamName: string) => Promise<PublishResponse>;
13
+ /**
14
+ * Request for url and authorization to subscribe to a stream.
15
+ *
16
+ * @link https://docs.dolby.io/streaming-apis/reference/director_subscribe
17
+ *
18
+ * @param streamName The name of the stream.
19
+ * @param streamAccountId Optional - The account identifier. Required only for published streams which have `subscribeRequiresAuth=false`.
20
+ * @param subscribeToken Optional - The subscribe token.
21
+ *
22
+ * @returns A `SubscribeResponse` object through a `Promise`.
23
+ */
24
+ export declare const subscribe: (streamName: string, streamAccountId?: string, publishingToken?: string) => Promise<SubscribeResponse>;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.subscribe = exports.publish = void 0;
8
+ var _httpHelpers = require("./internal/httpHelpers");
9
+ var _urls = require("./internal/urls");
10
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
11
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
+ /**
14
+ * Request for url and authorization to publish a stream.
15
+ *
16
+ * @link https://docs.dolby.io/streaming-apis/reference/director_publish
17
+ *
18
+ * @param publishingToken The publishing token.
19
+ * @param streamName The name of the stream.
20
+ *
21
+ * @returns A `PublishResponse` object through a `Promise`.
22
+ */
23
+ var publish = /*#__PURE__*/function () {
24
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(publishingToken, streamName) {
25
+ var body, options;
26
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
27
+ while (1) {
28
+ switch (_context.prev = _context.next) {
29
+ case 0:
30
+ body = {
31
+ streamName: streamName
32
+ };
33
+ options = {
34
+ hostname: _urls.SAPI_DIRECTOR_HOSTNAME,
35
+ path: '/api/director/publish',
36
+ headers: {
37
+ Accept: 'application/json',
38
+ 'Content-Type': 'application/json',
39
+ Authorization: "Bearer ".concat(publishingToken)
40
+ },
41
+ body: JSON.stringify(body)
42
+ };
43
+ _context.next = 4;
44
+ return (0, _httpHelpers.sendPost)(options);
45
+ case 4:
46
+ return _context.abrupt("return", _context.sent);
47
+ case 5:
48
+ case "end":
49
+ return _context.stop();
50
+ }
51
+ }
52
+ }, _callee);
53
+ }));
54
+ return function publish(_x, _x2) {
55
+ return _ref.apply(this, arguments);
56
+ };
57
+ }();
58
+
59
+ /**
60
+ * Request for url and authorization to subscribe to a stream.
61
+ *
62
+ * @link https://docs.dolby.io/streaming-apis/reference/director_subscribe
63
+ *
64
+ * @param streamName The name of the stream.
65
+ * @param streamAccountId Optional - The account identifier. Required only for published streams which have `subscribeRequiresAuth=false`.
66
+ * @param subscribeToken Optional - The subscribe token.
67
+ *
68
+ * @returns A `SubscribeResponse` object through a `Promise`.
69
+ */
70
+ exports.publish = publish;
71
+ var subscribe = /*#__PURE__*/function () {
72
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(streamName, streamAccountId, publishingToken) {
73
+ var body, options;
74
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
75
+ while (1) {
76
+ switch (_context2.prev = _context2.next) {
77
+ case 0:
78
+ body = {
79
+ streamName: streamName
80
+ };
81
+ if (streamAccountId) body['streamAccountId'] = streamAccountId;
82
+ options = {
83
+ hostname: _urls.SAPI_DIRECTOR_HOSTNAME,
84
+ path: '/api/director/subscribe',
85
+ headers: {
86
+ Accept: 'application/json',
87
+ 'Content-Type': 'application/json',
88
+ Authorization: publishingToken ? "Bearer ".concat(publishingToken) : 'NoAuth'
89
+ },
90
+ body: JSON.stringify(body)
91
+ };
92
+ _context2.next = 5;
93
+ return (0, _httpHelpers.sendPost)(options);
94
+ case 5:
95
+ return _context2.abrupt("return", _context2.sent);
96
+ case 6:
97
+ case "end":
98
+ return _context2.stop();
99
+ }
100
+ }
101
+ }, _callee2);
102
+ }));
103
+ return function subscribe(_x3, _x4, _x5) {
104
+ return _ref2.apply(this, arguments);
105
+ };
106
+ }();
107
+ exports.subscribe = subscribe;
@@ -0,0 +1,27 @@
1
+ import { GeoRestrictions } from './types/geo';
2
+ /**
3
+ * Read Account Geo Restrictions.
4
+ *
5
+ * Gets account wide geo restrictions. If a Token (either Publish or Subscribe) does not define any geo restrictions, the account wide rules are used.
6
+ *
7
+ * @link https://docs.dolby.io/streaming-apis/reference/geo_geo
8
+ *
9
+ * @param apiSecret The API secret.
10
+ *
11
+ * @returns A `GeoRestrictions` object through a `Promise`.
12
+ */
13
+ export declare const read: (apiSecret: string) => Promise<GeoRestrictions>;
14
+ /**
15
+ * Update Account Geo Restrictions
16
+ *
17
+ * Update account wide geo restrictions.
18
+ *
19
+ * @link https://docs.dolby.io/streaming-apis/reference/geo_updategeo
20
+ *
21
+ * @param apiSecret The API secret.
22
+ * @param allowedCountries The publishing token. An empty array [] removes all rules.
23
+ * @param deniedCountries The publishing token. An empty array [] removes all rules.
24
+ *
25
+ * @returns A `GeoRestrictions` object through a `Promise`.
26
+ */
27
+ export declare const update: (apiSecret: string, allowedCountries?: string[] | null, deniedCountries?: string[] | null) => Promise<GeoRestrictions>;