Skip to content

Commit

Permalink
chore: using object as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustrb committed Oct 22, 2024
1 parent 203fa1d commit 5263a7d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/apps/server/bridges/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class AppCloudBridge extends CloudWorkspaceBridge {
public async getWorkspaceToken(scope: string, appId: string): Promise<IWorkspaceToken> {
this.orch.debugLog(`App ${appId} is getting the workspace's token`);

const token = await getWorkspaceAccessTokenWithScope(scope);
const token = await getWorkspaceAccessTokenWithScope({ scope });

return token;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function getWorkspaceAccessToken(forceNew = false, scope = '', save

SystemLogger.debug(`Workspace credentials cache miss using scope: ${scope}, fetching new access token from cloud services.`);

const accessToken = await getWorkspaceAccessTokenWithScope(scope, throwOnError);
const accessToken = await getWorkspaceAccessTokenWithScope({ scope, throwOnError });

if (save) {
await WorkspaceCredentials.updateCredentialByScope({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ type WorkspaceAccessTokenWithScope = {
scope: string;
};

export async function getWorkspaceAccessTokenWithScope(scope = '', throwOnError = false): Promise<WorkspaceAccessTokenWithScope> {
type GetWorkspaceAccessTokenWithScopeParams = {
scope?: string;
throwOnError?: boolean;
};

export async function getWorkspaceAccessTokenWithScope({
scope = '',
throwOnError = false,
}: GetWorkspaceAccessTokenWithScopeParams): Promise<WorkspaceAccessTokenWithScope> {
const { workspaceRegistered } = await retrieveRegistrationStatus();

const tokenResponse = { token: '', expiresAt: new Date(), scope: '' };
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/ee/server/apps/communication/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class AppsRestApi {
return API.v1.failure({ error: 'Invalid purchase type' });
}

const response = await getWorkspaceAccessTokenWithScope('marketplace:purchase');
const response = await getWorkspaceAccessTokenWithScope({ scope: 'marketplace:purchase' });
if (!response.token) {
return API.v1.failure({ error: 'Unauthorized' });
}
Expand Down Expand Up @@ -289,7 +289,7 @@ export class AppsRestApi {
return API.v1.failure({ error: 'Invalid purchase type' });
}

const token = await getWorkspaceAccessTokenWithScope('marketplace:purchase');
const token = await getWorkspaceAccessTokenWithScope({ scope: 'marketplace:purchase' });
if (!token) {
return API.v1.failure({ error: 'Unauthorized' });
}
Expand Down

0 comments on commit 5263a7d

Please sign in to comment.