@insforge/sdk 1.2.1-dev.1 → 1.2.1-dev.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 +45 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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/verify-email' // optional, for link-based verification
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
// Sign in with email/password
|
|
@@ -78,6 +79,47 @@ 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/verify-email' // optional, 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, 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
|
+
|
|
81
123
|
### Database Operations
|
|
82
124
|
|
|
83
125
|
```javascript
|
|
@@ -201,14 +243,14 @@ const insforge = createClient({
|
|
|
201
243
|
The SDK is written in TypeScript and provides full type definitions:
|
|
202
244
|
|
|
203
245
|
```typescript
|
|
204
|
-
import { createClient, InsForgeClient
|
|
246
|
+
import { createClient, InsForgeClient } from '@insforge/sdk';
|
|
205
247
|
|
|
206
248
|
const insforge: InsForgeClient = createClient({
|
|
207
249
|
baseUrl: 'http://localhost:7130'
|
|
208
250
|
});
|
|
209
251
|
|
|
210
252
|
// Type-safe API calls
|
|
211
|
-
const response
|
|
253
|
+
const response =
|
|
212
254
|
await insforge.auth.getCurrentUser();
|
|
213
255
|
```
|
|
214
256
|
|
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
|
|
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
|
|
1148
|
+
"An unexpected error occurred while sending password reset email"
|
|
1149
1149
|
);
|
|
1150
1150
|
}
|
|
1151
1151
|
}
|