@eluvio/elv-client-js 4.0.122 → 4.0.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +4 -4
- package/dist/ElvClient-node-min.js +4 -4
- package/dist/ElvFrameClient-min.js +6 -6
- package/dist/ElvWalletClient-min.js +3 -3
- package/dist/ElvWalletClient-node-min.js +4 -4
- package/dist/src/AuthorizationClient.js +29 -23
- package/dist/src/ElvClient.js +5 -1
- package/dist/src/client/ContentAccess.js +7 -3
- package/dist/src/client/Shares.js +1 -0
- package/package.json +1 -1
- package/src/AuthorizationClient.js +2 -0
- package/src/ElvClient.js +4 -1
- package/src/client/ContentAccess.js +6 -3
- package/src/client/Shares.js +1 -0
- package/utilities/GenerateFabricToken.js +3 -2
|
@@ -140,30 +140,36 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
140
140
|
case 10:
|
|
141
141
|
isWalletRequest = _context2.t0;
|
|
142
142
|
if (!(this.client.staticToken && !isWalletRequest && !update)) {
|
|
143
|
-
_context2.next =
|
|
143
|
+
_context2.next = 15;
|
|
144
144
|
break;
|
|
145
145
|
}
|
|
146
146
|
return _context2.abrupt("return", this.client.staticToken);
|
|
147
|
-
case
|
|
147
|
+
case 15:
|
|
148
|
+
if (!(this.client.staticUpdateToken && !isWalletRequest)) {
|
|
149
|
+
_context2.next = 17;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
return _context2.abrupt("return", this.client.staticUpdateToken);
|
|
153
|
+
case 17:
|
|
148
154
|
initialNoCache = this.noCache;
|
|
149
|
-
_context2.prev =
|
|
155
|
+
_context2.prev = 18;
|
|
150
156
|
// noCache enabled for this call
|
|
151
157
|
if (noCache && !this.noCache) {
|
|
152
158
|
this.noCache = true;
|
|
153
159
|
}
|
|
154
160
|
if (!(channelAuth && this.client.signer && this.client.signer.remoteSigner)) {
|
|
155
|
-
_context2.next =
|
|
161
|
+
_context2.next = 22;
|
|
156
162
|
break;
|
|
157
163
|
}
|
|
158
164
|
return _context2.abrupt("return", this.client.CreateFabricToken({
|
|
159
165
|
context: context
|
|
160
166
|
}));
|
|
161
|
-
case
|
|
167
|
+
case 22:
|
|
162
168
|
if (!channelAuth) {
|
|
163
|
-
_context2.next =
|
|
169
|
+
_context2.next = 28;
|
|
164
170
|
break;
|
|
165
171
|
}
|
|
166
|
-
_context2.next =
|
|
172
|
+
_context2.next = 25;
|
|
167
173
|
return this.GenerateChannelContentToken({
|
|
168
174
|
objectId: objectId,
|
|
169
175
|
versionHash: versionHash,
|
|
@@ -171,20 +177,20 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
171
177
|
context: context,
|
|
172
178
|
oauthToken: oauthToken
|
|
173
179
|
});
|
|
174
|
-
case
|
|
180
|
+
case 25:
|
|
175
181
|
authorizationToken = _context2.sent;
|
|
176
|
-
_context2.next =
|
|
182
|
+
_context2.next = 33;
|
|
177
183
|
break;
|
|
178
|
-
case
|
|
184
|
+
case 28:
|
|
179
185
|
if (!(noAuth && this.client.signer && this.client.signer.remoteSigner && this.client.signer.unsignedPublicAuth)) {
|
|
180
|
-
_context2.next =
|
|
186
|
+
_context2.next = 30;
|
|
181
187
|
break;
|
|
182
188
|
}
|
|
183
189
|
return _context2.abrupt("return", this.client.CreateStaticToken({
|
|
184
190
|
libraryId: libraryId
|
|
185
191
|
}));
|
|
186
|
-
case
|
|
187
|
-
_context2.next =
|
|
192
|
+
case 30:
|
|
193
|
+
_context2.next = 32;
|
|
188
194
|
return this.GenerateAuthorizationToken({
|
|
189
195
|
libraryId: libraryId,
|
|
190
196
|
objectId: objectId,
|
|
@@ -194,23 +200,23 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
194
200
|
update: update,
|
|
195
201
|
makeAccessRequest: makeAccessRequest
|
|
196
202
|
});
|
|
197
|
-
case
|
|
203
|
+
case 32:
|
|
198
204
|
authorizationToken = _context2.sent;
|
|
199
|
-
case
|
|
205
|
+
case 33:
|
|
200
206
|
return _context2.abrupt("return", authorizationToken);
|
|
201
|
-
case
|
|
202
|
-
_context2.prev =
|
|
203
|
-
_context2.t4 = _context2["catch"](
|
|
207
|
+
case 36:
|
|
208
|
+
_context2.prev = 36;
|
|
209
|
+
_context2.t4 = _context2["catch"](18);
|
|
204
210
|
throw _context2.t4;
|
|
205
|
-
case
|
|
206
|
-
_context2.prev =
|
|
211
|
+
case 39:
|
|
212
|
+
_context2.prev = 39;
|
|
207
213
|
this.noCache = initialNoCache;
|
|
208
|
-
return _context2.finish(
|
|
209
|
-
case
|
|
214
|
+
return _context2.finish(39);
|
|
215
|
+
case 42:
|
|
210
216
|
case "end":
|
|
211
217
|
return _context2.stop();
|
|
212
218
|
}
|
|
213
|
-
}, _callee2, this, [[
|
|
219
|
+
}, _callee2, this, [[18, 36, 39, 42]]);
|
|
214
220
|
}));
|
|
215
221
|
function AuthorizationToken(_x2) {
|
|
216
222
|
return _AuthorizationToken.apply(this, arguments);
|
package/dist/src/ElvClient.js
CHANGED
|
@@ -1450,12 +1450,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1450
1450
|
* @methodGroup Authorization
|
|
1451
1451
|
* @namedParams
|
|
1452
1452
|
* @param {string=} token - The static token to use. If not provided, the default static token will be set.
|
|
1453
|
+
* @param {boolean=} update=false - If specified, the static token will be used for update operations as well
|
|
1453
1454
|
*/
|
|
1454
1455
|
}, {
|
|
1455
1456
|
key: "SetStaticToken",
|
|
1456
1457
|
value: function SetStaticToken() {
|
|
1457
1458
|
var _ref23 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1458
|
-
token = _ref23.token
|
|
1459
|
+
token = _ref23.token,
|
|
1460
|
+
_ref23$update = _ref23.update,
|
|
1461
|
+
update = _ref23$update === void 0 ? false : _ref23$update;
|
|
1459
1462
|
if (token) {
|
|
1460
1463
|
this.staticToken = token;
|
|
1461
1464
|
} else {
|
|
@@ -1463,6 +1466,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1463
1466
|
qspace_id: this.contentSpaceId
|
|
1464
1467
|
}));
|
|
1465
1468
|
}
|
|
1469
|
+
this.staticUpdateToken = update ? this.staticToken : undefined;
|
|
1466
1470
|
}
|
|
1467
1471
|
|
|
1468
1472
|
/**
|
|
@@ -2367,7 +2367,7 @@ exports.PlayoutOptions = /*#__PURE__*/function () {
|
|
|
2367
2367
|
case 21:
|
|
2368
2368
|
libraryId = _context34.sent;
|
|
2369
2369
|
_context34.prev = 22;
|
|
2370
|
-
if (linkPath) {
|
|
2370
|
+
if (!(!linkPath && handler === "playout")) {
|
|
2371
2371
|
_context34.next = 29;
|
|
2372
2372
|
break;
|
|
2373
2373
|
}
|
|
@@ -2526,6 +2526,7 @@ exports.PlayoutOptions = /*#__PURE__*/function () {
|
|
|
2526
2526
|
_context34.next = 95;
|
|
2527
2527
|
return this.LinkUrl({
|
|
2528
2528
|
versionHash: versionHash,
|
|
2529
|
+
writeToken: writeToken,
|
|
2529
2530
|
linkPath: UrlJoin(linkPath, offering, playoutPath),
|
|
2530
2531
|
queryParams: queryParams,
|
|
2531
2532
|
noAuth: true
|
|
@@ -2540,6 +2541,7 @@ exports.PlayoutOptions = /*#__PURE__*/function () {
|
|
|
2540
2541
|
libraryId: linkTarget.libraryId || libraryId,
|
|
2541
2542
|
objectId: linkTarget.objectId || objectId,
|
|
2542
2543
|
versionHash: linkTarget.versionHash || versionHash,
|
|
2544
|
+
writeToken: writeToken,
|
|
2543
2545
|
rep: UrlJoin(handler, offering, playoutPath),
|
|
2544
2546
|
noAuth: true,
|
|
2545
2547
|
queryParams: queryParams
|
|
@@ -3138,6 +3140,7 @@ exports.CallBitcodeMethod = /*#__PURE__*/function () {
|
|
|
3138
3140
|
* @namedParams
|
|
3139
3141
|
* @param {string=} libraryId - ID of the library
|
|
3140
3142
|
* @param {string=} objectId - ID of the object
|
|
3143
|
+
* @param {string=} writeToken - A write token for a draft of the object (requires libraryId)
|
|
3141
3144
|
* @param {string=} versionHash - Hash of the object version - if not specified, latest version will be used
|
|
3142
3145
|
* @param {string} rep - Representation to use
|
|
3143
3146
|
* @param {Object=} queryParams - Query params to add to the URL
|
|
@@ -3155,11 +3158,11 @@ exports.CallBitcodeMethod = /*#__PURE__*/function () {
|
|
|
3155
3158
|
*/
|
|
3156
3159
|
exports.Rep = /*#__PURE__*/function () {
|
|
3157
3160
|
var _ref69 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39(_ref68) {
|
|
3158
|
-
var libraryId, objectId, versionHash, rep, _ref68$queryParams, queryParams, _ref68$service, service, _ref68$makeAccessRequ, makeAccessRequest, _ref68$channelAuth, channelAuth, _ref68$noAuth, noAuth, _ref68$noCache, noCache;
|
|
3161
|
+
var libraryId, objectId, versionHash, writeToken, rep, _ref68$queryParams, queryParams, _ref68$service, service, _ref68$makeAccessRequ, makeAccessRequest, _ref68$channelAuth, channelAuth, _ref68$noAuth, noAuth, _ref68$noCache, noCache;
|
|
3159
3162
|
return _regeneratorRuntime.wrap(function _callee39$(_context39) {
|
|
3160
3163
|
while (1) switch (_context39.prev = _context39.next) {
|
|
3161
3164
|
case 0:
|
|
3162
|
-
libraryId = _ref68.libraryId, objectId = _ref68.objectId, versionHash = _ref68.versionHash, rep = _ref68.rep, _ref68$queryParams = _ref68.queryParams, queryParams = _ref68$queryParams === void 0 ? {} : _ref68$queryParams, _ref68$service = _ref68.service, service = _ref68$service === void 0 ? "fabric" : _ref68$service, _ref68$makeAccessRequ = _ref68.makeAccessRequest, makeAccessRequest = _ref68$makeAccessRequ === void 0 ? false : _ref68$makeAccessRequ, _ref68$channelAuth = _ref68.channelAuth, channelAuth = _ref68$channelAuth === void 0 ? false : _ref68$channelAuth, _ref68$noAuth = _ref68.noAuth, noAuth = _ref68$noAuth === void 0 ? false : _ref68$noAuth, _ref68$noCache = _ref68.noCache, noCache = _ref68$noCache === void 0 ? false : _ref68$noCache;
|
|
3165
|
+
libraryId = _ref68.libraryId, objectId = _ref68.objectId, versionHash = _ref68.versionHash, writeToken = _ref68.writeToken, rep = _ref68.rep, _ref68$queryParams = _ref68.queryParams, queryParams = _ref68$queryParams === void 0 ? {} : _ref68$queryParams, _ref68$service = _ref68.service, service = _ref68$service === void 0 ? "fabric" : _ref68$service, _ref68$makeAccessRequ = _ref68.makeAccessRequest, makeAccessRequest = _ref68$makeAccessRequ === void 0 ? false : _ref68$makeAccessRequ, _ref68$channelAuth = _ref68.channelAuth, channelAuth = _ref68$channelAuth === void 0 ? false : _ref68$channelAuth, _ref68$noAuth = _ref68.noAuth, noAuth = _ref68$noAuth === void 0 ? false : _ref68$noAuth, _ref68$noCache = _ref68.noCache, noCache = _ref68$noCache === void 0 ? false : _ref68$noCache;
|
|
3163
3166
|
ValidateParameters({
|
|
3164
3167
|
libraryId: libraryId,
|
|
3165
3168
|
objectId: objectId,
|
|
@@ -3175,6 +3178,7 @@ exports.Rep = /*#__PURE__*/function () {
|
|
|
3175
3178
|
libraryId: libraryId,
|
|
3176
3179
|
objectId: objectId,
|
|
3177
3180
|
versionHash: versionHash,
|
|
3181
|
+
writeToken: writeToken,
|
|
3178
3182
|
rep: rep,
|
|
3179
3183
|
queryParams: queryParams,
|
|
3180
3184
|
service: service,
|
|
@@ -40,6 +40,7 @@ exports.CreateShare = /*#__PURE__*/function () {
|
|
|
40
40
|
return this.MakeAuthServiceRequest({
|
|
41
41
|
path: UrlJoin("as", "sharing", tenantId, "share"),
|
|
42
42
|
method: "POST",
|
|
43
|
+
format: "JSON",
|
|
43
44
|
body: params,
|
|
44
45
|
headers: {
|
|
45
46
|
Authorization: "Bearer ".concat(this.signedToken)
|
package/package.json
CHANGED
|
@@ -130,6 +130,8 @@ class AuthorizationClient {
|
|
|
130
130
|
// User wallet requests can't use static token
|
|
131
131
|
if(this.client.staticToken && !isWalletRequest && !update) {
|
|
132
132
|
return this.client.staticToken;
|
|
133
|
+
} else if(this.client.staticUpdateToken && !isWalletRequest) {
|
|
134
|
+
return this.client.staticUpdateToken;
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
const initialNoCache = this.noCache;
|
package/src/ElvClient.js
CHANGED
|
@@ -1198,13 +1198,16 @@ class ElvClient {
|
|
|
1198
1198
|
* @methodGroup Authorization
|
|
1199
1199
|
* @namedParams
|
|
1200
1200
|
* @param {string=} token - The static token to use. If not provided, the default static token will be set.
|
|
1201
|
+
* @param {boolean=} update=false - If specified, the static token will be used for update operations as well
|
|
1201
1202
|
*/
|
|
1202
|
-
SetStaticToken({token}={}) {
|
|
1203
|
+
SetStaticToken({token, update=false}={}) {
|
|
1203
1204
|
if(token) {
|
|
1204
1205
|
this.staticToken = token;
|
|
1205
1206
|
} else {
|
|
1206
1207
|
this.staticToken = this.utils.B64(JSON.stringify({qspace_id: this.contentSpaceId}));
|
|
1207
1208
|
}
|
|
1209
|
+
|
|
1210
|
+
this.staticUpdateToken = update ? this.staticToken : undefined;
|
|
1208
1211
|
}
|
|
1209
1212
|
|
|
1210
1213
|
/**
|
|
@@ -1454,7 +1454,7 @@ exports.PlayoutOptions = async function({
|
|
|
1454
1454
|
|
|
1455
1455
|
try {
|
|
1456
1456
|
// If public/asset_metadata/sources/<offering> exists, use that instead of directly calling on object
|
|
1457
|
-
if(!linkPath) {
|
|
1457
|
+
if(!linkPath && handler === "playout") {
|
|
1458
1458
|
const offeringPath = UrlJoin("public", "asset_metadata", "sources", offering);
|
|
1459
1459
|
const link = await this.ContentObjectMetadata({
|
|
1460
1460
|
libraryId,
|
|
@@ -1573,6 +1573,7 @@ exports.PlayoutOptions = async function({
|
|
|
1573
1573
|
signedLink ?
|
|
1574
1574
|
await this.LinkUrl({
|
|
1575
1575
|
versionHash,
|
|
1576
|
+
writeToken,
|
|
1576
1577
|
linkPath: UrlJoin(linkPath, offering, playoutPath),
|
|
1577
1578
|
queryParams,
|
|
1578
1579
|
noAuth: true
|
|
@@ -1581,6 +1582,7 @@ exports.PlayoutOptions = async function({
|
|
|
1581
1582
|
libraryId: linkTarget.libraryId || libraryId,
|
|
1582
1583
|
objectId: linkTarget.objectId || objectId,
|
|
1583
1584
|
versionHash: linkTarget.versionHash || versionHash,
|
|
1585
|
+
writeToken,
|
|
1584
1586
|
rep: UrlJoin(handler, offering, playoutPath),
|
|
1585
1587
|
noAuth: true,
|
|
1586
1588
|
queryParams
|
|
@@ -2051,6 +2053,7 @@ exports.CallBitcodeMethod = async function({
|
|
|
2051
2053
|
* @namedParams
|
|
2052
2054
|
* @param {string=} libraryId - ID of the library
|
|
2053
2055
|
* @param {string=} objectId - ID of the object
|
|
2056
|
+
* @param {string=} writeToken - A write token for a draft of the object (requires libraryId)
|
|
2054
2057
|
* @param {string=} versionHash - Hash of the object version - if not specified, latest version will be used
|
|
2055
2058
|
* @param {string} rep - Representation to use
|
|
2056
2059
|
* @param {Object=} queryParams - Query params to add to the URL
|
|
@@ -2066,11 +2069,11 @@ exports.CallBitcodeMethod = async function({
|
|
|
2066
2069
|
*
|
|
2067
2070
|
* @returns {Promise<string>} - URL to the specified rep endpoint with authorization token
|
|
2068
2071
|
*/
|
|
2069
|
-
exports.Rep = async function({libraryId, objectId, versionHash, rep, queryParams={}, service="fabric", makeAccessRequest=false, channelAuth=false, noAuth=false, noCache=false}) {
|
|
2072
|
+
exports.Rep = async function({libraryId, objectId, versionHash, writeToken, rep, queryParams={}, service="fabric", makeAccessRequest=false, channelAuth=false, noAuth=false, noCache=false}) {
|
|
2070
2073
|
ValidateParameters({libraryId, objectId, versionHash});
|
|
2071
2074
|
if(!rep) { throw "Rep not specified"; }
|
|
2072
2075
|
|
|
2073
|
-
return this.FabricUrl({libraryId, objectId, versionHash, rep, queryParams, service, makeAccessRequest, channelAuth, noAuth, noCache});
|
|
2076
|
+
return this.FabricUrl({libraryId, objectId, versionHash, writeToken, rep, queryParams, service, makeAccessRequest, channelAuth, noAuth, noCache});
|
|
2074
2077
|
};
|
|
2075
2078
|
|
|
2076
2079
|
/**
|
package/src/client/Shares.js
CHANGED
|
@@ -28,6 +28,7 @@ exports.CreateShare = async function({objectId, expiresAt, params={}}) {
|
|
|
28
28
|
return await this.MakeAuthServiceRequest({
|
|
29
29
|
path: UrlJoin("as", "sharing", tenantId, "share"),
|
|
30
30
|
method: "POST",
|
|
31
|
+
format: "JSON",
|
|
31
32
|
body: params,
|
|
32
33
|
headers: {
|
|
33
34
|
Authorization: `Bearer ${this.signedToken}`
|
|
@@ -2,7 +2,7 @@ const { ElvClient } = require("../src/ElvClient");
|
|
|
2
2
|
|
|
3
3
|
const GenerateFabricToken = async () => {
|
|
4
4
|
try {
|
|
5
|
-
const client = await ElvClient.FromNetworkName({networkName: "main"});
|
|
5
|
+
const client = await ElvClient.FromNetworkName({networkName: process.env.ENV ?? "main"});
|
|
6
6
|
|
|
7
7
|
const wallet = client.GenerateWallet();
|
|
8
8
|
const signer = wallet.AddAccount({
|
|
@@ -12,7 +12,8 @@ const GenerateFabricToken = async () => {
|
|
|
12
12
|
client.SetSigner({signer});
|
|
13
13
|
|
|
14
14
|
console.log(await client.CreateFabricToken({
|
|
15
|
-
duration: parseInt(process.env.DURATION),
|
|
15
|
+
duration: parseInt(process.env.DURATION ?? 24 * 60 * 60 * 1000),
|
|
16
|
+
context: JSON.parse(process.env.ELV_TOK_CTX ?? "{}")
|
|
16
17
|
//context: {email:"xyz@eluv.io"}
|
|
17
18
|
}));
|
|
18
19
|
} catch(error) {
|