@mediaviz/sdk 1.0.80 → 1.0.81
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/sdk.cjs +24 -4
- package/dist/sdk.esm.js +24 -4
- package/dist/sdk.umd.js +24 -4
- package/package.json +1 -1
package/dist/sdk.cjs
CHANGED
|
@@ -91,8 +91,15 @@ function requireErrors () {
|
|
|
91
91
|
* @returns {OAuthError}
|
|
92
92
|
*/
|
|
93
93
|
static fromResponse(status, body) {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
// FastAPI wraps HTTPException payloads in a `detail` envelope, so an OAuth
|
|
95
|
+
// error arrives as { detail: { error, error_description } }. Unwrap it
|
|
96
|
+
// before falling back, or every server-side OAuth error reads as server_error.
|
|
97
|
+
const payload =
|
|
98
|
+
body && typeof body === 'object' && typeof body.error !== 'string' && body.detail
|
|
99
|
+
? body.detail
|
|
100
|
+
: body;
|
|
101
|
+
if (payload && typeof payload === 'object' && typeof payload.error === 'string') {
|
|
102
|
+
return new OAuthError(payload.error, payload.error_description ?? '', status, body);
|
|
96
103
|
}
|
|
97
104
|
return new OAuthError('server_error', 'Unexpected server response', status, body);
|
|
98
105
|
}
|
|
@@ -191,12 +198,22 @@ function requireClient () {
|
|
|
191
198
|
*/
|
|
192
199
|
static async registerClient(params) {
|
|
193
200
|
const baseUrl = params.baseUrl.replace(/\/+$/, '');
|
|
194
|
-
|
|
201
|
+
const body = {
|
|
195
202
|
client_name: params.clientName,
|
|
196
203
|
client_type: params.clientType,
|
|
197
204
|
redirect_uris: params.redirectUris,
|
|
198
205
|
is_first_party: params.isFirstParty,
|
|
199
|
-
}
|
|
206
|
+
};
|
|
207
|
+
// grant_types/company_id are required to provision a confidential
|
|
208
|
+
// client_credentials (machine-to-machine) client; omitted bodies keep the
|
|
209
|
+
// legacy public/authorization_code shape. The endpoint is admin-gated, so a
|
|
210
|
+
// bearer token must be supplied for the request to authenticate.
|
|
211
|
+
if (params.grantTypes !== undefined) body.grant_types = params.grantTypes;
|
|
212
|
+
if (params.companyId !== undefined) body.company_id = params.companyId;
|
|
213
|
+
const headers = params.accessToken
|
|
214
|
+
? { Authorization: `Bearer ${params.accessToken}` }
|
|
215
|
+
: {};
|
|
216
|
+
return postJson(`${baseUrl}/oauth/clients`, body, headers);
|
|
200
217
|
}
|
|
201
218
|
|
|
202
219
|
/**
|
|
@@ -416,6 +433,9 @@ function requireTypes () {
|
|
|
416
433
|
* @property {string} clientType - "public" or "confidential"
|
|
417
434
|
* @property {string[]} redirectUris - HTTPS redirect URIs
|
|
418
435
|
* @property {boolean} isFirstParty - Whether this is a first-party client
|
|
436
|
+
* @property {string[]} [grantTypes] - Allowed grants, e.g. ["client_credentials"]; required for machine-to-machine clients
|
|
437
|
+
* @property {number} [companyId] - Company to bind the client to; required for the client_credentials grant
|
|
438
|
+
* @property {string} [accessToken] - Admin bearer token; the registration endpoint is authorization-gated
|
|
419
439
|
*/
|
|
420
440
|
|
|
421
441
|
/**
|
package/dist/sdk.esm.js
CHANGED
|
@@ -89,8 +89,15 @@ function requireErrors () {
|
|
|
89
89
|
* @returns {OAuthError}
|
|
90
90
|
*/
|
|
91
91
|
static fromResponse(status, body) {
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
// FastAPI wraps HTTPException payloads in a `detail` envelope, so an OAuth
|
|
93
|
+
// error arrives as { detail: { error, error_description } }. Unwrap it
|
|
94
|
+
// before falling back, or every server-side OAuth error reads as server_error.
|
|
95
|
+
const payload =
|
|
96
|
+
body && typeof body === 'object' && typeof body.error !== 'string' && body.detail
|
|
97
|
+
? body.detail
|
|
98
|
+
: body;
|
|
99
|
+
if (payload && typeof payload === 'object' && typeof payload.error === 'string') {
|
|
100
|
+
return new OAuthError(payload.error, payload.error_description ?? '', status, body);
|
|
94
101
|
}
|
|
95
102
|
return new OAuthError('server_error', 'Unexpected server response', status, body);
|
|
96
103
|
}
|
|
@@ -189,12 +196,22 @@ function requireClient () {
|
|
|
189
196
|
*/
|
|
190
197
|
static async registerClient(params) {
|
|
191
198
|
const baseUrl = params.baseUrl.replace(/\/+$/, '');
|
|
192
|
-
|
|
199
|
+
const body = {
|
|
193
200
|
client_name: params.clientName,
|
|
194
201
|
client_type: params.clientType,
|
|
195
202
|
redirect_uris: params.redirectUris,
|
|
196
203
|
is_first_party: params.isFirstParty,
|
|
197
|
-
}
|
|
204
|
+
};
|
|
205
|
+
// grant_types/company_id are required to provision a confidential
|
|
206
|
+
// client_credentials (machine-to-machine) client; omitted bodies keep the
|
|
207
|
+
// legacy public/authorization_code shape. The endpoint is admin-gated, so a
|
|
208
|
+
// bearer token must be supplied for the request to authenticate.
|
|
209
|
+
if (params.grantTypes !== undefined) body.grant_types = params.grantTypes;
|
|
210
|
+
if (params.companyId !== undefined) body.company_id = params.companyId;
|
|
211
|
+
const headers = params.accessToken
|
|
212
|
+
? { Authorization: `Bearer ${params.accessToken}` }
|
|
213
|
+
: {};
|
|
214
|
+
return postJson(`${baseUrl}/oauth/clients`, body, headers);
|
|
198
215
|
}
|
|
199
216
|
|
|
200
217
|
/**
|
|
@@ -414,6 +431,9 @@ function requireTypes () {
|
|
|
414
431
|
* @property {string} clientType - "public" or "confidential"
|
|
415
432
|
* @property {string[]} redirectUris - HTTPS redirect URIs
|
|
416
433
|
* @property {boolean} isFirstParty - Whether this is a first-party client
|
|
434
|
+
* @property {string[]} [grantTypes] - Allowed grants, e.g. ["client_credentials"]; required for machine-to-machine clients
|
|
435
|
+
* @property {number} [companyId] - Company to bind the client to; required for the client_credentials grant
|
|
436
|
+
* @property {string} [accessToken] - Admin bearer token; the registration endpoint is authorization-gated
|
|
417
437
|
*/
|
|
418
438
|
|
|
419
439
|
/**
|
package/dist/sdk.umd.js
CHANGED
|
@@ -95,8 +95,15 @@
|
|
|
95
95
|
* @returns {OAuthError}
|
|
96
96
|
*/
|
|
97
97
|
static fromResponse(status, body) {
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
// FastAPI wraps HTTPException payloads in a `detail` envelope, so an OAuth
|
|
99
|
+
// error arrives as { detail: { error, error_description } }. Unwrap it
|
|
100
|
+
// before falling back, or every server-side OAuth error reads as server_error.
|
|
101
|
+
const payload =
|
|
102
|
+
body && typeof body === 'object' && typeof body.error !== 'string' && body.detail
|
|
103
|
+
? body.detail
|
|
104
|
+
: body;
|
|
105
|
+
if (payload && typeof payload === 'object' && typeof payload.error === 'string') {
|
|
106
|
+
return new OAuthError(payload.error, payload.error_description ?? '', status, body);
|
|
100
107
|
}
|
|
101
108
|
return new OAuthError('server_error', 'Unexpected server response', status, body);
|
|
102
109
|
}
|
|
@@ -195,12 +202,22 @@
|
|
|
195
202
|
*/
|
|
196
203
|
static async registerClient(params) {
|
|
197
204
|
const baseUrl = params.baseUrl.replace(/\/+$/, '');
|
|
198
|
-
|
|
205
|
+
const body = {
|
|
199
206
|
client_name: params.clientName,
|
|
200
207
|
client_type: params.clientType,
|
|
201
208
|
redirect_uris: params.redirectUris,
|
|
202
209
|
is_first_party: params.isFirstParty,
|
|
203
|
-
}
|
|
210
|
+
};
|
|
211
|
+
// grant_types/company_id are required to provision a confidential
|
|
212
|
+
// client_credentials (machine-to-machine) client; omitted bodies keep the
|
|
213
|
+
// legacy public/authorization_code shape. The endpoint is admin-gated, so a
|
|
214
|
+
// bearer token must be supplied for the request to authenticate.
|
|
215
|
+
if (params.grantTypes !== undefined) body.grant_types = params.grantTypes;
|
|
216
|
+
if (params.companyId !== undefined) body.company_id = params.companyId;
|
|
217
|
+
const headers = params.accessToken
|
|
218
|
+
? { Authorization: `Bearer ${params.accessToken}` }
|
|
219
|
+
: {};
|
|
220
|
+
return postJson(`${baseUrl}/oauth/clients`, body, headers);
|
|
204
221
|
}
|
|
205
222
|
|
|
206
223
|
/**
|
|
@@ -420,6 +437,9 @@
|
|
|
420
437
|
* @property {string} clientType - "public" or "confidential"
|
|
421
438
|
* @property {string[]} redirectUris - HTTPS redirect URIs
|
|
422
439
|
* @property {boolean} isFirstParty - Whether this is a first-party client
|
|
440
|
+
* @property {string[]} [grantTypes] - Allowed grants, e.g. ["client_credentials"]; required for machine-to-machine clients
|
|
441
|
+
* @property {number} [companyId] - Company to bind the client to; required for the client_credentials grant
|
|
442
|
+
* @property {string} [accessToken] - Admin bearer token; the registration endpoint is authorization-gated
|
|
423
443
|
*/
|
|
424
444
|
|
|
425
445
|
/**
|