@asgardeo/auth-react 0.2.1
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/.eslintignore +2 -0
- package/.eslintrc.js +74 -0
- package/README.md +958 -0
- package/babel.config.js +43 -0
- package/dist/main.js +822 -0
- package/dist/src/actions.d.ts +48 -0
- package/dist/src/actions.d.ts.map +1 -0
- package/dist/src/api.d.ts +193 -0
- package/dist/src/api.d.ts.map +1 -0
- package/dist/src/authenticate.d.ts +29 -0
- package/dist/src/authenticate.d.ts.map +1 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/models.d.ts +66 -0
- package/dist/src/models.d.ts.map +1 -0
- package/dist/src/public-api.d.ts +21 -0
- package/dist/src/public-api.d.ts.map +1 -0
- package/dist/src/reducer.d.ts +32 -0
- package/dist/src/reducer.d.ts.map +1 -0
- package/dist/src/secure-route.d.ts +30 -0
- package/dist/src/secure-route.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +2041 -0
- package/package.json +75 -0
- package/src/actions.ts +51 -0
- package/src/api.ts +394 -0
- package/src/authenticate.tsx +180 -0
- package/src/index.ts +23 -0
- package/src/models.ts +96 -0
- package/src/public-api.ts +21 -0
- package/src/reducer.ts +66 -0
- package/src/secure-route.tsx +58 -0
- package/tsconfig.json +26 -0
- package/webpack.config.js +105 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* AuthContext reducer actions enum.
|
|
20
|
+
*/
|
|
21
|
+
export declare enum AuthContextReducerActionTypes {
|
|
22
|
+
SET_SIGN_IN = "SET_SIGN_IN",
|
|
23
|
+
SET_SIGN_OUT = "SET_SIGN_OUT",
|
|
24
|
+
SET_PROFILE_INFO = "SET_PROFILE_INFO"
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Set Sign In State reducer action.
|
|
28
|
+
*/
|
|
29
|
+
export declare const setSignIn: (response: any) => {
|
|
30
|
+
payload: any;
|
|
31
|
+
type: AuthContextReducerActionTypes;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Set Sign Out State reducer action.
|
|
35
|
+
*/
|
|
36
|
+
export declare const setSignOut: () => {
|
|
37
|
+
type: AuthContextReducerActionTypes;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Set Profile Info reducer action.
|
|
41
|
+
*
|
|
42
|
+
* @param {any} details - Profile details
|
|
43
|
+
*/
|
|
44
|
+
export declare const setProfileInfo: (details: any) => {
|
|
45
|
+
payload: any;
|
|
46
|
+
type: AuthContextReducerActionTypes;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,oBAAY,6BAA6B;IACrC,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;CACxC;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,aAAc,GAAG;;;CAGrC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;;CAErB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAAa,GAAG;;;CAGzC,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { AuthClientConfig, BasicUserInfo, Config, CustomGrantConfig, DecodedIDTokenPayload, Hooks, HttpClientInstance, HttpRequestConfig, HttpResponse, OIDCEndpoints, SignInConfig } from "@asgardeo/auth-spa";
|
|
19
|
+
import { AuthStateInterface } from "./models";
|
|
20
|
+
declare class AuthAPI {
|
|
21
|
+
static DEFAULT_STATE: AuthStateInterface;
|
|
22
|
+
private _authState;
|
|
23
|
+
private _client;
|
|
24
|
+
constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Method to return Auth Client instance authentication state.
|
|
27
|
+
*
|
|
28
|
+
* @return {AuthStateInterface} Authentication State.
|
|
29
|
+
*/
|
|
30
|
+
getState(): AuthStateInterface;
|
|
31
|
+
/**
|
|
32
|
+
* Method to initialize the AuthClient instance.
|
|
33
|
+
*
|
|
34
|
+
* @param {Config} config - `dispatch` function from React Auth Context.
|
|
35
|
+
*/
|
|
36
|
+
init(config: AuthClientConfig<Config>): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Method to handle user Sign In requests.
|
|
39
|
+
*
|
|
40
|
+
* @param {any} dispatch - `dispatch` function from React Auth Context.
|
|
41
|
+
* @param {AuthStateInterface} state - Current authentication state in React Auth Context.
|
|
42
|
+
* @param {any} callback - Action to trigger on successful sign in.
|
|
43
|
+
*/
|
|
44
|
+
signIn(dispatch: (state: AuthStateInterface) => void, state: AuthStateInterface, config: SignInConfig, authorizationCode: string, sessionState: string, callback?: (response: BasicUserInfo) => void): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Method to handle user Sign Out requests.
|
|
47
|
+
*
|
|
48
|
+
* @param {any} dispatch - `dispatch` function from React Auth Context.
|
|
49
|
+
* @param {AuthStateInterface} state - Current authentication state in React Auth Context.
|
|
50
|
+
* @param {any} callback - Action to trigger on successful sign out.
|
|
51
|
+
*/
|
|
52
|
+
signOut(dispatch: (state: AuthStateInterface) => void, state: AuthStateInterface, callback?: () => void): void;
|
|
53
|
+
/**
|
|
54
|
+
* Method to update Auth Client instance authentication state.
|
|
55
|
+
*
|
|
56
|
+
* @param {AuthStateInterface} state - State values to update in authentication state.
|
|
57
|
+
*/
|
|
58
|
+
updateState(state: AuthStateInterface): void;
|
|
59
|
+
/**
|
|
60
|
+
* This method returns a Promise that resolves with the basic user information obtained from the ID token.
|
|
61
|
+
*
|
|
62
|
+
* @return {Promise<BasicUserInfo>} - A promise that resolves with the user information.
|
|
63
|
+
*/
|
|
64
|
+
getBasicUserInfo(): Promise<BasicUserInfo>;
|
|
65
|
+
/**
|
|
66
|
+
* This method sends an API request to a protected endpoint.
|
|
67
|
+
* The access token is automatically attached to the header of the request.
|
|
68
|
+
* This is the only way by which protected endpoints can be accessed
|
|
69
|
+
* when the web worker is used to store session information.
|
|
70
|
+
*
|
|
71
|
+
* @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
|
|
72
|
+
*
|
|
73
|
+
* @return {Promise<HttpResponse>} - Returns a Promise that resolves with the response to the request.
|
|
74
|
+
*/
|
|
75
|
+
httpRequest(config: HttpRequestConfig): Promise<HttpResponse<any>>;
|
|
76
|
+
/**
|
|
77
|
+
* This method sends multiple API requests to a protected endpoint.
|
|
78
|
+
* The access token is automatically attached to the header of the request.
|
|
79
|
+
* This is the only way by which multiple requests can be sent to protected endpoints
|
|
80
|
+
* when the web worker is used to store session information.
|
|
81
|
+
*
|
|
82
|
+
* @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
|
|
83
|
+
*
|
|
84
|
+
* @return {Promise<HttpResponse[]>} - Returns a Promise that resolves with the responses to the requests.
|
|
85
|
+
*/
|
|
86
|
+
httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
|
|
87
|
+
/**
|
|
88
|
+
* This method allows you to send a request with a custom grant.
|
|
89
|
+
*
|
|
90
|
+
* @param {CustomGrantRequestParams} config - The request parameters.
|
|
91
|
+
*
|
|
92
|
+
* @return {Promise<HttpResponse<any> | SignInResponse>} - A Promise that resolves with
|
|
93
|
+
* the value returned by the custom grant request.
|
|
94
|
+
*/
|
|
95
|
+
requestCustomGrant(config: CustomGrantConfig, callback: (response: BasicUserInfo | HttpResponse<any>) => void, dispatch: (state: AuthStateInterface) => void): void;
|
|
96
|
+
/**
|
|
97
|
+
* This method ends a user session. The access token is revoked and the session information is destroyed.
|
|
98
|
+
*
|
|
99
|
+
* @return {Promise<boolean>} - A promise that resolves with `true` if the process is successful.
|
|
100
|
+
*/
|
|
101
|
+
revokeAccessToken(dispatch: (state: AuthStateInterface) => void): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* This method returns a Promise that resolves with an object containing the service endpoints.
|
|
104
|
+
*
|
|
105
|
+
* @return {Promise<ServiceResourcesType} - A Promise that resolves with an object containing the service endpoints.
|
|
106
|
+
*/
|
|
107
|
+
getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
|
|
108
|
+
/**
|
|
109
|
+
* This methods returns the Axios http client.
|
|
110
|
+
*
|
|
111
|
+
* @return {HttpClientInstance} - The Axios HTTP client.
|
|
112
|
+
*/
|
|
113
|
+
getHttpClient(): Promise<HttpClientInstance>;
|
|
114
|
+
/**
|
|
115
|
+
* This method decodes the payload of the id token and returns it.
|
|
116
|
+
*
|
|
117
|
+
* @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
|
|
118
|
+
* the decoded payload of the id token.
|
|
119
|
+
*/
|
|
120
|
+
getDecodedIDToken(): Promise<DecodedIDTokenPayload>;
|
|
121
|
+
/**
|
|
122
|
+
* This method returns the ID token.
|
|
123
|
+
*
|
|
124
|
+
* @return {Promise<string>} - A Promise that resolves with the id token.
|
|
125
|
+
*/
|
|
126
|
+
getIDToken(): Promise<string>;
|
|
127
|
+
/**
|
|
128
|
+
* This method return a Promise that resolves with the access token.
|
|
129
|
+
*
|
|
130
|
+
* **This method will not return the access token if the storage type is set to `webWorker`.**
|
|
131
|
+
*
|
|
132
|
+
* @return {Promise<string>} - A Promise that resolves with the access token.
|
|
133
|
+
*/
|
|
134
|
+
getAccessToken(): Promise<string>;
|
|
135
|
+
/**
|
|
136
|
+
* This method refreshes the access token.
|
|
137
|
+
*
|
|
138
|
+
* @return {TokenResponseInterface} - A Promise that resolves with an object containing
|
|
139
|
+
* information about the refreshed access token.
|
|
140
|
+
*/
|
|
141
|
+
refreshAccessToken(): Promise<BasicUserInfo>;
|
|
142
|
+
/**
|
|
143
|
+
* This method specifies if the user is authenticated or not.
|
|
144
|
+
*
|
|
145
|
+
* @return {Promise<boolean>} - A Promise that resolves with `true` if teh user is authenticated.
|
|
146
|
+
*/
|
|
147
|
+
isAuthenticated(): Promise<boolean>;
|
|
148
|
+
/**
|
|
149
|
+
* This method enables callback functions attached to the http client.
|
|
150
|
+
*
|
|
151
|
+
* @return {Promise<boolean>} - A promise that resolves with True.
|
|
152
|
+
*
|
|
153
|
+
*/
|
|
154
|
+
enableHttpHandler(): Promise<boolean>;
|
|
155
|
+
/**
|
|
156
|
+
* This method disables callback functions attached to the http client.
|
|
157
|
+
*
|
|
158
|
+
* @return {Promise<boolean>} - A promise that resolves with True.
|
|
159
|
+
*/
|
|
160
|
+
disableHttpHandler(): Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* This method updates the configuration that was passed into the constructor when instantiating this class.
|
|
163
|
+
*
|
|
164
|
+
* @param {Partial<AuthClientConfig<T>>} config - A config object to update the SDK configurations with.
|
|
165
|
+
*/
|
|
166
|
+
updateConfig(config: Partial<AuthClientConfig<Config>>): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* This method attaches a callback function to an event hook that fires the callback when the event happens.
|
|
169
|
+
*
|
|
170
|
+
* @param {Hooks.CustomGrant} hook - The name of the hook.
|
|
171
|
+
* @param {(response?: any) => void} callback - The callback function.
|
|
172
|
+
* @param {string} id (optional) - The id of the hook. This is used when multiple custom grants are used.
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): Promise<void>;
|
|
176
|
+
on(hook: Hooks.RevokeAccessToken | Hooks.HttpRequestError | Hooks.HttpRequestFinish | Hooks.HttpRequestStart | Hooks.HttpRequestSuccess | Hooks.Initialize | Hooks.SignIn | Hooks.SignOut, callback: (response?: any) => void): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* This method allows you to sign in silently.
|
|
179
|
+
* First, this method sends a prompt none request to see if there is an active user session in the identity server.
|
|
180
|
+
* If there is one, then it requests the access token and stores it. Else, it returns false.
|
|
181
|
+
*
|
|
182
|
+
* @return {Promise<BasicUserInfo | boolean>} - A Promise that resolves with the user information after signing in
|
|
183
|
+
* or with `false` if the user is not signed in.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
*```
|
|
187
|
+
* client.trySignInSilently()
|
|
188
|
+
*```
|
|
189
|
+
*/
|
|
190
|
+
trySignInSilently(state: AuthStateInterface, dispatch: (state: AuthStateInterface) => void): Promise<BasicUserInfo | boolean | undefined>;
|
|
191
|
+
}
|
|
192
|
+
export default AuthAPI;
|
|
193
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEH,gBAAgB,EAChB,aAAa,EACb,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,EACL,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,YAAY,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,cAAM,OAAO;IACT,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC;IAEzC,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,OAAO,CAAoB;;IAYnC;;;;OAIG;IACI,QAAQ,IAAI,kBAAkB;IAIrC;;;;OAIG;IACI,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAI/D;;;;;;OAMG;IACU,MAAM,CACf,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,EAC7C,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,YAAY,EACpB,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,GAC7C,OAAO,CAAC,IAAI,CAAC;IAsBhB;;;;;;OAMG;IACI,OAAO,CACV,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,EAC7C,KAAK,EAAE,kBAAkB,EACzB,QAAQ,CAAC,EAAE,MAAM,IAAI,GACtB,IAAI;IAgBP;;;;OAIG;IACI,WAAW,CAA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AAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAInF;;;;;;;OAOG;IACI,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,KAAK,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1F,EAAE,CACL,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,OAAO,CAAC,IAAI,CAAC;IAShB;;;;;;;;;;;;OAYG;IACU,iBAAiB,CAC1B,KAAK,EAAE,kBAAkB,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAC9C,OAAO,CAAC,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;CA0BlD;AAWD,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { AuthClientConfig } from "@asgardeo/auth-spa";
|
|
19
|
+
import { FunctionComponent, PropsWithChildren } from "react";
|
|
20
|
+
import AuthAPI from "./api";
|
|
21
|
+
import { AuthContextInterface, AuthReactConfig } from "./models";
|
|
22
|
+
declare const AuthClient: AuthAPI;
|
|
23
|
+
interface AuthProviderPropsInterface {
|
|
24
|
+
config: AuthClientConfig<AuthReactConfig>;
|
|
25
|
+
}
|
|
26
|
+
declare const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterface>>;
|
|
27
|
+
declare const useAuthContext: () => AuthContextInterface;
|
|
28
|
+
export { AuthClient, AuthProvider, useAuthContext };
|
|
29
|
+
//# sourceMappingURL=authenticate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/authenticate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACH,gBAAgB,EAQnB,MAAM,oBAAoB,CAAC;AAC5B,OAAc,EACV,iBAAiB,EACjB,iBAAiB,EAKpB,MAAM,OAAO,CAAC;AACf,OAAO,OAAO,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAsB,MAAM,UAAU,CAAC;AAErF,QAAA,MAAM,UAAU,SAAgB,CAAC;AAOjC,UAAU,0BAA0B;IAChC,MAAM,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;CAC7C;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,CA2HlF,CAAC;AAEF,QAAA,MAAM,cAAc,QAAO,oBAE1B,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import "core-js";
|
|
19
|
+
import "regenerator-runtime/runtime";
|
|
20
|
+
export * from "@asgardeo/auth-spa";
|
|
21
|
+
export * from "./public-api";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,SAAS,CAAC;AACjB,OAAO,6BAA6B,CAAC;AAErC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { AuthClientConfig, BasicUserInfo, Config, CustomGrantConfig, DecodedIDTokenPayload, Hooks, HttpClientInstance, HttpRequestConfig, HttpResponse, OIDCEndpoints, SPAConfig } from "@asgardeo/auth-spa";
|
|
19
|
+
export interface AuthReactConfig extends SPAConfig {
|
|
20
|
+
/**
|
|
21
|
+
* The SDK's `AuthProvider` by default is listening to the URL changes to see
|
|
22
|
+
* if `code` & `session_state` search params are available so that it could perform
|
|
23
|
+
* token exchange. This option could be used to override that behaviour.
|
|
24
|
+
*/
|
|
25
|
+
skipRedirectCallback?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface AuthStateInterface {
|
|
28
|
+
allowedScopes: string;
|
|
29
|
+
displayName?: string;
|
|
30
|
+
email?: string;
|
|
31
|
+
isAuthenticated: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Are the Auth requests loading.
|
|
34
|
+
*/
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
username: string;
|
|
37
|
+
}
|
|
38
|
+
export interface AuthContextInterface {
|
|
39
|
+
signIn: (callback?: any) => Promise<void>;
|
|
40
|
+
signOut: () => void;
|
|
41
|
+
getBasicUserInfo(): Promise<BasicUserInfo>;
|
|
42
|
+
httpRequest(config: HttpRequestConfig): Promise<HttpResponse<any>>;
|
|
43
|
+
httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
|
|
44
|
+
requestCustomGrant(config: CustomGrantConfig, callback?: (response: BasicUserInfo | HttpResponse<any>) => void): void;
|
|
45
|
+
revokeAccessToken(): Promise<boolean>;
|
|
46
|
+
getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
|
|
47
|
+
getHttpClient(): Promise<HttpClientInstance>;
|
|
48
|
+
getDecodedIDToken(): Promise<DecodedIDTokenPayload>;
|
|
49
|
+
getIDToken(): Promise<string>;
|
|
50
|
+
getAccessToken(): Promise<string>;
|
|
51
|
+
refreshAccessToken(): Promise<BasicUserInfo>;
|
|
52
|
+
isAuthenticated(): Promise<boolean>;
|
|
53
|
+
enableHttpHandler(): Promise<boolean>;
|
|
54
|
+
disableHttpHandler(): Promise<boolean>;
|
|
55
|
+
updateConfig(config: Partial<AuthClientConfig<Config>>): Promise<void>;
|
|
56
|
+
trySignInSilently: () => Promise<boolean | BasicUserInfo>;
|
|
57
|
+
on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): void;
|
|
58
|
+
on(hook: Hooks.RevokeAccessToken | Hooks.HttpRequestError | Hooks.HttpRequestFinish | Hooks.HttpRequestStart | Hooks.HttpRequestSuccess | Hooks.Initialize | Hooks.SignIn | Hooks.SignOut, callback: (response?: any) => void): void;
|
|
59
|
+
on(hook: Hooks, callback: (response?: any) => void, id?: string): void;
|
|
60
|
+
state: AuthStateInterface;
|
|
61
|
+
}
|
|
62
|
+
export interface SecureRouteInterface {
|
|
63
|
+
callback: () => void;
|
|
64
|
+
component: any;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +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,SAAS,EACZ,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAC9C;;;;OAIG;IACH,oBAAoB,CAAC,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AAC,OAAO,CAAC,CAAC;IACtC,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,aAAa,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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
export * from "./authenticate";
|
|
19
|
+
export * from "./models";
|
|
20
|
+
export * from "./secure-route";
|
|
21
|
+
//# sourceMappingURL=public-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../src/public-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { AuthStateInterface } from "./models";
|
|
19
|
+
/**
|
|
20
|
+
* Initial authenticate state.
|
|
21
|
+
*/
|
|
22
|
+
declare const authenticateInitialState: AuthStateInterface;
|
|
23
|
+
/**
|
|
24
|
+
* Reducer to handle the state of authentication related actions.
|
|
25
|
+
*
|
|
26
|
+
* @param state - Previous state
|
|
27
|
+
* @param action - Action type
|
|
28
|
+
* @returns The new state
|
|
29
|
+
*/
|
|
30
|
+
declare const authenticateReducer: (state: any, action: any) => any;
|
|
31
|
+
export { authenticateInitialState, authenticateReducer };
|
|
32
|
+
//# sourceMappingURL=reducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/reducer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,QAAA,MAAM,wBAAwB,EAAE,kBAO/B,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,mBAAmB,kCAuBxB,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { FunctionComponent } from "react";
|
|
19
|
+
import { RouteProps } from "react-router-dom";
|
|
20
|
+
import { SecureRouteInterface } from "./models";
|
|
21
|
+
/**
|
|
22
|
+
* Protected route component.
|
|
23
|
+
*
|
|
24
|
+
* @param {SecureRouteInterface} props - Props injected in to the component.
|
|
25
|
+
*
|
|
26
|
+
* @return {React.ReactElement}
|
|
27
|
+
*/
|
|
28
|
+
declare const SecureRoute: FunctionComponent<SecureRouteInterface & RouteProps>;
|
|
29
|
+
export { SecureRoute };
|
|
30
|
+
//# sourceMappingURL=secure-route.d.ts.map
|