@overmap-ai/core 1.0.60-sdk-refactor.4 → 1.0.60-sdk-refactor.5
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.
|
@@ -15421,9 +15421,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15421
15421
|
class JWTService extends BaseAuthService {
|
|
15422
15422
|
constructor() {
|
|
15423
15423
|
super(...arguments);
|
|
15424
|
-
// AUTH below
|
|
15425
|
-
__publicField(this, "_getAccessToken", () => this.client.store.getState().authReducer.accessToken);
|
|
15426
|
-
__publicField(this, "_getRefreshToken", () => this.client.store.getState().authReducer.refreshToken);
|
|
15427
15424
|
// _getTokenPair and _getRenewedTokens don't need to use enqueueRequest from the BaseApiService because
|
|
15428
15425
|
// they are very simple. However, if we need robust error handling or want these operations to queue in the Outbox,
|
|
15429
15426
|
// we will use enqueueRequest.
|
|
@@ -15437,7 +15434,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15437
15434
|
const promise = this.enqueueRequest({
|
|
15438
15435
|
description: "Get renewed tokens",
|
|
15439
15436
|
method: HttpMethod.POST,
|
|
15440
|
-
url:
|
|
15437
|
+
url: this.refreshTokensUrl,
|
|
15441
15438
|
payload: { refresh: refreshToken },
|
|
15442
15439
|
isAuthNeeded: false,
|
|
15443
15440
|
blockers: [],
|
|
@@ -15448,14 +15445,14 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15448
15445
|
immediate: true
|
|
15449
15446
|
}).catch((e) => {
|
|
15450
15447
|
console.error("Could not renew tokens; logging out due to error:", e);
|
|
15451
|
-
void this.
|
|
15448
|
+
void this.clearAuth();
|
|
15452
15449
|
return void 0;
|
|
15453
15450
|
});
|
|
15454
15451
|
let response = void 0;
|
|
15455
15452
|
try {
|
|
15456
15453
|
response = await promise;
|
|
15457
15454
|
} catch (e) {
|
|
15458
|
-
await this.
|
|
15455
|
+
await this.clearAuth();
|
|
15459
15456
|
}
|
|
15460
15457
|
if (!response)
|
|
15461
15458
|
return void 0;
|
|
@@ -15469,9 +15466,9 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15469
15466
|
/**
|
|
15470
15467
|
* Logs the user out
|
|
15471
15468
|
*/
|
|
15472
|
-
async
|
|
15469
|
+
async clearAuth() {
|
|
15473
15470
|
this.dispatch(setLoggedIn(false));
|
|
15474
|
-
this.
|
|
15471
|
+
this.clearTokens();
|
|
15475
15472
|
this.dispatch(setActiveProjectId(null));
|
|
15476
15473
|
this.dispatch(setActiveWorkspaceId(null));
|
|
15477
15474
|
this.dispatch({ type: constants.RESET_STATE });
|
|
@@ -15483,7 +15480,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15483
15480
|
* Attempts to renew tokens
|
|
15484
15481
|
*/
|
|
15485
15482
|
async renewTokens() {
|
|
15486
|
-
const dyingRefreshToken = this.
|
|
15483
|
+
const dyingRefreshToken = this.getRefreshToken();
|
|
15487
15484
|
if (!dyingRefreshToken) {
|
|
15488
15485
|
throw new Error("No refresh token found");
|
|
15489
15486
|
}
|
|
@@ -15492,12 +15489,11 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15492
15489
|
if (!tokens) {
|
|
15493
15490
|
return void 0;
|
|
15494
15491
|
}
|
|
15495
|
-
const { accessToken, refreshToken } = tokens;
|
|
15496
15492
|
console.log("Got renewed tokens");
|
|
15497
|
-
this.
|
|
15493
|
+
this.setTokens(tokens);
|
|
15498
15494
|
} catch (e) {
|
|
15499
15495
|
console.error("Could not renew tokens; logging out.");
|
|
15500
|
-
await this.
|
|
15496
|
+
await this.clearAuth();
|
|
15501
15497
|
throw e;
|
|
15502
15498
|
}
|
|
15503
15499
|
}
|
|
@@ -15506,7 +15502,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15506
15502
|
* @returns {boolean}
|
|
15507
15503
|
*/
|
|
15508
15504
|
tokenIsExpiringSoon() {
|
|
15509
|
-
const accessToken = this.
|
|
15505
|
+
const accessToken = this.getAccessToken();
|
|
15510
15506
|
if (!accessToken) {
|
|
15511
15507
|
return false;
|
|
15512
15508
|
}
|
|
@@ -15531,7 +15527,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15531
15527
|
await this.renewTokens();
|
|
15532
15528
|
} catch (e) {
|
|
15533
15529
|
if (e instanceof APIError) {
|
|
15534
|
-
await this.
|
|
15530
|
+
await this.clearAuth();
|
|
15535
15531
|
}
|
|
15536
15532
|
return Promise.reject(e);
|
|
15537
15533
|
}
|
|
@@ -15543,7 +15539,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15543
15539
|
if (state.authReducer.isLoggedIn) {
|
|
15544
15540
|
console.warn("No signed-in user to sign out.");
|
|
15545
15541
|
}
|
|
15546
|
-
await this.
|
|
15542
|
+
await this.clearAuth();
|
|
15547
15543
|
throw new APIError({
|
|
15548
15544
|
message: "You have been signed out due to inactivity.",
|
|
15549
15545
|
response,
|
|
@@ -15572,7 +15568,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15572
15568
|
uuid: uuid$1,
|
|
15573
15569
|
description: "Get token pair",
|
|
15574
15570
|
method: HttpMethod.POST,
|
|
15575
|
-
url:
|
|
15571
|
+
url: this.initTokensUrl,
|
|
15576
15572
|
payload: { username, password },
|
|
15577
15573
|
isAuthNeeded: false,
|
|
15578
15574
|
checkAuth: false,
|
|
@@ -15592,87 +15588,12 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
15592
15588
|
if (timedOut) {
|
|
15593
15589
|
return void 0;
|
|
15594
15590
|
}
|
|
15595
|
-
this.
|
|
15591
|
+
this.setTokens(tokens);
|
|
15596
15592
|
this.dispatch(setLoggedIn(true));
|
|
15597
15593
|
this.dispatch({ type: "rehydrated/setRehydrated", payload: true });
|
|
15598
15594
|
});
|
|
15599
15595
|
return Promise.race([timeoutPromise, successPromise]);
|
|
15600
15596
|
}
|
|
15601
|
-
/**
|
|
15602
|
-
* Register a new user
|
|
15603
|
-
*/
|
|
15604
|
-
register(payload) {
|
|
15605
|
-
return this.enqueueRequest({
|
|
15606
|
-
description: "Register",
|
|
15607
|
-
method: HttpMethod.POST,
|
|
15608
|
-
url: "/authentication/users/register/",
|
|
15609
|
-
isAuthNeeded: false,
|
|
15610
|
-
payload,
|
|
15611
|
-
blockers: [],
|
|
15612
|
-
blocks: []
|
|
15613
|
-
});
|
|
15614
|
-
}
|
|
15615
|
-
async resetPassword(email) {
|
|
15616
|
-
return this.enqueueRequest({
|
|
15617
|
-
description: "Reset password",
|
|
15618
|
-
method: HttpMethod.PATCH,
|
|
15619
|
-
url: "/authentication/users/reset-password/",
|
|
15620
|
-
isAuthNeeded: false,
|
|
15621
|
-
payload: {
|
|
15622
|
-
email
|
|
15623
|
-
},
|
|
15624
|
-
blockers: [],
|
|
15625
|
-
blocks: []
|
|
15626
|
-
});
|
|
15627
|
-
}
|
|
15628
|
-
async replaceProfilePicture(file) {
|
|
15629
|
-
const hash = await hashFile(file);
|
|
15630
|
-
await this.client.files.addCache(file, hash);
|
|
15631
|
-
const [fileProps] = await this.client.files.uploadFileToS3(hash);
|
|
15632
|
-
this.dispatch(setProfilePicture({ file: `/files/${fileProps.file}`, file_sha1: hash }));
|
|
15633
|
-
return this.enqueueRequest({
|
|
15634
|
-
description: "Replace profile picture",
|
|
15635
|
-
method: HttpMethod.PATCH,
|
|
15636
|
-
url: "/authentication/users/profile-details/",
|
|
15637
|
-
payload: fileProps,
|
|
15638
|
-
blockers: [],
|
|
15639
|
-
blocks: []
|
|
15640
|
-
});
|
|
15641
|
-
}
|
|
15642
|
-
async addFavouriteProjectId(projectId) {
|
|
15643
|
-
this.dispatch(addFavouriteProjectId(projectId));
|
|
15644
|
-
return this.enqueueRequest({
|
|
15645
|
-
description: "Add favourite project",
|
|
15646
|
-
method: HttpMethod.POST,
|
|
15647
|
-
url: `/authentication/users/favourite-project/${projectId}/`,
|
|
15648
|
-
blockers: [],
|
|
15649
|
-
blocks: []
|
|
15650
|
-
});
|
|
15651
|
-
}
|
|
15652
|
-
async removeFavouriteProjectId(projectId) {
|
|
15653
|
-
this.dispatch(removeFavouriteProjectId(projectId));
|
|
15654
|
-
return this.enqueueRequest({
|
|
15655
|
-
description: "Add favourite project",
|
|
15656
|
-
method: HttpMethod.POST,
|
|
15657
|
-
url: `/authentication/users/unfavourite-project/${projectId}/`,
|
|
15658
|
-
blockers: [`favorite-project-${projectId}`],
|
|
15659
|
-
blocks: [`favorite-project-${projectId}`]
|
|
15660
|
-
});
|
|
15661
|
-
}
|
|
15662
|
-
async joinApplication(projectInviteId, verification_code, username, password) {
|
|
15663
|
-
return this.enqueueRequest({
|
|
15664
|
-
description: "Join application",
|
|
15665
|
-
method: HttpMethod.PATCH,
|
|
15666
|
-
url: `/authentication/join-app/${projectInviteId}/${verification_code}/`,
|
|
15667
|
-
payload: {
|
|
15668
|
-
username,
|
|
15669
|
-
password
|
|
15670
|
-
},
|
|
15671
|
-
isAuthNeeded: false,
|
|
15672
|
-
blockers: [],
|
|
15673
|
-
blocks: []
|
|
15674
|
-
});
|
|
15675
|
-
}
|
|
15676
15597
|
}
|
|
15677
15598
|
const CLASS_NAME_TO_SERVICE = {};
|
|
15678
15599
|
class BaseApiService {
|