TorqueUserModule

@torque-labs/sdk


@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): TorqueUserModule

Defined in: sdk/src/modules/user.ts:124

Parameters

Parameter
Type

url

string

signer

| Adapter | Keypair | PrivySolanaWallet

connection

Connection

Returns

TorqueUserModule

Properties

Property
Type
Description

_connection

Connection

The solana connection RPC endpoint

_signer

| Adapter | Keypair | PrivySolanaWallet

The user's wallet/signer for Solana

_token

undefined | string

The user's auth token for the API

apiUrl

string

The base URL of the Torque API

currentUser

The current user

Accessors

token

Get Signature

get token(): undefined | string

Defined in: sdk/src/modules/user.ts:133

Get the auth token

Returns

undefined | string

Set Signature

set token(value): void

Defined in: sdk/src/modules/user.ts:140

Set the auth token

Parameters

Parameter
Type

value

undefined | string

Returns

void

Methods

createOffchainReward()

createOffchainReward(data): Promise<OffchainRewardResponse>

Defined in: sdk/src/modules/user.ts:391

Create offchain reward

Parameters

Parameter
Type
Description

data

The offchain reward data

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

Parameter
Type
Description

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

Parameter
Type

userId?

string

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

Parameter
Type
Description

options?

The authentication options

authInput?

The login input object if you want to manually handle the login process

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

Parameter
Type
Description

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

Parameter
Type
Description

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

Parameter
Type
Description

params

The authentication input object

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

Parameter
Type
Description

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

Name
Type

expirationTime

string

issuedAt

string

statement

string

uri

string

Last updated