Methods
async Authenticate({token})
Authenticate with an ElvWalletClient authorization token
Parameters:
Name | Type | Description |
---|---|---|
token |
string |
A previously generated ElvWalletClient authorization token; |
async AuthenticateExternalWallet({address,tokenDurationoptional,walletNameoptional,Signoptional}) → Promise.<string>
Authenticate with an external Ethereum compatible wallet, like Metamask.
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. |
async AuthenticateOAuth({idToken,tenantIdoptional,emailoptional,signerURIsoptional,shareEmailoptional}) → Promise.<Object>
Authenticate with an OAuth ID token
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 |
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.
ClientAuthToken() → string
Requires login
Retrieve the current client auth token
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.
|
provider |
string |
<optional> |
If logging in via a specific method, specify the provider and mode. Options: |
|
mode |
string |
<optional> |
If logging in via a specific method, specify the mode. Options |
|
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.
async LogOut()
Remove authorization for the current user.
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.
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.
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 ( |
|
mode |
string | production |
Environment to use ( |
|
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 |