@authon/vue 0.2.1 → 0.3.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/dist/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as vue from 'vue';
2
- import { App, ComputedRef, PropType } from 'vue';
2
+ import { App, ComputedRef, Ref, PropType } from 'vue';
3
3
  import { AuthonConfig, Authon } from '@authon/js';
4
- import { AuthonUser, OAuthProviderType } from '@authon/shared';
4
+ import * as _authon_shared from '@authon/shared';
5
+ import { AuthonUser, Web3Chain, Web3WalletType, Web3NonceResponse, Web3Wallet, PasskeyCredential, OAuthProviderType } from '@authon/shared';
5
6
 
6
7
  declare const AUTHON_KEY: unique symbol;
7
8
  interface AuthonState {
@@ -9,6 +10,8 @@ interface AuthonState {
9
10
  isLoading: boolean;
10
11
  user: AuthonUser | null;
11
12
  client: Authon | null;
13
+ publishableKey: string;
14
+ apiUrl: string;
12
15
  }
13
16
  interface AuthonPluginOptions {
14
17
  publishableKey: string;
@@ -29,35 +32,100 @@ declare function useUser(): {
29
32
  isLoading: ComputedRef<boolean>;
30
33
  };
31
34
 
35
+ interface LinkWalletParams {
36
+ address: string;
37
+ chain: Web3Chain;
38
+ walletType: Web3WalletType;
39
+ chainId?: number;
40
+ message: string;
41
+ signature: string;
42
+ }
43
+ interface UseAuthonWeb3Return {
44
+ getNonce: (address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number) => Promise<Web3NonceResponse | null>;
45
+ verify: (message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType) => Promise<boolean>;
46
+ listWallets: () => Promise<Web3Wallet[] | null>;
47
+ linkWallet: (params: LinkWalletParams) => Promise<Web3Wallet | null>;
48
+ unlinkWallet: (walletId: string) => Promise<boolean>;
49
+ isLoading: Ref<boolean>;
50
+ error: Ref<Error | null>;
51
+ }
52
+ declare function useAuthonWeb3(): UseAuthonWeb3Return;
53
+
54
+ interface UseAuthonPasswordlessReturn {
55
+ sendMagicLink: (email: string) => Promise<boolean>;
56
+ sendEmailOtp: (email: string) => Promise<boolean>;
57
+ verifyPasswordless: (opts: {
58
+ token?: string;
59
+ email?: string;
60
+ code?: string;
61
+ }) => Promise<boolean>;
62
+ isLoading: Ref<boolean>;
63
+ error: Ref<Error | null>;
64
+ }
65
+ declare function useAuthonPasswordless(): UseAuthonPasswordlessReturn;
66
+
67
+ interface UseAuthonPasskeysReturn {
68
+ registerPasskey: (name?: string) => Promise<PasskeyCredential | null>;
69
+ authenticateWithPasskey: (email?: string) => Promise<boolean>;
70
+ listPasskeys: () => Promise<PasskeyCredential[] | null>;
71
+ renamePasskey: (id: string, name: string) => Promise<PasskeyCredential | null>;
72
+ revokePasskey: (id: string) => Promise<boolean>;
73
+ isLoading: Ref<boolean>;
74
+ error: Ref<Error | null>;
75
+ }
76
+ declare function useAuthonPasskeys(): UseAuthonPasskeysReturn;
77
+
32
78
  declare const AuthonSignIn: vue.DefineComponent<vue.ExtractPropTypes<{
33
- mode: {
34
- type: () => "popup" | "embedded";
35
- default: string;
79
+ afterSignInUrl: {
80
+ type: StringConstructor;
81
+ default: undefined;
82
+ };
83
+ appearance: {
84
+ type: () => AuthonConfig["appearance"];
85
+ default: undefined;
36
86
  };
37
87
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
38
88
  [key: string]: any;
39
- }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
40
- mode: {
41
- type: () => "popup" | "embedded";
42
- default: string;
89
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "signIn"[], "signIn", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
90
+ afterSignInUrl: {
91
+ type: StringConstructor;
92
+ default: undefined;
43
93
  };
44
- }>> & Readonly<{}>, {
45
- mode: "popup" | "embedded";
94
+ appearance: {
95
+ type: () => AuthonConfig["appearance"];
96
+ default: undefined;
97
+ };
98
+ }>> & Readonly<{
99
+ onSignIn?: ((...args: any[]) => any) | undefined;
100
+ }>, {
101
+ appearance: Partial<_authon_shared.BrandingConfig> | undefined;
102
+ afterSignInUrl: string;
46
103
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
47
104
  declare const AuthonSignUp: vue.DefineComponent<vue.ExtractPropTypes<{
48
- mode: {
49
- type: () => "popup" | "embedded";
50
- default: string;
105
+ afterSignUpUrl: {
106
+ type: StringConstructor;
107
+ default: undefined;
108
+ };
109
+ appearance: {
110
+ type: () => AuthonConfig["appearance"];
111
+ default: undefined;
51
112
  };
52
113
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
53
114
  [key: string]: any;
54
- }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
55
- mode: {
56
- type: () => "popup" | "embedded";
57
- default: string;
115
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "signUp"[], "signUp", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
116
+ afterSignUpUrl: {
117
+ type: StringConstructor;
118
+ default: undefined;
58
119
  };
59
- }>> & Readonly<{}>, {
60
- mode: "popup" | "embedded";
120
+ appearance: {
121
+ type: () => AuthonConfig["appearance"];
122
+ default: undefined;
123
+ };
124
+ }>> & Readonly<{
125
+ onSignUp?: ((...args: any[]) => any) | undefined;
126
+ }>, {
127
+ appearance: Partial<_authon_shared.BrandingConfig> | undefined;
128
+ afterSignUpUrl: string;
61
129
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
62
130
  declare const AuthonUserButton: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
63
131
  [key: string]: any;
@@ -155,11 +223,11 @@ declare const AuthonSocialButton: vue.DefineComponent<vue.ExtractPropTypes<{
155
223
  };
156
224
  }>> & Readonly<{}>, {
157
225
  label: string;
226
+ borderRadius: number;
158
227
  loading: boolean;
159
228
  disabled: boolean;
160
229
  compact: boolean;
161
230
  iconSize: number;
162
- borderRadius: number;
163
231
  height: number;
164
232
  size: number;
165
233
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
@@ -215,4 +283,4 @@ declare const AuthonSocialButtons: vue.DefineComponent<vue.ExtractPropTypes<{
215
283
  labels: Partial<Record<"google" | "apple" | "kakao" | "naver" | "facebook" | "github" | "discord" | "x" | "line" | "microsoft", string>>;
216
284
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
217
285
 
218
- export { AUTHON_KEY, type AuthonPluginOptions, AuthonSignIn, AuthonSignUp, AuthonSignedIn, AuthonSignedOut, AuthonSocialButton, AuthonSocialButtons, type AuthonState, AuthonUserButton, createAuthon, useAuthon, useUser };
286
+ export { AUTHON_KEY, type AuthonPluginOptions, AuthonSignIn, AuthonSignUp, AuthonSignedIn, AuthonSignedOut, AuthonSocialButton, AuthonSocialButtons, type AuthonState, AuthonUserButton, type LinkWalletParams, type UseAuthonPasskeysReturn, type UseAuthonPasswordlessReturn, type UseAuthonWeb3Return, createAuthon, useAuthon, useAuthonPasskeys, useAuthonPasswordless, useAuthonWeb3, useUser };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as vue from 'vue';
2
- import { App, ComputedRef, PropType } from 'vue';
2
+ import { App, ComputedRef, Ref, PropType } from 'vue';
3
3
  import { AuthonConfig, Authon } from '@authon/js';
4
- import { AuthonUser, OAuthProviderType } from '@authon/shared';
4
+ import * as _authon_shared from '@authon/shared';
5
+ import { AuthonUser, Web3Chain, Web3WalletType, Web3NonceResponse, Web3Wallet, PasskeyCredential, OAuthProviderType } from '@authon/shared';
5
6
 
6
7
  declare const AUTHON_KEY: unique symbol;
7
8
  interface AuthonState {
@@ -9,6 +10,8 @@ interface AuthonState {
9
10
  isLoading: boolean;
10
11
  user: AuthonUser | null;
11
12
  client: Authon | null;
13
+ publishableKey: string;
14
+ apiUrl: string;
12
15
  }
13
16
  interface AuthonPluginOptions {
14
17
  publishableKey: string;
@@ -29,35 +32,100 @@ declare function useUser(): {
29
32
  isLoading: ComputedRef<boolean>;
30
33
  };
31
34
 
35
+ interface LinkWalletParams {
36
+ address: string;
37
+ chain: Web3Chain;
38
+ walletType: Web3WalletType;
39
+ chainId?: number;
40
+ message: string;
41
+ signature: string;
42
+ }
43
+ interface UseAuthonWeb3Return {
44
+ getNonce: (address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number) => Promise<Web3NonceResponse | null>;
45
+ verify: (message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType) => Promise<boolean>;
46
+ listWallets: () => Promise<Web3Wallet[] | null>;
47
+ linkWallet: (params: LinkWalletParams) => Promise<Web3Wallet | null>;
48
+ unlinkWallet: (walletId: string) => Promise<boolean>;
49
+ isLoading: Ref<boolean>;
50
+ error: Ref<Error | null>;
51
+ }
52
+ declare function useAuthonWeb3(): UseAuthonWeb3Return;
53
+
54
+ interface UseAuthonPasswordlessReturn {
55
+ sendMagicLink: (email: string) => Promise<boolean>;
56
+ sendEmailOtp: (email: string) => Promise<boolean>;
57
+ verifyPasswordless: (opts: {
58
+ token?: string;
59
+ email?: string;
60
+ code?: string;
61
+ }) => Promise<boolean>;
62
+ isLoading: Ref<boolean>;
63
+ error: Ref<Error | null>;
64
+ }
65
+ declare function useAuthonPasswordless(): UseAuthonPasswordlessReturn;
66
+
67
+ interface UseAuthonPasskeysReturn {
68
+ registerPasskey: (name?: string) => Promise<PasskeyCredential | null>;
69
+ authenticateWithPasskey: (email?: string) => Promise<boolean>;
70
+ listPasskeys: () => Promise<PasskeyCredential[] | null>;
71
+ renamePasskey: (id: string, name: string) => Promise<PasskeyCredential | null>;
72
+ revokePasskey: (id: string) => Promise<boolean>;
73
+ isLoading: Ref<boolean>;
74
+ error: Ref<Error | null>;
75
+ }
76
+ declare function useAuthonPasskeys(): UseAuthonPasskeysReturn;
77
+
32
78
  declare const AuthonSignIn: vue.DefineComponent<vue.ExtractPropTypes<{
33
- mode: {
34
- type: () => "popup" | "embedded";
35
- default: string;
79
+ afterSignInUrl: {
80
+ type: StringConstructor;
81
+ default: undefined;
82
+ };
83
+ appearance: {
84
+ type: () => AuthonConfig["appearance"];
85
+ default: undefined;
36
86
  };
37
87
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
38
88
  [key: string]: any;
39
- }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
40
- mode: {
41
- type: () => "popup" | "embedded";
42
- default: string;
89
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "signIn"[], "signIn", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
90
+ afterSignInUrl: {
91
+ type: StringConstructor;
92
+ default: undefined;
43
93
  };
44
- }>> & Readonly<{}>, {
45
- mode: "popup" | "embedded";
94
+ appearance: {
95
+ type: () => AuthonConfig["appearance"];
96
+ default: undefined;
97
+ };
98
+ }>> & Readonly<{
99
+ onSignIn?: ((...args: any[]) => any) | undefined;
100
+ }>, {
101
+ appearance: Partial<_authon_shared.BrandingConfig> | undefined;
102
+ afterSignInUrl: string;
46
103
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
47
104
  declare const AuthonSignUp: vue.DefineComponent<vue.ExtractPropTypes<{
48
- mode: {
49
- type: () => "popup" | "embedded";
50
- default: string;
105
+ afterSignUpUrl: {
106
+ type: StringConstructor;
107
+ default: undefined;
108
+ };
109
+ appearance: {
110
+ type: () => AuthonConfig["appearance"];
111
+ default: undefined;
51
112
  };
52
113
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
53
114
  [key: string]: any;
54
- }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
55
- mode: {
56
- type: () => "popup" | "embedded";
57
- default: string;
115
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "signUp"[], "signUp", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
116
+ afterSignUpUrl: {
117
+ type: StringConstructor;
118
+ default: undefined;
58
119
  };
59
- }>> & Readonly<{}>, {
60
- mode: "popup" | "embedded";
120
+ appearance: {
121
+ type: () => AuthonConfig["appearance"];
122
+ default: undefined;
123
+ };
124
+ }>> & Readonly<{
125
+ onSignUp?: ((...args: any[]) => any) | undefined;
126
+ }>, {
127
+ appearance: Partial<_authon_shared.BrandingConfig> | undefined;
128
+ afterSignUpUrl: string;
61
129
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
62
130
  declare const AuthonUserButton: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
63
131
  [key: string]: any;
@@ -155,11 +223,11 @@ declare const AuthonSocialButton: vue.DefineComponent<vue.ExtractPropTypes<{
155
223
  };
156
224
  }>> & Readonly<{}>, {
157
225
  label: string;
226
+ borderRadius: number;
158
227
  loading: boolean;
159
228
  disabled: boolean;
160
229
  compact: boolean;
161
230
  iconSize: number;
162
- borderRadius: number;
163
231
  height: number;
164
232
  size: number;
165
233
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
@@ -215,4 +283,4 @@ declare const AuthonSocialButtons: vue.DefineComponent<vue.ExtractPropTypes<{
215
283
  labels: Partial<Record<"google" | "apple" | "kakao" | "naver" | "facebook" | "github" | "discord" | "x" | "line" | "microsoft", string>>;
216
284
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
217
285
 
218
- export { AUTHON_KEY, type AuthonPluginOptions, AuthonSignIn, AuthonSignUp, AuthonSignedIn, AuthonSignedOut, AuthonSocialButton, AuthonSocialButtons, type AuthonState, AuthonUserButton, createAuthon, useAuthon, useUser };
286
+ export { AUTHON_KEY, type AuthonPluginOptions, AuthonSignIn, AuthonSignUp, AuthonSignedIn, AuthonSignedOut, AuthonSocialButton, AuthonSocialButtons, type AuthonState, AuthonUserButton, type LinkWalletParams, type UseAuthonPasskeysReturn, type UseAuthonPasswordlessReturn, type UseAuthonWeb3Return, createAuthon, useAuthon, useAuthonPasskeys, useAuthonPasswordless, useAuthonWeb3, useUser };
package/dist/index.js CHANGED
@@ -7,7 +7,9 @@ function createAuthon(options) {
7
7
  isSignedIn: false,
8
8
  isLoading: true,
9
9
  user: null,
10
- client: null
10
+ client: null,
11
+ publishableKey: options.publishableKey,
12
+ apiUrl: options.config?.apiUrl ?? "https://api.authon.dev"
11
13
  });
12
14
  return {
13
15
  install(app) {
@@ -78,59 +80,242 @@ function useUser() {
78
80
  };
79
81
  }
80
82
 
83
+ // src/useAuthonWeb3.ts
84
+ import { ref } from "vue";
85
+ import { inject as inject2 } from "vue";
86
+ function useAuthonWeb3() {
87
+ const state = inject2(AUTHON_KEY);
88
+ if (!state) {
89
+ throw new Error("useAuthonWeb3() must be called inside a component tree with createAuthon() installed");
90
+ }
91
+ const s = state;
92
+ const isLoading = ref(false);
93
+ const error = ref(null);
94
+ async function wrap(fn) {
95
+ isLoading.value = true;
96
+ error.value = null;
97
+ try {
98
+ return await fn();
99
+ } catch (err) {
100
+ error.value = err instanceof Error ? err : new Error(String(err));
101
+ return null;
102
+ } finally {
103
+ isLoading.value = false;
104
+ }
105
+ }
106
+ async function getNonce(address, chain, walletType, chainId) {
107
+ return wrap(() => s.client.web3GetNonce(address, chain, walletType, chainId));
108
+ }
109
+ async function verify(message, signature, address, chain, walletType) {
110
+ const result = await wrap(
111
+ () => s.client.web3Verify(message, signature, address, chain, walletType)
112
+ );
113
+ return result !== null;
114
+ }
115
+ async function listWallets() {
116
+ return wrap(() => s.client.listWallets());
117
+ }
118
+ async function linkWallet(params) {
119
+ return wrap(() => s.client.linkWallet(params));
120
+ }
121
+ async function unlinkWallet(walletId) {
122
+ const result = await wrap(() => s.client.unlinkWallet(walletId));
123
+ return result !== null;
124
+ }
125
+ return {
126
+ getNonce,
127
+ verify,
128
+ listWallets,
129
+ linkWallet,
130
+ unlinkWallet,
131
+ isLoading,
132
+ error
133
+ };
134
+ }
135
+
136
+ // src/useAuthonPasswordless.ts
137
+ import { ref as ref2, inject as inject3 } from "vue";
138
+ function useAuthonPasswordless() {
139
+ const state = inject3(AUTHON_KEY);
140
+ if (!state) {
141
+ throw new Error("useAuthonPasswordless() must be called inside a component tree with createAuthon() installed");
142
+ }
143
+ const s = state;
144
+ const isLoading = ref2(false);
145
+ const error = ref2(null);
146
+ async function wrap(fn) {
147
+ isLoading.value = true;
148
+ error.value = null;
149
+ try {
150
+ return await fn();
151
+ } catch (err) {
152
+ error.value = err instanceof Error ? err : new Error(String(err));
153
+ return null;
154
+ } finally {
155
+ isLoading.value = false;
156
+ }
157
+ }
158
+ async function sendMagicLink(email) {
159
+ const result = await wrap(() => s.client.sendMagicLink(email));
160
+ return result !== null;
161
+ }
162
+ async function sendEmailOtp(email) {
163
+ const result = await wrap(() => s.client.sendEmailOtp(email));
164
+ return result !== null;
165
+ }
166
+ async function verifyPasswordless(opts) {
167
+ const result = await wrap(() => s.client.verifyPasswordless(opts));
168
+ return result !== null;
169
+ }
170
+ return {
171
+ sendMagicLink,
172
+ sendEmailOtp,
173
+ verifyPasswordless,
174
+ isLoading,
175
+ error
176
+ };
177
+ }
178
+
179
+ // src/useAuthonPasskeys.ts
180
+ import { ref as ref3, inject as inject4 } from "vue";
181
+ function useAuthonPasskeys() {
182
+ const state = inject4(AUTHON_KEY);
183
+ if (!state) {
184
+ throw new Error("useAuthonPasskeys() must be called inside a component tree with createAuthon() installed");
185
+ }
186
+ const s = state;
187
+ const isLoading = ref3(false);
188
+ const error = ref3(null);
189
+ async function wrap(fn) {
190
+ isLoading.value = true;
191
+ error.value = null;
192
+ try {
193
+ return await fn();
194
+ } catch (err) {
195
+ error.value = err instanceof Error ? err : new Error(String(err));
196
+ return null;
197
+ } finally {
198
+ isLoading.value = false;
199
+ }
200
+ }
201
+ async function registerPasskey(name) {
202
+ return wrap(() => s.client.registerPasskey(name));
203
+ }
204
+ async function authenticateWithPasskey(email) {
205
+ const result = await wrap(() => s.client.authenticateWithPasskey(email));
206
+ return result !== null;
207
+ }
208
+ async function listPasskeys() {
209
+ return wrap(() => s.client.listPasskeys());
210
+ }
211
+ async function renamePasskey(id, name) {
212
+ return wrap(() => s.client.renamePasskey(id, name));
213
+ }
214
+ async function revokePasskey(id) {
215
+ const result = await wrap(() => s.client.revokePasskey(id));
216
+ return result !== null;
217
+ }
218
+ return {
219
+ registerPasskey,
220
+ authenticateWithPasskey,
221
+ listPasskeys,
222
+ renamePasskey,
223
+ revokePasskey,
224
+ isLoading,
225
+ error
226
+ };
227
+ }
228
+
81
229
  // src/components.ts
82
- import { defineComponent, h, onMounted, ref, computed as computed2 } from "vue";
230
+ import { defineComponent, h, inject as inject5, onMounted, onUnmounted, ref as ref4, computed as computed2 } from "vue";
231
+ import { Authon as Authon2 } from "@authon/js";
232
+ var _embeddedCounter = 0;
233
+ function requireState2() {
234
+ const state = inject5(AUTHON_KEY);
235
+ if (!state) {
236
+ throw new Error("AuthonSignIn/AuthonSignUp must be used inside a component tree with createAuthon() installed");
237
+ }
238
+ return state;
239
+ }
83
240
  var AuthonSignIn = defineComponent({
84
241
  name: "AuthonSignIn",
85
242
  props: {
86
- mode: {
87
- type: String,
88
- default: "popup"
89
- }
243
+ afterSignInUrl: { type: String, default: void 0 },
244
+ appearance: { type: Object, default: void 0 }
90
245
  },
91
- setup(props) {
92
- const { client } = useAuthon();
246
+ emits: ["signIn"],
247
+ setup(props, { emit }) {
248
+ const state = requireState2();
249
+ const containerId = ref4(`authon-signin-${++_embeddedCounter}`);
250
+ let embeddedClient = null;
251
+ let cleanupSignedIn = null;
93
252
  onMounted(() => {
94
- if (props.mode === "popup") {
95
- client?.openSignIn();
96
- }
253
+ embeddedClient = new Authon2(state.publishableKey, {
254
+ apiUrl: state.apiUrl,
255
+ mode: "embedded",
256
+ containerId: containerId.value,
257
+ appearance: props.appearance
258
+ });
259
+ cleanupSignedIn = embeddedClient.on("signedIn", (user) => {
260
+ state.user = user;
261
+ state.isSignedIn = true;
262
+ emit("signIn", user);
263
+ if (props.afterSignInUrl) {
264
+ window.location.href = props.afterSignInUrl;
265
+ }
266
+ });
267
+ embeddedClient.openSignIn();
97
268
  });
98
- return () => {
99
- if (props.mode === "embedded") {
100
- return h("div", { id: "authon-signin-container" });
101
- }
102
- return null;
103
- };
269
+ onUnmounted(() => {
270
+ cleanupSignedIn?.();
271
+ embeddedClient?.destroy();
272
+ embeddedClient = null;
273
+ });
274
+ return () => h("div", { id: containerId.value });
104
275
  }
105
276
  });
106
277
  var AuthonSignUp = defineComponent({
107
278
  name: "AuthonSignUp",
108
279
  props: {
109
- mode: {
110
- type: String,
111
- default: "popup"
112
- }
280
+ afterSignUpUrl: { type: String, default: void 0 },
281
+ appearance: { type: Object, default: void 0 }
113
282
  },
114
- setup(props) {
115
- const { client } = useAuthon();
283
+ emits: ["signUp"],
284
+ setup(props, { emit }) {
285
+ const state = requireState2();
286
+ const containerId = ref4(`authon-signup-${++_embeddedCounter}`);
287
+ let embeddedClient = null;
288
+ let cleanupSignedIn = null;
116
289
  onMounted(() => {
117
- if (props.mode === "popup") {
118
- client?.openSignUp();
119
- }
290
+ embeddedClient = new Authon2(state.publishableKey, {
291
+ apiUrl: state.apiUrl,
292
+ mode: "embedded",
293
+ containerId: containerId.value,
294
+ appearance: props.appearance
295
+ });
296
+ cleanupSignedIn = embeddedClient.on("signedIn", (user) => {
297
+ state.user = user;
298
+ state.isSignedIn = true;
299
+ emit("signUp", user);
300
+ if (props.afterSignUpUrl) {
301
+ window.location.href = props.afterSignUpUrl;
302
+ }
303
+ });
304
+ embeddedClient.openSignUp();
120
305
  });
121
- return () => {
122
- if (props.mode === "embedded") {
123
- return h("div", { id: "authon-signup-container" });
124
- }
125
- return null;
126
- };
306
+ onUnmounted(() => {
307
+ cleanupSignedIn?.();
308
+ embeddedClient?.destroy();
309
+ embeddedClient = null;
310
+ });
311
+ return () => h("div", { id: containerId.value });
127
312
  }
128
313
  });
129
314
  var AuthonUserButton = defineComponent({
130
315
  name: "AuthonUserButton",
131
316
  setup() {
132
317
  const { user, isSignedIn, signOut, openSignIn } = useAuthon();
133
- const open = ref(false);
318
+ const open = ref4(false);
134
319
  const initials = computed2(() => {
135
320
  if (!user) return "?";
136
321
  const u = user;
@@ -257,7 +442,7 @@ var AuthonSignedOut = defineComponent({
257
442
  });
258
443
 
259
444
  // src/SocialButton.ts
260
- import { defineComponent as defineComponent2, h as h2, ref as ref2, computed as computed3, onMounted as onMounted2 } from "vue";
445
+ import { defineComponent as defineComponent2, h as h2, ref as ref5, computed as computed3, onMounted as onMounted2 } from "vue";
261
446
  import { PROVIDER_COLORS, PROVIDER_DISPLAY_NAMES } from "@authon/shared";
262
447
  import { getProviderButtonConfig } from "@authon/js";
263
448
  var AuthonSocialButton = defineComponent2({
@@ -370,8 +555,8 @@ var AuthonSocialButtons = defineComponent2({
370
555
  },
371
556
  setup(props) {
372
557
  const { client } = useAuthon();
373
- const providers = ref2([]);
374
- const loadingProvider = ref2(null);
558
+ const providers = ref5([]);
559
+ const loadingProvider = ref5(null);
375
560
  const resolvedGap = computed3(() => props.gap ?? (props.compact ? 12 : 10));
376
561
  onMounted2(async () => {
377
562
  if (client) {
@@ -423,6 +608,9 @@ export {
423
608
  AuthonUserButton,
424
609
  createAuthon,
425
610
  useAuthon,
611
+ useAuthonPasskeys,
612
+ useAuthonPasswordless,
613
+ useAuthonWeb3,
426
614
  useUser
427
615
  };
428
616
  //# sourceMappingURL=index.js.map