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.
@@ -83,16 +83,43 @@ export interface MulguardInstance {
83
83
  */
84
84
  _getTokenRefreshManager?(): import('./core/client/token-refresh-manager').TokenRefreshManager | undefined;
85
85
  /**
86
- * Sign in methods - uses custom actions from config
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
- * Sign in with email and password
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,6 +1,6 @@
1
1
  {
2
2
  "name": "mulguard",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Mulguard is a modern authentication backend-first library for Next.js",
5
5
  "main": "./dist/index/index.js",
6
6
  "module": "./dist/index/index.mjs",
@@ -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;