Skip to content

Commit

Permalink
Merge pull request #6 from Mermaid-Chart/fix/fix-handleAuthorizationR…
Browse files Browse the repository at this point in the history
…esponse-missing-state-in-url

fix(sdk): fix `#getAuthorizationData()` default URL missing a `state` parameter
  • Loading branch information
sidharthv96 authored Nov 24, 2023
2 parents 838d435 + 6dc3248 commit 654d323
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- `MermaidChart#getAuthorizationData()` now correctly sets `state` in the URL
by default.
- `MermaidChart#handleAuthorizationResponse()` now supports relative URLs.

## [0.1.1] - 2023-09-08
Expand Down
8 changes: 8 additions & 0 deletions packages/sdk/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ describe('MermaidChart', () => {
});
});

describe('#getAuthorizationData', () => {
it('should set default state', async () => {
const { state, url } = await client.getAuthorizationData();

expect(new URL(url).searchParams.has('state', state)).toBeTruthy();
});
});

describe('#handleAuthorizationResponse', () => {
let state: AuthorizationData['state'];
beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class MermaidChart {

const url = await this.oauth.authorizationCode.getAuthorizeUri({
redirectUri: this.redirectURI,
state,
state: stateID,
codeVerifier,
scope,
});
Expand Down

0 comments on commit 654d323

Please sign in to comment.