ugcinc 2.72.0 → 2.73.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/dist/base.js +10 -17
- package/package.json +1 -1
package/dist/base.js
CHANGED
|
@@ -18,21 +18,17 @@ class BaseClient {
|
|
|
18
18
|
}
|
|
19
19
|
async request(endpoint, options = {}) {
|
|
20
20
|
let url = `${this.baseUrl}${endpoint}`;
|
|
21
|
-
// If orgId is provided,
|
|
21
|
+
// If orgId is provided, add it as query param to scope to that org
|
|
22
22
|
if (this.orgId) {
|
|
23
23
|
const separator = endpoint.includes('?') ? '&' : '?';
|
|
24
24
|
url = `${url}${separator}orgId=${encodeURIComponent(this.orgId)}`;
|
|
25
25
|
}
|
|
26
26
|
const headers = {
|
|
27
27
|
'Content-Type': 'application/json',
|
|
28
|
+
// Always use x-api-key header for admin authentication
|
|
29
|
+
// When orgId is provided, scopes to that org; when not provided, accesses all data
|
|
30
|
+
'x-api-key': this.apiKey,
|
|
28
31
|
};
|
|
29
|
-
// Use admin key header if orgId is provided, otherwise use Bearer token
|
|
30
|
-
if (this.orgId) {
|
|
31
|
-
headers['x-api-key'] = this.apiKey;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
headers['Authorization'] = `Bearer ${this.apiKey}`;
|
|
35
|
-
}
|
|
36
32
|
try {
|
|
37
33
|
const response = await fetch(url, {
|
|
38
34
|
...options,
|
|
@@ -78,19 +74,16 @@ class BaseClient {
|
|
|
78
74
|
}
|
|
79
75
|
async postFormData(endpoint, formData) {
|
|
80
76
|
let url = `${this.baseUrl}${endpoint}`;
|
|
81
|
-
// If orgId is provided,
|
|
77
|
+
// If orgId is provided, add it as query param to scope to that org
|
|
82
78
|
if (this.orgId) {
|
|
83
79
|
const separator = endpoint.includes('?') ? '&' : '?';
|
|
84
80
|
url = `${url}${separator}orgId=${encodeURIComponent(this.orgId)}`;
|
|
85
81
|
}
|
|
86
|
-
const headers = {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
headers['Authorization'] = `Bearer ${this.apiKey}`;
|
|
93
|
-
}
|
|
82
|
+
const headers = {
|
|
83
|
+
// Always use x-api-key header for admin authentication
|
|
84
|
+
// When orgId is provided, scopes to that org; when not provided, accesses all data
|
|
85
|
+
'x-api-key': this.apiKey,
|
|
86
|
+
};
|
|
94
87
|
try {
|
|
95
88
|
const response = await fetch(url, {
|
|
96
89
|
method: 'POST',
|