@dolbyio/dolbyio-rest-apis-client 3.4.5 → 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.
- package/README.md +41 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/internal/httpHelpers.d.ts +8 -0
- package/dist/internal/httpHelpers.js +36 -2
- package/dist/streaming/cluster.d.ts +3 -0
- package/dist/streaming/cluster.js +78 -0
- package/dist/streaming/director.d.ts +24 -0
- package/dist/streaming/director.js +107 -0
- package/dist/streaming/geo.d.ts +27 -0
- package/dist/streaming/geo.js +110 -0
- package/dist/streaming/index.d.ts +7 -0
- package/dist/streaming/index.js +21 -0
- package/dist/streaming/internal/httpHelpers.d.ts +41 -0
- package/dist/streaming/internal/httpHelpers.js +172 -0
- package/dist/streaming/internal/urls.d.ts +2 -0
- package/dist/streaming/internal/urls.js +10 -0
- package/dist/streaming/publishToken.d.ts +9 -0
- package/dist/streaming/publishToken.js +284 -0
- package/dist/streaming/stream.d.ts +2 -0
- package/dist/streaming/stream.js +76 -0
- package/dist/streaming/subscribeToken.d.ts +6 -0
- package/dist/streaming/subscribeToken.js +182 -0
- package/dist/streaming/types/cluster.d.ts +14 -0
- package/dist/streaming/types/cluster.js +5 -0
- package/dist/streaming/types/core.d.ts +4 -0
- package/dist/streaming/types/core.js +5 -0
- package/dist/streaming/types/director.d.ts +14 -0
- package/dist/streaming/types/director.js +5 -0
- package/dist/streaming/types/geo.d.ts +4 -0
- package/dist/streaming/types/geo.js +5 -0
- package/dist/streaming/types/publishToken.d.ts +63 -0
- package/dist/streaming/types/publishToken.js +5 -0
- package/dist/streaming/types/subscribeToken.d.ts +43 -0
- package/dist/streaming/types/subscribeToken.js +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://github.com/DolbyIO/dolbyio-rest-apis-client-node/actions/workflows/build-package.yml)
|
|
2
|
+
[](https://github.com/DolbyIO/dolbyio-rest-apis-client-node/actions/workflows/publish-package.yml)
|
|
3
|
+

|
|
4
|
+
[](LICENSE)
|
|
2
5
|
|
|
3
|
-
|
|
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
|
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.
|
|
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.
|
|
202
|
+
exports.sendPatch = sendPatch;
|
|
169
203
|
var download = function download(filepath, options) {
|
|
170
204
|
var sendRequestOptions = _objectSpread({
|
|
171
205
|
method: 'GET'
|
|
@@ -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>;
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* Read Account Geo Restrictions.
|
|
15
|
+
*
|
|
16
|
+
* Gets account wide geo restrictions. If a Token (either Publish or Subscribe) does not define any geo restrictions, the account wide rules are used.
|
|
17
|
+
*
|
|
18
|
+
* @link https://docs.dolby.io/streaming-apis/reference/geo_geo
|
|
19
|
+
*
|
|
20
|
+
* @param apiSecret The API secret.
|
|
21
|
+
*
|
|
22
|
+
* @returns A `GeoRestrictions` object through a `Promise`.
|
|
23
|
+
*/
|
|
24
|
+
var read = /*#__PURE__*/function () {
|
|
25
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(apiSecret) {
|
|
26
|
+
var options;
|
|
27
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
28
|
+
while (1) {
|
|
29
|
+
switch (_context.prev = _context.next) {
|
|
30
|
+
case 0:
|
|
31
|
+
options = {
|
|
32
|
+
hostname: _urls.SAPI_HOSTNAME,
|
|
33
|
+
path: '/api/geo/account',
|
|
34
|
+
headers: {
|
|
35
|
+
Accept: 'application/json',
|
|
36
|
+
Authorization: "Bearer ".concat(apiSecret)
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
_context.next = 3;
|
|
40
|
+
return (0, _httpHelpers.sendGet)(options);
|
|
41
|
+
case 3:
|
|
42
|
+
return _context.abrupt("return", _context.sent);
|
|
43
|
+
case 4:
|
|
44
|
+
case "end":
|
|
45
|
+
return _context.stop();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, _callee);
|
|
49
|
+
}));
|
|
50
|
+
return function read(_x) {
|
|
51
|
+
return _ref.apply(this, arguments);
|
|
52
|
+
};
|
|
53
|
+
}();
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Update Account Geo Restrictions
|
|
57
|
+
*
|
|
58
|
+
* Update account wide geo restrictions.
|
|
59
|
+
*
|
|
60
|
+
* @link https://docs.dolby.io/streaming-apis/reference/geo_updategeo
|
|
61
|
+
*
|
|
62
|
+
* @param apiSecret The API secret.
|
|
63
|
+
* @param allowedCountries The publishing token. An empty array [] removes all rules.
|
|
64
|
+
* @param deniedCountries The publishing token. An empty array [] removes all rules.
|
|
65
|
+
*
|
|
66
|
+
* @returns A `GeoRestrictions` object through a `Promise`.
|
|
67
|
+
*/
|
|
68
|
+
exports.read = read;
|
|
69
|
+
var update = /*#__PURE__*/function () {
|
|
70
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(apiSecret) {
|
|
71
|
+
var allowedCountries,
|
|
72
|
+
deniedCountries,
|
|
73
|
+
body,
|
|
74
|
+
options,
|
|
75
|
+
_args2 = arguments;
|
|
76
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
77
|
+
while (1) {
|
|
78
|
+
switch (_context2.prev = _context2.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
allowedCountries = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : null;
|
|
81
|
+
deniedCountries = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : null;
|
|
82
|
+
body = {};
|
|
83
|
+
if (allowedCountries) body['updateAllowedCountries'] = allowedCountries;
|
|
84
|
+
if (deniedCountries) body['updateDeniedCountries'] = deniedCountries;
|
|
85
|
+
options = {
|
|
86
|
+
hostname: _urls.SAPI_HOSTNAME,
|
|
87
|
+
path: '/api/geo/account',
|
|
88
|
+
headers: {
|
|
89
|
+
Accept: 'application/json',
|
|
90
|
+
'Content-Type': 'application/json',
|
|
91
|
+
Authorization: "Bearer ".concat(apiSecret)
|
|
92
|
+
},
|
|
93
|
+
body: JSON.stringify(body)
|
|
94
|
+
};
|
|
95
|
+
_context2.next = 8;
|
|
96
|
+
return (0, _httpHelpers.sendPost)(options);
|
|
97
|
+
case 8:
|
|
98
|
+
return _context2.abrupt("return", _context2.sent);
|
|
99
|
+
case 9:
|
|
100
|
+
case "end":
|
|
101
|
+
return _context2.stop();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, _callee2);
|
|
105
|
+
}));
|
|
106
|
+
return function update(_x2) {
|
|
107
|
+
return _ref2.apply(this, arguments);
|
|
108
|
+
};
|
|
109
|
+
}();
|
|
110
|
+
exports.update = update;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as cluster from './cluster';
|
|
2
|
+
import * as director from './director';
|
|
3
|
+
import * as geo from './geo';
|
|
4
|
+
import * as publishToken from './publishToken';
|
|
5
|
+
import * as stream from './stream';
|
|
6
|
+
import * as subscribeToken from './subscribeToken';
|
|
7
|
+
export { cluster, director, geo, publishToken, stream, subscribeToken };
|
|
@@ -0,0 +1,21 @@
|
|
|
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.subscribeToken = exports.stream = exports.publishToken = exports.geo = exports.director = exports.cluster = void 0;
|
|
8
|
+
var cluster = _interopRequireWildcard(require("./cluster"));
|
|
9
|
+
exports.cluster = cluster;
|
|
10
|
+
var director = _interopRequireWildcard(require("./director"));
|
|
11
|
+
exports.director = director;
|
|
12
|
+
var geo = _interopRequireWildcard(require("./geo"));
|
|
13
|
+
exports.geo = geo;
|
|
14
|
+
var publishToken = _interopRequireWildcard(require("./publishToken"));
|
|
15
|
+
exports.publishToken = publishToken;
|
|
16
|
+
var stream = _interopRequireWildcard(require("./stream"));
|
|
17
|
+
exports.stream = stream;
|
|
18
|
+
var subscribeToken = _interopRequireWildcard(require("./subscribeToken"));
|
|
19
|
+
exports.subscribeToken = subscribeToken;
|
|
20
|
+
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); }
|
|
21
|
+
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; }
|