Skip to content

Commit

Permalink
fix: update tokenSignature to include authId
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-lemon committed Jun 11, 2024
1 parent 9e0e77f commit 3bf2331
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/core/aws-web.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,28 +274,24 @@ export class AWSWebCore implements WebCoreService {
/**
* Changes the user site and returns new AWS credentials.
*
* @param {string} authId - user authId. It same as identityId in UserProfileView
* @param {ChangeSiteBody} changeSiteBody - The body containing site change details.
* @param {string} [url] - Optional URL for the OAuth endpoint.
* @returns {Promise<AWS.Credentials>} - A promise that resolves to AWS credentials.
* @throws Will throw an error if `authId`, `changeSiteBody`, `changeSiteBody.siteId`, or `changeSiteBody.userId` are not provided.
* @throws Will throw an error if `changeSiteBody`, `changeSiteBody.siteId`, or `changeSiteBody.userId` are not provided.
*
* @example
* const changeSiteBody = { siteId: 'newSiteId', userId: 'userId123' };
* const credentials = await changeUserSite(changeSiteBody);
*/
async changeUserSite(authId: string, changeSiteBody: ChangeSiteBody, url?: string): Promise<AWS.Credentials> {
if (!authId) {
throw new Error('@authId required');
}
async changeUserSite(changeSiteBody: ChangeSiteBody, url?: string): Promise<AWS.Credentials> {
if (!changeSiteBody || !changeSiteBody.siteId || !changeSiteBody.userId) {
throw new Error('@changeSiteBody required');
}

const cached = await this.tokenStorage.getCachedOAuthToken();
const target = `${changeSiteBody.userId}@${changeSiteBody.siteId}`;
const tokenSignature = await this.getTokenSignature();
const { current, signature, originToken } = tokenSignature;
const { authId, current, signature, originToken } = tokenSignature;

const response: HttpResponse<LemonOAuthToken> = await this.signedRequest(
'POST',
Expand Down

0 comments on commit 3bf2331

Please sign in to comment.