Skip to main content

ElvWalletClient

Use the Initialize method to initialize a new client.

See the Modules section on the sidebar for all client methods unrelated to login and authorization

Authenticate

Authenticate({ token })

Authenticate with an ElvWalletClient authorization token

Parameters

NameTypeRequiredDescription
tokenstring

A previously generated ElvWalletClient authorization token;

AuthenticateExternalWallet

AuthenticateExternalWallet({
  address,
  tokenDuration, // optional
  walletName, // optional
  Sign // optional
}) → Promise.<string>

Authenticate with an external Ethereum compatible wallet, like Metamask.

Returns: Returns an authorization token that can be used to initialize the client using Authenticate. Save this token to avoid having to reauthenticate. This token expires after 24 hours.

Parameters

NameTypeRequiredDescription
addressstring

The address of the wallet

tokenDurationnumber

Number of hours the generated authorization token will last before expiring

(default: 24)
walletNamestring

Name of the external wallet

(default: Metamask)
Signfunction

The method used for signing by the wallet. If not specified, will attempt to sign with Metamask.

AuthenticateOAuth

AuthenticateOAuth({
  idToken,
  tenantId, // optional
  email, // optional
  signerURIs, // optional
  shareEmail, // optional
  tokenDuration // optional
}) → Promise.<Object>

Authenticate with an OAuth ID token

Returns: Returns an authorization tokens that can be used to initialize the client using Authenticate. Save this token to avoid having to reauthenticate with OAuth. This token expires after 24 hours. The result includes two tokens: token - Standard client auth token used to access content and perform actions on behalf of the user. signingToken - Identical to authToken, but also includes the ability to perform arbitrary signatures with the custodial wallet. This token should be protected and should not be shared with third parties.

Parameters

NameTypeRequiredDescription
idTokenstring

An OAuth ID token

tenantIdstring

ID of tenant with which to associate the user. If marketplace info was set upon initialization, this will be determined automatically.

emailstring

Email address of the user. If not specified, this method will attempt to extract the email from the ID token.

signerURIsArray.<string>

(Only if using custom OAuth) - URIs corresponding to the key server(s) to use

shareEmailboolean

Whether or not the user consents to sharing their email

(default: false)
tokenDurationnumber

Token expiration duration, in hours

(default: 24)

CanSign

CanSign() → boolean

Check if this client can sign without opening a popup.

Generally, Eluvio custodial wallet users will require a popup prompt, while Metamask and custom OAuth users will not.

Returns: Whether or not this client can sign a message without a popup.

ClientAuthToken

ClientAuthToken() → string

Requires login

Retrieve the current client auth token

Returns: The client auth token

Initialize

Initialize({
  appId,
  network,
  mode,
  marketplaceParams, // optional
  storeAuthToken, // optional
  client // optional
}) → Promise.<ElvWalletClient>

Initialize the wallet client.

Specify tenantSlug and marketplaceSlug to automatically associate this tenant with a particular marketplace.

Parameters

NameTypeRequiredDescription
appIdstring

A string identifying your app. This is used for namespacing user profile data.

networkstring

Name of the Fabric network to use (main, demo)

(default: main)
modestring

Environment to use (production, staging)

(default: production)
marketplaceParamsObject

Marketplace parameters

storeAuthTokenboolean

If specified, auth tokens will be stored in localstorage (if available)

(default: true)
clientObject

Existing instance of ElvClient to use instead of initializing a new one

LogIn

LogIn({
  method, // optional
  provider, // optional
  mode, // optional
  callbackUrl, // optional
  marketplaceParams, // optional
  clearLogin // optional
})

Direct the user to the Eluvio Media Wallet login page.

For redirect login, the authorization token will be included in the URL parameters of the callbackUrl. Simply re-initialize the wallet client and it will authorize with this token, or you can retrieve the parameter (elvToken) yourself and use it in the Authenticate method.

NOTE: The domain of the opening window (popup flow) or domain of the callbackUrl (redirect flow) MUST be allowed in the metadata of the specified marketplace.

Parameters

NameTypeRequiredDescription
methodstring

How to present the login page.

  • redirect - Redirect to the wallet login page. Upon login, the page will be redirected back to the specified redirectUrl with the authorization token.
  • popup - Open the wallet login page in a new tab. Upon login, authorization information will be sent back to the client via message and the tab will be closed.
(default: redirect)
providerstring

If logging in via a specific method, specify the provider and mode. Options: oauth, metamask

modestring

If logging in via a specific method, specify the mode. Options login (Log In), create (Sign Up)

callbackUrlstring

If using the redirect flow, the URL to redirect back to after login.

marketplaceParamsObject

Parameters of a marketplace to associate the login with. If not specified, the marketplace parameters used upon client initialization will be used. A marketplace is required when using the redirect flow.

clearLoginboolean

If specified, the user will be prompted to log in anew even if they are already logged in on the Eluvio Media Wallet app

(default: false)

LogOut

LogOut()

Remove authorization for the current user.

PersonalSign

PersonalSign({ message }) → Promise.<string>

Requires login

Request the current user sign the specified message.

If this client is not able to perform the signature (Eluvio custodial OAuth users), a popup will be opened and the user will be prompted to sign.

To check if the signature can be done without a popup, use the CanSign method.

Returns: The signature of the message

Parameters

NameTypeRequiredDescription
messagestring

The message to sign