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 "bob@example.com"
const loginResponse = await trinsic.account().login(
LoginRequest.fromPartial({
email: "bob@example.com",
})
);
var loginResponse = await trinsic.Account.LoginAsync(new() {
EcosystemId = ecosystemId,
Email = "bob@example.com"
});
login_response = await trinsic.account.login(
request=LoginRequest(email="bob@example.com")
)
loginResponse, err := trinsic.Account().Login(context.Background(), &account.LoginRequest{
Email: "bob@example.com",
})
var loginResponse =
trinsic
.account()
.login(LoginRequest.newBuilder().setEmail("bob@example.com").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 "bob@example.com"
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(loginResponse.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.
Authorize Webhook¶
Authorizes the ecosystem provider to receive webhooks pertaining to this wallet.
trinsic account authorize-webhook --events "*"
const response = await trinsic.account().authorizeWebhook(
AuthorizeWebhookRequest.fromPartial({
events: ["*"], // Authorize all events
})
);
var request = new AuthorizeWebhookRequest();
request.Events.Add("*"); //Authorize all events
await trinsic.Account.AuthorizeWebhookAsync(request);
request = AuthorizeWebhookRequest()
request.events.append("*")
response = await trinsic.account.authorize_webhook(request=request)
request := &account.AuthorizeWebhookRequest{
Events: []string{"*"}, //Authorize all events
}
authResponse, err := trinsic.Account().AuthorizeWebhook(context.Background(), request)
var authorizeResponse =
trinsic
.account()
.authorizeWebhook(
AuthorizeWebhookRequest.newBuilder()
.addEvents("*") // Authorize all events
.build())
.get();
AuthorizeWebhookRequest
Protect Account Profile¶
Deprecated Sign-in Flow
This section is related to the the deprecated SignIn endpoint; the new Login flow does not require
the use of Protect
and Unprotect
.
Protects the specified account profile with a security code. It is not possible to execute this call using the CLI.
const protectedProfile = await accountService.protect(accountProfile, "1234");
var securityCode = "1234";
var myProtectedProfile = AccountService.Protect(myProfile, securityCode);
var myUnprotectedProfile = AccountService.Unprotect(myProtectedProfile, securityCode);
code = b"1234"
my_protected_profile = account_service.protect(
profile=my_profile, security_code=code
)
my_unprotected_profile = account_service.unprotect(
profile=my_protected_profile, security_code=code
)
securityCode := "1234"
protectedProfile, err := trinsic.Account().Protect(profile, securityCode)
if !assert2.Nil(err) {
return
}
unprotectedProfile, err := trinsic.Account().Unprotect(protectedProfile, securityCode)
if !assert2.Nil(err) {
return
}
var code = "1234";
var myProtectedProfile = AccountService.protect(myProfile, code);
var myUnprotectedProfile = AccountService.unprotect(myProtectedProfile, code);
Info
In this context, "protection" refers to a cryptographic operation on the authorization token for an account.
Protecting an account profile with code c
returns a new access token which is unusable until it is unprotected with the same code c
. It is not possible to reverse the protection process without the original protection code.
You will receive a protected account profile from Trinsic if you attempt to sign in to an account via email, SMS, or any other method which requires authentication. Trinsic will send a security code to the email or phone number associated with the account, which can be used to unprotect the account profile.
Specifically, Trinsic is using Oberon to handle access tokens; protection and unprotection is handled using the blinding/unblinding features of Oberon.
Unprotect Account Profile¶
Deprecated Sign-in Flow
This section is related to the the deprecated SignIn endpoint; the new Login flow does not require
the use of Protect
and Unprotect
.
Unprotects the specified account profile using the given code. It is not possible to execute this call using the CLI.
The profile must have been previously protected using the same code that is being used to unprotect it. Profiles can be protected using any arbitrary code via the Protect method.
Most commonly, this method is used on a protected profile received from the Sign In method. The code to unprotect it will have been sent to the account owner via email or SMS.
const accountProfile = await accountService.unprotect(protectedProfile, "1234");
var securityCode = "1234";
var myProtectedProfile = AccountService.Protect(myProfile, securityCode);
var myUnprotectedProfile = AccountService.Unprotect(myProtectedProfile, securityCode);
code = b"1234"
my_protected_profile = account_service.protect(
profile=my_profile, security_code=code
)
my_unprotected_profile = account_service.unprotect(
profile=my_protected_profile, security_code=code
)
securityCode := "1234"
protectedProfile, err := trinsic.Account().Protect(profile, securityCode)
if !assert2.Nil(err) {
return
}
unprotectedProfile, err := trinsic.Account().Unprotect(protectedProfile, securityCode)
if !assert2.Nil(err) {
return
}
var code = "1234";
var myProtectedProfile = AccountService.protect(myProfile, code);
var myUnprotectedProfile = AccountService.unprotect(myProtectedProfile, code);
[Deprecated] Sign In¶
Deprecated
This endpoint is deprecated, and will be removed in the near future.
Please use Login and LoginConfirm.
Sign in to an existing account, or create a new one.
If no account details are passed to this method, an anonymous account will be created.
trinsic account login --email <PROFILE_EMAIL> --name <PROFILE_NAME>
const allison = (await accountService.signIn()).getProfile();
var myProfile = await trinsic.Account.SignInAsync(new());
my_profile = await account_service.login_anonymous()
profile, err := trinsic.Account().LoginAnonymous(context.Background())
if !assert2.Nil(err) {
return
}
var myProfile = trinsic.account().signIn().get();
invitation_code
is passedThis operation, if successful, returns an authentication token string.
Protected Authentication Tokens
If you are attempting to login to a non-anonymous account (by specifying an email address or phone number), the authentication token returned will be protected, and cannot be used until it has been unprotected.
Trinsic will have sent a security code to the account's email address or phone number; this security code must be used with the Unprotect call to receive a usable authentication token.
In the future, we will provide an SDK call to determine if an authentication token is protected.