@0xsequence/provider 0.42.6 → 0.42.8

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.
@@ -1769,6 +1769,7 @@ const recoverWalletConfig = async (address, digest, signature, chainId, walletCo
1769
1769
  return config$1;
1770
1770
  };
1771
1771
  const isBrowserExtension = () => window.location.protocol === 'chrome-extension:' || window.location.protocol === 'moz-extension:';
1772
+ const isUnityPlugin = () => !!navigator.userAgent.match(/UnitySequence/i);
1772
1773
  /**
1773
1774
  * Returns the status of a signer's wallet on given chain by checking wallet deployment and config status
1774
1775
  *
@@ -2746,7 +2747,7 @@ class WindowMessageProvider extends BaseProviderTransport {
2746
2747
  if (!intent.options) intent.options = {}; // skip setting origin host if we're in an browser extension execution context
2747
2748
  // allow origin that is passed in
2748
2749
 
2749
- if (!isBrowserExtension()) {
2750
+ if (!isBrowserExtension() && !isUnityPlugin()) {
2750
2751
  intent.options.origin = window.location.origin;
2751
2752
  }
2752
2753
  } // encode intent as base64 url-encoded param
@@ -4116,6 +4117,7 @@ exports.getWallet = getWallet;
4116
4117
  exports.initWallet = initWallet;
4117
4118
  exports.isBrowserExtension = isBrowserExtension;
4118
4119
  exports.isSequenceProvider = isSequenceProvider;
4120
+ exports.isUnityPlugin = isUnityPlugin;
4119
4121
  exports.isValidMessageSignature = isValidMessageSignature;
4120
4122
  exports.isValidSignature = isValidSignature;
4121
4123
  exports.isValidTypedDataSignature = isValidTypedDataSignature;
@@ -1769,6 +1769,7 @@ const recoverWalletConfig = async (address, digest, signature, chainId, walletCo
1769
1769
  return config$1;
1770
1770
  };
1771
1771
  const isBrowserExtension = () => window.location.protocol === 'chrome-extension:' || window.location.protocol === 'moz-extension:';
1772
+ const isUnityPlugin = () => !!navigator.userAgent.match(/UnitySequence/i);
1772
1773
  /**
1773
1774
  * Returns the status of a signer's wallet on given chain by checking wallet deployment and config status
1774
1775
  *
@@ -2746,7 +2747,7 @@ class WindowMessageProvider extends BaseProviderTransport {
2746
2747
  if (!intent.options) intent.options = {}; // skip setting origin host if we're in an browser extension execution context
2747
2748
  // allow origin that is passed in
2748
2749
 
2749
- if (!isBrowserExtension()) {
2750
+ if (!isBrowserExtension() && !isUnityPlugin()) {
2750
2751
  intent.options.origin = window.location.origin;
2751
2752
  }
2752
2753
  } // encode intent as base64 url-encoded param
@@ -4116,6 +4117,7 @@ exports.getWallet = getWallet;
4116
4117
  exports.initWallet = initWallet;
4117
4118
  exports.isBrowserExtension = isBrowserExtension;
4118
4119
  exports.isSequenceProvider = isSequenceProvider;
4120
+ exports.isUnityPlugin = isUnityPlugin;
4119
4121
  exports.isValidMessageSignature = isValidMessageSignature;
4120
4122
  exports.isValidSignature = isValidSignature;
4121
4123
  exports.isValidTypedDataSignature = isValidTypedDataSignature;
@@ -1765,6 +1765,7 @@ const recoverWalletConfig = async (address, digest, signature, chainId, walletCo
1765
1765
  return config;
1766
1766
  };
1767
1767
  const isBrowserExtension = () => window.location.protocol === 'chrome-extension:' || window.location.protocol === 'moz-extension:';
1768
+ const isUnityPlugin = () => !!navigator.userAgent.match(/UnitySequence/i);
1768
1769
  /**
1769
1770
  * Returns the status of a signer's wallet on given chain by checking wallet deployment and config status
1770
1771
  *
@@ -2742,7 +2743,7 @@ class WindowMessageProvider extends BaseProviderTransport {
2742
2743
  if (!intent.options) intent.options = {}; // skip setting origin host if we're in an browser extension execution context
2743
2744
  // allow origin that is passed in
2744
2745
 
2745
- if (!isBrowserExtension()) {
2746
+ if (!isBrowserExtension() && !isUnityPlugin()) {
2746
2747
  intent.options.origin = window.location.origin;
2747
2748
  }
2748
2749
  } // encode intent as base64 url-encoded param
@@ -4081,4 +4082,4 @@ const getWallet = () => {
4081
4082
  return walletInstance;
4082
4083
  };
4083
4084
 
4084
- export { BaseInjectedTransport, BaseProviderTransport, BaseWalletTransport, CHANNEL_ID, DefaultProviderConfig, ErrSignedInRequired, EventType, ExtensionMessageHandler, ExtensionMessageProvider, InitState, LocalStorage, LocalStore, LocalWeb3Provider, MuxMessageProvider, OpenState, PROVIDER_OPEN_TIMEOUT, ProviderError, ProxyMessageChannel, ProxyMessageChannelPort, ProxyMessageHandler, ProxyMessageProvider, UnrealMessageHandler, UnrealMessageProvider, Wallet, WalletRequestHandler, Web3Provider, Web3Signer, WindowMessageHandler, WindowMessageProvider, WindowSessionParams, getWallet, initWallet, isBrowserExtension, isSequenceProvider, isValidMessageSignature, isValidSignature, isValidTypedDataSignature, isWalletUpToDate, messageToBytes, nextMessageIdx, prefixEIP191Message, recoverWalletConfig };
4085
+ export { BaseInjectedTransport, BaseProviderTransport, BaseWalletTransport, CHANNEL_ID, DefaultProviderConfig, ErrSignedInRequired, EventType, ExtensionMessageHandler, ExtensionMessageProvider, InitState, LocalStorage, LocalStore, LocalWeb3Provider, MuxMessageProvider, OpenState, PROVIDER_OPEN_TIMEOUT, ProviderError, ProxyMessageChannel, ProxyMessageChannelPort, ProxyMessageHandler, ProxyMessageProvider, UnrealMessageHandler, UnrealMessageProvider, Wallet, WalletRequestHandler, Web3Provider, Web3Signer, WindowMessageHandler, WindowMessageProvider, WindowSessionParams, getWallet, initWallet, isBrowserExtension, isSequenceProvider, isUnityPlugin, isValidMessageSignature, isValidSignature, isValidTypedDataSignature, isWalletUpToDate, messageToBytes, nextMessageIdx, prefixEIP191Message, recoverWalletConfig };
@@ -164,6 +164,14 @@ export interface Settings {
164
164
  * Note that this setting will not be persisted, use wallet.open with 'openWithOptions' intent
165
165
  * to set when you open the wallet for user. */
166
166
  lockFundingCurrencyToDefault?: boolean;
167
+ /** Specify an email address to allow user automatically sign in with the email option.
168
+ * Will be ignored if user is already signed in.
169
+ */
170
+ signInWithEmail?: string;
171
+ /** Specify which sign in options are allowed.
172
+ * Will be ignored if user is already signed in.
173
+ */
174
+ signInOptions?: SignInOption[];
167
175
  /** Specify auxiliary data
168
176
  */
169
177
  aux?: any;
@@ -174,6 +182,7 @@ export interface Settings {
174
182
  export declare type ThemeOption = 'light' | 'dark' | string;
175
183
  export declare type PaymentProviderOption = 'moonpay' | 'wyre' | 'ramp';
176
184
  export declare type CurrencyOption = 'usdc' | 'eth' | 'matic';
185
+ export declare type SignInOption = 'email' | 'google' | 'apple' | 'facebook' | 'discord' | 'twitch';
177
186
  export interface ConnectDetails {
178
187
  chainId?: string;
179
188
  error?: string;
@@ -11,6 +11,7 @@ export declare const isValidMessageSignature: (address: string, message: string
11
11
  export declare const isValidTypedDataSignature: (address: string, typedData: TypedData, signature: string, provider: Web3Provider | ethers.providers.Web3Provider, chainId?: number | undefined, walletContext?: WalletContext | undefined) => Promise<boolean | undefined>;
12
12
  export declare const recoverWalletConfig: (address: string, digest: BytesLike, signature: string | DecodedSignature, chainId: BigNumberish, walletContext?: WalletContext | undefined) => Promise<WalletConfig>;
13
13
  export declare const isBrowserExtension: () => boolean;
14
+ export declare const isUnityPlugin: () => boolean;
14
15
  /**
15
16
  * Returns the status of a signer's wallet on given chain by checking wallet deployment and config status
16
17
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/provider",
3
- "version": "0.42.6",
3
+ "version": "0.42.8",
4
4
  "description": "provider sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
6
6
  "source": "src/index.ts",
@@ -13,13 +13,13 @@
13
13
  "typecheck": "tsc --noEmit"
14
14
  },
15
15
  "dependencies": {
16
- "@0xsequence/abi": "^0.42.6",
17
- "@0xsequence/auth": "^0.42.6",
18
- "@0xsequence/config": "^0.42.6",
19
- "@0xsequence/network": "^0.42.6",
20
- "@0xsequence/transactions": "^0.42.6",
21
- "@0xsequence/utils": "^0.42.6",
22
- "@0xsequence/wallet": "^0.42.6",
16
+ "@0xsequence/abi": "^0.42.8",
17
+ "@0xsequence/auth": "^0.42.8",
18
+ "@0xsequence/config": "^0.42.8",
19
+ "@0xsequence/network": "^0.42.8",
20
+ "@0xsequence/transactions": "^0.42.8",
21
+ "@0xsequence/utils": "^0.42.8",
22
+ "@0xsequence/wallet": "^0.42.8",
23
23
  "@ethersproject/abstract-signer": "^5.5.0",
24
24
  "@ethersproject/hash": "^5.5.0",
25
25
  "@ethersproject/providers": "^5.5.1",
@@ -1,7 +1,7 @@
1
1
  import { OpenWalletIntent, ProviderMessage, InitState, EventType, WindowSessionParams } from '../../types'
2
2
  import { BaseProviderTransport } from '../base-provider-transport'
3
3
  import { logger, base64EncodeObject } from '@0xsequence/utils'
4
- import { isBrowserExtension } from '../../utils'
4
+ import { isBrowserExtension, isUnityPlugin } from '../../utils'
5
5
 
6
6
  // ..
7
7
  let registeredWindowMessageProvider: WindowMessageProvider | undefined
@@ -92,7 +92,7 @@ export class WindowMessageProvider extends BaseProviderTransport {
92
92
 
93
93
  // skip setting origin host if we're in an browser extension execution context
94
94
  // allow origin that is passed in
95
- if (!isBrowserExtension()) {
95
+ if (!isBrowserExtension() && !isUnityPlugin()) {
96
96
  intent.options.origin = window.location.origin
97
97
  }
98
98
  }
package/src/types.ts CHANGED
@@ -210,6 +210,16 @@ export interface Settings {
210
210
  * to set when you open the wallet for user. */
211
211
  lockFundingCurrencyToDefault?: boolean
212
212
 
213
+ /** Specify an email address to allow user automatically sign in with the email option.
214
+ * Will be ignored if user is already signed in.
215
+ */
216
+ signInWithEmail?: string
217
+
218
+ /** Specify which sign in options are allowed.
219
+ * Will be ignored if user is already signed in.
220
+ */
221
+ signInOptions?: SignInOption[]
222
+
213
223
  /** Specify auxiliary data
214
224
  */
215
225
  aux?: any
@@ -221,6 +231,7 @@ export interface Settings {
221
231
  export type ThemeOption = 'light' | 'dark' | string
222
232
  export type PaymentProviderOption = 'moonpay' | 'wyre' | 'ramp'
223
233
  export type CurrencyOption = 'usdc' | 'eth' | 'matic'
234
+ export type SignInOption = 'email' | 'google' | 'apple' | 'facebook' | 'discord' | 'twitch'
224
235
 
225
236
  export interface ConnectDetails {
226
237
  // chainId (in hex) and error are defined by EIP-1193 expected fields
package/src/utils.ts CHANGED
@@ -86,6 +86,8 @@ export const recoverWalletConfig = async (
86
86
  export const isBrowserExtension = (): boolean =>
87
87
  window.location.protocol === 'chrome-extension:' || window.location.protocol === 'moz-extension:'
88
88
 
89
+ export const isUnityPlugin = (): boolean => !!navigator.userAgent.match(/UnitySequence/i)
90
+
89
91
  /**
90
92
  * Returns the status of a signer's wallet on given chain by checking wallet deployment and config status
91
93
  *