@trimble-oss/trimble-id-react 0.0.4-rc.2 → 0.1.0-rc.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/README.md +10 -0
- package/dist/TIDClient/TIDClient.d.ts +9 -1
- package/dist/TIDClient/interfaces.d.ts +13 -0
- package/dist/TIDProvider/TIDContext.d.ts +8 -1
- package/dist/TIDProvider/reducer.d.ts +3 -0
- package/dist/TIDProvider/useAuth.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/trimble-id-react.es.js +356 -320
- package/dist/trimble-id-react.umd.js +8 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -114,6 +114,7 @@ Type of persistence you want the user and token to be store
|
|
|
114
114
|
* **localStorage** - This persistent doesn't have expiration date
|
|
115
115
|
* **sessionStorage** - This one is cleared when the page session ends
|
|
116
116
|
|
|
117
|
+
> **_NOTE:_** localStorage and sessionStorage will be removed in future releases due to security concerns. Using localStorage and sessionStorage for storing sensitive information poses several security risks, including vulnerability to XSS attacks, lack of secure attributes, persistent storage, and session hijacking. Please plan to use in-memory option.
|
|
117
118
|
|
|
118
119
|
### useAuth
|
|
119
120
|
Use the `useAuth` hook in your components to access authentication state (`isLoading`, `isAuthenticated`, `user`, `error`) and authentication methods (`loginWithRedirect` and `logout`):
|
|
@@ -160,6 +161,15 @@ const {getAccessTokenSilently}= useAuth()
|
|
|
160
161
|
var access_token = await getAccessTokenSilently()
|
|
161
162
|
```
|
|
162
163
|
|
|
164
|
+
### getTokens
|
|
165
|
+
|
|
166
|
+
Gets the token details from cache.
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
const {getTokens}= useAuth()
|
|
170
|
+
var tokenResponse : TokenResponse = await getTokens()
|
|
171
|
+
```
|
|
172
|
+
|
|
163
173
|
### user
|
|
164
174
|
|
|
165
175
|
Information of the user in session
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BearerTokenHttpClientProvider } from '@trimble-oss/trimble-id';
|
|
2
2
|
import { PersistentStore } from './storage/cache-storage/CacheManager';
|
|
3
|
-
import { AuthState, TIDUser } from './interfaces';
|
|
3
|
+
import { AuthState, TIDUser, TokenResponse } from './interfaces';
|
|
4
4
|
interface TIDClientConfig {
|
|
5
5
|
/**
|
|
6
6
|
* The URL for the Trimble Identity OpenID well known configuration endpoint
|
|
@@ -165,6 +165,14 @@ export declare class TIDClient {
|
|
|
165
165
|
* @throws {TokenExpiredException} Will throw an exception if the user token expired
|
|
166
166
|
*/
|
|
167
167
|
getAccessTokenSilently(): Promise<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Retrieves token details from the cache, including the access token, ID token, and expiration time.
|
|
170
|
+
* If the token already expired, will try to refresh it using the refresh token.
|
|
171
|
+
* @return {Promise<TokenResponse>} Token response
|
|
172
|
+
* @throws {TokenNotFoundException} Will throw an exception if there are no tokens in cache
|
|
173
|
+
* @throws {TokenExpiredException} Will throw an exception if the user token expired
|
|
174
|
+
*/
|
|
175
|
+
getTokens(): Promise<TokenResponse>;
|
|
168
176
|
/**
|
|
169
177
|
* Redirect the user to TID using the browser
|
|
170
178
|
* @param {LogoutOptions} options - Custom configuration for teh redirection
|
|
@@ -25,7 +25,20 @@ export interface TIDAuthToken {
|
|
|
25
25
|
/** The custom state transferred in the last signin */
|
|
26
26
|
state: any;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Represents the token response like access_token, id_token, and expires_at.
|
|
30
|
+
*/
|
|
31
|
+
export interface TokenResponse {
|
|
32
|
+
/** The id_token returned from the OIDC provider */
|
|
33
|
+
id_token: string;
|
|
34
|
+
/** The access token returned from the OIDC provider. */
|
|
35
|
+
access_token: string;
|
|
36
|
+
/** The expires at returned from the OIDC provider */
|
|
37
|
+
expires_at: number;
|
|
38
|
+
}
|
|
28
39
|
export interface TIDUser {
|
|
40
|
+
/** User or application UUID */
|
|
41
|
+
id?: string;
|
|
29
42
|
/** End-User's full name */
|
|
30
43
|
name?: string;
|
|
31
44
|
/** Given name(s) or first name(s) of the End-User */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TIDAuthState } from './state';
|
|
2
|
-
import { AuthState } from '../TIDClient';
|
|
2
|
+
import { AuthState, TokenResponse } from '../TIDClient';
|
|
3
3
|
export interface LoginWithRedirectOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Function called when the user redirection is occurring
|
|
@@ -53,6 +53,13 @@ export interface TIDContextState extends TIDAuthState {
|
|
|
53
53
|
* @throws {TokenExpiredException} Will throw an if the user token expired
|
|
54
54
|
*/
|
|
55
55
|
getAccessTokenSilently: () => Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the token details from cache.
|
|
58
|
+
* @return {Promise<TokenResponse>} token response
|
|
59
|
+
* @throws {TokenNotFoundException} Will throw an exception there are no tokens in cache
|
|
60
|
+
* @throws {TokenExpiredException} Will throw an if the user token expired
|
|
61
|
+
*/
|
|
62
|
+
getTokens: () => Promise<TokenResponse>;
|
|
56
63
|
/**
|
|
57
64
|
* Redirect the user to TID using the browser
|
|
58
65
|
* @param {LoginWithRedirectOptions} options - Custom configuration for teh redirection
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { TIDClient } from './TIDClient';
|
|
2
2
|
export { TIDContext, useAuth, TIDProvider } from './TIDProvider';
|
|
3
3
|
export { AuthenticationGuard } from './AuthenticationGuard/AuthenticationGuard';
|
|
4
|
+
export type { TokenResponse } from './TIDClient';
|
|
4
5
|
export type { PersistentStore } from './TIDClient';
|