@proofchain/sdk 2.9.0 → 2.11.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 +169 -5
- package/dist/index.d.ts +169 -5
- package/dist/index.js +125 -1
- package/dist/index.mjs +125 -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,97 @@ 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 EnsureWalletResult {
|
|
1634
|
+
user_id: string;
|
|
1635
|
+
asset_wallet: {
|
|
1636
|
+
wallet_id: string;
|
|
1637
|
+
address: string;
|
|
1638
|
+
wallet_type: string;
|
|
1639
|
+
network: string;
|
|
1640
|
+
[key: string]: any;
|
|
1641
|
+
};
|
|
1642
|
+
smart_wallet: {
|
|
1643
|
+
wallet_id: string;
|
|
1644
|
+
address: string;
|
|
1645
|
+
wallet_type: string;
|
|
1646
|
+
network: string;
|
|
1647
|
+
[key: string]: any;
|
|
1648
|
+
};
|
|
1649
|
+
network: string;
|
|
1650
|
+
created: boolean;
|
|
1651
|
+
}
|
|
1652
|
+
interface SetProfileRequest {
|
|
1653
|
+
email?: string;
|
|
1654
|
+
first_name?: string;
|
|
1655
|
+
last_name?: string;
|
|
1656
|
+
display_name?: string;
|
|
1657
|
+
avatar_url?: string;
|
|
1658
|
+
phone?: string;
|
|
1659
|
+
date_of_birth?: string;
|
|
1660
|
+
country?: string;
|
|
1661
|
+
city?: string;
|
|
1662
|
+
timezone?: string;
|
|
1663
|
+
language?: string;
|
|
1664
|
+
bio?: string;
|
|
1665
|
+
}
|
|
1577
1666
|
declare class EndUsersClient {
|
|
1578
1667
|
private http;
|
|
1579
1668
|
constructor(http: HttpClient);
|
|
@@ -1622,9 +1711,84 @@ declare class EndUsersClient {
|
|
|
1622
1711
|
*/
|
|
1623
1712
|
merge(request: MergeUsersRequest): Promise<EndUser>;
|
|
1624
1713
|
/**
|
|
1625
|
-
* Update user
|
|
1714
|
+
* Update an end-user profile by internal UUID
|
|
1715
|
+
*/
|
|
1716
|
+
updateByInternalId(userId: string, data: UpdateEndUserRequest): Promise<EndUser>;
|
|
1717
|
+
/**
|
|
1718
|
+
* Get user rewards by external ID
|
|
1719
|
+
*/
|
|
1720
|
+
getRewards(externalId: string, options?: {
|
|
1721
|
+
status?: string;
|
|
1722
|
+
page?: number;
|
|
1723
|
+
page_size?: number;
|
|
1724
|
+
}): Promise<UserRewardsResponse>;
|
|
1725
|
+
/**
|
|
1726
|
+
* Get user rewards by internal UUID
|
|
1727
|
+
*/
|
|
1728
|
+
getRewardsByInternalId(userId: string, options?: {
|
|
1729
|
+
status?: string;
|
|
1730
|
+
page?: number;
|
|
1731
|
+
page_size?: number;
|
|
1732
|
+
}): Promise<UserRewardsResponse>;
|
|
1733
|
+
/**
|
|
1734
|
+
* Create a CDP (custodial) wallet for an end-user by external ID
|
|
1735
|
+
*/
|
|
1736
|
+
createWallet(externalId: string, request?: CreateWalletRequest): Promise<WalletCreationResult>;
|
|
1737
|
+
/**
|
|
1738
|
+
* Register an external wallet for an end-user by external ID
|
|
1739
|
+
*/
|
|
1740
|
+
registerWallet(externalId: string, request: RegisterWalletRequest): Promise<WalletCreationResult>;
|
|
1741
|
+
/**
|
|
1742
|
+
* Ensure a user has dual wallets (EOA + Smart Account), creating them if they don't exist.
|
|
1743
|
+
*
|
|
1744
|
+
* This is the recommended way for frontend devs to guarantee wallets exist
|
|
1745
|
+
* before performing any wallet-dependent operation (e.g. attestation,
|
|
1746
|
+
* on-chain claims, token transfers).
|
|
1747
|
+
*
|
|
1748
|
+
* If the user already has both wallet types, returns them immediately.
|
|
1749
|
+
* If not, creates a dual wallet pair (EOA asset wallet + Smart Account
|
|
1750
|
+
* for gasless transactions) via the CDP SDK.
|
|
1751
|
+
*
|
|
1752
|
+
* @param externalId - The user's external ID
|
|
1753
|
+
* @param network - Network to create wallets on (default: 'base-sepolia')
|
|
1754
|
+
* @returns EnsureWalletResult with both wallets and whether they were newly created
|
|
1755
|
+
*
|
|
1756
|
+
* @example
|
|
1757
|
+
* ```typescript
|
|
1758
|
+
* // One-liner before any wallet-dependent operation
|
|
1759
|
+
* const result = await client.users.ensureWallet('user-123');
|
|
1760
|
+
* console.log(result.asset_wallet.address); // '0xabc...'
|
|
1761
|
+
* console.log(result.smart_wallet.address); // '0xdef...'
|
|
1762
|
+
* console.log(result.created); // false if they already existed
|
|
1763
|
+
*
|
|
1764
|
+
* // With specific network
|
|
1765
|
+
* const result = await client.users.ensureWallet('user-123', 'base-mainnet');
|
|
1766
|
+
* ```
|
|
1767
|
+
*/
|
|
1768
|
+
ensureWallet(externalId: string, network?: string): Promise<EnsureWalletResult>;
|
|
1769
|
+
/**
|
|
1770
|
+
* Update user attributes (convenience method) by external ID.
|
|
1771
|
+
* Merges the provided attributes into the existing attributes object.
|
|
1626
1772
|
*/
|
|
1627
1773
|
updateAttributes(externalId: string, attributes: Record<string, any>): Promise<EndUser>;
|
|
1774
|
+
/**
|
|
1775
|
+
* Remove specific attributes from a user by external ID.
|
|
1776
|
+
* Fetches current attributes, removes the specified keys, and saves.
|
|
1777
|
+
*/
|
|
1778
|
+
removeAttributes(externalId: string, keys: string[]): Promise<EndUser>;
|
|
1779
|
+
/**
|
|
1780
|
+
* Set profile fields (convenience method) by external ID.
|
|
1781
|
+
* Only updates the fields provided, leaving others unchanged.
|
|
1782
|
+
*/
|
|
1783
|
+
setProfile(externalId: string, profile: SetProfileRequest): Promise<EndUser>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Preview what would be deleted for a GDPR request
|
|
1786
|
+
*/
|
|
1787
|
+
gdprPreview(userId: string): Promise<GDPRPreviewResponse>;
|
|
1788
|
+
/**
|
|
1789
|
+
* GDPR Right to Be Forgotten - permanently delete all user data
|
|
1790
|
+
*/
|
|
1791
|
+
gdprDelete(userId: string, request: GDPRDeletionRequest): Promise<GDPRDeletionResponse>;
|
|
1628
1792
|
/**
|
|
1629
1793
|
* Export users as CSV
|
|
1630
1794
|
*/
|
|
@@ -2984,4 +3148,4 @@ declare class TimeoutError extends ProofChainError {
|
|
|
2984
3148
|
constructor(message?: string);
|
|
2985
3149
|
}
|
|
2986
3150
|
|
|
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 };
|
|
3151
|
+
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,97 @@ 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 EnsureWalletResult {
|
|
1634
|
+
user_id: string;
|
|
1635
|
+
asset_wallet: {
|
|
1636
|
+
wallet_id: string;
|
|
1637
|
+
address: string;
|
|
1638
|
+
wallet_type: string;
|
|
1639
|
+
network: string;
|
|
1640
|
+
[key: string]: any;
|
|
1641
|
+
};
|
|
1642
|
+
smart_wallet: {
|
|
1643
|
+
wallet_id: string;
|
|
1644
|
+
address: string;
|
|
1645
|
+
wallet_type: string;
|
|
1646
|
+
network: string;
|
|
1647
|
+
[key: string]: any;
|
|
1648
|
+
};
|
|
1649
|
+
network: string;
|
|
1650
|
+
created: boolean;
|
|
1651
|
+
}
|
|
1652
|
+
interface SetProfileRequest {
|
|
1653
|
+
email?: string;
|
|
1654
|
+
first_name?: string;
|
|
1655
|
+
last_name?: string;
|
|
1656
|
+
display_name?: string;
|
|
1657
|
+
avatar_url?: string;
|
|
1658
|
+
phone?: string;
|
|
1659
|
+
date_of_birth?: string;
|
|
1660
|
+
country?: string;
|
|
1661
|
+
city?: string;
|
|
1662
|
+
timezone?: string;
|
|
1663
|
+
language?: string;
|
|
1664
|
+
bio?: string;
|
|
1665
|
+
}
|
|
1577
1666
|
declare class EndUsersClient {
|
|
1578
1667
|
private http;
|
|
1579
1668
|
constructor(http: HttpClient);
|
|
@@ -1622,9 +1711,84 @@ declare class EndUsersClient {
|
|
|
1622
1711
|
*/
|
|
1623
1712
|
merge(request: MergeUsersRequest): Promise<EndUser>;
|
|
1624
1713
|
/**
|
|
1625
|
-
* Update user
|
|
1714
|
+
* Update an end-user profile by internal UUID
|
|
1715
|
+
*/
|
|
1716
|
+
updateByInternalId(userId: string, data: UpdateEndUserRequest): Promise<EndUser>;
|
|
1717
|
+
/**
|
|
1718
|
+
* Get user rewards by external ID
|
|
1719
|
+
*/
|
|
1720
|
+
getRewards(externalId: string, options?: {
|
|
1721
|
+
status?: string;
|
|
1722
|
+
page?: number;
|
|
1723
|
+
page_size?: number;
|
|
1724
|
+
}): Promise<UserRewardsResponse>;
|
|
1725
|
+
/**
|
|
1726
|
+
* Get user rewards by internal UUID
|
|
1727
|
+
*/
|
|
1728
|
+
getRewardsByInternalId(userId: string, options?: {
|
|
1729
|
+
status?: string;
|
|
1730
|
+
page?: number;
|
|
1731
|
+
page_size?: number;
|
|
1732
|
+
}): Promise<UserRewardsResponse>;
|
|
1733
|
+
/**
|
|
1734
|
+
* Create a CDP (custodial) wallet for an end-user by external ID
|
|
1735
|
+
*/
|
|
1736
|
+
createWallet(externalId: string, request?: CreateWalletRequest): Promise<WalletCreationResult>;
|
|
1737
|
+
/**
|
|
1738
|
+
* Register an external wallet for an end-user by external ID
|
|
1739
|
+
*/
|
|
1740
|
+
registerWallet(externalId: string, request: RegisterWalletRequest): Promise<WalletCreationResult>;
|
|
1741
|
+
/**
|
|
1742
|
+
* Ensure a user has dual wallets (EOA + Smart Account), creating them if they don't exist.
|
|
1743
|
+
*
|
|
1744
|
+
* This is the recommended way for frontend devs to guarantee wallets exist
|
|
1745
|
+
* before performing any wallet-dependent operation (e.g. attestation,
|
|
1746
|
+
* on-chain claims, token transfers).
|
|
1747
|
+
*
|
|
1748
|
+
* If the user already has both wallet types, returns them immediately.
|
|
1749
|
+
* If not, creates a dual wallet pair (EOA asset wallet + Smart Account
|
|
1750
|
+
* for gasless transactions) via the CDP SDK.
|
|
1751
|
+
*
|
|
1752
|
+
* @param externalId - The user's external ID
|
|
1753
|
+
* @param network - Network to create wallets on (default: 'base-sepolia')
|
|
1754
|
+
* @returns EnsureWalletResult with both wallets and whether they were newly created
|
|
1755
|
+
*
|
|
1756
|
+
* @example
|
|
1757
|
+
* ```typescript
|
|
1758
|
+
* // One-liner before any wallet-dependent operation
|
|
1759
|
+
* const result = await client.users.ensureWallet('user-123');
|
|
1760
|
+
* console.log(result.asset_wallet.address); // '0xabc...'
|
|
1761
|
+
* console.log(result.smart_wallet.address); // '0xdef...'
|
|
1762
|
+
* console.log(result.created); // false if they already existed
|
|
1763
|
+
*
|
|
1764
|
+
* // With specific network
|
|
1765
|
+
* const result = await client.users.ensureWallet('user-123', 'base-mainnet');
|
|
1766
|
+
* ```
|
|
1767
|
+
*/
|
|
1768
|
+
ensureWallet(externalId: string, network?: string): Promise<EnsureWalletResult>;
|
|
1769
|
+
/**
|
|
1770
|
+
* Update user attributes (convenience method) by external ID.
|
|
1771
|
+
* Merges the provided attributes into the existing attributes object.
|
|
1626
1772
|
*/
|
|
1627
1773
|
updateAttributes(externalId: string, attributes: Record<string, any>): Promise<EndUser>;
|
|
1774
|
+
/**
|
|
1775
|
+
* Remove specific attributes from a user by external ID.
|
|
1776
|
+
* Fetches current attributes, removes the specified keys, and saves.
|
|
1777
|
+
*/
|
|
1778
|
+
removeAttributes(externalId: string, keys: string[]): Promise<EndUser>;
|
|
1779
|
+
/**
|
|
1780
|
+
* Set profile fields (convenience method) by external ID.
|
|
1781
|
+
* Only updates the fields provided, leaving others unchanged.
|
|
1782
|
+
*/
|
|
1783
|
+
setProfile(externalId: string, profile: SetProfileRequest): Promise<EndUser>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Preview what would be deleted for a GDPR request
|
|
1786
|
+
*/
|
|
1787
|
+
gdprPreview(userId: string): Promise<GDPRPreviewResponse>;
|
|
1788
|
+
/**
|
|
1789
|
+
* GDPR Right to Be Forgotten - permanently delete all user data
|
|
1790
|
+
*/
|
|
1791
|
+
gdprDelete(userId: string, request: GDPRDeletionRequest): Promise<GDPRDeletionResponse>;
|
|
1628
1792
|
/**
|
|
1629
1793
|
* Export users as CSV
|
|
1630
1794
|
*/
|
|
@@ -2984,4 +3148,4 @@ declare class TimeoutError extends ProofChainError {
|
|
|
2984
3148
|
constructor(message?: string);
|
|
2985
3149
|
}
|
|
2986
3150
|
|
|
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 };
|
|
3151
|
+
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,134 @@ 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 dual wallets (EOA + Smart Account), creating them if they don't exist.
|
|
1252
|
+
*
|
|
1253
|
+
* This is the recommended way for frontend devs to guarantee wallets exist
|
|
1254
|
+
* before performing any wallet-dependent operation (e.g. attestation,
|
|
1255
|
+
* on-chain claims, token transfers).
|
|
1256
|
+
*
|
|
1257
|
+
* If the user already has both wallet types, returns them immediately.
|
|
1258
|
+
* If not, creates a dual wallet pair (EOA asset wallet + Smart Account
|
|
1259
|
+
* for gasless transactions) via the CDP SDK.
|
|
1260
|
+
*
|
|
1261
|
+
* @param externalId - The user's external ID
|
|
1262
|
+
* @param network - Network to create wallets on (default: 'base-sepolia')
|
|
1263
|
+
* @returns EnsureWalletResult with both wallets and whether they were newly created
|
|
1264
|
+
*
|
|
1265
|
+
* @example
|
|
1266
|
+
* ```typescript
|
|
1267
|
+
* // One-liner before any wallet-dependent operation
|
|
1268
|
+
* const result = await client.users.ensureWallet('user-123');
|
|
1269
|
+
* console.log(result.asset_wallet.address); // '0xabc...'
|
|
1270
|
+
* console.log(result.smart_wallet.address); // '0xdef...'
|
|
1271
|
+
* console.log(result.created); // false if they already existed
|
|
1272
|
+
*
|
|
1273
|
+
* // With specific network
|
|
1274
|
+
* const result = await client.users.ensureWallet('user-123', 'base-mainnet');
|
|
1275
|
+
* ```
|
|
1276
|
+
*/
|
|
1277
|
+
async ensureWallet(externalId, network = "base-sepolia") {
|
|
1278
|
+
const existingWallets = await this.http.get(
|
|
1279
|
+
`/wallets/user/${encodeURIComponent(externalId)}`
|
|
1280
|
+
);
|
|
1281
|
+
if (existingWallets && existingWallets.length > 0) {
|
|
1282
|
+
const eoa = existingWallets.find((w) => w.wallet_type === "eoa");
|
|
1283
|
+
const smart = existingWallets.find((w) => w.wallet_type === "smart");
|
|
1284
|
+
if (eoa && smart) {
|
|
1285
|
+
return {
|
|
1286
|
+
user_id: externalId,
|
|
1287
|
+
asset_wallet: eoa,
|
|
1288
|
+
smart_wallet: smart,
|
|
1289
|
+
network: eoa.network,
|
|
1290
|
+
created: false
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
const dual = await this.http.post("/wallets/dual", {
|
|
1295
|
+
user_id: externalId,
|
|
1296
|
+
network
|
|
1297
|
+
});
|
|
1298
|
+
return {
|
|
1299
|
+
...dual,
|
|
1300
|
+
created: true
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Update user attributes (convenience method) by external ID.
|
|
1305
|
+
* Merges the provided attributes into the existing attributes object.
|
|
1213
1306
|
*/
|
|
1214
1307
|
async updateAttributes(externalId, attributes) {
|
|
1215
1308
|
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, { attributes });
|
|
1216
1309
|
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Remove specific attributes from a user by external ID.
|
|
1312
|
+
* Fetches current attributes, removes the specified keys, and saves.
|
|
1313
|
+
*/
|
|
1314
|
+
async removeAttributes(externalId, keys) {
|
|
1315
|
+
const user = await this.get(externalId);
|
|
1316
|
+
const attributes = { ...user.attributes || {} };
|
|
1317
|
+
for (const key of keys) {
|
|
1318
|
+
delete attributes[key];
|
|
1319
|
+
}
|
|
1320
|
+
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, { attributes });
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Set profile fields (convenience method) by external ID.
|
|
1324
|
+
* Only updates the fields provided, leaving others unchanged.
|
|
1325
|
+
*/
|
|
1326
|
+
async setProfile(externalId, profile) {
|
|
1327
|
+
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, profile);
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Preview what would be deleted for a GDPR request
|
|
1331
|
+
*/
|
|
1332
|
+
async gdprPreview(userId) {
|
|
1333
|
+
return this.http.get(`/end-users/${userId}/gdpr/preview`);
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* GDPR Right to Be Forgotten - permanently delete all user data
|
|
1337
|
+
*/
|
|
1338
|
+
async gdprDelete(userId, request) {
|
|
1339
|
+
return this.http.request("DELETE", `/end-users/${userId}/gdpr`, { body: request });
|
|
1340
|
+
}
|
|
1217
1341
|
/**
|
|
1218
1342
|
* Export users as CSV
|
|
1219
1343
|
*/
|
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,134 @@ 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 dual wallets (EOA + Smart Account), creating them if they don't exist.
|
|
1198
|
+
*
|
|
1199
|
+
* This is the recommended way for frontend devs to guarantee wallets exist
|
|
1200
|
+
* before performing any wallet-dependent operation (e.g. attestation,
|
|
1201
|
+
* on-chain claims, token transfers).
|
|
1202
|
+
*
|
|
1203
|
+
* If the user already has both wallet types, returns them immediately.
|
|
1204
|
+
* If not, creates a dual wallet pair (EOA asset wallet + Smart Account
|
|
1205
|
+
* for gasless transactions) via the CDP SDK.
|
|
1206
|
+
*
|
|
1207
|
+
* @param externalId - The user's external ID
|
|
1208
|
+
* @param network - Network to create wallets on (default: 'base-sepolia')
|
|
1209
|
+
* @returns EnsureWalletResult with both wallets and whether they were newly created
|
|
1210
|
+
*
|
|
1211
|
+
* @example
|
|
1212
|
+
* ```typescript
|
|
1213
|
+
* // One-liner before any wallet-dependent operation
|
|
1214
|
+
* const result = await client.users.ensureWallet('user-123');
|
|
1215
|
+
* console.log(result.asset_wallet.address); // '0xabc...'
|
|
1216
|
+
* console.log(result.smart_wallet.address); // '0xdef...'
|
|
1217
|
+
* console.log(result.created); // false if they already existed
|
|
1218
|
+
*
|
|
1219
|
+
* // With specific network
|
|
1220
|
+
* const result = await client.users.ensureWallet('user-123', 'base-mainnet');
|
|
1221
|
+
* ```
|
|
1222
|
+
*/
|
|
1223
|
+
async ensureWallet(externalId, network = "base-sepolia") {
|
|
1224
|
+
const existingWallets = await this.http.get(
|
|
1225
|
+
`/wallets/user/${encodeURIComponent(externalId)}`
|
|
1226
|
+
);
|
|
1227
|
+
if (existingWallets && existingWallets.length > 0) {
|
|
1228
|
+
const eoa = existingWallets.find((w) => w.wallet_type === "eoa");
|
|
1229
|
+
const smart = existingWallets.find((w) => w.wallet_type === "smart");
|
|
1230
|
+
if (eoa && smart) {
|
|
1231
|
+
return {
|
|
1232
|
+
user_id: externalId,
|
|
1233
|
+
asset_wallet: eoa,
|
|
1234
|
+
smart_wallet: smart,
|
|
1235
|
+
network: eoa.network,
|
|
1236
|
+
created: false
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
const dual = await this.http.post("/wallets/dual", {
|
|
1241
|
+
user_id: externalId,
|
|
1242
|
+
network
|
|
1243
|
+
});
|
|
1244
|
+
return {
|
|
1245
|
+
...dual,
|
|
1246
|
+
created: true
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Update user attributes (convenience method) by external ID.
|
|
1251
|
+
* Merges the provided attributes into the existing attributes object.
|
|
1159
1252
|
*/
|
|
1160
1253
|
async updateAttributes(externalId, attributes) {
|
|
1161
1254
|
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, { attributes });
|
|
1162
1255
|
}
|
|
1256
|
+
/**
|
|
1257
|
+
* Remove specific attributes from a user by external ID.
|
|
1258
|
+
* Fetches current attributes, removes the specified keys, and saves.
|
|
1259
|
+
*/
|
|
1260
|
+
async removeAttributes(externalId, keys) {
|
|
1261
|
+
const user = await this.get(externalId);
|
|
1262
|
+
const attributes = { ...user.attributes || {} };
|
|
1263
|
+
for (const key of keys) {
|
|
1264
|
+
delete attributes[key];
|
|
1265
|
+
}
|
|
1266
|
+
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, { attributes });
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Set profile fields (convenience method) by external ID.
|
|
1270
|
+
* Only updates the fields provided, leaving others unchanged.
|
|
1271
|
+
*/
|
|
1272
|
+
async setProfile(externalId, profile) {
|
|
1273
|
+
return this.http.patch(`/end-users/by-external/${encodeURIComponent(externalId)}`, profile);
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Preview what would be deleted for a GDPR request
|
|
1277
|
+
*/
|
|
1278
|
+
async gdprPreview(userId) {
|
|
1279
|
+
return this.http.get(`/end-users/${userId}/gdpr/preview`);
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* GDPR Right to Be Forgotten - permanently delete all user data
|
|
1283
|
+
*/
|
|
1284
|
+
async gdprDelete(userId, request) {
|
|
1285
|
+
return this.http.request("DELETE", `/end-users/${userId}/gdpr`, { body: request });
|
|
1286
|
+
}
|
|
1163
1287
|
/**
|
|
1164
1288
|
* Export users as CSV
|
|
1165
1289
|
*/
|
package/package.json
CHANGED