Documentation ¶
Index ¶
- func Init(turnkeyApiHost, turnkeyApiPrivateKey, organizationID string) error
- type CreateSubOrganizationResult
- type TurnkeyApiClient
- func (c *TurnkeyApiClient) CreateUserSubOrganization(userEmail string, attestation types.Attestation, challenge string) (*CreateSubOrganizationResult, error)
- func (c *TurnkeyApiClient) EmailAuth(subOrganizationId, email, targetPublicKey string) (string, string, error)
- func (c *TurnkeyApiClient) ForwardSignedActivity(url string, requestBody string, stamp types.TurnkeyStamp) ([]byte, error)
- func (c *TurnkeyApiClient) ForwardSignedRequest(url string, requestBody string, stamp types.TurnkeyStamp) (int, []byte, error)
- func (c *TurnkeyApiClient) GetAuthenticator() *sdk.Authenticator
- func (c *TurnkeyApiClient) GetEthereumAddress(organizationId, privateKeyId string) (string, error)
- func (c *TurnkeyApiClient) InitRecovery(subOrganizationId, email, targetPublicKey string) (string, error)
- func (c *TurnkeyApiClient) SignTransaction(organizationId string, signWith string, unsignedTransaction string) (string, error)
- func (c *TurnkeyApiClient) WaitForResult(organizationId, activityId string) (*models.Result, error)
- func (c *TurnkeyApiClient) Whoami() (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CreateSubOrganizationResult ¶
type CreateSubOrganizationResult struct { SubOrganizationId string WalletId string // Note: we _could_ create more than 1 address per sub-org // But we don't want to right now. EthereumAddress string }
Custom type to hold results from a sub-org creation result
type TurnkeyApiClient ¶
type TurnkeyApiClient struct { // APIKey is the structure APIKey *apikey.Key // Client is a raw TurnkeyAPI client Client *client.TurnkeyAPI // Organization is the default organization to be used for tests. OrganizationID string TurnkeyApiHost string }
var Client *TurnkeyApiClient
func (*TurnkeyApiClient) CreateUserSubOrganization ¶
func (c *TurnkeyApiClient) CreateUserSubOrganization(userEmail string, attestation types.Attestation, challenge string) (*CreateSubOrganizationResult, error)
This function creates a new sub-organization for a given user email. Turnkey's CREATE_SUB_ORGANIZATION activity supports creating a sub-org and private key(s) at once, atomically. We use this to our advantage here!
func (*TurnkeyApiClient) EmailAuth ¶
func (c *TurnkeyApiClient) EmailAuth(subOrganizationId, email, targetPublicKey string) (string, string, error)
Initiates email auth for a given sub-organization user
func (*TurnkeyApiClient) ForwardSignedActivity ¶
func (c *TurnkeyApiClient) ForwardSignedActivity(url string, requestBody string, stamp types.TurnkeyStamp) ([]byte, error)
TODO: should be part of the Go SDK! This function does something similar to `ForwardSignedRequest`, except it also polls until the activity is COMPLETE or FAILED If that's not the case after 3 attempts, give up.
func (*TurnkeyApiClient) ForwardSignedRequest ¶
func (c *TurnkeyApiClient) ForwardSignedRequest(url string, requestBody string, stamp types.TurnkeyStamp) (int, []byte, error)
Method to forward signed requests to Turnkey. TODO: should be part of the Go SDK!
func (*TurnkeyApiClient) GetAuthenticator ¶
func (c *TurnkeyApiClient) GetAuthenticator() *sdk.Authenticator
func (*TurnkeyApiClient) GetEthereumAddress ¶
func (c *TurnkeyApiClient) GetEthereumAddress(organizationId, privateKeyId string) (string, error)
Gets the Ethereum address for a private key ID created on Turnkey This is only used to pull one address: the warchest private key address
func (*TurnkeyApiClient) InitRecovery ¶
func (c *TurnkeyApiClient) InitRecovery(subOrganizationId, email, targetPublicKey string) (string, error)
Starts recovery for a given sub-organization The backend API key can do this because parent organizations are allowed to initiate recovery for their sub-orgs. Any (API) user which has the ability to perform ACTIVITY_TYPE_INIT_USER_EMAIL_RECOVERY in the parent can thus target the sub-organizations as well.
func (*TurnkeyApiClient) SignTransaction ¶
func (c *TurnkeyApiClient) SignTransaction(organizationId string, signWith string, unsignedTransaction string) (string, error)
Takes an unsigned ETH payload and tries to sign it. On success, the signed transaction is returned. On failure, an error is returned.
func (*TurnkeyApiClient) WaitForResult ¶
func (c *TurnkeyApiClient) WaitForResult(organizationId, activityId string) (*models.Result, error)
Utility to wait for an activity result
func (*TurnkeyApiClient) Whoami ¶
func (c *TurnkeyApiClient) Whoami() (string, error)