@nylas/react 2.2.4 → 3.0.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/LICENSE.md +1 -0
- package/README.md +208 -4
- package/dist/cjs/components.js +501 -0
- package/dist/cjs/components.js.map +1 -0
- package/dist/cjs/connect.js +2 -1
- package/dist/cjs/connect.js.map +1 -0
- package/dist/cjs/elements.js +2 -1
- package/dist/cjs/elements.js.map +1 -0
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/p-DVWbg8if.js +292 -0
- package/dist/cjs/p-DVWbg8if.js.map +1 -0
- package/dist/cjs/utils.js +2 -1
- package/dist/cjs/utils.js.map +1 -0
- package/dist/connect.d.ts +1 -1
- package/dist/elements.d.ts +1 -1
- package/dist/es/components.js +40349 -0
- package/dist/es/components.js.map +1 -0
- package/dist/es/connect.js +241 -157
- package/dist/es/connect.js.map +1 -0
- package/dist/es/elements.js +134 -1317
- package/dist/es/elements.js.map +1 -0
- package/dist/es/index.js +137 -279
- package/dist/es/index.js.map +1 -0
- package/dist/es/p-DVWbg8if.js +18604 -0
- package/dist/es/p-DVWbg8if.js.map +1 -0
- package/dist/es/utils.js +6 -2
- package/dist/es/utils.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/src/connect/NylasConnectButton.d.ts +42 -0
- package/dist/src/connect/NylasConnectButton.d.ts.map +1 -0
- package/dist/src/connect/NylasConnectButton.test.d.ts +2 -0
- package/dist/src/connect/NylasConnectButton.test.d.ts.map +1 -0
- package/dist/src/connect/index.d.ts +9 -0
- package/dist/src/connect/index.d.ts.map +1 -0
- package/dist/{lib → src}/connect/types.d.ts +3 -2
- package/dist/src/connect/types.d.ts.map +1 -0
- package/dist/{lib → src}/connect/useNylasConnect.d.ts +11 -5
- package/dist/src/connect/useNylasConnect.d.ts.map +1 -0
- package/dist/src/connect/useNylasConnect.test.d.ts +2 -0
- package/dist/src/connect/useNylasConnect.test.d.ts.map +1 -0
- package/dist/src/connect.d.ts +2 -0
- package/dist/src/connect.d.ts.map +1 -0
- package/dist/{lib → src}/elements/components.d.ts +145 -143
- package/dist/src/elements/components.d.ts.map +1 -0
- package/dist/src/elements.d.ts +2 -0
- package/dist/src/elements.d.ts.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/main.d.ts +2 -0
- package/dist/src/main.d.ts.map +1 -0
- package/dist/src/utils.d.ts +3 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/vitest.setup.d.ts +2 -0
- package/dist/vitest.setup.d.ts.map +1 -0
- package/package.json +32 -24
- package/dist/cjs/notetaker.js +0 -62
- package/dist/es/notetaker.js +0 -5784
- package/dist/lib/connect/index.d.ts +0 -6
- package/dist/lib/connect/useNylasConnect.test.d.ts +0 -1
- package/dist/lib/connect.d.ts +0 -1
- package/dist/lib/elements.d.ts +0 -1
- package/dist/lib/index.d.ts +0 -3
- package/dist/lib/main.d.ts +0 -0
- package/dist/lib/notetaker/CalendarSync/CalendarSync.d.ts +0 -37
- package/dist/lib/notetaker/CalendarSync/CalendarSync.spec.d.ts +0 -0
- package/dist/lib/notetaker/SendNotetaker/SendNotetaker.d.ts +0 -32
- package/dist/lib/notetaker/SendNotetaker/SendNotetaker.spec.d.ts +0 -1
- package/dist/lib/notetaker/Transcript/Transcript.d.ts +0 -23
- package/dist/lib/notetaker/Transcript/Transcript.spec.d.ts +0 -0
- package/dist/lib/notetaker/VideoPlayer/VideoPlayer.d.ts +0 -24
- package/dist/lib/notetaker/VideoPlayer/VideoPlayer.spec.d.ts +0 -1
- package/dist/lib/notetaker/index.d.ts +0 -9
- package/dist/lib/notetaker/lib/constants.d.ts +0 -12
- package/dist/lib/notetaker/lib/http-client.d.ts +0 -2
- package/dist/lib/notetaker/lib/primitives.d.ts +0 -66
- package/dist/lib/notetaker/lib/store.d.ts +0 -6
- package/dist/lib/notetaker/types.d.ts +0 -42
- package/dist/lib/notetaker.d.ts +0 -1
- package/dist/lib/utils.d.ts +0 -2
- package/dist/notetaker.d.ts +0 -1
- package/dist/test/vitest.setup.d.ts +0 -0
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -9,8 +9,6 @@ React components for Nylas Scheduler
|
|
|
9
9
|
- [Node.js](https://nodejs.org/en/) v20 or higher
|
|
10
10
|
- [React.js](https://react.dev/) v18 or higher
|
|
11
11
|
|
|
12
|
-
## Compatibility Notice
|
|
13
|
-
|
|
14
12
|
## Installation
|
|
15
13
|
|
|
16
14
|
Install Nylas React Components via npm:
|
|
@@ -25,6 +23,16 @@ or yarn
|
|
|
25
23
|
yarn add @nylas/react@latest
|
|
26
24
|
```
|
|
27
25
|
|
|
26
|
+
## Exports overview
|
|
27
|
+
|
|
28
|
+
- **Elements**
|
|
29
|
+
- `NylasSchedulerEditor`, `NylasScheduling`, `NylasSchedulingMethod`
|
|
30
|
+
- Import from `@nylas/react` or `@nylas/react/elements`
|
|
31
|
+
|
|
32
|
+
- **Connect**
|
|
33
|
+
- `useNylasConnect`, `NylasConnectButton`
|
|
34
|
+
- Import from `@nylas/react` or `@nylas/react/connect`
|
|
35
|
+
|
|
28
36
|
## Getting Started
|
|
29
37
|
|
|
30
38
|
The following example adds the Nylas Scheduler Editor and Scheduling components to your React app.
|
|
@@ -64,7 +72,7 @@ function App() {
|
|
|
64
72
|
element={
|
|
65
73
|
<div>
|
|
66
74
|
<NylasSchedulerEditor
|
|
67
|
-
schedulerPreviewLink={`${window.location.origin}/?config_id
|
|
75
|
+
schedulerPreviewLink={`${window.location.origin}/?config_id=${config.id}`}
|
|
68
76
|
nylasSessionsConfig={{
|
|
69
77
|
clientId: "NYLAS_CLIENT_ID", // Replace with your Nylas client ID from the previous
|
|
70
78
|
redirectUri: `${window.location.origin}/scheduler-editor`,
|
|
@@ -105,9 +113,205 @@ npm run dev -- --port <PORT>
|
|
|
105
113
|
|
|
106
114
|
After you run the command, open your browser to `http://localhost:<PORT>/scheduler-editor` to see your Scheduler Editor and create your first Scheduling Page.
|
|
107
115
|
|
|
116
|
+
|
|
117
|
+
## Nylas Connect Hook
|
|
118
|
+
|
|
119
|
+
The `useNylasConnect` hook provides a simple way to add OAuth authentication to your React app using Nylas Connect.
|
|
120
|
+
|
|
121
|
+
### Basic Usage
|
|
122
|
+
|
|
123
|
+
```jsx
|
|
124
|
+
import { useNylasConnect } from '@nylas/react';
|
|
125
|
+
|
|
126
|
+
function LoginButton() {
|
|
127
|
+
const { isConnected, connect, logout, grant, isLoading } = useNylasConnect({
|
|
128
|
+
clientId: 'your-nylas-client-id',
|
|
129
|
+
redirectUri: 'http://localhost:3000/callback'
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (isLoading) return <div>Loading...</div>;
|
|
133
|
+
|
|
134
|
+
if (isConnected) {
|
|
135
|
+
return (
|
|
136
|
+
<div>
|
|
137
|
+
<p>Connected as: {grant?.email}</p>
|
|
138
|
+
<button onClick={() => logout()}>Logout</button>
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<button onClick={() => connect({ method: 'popup' })}>
|
|
145
|
+
Connect Account
|
|
146
|
+
</button>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
### Configuration
|
|
153
|
+
|
|
154
|
+
| Option | Type | Default | Description |
|
|
155
|
+
|--------|------|---------|-------------|
|
|
156
|
+
| `clientId` | `string` | - | Your Nylas Client ID |
|
|
157
|
+
| `redirectUri` | `string` | - | OAuth callback URL |
|
|
158
|
+
| `autoHandleCallback` | `boolean` | `true` | Automatically handle OAuth callback |
|
|
159
|
+
| `autoRefreshInterval` | `number` | - | Auto-refresh session interval (ms) |
|
|
160
|
+
| `retryAttempts` | `number` | `0` | Number of retry attempts for failed operations |
|
|
161
|
+
| `enableAutoRecovery` | `boolean` | `false` | Enable automatic error recovery |
|
|
162
|
+
|
|
163
|
+
### Hook Return Values
|
|
164
|
+
|
|
165
|
+
The hook returns an object with the following properties:
|
|
166
|
+
|
|
167
|
+
**State:**
|
|
168
|
+
- `isConnected` - Whether user is authenticated
|
|
169
|
+
- `grant` - Current user's grant information
|
|
170
|
+
- `isLoading` - Loading state for operations
|
|
171
|
+
- `error` - Current error, if any
|
|
172
|
+
|
|
173
|
+
**Actions:**
|
|
174
|
+
- `connect(options)` - Start OAuth flow
|
|
175
|
+
- `logout(grantId?)` - Sign out user
|
|
176
|
+
- `refreshSession()` - Refresh current session
|
|
177
|
+
- `subscribe(callback)` - Listen to connection events
|
|
178
|
+
|
|
179
|
+
### Environment Setup
|
|
180
|
+
|
|
181
|
+
For security, use environment variables for your configuration:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# .env.local
|
|
185
|
+
VITE_NYLAS_CLIENT_ID=your-nylas-client-id
|
|
186
|
+
VITE_NYLAS_REDIRECT_URI=http://localhost:3000/callback
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
```jsx
|
|
190
|
+
const { isConnected, connect } = useNylasConnect({
|
|
191
|
+
clientId: import.meta.env.VITE_NYLAS_CLIENT_ID,
|
|
192
|
+
redirectUri: import.meta.env.VITE_NYLAS_REDIRECT_URI
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
## Nylas Connect Button
|
|
201
|
+
|
|
202
|
+
The `NylasConnectButton` component provides a simple way to add email provider authentication to your React application.
|
|
203
|
+
|
|
204
|
+
### Basic Usage
|
|
205
|
+
|
|
206
|
+
```jsx
|
|
207
|
+
import { NylasConnectButton } from "@nylas/react";
|
|
208
|
+
|
|
209
|
+
function App() {
|
|
210
|
+
return (
|
|
211
|
+
<NylasConnectButton
|
|
212
|
+
clientId="your-nylas-client-id"
|
|
213
|
+
redirectUri="http://localhost:3000/callback"
|
|
214
|
+
onSuccess={(result) => {
|
|
215
|
+
console.log("Connected successfully:", result);
|
|
216
|
+
}}
|
|
217
|
+
onError={(error) => {
|
|
218
|
+
console.error("Connection failed:", error);
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### External Identity Provider Integration
|
|
226
|
+
|
|
227
|
+
For applications that use external identity providers (via JWKS), you can pass identity provider tokens during authentication:
|
|
228
|
+
|
|
229
|
+
```jsx
|
|
230
|
+
import { NylasConnectButton } from "@nylas/react";
|
|
231
|
+
|
|
232
|
+
function App() {
|
|
233
|
+
// Function to retrieve JWT token from your external identity provider
|
|
234
|
+
const getIdpToken = async () => {
|
|
235
|
+
// Get the JWT token from your authentication system
|
|
236
|
+
const token = await yourAuthSystem.getJWT();
|
|
237
|
+
return token; // or return null if not available
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<NylasConnectButton
|
|
242
|
+
clientId="your-nylas-client-id"
|
|
243
|
+
redirectUri="http://localhost:3000/callback"
|
|
244
|
+
identityProviderToken={getIdpToken}
|
|
245
|
+
onSuccess={(result) => {
|
|
246
|
+
console.log("Connected with IDP claims:", result);
|
|
247
|
+
}}
|
|
248
|
+
onError={(error) => {
|
|
249
|
+
console.error("Connection failed:", error);
|
|
250
|
+
}}
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Custom Backend Code Exchange
|
|
257
|
+
|
|
258
|
+
For enhanced security, you can handle the OAuth code exchange on your backend:
|
|
259
|
+
|
|
260
|
+
```jsx
|
|
261
|
+
import { NylasConnectButton } from "@nylas/react";
|
|
262
|
+
|
|
263
|
+
function App() {
|
|
264
|
+
const handleCodeExchange = async (params) => {
|
|
265
|
+
// Send the authorization code to your backend
|
|
266
|
+
const response = await fetch("/api/auth/exchange", {
|
|
267
|
+
method: "POST",
|
|
268
|
+
headers: { "Content-Type": "application/json" },
|
|
269
|
+
body: JSON.stringify({
|
|
270
|
+
code: params.code,
|
|
271
|
+
state: params.state,
|
|
272
|
+
clientId: params.clientId,
|
|
273
|
+
redirectUri: params.redirectUri,
|
|
274
|
+
scopes: params.scopes,
|
|
275
|
+
provider: params.provider,
|
|
276
|
+
}),
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
if (!response.ok) {
|
|
280
|
+
throw new Error(`Token exchange failed: ${response.statusText}`);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const tokenData = await response.json();
|
|
284
|
+
|
|
285
|
+
// Return the expected ConnectResult format
|
|
286
|
+
return {
|
|
287
|
+
accessToken: tokenData.access_token,
|
|
288
|
+
idToken: tokenData.id_token,
|
|
289
|
+
grantId: tokenData.grant_id,
|
|
290
|
+
expiresAt: Date.now() + tokenData.expires_in * 1000,
|
|
291
|
+
scope: tokenData.scope,
|
|
292
|
+
grantInfo: tokenData.grant_info,
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<NylasConnectButton
|
|
298
|
+
clientId="your-nylas-client-id"
|
|
299
|
+
redirectUri="http://localhost:3000/callback"
|
|
300
|
+
codeExchange={handleCodeExchange}
|
|
301
|
+
onSuccess={(result) => {
|
|
302
|
+
console.log("Connected successfully:", result);
|
|
303
|
+
}}
|
|
304
|
+
onError={(error) => {
|
|
305
|
+
console.error("Connection failed:", error);
|
|
306
|
+
}}
|
|
307
|
+
/>
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
108
312
|
## Links
|
|
109
313
|
|
|
110
|
-
|
|
314
|
+
A complete walkthrough for setting up Scheduler can be found at [https://developer.nylas.com/docs/v3/getting-started/scheduler/](https://developer.nylas.com/docs/v3/getting-started/scheduler/), with the complete code available on [GitHub](https://github.com/nylas-samples/quickstart-scheduler-react).
|
|
111
315
|
|
|
112
316
|
### Further reading:
|
|
113
317
|
|