mulguard 1.0.1 → 1.1.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 +70 -0
- package/README.md +799 -123
- package/dist/client/index.js +1 -1
- package/dist/client/index.mjs +34 -32
- package/dist/client/provider.d.ts +50 -6
- package/dist/core/auth/signin-unified.d.ts +1 -1
- package/dist/index/index.js +1 -1
- package/dist/index/index.mjs +824 -728
- package/dist/mulguard.d.ts +32 -5
- package/package.json +1 -1
- package/dist/signin-unified-BS2gxaG1.mjs +0 -30
- package/dist/signin-unified-Cw41EFkc.js +0 -1
package/dist/mulguard.d.ts
CHANGED
|
@@ -83,16 +83,43 @@ export interface MulguardInstance {
|
|
|
83
83
|
*/
|
|
84
84
|
_getTokenRefreshManager?(): import('./core/client/token-refresh-manager').TokenRefreshManager | undefined;
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
86
|
+
* Unified sign in method - supports both unified and direct method calls
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Unified interface (auth.js-like)
|
|
91
|
+
* await auth.signIn('google')
|
|
92
|
+
* await auth.signIn('credentials', { email: 'user@example.com', password: 'password' })
|
|
93
|
+
* await auth.signIn('otp', { email: 'user@example.com', code: '123456' })
|
|
94
|
+
*
|
|
95
|
+
* // Direct methods (for backward compatibility)
|
|
96
|
+
* await auth.signIn.email({ email: 'user@example.com', password: 'password' })
|
|
97
|
+
* await auth.signIn.oauth('google')
|
|
98
|
+
* ```
|
|
87
99
|
*/
|
|
88
100
|
signIn: {
|
|
89
101
|
/**
|
|
90
|
-
*
|
|
102
|
+
* Unified sign in function - supports provider-based and direct method calls
|
|
103
|
+
*/
|
|
104
|
+
(provider: 'google' | 'github' | 'apple' | 'facebook' | string): Promise<{
|
|
105
|
+
url: string;
|
|
106
|
+
state: string;
|
|
107
|
+
}>;
|
|
108
|
+
(provider: 'credentials', credentials: EmailCredentials): Promise<AuthResult>;
|
|
109
|
+
(provider: 'otp', options: {
|
|
110
|
+
email: string;
|
|
111
|
+
code?: string;
|
|
112
|
+
}): Promise<AuthResult>;
|
|
113
|
+
(provider: 'passkey', options?: {
|
|
114
|
+
userId?: string;
|
|
115
|
+
}): Promise<AuthResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Sign in with email and password (direct method)
|
|
91
118
|
* Executes custom email action from config
|
|
92
119
|
*/
|
|
93
120
|
email(credentials: EmailCredentials): Promise<AuthResult>;
|
|
94
121
|
/**
|
|
95
|
-
* Initiate OAuth sign in flow
|
|
122
|
+
* Initiate OAuth sign in flow (direct method)
|
|
96
123
|
* Executes custom oauth action from config
|
|
97
124
|
*/
|
|
98
125
|
oauth?(provider: string): Promise<{
|
|
@@ -100,14 +127,14 @@ export interface MulguardInstance {
|
|
|
100
127
|
state: string;
|
|
101
128
|
}>;
|
|
102
129
|
/**
|
|
103
|
-
* Sign in with PassKey/WebAuthn
|
|
130
|
+
* Sign in with PassKey/WebAuthn (direct method)
|
|
104
131
|
* Executes custom passkey action from config
|
|
105
132
|
*/
|
|
106
133
|
passkey?(options?: {
|
|
107
134
|
userId?: string;
|
|
108
135
|
}): Promise<AuthResult>;
|
|
109
136
|
/**
|
|
110
|
-
* Sign in with OTP
|
|
137
|
+
* Sign in with OTP (direct method)
|
|
111
138
|
* Executes custom otp action from config
|
|
112
139
|
*/
|
|
113
140
|
otp?(email: string, code?: string): Promise<AuthResult>;
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
async function e(o, n, i) {
|
|
2
|
-
if (n === "google" || n === "github" || n === "apple" || n === "facebook" || typeof n == "string" && !["credentials", "otp", "passkey"].includes(n)) {
|
|
3
|
-
if (!o.signIn.oauth)
|
|
4
|
-
throw new Error("OAuth sign in is not configured. Provide oauth action in signIn.");
|
|
5
|
-
return o.signIn.oauth(n);
|
|
6
|
-
}
|
|
7
|
-
if (n === "credentials") {
|
|
8
|
-
if (!i || !("email" in i) || !("password" in i))
|
|
9
|
-
throw new Error("Credentials are required for credentials provider");
|
|
10
|
-
return o.signIn.email(i);
|
|
11
|
-
}
|
|
12
|
-
if (n === "otp") {
|
|
13
|
-
if (!i || !("email" in i))
|
|
14
|
-
throw new Error("Email is required for OTP provider");
|
|
15
|
-
const s = i;
|
|
16
|
-
if (!o.signIn.otp)
|
|
17
|
-
throw new Error("OTP sign in is not configured. Provide otp action in signIn.");
|
|
18
|
-
return o.signIn.otp(s.email, s.code);
|
|
19
|
-
}
|
|
20
|
-
if (n === "passkey") {
|
|
21
|
-
const s = i;
|
|
22
|
-
if (!o.signIn.passkey)
|
|
23
|
-
throw new Error("PassKey sign in is not configured. Provide passkey action in signIn.");
|
|
24
|
-
return o.signIn.passkey(s);
|
|
25
|
-
}
|
|
26
|
-
throw new Error(`Unknown provider: ${n}`);
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
e as s
|
|
30
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";async function e(o,n,i){if(n==="google"||n==="github"||n==="apple"||n==="facebook"||typeof n=="string"&&!["credentials","otp","passkey"].includes(n)){if(!o.signIn.oauth)throw new Error("OAuth sign in is not configured. Provide oauth action in signIn.");return o.signIn.oauth(n)}if(n==="credentials"){if(!i||!("email"in i)||!("password"in i))throw new Error("Credentials are required for credentials provider");return o.signIn.email(i)}if(n==="otp"){if(!i||!("email"in i))throw new Error("Email is required for OTP provider");const s=i;if(!o.signIn.otp)throw new Error("OTP sign in is not configured. Provide otp action in signIn.");return o.signIn.otp(s.email,s.code)}if(n==="passkey"){const s=i;if(!o.signIn.passkey)throw new Error("PassKey sign in is not configured. Provide passkey action in signIn.");return o.signIn.passkey(s)}throw new Error(`Unknown provider: ${n}`)}exports.signIn=e;
|