@nylas/react 2.2.4 → 3.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.
Files changed (84) hide show
  1. package/LICENSE.md +1 -0
  2. package/README.md +208 -4
  3. package/dist/cjs/components.js +501 -0
  4. package/dist/cjs/components.js.map +1 -0
  5. package/dist/cjs/connect.js +2 -1
  6. package/dist/cjs/connect.js.map +1 -0
  7. package/dist/cjs/elements.js +2 -1
  8. package/dist/cjs/elements.js.map +1 -0
  9. package/dist/cjs/index.js +2 -1
  10. package/dist/cjs/index.js.map +1 -0
  11. package/dist/cjs/p-DVWbg8if.js +292 -0
  12. package/dist/cjs/p-DVWbg8if.js.map +1 -0
  13. package/dist/cjs/utils.js +2 -1
  14. package/dist/cjs/utils.js.map +1 -0
  15. package/dist/connect.d.ts +1 -1
  16. package/dist/elements.d.ts +1 -1
  17. package/dist/es/components.js +40349 -0
  18. package/dist/es/components.js.map +1 -0
  19. package/dist/es/connect.js +241 -157
  20. package/dist/es/connect.js.map +1 -0
  21. package/dist/es/elements.js +134 -1317
  22. package/dist/es/elements.js.map +1 -0
  23. package/dist/es/index.js +137 -279
  24. package/dist/es/index.js.map +1 -0
  25. package/dist/es/p-DVWbg8if.js +18604 -0
  26. package/dist/es/p-DVWbg8if.js.map +1 -0
  27. package/dist/es/utils.js +6 -2
  28. package/dist/es/utils.js.map +1 -0
  29. package/dist/index.d.ts +1 -1
  30. package/dist/src/connect/NylasConnectButton.d.ts +42 -0
  31. package/dist/src/connect/NylasConnectButton.d.ts.map +1 -0
  32. package/dist/src/connect/NylasConnectButton.test.d.ts +2 -0
  33. package/dist/src/connect/NylasConnectButton.test.d.ts.map +1 -0
  34. package/dist/src/connect/index.d.ts +9 -0
  35. package/dist/src/connect/index.d.ts.map +1 -0
  36. package/dist/{lib → src}/connect/types.d.ts +3 -2
  37. package/dist/src/connect/types.d.ts.map +1 -0
  38. package/dist/{lib → src}/connect/useNylasConnect.d.ts +11 -5
  39. package/dist/src/connect/useNylasConnect.d.ts.map +1 -0
  40. package/dist/src/connect/useNylasConnect.test.d.ts +2 -0
  41. package/dist/src/connect/useNylasConnect.test.d.ts.map +1 -0
  42. package/dist/src/connect.d.ts +2 -0
  43. package/dist/src/connect.d.ts.map +1 -0
  44. package/dist/{lib → src}/elements/components.d.ts +145 -143
  45. package/dist/src/elements/components.d.ts.map +1 -0
  46. package/dist/src/elements.d.ts +2 -0
  47. package/dist/src/elements.d.ts.map +1 -0
  48. package/dist/src/index.d.ts +3 -0
  49. package/dist/src/index.d.ts.map +1 -0
  50. package/dist/src/main.d.ts +2 -0
  51. package/dist/src/main.d.ts.map +1 -0
  52. package/dist/src/utils.d.ts +3 -0
  53. package/dist/src/utils.d.ts.map +1 -0
  54. package/dist/style.css +1 -1
  55. package/dist/utils.d.ts +1 -1
  56. package/dist/vitest.setup.d.ts +2 -0
  57. package/dist/vitest.setup.d.ts.map +1 -0
  58. package/package.json +32 -24
  59. package/dist/cjs/notetaker.js +0 -62
  60. package/dist/es/notetaker.js +0 -5784
  61. package/dist/lib/connect/index.d.ts +0 -6
  62. package/dist/lib/connect/useNylasConnect.test.d.ts +0 -1
  63. package/dist/lib/connect.d.ts +0 -1
  64. package/dist/lib/elements.d.ts +0 -1
  65. package/dist/lib/index.d.ts +0 -3
  66. package/dist/lib/main.d.ts +0 -0
  67. package/dist/lib/notetaker/CalendarSync/CalendarSync.d.ts +0 -37
  68. package/dist/lib/notetaker/CalendarSync/CalendarSync.spec.d.ts +0 -0
  69. package/dist/lib/notetaker/SendNotetaker/SendNotetaker.d.ts +0 -32
  70. package/dist/lib/notetaker/SendNotetaker/SendNotetaker.spec.d.ts +0 -1
  71. package/dist/lib/notetaker/Transcript/Transcript.d.ts +0 -23
  72. package/dist/lib/notetaker/Transcript/Transcript.spec.d.ts +0 -0
  73. package/dist/lib/notetaker/VideoPlayer/VideoPlayer.d.ts +0 -24
  74. package/dist/lib/notetaker/VideoPlayer/VideoPlayer.spec.d.ts +0 -1
  75. package/dist/lib/notetaker/index.d.ts +0 -9
  76. package/dist/lib/notetaker/lib/constants.d.ts +0 -12
  77. package/dist/lib/notetaker/lib/http-client.d.ts +0 -2
  78. package/dist/lib/notetaker/lib/primitives.d.ts +0 -66
  79. package/dist/lib/notetaker/lib/store.d.ts +0 -6
  80. package/dist/lib/notetaker/types.d.ts +0 -42
  81. package/dist/lib/notetaker.d.ts +0 -1
  82. package/dist/lib/utils.d.ts +0 -2
  83. package/dist/notetaker.d.ts +0 -1
  84. package/dist/test/vitest.setup.d.ts +0 -0
package/LICENSE.md CHANGED
@@ -20,3 +20,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
20
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  THE SOFTWARE.
23
+
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={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
- For a complete walkthrough on 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).
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