Class: TorqueUserClient
@torque-labs/torque-ts-sdk • Docs
@torque-labs/torque-ts-sdk / TorqueUserClient
Class: TorqueUserClient
The TorqueUserClient class is used to authenticate a user with the Torque API. The user client allows publishers to fetch campaigns and offers that are savailable for the current user.
Example
Constructors
new TorqueUserClient()
Create a new instance of the TorqueUserClient class with the publisher's handle, if provided.
Parameters
Returns
Throws
Throws an error if the user's wallet is not provided.
Defined in
Properties
Methods
acceptCampaign()
Initiate a user journey to accept a campaign for the current user.
Parameters
Returns
Promise
<ApiUserJourney
>
A Promise that resolves to the journey data for the campaign.
Throws
Throws an error if the client is not initialized or if there is an error accepting the campaign.
Defined in
authTelegram()
Links user's telegram account to their Torque account.
Parameters
Returns
Promise
<ApiTelegramAuth
>
The data associated with the shared link if the request is successful.
Throws
Throws an error there was an error getting the shared link data.
Defined in
confirmActionSignature()
Sends a signed message to the Torque API to confirm the user's signature for a requirement.
Parameters
Returns
Promise
<ActionPostResponse
>
A Solana action response that contains the next requirement.
Defined in
createCustomEvent()
Creates a new a custom event for the user's account which can be used for custom event requirements during a campaign.
Parameters
Returns
Promise
<{ id
: string
; }>
A Promise that resolves to the id of the new custom event.
Defined in
getAllUserShareLinks()
Fetches all of the user's share links that they have previously created.
Returns
Promise
<{ links
: { campaignId
: string
; url
: string
; }[]; }>
A Promise resolving to the URLs of the user's share links.
Throws
An error if the link fetch fails.
Defined in
getBountyStepAction()
Get the Solana action for a specific bounty/requirement step.
Parameters
Returns
Promise
<ActionPostResponse
>
The Solana Action response which contains the transaction.
Defined in
getCampaignJourney()
Retrieves the user's campaign journey for the specified campaign.
Parameters
Returns
Promise
<undefined
| ApiCampaignJourney
>
A Promise that resolves to the user's campaign journey.
Throws
Throws an error if the client is not initialized or if there is an error getting the journey.
Defined in
getCurrentUser()
Checks to see if the user is already logged into the Torque API.
Returns
Promise
<undefined
| ApiUser
>
A promise that resolves to the user if they are signed in, otherwise undefined.
Throws
Throws an error if checking the user's login status fails.
Defined in
getCustomEvents()
Fetches the user's custom events
Returns
Promise
<{ config
: Record
<string
, CustomEventFieldType
>; id
: string
; name
: string
; }[]>
A Promise that resolves to an array of custom events.
Throws
If the client is not initialized or there was an error fetching the custom events.
Defined in
getJourneys()
Retrieves the user's campaign journeys
Returns
Promise
<undefined
| ApiCampaignJourney
[]>
A Promise that resolves to the user's campaign journey.
Throws
Throws an error if the client is not initialized or if there is an error getting the journey.
Defined in
getMaxTransferableSpl()
Parameters
Returns
Promise
<number
>
Defined in
getOffers()
Retrieves a list of active campaigns from the Torque API that the user is eligible to participate in.
Parameters
Returns
Promise
<{ campaigns
: ApiCampaign
[]; }>
A Promise resolving to an array of ApiCampaign
objects representing the active campaigns.
Throws
An error if the fetch operation fails, or if the API returns a status other than "SUCCESS".
Defined in
getPublisherBalance()
Get the balance of the publisher PDA for the current user.
Returns
Promise
<number
>
The balance of the publisher PDA for the current user in lamports.
Defined in
getPublisherPda()
Get the publisher PDA for the current user.
Returns
undefined
| PublicKey
The publisher PDA for the current user.
Defined in
getSharedLinkData()
Retrieves the data for an offer link for a specific campaign and handle.
Parameters
Returns
Promise
<ApiShare
>
The data associated with the shared link if the request is successful.
Throws
Throws an error there was an error getting the shared link data.
Defined in
getUserHandle()
Retrieves the user's handle.
Returns
undefined
| string
The user's handle or undefined
if no handle is available.
Defined in
getUserPayout()
Retrieves user's payout history from conversions.
Returns
Promise
<ApiUserPayout
>
The data associated with the shared link if the request is successful.
Throws
Throws an error there was an error getting the shared link data.
Defined in
getUserShareLink()
Generates a URL for a user's shared link for a specific campaign.
Parameters
Returns
string
A promise that resolves to the URL string of the user's shared link for the campaign.
Throws
Throws an error if the user is not a publisher or does not have a handle.
Defined in
initializeUser()
Initializes the TorqueUserClient with the provided options.
Parameters
Returns
Promise
<ApiUser
>
A Promise that resolves when the initialization is complete.
Throws
If user was not verified.
Defined in
isPublisher()
Checks to see if the user is a publisher.
Returns
boolean
True if the user is a publisher, false otherwise.
Throws
Throws an error if the user is not signed in.
Defined in
login()
Authenticate the user with the torque API with the provided user signature object.
Parameters
Returns
Promise
<ApiUser
>
A Promise that resolves to an object containing the user information.
Throws
Throws an error if there is an error authenticating the user.
Defined in
logout()
Logout the user from the Torque API.
Returns
Promise
<{ cleared
: boolean
; }>
Throws
Throws an error if the client is not initialized or if there is an error logging out the user.
Defined in
refreshUser()
Rereshes the user's information from the Torque API.
Returns
Promise
<undefined
| ApiUser
>
A promise that resolves to the user if they are signed in, otherwise undefined.
Defined in
setUserPublisher()
Returns
void
Defined in
updateCustomEvent()
Updates an existing custom event for the user's account.
Parameters
Returns
Promise
<{ id
: string
; }>
A Promise that resolves to the id of the updated custom event.
Defined in
verifyCampaignAudience()
Verifies that the user is part of the audience for a specific campaign.
Parameters
Returns
Promise
<boolean
>
A Promise that resolves to true if the user is part of the audience for the campaign, false otherwise.
Defined in
Last updated