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

Constructor

new ElvWalletClient()

Source:

Methods

async Authenticate({token})

Authenticate with an ElvWalletClient authorization token

Parameters:
Name Type Description
token string

A previously generated ElvWalletClient authorization token;

Source:

async AuthenticateExternalWallet({
address,
tokenDurationoptional,
walletNameoptional,
Signoptional
})
→ 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:
Name Type Attributes Default Description
address string

The address of the wallet

tokenDuration number <optional>
24

Number of hours the generated authorization token will last before expiring

walletName string <optional>
Metamask

Name of the external wallet

Sign function <optional>

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

Source:

async AuthenticateOAuth({
idToken,
tenantIdoptional,
emailoptional,
signerURIsoptional,
shareEmailoptional
})
→ 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:
Name Type Attributes Default Description
idToken string

An OAuth ID token

tenantId string <optional>

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

email string <optional>

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

signerURIs Array.<string> <optional>

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

shareEmail boolean <optional>
false

Whether or not the user consents to sharing their email

Source:

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.
Source:

ClientAuthToken() → string

Requires login

Retrieve the current client auth token

Returns: The client auth token
Source:

async LogIn({
methodoptional,
provideroptional,
modeoptional,
callbackUrloptional,
marketplaceParamsoptional,
clearLoginoptional
})

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:
Name Type Attributes Default Description
method string <optional>
redirect

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.
provider string <optional>

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

mode string <optional>

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

callbackUrl string <optional>

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

marketplaceParams Object <optional>

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.

clearLogin boolean <optional>
false

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

Throws:
  • If using the popup flow and the user closes the popup, this method will throw an error.
Source:

async LogOut()

Remove authorization for the current user.

Source:

async 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:
Name Type Description
message string

The message to sign

Throws:
  • If the user rejects the signature or closes the popup, an error will be thrown.
Source:

async, static Initialize({
appId,
network,
mode,
marketplaceParamsoptional,
storeAuthTokenoptional,
clientoptional
})
→ Promise.<ElvWalletClient>

Initialize the wallet client.

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

Parameters:
Name Type Attributes Default Description
appId string

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

network string main

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

mode string production

Environment to use (production, staging)

marketplaceParams Object <optional>

Marketplace parameters

storeAuthToken boolean <optional>
true

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

client Object <optional>

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

Source: