Skip to content

Commit

Permalink
chore(): Prepare release 4.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
moberwasserlechner committed Apr 11, 2023
1 parent dc9ed19 commit 3d11ba2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Changelog

## [4.0.2] - 2023-04-11

### Fixed

* Web: Parse url parameters for search and hash properly [#183](https://github.com/moberwasserlechner/capacitor-oauth2/pull/183), [#182](https://github.com/moberwasserlechner/capacitor-oauth2/issues/182). Thank you, [@jvartanian](https://github.com/jvartanian)

## [4.0.1] - 2023-04-11

### Fixed

* Android: Additional `id_token` argument for logout method [#192](https://github.com/moberwasserlechner/capacitor-oauth2/issues/233). Thank you [@svzi](https://github.com/svzi)
* Android: Additional `id_token` argument for logout method [#233](https://github.com/moberwasserlechner/capacitor-oauth2/pull/233). Thank you, [@svzi](https://github.com/svzi)

### Chore

Expand Down Expand Up @@ -133,7 +139,8 @@ This is controlled by Android specific parameters `handleResultOnNewIntent` for
- Android: Fix Java compiler error #36 (thx @Anthbs)
- Fix github security error by updating Jest lib

[Unreleased]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/4.0.1...main
[Unreleased]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/4.0.2...main
[4.0.2]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/4.0.1...4.0.2
[4.0.1]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/4.0.0...4.0.1
[4.0.0]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/3.0.1...4.0.0
[3.0.1]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/3.0.0...3.0.1
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": "@byteowls/capacitor-oauth2",
"version": "4.0.1",
"version": "4.0.2",
"description": "Capacitor OAuth 2 client plugin",
"author": "Michael Oberwasserlechner",
"homepage": "https://github.com/moberwasserlechner/capacitor-oauth2",
Expand Down
42 changes: 35 additions & 7 deletions src/web-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,31 +140,36 @@ describe('web options', () => {

describe("Url param extraction", () => {

it('should return null on null url', () => {
it('should return undefined on null url', () => {
const paramObj = WebUtils.getUrlParams(null!);
expect(paramObj).toBeUndefined();
});

it('should return null on empty url', () => {
it('should return undefined on empty url', () => {
const paramObj = WebUtils.getUrlParams("");
expect(paramObj).toBeUndefined();
});

it('should return null on url with spaces', () => {
it('should return undefined on url with spaces', () => {
const paramObj = WebUtils.getUrlParams(" ");
expect(paramObj).toBeUndefined();
});

it('should return null if no params in url', () => {
it('should return undefined if no params in url', () => {
const paramObj = WebUtils.getUrlParams("https://app.example.com/");
expect(paramObj).toBeUndefined();
});

it('should return null if no params in url', () => {
it('should return undefined if no params in url search', () => {
const paramObj = WebUtils.getUrlParams("https://app.example.com?");
expect(paramObj).toBeUndefined();
});

it('should return undefined if no params in url hash', () => {
const paramObj = WebUtils.getUrlParams("https://app.example.com#");
expect(paramObj).toBeUndefined();
});

it('should remove invalid combinations one param', () => {
const paramObj = WebUtils.getUrlParams("https://app.example.com?=test");
expect(paramObj).toBeUndefined();
Expand All @@ -182,7 +187,7 @@ describe("Url param extraction", () => {

it('should extract a uuid state param', () => {
const state = WebUtils.randomString();
const paramObj = WebUtils.getUrlParams("https://app.example.com?state=" + state + "&access_token=testtoken");
const paramObj = WebUtils.getUrlParams(`https://app.example.com?state=${state}&access_token=testtoken`);
expect(paramObj!["state"]).toStrictEqual(state);
});

Expand All @@ -191,7 +196,15 @@ describe("Url param extraction", () => {
const foo = WebUtils.randomString();
const paramObj = WebUtils.getUrlParams(`https://app.example.com?random=${random}&foo=${foo}#ignored`);
expect(paramObj!["random"]).toStrictEqual(random);
expect(paramObj!["foo"]).toStrictEqual(`${foo}`);
expect(paramObj!["foo"]).toStrictEqual(foo);
});

it('should use query flag with another question mark in a param', () => {
const random = WebUtils.randomString();
const foo = WebUtils.randomString();
const paramObj = WebUtils.getUrlParams(`https://app.example.com?random=${random}&foo=${foo}?questionmark`);
expect(paramObj!["random"]).toStrictEqual(random);
expect(paramObj!["foo"]).toStrictEqual(`${foo}?questionmark`);
});

it('should use hash flag and ignore query flag', () => {
Expand All @@ -202,6 +215,14 @@ describe("Url param extraction", () => {
expect(paramObj!["foo"]).toStrictEqual(`${foo}?ignored`);
});

it('should use hash flag with another hash in a param', () => {
const random = WebUtils.randomString();
const foo = WebUtils.randomString();
const paramObj = WebUtils.getUrlParams(`https://app.example.com#random=${random}&foo=${foo}#hash`);
expect(paramObj!["random"]).toStrictEqual(random);
expect(paramObj!["foo"]).toStrictEqual(`${foo}#hash`);
});

it('should extract hash params correctly', () => {
const random = WebUtils.randomString(20);
const url = `http://localhost:4200/#state=${random}&access_token=ya29.a0ARrdaM-sdfsfsdfsdfsdfs-YGFHwg_lM6dePPaT_TunbpsdfsdfsdfsEG6vTVLsLJDDW
Expand All @@ -213,6 +234,13 @@ describe("Url param extraction", () => {
expect(paramObj!["prompt"]).toBeDefined();
expect(paramObj!["state"]).toStrictEqual(random);
});

it('should extract hash params if search param indicator present', () => {
const token = "sldfskdjflsdf12302";
const url = `http://localhost:3000/login?#access_token=${token}`;
const paramObj = WebUtils.getUrlParams(url);
expect(paramObj!["access_token"]).toStrictEqual(token);
})
});

describe("Random string gen", () => {
Expand Down

0 comments on commit 3d11ba2

Please sign in to comment.