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 with an ElvWalletClient authorization token
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
token | string | ✓ | A previously generated ElvWalletClient authorization token; |
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
| Name | Type | Required | Description |
|---|---|---|---|
address | string | ✓ | The address of the wallet |
tokenDuration | number | Number of hours the generated authorization token will last before expiring (default:24) | |
walletName | string | Name of the external wallet (default:Metamask) | |
Sign | function | The method used for signing by the wallet. If not specified, will attempt to sign with Metamask. |
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
| Name | Type | Required | Description |
|---|---|---|---|
idToken | string | ✓ | An OAuth ID token |
tenantId | string | ID of tenant with which to associate the user. If marketplace info was set upon initialization, this will be determined automatically. | |
email | string | Email address of the user. If not specified, this method will attempt to extract the email from the ID token. | |
signerURIs | Array.<string> | (Only if using custom OAuth) - URIs corresponding to the key server(s) to use | |
shareEmail | boolean | Whether or not the user consents to sharing their email (default:false) | |
tokenDuration | number | Token expiration duration, in hours (default:24) |
CanSign
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
Requires login
Retrieve the current client auth token
Returns: The client auth token
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
| Name | Type | Required | Description |
|---|---|---|---|
appId | string | ✓ | A string identifying your app. This is used for namespacing user profile data. |
network | string | ✓ | Name of the Fabric network to use ( main) |
mode | string | ✓ | Environment to use ( production) |
marketplaceParams | Object | Marketplace parameters | |
storeAuthToken | boolean | If specified, auth tokens will be stored in localstorage (if available) (default:true) | |
client | Object | Existing instance of ElvClient to use instead of initializing a new one |
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
| Name | Type | Required | Description |
|---|---|---|---|
method | string | How to present the login page.
redirect) | |
provider | string | If logging in via a specific method, specify the provider and mode. Options: | |
mode | string | If logging in via a specific method, specify the mode. Options | |
callbackUrl | string | If using the redirect flow, the URL to redirect back to after login. | |
marketplaceParams | Object | 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 | 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
Remove authorization for the current user.
PersonalSign
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 | Required | Description |
|---|---|---|---|
message | string | ✓ | The message to sign |