Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/utils-reference/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ npm install --save @raycast/utils

## Changelog

### v2.2.6

- Fixed an issue where refreshing OAuth tokens would fails for providers that return scope as an array instead of a string

### v2.2.5

- Fixed an issue where `useSql` would not properly show the permission priming screen
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@raycast/utils",
"version": "2.2.5",
"version": "2.2.6",
"description": "Set of utilities to streamline building Raycast extensions",
"author": "Raycast Technologies Ltd.",
"homepage": "https://developers.raycast.com/utilities/getting-started",
Expand Down
10 changes: 7 additions & 3 deletions src/oauth/OAuthService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
ProviderWithDefaultClientOptions,
} from "./types";

function normalizeTokenResponse(tokens: OAuth.TokenResponse): OAuth.TokenResponse {
// Some clients such as Linear can return a scope array instead of a string.
return Array.isArray(tokens.scope) ? { ...tokens, scope: tokens.scope.join(" ") } : tokens;
}

/**
* Class allowing to create an OAuth service using the the PKCE (Proof Key for Code Exchange) flow.
*
Expand Down Expand Up @@ -273,7 +278,7 @@
tokenRefreshResponseParser: options.tokenRefreshResponseParser,
tokenResponseParser:
options.tokenResponseParser ??
((response: any) => {

Check warning on line 281 in src/oauth/OAuthService.ts

View workflow job for this annotation

GitHub Actions / tests

Unexpected any. Specify a different type
return {
access_token: response.authed_user.access_token,
scope: response.authed_user.scope,
Expand Down Expand Up @@ -400,8 +405,7 @@
}
const tokens = this.tokenResponseParser(await response.json());

// Some clients such as Linear can return a scope array instead of a string
return Array.isArray(tokens.scope) ? { ...tokens, scope: tokens.scope.join(" ") } : tokens;
return normalizeTokenResponse(tokens);
}

private async refreshTokens({ token }: { token: string }) {
Expand Down Expand Up @@ -435,7 +439,7 @@
} else {
const tokenResponse = this.tokenRefreshResponseParser(await response.json());
tokenResponse.refresh_token = tokenResponse.refresh_token ?? token;
return tokenResponse;
return normalizeTokenResponse(tokenResponse);
}
}
}
Loading