@dolbyio/dolbyio-rest-apis-client 3.5.5 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
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
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)
3
+ [![npm](https://img.shields.io/npm/v/@dolbyio/dolbyio-rest-apis-client)](https://www.npmjs.com/package/@dolbyio/dolbyio-rest-apis-client)
4
4
  [![License](https://img.shields.io/github/license/DolbyIO/dolbyio-rest-apis-client-node)](LICENSE)
5
5
 
6
6
  # Dolby.io REST APIs Client for Node.JS
@@ -30,6 +30,20 @@ const jwt = await dolbyio.authentication.getApiAccessToken(APP_KEY, APP_SECRET);
30
30
  console.log(`Access Token: ${jwt.access_token}`);
31
31
  ```
32
32
 
33
+ To request a particular scope for this access token:
34
+
35
+ ```javascript
36
+ const dolbyio = require('@dolbyio/dolbyio-rest-apis-client');
37
+
38
+ const APP_KEY = 'YOUR_APP_KEY';
39
+ const APP_SECRET = 'YOUR_APP_SECRET';
40
+
41
+ const jwt = await dolbyio.authentication.getApiAccessToken(APP_KEY, APP_SECRET, 3600, ['comms:client_access_token:create']);
42
+
43
+ console.log(`Access Token: ${jwt.access_token}`);
44
+ console.log(`Scope: ${jwt.scope}`);
45
+ ```
46
+
33
47
  ## Communications Examples
34
48
 
35
49
  ### Authenticate
@@ -42,9 +56,16 @@ const dolbyio = require('@dolbyio/dolbyio-rest-apis-client');
42
56
  const APP_KEY = 'YOUR_APP_KEY';
43
57
  const APP_SECRET = 'YOUR_APP_SECRET';
44
58
 
45
- const at = await dolbyio.communications.authentication.getClientAccessToken(APP_KEY, APP_SECRET);
59
+ // Request an API Token
60
+ const api_token = await dolbyio.authentication.getApiAccessToken(APP_KEY, APP_SECRET, 3600, ['comms:client_access_token:create']);
46
61
 
47
- console.log(`Access Token: ${at.access_token}`);
62
+ // Request the Client Access Token
63
+ const cat = await dolbyio.communications.authentication.getClientAccessTokenV2({
64
+ accessToken: api_token,
65
+ sessionScope: ['*'],
66
+ });
67
+
68
+ console.log(`Client Access Token: ${cat.access_token}`);
48
69
  ```
49
70
 
50
71
  ### Create a conference
@@ -71,8 +92,8 @@ const options = {
71
92
  ],
72
93
  };
73
94
 
74
- // Request an Access Token
75
- const jwt = await dolbyio.authentication.getApiAccessToken(APP_KEY, APP_SECRET);
95
+ // Request an API Token
96
+ const jwt = await dolbyio.authentication.getApiAccessToken(APP_KEY, APP_SECRET, 3600, ['comms:conf:create']);
76
97
 
77
98
  // Create the conference
78
99
  const conference = await dolbyio.communications.conference.createConference(jwt, options);
@@ -193,7 +214,7 @@ At this stage, the file has been processed and written to the temporary storage
193
214
  // Local path where to download the file to
194
215
  const enhancedFilePath = '/path/to/enhanced_file.mp4';
195
216
 
196
- await dolbyio.io.downloadFile(jwt, outputUrl, enhancedFilePath);
217
+ await dolbyio.media.io.downloadFile(jwt, outputUrl, enhancedFilePath);
197
218
  ```
198
219
 
199
220
  ## Build this project
@@ -9,8 +9,21 @@ import JwtToken from './types/jwtToken';
9
9
  *
10
10
  * @param appKey Your Dolby.io App Key.
11
11
  * @param appSecret Your Dolby.io App Secret.
12
- * @param expiresIn API token expiration time in seconds. The maximum value is 86,400, indicating 24 hours. If no value is specified, the default is 1800, indicating 30 minutes.
12
+ * @param expiresIn API token expiration time in seconds. If no value is specified, the default is 1800, indicating 30 minutes. The maximum value is 86,400, indicating 24 hours.
13
+ * @param scope A list of case-sensitive strings allowing you to control what scope of access the API token should have. If not specified, the API token will possess unrestricted access to all resources and actions. The API supports the following scopes:
14
+ * * `comms:client_access_token:create`: Allows requesting a client access token.
15
+ * * `comms:conf:create`: Allows creating a new conference.
16
+ * * `comms:conf:admin`: Allows administrating a conference, including actions such as Invite, Kick, Send Message, Set Spatial Listener's Audio, and Update Permissions.
17
+ * * `comms:conf:destroy`: Allows terminating a live conference.
18
+ * * `comms:monitor:delete`: Allows deleting data from the Monitor API, for example, deleting recordings.
19
+ * * `comms:monitor:read`: Allows reading data through the Monitor API.
20
+ * * `comms:monitor:download`: Allows generating download URLs for data (e.g. recording) through the Monitor API.
21
+ * * `comms:stream:write`: Allows starting and stopping RTMP or Real-Time streaming.
22
+ * * `comms:remix:write`: Allows remixing recordings.
23
+ * * `comms:remix:read`: Allows reading the remix status.
24
+ * * `comms:record:write`: Allows starting and stopping recordings.
25
+ * Incorrect values are omitted. If you want to give the token access to all Communications REST APIs, you can use a wildcard, such as comms:*
13
26
  *
14
27
  * @returns A {@link JwtToken} object through a {@link Promise}.
15
28
  */
16
- export declare const getApiAccessToken: (appKey: string, appSecret: string, expiresIn?: number) => Promise<JwtToken>;
29
+ export declare const getApiAccessToken: (appKey: string, appSecret: string, expiresIn?: number, scope?: string[]) => Promise<JwtToken>;
@@ -20,19 +20,37 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
20
20
  *
21
21
  * @param appKey Your Dolby.io App Key.
22
22
  * @param appSecret Your Dolby.io App Secret.
23
- * @param expiresIn API token expiration time in seconds. The maximum value is 86,400, indicating 24 hours. If no value is specified, the default is 1800, indicating 30 minutes.
23
+ * @param expiresIn API token expiration time in seconds. If no value is specified, the default is 1800, indicating 30 minutes. The maximum value is 86,400, indicating 24 hours.
24
+ * @param scope A list of case-sensitive strings allowing you to control what scope of access the API token should have. If not specified, the API token will possess unrestricted access to all resources and actions. The API supports the following scopes:
25
+ * * `comms:client_access_token:create`: Allows requesting a client access token.
26
+ * * `comms:conf:create`: Allows creating a new conference.
27
+ * * `comms:conf:admin`: Allows administrating a conference, including actions such as Invite, Kick, Send Message, Set Spatial Listener's Audio, and Update Permissions.
28
+ * * `comms:conf:destroy`: Allows terminating a live conference.
29
+ * * `comms:monitor:delete`: Allows deleting data from the Monitor API, for example, deleting recordings.
30
+ * * `comms:monitor:read`: Allows reading data through the Monitor API.
31
+ * * `comms:monitor:download`: Allows generating download URLs for data (e.g. recording) through the Monitor API.
32
+ * * `comms:stream:write`: Allows starting and stopping RTMP or Real-Time streaming.
33
+ * * `comms:remix:write`: Allows remixing recordings.
34
+ * * `comms:remix:read`: Allows reading the remix status.
35
+ * * `comms:record:write`: Allows starting and stopping recordings.
36
+ * Incorrect values are omitted. If you want to give the token access to all Communications REST APIs, you can use a wildcard, such as comms:*
24
37
  *
25
38
  * @returns A {@link JwtToken} object through a {@link Promise}.
26
39
  */
27
40
  var getApiAccessToken = /*#__PURE__*/function () {
28
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(appKey, appSecret, expiresIn) {
41
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(appKey, appSecret, expiresIn, scope) {
29
42
  var body, authz, options, response;
30
43
  return _regeneratorRuntime().wrap(function _callee$(_context) {
31
44
  while (1) switch (_context.prev = _context.next) {
32
45
  case 0:
33
- body = 'grant_type=client_credentials';
46
+ body = new URLSearchParams({
47
+ grant_type: 'client_credentials'
48
+ });
34
49
  if (expiresIn) {
35
- body += "&expires_in=".concat(expiresIn);
50
+ body.append('expires_in', expiresIn.toFixed(0));
51
+ }
52
+ if (scope !== null && scope !== void 0 && scope.length) {
53
+ body.append('scope', scope.join(' '));
36
54
  }
37
55
  authz = Buffer.from("".concat(appKey, ":").concat(appSecret)).toString('base64');
38
56
  options = {
@@ -43,20 +61,20 @@ var getApiAccessToken = /*#__PURE__*/function () {
43
61
  'Cache-Control': 'no-cache',
44
62
  Authorization: "Basic ".concat(authz)
45
63
  },
46
- body: body
64
+ body: body.toString()
47
65
  };
48
- _context.next = 6;
66
+ _context.next = 7;
49
67
  return (0, _httpHelpers.sendPost)(options);
50
- case 6:
68
+ case 7:
51
69
  response = _context.sent;
52
70
  return _context.abrupt("return", response);
53
- case 8:
71
+ case 9:
54
72
  case "end":
55
73
  return _context.stop();
56
74
  }
57
75
  }, _callee);
58
76
  }));
59
- return function getApiAccessToken(_x, _x2, _x3) {
77
+ return function getApiAccessToken(_x, _x2, _x3, _x4) {
60
78
  return _ref.apply(this, arguments);
61
79
  };
62
80
  }();
@@ -1,13 +1,28 @@
1
1
  import JwtToken from '../types/jwtToken';
2
+ import { GetClientAccessTokenOptions } from './types/authentication';
2
3
  /**
3
4
  * Gets a client access token to authenticate a session.
4
5
  *
5
- * @link https://docs.dolby.io/communications-apis/reference/get-client-access-token
6
+ * @link https://docs.dolby.io/communications-apis/reference/get-client-access-token-v1
6
7
  *
7
8
  * @param appKey Your Dolby.io App Key.
8
9
  * @param appSecret Your Dolby.io App Secret.
9
- * @param expiresIn Access token expiration time in seconds. The maximum value is 2,592,000, indicating 30 days. If no value is specified, the default is 3,600, indicating one hour.
10
+ * @param expiresIn Access token expiration time in seconds. If no value is specified, the default is 3,600, indicating one hour. The maximum value is 86,400, indicating 24 hours.
10
11
  *
11
12
  * @returns A {@link JwtToken} object through a {@link Promise}.
13
+ *
14
+ * @deprecated This function is now deprecated and will be removed in the next release of this SDK. Please start using {@link getClientAccessTokenV2} instead.
12
15
  */
13
16
  export declare const getClientAccessToken: (appKey: string, appSecret: string, expiresIn?: number) => Promise<JwtToken>;
17
+ /**
18
+ * Generates a client access token.
19
+ *
20
+ * This API returns a client access token that your backend can request on behalf of a client to initialize the Dolby.io SDK in a secure way.
21
+ *
22
+ * @link https://docs.dolby.io/communications-apis/reference/get-client-access-token
23
+ *
24
+ * @param options Options to generate a client access token.
25
+ *
26
+ * @returns A {@link JwtToken} object through a {@link Promise}.
27
+ */
28
+ export declare const getClientAccessTokenV2: (options: GetClientAccessTokenOptions) => Promise<JwtToken>;
@@ -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.getClientAccessToken = void 0;
7
+ exports.getClientAccessTokenV2 = exports.getClientAccessToken = void 0;
8
8
  var _httpHelpers = require("../internal/httpHelpers");
9
9
  var _urls = require("./internal/urls");
10
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 methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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; }
@@ -13,13 +13,15 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
13
13
  /**
14
14
  * Gets a client access token to authenticate a session.
15
15
  *
16
- * @link https://docs.dolby.io/communications-apis/reference/get-client-access-token
16
+ * @link https://docs.dolby.io/communications-apis/reference/get-client-access-token-v1
17
17
  *
18
18
  * @param appKey Your Dolby.io App Key.
19
19
  * @param appSecret Your Dolby.io App Secret.
20
- * @param expiresIn Access token expiration time in seconds. The maximum value is 2,592,000, indicating 30 days. If no value is specified, the default is 3,600, indicating one hour.
20
+ * @param expiresIn Access token expiration time in seconds. If no value is specified, the default is 3,600, indicating one hour. The maximum value is 86,400, indicating 24 hours.
21
21
  *
22
22
  * @returns A {@link JwtToken} object through a {@link Promise}.
23
+ *
24
+ * @deprecated This function is now deprecated and will be removed in the next release of this SDK. Please start using {@link getClientAccessTokenV2} instead.
23
25
  */
24
26
  var getClientAccessToken = /*#__PURE__*/function () {
25
27
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(appKey, appSecret, expiresIn) {
@@ -27,9 +29,11 @@ var getClientAccessToken = /*#__PURE__*/function () {
27
29
  return _regeneratorRuntime().wrap(function _callee$(_context) {
28
30
  while (1) switch (_context.prev = _context.next) {
29
31
  case 0:
30
- body = 'grant_type=client_credentials';
32
+ body = new URLSearchParams({
33
+ grant_type: 'client_credentials'
34
+ });
31
35
  if (expiresIn) {
32
- body += "&expires_in=".concat(expiresIn);
36
+ body.append('expires_in', expiresIn.toFixed(0));
33
37
  }
34
38
  authz = Buffer.from("".concat(appKey, ":").concat(appSecret)).toString('base64');
35
39
  options = {
@@ -40,7 +44,7 @@ var getClientAccessToken = /*#__PURE__*/function () {
40
44
  'Cache-Control': 'no-cache',
41
45
  Authorization: "Basic ".concat(authz)
42
46
  },
43
- body: body
47
+ body: body.toString()
44
48
  };
45
49
  _context.next = 6;
46
50
  return (0, _httpHelpers.sendPost)(options);
@@ -57,4 +61,54 @@ var getClientAccessToken = /*#__PURE__*/function () {
57
61
  return _ref.apply(this, arguments);
58
62
  };
59
63
  }();
60
- exports.getClientAccessToken = getClientAccessToken;
64
+
65
+ /**
66
+ * Generates a client access token.
67
+ *
68
+ * This API returns a client access token that your backend can request on behalf of a client to initialize the Dolby.io SDK in a secure way.
69
+ *
70
+ * @link https://docs.dolby.io/communications-apis/reference/get-client-access-token
71
+ *
72
+ * @param options Options to generate a client access token.
73
+ *
74
+ * @returns A {@link JwtToken} object through a {@link Promise}.
75
+ */
76
+ exports.getClientAccessToken = getClientAccessToken;
77
+ var getClientAccessTokenV2 = /*#__PURE__*/function () {
78
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
79
+ var body, postOptions, response;
80
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
81
+ while (1) switch (_context2.prev = _context2.next) {
82
+ case 0:
83
+ body = {
84
+ sessionScope: options.sessionScope.join(' ')
85
+ };
86
+ if (options.externalId) body['externalId'] = options.externalId;
87
+ if (options.expiresIn) body['expiresIn'] = options.expiresIn;
88
+ postOptions = {
89
+ hostname: _urls.COMMS_HOSTNAME,
90
+ path: '/v2/client-access-token',
91
+ headers: {
92
+ 'Cache-Control': 'no-cache',
93
+ Accept: 'application/json',
94
+ 'Content-Type': 'application/json',
95
+ Authorization: "".concat(options.accessToken.token_type, " ").concat(options.accessToken.access_token)
96
+ },
97
+ body: JSON.stringify(body)
98
+ };
99
+ _context2.next = 6;
100
+ return (0, _httpHelpers.sendPost)(postOptions);
101
+ case 6:
102
+ response = _context2.sent;
103
+ return _context2.abrupt("return", response);
104
+ case 8:
105
+ case "end":
106
+ return _context2.stop();
107
+ }
108
+ }, _callee2);
109
+ }));
110
+ return function getClientAccessTokenV2(_x4) {
111
+ return _ref2.apply(this, arguments);
112
+ };
113
+ }();
114
+ exports.getClientAccessTokenV2 = getClientAccessTokenV2;
@@ -1,4 +1,4 @@
1
- import { CreateConferenceOptions, Conference, UserTokens } from './types/conference';
1
+ import { CreateConferenceOptions, Conference, UserTokens, ListParticipantsResponse } from './types/conference';
2
2
  import { SpatialEnvironment, SpatialListener, SpatialUsers } from './types/spatialAudio';
3
3
  import JwtToken from '../types/jwtToken';
4
4
  import Participant from './types/participant';
@@ -73,6 +73,17 @@ export declare const setSpatialListenersAudio: (accessToken: JwtToken, conferenc
73
73
  * @returns The list of user tokens for each participants.
74
74
  */
75
75
  export declare const updatePermissions: (accessToken: JwtToken, conferenceId: string, participants: Array<Participant>) => Promise<UserTokens>;
76
+ /**
77
+ * Returns the current participant list.
78
+ *
79
+ * @link https://docs.dolby.io/communications-apis/reference/return-participant-list
80
+ *
81
+ * @param accessToken Access token to use for authentication.
82
+ * @param conferenceId Identifier of the conference.
83
+ *
84
+ * @returns The list of participants in the conference.
85
+ */
86
+ export declare const participants: (accessToken: JwtToken, conferenceId: string) => Promise<ListParticipantsResponse>;
76
87
  /**
77
88
  * Terminates an ongoing conference and removes all remaining participants from the conference.
78
89
  *
@@ -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.updatePermissions = exports.terminate = exports.setSpatialListenersAudio = exports.sendMessage = exports.kick = exports.invite = exports.createConference = void 0;
7
+ exports.updatePermissions = exports.terminate = exports.setSpatialListenersAudio = exports.sendMessage = exports.participants = exports.kick = exports.invite = exports.createConference = void 0;
8
8
  var _httpHelpers = require("../internal/httpHelpers");
9
9
  var _urls = require("./internal/urls");
10
10
  var _rtcpMode = require("./types/rtcpMode");
@@ -333,23 +333,25 @@ var updatePermissions = /*#__PURE__*/function () {
333
333
  }();
334
334
 
335
335
  /**
336
- * Terminates an ongoing conference and removes all remaining participants from the conference.
336
+ * Returns the current participant list.
337
337
  *
338
- * @link https://docs.dolby.io/communications-apis/reference/terminate-conference
338
+ * @link https://docs.dolby.io/communications-apis/reference/return-participant-list
339
339
  *
340
340
  * @param accessToken Access token to use for authentication.
341
341
  * @param conferenceId Identifier of the conference.
342
+ *
343
+ * @returns The list of participants in the conference.
342
344
  */
343
345
  exports.updatePermissions = updatePermissions;
344
- var terminate = /*#__PURE__*/function () {
346
+ var participants = /*#__PURE__*/function () {
345
347
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(accessToken, conferenceId) {
346
- var options;
348
+ var requestOptions, response;
347
349
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
348
350
  while (1) switch (_context7.prev = _context7.next) {
349
351
  case 0:
350
- options = {
352
+ requestOptions = {
351
353
  hostname: _urls.COMMS_HOSTNAME,
352
- path: "/v2/conferences/".concat(conferenceId),
354
+ path: "/v2/conferences/".concat(conferenceId, "/participants"),
353
355
  headers: {
354
356
  Accept: 'application/json',
355
357
  'Content-Type': 'application/json',
@@ -357,15 +359,55 @@ var terminate = /*#__PURE__*/function () {
357
359
  }
358
360
  };
359
361
  _context7.next = 3;
360
- return (0, _httpHelpers.sendDelete)(options);
362
+ return (0, _httpHelpers.sendGet)(requestOptions);
361
363
  case 3:
364
+ response = _context7.sent;
365
+ return _context7.abrupt("return", response);
366
+ case 5:
362
367
  case "end":
363
368
  return _context7.stop();
364
369
  }
365
370
  }, _callee7);
366
371
  }));
367
- return function terminate(_x22, _x23) {
372
+ return function participants(_x22, _x23) {
368
373
  return _ref7.apply(this, arguments);
369
374
  };
370
375
  }();
376
+
377
+ /**
378
+ * Terminates an ongoing conference and removes all remaining participants from the conference.
379
+ *
380
+ * @link https://docs.dolby.io/communications-apis/reference/terminate-conference
381
+ *
382
+ * @param accessToken Access token to use for authentication.
383
+ * @param conferenceId Identifier of the conference.
384
+ */
385
+ exports.participants = participants;
386
+ var terminate = /*#__PURE__*/function () {
387
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(accessToken, conferenceId) {
388
+ var options;
389
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
390
+ while (1) switch (_context8.prev = _context8.next) {
391
+ case 0:
392
+ options = {
393
+ hostname: _urls.COMMS_HOSTNAME,
394
+ path: "/v2/conferences/".concat(conferenceId),
395
+ headers: {
396
+ Accept: 'application/json',
397
+ 'Content-Type': 'application/json',
398
+ Authorization: "".concat(accessToken.token_type, " ").concat(accessToken.access_token)
399
+ }
400
+ };
401
+ _context8.next = 3;
402
+ return (0, _httpHelpers.sendDelete)(options);
403
+ case 3:
404
+ case "end":
405
+ return _context8.stop();
406
+ }
407
+ }, _callee8);
408
+ }));
409
+ return function terminate(_x24, _x25) {
410
+ return _ref8.apply(this, arguments);
411
+ };
412
+ }();
371
413
  exports.terminate = terminate;
@@ -0,0 +1,25 @@
1
+ import JwtToken from '../../types/jwtToken';
2
+ export interface GetClientAccessTokenOptions {
3
+ /**
4
+ * Access token to use for authentication.
5
+ */
6
+ accessToken: JwtToken;
7
+ /**
8
+ * Access token expiration time in seconds.
9
+ * The maximum value is 86,400, indicating 24 hours.
10
+ * If no value is specified, the default is 3,600, indicating one hour.
11
+ */
12
+ expiresIn?: number;
13
+ /** The unique identifier of the participant who requests the token. */
14
+ externalId?: string;
15
+ /**
16
+ * A list of case-sensitive strings allowing you to control what scope of access the client access token should have.
17
+ * The API supports the following scopes:
18
+ * * `conf:create`: Allows creating a new conference.
19
+ * * `notifications:set`: Allows the client to subscribe to events.
20
+ * * `file:convert`: Allows converting files.
21
+ * * `session:update`: Allows updating the participant's name and avatar URL.
22
+ * Incorrect values are omitted. If you want to give the token access to all scopes, you can use a wildcard, such as *.
23
+ */
24
+ sessionScope: string[];
25
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -52,3 +52,25 @@ export interface Conference {
52
52
  /** The conference access token of the conference participants. */
53
53
  usersTokens: UserTokens;
54
54
  }
55
+ export interface Participants {
56
+ /** The participant ID, in UUID (Universally Unique Identifier) format. The Dolby.io Communications APIs platform automatically generates an ID for each participant connected to the conference. */
57
+ userId: string;
58
+ /** The external ID of the participant. */
59
+ externalId: string;
60
+ /** The name of the participant. */
61
+ name: string;
62
+ /** The URL of the participant's avatar. */
63
+ avatarUrl: string;
64
+ /** The last external IP used by the participant in the conference. */
65
+ ipAddress: string;
66
+ /** The participant's user agent. */
67
+ userAgent: string;
68
+ /** The timestamp of the last time when the participant joined the conference. */
69
+ lastJoinTimestamp: number;
70
+ /** The number of times the participant joined the conference. */
71
+ nbSession: number;
72
+ }
73
+ export interface ListParticipantsResponse {
74
+ /** The ID of the created conference. */
75
+ participants: Participants[];
76
+ }
package/dist/index.js CHANGED
@@ -15,5 +15,5 @@ var streaming = _interopRequireWildcard(require("./streaming"));
15
15
  exports.streaming = streaming;
16
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); }
17
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; }
18
- var version = "3.5.5";
18
+ var version = "3.6.1";
19
19
  exports.version = version;
@@ -2,4 +2,5 @@ export default interface JwtToken {
2
2
  access_token: string;
3
3
  expires_in: number;
4
4
  token_type: string;
5
+ scope?: string;
5
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolbyio/dolbyio-rest-apis-client",
3
- "version": "3.5.5",
3
+ "version": "3.6.1",
4
4
  "description": "Node.JS wrapper for the dolby.io REST APIs",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {