@proofchain/sdk 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +150 -5
- package/dist/index.d.ts +150 -5
- package/dist/index.js +112 -1
- package/dist/index.mjs +112 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1115,7 +1115,7 @@ interface UserWalletSummary {
|
|
|
1115
1115
|
};
|
|
1116
1116
|
}>;
|
|
1117
1117
|
}
|
|
1118
|
-
interface CreateWalletRequest {
|
|
1118
|
+
interface CreateWalletRequest$1 {
|
|
1119
1119
|
user_id: string;
|
|
1120
1120
|
wallet_type?: 'eoa' | 'smart' | 'solana';
|
|
1121
1121
|
network?: string;
|
|
@@ -1268,7 +1268,7 @@ declare class WalletClient {
|
|
|
1268
1268
|
/**
|
|
1269
1269
|
* Create a single wallet for a user
|
|
1270
1270
|
*/
|
|
1271
|
-
create(data: CreateWalletRequest): Promise<Wallet>;
|
|
1271
|
+
create(data: CreateWalletRequest$1): Promise<Wallet>;
|
|
1272
1272
|
/**
|
|
1273
1273
|
* Get a wallet by ID
|
|
1274
1274
|
*/
|
|
@@ -1562,6 +1562,7 @@ interface ListEndUsersOptions {
|
|
|
1562
1562
|
status?: string;
|
|
1563
1563
|
segment?: string;
|
|
1564
1564
|
has_wallet?: boolean;
|
|
1565
|
+
min_events?: number;
|
|
1565
1566
|
sort_by?: string;
|
|
1566
1567
|
sort_order?: 'asc' | 'desc';
|
|
1567
1568
|
}
|
|
@@ -1571,9 +1572,78 @@ interface LinkWalletRequest {
|
|
|
1571
1572
|
signature?: string;
|
|
1572
1573
|
}
|
|
1573
1574
|
interface MergeUsersRequest {
|
|
1574
|
-
|
|
1575
|
+
source_user_ids: string[];
|
|
1575
1576
|
target_user_id: string;
|
|
1576
1577
|
}
|
|
1578
|
+
interface CreateWalletRequest {
|
|
1579
|
+
wallet_type?: string;
|
|
1580
|
+
network?: string;
|
|
1581
|
+
}
|
|
1582
|
+
interface RegisterWalletRequest {
|
|
1583
|
+
wallet_address: string;
|
|
1584
|
+
signature?: string;
|
|
1585
|
+
}
|
|
1586
|
+
interface UserReward {
|
|
1587
|
+
id: string;
|
|
1588
|
+
reward_name: string;
|
|
1589
|
+
reward_type: string;
|
|
1590
|
+
value?: number;
|
|
1591
|
+
value_currency?: string;
|
|
1592
|
+
status: string;
|
|
1593
|
+
earned_at?: string;
|
|
1594
|
+
distributed_at?: string;
|
|
1595
|
+
nft_token_id?: number;
|
|
1596
|
+
nft_tx_hash?: string;
|
|
1597
|
+
}
|
|
1598
|
+
interface UserRewardsResponse {
|
|
1599
|
+
user_id: string;
|
|
1600
|
+
rewards: UserReward[];
|
|
1601
|
+
total: number;
|
|
1602
|
+
page: number;
|
|
1603
|
+
page_size: number;
|
|
1604
|
+
has_more: boolean;
|
|
1605
|
+
}
|
|
1606
|
+
interface GDPRDeletionRequest {
|
|
1607
|
+
confirm: boolean;
|
|
1608
|
+
delete_events?: boolean;
|
|
1609
|
+
delete_wallets?: boolean;
|
|
1610
|
+
reason?: string;
|
|
1611
|
+
}
|
|
1612
|
+
interface GDPRDeletionResponse {
|
|
1613
|
+
success: boolean;
|
|
1614
|
+
user_id: string;
|
|
1615
|
+
external_id: string;
|
|
1616
|
+
deleted_records: Record<string, number>;
|
|
1617
|
+
merkle_warning?: string;
|
|
1618
|
+
audit_id?: string;
|
|
1619
|
+
}
|
|
1620
|
+
interface GDPRPreviewResponse {
|
|
1621
|
+
user: Record<string, any>;
|
|
1622
|
+
would_delete: Record<string, number>;
|
|
1623
|
+
merkle_warning?: string;
|
|
1624
|
+
}
|
|
1625
|
+
interface WalletCreationResult {
|
|
1626
|
+
success: boolean;
|
|
1627
|
+
user_id: string;
|
|
1628
|
+
wallet_address: string;
|
|
1629
|
+
wallet_type?: string;
|
|
1630
|
+
network?: string;
|
|
1631
|
+
source: string;
|
|
1632
|
+
}
|
|
1633
|
+
interface SetProfileRequest {
|
|
1634
|
+
email?: string;
|
|
1635
|
+
first_name?: string;
|
|
1636
|
+
last_name?: string;
|
|
1637
|
+
display_name?: string;
|
|
1638
|
+
avatar_url?: string;
|
|
1639
|
+
phone?: string;
|
|
1640
|
+
date_of_birth?: string;
|
|
1641
|
+
country?: string;
|
|
1642
|
+
city?: string;
|
|
1643
|
+
timezone?: string;
|
|
1644
|
+
language?: string;
|
|
1645
|
+
bio?: string;
|
|
1646
|
+
}
|
|
1577
1647
|
declare class EndUsersClient {
|
|
1578
1648
|
private http;
|
|
1579
1649
|
constructor(http: HttpClient);
|
|
@@ -1622,9 +1692,84 @@ declare class EndUsersClient {
|
|
|
1622
1692
|
*/
|
|
1623
1693
|
merge(request: MergeUsersRequest): Promise<EndUser>;
|
|
1624
1694
|
/**
|
|
1625
|
-
* Update user
|
|
1695
|
+
* Update an end-user profile by internal UUID
|
|
1696
|
+
*/
|
|
1697
|
+
updateByInternalId(userId: string, data: UpdateEndUserRequest): Promise<EndUser>;
|
|
1698
|
+
/**
|
|
1699
|
+
* Get user rewards by external ID
|
|
1700
|
+
*/
|
|
1701
|
+
getRewards(externalId: string, options?: {
|
|
1702
|
+
status?: string;
|
|
1703
|
+
page?: number;
|
|
1704
|
+
page_size?: number;
|
|
1705
|
+
}): Promise<UserRewardsResponse>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Get user rewards by internal UUID
|
|
1708
|
+
*/
|
|
1709
|
+
getRewardsByInternalId(userId: string, options?: {
|
|
1710
|
+
status?: string;
|
|
1711
|
+
page?: number;
|
|
1712
|
+
page_size?: number;
|
|
1713
|
+
}): Promise<UserRewardsResponse>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Create a CDP (custodial) wallet for an end-user by external ID
|
|
1716
|
+
*/
|
|
1717
|
+
createWallet(externalId: string, request?: CreateWalletRequest): Promise<WalletCreationResult>;
|
|
1718
|
+
/**
|
|
1719
|
+
* Register an external wallet for an end-user by external ID
|
|
1720
|
+
*/
|
|
1721
|
+
registerWallet(externalId: string, request: RegisterWalletRequest): Promise<WalletCreationResult>;
|
|
1722
|
+
/**
|
|
1723
|
+
* Ensure a user has a wallet, creating one if they don't.
|
|
1724
|
+
*
|
|
1725
|
+
* This is the recommended way for frontend devs to guarantee a wallet
|
|
1726
|
+
* exists before performing any wallet-dependent operation (e.g. attestation,
|
|
1727
|
+
* on-chain claims, token transfers).
|
|
1728
|
+
*
|
|
1729
|
+
* If the user already has a wallet, returns immediately with the existing
|
|
1730
|
+
* address. If not, creates a CDP wallet with the specified options.
|
|
1731
|
+
*
|
|
1732
|
+
* @param externalId - The user's external ID
|
|
1733
|
+
* @param options - Wallet creation options (only used if a new wallet is created)
|
|
1734
|
+
* @returns Wallet result with address and creation status
|
|
1735
|
+
*
|
|
1736
|
+
* @example
|
|
1737
|
+
* ```typescript
|
|
1738
|
+
* // One-liner before any wallet-dependent operation
|
|
1739
|
+
* const wallet = await client.users.ensureWallet('user-123');
|
|
1740
|
+
* console.log(wallet.wallet_address); // '0xabc...'
|
|
1741
|
+
*
|
|
1742
|
+
* // With options
|
|
1743
|
+
* const wallet = await client.users.ensureWallet('user-123', {
|
|
1744
|
+
* wallet_type: 'eoa',
|
|
1745
|
+
* network: 'base-mainnet',
|
|
1746
|
+
* });
|
|
1747
|
+
* ```
|
|
1748
|
+
*/
|
|
1749
|
+
ensureWallet(externalId: string, options?: CreateWalletRequest): Promise<WalletCreationResult>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Update user attributes (convenience method) by external ID.
|
|
1752
|
+
* Merges the provided attributes into the existing attributes object.
|
|
1626
1753
|
*/
|
|
1627
1754
|
updateAttributes(externalId: string, attributes: Record<string, any>): Promise<EndUser>;
|
|
1755
|
+
/**
|
|
1756
|
+
* Remove specific attributes from a user by external ID.
|
|
1757
|
+
* Fetches current attributes, removes the specified keys, and saves.
|
|
1758
|
+
*/
|
|
1759
|
+
removeAttributes(externalId: string, keys: string[]): Promise<EndUser>;
|
|
1760
|
+
/**
|
|
1761
|
+
* Set profile fields (convenience method) by external ID.
|
|
1762
|
+
* Only updates the fields provided, leaving others unchanged.
|
|
1763
|
+
*/
|
|
1764
|
+
setProfile(externalId: string, profile: SetProfileRequest): Promise<EndUser>;
|
|
1765
|
+
/**
|
|
1766
|
+
* Preview what would be deleted for a GDPR request
|
|
1767
|
+
*/
|
|
1768
|
+
gdprPreview(userId: string): Promise<GDPRPreviewResponse>;
|
|
1769
|
+
/**
|
|
1770
|
+
* GDPR Right to Be Forgotten - permanently delete all user data
|
|
1771
|
+
*/
|
|
1772
|
+
gdprDelete(userId: string, request: GDPRDeletionRequest): Promise<GDPRDeletionResponse>;
|
|
1628
1773
|
/**
|
|
1629
1774
|
* Export users as CSV
|
|
1630
1775
|
*/
|
|
@@ -2984,4 +3129,4 @@ declare class TimeoutError extends ProofChainError {
|
|
|
2984
3129
|
constructor(message?: string);
|
|
2985
3130
|
}
|
|
2986
3131
|
|
|
2987
|
-
export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type ApiKey, type AttestRequest, type AttestationMode, type AttestationResult, AuthenticationError, AuthorizationError, type AvailableView, type Badge, type BatchIngestRequest, type BatchIngestResponse, type BatchVerifyResult, type BlockchainProof, type BlockchainStats, type Certificate, type CertificateVerifyResult, CertificatesResource, type Channel, type ChannelState, type ChannelStatus, ChannelsResource, type ClaimRewardResult, type CohortDefinition, type CohortGroupStats, CohortLeaderboardClient, type CohortLeaderboardEntry, type CohortLeaderboardOptions, type CohortLeaderboardResponse, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateDataViewRequest, type CreateDualWalletsRequest, type CreateEndUserRequest, type CreateEventRequest, type CreatePassportDefinitionRequest, type CreatePassportRequest, type CreateQuestRequest, type CreateQuestStepRequest, type CreateRewardDefinitionRequest, type CreateSchemaRequest, type CreateTemplateFieldRequest, type CreateTemplateRequest, type CreateWalletRequest, type CreateWebhookRequest, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, type EndUserListResponse, EndUsersClient, type Event, type EventBatchProof, type EventMetadata, type EventStatus, EventsResource, type ExecuteSwapRequest, type Facet, type FacetsResponse, type FanProfileView, type FanpassGroupStats, FanpassLeaderboardClient, type FanpassLeaderboardEntry, type FanpassLeaderboardOptions, type FanpassLeaderboardResponse, type FanpassUserComparisonResponse, type FieldValue, type IngestEventRequest, type IngestEventResponse, IngestionClient, type IngestionClientOptions, type IssueCertificateRequest, type LeaderboardUserProfile$1 as LeaderboardUserProfile, type LinkWalletRequest, type ListCertificatesRequest, type ListCohortsOptions, type ListEndUsersOptions, type ListEventsRequest, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RewardAsset, type RewardDefinition, type RewardEarned, RewardsClient, type Schema, type SchemaDetail, type SchemaField, type SchemaListResponse, type ValidationError$1 as SchemaValidationError, SchemasClient, type SearchFilters, type SearchQueryRequest, type SearchRequest, SearchResource, type SearchResponse, type SearchResult, type SearchStats, ServerError, type Settlement, type StepCompletionResult, type StepProgress, type StreamAck, type StreamEventRequest, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserBreakdownResponse, type UserCohortBreakdownEntry, type UserQuestProgress, type UserWalletSummary, type UserWithWallets, type UsersWithWalletsResponse, type ValidateDataRequest, ValidationError, type ValidationErrorDetail, type ValidationResult, type VaultFile, type VaultFolder, type VaultListResponse, VaultResource, type VaultStats, type VaultUploadRequest, type VerificationResult, VerifyResource, type ViewColumn, type ViewTemplate, type Wallet, type WalletBalance, WalletClient, type WalletStats, type Webhook, WebhooksResource };
|
|
3132
|
+
export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type ApiKey, type AttestRequest, type AttestationMode, type AttestationResult, AuthenticationError, AuthorizationError, type AvailableView, type Badge, type BatchIngestRequest, type BatchIngestResponse, type BatchVerifyResult, type BlockchainProof, type BlockchainStats, type Certificate, type CertificateVerifyResult, CertificatesResource, type Channel, type ChannelState, type ChannelStatus, ChannelsResource, type ClaimRewardResult, type CohortDefinition, type CohortGroupStats, CohortLeaderboardClient, type CohortLeaderboardEntry, type CohortLeaderboardOptions, type CohortLeaderboardResponse, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateDataViewRequest, type CreateDualWalletsRequest, type CreateEndUserRequest, type CreateEventRequest, type CreatePassportDefinitionRequest, type CreatePassportRequest, type CreateQuestRequest, type CreateQuestStepRequest, type CreateRewardDefinitionRequest, type CreateSchemaRequest, type CreateTemplateFieldRequest, type CreateTemplateRequest, type CreateWalletRequest as CreateUserWalletRequest, type CreateWalletRequest$1 as CreateWalletRequest, type CreateWebhookRequest, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, type EndUserListResponse, EndUsersClient, type Event, type EventBatchProof, type EventMetadata, type EventStatus, EventsResource, type ExecuteSwapRequest, type Facet, type FacetsResponse, type FanProfileView, type FanpassGroupStats, FanpassLeaderboardClient, type FanpassLeaderboardEntry, type FanpassLeaderboardOptions, type FanpassLeaderboardResponse, type FanpassUserComparisonResponse, type FieldValue, type GDPRDeletionRequest, type GDPRDeletionResponse, type GDPRPreviewResponse, type IngestEventRequest, type IngestEventResponse, IngestionClient, type IngestionClientOptions, type IssueCertificateRequest, type LeaderboardUserProfile$1 as LeaderboardUserProfile, type LinkWalletRequest, type ListCertificatesRequest, type ListCohortsOptions, type ListEndUsersOptions, type ListEventsRequest, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RegisterWalletRequest, type RewardAsset, type RewardDefinition, type RewardEarned, RewardsClient, type Schema, type SchemaDetail, type SchemaField, type SchemaListResponse, type ValidationError$1 as SchemaValidationError, SchemasClient, type SearchFilters, type SearchQueryRequest, type SearchRequest, SearchResource, type SearchResponse, type SearchResult, type SearchStats, ServerError, type SetProfileRequest, type Settlement, type StepCompletionResult, type StepProgress, type StreamAck, type StreamEventRequest, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserBreakdownResponse, type UserCohortBreakdownEntry, type UserQuestProgress, type UserReward, type UserRewardsResponse, type UserWalletSummary, type UserWithWallets, type UsersWithWalletsResponse, type ValidateDataRequest, ValidationError, type ValidationErrorDetail, type ValidationResult, type VaultFile, type VaultFolder, type VaultListResponse, VaultResource, type VaultStats, type VaultUploadRequest, type VerificationResult, VerifyResource, type ViewColumn, type ViewTemplate, type Wallet, type WalletBalance, WalletClient, type WalletCreationResult, type WalletStats, type Webhook, WebhooksResource };
|
package/dist/index.d.ts
CHANGED
|
@@ -1115,7 +1115,7 @@ interface UserWalletSummary {
|
|
|
1115
1115
|
};
|
|
1116
1116
|
}>;
|
|
1117
1117
|
}
|
|
1118
|
-
interface CreateWalletRequest {
|
|
1118
|
+
interface CreateWalletRequest$1 {
|
|
1119
1119
|
user_id: string;
|
|
1120
1120
|
wallet_type?: 'eoa' | 'smart' | 'solana';
|
|
1121
1121
|
network?: string;
|
|
@@ -1268,7 +1268,7 @@ declare class WalletClient {
|
|
|
1268
1268
|
/**
|
|
1269
1269
|
* Create a single wallet for a user
|
|
1270
1270
|
*/
|
|
1271
|
-
create(data: CreateWalletRequest): Promise<Wallet>;
|
|
1271
|
+
create(data: CreateWalletRequest$1): Promise<Wallet>;
|
|
1272
1272
|
/**
|
|
1273
1273
|
* Get a wallet by ID
|
|
1274
1274
|
*/
|
|
@@ -1562,6 +1562,7 @@ interface ListEndUsersOptions {
|
|
|
1562
1562
|
status?: string;
|
|
1563
1563
|
segment?: string;
|
|
1564
1564
|
has_wallet?: boolean;
|
|
1565
|
+
min_events?: number;
|
|
1565
1566
|
sort_by?: string;
|
|
1566
1567
|
sort_order?: 'asc' | 'desc';
|
|
1567
1568
|
}
|
|
@@ -1571,9 +1572,78 @@ interface LinkWalletRequest {
|
|
|
1571
1572
|
signature?: string;
|
|
1572
1573
|
}
|
|
1573
1574
|
interface MergeUsersRequest {
|
|
1574
|
-
|
|
1575
|
+
source_user_ids: string[];
|
|
1575
1576
|
target_user_id: string;
|
|
1576
1577
|
}
|
|
1578
|
+
interface CreateWalletRequest {
|
|
1579
|
+
wallet_type?: string;
|
|
1580
|
+
network?: string;
|
|
1581
|
+
}
|
|
1582
|
+
interface RegisterWalletRequest {
|
|
1583
|
+
wallet_address: string;
|
|
1584
|
+
signature?: string;
|
|
1585
|
+
}
|
|
1586
|
+
interface UserReward {
|
|
1587
|
+
id: string;
|
|
1588
|
+
reward_name: string;
|
|
1589
|
+
reward_type: string;
|
|
1590
|
+
value?: number;
|
|
1591
|
+
value_currency?: string;
|
|
1592
|
+
status: string;
|
|
1593
|
+
earned_at?: string;
|
|
1594
|
+
distributed_at?: string;
|
|
1595
|
+
nft_token_id?: number;
|
|
1596
|
+
nft_tx_hash?: string;
|
|
1597
|
+
}
|
|
1598
|
+
interface UserRewardsResponse {
|
|
1599
|
+
user_id: string;
|
|
1600
|
+
rewards: UserReward[];
|
|
1601
|
+
total: number;
|
|
1602
|
+
page: number;
|
|
1603
|
+
page_size: number;
|
|
1604
|
+
has_more: boolean;
|
|
1605
|
+
}
|
|
1606
|
+
interface GDPRDeletionRequest {
|
|
1607
|
+
confirm: boolean;
|
|
1608
|
+
delete_events?: boolean;
|
|
1609
|
+
delete_wallets?: boolean;
|
|
1610
|
+
reason?: string;
|
|
1611
|
+
}
|
|
1612
|
+
interface GDPRDeletionResponse {
|
|
1613
|
+
success: boolean;
|
|
1614
|
+
user_id: string;
|
|
1615
|
+
external_id: string;
|
|
1616
|
+
deleted_records: Record<string, number>;
|
|
1617
|
+
merkle_warning?: string;
|
|
1618
|
+
audit_id?: string;
|
|
1619
|
+
}
|
|
1620
|
+
interface GDPRPreviewResponse {
|
|
1621
|
+
user: Record<string, any>;
|
|
1622
|
+
would_delete: Record<string, number>;
|
|
1623
|
+
merkle_warning?: string;
|
|
1624
|
+
}
|
|
1625
|
+
interface WalletCreationResult {
|
|
1626
|
+
success: boolean;
|
|
1627
|
+
user_id: string;
|
|
1628
|
+
wallet_address: string;
|
|
1629
|
+
wallet_type?: string;
|
|
1630
|
+
network?: string;
|
|
1631
|
+
source: string;
|
|
1632
|
+
}
|
|
1633
|
+
interface SetProfileRequest {
|
|
1634
|
+
email?: string;
|
|
1635
|
+
first_name?: string;
|
|
1636
|
+
last_name?: string;
|
|
1637
|
+
display_name?: string;
|
|
1638
|
+
avatar_url?: string;
|
|
1639
|
+
phone?: string;
|
|
1640
|
+
date_of_birth?: string;
|
|
1641
|
+
country?: string;
|
|
1642
|
+
city?: string;
|
|
1643
|
+
timezone?: string;
|
|
1644
|
+
language?: string;
|
|
1645
|
+
bio?: string;
|
|
1646
|
+
}
|
|
1577
1647
|
declare class EndUsersClient {
|
|
1578
1648
|
private http;
|
|
1579
1649
|
constructor(http: HttpClient);
|
|
@@ -1622,9 +1692,84 @@ declare class EndUsersClient {
|
|
|
1622
1692
|
*/
|
|
1623
1693
|
merge(request: MergeUsersRequest): Promise<EndUser>;
|
|
1624
1694
|
/**
|
|
1625
|
-
* Update user
|
|
1695
|
+
* Update an end-user profile by internal UUID
|
|
1696
|
+
*/
|
|
1697
|
+
updateByInternalId(userId: string, data: UpdateEndUserRequest): Promise<EndUser>;
|
|
1698
|
+
/**
|
|
1699
|
+
* Get user rewards by external ID
|
|
1700
|
+
*/
|
|
1701
|
+
getRewards(externalId: string, options?: {
|
|
1702
|
+
status?: string;
|
|
1703
|
+
page?: number;
|
|
1704
|
+
page_size?: number;
|
|
1705
|
+
}): Promise<UserRewardsResponse>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Get user rewards by internal UUID
|
|
1708
|
+
*/
|
|
1709
|
+
getRewardsByInternalId(userId: string, options?: {
|
|
1710
|
+
status?: string;
|
|
1711
|
+
page?: number;
|
|
1712
|
+
page_size?: number;
|
|
1713
|
+
}): Promise<UserRewardsResponse>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Create a CDP (custodial) wallet for an end-user by external ID
|
|
1716
|
+
*/
|
|
1717
|
+
createWallet(externalId: string, request?: CreateWalletRequest): Promise<WalletCreationResult>;
|
|
1718
|
+
/**
|
|
1719
|
+
* Register an external wallet for an end-user by external ID
|
|
1720
|
+
*/
|
|
1721
|
+
registerWallet(externalId: string, request: RegisterWalletRequest): Promise<WalletCreationResult>;
|
|
1722
|
+
/**
|
|
1723
|
+
* Ensure a user has a wallet, creating one if they don't.
|
|
1724
|
+
*
|
|
1725
|
+
* This is the recommended way for frontend devs to guarantee a wallet
|
|
1726
|
+
* exists before performing any wallet-dependent operation (e.g. attestation,
|
|
1727
|
+
* on-chain claims, token transfers).
|
|
1728
|
+
*
|
|
1729
|
+
* If the user already has a wallet, returns immediately with the existing
|
|
1730
|
+
* address. If not, creates a CDP wallet with the specified options.
|
|
1731
|
+
*
|
|
1732
|
+
* @param externalId - The user's external ID
|
|
1733
|
+
* @param options - Wallet creation options (only used if a new wallet is created)
|
|
1734
|
+
* @returns Wallet result with address and creation status
|
|
1735
|
+
*
|
|
1736
|
+
* @example
|
|
1737
|
+
* ```typescript
|
|
1738
|
+
* // One-liner before any wallet-dependent operation
|
|
1739
|
+
* const wallet = await client.users.ensureWallet('user-123');
|
|
1740
|
+
* console.log(wallet.wallet_address); // '0xabc...'
|
|
1741
|
+
*
|
|
1742
|
+
* // With options
|
|
1743
|
+
* const wallet = await client.users.ensureWallet('user-123', {
|
|
1744
|
+
* wallet_type: 'eoa',
|
|
1745
|
+
* network: 'base-mainnet',
|
|
1746
|
+
* });
|
|
1747
|
+
* ```
|
|
1748
|
+
*/
|
|
1749
|
+
ensureWallet(externalId: string, options?: CreateWalletRequest): Promise<WalletCreationResult>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Update user attributes (convenience method) by external ID.
|
|
1752
|
+
* Merges the provided attributes into the existing attributes object.
|
|
1626
1753
|
*/
|
|
1627
1754
|
updateAttributes(externalId: string, attributes: Record<string, any>): Promise<EndUser>;
|
|
1755
|
+
/**
|
|
1756
|
+
* Remove specific attributes from a user by external ID.
|
|
1757
|
+
* Fetches current attributes, removes the specified keys, and saves.
|
|
1758
|
+
*/
|
|
1759
|
+
removeAttributes(externalId: string, keys: string[]): Promise<EndUser>;
|
|
1760
|
+
/**
|
|
1761
|
+
* Set profile fields (convenience method) by external ID.
|
|
1762
|
+
* Only updates the fields provided, leaving others unchanged.
|
|
1763
|
+
*/
|
|
1764
|
+
setProfile(externalId: string, profile: SetProfileRequest): Promise<EndUser>;
|
|
1765
|
+
/**
|
|
1766
|
+
* Preview what would be deleted for a GDPR request
|
|
1767
|
+
*/
|
|
1768
|
+
gdprPreview(userId: string): Promise<GDPRPreviewResponse>;
|
|
1769
|
+
/**
|
|
1770
|
+
* GDPR Right to Be Forgotten - permanently delete all user data
|
|
1771
|
+
*/
|
|
1772
|
+
gdprDelete(userId: string, request: GDPRDeletionRequest): Promise<GDPRDeletionResponse>;
|
|
1628
1773
|
/**
|
|
1629
1774
|
* Export users as CSV
|
|
1630
1775
|
*/
|
|
@@ -2984,4 +3129,4 @@ declare class TimeoutError extends ProofChainError {
|
|
|
2984
3129
|
constructor(message?: string);
|
|
2985
3130
|
}
|
|
2986
3131
|
|
|
2987
|
-
export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type ApiKey, type AttestRequest, type AttestationMode, type AttestationResult, AuthenticationError, AuthorizationError, type AvailableView, type Badge, type BatchIngestRequest, type BatchIngestResponse, type BatchVerifyResult, type BlockchainProof, type BlockchainStats, type Certificate, type CertificateVerifyResult, CertificatesResource, type Channel, type ChannelState, type ChannelStatus, ChannelsResource, type ClaimRewardResult, type CohortDefinition, type CohortGroupStats, CohortLeaderboardClient, type CohortLeaderboardEntry, type CohortLeaderboardOptions, type CohortLeaderboardResponse, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateDataViewRequest, type CreateDualWalletsRequest, type CreateEndUserRequest, type CreateEventRequest, type CreatePassportDefinitionRequest, type CreatePassportRequest, type CreateQuestRequest, type CreateQuestStepRequest, type CreateRewardDefinitionRequest, type CreateSchemaRequest, type CreateTemplateFieldRequest, type CreateTemplateRequest, type CreateWalletRequest, type CreateWebhookRequest, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, type EndUserListResponse, EndUsersClient, type Event, type EventBatchProof, type EventMetadata, type EventStatus, EventsResource, type ExecuteSwapRequest, type Facet, type FacetsResponse, type FanProfileView, type FanpassGroupStats, FanpassLeaderboardClient, type FanpassLeaderboardEntry, type FanpassLeaderboardOptions, type FanpassLeaderboardResponse, type FanpassUserComparisonResponse, type FieldValue, type IngestEventRequest, type IngestEventResponse, IngestionClient, type IngestionClientOptions, type IssueCertificateRequest, type LeaderboardUserProfile$1 as LeaderboardUserProfile, type LinkWalletRequest, type ListCertificatesRequest, type ListCohortsOptions, type ListEndUsersOptions, type ListEventsRequest, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RewardAsset, type RewardDefinition, type RewardEarned, RewardsClient, type Schema, type SchemaDetail, type SchemaField, type SchemaListResponse, type ValidationError$1 as SchemaValidationError, SchemasClient, type SearchFilters, type SearchQueryRequest, type SearchRequest, SearchResource, type SearchResponse, type SearchResult, type SearchStats, ServerError, type Settlement, type StepCompletionResult, type StepProgress, type StreamAck, type StreamEventRequest, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserBreakdownResponse, type UserCohortBreakdownEntry, type UserQuestProgress, type UserWalletSummary, type UserWithWallets, type UsersWithWalletsResponse, type ValidateDataRequest, ValidationError, type ValidationErrorDetail, type ValidationResult, type VaultFile, type VaultFolder, type VaultListResponse, VaultResource, type VaultStats, type VaultUploadRequest, type VerificationResult, VerifyResource, type ViewColumn, type ViewTemplate, type Wallet, type WalletBalance, WalletClient, type WalletStats, type Webhook, WebhooksResource };
|
|
3132
|
+
export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type ApiKey, type AttestRequest, type AttestationMode, type AttestationResult, AuthenticationError, AuthorizationError, type AvailableView, type Badge, type BatchIngestRequest, type BatchIngestResponse, type BatchVerifyResult, type BlockchainProof, type BlockchainStats, type Certificate, type CertificateVerifyResult, CertificatesResource, type Channel, type ChannelState, type ChannelStatus, ChannelsResource, type ClaimRewardResult, type CohortDefinition, type CohortGroupStats, CohortLeaderboardClient, type CohortLeaderboardEntry, type CohortLeaderboardOptions, type CohortLeaderboardResponse, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateDataViewRequest, type CreateDualWalletsRequest, type CreateEndUserRequest, type CreateEventRequest, type CreatePassportDefinitionRequest, type CreatePassportRequest, type CreateQuestRequest, type CreateQuestStepRequest, type CreateRewardDefinitionRequest, type CreateSchemaRequest, type CreateTemplateFieldRequest, type CreateTemplateRequest, type CreateWalletRequest as CreateUserWalletRequest, type CreateWalletRequest$1 as CreateWalletRequest, type CreateWebhookRequest, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, type EndUserListResponse, EndUsersClient, type Event, type EventBatchProof, type EventMetadata, type EventStatus, EventsResource, type ExecuteSwapRequest, type Facet, type FacetsResponse, type FanProfileView, type FanpassGroupStats, FanpassLeaderboardClient, type FanpassLeaderboardEntry, type FanpassLeaderboardOptions, type FanpassLeaderboardResponse, type FanpassUserComparisonResponse, type FieldValue, type GDPRDeletionRequest, type GDPRDeletionResponse, type GDPRPreviewResponse, type IngestEventRequest, type IngestEventResponse, IngestionClient, type IngestionClientOptions, type IssueCertificateRequest, type LeaderboardUserProfile$1 as LeaderboardUserProfile, type LinkWalletRequest, type ListCertificatesRequest, type ListCohortsOptions, type ListEndUsersOptions, type ListEventsRequest, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RegisterWalletRequest, type RewardAsset, type RewardDefinition, type RewardEarned, RewardsClient, type Schema, type SchemaDetail, type SchemaField, type SchemaListResponse, type ValidationError$1 as SchemaValidationError, SchemasClient, type SearchFilters, type SearchQueryRequest, type SearchRequest, SearchResource, type SearchResponse, type SearchResult, type SearchStats, ServerError, type SetProfileRequest, type Settlement, type StepCompletionResult, type StepProgress, type StreamAck, type StreamEventRequest, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserBreakdownResponse, type UserCohortBreakdownEntry, type UserQuestProgress, type UserReward, type UserRewardsResponse, type UserWalletSummary, type UserWithWallets, type UsersWithWalletsResponse, type ValidateDataRequest, ValidationError, type ValidationErrorDetail, type ValidationResult, type VaultFile, type VaultFolder, type VaultListResponse, VaultResource, type VaultStats, type VaultUploadRequest, type VerificationResult, VerifyResource, type ViewColumn, type ViewTemplate, type Wallet, type WalletBalance, WalletClient, type WalletCreationResult, type WalletStats, type Webhook, WebhooksResource };
|
package/dist/index.js
CHANGED
|
@@ -1143,6 +1143,7 @@ var EndUsersClient = class {
|
|
|
1143
1143
|
if (options.status) params.append("status", options.status);
|
|
1144
1144
|
if (options.segment) params.append("segment", options.segment);
|
|
1145
1145
|
if (options.has_wallet !== void 0) params.append("has_wallet", options.has_wallet.toString());
|
|
1146
|
+
if (options.min_events !== void 0) params.append("min_events", options.min_events.toString());
|
|
1146
1147
|
if (options.sort_by) params.append("sort_by", options.sort_by);
|
|
1147
1148
|
if (options.sort_order) params.append("sort_order", options.sort_order);
|
|
1148
1149
|
return this.http.get(`/end-users?${params.toString()}`);
|
|
@@ -1209,11 +1210,121 @@ var EndUsersClient = class {
|
|
|
1209
1210
|
return this.http.post("/end-users/merge", request);
|
|
1210
1211
|
}
|
|
1211
1212
|
/**
|
|
1212
|
-
* Update user
|
|
1213
|
+
* Update an end-user profile by internal UUID
|
|
1214
|
+
*/
|
|
1215
|
+
async updateByInternalId(userId, data) {
|
|
1216
|
+
return this.http.patch(`/end-users/${userId}`, data);
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Get user rewards by external ID
|
|
1220
|
+
*/
|
|
1221
|
+
async getRewards(externalId, options = {}) {
|
|
1222
|
+
const params = new URLSearchParams();
|
|
1223
|
+
if (options.status) params.append("status", options.status);
|
|
1224
|
+
if (options.page) params.append("page", options.page.toString());
|
|
1225
|
+
if (options.page_size) params.append("page_size", options.page_size.toString());
|
|
1226
|
+
return this.http.get(`/end-users/by-external/${encodeURIComponent(externalId)}/rewards?${params.toString()}`);
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Get user rewards by internal UUID
|
|
1230
|
+
*/
|
|
1231
|
+
async getRewardsByInternalId(userId, options = {}) {
|
|
1232
|
+
const params = new URLSearchParams();
|
|
1233
|
+
if (options.status) params.append("status", options.status);
|
|
1234
|
+
if (options.page) params.append("page", options.page.toString());
|
|
1235
|
+
if (options.page_size) params.append("page_size", options.page_size.toString());
|
|
1236
|
+
return this.http.get(`/end-users/${userId}/rewards?${params.toString()}`);
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Create a CDP (custodial) wallet for an end-user by external ID
|
|
1240
|
+
*/
|
|
1241
|
+
async createWallet(externalId, request = {}) {
|
|
1242
|
+
return this.http.post(`/end-users/by-external/${encodeURIComponent(externalId)}/create-wallet`, request);
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Register an external wallet for an end-user by external ID
|
|
1246
|
+
*/
|
|
1247
|
+
async registerWallet(externalId, request) {
|
|
1248
|
+
return this.http.post(`/end-users/by-external/${encodeURIComponent(externalId)}/register-wallet`, request);
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Ensure a user has a wallet, creating one if they don't.
|
|
1252
|
+
*
|
|
1253
|
+
* This is the recommended way for frontend devs to guarantee a wallet
|
|
1254
|
+
* exists before performing any wallet-dependent operation (e.g. attestation,
|
|
1255
|
+
* on-chain claims, token transfers).
|
|
1256
|
+
*
|
|
1257
|
+
* If the user already has a wallet, returns immediately with the existing
|
|
1258
|
+
* address. If not, creates a CDP wallet with the specified options.
|
|
1259
|
+
*
|
|
1260
|
+
* @param externalId - The user's external ID
|
|
1261
|
+
* @param options - Wallet creation options (only used if a new wallet is created)
|
|
1262
|
+
* @returns Wallet result with address and creation status
|
|
1263
|
+
*
|
|
1264
|
+
* @example
|
|
1265
|
+
* ```typescript
|
|
1266
|
+
* // One-liner before any wallet-dependent operation
|
|
1267
|
+
* const wallet = await client.users.ensureWallet('user-123');
|
|
1268
|
+
* console.log(wallet.wallet_address); // '0xabc...'
|
|
1269
|
+
*
|
|
1270
|
+
* // With options
|
|
1271
|
+
* const wallet = await client.users.ensureWallet('user-123', {
|
|
1272
|
+
* wallet_type: 'eoa',
|
|
1273
|
+
* network: 'base-mainnet',
|
|
1274
|
+
* });
|
|
1275
|
+
* ```
|
|
1276
|
+
*/
|
|
1277
|
+
async ensureWallet(externalId, options = {}) {
|
|
1278
|
+
const user = await this.get(externalId);
|
|
1279
|
+
if (user.wallet_address) {
|
|
1280
|
+
return {
|
|
1281
|
+
success: true,
|
|
1282
|
+
user_id: externalId,
|
|
1283
|
+
wallet_address: user.wallet_address,
|
|
1284
|
+
wallet_type: user.wallet_source ?? void 0,
|
|
1285
|
+
source: "existing"
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
return this.createWallet(externalId, options);
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Update user attributes (convenience method) by external ID.
|
|
1292
|
+
* Merges the provided attributes into the existing attributes object.
|
|
1213
1293
|
*/
|
|
1214
1294
|
async updateAttributes(externalId, attributes) {
|
|
1215
1295
|
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, { attributes });
|
|
1216
1296
|
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Remove specific attributes from a user by external ID.
|
|
1299
|
+
* Fetches current attributes, removes the specified keys, and saves.
|
|
1300
|
+
*/
|
|
1301
|
+
async removeAttributes(externalId, keys) {
|
|
1302
|
+
const user = await this.get(externalId);
|
|
1303
|
+
const attributes = { ...user.attributes || {} };
|
|
1304
|
+
for (const key of keys) {
|
|
1305
|
+
delete attributes[key];
|
|
1306
|
+
}
|
|
1307
|
+
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, { attributes });
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Set profile fields (convenience method) by external ID.
|
|
1311
|
+
* Only updates the fields provided, leaving others unchanged.
|
|
1312
|
+
*/
|
|
1313
|
+
async setProfile(externalId, profile) {
|
|
1314
|
+
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, profile);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Preview what would be deleted for a GDPR request
|
|
1318
|
+
*/
|
|
1319
|
+
async gdprPreview(userId) {
|
|
1320
|
+
return this.http.get(`/end-users/${userId}/gdpr/preview`);
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* GDPR Right to Be Forgotten - permanently delete all user data
|
|
1324
|
+
*/
|
|
1325
|
+
async gdprDelete(userId, request) {
|
|
1326
|
+
return this.http.request("DELETE", `/end-users/${userId}/gdpr`, { body: request });
|
|
1327
|
+
}
|
|
1217
1328
|
/**
|
|
1218
1329
|
* Export users as CSV
|
|
1219
1330
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1089,6 +1089,7 @@ var EndUsersClient = class {
|
|
|
1089
1089
|
if (options.status) params.append("status", options.status);
|
|
1090
1090
|
if (options.segment) params.append("segment", options.segment);
|
|
1091
1091
|
if (options.has_wallet !== void 0) params.append("has_wallet", options.has_wallet.toString());
|
|
1092
|
+
if (options.min_events !== void 0) params.append("min_events", options.min_events.toString());
|
|
1092
1093
|
if (options.sort_by) params.append("sort_by", options.sort_by);
|
|
1093
1094
|
if (options.sort_order) params.append("sort_order", options.sort_order);
|
|
1094
1095
|
return this.http.get(`/end-users?${params.toString()}`);
|
|
@@ -1155,11 +1156,121 @@ var EndUsersClient = class {
|
|
|
1155
1156
|
return this.http.post("/end-users/merge", request);
|
|
1156
1157
|
}
|
|
1157
1158
|
/**
|
|
1158
|
-
* Update user
|
|
1159
|
+
* Update an end-user profile by internal UUID
|
|
1160
|
+
*/
|
|
1161
|
+
async updateByInternalId(userId, data) {
|
|
1162
|
+
return this.http.patch(`/end-users/${userId}`, data);
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Get user rewards by external ID
|
|
1166
|
+
*/
|
|
1167
|
+
async getRewards(externalId, options = {}) {
|
|
1168
|
+
const params = new URLSearchParams();
|
|
1169
|
+
if (options.status) params.append("status", options.status);
|
|
1170
|
+
if (options.page) params.append("page", options.page.toString());
|
|
1171
|
+
if (options.page_size) params.append("page_size", options.page_size.toString());
|
|
1172
|
+
return this.http.get(`/end-users/by-external/${encodeURIComponent(externalId)}/rewards?${params.toString()}`);
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Get user rewards by internal UUID
|
|
1176
|
+
*/
|
|
1177
|
+
async getRewardsByInternalId(userId, options = {}) {
|
|
1178
|
+
const params = new URLSearchParams();
|
|
1179
|
+
if (options.status) params.append("status", options.status);
|
|
1180
|
+
if (options.page) params.append("page", options.page.toString());
|
|
1181
|
+
if (options.page_size) params.append("page_size", options.page_size.toString());
|
|
1182
|
+
return this.http.get(`/end-users/${userId}/rewards?${params.toString()}`);
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Create a CDP (custodial) wallet for an end-user by external ID
|
|
1186
|
+
*/
|
|
1187
|
+
async createWallet(externalId, request = {}) {
|
|
1188
|
+
return this.http.post(`/end-users/by-external/${encodeURIComponent(externalId)}/create-wallet`, request);
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Register an external wallet for an end-user by external ID
|
|
1192
|
+
*/
|
|
1193
|
+
async registerWallet(externalId, request) {
|
|
1194
|
+
return this.http.post(`/end-users/by-external/${encodeURIComponent(externalId)}/register-wallet`, request);
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Ensure a user has a wallet, creating one if they don't.
|
|
1198
|
+
*
|
|
1199
|
+
* This is the recommended way for frontend devs to guarantee a wallet
|
|
1200
|
+
* exists before performing any wallet-dependent operation (e.g. attestation,
|
|
1201
|
+
* on-chain claims, token transfers).
|
|
1202
|
+
*
|
|
1203
|
+
* If the user already has a wallet, returns immediately with the existing
|
|
1204
|
+
* address. If not, creates a CDP wallet with the specified options.
|
|
1205
|
+
*
|
|
1206
|
+
* @param externalId - The user's external ID
|
|
1207
|
+
* @param options - Wallet creation options (only used if a new wallet is created)
|
|
1208
|
+
* @returns Wallet result with address and creation status
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* ```typescript
|
|
1212
|
+
* // One-liner before any wallet-dependent operation
|
|
1213
|
+
* const wallet = await client.users.ensureWallet('user-123');
|
|
1214
|
+
* console.log(wallet.wallet_address); // '0xabc...'
|
|
1215
|
+
*
|
|
1216
|
+
* // With options
|
|
1217
|
+
* const wallet = await client.users.ensureWallet('user-123', {
|
|
1218
|
+
* wallet_type: 'eoa',
|
|
1219
|
+
* network: 'base-mainnet',
|
|
1220
|
+
* });
|
|
1221
|
+
* ```
|
|
1222
|
+
*/
|
|
1223
|
+
async ensureWallet(externalId, options = {}) {
|
|
1224
|
+
const user = await this.get(externalId);
|
|
1225
|
+
if (user.wallet_address) {
|
|
1226
|
+
return {
|
|
1227
|
+
success: true,
|
|
1228
|
+
user_id: externalId,
|
|
1229
|
+
wallet_address: user.wallet_address,
|
|
1230
|
+
wallet_type: user.wallet_source ?? void 0,
|
|
1231
|
+
source: "existing"
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
return this.createWallet(externalId, options);
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Update user attributes (convenience method) by external ID.
|
|
1238
|
+
* Merges the provided attributes into the existing attributes object.
|
|
1159
1239
|
*/
|
|
1160
1240
|
async updateAttributes(externalId, attributes) {
|
|
1161
1241
|
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, { attributes });
|
|
1162
1242
|
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Remove specific attributes from a user by external ID.
|
|
1245
|
+
* Fetches current attributes, removes the specified keys, and saves.
|
|
1246
|
+
*/
|
|
1247
|
+
async removeAttributes(externalId, keys) {
|
|
1248
|
+
const user = await this.get(externalId);
|
|
1249
|
+
const attributes = { ...user.attributes || {} };
|
|
1250
|
+
for (const key of keys) {
|
|
1251
|
+
delete attributes[key];
|
|
1252
|
+
}
|
|
1253
|
+
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, { attributes });
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Set profile fields (convenience method) by external ID.
|
|
1257
|
+
* Only updates the fields provided, leaving others unchanged.
|
|
1258
|
+
*/
|
|
1259
|
+
async setProfile(externalId, profile) {
|
|
1260
|
+
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, profile);
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Preview what would be deleted for a GDPR request
|
|
1264
|
+
*/
|
|
1265
|
+
async gdprPreview(userId) {
|
|
1266
|
+
return this.http.get(`/end-users/${userId}/gdpr/preview`);
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* GDPR Right to Be Forgotten - permanently delete all user data
|
|
1270
|
+
*/
|
|
1271
|
+
async gdprDelete(userId, request) {
|
|
1272
|
+
return this.http.request("DELETE", `/end-users/${userId}/gdpr`, { body: request });
|
|
1273
|
+
}
|
|
1163
1274
|
/**
|
|
1164
1275
|
* Export users as CSV
|
|
1165
1276
|
*/
|
package/package.json
CHANGED