@dream-api/sdk 0.1.2 → 0.1.3
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 +6 -0
- package/dist/index.mjs +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -116,6 +116,9 @@ var DreamClient = class {
|
|
|
116
116
|
*/
|
|
117
117
|
async request(method, endpoint, options = {}) {
|
|
118
118
|
const { body, requiresUserToken = false } = options;
|
|
119
|
+
if (requiresUserToken || this.userToken) {
|
|
120
|
+
await this.ensureFreshToken();
|
|
121
|
+
}
|
|
119
122
|
const headers = {
|
|
120
123
|
"Content-Type": "application/json"
|
|
121
124
|
};
|
|
@@ -324,6 +327,9 @@ var AuthHelpers = class {
|
|
|
324
327
|
async init() {
|
|
325
328
|
if (this.initialized) return;
|
|
326
329
|
await this.clerk.load();
|
|
330
|
+
this.client.setTokenRefresher(async () => {
|
|
331
|
+
return await this.clerk.refreshToken();
|
|
332
|
+
});
|
|
327
333
|
this.initialized = true;
|
|
328
334
|
}
|
|
329
335
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -88,6 +88,9 @@ var DreamClient = class {
|
|
|
88
88
|
*/
|
|
89
89
|
async request(method, endpoint, options = {}) {
|
|
90
90
|
const { body, requiresUserToken = false } = options;
|
|
91
|
+
if (requiresUserToken || this.userToken) {
|
|
92
|
+
await this.ensureFreshToken();
|
|
93
|
+
}
|
|
91
94
|
const headers = {
|
|
92
95
|
"Content-Type": "application/json"
|
|
93
96
|
};
|
|
@@ -296,6 +299,9 @@ var AuthHelpers = class {
|
|
|
296
299
|
async init() {
|
|
297
300
|
if (this.initialized) return;
|
|
298
301
|
await this.clerk.load();
|
|
302
|
+
this.client.setTokenRefresher(async () => {
|
|
303
|
+
return await this.clerk.refreshToken();
|
|
304
|
+
});
|
|
299
305
|
this.initialized = true;
|
|
300
306
|
}
|
|
301
307
|
/**
|