@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/es/index.mjs
CHANGED
|
@@ -14028,7 +14028,7 @@ function isValidEmail(source) {
|
|
|
14028
14028
|
return emailRegex.test(source);
|
|
14029
14029
|
}
|
|
14030
14030
|
|
|
14031
|
-
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||{}),
|
|
14031
|
+
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||{});
|
|
14032
14032
|
|
|
14033
14033
|
// Reown project ID
|
|
14034
14034
|
const projectId = '141e0e0e531b47a47d662bca4eb70fae';
|
|
@@ -14104,7 +14104,7 @@ class MagicWidgetExtension extends Extension.Internal {
|
|
|
14104
14104
|
// Store singleton reference for internal use
|
|
14105
14105
|
extensionInstance = this;
|
|
14106
14106
|
// Check if already connected from localStorage
|
|
14107
|
-
const storedProvider = localStorage.getItem(
|
|
14107
|
+
const storedProvider = localStorage.getItem(_.PROVIDER);
|
|
14108
14108
|
if (storedProvider === MAGIC_WIDGET_PROVIDER) {
|
|
14109
14109
|
this.sdk.thirdPartyWallets.isConnected = true;
|
|
14110
14110
|
this.restoreWalletConnection();
|
|
@@ -14119,7 +14119,7 @@ class MagicWidgetExtension extends Extension.Internal {
|
|
|
14119
14119
|
this.setupEip1193EventListeners();
|
|
14120
14120
|
return;
|
|
14121
14121
|
}
|
|
14122
|
-
const storedProvider = localStorage.getItem(
|
|
14122
|
+
const storedProvider = localStorage.getItem(_.PROVIDER);
|
|
14123
14123
|
if (storedProvider !== MAGIC_WIDGET_PROVIDER) {
|
|
14124
14124
|
return;
|
|
14125
14125
|
}
|
|
@@ -14147,9 +14147,9 @@ class MagicWidgetExtension extends Extension.Internal {
|
|
|
14147
14147
|
* This enables RPC request routing through the 3rd party wallet.
|
|
14148
14148
|
*/
|
|
14149
14149
|
setConnectedState(address, chainId = 1) {
|
|
14150
|
-
localStorage.setItem(
|
|
14151
|
-
localStorage.setItem(
|
|
14152
|
-
localStorage.setItem(
|
|
14150
|
+
localStorage.setItem(_.PROVIDER, MAGIC_WIDGET_PROVIDER);
|
|
14151
|
+
localStorage.setItem(_.ADDRESS, address);
|
|
14152
|
+
localStorage.setItem(_.CHAIN_ID, chainId.toString());
|
|
14153
14153
|
this.sdk.thirdPartyWallets.isConnected = true;
|
|
14154
14154
|
this.setupEip1193EventListeners();
|
|
14155
14155
|
}
|
|
@@ -14191,7 +14191,7 @@ class MagicWidgetExtension extends Extension.Internal {
|
|
|
14191
14191
|
const client = await this.getWalletProvider();
|
|
14192
14192
|
if (!client) {
|
|
14193
14193
|
throw new MagicRPCError({
|
|
14194
|
-
code:
|
|
14194
|
+
code: v.InternalError,
|
|
14195
14195
|
message: 'No wallet connected. Please connect a wallet first.',
|
|
14196
14196
|
});
|
|
14197
14197
|
}
|
|
@@ -14210,8 +14210,8 @@ class MagicWidgetExtension extends Extension.Internal {
|
|
|
14210
14210
|
// Watch for account/chain changes using wagmi's watchAccount
|
|
14211
14211
|
const unwatch = watchAccount(wagmiConfig, {
|
|
14212
14212
|
onChange: (account, prevAccount) => {
|
|
14213
|
-
const storedAddress = localStorage.getItem(
|
|
14214
|
-
const storedChainId = localStorage.getItem(
|
|
14213
|
+
const storedAddress = localStorage.getItem(_.ADDRESS);
|
|
14214
|
+
const storedChainId = localStorage.getItem(_.CHAIN_ID);
|
|
14215
14215
|
// If user disconnected
|
|
14216
14216
|
if (!account.isConnected && storedAddress) {
|
|
14217
14217
|
this.handleWalletDisconnect();
|
|
@@ -14221,7 +14221,7 @@ class MagicWidgetExtension extends Extension.Internal {
|
|
|
14221
14221
|
}
|
|
14222
14222
|
// Account changed
|
|
14223
14223
|
if (account.address && account.address !== storedAddress) {
|
|
14224
|
-
localStorage.setItem(
|
|
14224
|
+
localStorage.setItem(_.ADDRESS, account.address);
|
|
14225
14225
|
this.sdk.rpcProvider.emit('accountsChanged', [account.address]);
|
|
14226
14226
|
this.dispatchWalletUpdate({
|
|
14227
14227
|
chain: account.chain,
|
|
@@ -14232,7 +14232,7 @@ class MagicWidgetExtension extends Extension.Internal {
|
|
|
14232
14232
|
}
|
|
14233
14233
|
// Chain changed
|
|
14234
14234
|
if (account.chainId && account.chainId.toString() !== storedChainId) {
|
|
14235
|
-
localStorage.setItem(
|
|
14235
|
+
localStorage.setItem(_.CHAIN_ID, account.chainId.toString());
|
|
14236
14236
|
this.sdk.rpcProvider.emit('chainChanged', account.chainId);
|
|
14237
14237
|
this.dispatchWalletUpdate({
|
|
14238
14238
|
chain: account.chain,
|
|
@@ -14257,7 +14257,7 @@ class MagicWidgetExtension extends Extension.Internal {
|
|
|
14257
14257
|
this.sdk.thirdPartyWallets.resetThirdPartyWalletState();
|
|
14258
14258
|
this.sdk.rpcProvider.emit('accountsChanged', []);
|
|
14259
14259
|
try {
|
|
14260
|
-
const logoutPayload = this.utils.createJsonRpcRequestPayload(
|
|
14260
|
+
const logoutPayload = this.utils.createJsonRpcRequestPayload(g.Logout, []);
|
|
14261
14261
|
await this.request(logoutPayload);
|
|
14262
14262
|
}
|
|
14263
14263
|
catch (error) {
|
|
@@ -14502,7 +14502,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14502
14502
|
const submitOTP = useCallback((otp) => {
|
|
14503
14503
|
if (handleRef.current) {
|
|
14504
14504
|
dispatch({ type: 'EMAIL_OTP_VERIFYING' });
|
|
14505
|
-
handleRef.current.emit(
|
|
14505
|
+
handleRef.current.emit(y.VerifyEmailOtp, otp);
|
|
14506
14506
|
}
|
|
14507
14507
|
}, [dispatch]);
|
|
14508
14508
|
/**
|
|
@@ -14511,7 +14511,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14511
14511
|
const submitMFA = useCallback((totp) => {
|
|
14512
14512
|
if (handleRef.current) {
|
|
14513
14513
|
dispatch({ type: 'MFA_VERIFYING' });
|
|
14514
|
-
handleRef.current.emit(
|
|
14514
|
+
handleRef.current.emit(y.VerifyMFACode, totp);
|
|
14515
14515
|
}
|
|
14516
14516
|
}, [dispatch]);
|
|
14517
14517
|
/**
|
|
@@ -14520,7 +14520,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14520
14520
|
const lostDevice = useCallback(() => {
|
|
14521
14521
|
if (handleRef.current) {
|
|
14522
14522
|
dispatch({ type: 'LOST_DEVICE' });
|
|
14523
|
-
handleRef.current.emit(
|
|
14523
|
+
handleRef.current.emit(y.LostDevice);
|
|
14524
14524
|
}
|
|
14525
14525
|
}, [dispatch]);
|
|
14526
14526
|
/**
|
|
@@ -14529,7 +14529,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14529
14529
|
const submitRecoveryCode = useCallback((recoveryCode) => {
|
|
14530
14530
|
if (handleRef.current) {
|
|
14531
14531
|
dispatch({ type: 'RECOVERY_CODE_VERIFYING' });
|
|
14532
|
-
handleRef.current.emit(
|
|
14532
|
+
handleRef.current.emit(y.VerifyRecoveryCode, recoveryCode);
|
|
14533
14533
|
}
|
|
14534
14534
|
}, [dispatch]);
|
|
14535
14535
|
/**
|
|
@@ -14537,7 +14537,7 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14537
14537
|
*/
|
|
14538
14538
|
const cancelLogin = useCallback(() => {
|
|
14539
14539
|
if (handleRef.current) {
|
|
14540
|
-
handleRef.current.emit(
|
|
14540
|
+
handleRef.current.emit(y.Cancel);
|
|
14541
14541
|
}
|
|
14542
14542
|
handleRef.current = null;
|
|
14543
14543
|
emailRef.current = null;
|
|
@@ -14548,13 +14548,13 @@ function EmailLoginProvider({ children, dispatch }) {
|
|
|
14548
14548
|
*/
|
|
14549
14549
|
const retryDeviceVerification = useCallback(() => {
|
|
14550
14550
|
if (handleRef.current) {
|
|
14551
|
-
handleRef.current.emit(
|
|
14551
|
+
handleRef.current.emit(C.Retry);
|
|
14552
14552
|
}
|
|
14553
14553
|
}, []);
|
|
14554
14554
|
const resendEmailOTP = useCallback(() => {
|
|
14555
14555
|
const email = emailRef.current;
|
|
14556
14556
|
if (handleRef.current) {
|
|
14557
|
-
handleRef.current.emit(
|
|
14557
|
+
handleRef.current.emit(y.Cancel);
|
|
14558
14558
|
}
|
|
14559
14559
|
handleRef.current = null;
|
|
14560
14560
|
emailRef.current = null;
|