diff --git a/documentation/docs/api/Types/GetAccessTokenSilently.mdx b/documentation/docs/api/Types/GetAccessTokenSilently.mdx
new file mode 100644
index 00000000..b66f1e6b
--- /dev/null
+++ b/documentation/docs/api/Types/GetAccessTokenSilently.mdx
@@ -0,0 +1,17 @@
+---
+id: 'GetAccessTokenSilently'
+title: 'GetAccessTokenSilently'
+sidebar_label: 'GetAccessTokenSilently'
+sidebar_position: 1
+---
+import Type from '../_type-definitions/GetAccessTokenSilently.md';
+
+
+```ts
+import { type GetAccessTokenSilently } from '@orfium/toolbox';
+```
+
+### Definition
+
+
(opts?: GetTokenSilentlyOptions) => Promise\<\ No newline at end of file diff --git a/documentation/docs/api/_type-definitions/Permissions.md b/documentation/docs/api/_type-definitions/Permissions.md new file mode 100644 index 00000000..df2c2579 --- /dev/null +++ b/documentation/docs/api/_type-definitions/Permissions.md @@ -0,0 +1 @@ +`string[]` \ No newline at end of file diff --git a/documentation/docs/api/_type-definitions/UseAuthenticationReturnValue.md b/documentation/docs/api/_type-definitions/UseAuthenticationReturnValue.md index e262dd37..0cbab516 100644 --- a/documentation/docs/api/_type-definitions/UseAuthenticationReturnValue.md +++ b/documentation/docs/api/_type-definitions/UseAuthenticationReturnValue.md @@ -1,8 +1,9 @@ -| Name | Type | -| :----------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `isAuthenticated` | `boolean` | -| `isLoading` | `boolean` | -| `user` |
void |
\{
decodedToken: [DecodedTokenResponse](/docs/api/Types/DecodedTokenResponse) | Record\;
token: string;
\}
\>
[User](/docs/api/Types/User) | undefined
|
-| `getAccessTokenSilently` | (opts?: GetTokenSilentlyOptions) => Promise\<| -| `loginWithRedirect` |
void |
\{
decodedToken: [DecodedTokenResponse](/docs/api/Types/DecodedTokenResponse) | Record\;
token: string;
\}
\>
(o?: RedirectLoginOptions\) => Promise\
|
-| `logout` | `() => void` |
+| Name | Type |
+| :----------------------- |:------------------------------------------------------------------|
+| `isAuthenticated` | `boolean` |
+| `isLoading` | `boolean` |
+| `permissions` | [`Permissions`](/docs/api/Types/Permissions) |
+| `user` | [User](/docs/api/Types/User) | undefined
|
+| `getAccessTokenSilently` | [`GetAccessTokenSilently`](/docs/api/Types/GetAccessTokenSilently) |
+| `loginWithRedirect` | (o?: RedirectLoginOptions\) => Promise\
|
+| `logout` | `() => void` |
diff --git a/documentation/docs/api/_type-definitions/UseOrfiumProductsReturnValue.md b/documentation/docs/api/_type-definitions/UseOrfiumProductsReturnValue.md
index 3201ba3c..c2d3a958 100644
--- a/documentation/docs/api/_type-definitions/UseOrfiumProductsReturnValue.md
+++ b/documentation/docs/api/_type-definitions/UseOrfiumProductsReturnValue.md
@@ -1 +1 @@
-[`Product`](../Types/Product)`[] | null`
+[Product](/docs/api/Types/Product)[] | null
diff --git a/documentation/docs/api/_type-definitions/UseOrganizationsReturnValue.md b/documentation/docs/api/_type-definitions/UseOrganizationsReturnValue.md
index ce0ba440..c2be32da 100644
--- a/documentation/docs/api/_type-definitions/UseOrganizationsReturnValue.md
+++ b/documentation/docs/api/_type-definitions/UseOrganizationsReturnValue.md
@@ -1,5 +1,5 @@
-| Name | Type |
-| :--------------------- | :--------------------------------------------------------------- |
-| `organizations` | [Organization](../Types/Organization)[]
|
-| `selectedOrganization` | [Organization](../Types/Organization)[] | null
|
-| `switchOrganization` | `(organisation: string) => void` |
+| Name | Type |
+| :--------------------- | :------------------------------------------------------------- |
+| `organizations` | [Organization](../Types/Organization)[]
|
+| `selectedOrganization` | [Organization](../Types/Organization) | null
|
+| `switchOrganization` | `(organisation: string) => void` |
diff --git a/src/contexts/authentication.ts b/src/contexts/authentication.ts
index 30bb48d6..f42d281d 100644
--- a/src/contexts/authentication.ts
+++ b/src/contexts/authentication.ts
@@ -1,6 +1,8 @@
import { type GetTokenSilentlyOptions, type RedirectLoginOptions } from '@auth0/auth0-spa-js';
import { createContext } from 'react';
+export type Permissions = string[];
+
export type DecodedTokenResponse = {
iss?: string;
sub?: string;
@@ -12,7 +14,7 @@ export type DecodedTokenResponse = {
/** the organization id of the user currently selected **/
org_id?: string;
/** the permissions defined on the user for more info visit https://orfium.atlassian.net/wiki/spaces/OPS/pages/2554134739/Roles+and+Permissions#Organization-Roles **/
- permissions?: string[];
+ permissions?: Permissions;
};
export type User = {
@@ -39,16 +41,19 @@ export type User = {
[key: string]: any;
};
+export type GetAccessTokenSilently = (opts?: GetTokenSilentlyOptions) => Promise<{
+ token: string;
+ decodedToken: DecodedTokenResponse | Record