Account Service¶
The Account Service allows you to create and sign in to accounts.
Wallets vs Accounts
Wallets and accounts are related and often interchangeable -- each account has an associated wallet, and operations on a wallet are performed using an account's access token.
Every account has exactly one wallet.
Authentication Tokens
When you create or sign in to an account, the response is an authentication token string.
This string is an encoded form of your account profile, as well as an access key to perform calls using the account.
These are effectively API keys; they should be kept safe and never published.
Login¶
Attempts the first step of the login process for the specified account, creating it if it does not already exist.
Trinsic will response with a challenge
, and send an authentication code to the account's email address.
The authentication code must be passed along with challenge
to LoginConfirm to finalize the login.
trinsic account login --email "[email protected]" --ecosystem "<ecosystem id or name>"
const loginResponse = await trinsic.account().login(
LoginRequest.fromPartial({
ecosystemId: myEcosystemIdOrName(),
email: "[email protected]",
})
);
var loginResponse = await trinsic.Account.LoginAsync(new() {
// ecosystem id or name
EcosystemId = ecosystemId,
Email = "[email protected]"
});
login_response = await trinsic.account.login(
request=LoginRequest(
email="[email protected]", ecosystem_id="<ecosystem id or name>"
)
)
loginResponse, err := trinsic.Account().Login(context.Background(), &account.LoginRequest{
Email: "[email protected]",
EcosystemId: myEcosystemIdOrName,
})
var loginResponse =
trinsic
.account()
.login(
LoginRequest.newBuilder()
.setEmail("[email protected]")
.setEcosystemId(myEcosystemIdOrName)
.build())
.get();
invitation_code
is passed.LoginRequest
LoginConfirm
.Anonymous Login
Anonymous accounts are accounts which are not tied to any email or phone number, and do not require any authentication. They are typically used for testing and prototypes.
To create an anonymous account with an SDK, use the TrinsicService.LoginAnonymous()
method.
To create an anonymous account with the CLI, simply leave the email
parameter unspecified.
Login Confirm¶
Finalizes the login process.
You must pass challenge
as it was received in response to Login, along with the confirmation code that was sent in an email.
Our SDK will take care of hashing the confirmation code for you.
trinsic account login --email "[email protected]"
const authToken = await trinsic
.account()
.loginConfirm(loginResponse.challenge, "12345");
var authToken = await trinsic.Account.LoginConfirmAsync(loginResponse.Challenge, authCode);
auth_token = await trinsic.account.login_confirm(
challenge=login_response.challenge, auth_code="12345"
)
authToken, err := trinsic.Account().LoginConfirm(context.Background(), loginResponse.GetChallenge(), "12345")
var authToken = trinsic.account().loginConfirm(myLoginResponse.getChallenge(), "12345").get();
Login
LoginConfirmRequest
Get Account Info¶
Returns the account information (name, email address, phone number, etc.) used to create the currently-active account profile.
trinsic account info
const info = await accountService.info();
var info = await trinsic.Account.GetInfoAsync();
info = await service.get_info()
info2, err2 := trinsic.Account().GetInfo(context.Background())
var info = trinsic.account().getInfo().get();
issuer
when signing verifiable credentialsNote
This call returns the information associated with the authentication token used to create the request; therefore, it is not possible to pass a different authentication token to this call. Otherwise, Trinsic's zero-knowledge proof authentication scheme would be violated.
When using the CLI, this will return information for the account most recently logged in to.
When using the SDK, this will return information for the authentication token stored in the AccountService
instance's ServiceOptions.AuthToken
field, which will be the account most recently logged in to, unless you have manually set this value yourself.