TorqueUserModule
@torque-labs/sdk / TorqueUserModule
Class: TorqueUserModule
Defined in: sdk/src/modules/user.ts:98
The TorqueUserModule class is used to handle user authentication for the Torque SDK as well as user management.
Param
The URL of the Torque API server
Param
The signer for the user
Param
The connection to the Solana network
Constructors
new TorqueUserModule()
new TorqueUserModule(
url,
signer,
connection): TorqueUserModuleDefined in: sdk/src/modules/user.ts:124
Parameters
Returns
TorqueUserModule
Properties
_connection
Connection
The solana connection RPC endpoint
_token
undefined | string
The user's auth token for the API
apiUrl
string
The base URL of the Torque API
Accessors
token
Get Signature
get token(): undefined | stringDefined in: sdk/src/modules/user.ts:133
Get the auth token
Returns
undefined | string
Set Signature
set token(value): voidDefined in: sdk/src/modules/user.ts:140
Set the auth token
Parameters
value
undefined | string
Returns
void
Methods
createOffchainReward()
createOffchainReward(data): Promise<OffchainRewardResponse>Defined in: sdk/src/modules/user.ts:391
Create offchain reward
Parameters
Returns
Promise<OffchainRewardResponse>
The created offchain reward
deleteOffchainReward()
deleteOffchainReward(offchainrewardid): Promise<{
message: string;
}>Defined in: sdk/src/modules/user.ts:415
Delete offchain reward
Parameters
offchainRewardId
string
The id of the offchain reward to delete
Returns
Promise<{message: string;
}>
The deleted offchain reward
getBadges()
getBadges(): Promise<UserBadgeResponse & {
badge: OffchainRewardResponse;
}[]>Defined in: sdk/src/modules/user.ts:455
Get the user's badges
Returns
Promise<UserBadgeResponse & {badge: OffchainRewardResponse;
}[]>
The user's badges
getCurrentUser()
getCurrentUser(): Promise<UserWithConnectedAccounts>Defined in: sdk/src/modules/user.ts:353
Get the current user
Returns
Promise<UserWithConnectedAccounts>
The current user
getOffchainRewards()
getOffchainRewards(userid?, type?): Promise<OffchainRewardResponse[]>Defined in: sdk/src/modules/user.ts:428
Get all offchain rewards
Parameters
userId?
string
type?
Returns
Promise<OffchainRewardResponse[]>
All offchain rewards
login()
login(options?, authinput?): Promise<undefined | string>Defined in: sdk/src/modules/user.ts:154
Authenticate the user with the API using the provided login data.
Parameters
Returns
Promise<undefined | string>
The auth token for the API
Throws
If the authentication fails
logout()
logout(): Promise<void>Defined in: sdk/src/modules/user.ts:262
Logout the user from the API.
Returns
Promise<void>
setOffchainAllocationEndpoint()
setOffchainAllocationEndpoint(endpoint): Promise<void>Defined in: sdk/src/modules/user.ts:335
Set offchain allocation endpoint
Parameters
endpoint
string
The offchain allocation endpoint
Returns
Promise<void>
setXTokens()
setXTokens(
xAccessToken,
xRefreshToken,
privyAccessToken,
privyIdentityToken,
accessTokenExpiresInSeconds): Promise<void>Defined in: sdk/src/modules/user.ts:482
Set the user's X tokens
Parameters
xAccessToken
string
The user's X access token
xRefreshToken
string
The user's X refresh token
privyAccessToken
string
The user's Privy access token
privyIdentityToken
string
The user's Privy identity token
accessTokenExpiresInSeconds
number
The user's X access token expiry in seconds
Returns
Promise<void>
constructLoginBody()
static constructLoginBody(params):
| undefined
| {
authType: "siws";
payload: {
input: SolanaSignInInput;
output: SolanaSignInOutput;
};
pubKey: string;
}
| {
authType: "basic";
payload: {
input: string;
output: string;
};
pubKey: string;
}Defined in: sdk/src/modules/user.ts:298
Constructs the body for the login API request based on the authentication type.
Parameters
Returns
| undefined
| {authType: "siws";payload: {input: SolanaSignInInput;output: SolanaSignInOutput;
};pubKey: string;
}
| {authType: "basic";payload: {input: string;output: string;
};pubKey: string;
}
The constructed body for the verify API request, formatted based on the authentication type.
getLoginPayload()
static getLoginPayload(uri): {
expirationTime: string;
issuedAt: string;
statement: string;
uri: string;
}Defined in: sdk/src/modules/user.ts:274
Get the default login payload/message to be signed for authentication.
Parameters
uri
string
URL to use for the login payload. Defaults to https://app.torque.so.
Returns
{
expirationTime: string;
issuedAt: string;
statement: string;
uri: string;
}The login payload to be signed for authentication
expirationTime
string
issuedAt
string
statement
string
uri
string
Last updated
