@hipnation-truth/sdk 0.26.13 → 0.26.14
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/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +7 -2
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -140,6 +140,11 @@ var REQUIRE_TOKEN_RETRY_DELAY_MS = 150;
|
|
|
140
140
|
function delay(ms) {
|
|
141
141
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
142
142
|
}
|
|
143
|
+
var USER_TOKEN_HEADER = "X-Truth-Authorization";
|
|
144
|
+
function setUserToken(headers, token) {
|
|
145
|
+
headers.Authorization = `Bearer ${token}`;
|
|
146
|
+
headers[USER_TOKEN_HEADER] = `Bearer ${token}`;
|
|
147
|
+
}
|
|
143
148
|
function resolveAuthToken(getAuthToken) {
|
|
144
149
|
return __async(this, null, function* () {
|
|
145
150
|
try {
|
|
@@ -170,7 +175,7 @@ function buildAuthHeaders(auth, options) {
|
|
|
170
175
|
for (let attempt = 0; attempt < REQUIRE_TOKEN_MAX_ATTEMPTS; attempt++) {
|
|
171
176
|
const token = yield resolveAuthToken(auth.getAuthToken);
|
|
172
177
|
if (token) {
|
|
173
|
-
headers
|
|
178
|
+
setUserToken(headers, token);
|
|
174
179
|
return headers;
|
|
175
180
|
}
|
|
176
181
|
if (attempt < REQUIRE_TOKEN_MAX_ATTEMPTS - 1) {
|
|
@@ -184,7 +189,7 @@ function buildAuthHeaders(auth, options) {
|
|
|
184
189
|
if (auth.getAuthToken) {
|
|
185
190
|
const token = yield resolveAuthToken(auth.getAuthToken);
|
|
186
191
|
if (token) {
|
|
187
|
-
headers
|
|
192
|
+
setUserToken(headers, token);
|
|
188
193
|
}
|
|
189
194
|
}
|
|
190
195
|
return headers;
|