@magic-ext/magic-widget 1.0.0-canary.979.21085311128.0 → 1.0.0-canary.979.21086257393.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/dist/cjs/index.js +19 -19
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.mjs +19 -19
- package/dist/es/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -14048,7 +14048,7 @@ function isValidEmail(source) {
|
|
|
14048
14048
|
return emailRegex.test(source);
|
|
14049
14049
|
}
|
|
14050
14050
|
|
|
14051
|
-
var m=(o=>(o.MissingApiKey="MISSING_API_KEY",o.ModalNotReady="MODAL_NOT_READY",o.ConnectionLost="CONNECTION_WAS_LOST",o.MalformedResponse="MALFORMED_RESPONSE",o.InvalidArgument="INVALID_ARGUMENT",o.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",o.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",o))(m||{}),
|
|
14051
|
+
var m=(o=>(o.MissingApiKey="MISSING_API_KEY",o.ModalNotReady="MODAL_NOT_READY",o.ConnectionLost="CONNECTION_WAS_LOST",o.MalformedResponse="MALFORMED_RESPONSE",o.InvalidArgument="INVALID_ARGUMENT",o.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",o.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",o))(m||{}),u=(s=>(s.SyncWeb3Method="SYNC_WEB3_METHOD",s.DuplicateIframe="DUPLICATE_IFRAME",s.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",s.DeprecationNotice="DEPRECATION_NOTICE",s.ProductAnnouncement="ANNOUNCEMENT",s))(u||{}),v=(i=>(i[i.ParseError=-32700]="ParseError",i[i.InvalidRequest=-32600]="InvalidRequest",i[i.MethodNotFound=-32601]="MethodNotFound",i[i.InvalidParams=-32602]="InvalidParams",i[i.InternalError=-32603]="InternalError",i[i.MagicLinkFailedVerification=-1e4]="MagicLinkFailedVerification",i[i.MagicLinkExpired=-10001]="MagicLinkExpired",i[i.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",i[i.MagicLinkInvalidRedirectURL=-10006]="MagicLinkInvalidRedirectURL",i[i.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",i[i.UpdateEmailFailed=-10004]="UpdateEmailFailed",i[i.UserRequestEditEmail=-10005]="UserRequestEditEmail",i[i.InactiveRecipient=-10010]="InactiveRecipient",i[i.AccessDeniedToUser=-10011]="AccessDeniedToUser",i[i.RedirectLoginComplete=-10015]="RedirectLoginComplete",i[i.DpopInvalidated=-10019]="DpopInvalidated",i))(v||{});var _=(t=>(t.PROVIDER="magic_3pw_provider",t.ADDRESS="magic_3pw_address",t.CHAIN_ID="magic_3pw_chainId",t))(_||{}),f=(t=>(t.WalletConnected="wallet_connected",t.WalletRejected="wallet_rejected",t.Web3ModalSelected="web3modal_selected",t))(f||{}),g=(e=>(e.LoginWithSms="magic_auth_login_with_sms",e.LoginWithEmailOTP="magic_auth_login_with_email_otp",e.LoginWithMagicLink="magic_auth_login_with_magic_link",e.LoginWithCredential="magic_auth_login_with_credential",e.SetAuthorizationToken="magic_auth_set_authorization_token",e.GetIdToken="magic_auth_get_id_token",e.GenerateIdToken="magic_auth_generate_id_token",e.GetMetadata="magic_auth_get_metadata",e.IsLoggedIn="magic_is_logged_in",e.Logout="magic_auth_logout",e.UpdateEmail="magic_auth_update_email",e.UserSettings="magic_auth_settings",e.UserSettingsTestMode="magic_auth_settings_testing_mode",e.LoginWithSmsTestMode="magic_auth_login_with_sms_testing_mode",e.LoginWithEmailOTPTestMode="magic_auth_login_with_email_otp_testing_mode",e.LoginWithMagicLinkTestMode="magic_login_with_magic_link_testing_mode",e.LoginWithCredentialTestMode="magic_auth_login_with_credential_testing_mode",e.GetIdTokenTestMode="magic_auth_get_id_token_testing_mode",e.GenerateIdTokenTestMode="magic_auth_generate_id_token_testing_mode",e.GetMetadataTestMode="magic_auth_get_metadata_testing_mode",e.IsLoggedInTestMode="magic_auth_is_logged_in_testing_mode",e.LogoutTestMode="magic_auth_logout_testing_mode",e.UpdateEmailTestMode="magic_auth_update_email_testing_mode",e.IntermediaryEvent="magic_intermediary_event",e.RequestAccounts="eth_requestAccounts",e.GetInfo="magic_get_info",e.ShowUI="magic_wallet",e.NFTPurchase="magic_nft_purchase",e.NFTCheckout="magic_nft_checkout",e.NFTTransfer="magic_nft_transfer",e.RequestUserInfoWithUI="mc_request_user_info",e.Disconnect="mc_disconnect",e.RecoverAccount="magic_auth_recover_account",e.RecoverAccountTestMode="magic_auth_recover_account_testing_mode",e.MagicBoxHeartBeat="magic_box_heart_beat",e.AutoConnect="mc_auto_connect",e.Login="mc_login",e.EncryptV1="magic_auth_encrypt_v1",e.DecryptV1="magic_auth_decrypt_v1",e.ShowNFTs="magic_show_nfts",e.ShowOnRamp="magic_show_fiat_onramp",e.ShowSendTokensUI="magic_show_send_tokens_ui",e.ShowAddress="magic_show_address",e.ShowBalances="magic_show_balances",e.SendGaslessTransaction="eth_sendGaslessTransaction",e.RevealPK="magic_reveal_key",e.EnableMFA="magic_auth_enable_mfa_flow",e.DisableMFA="magic_auth_disable_mfa_flow",e.GetMultichainPublicAddress="magic_get_multichain_public_address",e.Sign7702Authorization="magic_wallet_sign_7702_authorization",e))(g||{});var E=(c=>(c.MAGIC_HANDLE_RESPONSE="MAGIC_HANDLE_RESPONSE",c.MAGIC_OVERLAY_READY="MAGIC_OVERLAY_READY",c.MAGIC_SHOW_OVERLAY="MAGIC_SHOW_OVERLAY",c.MAGIC_HIDE_OVERLAY="MAGIC_HIDE_OVERLAY",c.MAGIC_HANDLE_EVENT="MAGIC_HANDLE_EVENT",c.MAGIC_MG_BOX_SEND_RECEIPT="MAGIC_MG_BOX_SEND_RECEIPT",c.MAGIC_SEND_PRODUCT_ANNOUNCEMENT="MAGIC_SEND_PRODUCT_ANNOUNCEMENT",c.MAGIC_PONG="MAGIC_PONG",c.MAGIC_POPUP_RESPONSE="MAGIC_POPUP_RESPONSE",c.MAGIC_POPUP_OAUTH_VERIFY_RESPONSE="MAGIC_POPUP_OAUTH_VERIFY_RESPONSE",c.MAGIC_THIRD_PARTY_WALLET_REQUEST="MAGIC_THIRD_PARTY_WALLET_REQUEST",c))(E||{}),A=(n=>(n.MAGIC_HANDLE_REQUEST="MAGIC_HANDLE_REQUEST",n.MAGIC_THIRD_PARTY_WALLET_RESPONSE="MAGIC_THIRD_PARTY_WALLET_RESPONSE",n.MAGIC_THIRD_PARTY_WALLET_UPDATE="MAGIC_THIRD_PARTY_WALLET_EVENT",n.MAGIC_PING="MAGIC_PING",n))(A||{});var I=(t=>(t.UpdateEmail="update-email",t.MFA="mfa",t.Recovery="recovery",t))(I||{});var h=(r=>(r.Retry="retry",r))(h||{}),R=(d=>(d.EmailSent="email-sent",d.EmailNotDeliverable="email-not-deliverable",d))(R||{}),y=(s=>(s.VerifyEmailOtp="verify-email-otp",s.VerifyMFACode="verify-mfa-code",s.LostDevice="lost-device",s.VerifyRecoveryCode="verify-recovery-code",s.Cancel="cancel",s))(y||{}),x=(t=>(t.VerifySmsOtp="verify-sms-otp",t.Cancel="cancel",t.Retry="retry",t))(x||{}),T=(t=>(t.SmsOTPSent="sms-otp-sent",t.InvalidSmsOtp="invalid-sms-otp",t.ExpiredSmsOtp="expired-sms-otp",t))(T||{}),N=(l=>(l.EmailOTPSent="email-otp-sent",l.InvalidEmailOtp="invalid-email-otp",l.InvalidMfaOtp="invalid-mfa-otp",l.ExpiredEmailOtp="expired-email-otp",l.MfaSentHandle="mfa-sent-handle",l.RecoveryCodeSentHandle="recovery-code-sent-handle",l.InvalidRecoveryCode="invalid-recovery-code",l.RecoveryCodeSuccess="recovery-code-success",l.LoginThrottled="login-throttled",l.MaxAttemptsReached="max-attempts-reached",l))(N||{}),C=(r=>(r.Retry="device-retry",r))(C||{}),S=(n=>(n.DeviceApproved="device-approved",n.DeviceNeedsApproval="device-needs-approval",n.DeviceVerificationLinkExpired="device-verification-link-expired",n.DeviceVerificationEmailSent="device-verification-email-sent",n))(S||{}),O=(n=>(n.Retry="Recency/auth-factor-retry",n.Cancel="Recency/auth-factor-verification-cancel",n.VerifyEmailOtp="Recency/auth-factor-verify-email-otp",n.VerifyMFACode="Recency/verify-mfa-code",n))(O||{}),b=(a=>(a.PrimaryAuthFactorNeedsVerification="Recency/auth-factor-needs-verification",a.PrimaryAuthFactorVerified="Recency/auth-factor-verified",a.InvalidEmailOtp="Recency/auth-factor-invalid-email-otp",a.EmailExpired="Recency/auth-factor-verification-email-expired",a.EmailSent="Recency/auth-factor-verification-email-sent",a.EmailNotDeliverable="Recency/auth-factor-verification-email-not-deliverable",a))(b||{}),L=(t=>(t.RetryWithNewEmail="UpdateEmail/retry-with-new-email",t.Cancel="UpdateEmail/new-email-verification-cancel",t.VerifyEmailOtp="UpdateEmail/new-email-verify-otp",t))(L||{}),U=(p=>(p.NewAuthFactorNeedsVerification="UpdateEmail/new-email-needs-verification",p.EmailUpdated="UpdateEmail/email-updated",p.InvalidEmailOtp="UpdateEmail/new-email-invalid-email-otp",p.EmailExpired="UpdateEmail/new-email-verification-email-expired",p.EmailSent="UpdateEmail/new-email-verification-email-sent",p.EmailNotDeliverable="UpdateEmail/new-email-verification-email-not-deliverable",p.InvalidEmail="UpdateEmail/new-email-invalid",p.EmailAlreadyExists="UpdateEmail/new-email-already-exists",p))(U||{}),F=(r=>(r.IDTokenCreated="Auth/id-token-created",r))(F||{}),k=(r=>(r.Cancel="Farcaster/cancel",r))(k||{}),w=(t=>(t.MFASecretGenerated="mfa-secret-generated",t.InvalidMFAOtp="invalid-mfa-otp",t.MFARecoveryCodes="mfa-recovery-codes",t))(w||{}),D=(d=>(d.VerifyMFACode="verify-mfa-code",d.Cancel="cancel-mfa-setup",d))(D||{}),G=(t=>(t.MFACodeRequested="mfa-code-requested",t.InvalidMFAOtp="invalid-mfa-otp",t.InvalidRecoveryCode="invalid-recovery-code",t))(G||{}),W=(t=>(t.VerifyMFACode="verify-mfa-code",t.LostDevice="lost-device",t.Cancel="cancel-mfa-disable",t))(W||{});var V=(r=>(r.Harmony="HARMONY",r))(V||{});var H=(r=>(r.ClosedByUser="closed-by-user",r))(H||{}),P=(r=>(r.ClosedByUser="closed-by-user-on-received",r))(P||{}),q=(o=>(o.EnterNewPhoneNumber="enter-new-phone-number",o.EnterOtpCode="enter-otp-code",o.RecoveryFactorAlreadyExists="recovery-factor-already-exists",o.MalformedPhoneNumber="malformed-phone-number",o.InvalidOtpCode="invalid-otp-code",o.RecoveryFactorUpdated="recovery-factor-updated",o.RecoveryFactorDeleted="recovery-factor-deleted",o))(q||{}),Y=(n=>(n.SendNewPhoneNumber="send-new-phone-number",n.SendOtpCode="send-otp-code",n.Cancel="cancel",n.StartEditPhoneNumber="start-edit-phone-number",n))(Y||{}),J=(r=>(r.PhoneNumber="phone_number",r))(J||{}),M=(a=>(a.SmsOtpSent="sms-otp-sent",a.LoginThrottled="login-throttled",a.InvalidSmsOtp="invalid-sms-otp",a.SmsVerified="sms-verified",a.AccountRecovered="account-recovered",a.UpdateEmailRequired="update-email-required",a))(M||{}),B=(n=>(n.Cancel="cancel",n.VerifyOtp="verify-otp-code",n.ResendSms="resend-sms-otp",n.UpdateEmail="update-email",n))(B||{});var z=(n=>(n.Success="nft-checkout-success",n.Failure="nft-checkout-failure",n.Initiated="nft-checkout-initiated",n.Disconnect="disconnect",n))(z||{});var Q=(r=>(r.WalletInfoFetched="Wallet/wallet-info-fetched",r))(Q||{});var $=(r=>(r.CloseMagicWindow="close-magic-window",r))($||{});var j=(r=>(r.PopupUrl="popup-url",r))(j||{}),X=(d=>(d.PopupEvent="popup-event",d.Cancel="cancel",d))(X||{});
|
|
14052
14052
|
|
|
14053
14053
|
// Reown project ID
|
|
14054
14054
|
const projectId = '141e0e0e531b47a47d662bca4eb70fae';
|
|
@@ -14124,7 +14124,7 @@ class MagicWidgetExtension extends provider.Extension.Internal {
|
|
|
14124
14124
|
// Store singleton reference for internal use
|
|
14125
14125
|
extensionInstance = this;
|
|
14126
14126
|
// Check if already connected from localStorage
|
|
14127
|
-
const storedProvider = localStorage.getItem(
|
|
14127
|
+
const storedProvider = localStorage.getItem(_.PROVIDER);
|
|
14128
14128
|
if (storedProvider === MAGIC_WIDGET_PROVIDER) {
|
|
14129
14129
|
this.sdk.thirdPartyWallets.isConnected = true;
|
|
14130
14130
|
this.restoreWalletConnection();
|
|
@@ -14139,7 +14139,7 @@ class MagicWidgetExtension extends provider.Extension.Internal {
|
|
|
14139
14139
|
this.setupEip1193EventListeners();
|
|
14140
14140
|
return;
|
|
14141
14141
|
}
|
|
14142
|
-
const storedProvider = localStorage.getItem(
|
|
14142
|
+
const storedProvider = localStorage.getItem(_.PROVIDER);
|
|
14143
14143
|
if (storedProvider !== MAGIC_WIDGET_PROVIDER) {
|
|
14144
14144
|
return;
|
|
14145
14145
|
}
|
|
@@ -14167,9 +14167,9 @@ class MagicWidgetExtension extends provider.Extension.Internal {
|
|
|
14167
14167
|
* This enables RPC request routing through the 3rd party wallet.
|
|
14168
14168
|
*/
|
|
14169
14169
|
setConnectedState(address, chainId = 1) {
|
|
14170
|
-
localStorage.setItem(
|
|
14171
|
-
localStorage.setItem(
|
|
14172
|
-
localStorage.setItem(
|
|
14170
|
+
localStorage.setItem(_.PROVIDER, MAGIC_WIDGET_PROVIDER);
|
|
14171
|
+
localStorage.setItem(_.ADDRESS, address);
|
|
14172
|
+
localStorage.setItem(_.CHAIN_ID, chainId.toString());
|
|
14173
14173
|
this.sdk.thirdPartyWallets.isConnected = true;
|
|
14174
14174
|
this.setupEip1193EventListeners();
|
|
14175
14175
|
}
|
|
@@ -14211,7 +14211,7 @@ class MagicWidgetExtension extends provider.Extension.Internal {
|
|
|
14211
14211
|
const client = await this.getWalletProvider();
|
|
14212
14212
|
if (!client) {
|
|
14213
14213
|
throw new provider.MagicRPCError({
|
|
14214
|
-
code:
|
|
14214
|
+
code: v.InternalError,
|
|
14215
14215
|
message: 'No wallet connected. Please connect a wallet first.',
|
|
14216
14216
|
});
|
|
14217
14217
|
}
|
|
@@ -14230,8 +14230,8 @@ class MagicWidgetExtension extends provider.Extension.Internal {
|
|
|
14230
14230
|
// Watch for account/chain changes using wagmi's watchAccount
|
|
14231
14231
|
const unwatch = core.watchAccount(wagmiConfig, {
|
|
14232
14232
|
onChange: (account, prevAccount) => {
|
|
14233
|
-
const storedAddress = localStorage.getItem(
|
|
14234
|
-
const storedChainId = localStorage.getItem(
|
|
14233
|
+
const storedAddress = localStorage.getItem(_.ADDRESS);
|
|
14234
|
+
const storedChainId = localStorage.getItem(_.CHAIN_ID);
|
|
14235
14235
|
// If user disconnected
|
|
14236
14236
|
if (!account.isConnected && storedAddress) {
|
|
14237
14237
|
this.handleWalletDisconnect();
|
|
@@ -14241,7 +14241,7 @@ class MagicWidgetExtension extends provider.Extension.Internal {
|
|
|
14241
14241
|
}
|
|
14242
14242
|
// Account changed
|
|
14243
14243
|
if (account.address && account.address !== storedAddress) {
|
|
14244
|
-
localStorage.setItem(
|
|
14244
|
+
localStorage.setItem(_.ADDRESS, account.address);
|
|
14245
14245
|
this.sdk.rpcProvider.emit('accountsChanged', [account.address]);
|
|
14246
14246
|
this.dispatchWalletUpdate({
|
|
14247
14247
|
chain: account.chain,
|
|
@@ -14252,7 +14252,7 @@ class MagicWidgetExtension extends provider.Extension.Internal {
|
|
|
14252
14252
|
}
|
|
14253
14253
|
// Chain changed
|
|
14254
14254
|
if (account.chainId && account.chainId.toString() !== storedChainId) {
|
|
14255
|
-
localStorage.setItem(
|
|
14255
|
+
localStorage.setItem(_.CHAIN_ID, account.chainId.toString());
|
|
14256
14256
|
this.sdk.rpcProvider.emit('chainChanged', account.chainId);
|
|
14257
14257
|
this.dispatchWalletUpdate({
|
|
14258
14258
|
chain: account.chain,
|
|
@@ -14277,7 +14277,7 @@ class MagicWidgetExtension extends provider.Extension.Internal {
|
|
|
14277
14277
|
this.sdk.thirdPartyWallets.resetThirdPartyWalletState();
|
|
14278
14278
|
this.sdk.rpcProvider.emit('accountsChanged', []);
|
|
14279
14279
|
try {
|
|
14280
|
-
const logoutPayload = this.utils.createJsonRpcRequestPayload(
|
|
14280
|
+
const logoutPayload = this.utils.createJsonRpcRequestPayload(g.Logout, []);
|
|
14281
14281
|
await this.request(logoutPayload);
|
|
14282
14282
|
}
|
|
14283
14283
|
catch (error) {
|
|
@@ -14522,7 +14522,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14522
14522
|
const submitOTP = React.useCallback((otp) => {
|
|
14523
14523
|
if (handleRef.current) {
|
|
14524
14524
|
dispatch({ type: 'EMAIL_OTP_VERIFYING' });
|
|
14525
|
-
handleRef.current.emit(
|
|
14525
|
+
handleRef.current.emit(y.VerifyEmailOtp, otp);
|
|
14526
14526
|
}
|
|
14527
14527
|
}, [dispatch]);
|
|
14528
14528
|
/**
|
|
@@ -14531,7 +14531,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14531
14531
|
const submitMFA = React.useCallback((totp) => {
|
|
14532
14532
|
if (handleRef.current) {
|
|
14533
14533
|
dispatch({ type: 'MFA_VERIFYING' });
|
|
14534
|
-
handleRef.current.emit(
|
|
14534
|
+
handleRef.current.emit(y.VerifyMFACode, totp);
|
|
14535
14535
|
}
|
|
14536
14536
|
}, [dispatch]);
|
|
14537
14537
|
/**
|
|
@@ -14540,7 +14540,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14540
14540
|
const lostDevice = React.useCallback(() => {
|
|
14541
14541
|
if (handleRef.current) {
|
|
14542
14542
|
dispatch({ type: 'LOST_DEVICE' });
|
|
14543
|
-
handleRef.current.emit(
|
|
14543
|
+
handleRef.current.emit(y.LostDevice);
|
|
14544
14544
|
}
|
|
14545
14545
|
}, [dispatch]);
|
|
14546
14546
|
/**
|
|
@@ -14549,7 +14549,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14549
14549
|
const submitRecoveryCode = React.useCallback((recoveryCode) => {
|
|
14550
14550
|
if (handleRef.current) {
|
|
14551
14551
|
dispatch({ type: 'RECOVERY_CODE_VERIFYING' });
|
|
14552
|
-
handleRef.current.emit(
|
|
14552
|
+
handleRef.current.emit(y.VerifyRecoveryCode, recoveryCode);
|
|
14553
14553
|
}
|
|
14554
14554
|
}, [dispatch]);
|
|
14555
14555
|
/**
|
|
@@ -14557,7 +14557,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14557
14557
|
*/
|
|
14558
14558
|
const cancelLogin = React.useCallback(() => {
|
|
14559
14559
|
if (handleRef.current) {
|
|
14560
|
-
handleRef.current.emit(
|
|
14560
|
+
handleRef.current.emit(y.Cancel);
|
|
14561
14561
|
}
|
|
14562
14562
|
handleRef.current = null;
|
|
14563
14563
|
emailRef.current = null;
|
|
@@ -14568,13 +14568,13 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14568
14568
|
*/
|
|
14569
14569
|
const retryDeviceVerification = React.useCallback(() => {
|
|
14570
14570
|
if (handleRef.current) {
|
|
14571
|
-
handleRef.current.emit(
|
|
14571
|
+
handleRef.current.emit(C.Retry);
|
|
14572
14572
|
}
|
|
14573
14573
|
}, []);
|
|
14574
14574
|
const resendEmailOTP = React.useCallback(() => {
|
|
14575
14575
|
const email = emailRef.current;
|
|
14576
14576
|
if (handleRef.current) {
|
|
14577
|
-
handleRef.current.emit(
|
|
14577
|
+
handleRef.current.emit(y.Cancel);
|
|
14578
14578
|
}
|
|
14579
14579
|
handleRef.current = null;
|
|
14580
14580
|
emailRef.current = null;
|