@acl-identity/react 0.1.0 → 0.1.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/.turbo/turbo-build.log +82 -82
- package/README.md +126 -0
- package/package.json +4 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
> @acl-identity/react@0.1.
|
|
3
|
-
> tsup
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
package.json:13:6:
|
|
8
|
-
|
|
9
|
-
╵
|
|
10
|
-
|
|
11
|
-
The "import" condition comes earlier and will be used for all "import" statements:
|
|
12
|
-
|
|
13
|
-
package.json:11:6:
|
|
14
|
-
|
|
15
|
-
╵
|
|
16
|
-
|
|
17
|
-
The "require" condition comes earlier and will be used for all "require" calls:
|
|
18
|
-
|
|
19
|
-
package.json:12:6:
|
|
20
|
-
|
|
21
|
-
╵
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
package.json:13:6:
|
|
35
|
-
[37m 13 │ [32m"types"[37m: "./dist/index.d.ts"
|
|
36
|
-
╵ [32m~~~~~~~[0m
|
|
37
|
-
|
|
38
|
-
The "import" condition comes earlier and will be used for all "import" statements:
|
|
39
|
-
|
|
40
|
-
package.json:11:6:
|
|
41
|
-
[37m 11 │ [32m"import"[37m: "./dist/index.js",
|
|
42
|
-
╵ [32m~~~~~~~~[0m
|
|
43
|
-
|
|
44
|
-
The "require" condition comes earlier and will be used for all "require" calls:
|
|
45
|
-
|
|
46
|
-
package.json:12:6:
|
|
47
|
-
[37m 12 │ [32m"require"[37m: "./dist/index.cjs",
|
|
48
|
-
╵ [32m~~~~~~~~~[0m
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
package.json:13:6:
|
|
56
|
-
[37m 13 │ [32m"types"[37m: "./dist/index.d.ts"
|
|
57
|
-
╵ [32m~~~~~~~[0m
|
|
58
|
-
|
|
59
|
-
The "import" condition comes earlier and will be used for all "import" statements:
|
|
60
|
-
|
|
61
|
-
package.json:11:6:
|
|
62
|
-
[37m 11 │ [32m"import"[37m: "./dist/index.js",
|
|
63
|
-
╵ [32m~~~~~~~~[0m
|
|
64
|
-
|
|
65
|
-
The "require" condition comes earlier and will be used for all "require" calls:
|
|
66
|
-
|
|
67
|
-
package.json:12:6:
|
|
68
|
-
[37m 12 │ [32m"require"[37m: "./dist/index.cjs",
|
|
69
|
-
╵ [32m~~~~~~~~~[0m
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
DTS Build start
|
|
80
|
-
DTS ⚡️ Build success in
|
|
81
|
-
DTS dist/index.d.mts 4.58 KB
|
|
82
|
-
DTS dist/index.d.ts 4.58 KB
|
|
1
|
+
|
|
2
|
+
> @acl-identity/react@0.1.1 build /Users/lanreyusuf/Developer/personal/acl-identity-sdk/packages/react
|
|
3
|
+
> tsup
|
|
4
|
+
|
|
5
|
+
▲ [WARNING] The condition "types" here will never be used as it comes after both "import" and "require" [package.json]
|
|
6
|
+
|
|
7
|
+
package.json:13:6:
|
|
8
|
+
13 │ "types": "./dist/index.d.ts"
|
|
9
|
+
╵ ~~~~~~~
|
|
10
|
+
|
|
11
|
+
The "import" condition comes earlier and will be used for all "import" statements:
|
|
12
|
+
|
|
13
|
+
package.json:11:6:
|
|
14
|
+
11 │ "import": "./dist/index.js",
|
|
15
|
+
╵ ~~~~~~~~
|
|
16
|
+
|
|
17
|
+
The "require" condition comes earlier and will be used for all "require" calls:
|
|
18
|
+
|
|
19
|
+
package.json:12:6:
|
|
20
|
+
12 │ "require": "./dist/index.cjs",
|
|
21
|
+
╵ ~~~~~~~~~
|
|
22
|
+
|
|
23
|
+
CLI Building entry: {"index":"src/index.ts"}
|
|
24
|
+
CLI Using tsconfig: tsconfig.json
|
|
25
|
+
CLI tsup v8.5.1
|
|
26
|
+
CLI Using tsup config: /Users/lanreyusuf/Developer/personal/acl-identity-sdk/packages/react/tsup.config.ts
|
|
27
|
+
CLI Target: es2020
|
|
28
|
+
CLI Cleaning output folder
|
|
29
|
+
ESM Build start
|
|
30
|
+
CJS Build start
|
|
31
|
+
|
|
32
|
+
WARN [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe condition "types" here will never be used as it comes after both "import" and "require"[0m [package.json]
|
|
33
|
+
|
|
34
|
+
package.json:13:6:
|
|
35
|
+
[37m 13 │ [32m"types"[37m: "./dist/index.d.ts"
|
|
36
|
+
╵ [32m~~~~~~~[0m
|
|
37
|
+
|
|
38
|
+
The "import" condition comes earlier and will be used for all "import" statements:
|
|
39
|
+
|
|
40
|
+
package.json:11:6:
|
|
41
|
+
[37m 11 │ [32m"import"[37m: "./dist/index.js",
|
|
42
|
+
╵ [32m~~~~~~~~[0m
|
|
43
|
+
|
|
44
|
+
The "require" condition comes earlier and will be used for all "require" calls:
|
|
45
|
+
|
|
46
|
+
package.json:12:6:
|
|
47
|
+
[37m 12 │ [32m"require"[37m: "./dist/index.cjs",
|
|
48
|
+
╵ [32m~~~~~~~~~[0m
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
WARN [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe condition "types" here will never be used as it comes after both "import" and "require"[0m [package.json]
|
|
54
|
+
|
|
55
|
+
package.json:13:6:
|
|
56
|
+
[37m 13 │ [32m"types"[37m: "./dist/index.d.ts"
|
|
57
|
+
╵ [32m~~~~~~~[0m
|
|
58
|
+
|
|
59
|
+
The "import" condition comes earlier and will be used for all "import" statements:
|
|
60
|
+
|
|
61
|
+
package.json:11:6:
|
|
62
|
+
[37m 11 │ [32m"import"[37m: "./dist/index.js",
|
|
63
|
+
╵ [32m~~~~~~~~[0m
|
|
64
|
+
|
|
65
|
+
The "require" condition comes earlier and will be used for all "require" calls:
|
|
66
|
+
|
|
67
|
+
package.json:12:6:
|
|
68
|
+
[37m 12 │ [32m"require"[37m: "./dist/index.cjs",
|
|
69
|
+
╵ [32m~~~~~~~~~[0m
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
ESM dist/index.mjs 7.33 KB
|
|
74
|
+
ESM dist/index.mjs.map 18.09 KB
|
|
75
|
+
ESM ⚡️ Build success in 59ms
|
|
76
|
+
CJS dist/index.js 8.65 KB
|
|
77
|
+
CJS dist/index.js.map 17.71 KB
|
|
78
|
+
CJS ⚡️ Build success in 59ms
|
|
79
|
+
DTS Build start
|
|
80
|
+
DTS ⚡️ Build success in 407ms
|
|
81
|
+
DTS dist/index.d.mts 4.58 KB
|
|
82
|
+
DTS dist/index.d.ts 4.58 KB
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @acl-identity/react
|
|
2
|
+
|
|
3
|
+
React integration for the ACL Identity SDK. Provides `AuthProvider`, the `useAuth` hook, and ready-made components for sign-in, sign-out, and OAuth2 callback handling.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @acl-identity/react
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @acl-identity/react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires React 18 or later as a peer dependency.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
### 1. Create the client and wrap your app
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { ACLBrowserClient, AuthProvider } from '@acl-identity/react';
|
|
21
|
+
|
|
22
|
+
const client = new ACLBrowserClient({
|
|
23
|
+
baseUrl: 'https://auth.example.com',
|
|
24
|
+
clientId: 'my-client-id',
|
|
25
|
+
redirectUri: 'https://app.example.com/callback',
|
|
26
|
+
orgSlug: 'my-org',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
function App() {
|
|
30
|
+
return (
|
|
31
|
+
<AuthProvider
|
|
32
|
+
client={client}
|
|
33
|
+
clientId="my-client-id"
|
|
34
|
+
redirectUri="https://app.example.com/callback"
|
|
35
|
+
orgSlug="my-org"
|
|
36
|
+
onRedirectCallback={(appState) => {
|
|
37
|
+
// navigate to appState?.returnTo after login
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<YourApp />
|
|
41
|
+
</AuthProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Use the `useAuth` hook
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { useAuth } from '@acl-identity/react';
|
|
50
|
+
|
|
51
|
+
function Header() {
|
|
52
|
+
const { user, isAuthenticated, isLoading, signIn, signOut } = useAuth();
|
|
53
|
+
|
|
54
|
+
if (isLoading) return <Spinner />;
|
|
55
|
+
|
|
56
|
+
if (!isAuthenticated) {
|
|
57
|
+
return <button onClick={() => signIn()}>Sign in</button>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div>
|
|
62
|
+
<span>Welcome, {user?.name}</span>
|
|
63
|
+
<button onClick={() => signOut()}>Sign out</button>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. Handle the OAuth2 callback
|
|
70
|
+
|
|
71
|
+
Add a callback page that renders `<CallbackHandler />`:
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { CallbackHandler } from '@acl-identity/react';
|
|
75
|
+
import { useNavigate } from 'react-router-dom';
|
|
76
|
+
|
|
77
|
+
export function CallbackPage() {
|
|
78
|
+
const navigate = useNavigate();
|
|
79
|
+
return (
|
|
80
|
+
<CallbackHandler
|
|
81
|
+
onSuccess={() => navigate('/')}
|
|
82
|
+
onError={(err) => console.error(err)}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Components
|
|
89
|
+
|
|
90
|
+
| Component | Description |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `AuthProvider` | Context provider — wraps your app |
|
|
93
|
+
| `CallbackHandler` | Processes the OAuth2 redirect callback |
|
|
94
|
+
| `SignInButton` | Pre-wired sign-in button |
|
|
95
|
+
| `SignOutButton` | Pre-wired sign-out button |
|
|
96
|
+
| `SilentCallbackPage` | Placed at `silentRedirectUri` for iframe-based silent renewal |
|
|
97
|
+
|
|
98
|
+
## Silent token renewal
|
|
99
|
+
|
|
100
|
+
Mount `<SilentCallbackPage />` at a dedicated route (e.g. `/silent-callback`) and pass its URL to `AuthProvider`:
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<AuthProvider
|
|
104
|
+
...
|
|
105
|
+
silentRedirectUri="https://app.example.com/silent-callback"
|
|
106
|
+
>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Tokens are renewed automatically before they expire without a visible redirect.
|
|
110
|
+
|
|
111
|
+
## `useAuth` return value
|
|
112
|
+
|
|
113
|
+
| Field | Type | Description |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| `user` | `UserClaims \| null` | Decoded JWT claims of the current user |
|
|
116
|
+
| `isAuthenticated` | `boolean` | Whether a valid token exists |
|
|
117
|
+
| `isLoading` | `boolean` | True while the initial session check is in progress |
|
|
118
|
+
| `error` | `Error \| null` | Last auth error |
|
|
119
|
+
| `signIn(options?)` | `Promise<void>` | Redirects to the authorization server |
|
|
120
|
+
| `signOut(options?)` | `Promise<void>` | Clears tokens and optionally revokes them |
|
|
121
|
+
| `getAccessToken()` | `Promise<string \| null>` | Returns the current access token |
|
|
122
|
+
| `handleCallback(url?)` | `Promise<{ appState? }>` | Manually processes a callback URL |
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acl-identity/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React hooks and provider for ACL Identity — Phase 2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"react-dom": ">=18.0.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@acl-identity/types": "0.1.
|
|
22
|
-
"@acl-identity/
|
|
23
|
-
"@acl-identity/
|
|
21
|
+
"@acl-identity/types": "0.1.1",
|
|
22
|
+
"@acl-identity/browser": "0.1.1",
|
|
23
|
+
"@acl-identity/core": "0.1.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/react": "^18.3.3",
|