nexus-auth-sdk 4.1.1 → 4.2.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.
- package/index.d.ts +2 -0
- package/index.js +12 -0
- package/index.mjs +10 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -38,5 +38,7 @@ declare module '@authcore/sdk' {
|
|
|
38
38
|
register(params: RegisterParams): Promise<AuthResponse>;
|
|
39
39
|
login(params: LoginParams): Promise<AuthResponse>;
|
|
40
40
|
verify(token: string): Promise<VerifyResponse>;
|
|
41
|
+
sendCode(params: { email: string }): Promise<{ success: boolean; expires_in: number }>;
|
|
42
|
+
verifyCode(params: { email: string; code: string }): Promise<{ valid: boolean; error?: string }>;
|
|
41
43
|
}
|
|
42
44
|
}
|
package/index.js
CHANGED
|
@@ -45,6 +45,18 @@ class AuthCore {
|
|
|
45
45
|
if (!token) throw new Error('[AuthCore] token is required');
|
|
46
46
|
return this._fetch('/auth/authenticate', { token });
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
/** Send verification code to email. Returns { success, expires_in }. */
|
|
50
|
+
async sendCode({ email }) {
|
|
51
|
+
if (!email) throw new Error('[AuthCore] email is required');
|
|
52
|
+
return this._fetch('/auth/send-code', { email });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Verify a received code. Returns { valid }. */
|
|
56
|
+
async verifyCode({ email, code }) {
|
|
57
|
+
if (!email || !code) throw new Error('[AuthCore] email and code are required');
|
|
58
|
+
return this._fetch('/auth/verify-code', { email, code });
|
|
59
|
+
}
|
|
48
60
|
}
|
|
49
61
|
|
|
50
62
|
// CJS
|
package/index.mjs
CHANGED
|
@@ -41,6 +41,16 @@ class AuthCore {
|
|
|
41
41
|
if (!token) throw new Error('[AuthCore] token is required');
|
|
42
42
|
return this._fetch('/auth/authenticate', { token });
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
async sendCode({ email }) {
|
|
46
|
+
if (!email) throw new Error('[AuthCore] email is required');
|
|
47
|
+
return this._fetch('/auth/send-code', { email });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async verifyCode({ email, code }) {
|
|
51
|
+
if (!email || !code) throw new Error('[AuthCore] email and code are required');
|
|
52
|
+
return this._fetch('/auth/verify-code', { email, code });
|
|
53
|
+
}
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
export { AuthCore };
|