@insforge/sdk 1.2.1-dev.1 → 1.2.2

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 CHANGED
@@ -46,7 +46,8 @@ const insforge = createClient({
46
46
  const { data, error } = await insforge.auth.signUp({
47
47
  email: 'user@example.com',
48
48
  password: 'securePassword123',
49
- name: 'John Doe' // optional
49
+ name: 'John Doe', // optional
50
+ redirectTo: 'http://localhost:3000/sign-in' // optional, recommended for link-based verification
50
51
  });
51
52
 
52
53
  // Sign in with email/password
@@ -61,8 +62,8 @@ await insforge.auth.signInWithOAuth({
61
62
  redirectTo: 'http://localhost:3000/dashboard'
62
63
  });
63
64
 
64
- // Get current user
65
- const { data: user } = await insforge.auth.getCurrentUser();
65
+ // Get current user (call this during browser app startup)
66
+ const { data: currentUser } = await insforge.auth.getCurrentUser();
66
67
 
67
68
  // Get any user's profile by ID (public endpoint)
68
69
  const { data: profile, error } = await insforge.auth.getProfile('user-id-here');
@@ -78,6 +79,51 @@ const { data: updatedProfile, error } = await insforge.auth.setProfile({
78
79
  await insforge.auth.signOut();
79
80
  ```
80
81
 
82
+ ### Email Verification And Password Reset
83
+
84
+ ```javascript
85
+ // Resend a verification email
86
+ await insforge.auth.resendVerificationEmail({
87
+ email: 'user@example.com',
88
+ redirectTo: 'http://localhost:3000/sign-in' // optional, recommended for link-based verification
89
+ });
90
+
91
+ // Verify email with a 6-digit code
92
+ await insforge.auth.verifyEmail({
93
+ email: 'user@example.com',
94
+ otp: '123456'
95
+ });
96
+
97
+ // Send password reset email
98
+ await insforge.auth.sendResetPasswordEmail({
99
+ email: 'user@example.com',
100
+ redirectTo: 'http://localhost:3000/reset-password' // optional, recommended for link-based reset
101
+ });
102
+
103
+ // Code-based reset flow: exchange the code, then reset the password
104
+ const { data: resetToken } = await insforge.auth.exchangeResetPasswordToken({
105
+ email: 'user@example.com',
106
+ code: '123456'
107
+ });
108
+
109
+ if (resetToken) {
110
+ await insforge.auth.resetPassword({
111
+ newPassword: 'newSecurePassword123',
112
+ otp: resetToken.token
113
+ });
114
+ }
115
+ ```
116
+
117
+ For link-based verification and password reset, users click the emailed browser links:
118
+ - `GET /api/auth/email/verify-link`
119
+ - `GET /api/auth/email/reset-password-link`
120
+
121
+ Those backend endpoints validate the token first, then redirect the browser to your `redirectTo` URL.
122
+
123
+ - Verification links redirect with `insforge_status=success|error`, `insforge_type=verify_email`, and optional `insforge_error`
124
+ - Recommended: use your sign-in page as the verification `redirectTo`, then show a confirmation message and ask the user to sign in with email and password
125
+ - Reset links redirect with `token` when ready, plus `insforge_status=ready|error`, `insforge_type=reset_password`, and optional `insforge_error`
126
+
81
127
  ### Database Operations
82
128
 
83
129
  ```javascript
@@ -201,14 +247,14 @@ const insforge = createClient({
201
247
  The SDK is written in TypeScript and provides full type definitions:
202
248
 
203
249
  ```typescript
204
- import { createClient, InsForgeClient, User, Session } from '@insforge/sdk';
250
+ import { createClient, InsForgeClient } from '@insforge/sdk';
205
251
 
206
252
  const insforge: InsForgeClient = createClient({
207
253
  baseUrl: 'http://localhost:7130'
208
254
  });
209
255
 
210
256
  // Type-safe API calls
211
- const response: { data: User | null; error: Error | null } =
257
+ const response =
212
258
  await insforge.auth.getCurrentUser();
213
259
  ```
214
260
 
package/dist/index.js CHANGED
@@ -1112,7 +1112,7 @@ var Auth = class {
1112
1112
  } catch (error) {
1113
1113
  return wrapError(
1114
1114
  error,
1115
- "An unexpected error occurred while sending verification code"
1115
+ "An unexpected error occurred while sending verification email"
1116
1116
  );
1117
1117
  }
1118
1118
  }
@@ -1145,7 +1145,7 @@ var Auth = class {
1145
1145
  } catch (error) {
1146
1146
  return wrapError(
1147
1147
  error,
1148
- "An unexpected error occurred while sending password reset code"
1148
+ "An unexpected error occurred while sending password reset email"
1149
1149
  );
1150
1150
  }
1151
1151
  }