@asgardeo/auth-react 0.2.16 → 1.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgardeo/auth-react",
3
- "version": "0.2.16",
3
+ "version": "1.0.0",
4
4
  "description": "Asgardeo Auth React SDK for React Applications.",
5
5
  "keywords": [
6
6
  "WSO2",
@@ -36,7 +36,7 @@
36
36
  "author": "WSO2",
37
37
  "license": "Apache-2.0",
38
38
  "dependencies": {
39
- "@asgardeo/auth-spa": "^0.2.19"
39
+ "@asgardeo/auth-spa": "^0.2.21"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@babel/cli": "^7.10.5",
package/src/api.ts CHANGED
@@ -22,6 +22,7 @@ import {
22
22
  BasicUserInfo,
23
23
  Config,
24
24
  DecodedIDTokenPayload,
25
+ FetchResponse,
25
26
  Hooks,
26
27
  HttpClientInstance,
27
28
  HttpRequestConfig,
@@ -168,7 +169,7 @@ class AuthAPI {
168
169
  *
169
170
  * @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
170
171
  *
171
- * @return {Promise<HttpResponse>} - Returns a Promise that resolves with the response to the request.
172
+ * @return {Promise<FetchResponse>} - Returns a Promise that resolves with the response to the request.
172
173
  */
173
174
  public async httpRequest(config: HttpRequestConfig): Promise<HttpResponse<any>> {
174
175
  return this._client.httpRequest(config);
@@ -182,7 +183,7 @@ class AuthAPI {
182
183
  *
183
184
  * @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
184
185
  *
185
- * @return {Promise<HttpResponse[]>} - Returns a Promise that resolves with the responses to the requests.
186
+ * @return {Promise<FetchResponse[]>} - Returns a Promise that resolves with the responses to the requests.
186
187
  */
187
188
  public async httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse<any>[]> {
188
189
  return this._client.httpRequestAll(configs);
@@ -193,17 +194,17 @@ class AuthAPI {
193
194
  *
194
195
  * @param {CustomGrantRequestParams} config - The request parameters.
195
196
  *
196
- * @return {Promise<HttpResponse<any> | SignInResponse>} - A Promise that resolves with
197
+ * @return {Promise<FetchResponse<any> | SignInResponse>} - A Promise that resolves with
197
198
  * the value returned by the custom grant request.
198
199
  */
199
200
  public requestCustomGrant(
200
201
  config: SPACustomGrantConfig,
201
- callback: (response: BasicUserInfo | HttpResponse<any>) => void,
202
+ callback: (response: BasicUserInfo | FetchResponse<any>) => void,
202
203
  dispatch: (state: AuthStateInterface) => void
203
- ): Promise<BasicUserInfo | HttpResponse<any>> {
204
+ ): Promise<BasicUserInfo | FetchResponse<any>> {
204
205
  return this._client
205
206
  .requestCustomGrant(config)
206
- .then((response: BasicUserInfo | HttpResponse<any>) => {
207
+ .then((response: BasicUserInfo | FetchResponse<any>) => {
207
208
  if (!response) {
208
209
  return;
209
210
  }
@@ -351,15 +352,7 @@ class AuthAPI {
351
352
  */
352
353
  public on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): Promise<void>;
353
354
  public on(
354
- hook:
355
- | Hooks.RevokeAccessToken
356
- | Hooks.HttpRequestError
357
- | Hooks.HttpRequestFinish
358
- | Hooks.HttpRequestStart
359
- | Hooks.HttpRequestSuccess
360
- | Hooks.Initialize
361
- | Hooks.SignIn
362
- | Hooks.SignOut,
355
+ hook: Exclude<Hooks, Hooks.CustomGrant>,
363
356
  callback: (response?: any) => void
364
357
  ): Promise<void>;
365
358
  public on(hook: Hooks, callback: (response?: any) => void, id?: string): Promise<void> {
@@ -19,9 +19,9 @@
19
19
  import {
20
20
  AuthClientConfig,
21
21
  BasicUserInfo,
22
+ FetchResponse,
22
23
  Hooks,
23
24
  HttpRequestConfig,
24
- HttpResponse,
25
25
  SPAUtils,
26
26
  SignInConfig
27
27
  } from "@asgardeo/auth-spa";
@@ -44,7 +44,7 @@ import { AuthContextInterface, AuthReactConfig, AuthStateInterface } from "./mod
44
44
  * Default `AuthReactConfig` config.
45
45
  */
46
46
  const defaultConfig: Partial<ReactConfig> = {
47
- disableTrySignInSilently: false
47
+ disableTrySignInSilently: true
48
48
  };
49
49
 
50
50
  const AuthClient = new AuthAPI();
@@ -89,7 +89,7 @@ const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterfa
89
89
  const httpRequestAll = (configs: HttpRequestConfig[]) => AuthClient.httpRequestAll(configs);
90
90
  const requestCustomGrant = (
91
91
  config: SPACustomGrantConfig,
92
- callback?: (response: BasicUserInfo | HttpResponse<any>) => void
92
+ callback?: (response: BasicUserInfo | FetchResponse<any>) => void
93
93
  ) => AuthClient.requestCustomGrant(config, callback, dispatch);
94
94
  const revokeAccessToken = () => AuthClient.revokeAccessToken(dispatch);
95
95
  const getOIDCServiceEndpoints = () => AuthClient.getOIDCServiceEndpoints();
package/src/models.ts CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  Config,
24
24
  CustomGrantConfig,
25
25
  DecodedIDTokenPayload,
26
+ FetchResponse,
26
27
  Hooks,
27
28
  HttpClientInstance,
28
29
  HttpRequestConfig,
@@ -95,7 +96,7 @@ export interface AuthContextInterface {
95
96
  httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
96
97
  requestCustomGrant(
97
98
  config: CustomGrantConfig,
98
- callback?: (response: BasicUserInfo | HttpResponse<any>) => void
99
+ callback?: (response: BasicUserInfo | FetchResponse<any>) => void
99
100
  ): void;
100
101
  revokeAccessToken(): Promise<boolean>;
101
102
  getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
@@ -111,15 +112,7 @@ export interface AuthContextInterface {
111
112
  trySignInSilently: () => Promise<boolean | BasicUserInfo>;
112
113
  on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): void;
113
114
  on(
114
- hook:
115
- | Hooks.RevokeAccessToken
116
- | Hooks.HttpRequestError
117
- | Hooks.HttpRequestFinish
118
- | Hooks.HttpRequestStart
119
- | Hooks.HttpRequestSuccess
120
- | Hooks.Initialize
121
- | Hooks.SignIn
122
- | Hooks.SignOut,
115
+ hook: Exclude<Hooks, Hooks.CustomGrant>,
123
116
  callback: (response?: any) => void
124
117
  ): void;
125
118
  on(hook: Hooks, callback: (response?: any) => void, id?: string): void;
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
 
19
- import React, { Suspense, FunctionComponent, PropsWithChildren, ReactElement, useEffect } from "react";
19
+ import React, { FunctionComponent, PropsWithChildren, ReactElement, Suspense, useEffect } from "react";
20
20
  import { useAuthContext } from "./authenticate";
21
21
  import { AuthenticatedComponent } from "./authenticated-component";
22
22