@asgardeo/auth-react 0.2.5 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +154 -62
- package/dist/main.js +38 -38
- package/dist/src/authenticate.d.ts.map +1 -1
- package/dist/src/models.d.ts +4 -4
- package/dist/src/models.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +11 -11
- package/package.json +9 -9
- package/src/api.ts +4 -4
- package/src/authenticate.tsx +7 -4
- package/src/models.ts +6 -5
- package/src/reducer.ts +1 -1
- package/webpack.config.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/authenticate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAYH,OAAc,EACV,iBAAiB,EACjB,iBAAiB,EAMjB,SAAS,EACZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/authenticate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAYH,OAAc,EACV,iBAAiB,EACjB,iBAAiB,EAMjB,SAAS,EACZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAe,MAAM,GAAG,CAAC;AAC5C,OAAO,OAAO,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAsB,MAAM,UAAU,CAAC;AASrF,QAAA,MAAM,UAAU,SAAgB,CAAC;AAOjC,UAAU,0BAA0B;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,CAiKlF,CAAC;AAEF,QAAA,MAAM,cAAc,QAAO,oBAE1B,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/src/models.d.ts
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AuthClientConfig, BasicUserInfo, Config, CustomGrantConfig, DecodedIDTokenPayload, Hooks, HttpClientInstance, HttpRequestConfig, HttpResponse, OIDCEndpoints, SignInConfig
|
|
19
|
-
export interface ReactConfig
|
|
18
|
+
import { AuthClientConfig, AuthSPAClientConfig, BasicUserInfo, Config, CustomGrantConfig, DecodedIDTokenPayload, Hooks, HttpClientInstance, HttpRequestConfig, HttpResponse, OIDCEndpoints, SignInConfig } from "@asgardeo/auth-spa";
|
|
19
|
+
export interface ReactConfig {
|
|
20
20
|
/**
|
|
21
21
|
* The SDK's `AuthProvider` by default is listening to the URL changes to see
|
|
22
22
|
* if `code` & `session_state` search params are available so that it could perform
|
|
@@ -29,7 +29,7 @@ export interface ReactConfig extends SPAConfig {
|
|
|
29
29
|
*/
|
|
30
30
|
disableTrySignInSilently?: boolean;
|
|
31
31
|
}
|
|
32
|
-
export declare type AuthReactConfig =
|
|
32
|
+
export declare type AuthReactConfig = AuthSPAClientConfig & ReactConfig;
|
|
33
33
|
export interface AuthStateInterface {
|
|
34
34
|
allowedScopes: string;
|
|
35
35
|
displayName?: string;
|
|
@@ -39,7 +39,7 @@ export interface AuthStateInterface {
|
|
|
39
39
|
* Are the Auth requests loading.
|
|
40
40
|
*/
|
|
41
41
|
isLoading: boolean;
|
|
42
|
-
username
|
|
42
|
+
username?: string;
|
|
43
43
|
}
|
|
44
44
|
export interface AuthContextInterface {
|
|
45
45
|
signIn: (config?: SignInConfig, authorizationCode?: string, sessionState?: string, callback?: (response: BasicUserInfo) => void) => Promise<BasicUserInfo>;
|
package/dist/src/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACH,gBAAgB,EAChB,aAAa,EACb,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,EACL,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,YAAY,
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,EACL,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,YAAY,EACf,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,WAAW;IACxB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACtC;AAED,oBAAY,eAAe,GAAG,mBAAmB,GAAG,WAAW,CAAC;AAEhE,MAAM,WAAW,kBAAkB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,CACJ,MAAM,CAAC,EAAE,YAAY,EACrB,iBAAiB,CAAC,EAAE,MAAM,EAC1B,YAAY,CAAC,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KA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Aa,CAAC,CAAC;IAC1D,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,KAAK,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClF,EAAE,CACE,IAAI,EACE,KAAK,CAAC,iBAAiB,GACvB,KAAK,CAAC,gBAAgB,GACtB,KAAK,CAAC,iBAAiB,GACvB,KAAK,CAAC,gBAAgB,GACtB,KAAK,CAAC,kBAAkB,GACxB,KAAK,CAAC,UAAU,GAChB,KAAK,CAAC,MAAM,GACZ,KAAK,CAAC,OAAO,EACnB,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,KAAK,IAAI,GACnC,IAAI,CAAC;IACR,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,KAAK,IAAI,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvE,KAAK,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACjC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -247,8 +247,8 @@
|
|
|
247
247
|
"affectsGlobalScope": false
|
|
248
248
|
},
|
|
249
249
|
"../../node_modules/@asgardeo/auth-js/dist/src/models/user.d.ts": {
|
|
250
|
-
"version": "
|
|
251
|
-
"signature": "
|
|
250
|
+
"version": "c0c32cd791d40c234e202fa9d8788b555a4dd3c8b9eb15ac1d5d13dd0b551bb7",
|
|
251
|
+
"signature": "c0c32cd791d40c234e202fa9d8788b555a4dd3c8b9eb15ac1d5d13dd0b551bb7",
|
|
252
252
|
"affectsGlobalScope": false
|
|
253
253
|
},
|
|
254
254
|
"../../node_modules/@asgardeo/auth-js/dist/src/models/crypto.d.ts": {
|
|
@@ -387,13 +387,13 @@
|
|
|
387
387
|
"affectsGlobalScope": false
|
|
388
388
|
},
|
|
389
389
|
"../../node_modules/@asgardeo/auth-spa/dist/src/client.d.ts": {
|
|
390
|
-
"version": "
|
|
391
|
-
"signature": "
|
|
390
|
+
"version": "3745da53198e9019bd8317d08a81255099a1fc8d31a75964233b76a97f4b6f1f",
|
|
391
|
+
"signature": "3745da53198e9019bd8317d08a81255099a1fc8d31a75964233b76a97f4b6f1f",
|
|
392
392
|
"affectsGlobalScope": false
|
|
393
393
|
},
|
|
394
394
|
"../../node_modules/@asgardeo/auth-spa/dist/src/utils/spa-utils.d.ts": {
|
|
395
|
-
"version": "
|
|
396
|
-
"signature": "
|
|
395
|
+
"version": "7f637e69c051e589a53ef176770786f110e75b840771747e01845334ba15eb3d",
|
|
396
|
+
"signature": "7f637e69c051e589a53ef176770786f110e75b840771747e01845334ba15eb3d",
|
|
397
397
|
"affectsGlobalScope": false
|
|
398
398
|
},
|
|
399
399
|
"../../node_modules/@asgardeo/auth-spa/dist/src/public-api.d.ts": {
|
|
@@ -407,12 +407,12 @@
|
|
|
407
407
|
"affectsGlobalScope": false
|
|
408
408
|
},
|
|
409
409
|
"../src/models.ts": {
|
|
410
|
-
"version": "
|
|
411
|
-
"signature": "
|
|
410
|
+
"version": "99c790878c588c7433f19fe3eb2facfdcb9fa7422eb0042d9c5baf24920d70ee",
|
|
411
|
+
"signature": "bba795e0d490d64c7cec7130b24775cbb48d388bd15ee17fa89b1dcdeda214a4",
|
|
412
412
|
"affectsGlobalScope": false
|
|
413
413
|
},
|
|
414
414
|
"../src/api.ts": {
|
|
415
|
-
"version": "
|
|
415
|
+
"version": "5f8384b96ff39f923ddf6420101ee2f667f85e18538e3391296db1310bead691",
|
|
416
416
|
"signature": "236268caea2fc92cb7c12e17621df787a9e8be5fd71772d19cc81abf335bcba3",
|
|
417
417
|
"affectsGlobalScope": false
|
|
418
418
|
},
|
|
@@ -527,12 +527,12 @@
|
|
|
527
527
|
"affectsGlobalScope": false
|
|
528
528
|
},
|
|
529
529
|
"../src/authenticate.tsx": {
|
|
530
|
-
"version": "
|
|
530
|
+
"version": "c7939d0fd114f2a550b4a591a099a95ba9e1e419e73df8f6e746edbdc5cfa270",
|
|
531
531
|
"signature": "336cb282ec49398aece02113130600346cc39c172377aad24e5cb639ce3d226b",
|
|
532
532
|
"affectsGlobalScope": false
|
|
533
533
|
},
|
|
534
534
|
"../src/reducer.ts": {
|
|
535
|
-
"version": "
|
|
535
|
+
"version": "970fa7ffd2a338e469c23af6ec4fc75d86e0b8fcf1ab8a1504353e461a77995e",
|
|
536
536
|
"signature": "8ad53cc4bf5cc967c8947af4f113a3ed943d9b26002a36fbaa062341233d8e17",
|
|
537
537
|
"affectsGlobalScope": false
|
|
538
538
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgardeo/auth-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Asgardeo Auth React SDK for React Applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"WSO2",
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
"types": "dist/src/index.d.ts",
|
|
19
19
|
"module": "dist/main.js",
|
|
20
20
|
"scripts": {
|
|
21
|
-
"lint": "
|
|
21
|
+
"lint": "eslint --ext .js,.ts .",
|
|
22
|
+
"fix-lint": "eslint --ext .js,.ts . --fix",
|
|
22
23
|
"build": "rimraf dist && npm run type-check && webpack -p --env.NODE_ENV=production",
|
|
23
|
-
"build:dev": "rimraf dist && npm run type-check && webpack -p --env.NODE_ENV=
|
|
24
|
+
"build:dev": "rimraf dist && npm run type-check && webpack -p --env.NODE_ENV=development",
|
|
24
25
|
"type-check": "tsc --emitDeclarationOnly",
|
|
25
26
|
"type-check:watch": "npm run type-check -- --watch"
|
|
26
27
|
},
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"author": "WSO2",
|
|
36
37
|
"license": "Apache-2.0",
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@asgardeo/auth-spa": "^0.2.
|
|
39
|
+
"@asgardeo/auth-spa": "^0.2.11"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@babel/cli": "^7.10.5",
|
|
@@ -52,10 +53,9 @@
|
|
|
52
53
|
"@typescript-eslint/parser": "^3.10.1",
|
|
53
54
|
"babel-loader": "^8.1.0",
|
|
54
55
|
"core-js": "^3.8.3",
|
|
55
|
-
"eslint": "^
|
|
56
|
-
"eslint-loader": "^3.0.3",
|
|
56
|
+
"eslint": "^7.20.0",
|
|
57
57
|
"eslint-plugin-import": "^2.20.2",
|
|
58
|
-
"eslint-plugin-react": "^7.
|
|
58
|
+
"eslint-plugin-react": "^7.18.3",
|
|
59
59
|
"eslint-plugin-react-hooks": "^4.0.0",
|
|
60
60
|
"react": "^16.14.0",
|
|
61
61
|
"react-dom": "16.14.0",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@babel/runtime-corejs3": "^7.11.2",
|
|
71
|
-
"react": "
|
|
72
|
-
"react-dom": "16.
|
|
71
|
+
"react": ">=16.8",
|
|
72
|
+
"react-dom": ">=16.8",
|
|
73
73
|
"react-router-dom": "^5.2.0"
|
|
74
74
|
}
|
|
75
75
|
}
|
package/src/api.ts
CHANGED
|
@@ -89,14 +89,14 @@ class AuthAPI {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
if (await this._client.isAuthenticated()) {
|
|
92
|
-
const stateToUpdate =
|
|
92
|
+
const stateToUpdate ={
|
|
93
93
|
allowedScopes: response.allowedScopes,
|
|
94
94
|
displayName: response.displayName,
|
|
95
95
|
email: response.email,
|
|
96
96
|
isAuthenticated: true,
|
|
97
|
-
username: response.username,
|
|
98
97
|
isLoading: false,
|
|
99
|
-
isSigningOut: false
|
|
98
|
+
isSigningOut: false,
|
|
99
|
+
username: response.username
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
this.updateState(stateToUpdate);
|
|
@@ -236,7 +236,7 @@ class AuthAPI {
|
|
|
236
236
|
return this._client
|
|
237
237
|
.revokeAccessToken()
|
|
238
238
|
.then(() => {
|
|
239
|
-
this.updateState(AuthAPI.DEFAULT_STATE);
|
|
239
|
+
this.updateState({ ...AuthAPI.DEFAULT_STATE, isLoading: false });
|
|
240
240
|
dispatch(AuthAPI.DEFAULT_STATE);
|
|
241
241
|
return true;
|
|
242
242
|
})
|
package/src/authenticate.tsx
CHANGED
|
@@ -36,14 +36,14 @@ import React, {
|
|
|
36
36
|
useState,
|
|
37
37
|
ReactNode
|
|
38
38
|
} from "react";
|
|
39
|
-
import { AuthParams } from ".";
|
|
39
|
+
import { AuthParams, ReactConfig } from ".";
|
|
40
40
|
import AuthAPI from "./api";
|
|
41
41
|
import { AuthContextInterface, AuthReactConfig, AuthStateInterface } from "./models";
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Default `
|
|
44
|
+
* Default `AuthReactConfig` config.
|
|
45
45
|
*/
|
|
46
|
-
const defaultConfig: Partial<
|
|
46
|
+
const defaultConfig: Partial<ReactConfig> = {
|
|
47
47
|
disableTrySignInSilently: false
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -148,7 +148,10 @@ const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterfa
|
|
|
148
148
|
authParams = await getAuthParams();
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
if (SPAUtils.hasAuthSearchParamsInURL()
|
|
151
|
+
if (SPAUtils.hasAuthSearchParamsInURL()
|
|
152
|
+
|| authParams?.authorizationCode
|
|
153
|
+
|| new URL(location.href).searchParams.get("error") )
|
|
154
|
+
{
|
|
152
155
|
await signIn({ callOnlyOnRedirect: true }, authParams?.authorizationCode, authParams?.sessionState)
|
|
153
156
|
.then(() => {
|
|
154
157
|
// TODO: Add logs when a logger is available.
|
package/src/models.ts
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
20
|
AuthClientConfig,
|
|
21
|
+
AuthSPAClientConfig,
|
|
21
22
|
BasicUserInfo,
|
|
22
23
|
Config,
|
|
23
24
|
CustomGrantConfig,
|
|
@@ -27,11 +28,10 @@ import {
|
|
|
27
28
|
HttpRequestConfig,
|
|
28
29
|
HttpResponse,
|
|
29
30
|
OIDCEndpoints,
|
|
30
|
-
SignInConfig
|
|
31
|
-
SPAConfig
|
|
31
|
+
SignInConfig
|
|
32
32
|
} from "@asgardeo/auth-spa";
|
|
33
33
|
|
|
34
|
-
export interface ReactConfig
|
|
34
|
+
export interface ReactConfig {
|
|
35
35
|
/**
|
|
36
36
|
* The SDK's `AuthProvider` by default is listening to the URL changes to see
|
|
37
37
|
* if `code` & `session_state` search params are available so that it could perform
|
|
@@ -45,7 +45,8 @@ export interface ReactConfig extends SPAConfig {
|
|
|
45
45
|
disableTrySignInSilently?: boolean;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export type AuthReactConfig =
|
|
48
|
+
export type AuthReactConfig = AuthSPAClientConfig & ReactConfig;
|
|
49
|
+
|
|
49
50
|
export interface AuthStateInterface {
|
|
50
51
|
allowedScopes: string;
|
|
51
52
|
displayName?: string;
|
|
@@ -55,7 +56,7 @@ export interface AuthStateInterface {
|
|
|
55
56
|
* Are the Auth requests loading.
|
|
56
57
|
*/
|
|
57
58
|
isLoading: boolean;
|
|
58
|
-
username
|
|
59
|
+
username?: string;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
export interface AuthContextInterface {
|
package/src/reducer.ts
CHANGED
package/webpack.config.js
CHANGED