@proofchain/sdk 2.12.2 → 2.13.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 CHANGED
@@ -2,13 +2,17 @@
2
2
  * HTTP Client for ProofChain API
3
3
  */
4
4
  interface HttpClientOptions {
5
- apiKey: string;
5
+ apiKey?: string;
6
+ userToken?: string;
7
+ tenantId?: string;
6
8
  baseUrl?: string;
7
9
  timeout?: number;
8
10
  maxRetries?: number;
9
11
  }
10
12
  declare class HttpClient {
11
13
  private apiKey;
14
+ private userToken;
15
+ private tenantId;
12
16
  private baseUrl;
13
17
  private timeout;
14
18
  private maxRetries;
@@ -377,7 +381,11 @@ interface CreateApiKeyRequest {
377
381
  expiresInDays?: number;
378
382
  }
379
383
  interface ProofChainOptions {
380
- apiKey: string;
384
+ apiKey?: string;
385
+ /** End-user JWT for JWKS auth (alternative to apiKey). For PWA clients. */
386
+ userToken?: string;
387
+ /** Tenant slug or client_id. Required when using userToken. */
388
+ tenantId?: string;
381
389
  baseUrl?: string;
382
390
  timeout?: number;
383
391
  maxRetries?: number;
@@ -1586,7 +1594,7 @@ interface RegisterWalletRequest {
1586
1594
  wallet_address: string;
1587
1595
  signature?: string;
1588
1596
  }
1589
- interface UserReward {
1597
+ interface UserReward$1 {
1590
1598
  id: string;
1591
1599
  reward_name: string;
1592
1600
  reward_type: string;
@@ -1600,7 +1608,7 @@ interface UserReward {
1600
1608
  }
1601
1609
  interface UserRewardsResponse {
1602
1610
  user_id: string;
1603
- rewards: UserReward[];
1611
+ rewards: UserReward$1[];
1604
1612
  total: number;
1605
1613
  page: number;
1606
1614
  page_size: number;
@@ -1846,6 +1854,23 @@ interface EarnedReward {
1846
1854
  earned_at: string;
1847
1855
  distributed_at?: string;
1848
1856
  }
1857
+ interface UserReward {
1858
+ id: string;
1859
+ reward_name: string;
1860
+ reward_type: string;
1861
+ slug?: string;
1862
+ description?: string;
1863
+ status: string;
1864
+ value?: number;
1865
+ value_currency?: string;
1866
+ image_url?: string;
1867
+ badge_color?: string;
1868
+ nft_token_id?: number;
1869
+ nft_tx_hash?: string;
1870
+ earned_at: string;
1871
+ distributed_at?: string;
1872
+ expires_at?: string;
1873
+ }
1849
1874
  interface RewardAsset {
1850
1875
  id: string;
1851
1876
  definition_id: string;
@@ -1937,9 +1962,12 @@ declare class RewardsClient {
1937
1962
  offset?: number;
1938
1963
  }): Promise<EarnedReward[]>;
1939
1964
  /**
1940
- * Get earned rewards for a user
1965
+ * Get earned rewards for a user (with full badge/reward details)
1941
1966
  */
1942
- getUserRewards(userId: string): Promise<EarnedReward[]>;
1967
+ getUserRewards(userId: string, options?: {
1968
+ status?: string;
1969
+ reward_type?: string;
1970
+ }): Promise<UserReward[]>;
1943
1971
  /**
1944
1972
  * Manually award rewards to users
1945
1973
  */
@@ -3009,6 +3037,27 @@ declare class ProofChain {
3009
3037
  /** Fanpass leaderboard client for composite score leaderboards */
3010
3038
  fanpassLeaderboard: FanpassLeaderboardClient;
3011
3039
  constructor(options: ProofChainOptions);
3040
+ /**
3041
+ * Create a client for end-user JWT authentication (PWA/frontend use).
3042
+ * Uses the end-user's JWT from their auth system instead of an API key.
3043
+ * End-user clients have read-only access scoped to their own data.
3044
+ *
3045
+ * @example
3046
+ * ```typescript
3047
+ * const client = ProofChain.forEndUser({
3048
+ * userToken: authSystem.getIdToken(),
3049
+ * tenantId: 'my-tenant-slug',
3050
+ * });
3051
+ * const passport = await client.passports.getUserPassport(myUserId);
3052
+ * ```
3053
+ */
3054
+ static forEndUser(options: {
3055
+ userToken: string;
3056
+ tenantId: string;
3057
+ baseUrl?: string;
3058
+ timeout?: number;
3059
+ maxRetries?: number;
3060
+ }): ProofChain;
3012
3061
  /**
3013
3062
  * Create a client from environment variables.
3014
3063
  * Reads PROOFCHAIN_API_KEY and optionally PROOFCHAIN_BASE_URL.
@@ -3151,4 +3200,4 @@ declare class TimeoutError extends ProofChainError {
3151
3200
  constructor(message?: string);
3152
3201
  }
3153
3202
 
3154
- 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 };
3203
+ 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$1 as 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
@@ -2,13 +2,17 @@
2
2
  * HTTP Client for ProofChain API
3
3
  */
4
4
  interface HttpClientOptions {
5
- apiKey: string;
5
+ apiKey?: string;
6
+ userToken?: string;
7
+ tenantId?: string;
6
8
  baseUrl?: string;
7
9
  timeout?: number;
8
10
  maxRetries?: number;
9
11
  }
10
12
  declare class HttpClient {
11
13
  private apiKey;
14
+ private userToken;
15
+ private tenantId;
12
16
  private baseUrl;
13
17
  private timeout;
14
18
  private maxRetries;
@@ -377,7 +381,11 @@ interface CreateApiKeyRequest {
377
381
  expiresInDays?: number;
378
382
  }
379
383
  interface ProofChainOptions {
380
- apiKey: string;
384
+ apiKey?: string;
385
+ /** End-user JWT for JWKS auth (alternative to apiKey). For PWA clients. */
386
+ userToken?: string;
387
+ /** Tenant slug or client_id. Required when using userToken. */
388
+ tenantId?: string;
381
389
  baseUrl?: string;
382
390
  timeout?: number;
383
391
  maxRetries?: number;
@@ -1586,7 +1594,7 @@ interface RegisterWalletRequest {
1586
1594
  wallet_address: string;
1587
1595
  signature?: string;
1588
1596
  }
1589
- interface UserReward {
1597
+ interface UserReward$1 {
1590
1598
  id: string;
1591
1599
  reward_name: string;
1592
1600
  reward_type: string;
@@ -1600,7 +1608,7 @@ interface UserReward {
1600
1608
  }
1601
1609
  interface UserRewardsResponse {
1602
1610
  user_id: string;
1603
- rewards: UserReward[];
1611
+ rewards: UserReward$1[];
1604
1612
  total: number;
1605
1613
  page: number;
1606
1614
  page_size: number;
@@ -1846,6 +1854,23 @@ interface EarnedReward {
1846
1854
  earned_at: string;
1847
1855
  distributed_at?: string;
1848
1856
  }
1857
+ interface UserReward {
1858
+ id: string;
1859
+ reward_name: string;
1860
+ reward_type: string;
1861
+ slug?: string;
1862
+ description?: string;
1863
+ status: string;
1864
+ value?: number;
1865
+ value_currency?: string;
1866
+ image_url?: string;
1867
+ badge_color?: string;
1868
+ nft_token_id?: number;
1869
+ nft_tx_hash?: string;
1870
+ earned_at: string;
1871
+ distributed_at?: string;
1872
+ expires_at?: string;
1873
+ }
1849
1874
  interface RewardAsset {
1850
1875
  id: string;
1851
1876
  definition_id: string;
@@ -1937,9 +1962,12 @@ declare class RewardsClient {
1937
1962
  offset?: number;
1938
1963
  }): Promise<EarnedReward[]>;
1939
1964
  /**
1940
- * Get earned rewards for a user
1965
+ * Get earned rewards for a user (with full badge/reward details)
1941
1966
  */
1942
- getUserRewards(userId: string): Promise<EarnedReward[]>;
1967
+ getUserRewards(userId: string, options?: {
1968
+ status?: string;
1969
+ reward_type?: string;
1970
+ }): Promise<UserReward[]>;
1943
1971
  /**
1944
1972
  * Manually award rewards to users
1945
1973
  */
@@ -3009,6 +3037,27 @@ declare class ProofChain {
3009
3037
  /** Fanpass leaderboard client for composite score leaderboards */
3010
3038
  fanpassLeaderboard: FanpassLeaderboardClient;
3011
3039
  constructor(options: ProofChainOptions);
3040
+ /**
3041
+ * Create a client for end-user JWT authentication (PWA/frontend use).
3042
+ * Uses the end-user's JWT from their auth system instead of an API key.
3043
+ * End-user clients have read-only access scoped to their own data.
3044
+ *
3045
+ * @example
3046
+ * ```typescript
3047
+ * const client = ProofChain.forEndUser({
3048
+ * userToken: authSystem.getIdToken(),
3049
+ * tenantId: 'my-tenant-slug',
3050
+ * });
3051
+ * const passport = await client.passports.getUserPassport(myUserId);
3052
+ * ```
3053
+ */
3054
+ static forEndUser(options: {
3055
+ userToken: string;
3056
+ tenantId: string;
3057
+ baseUrl?: string;
3058
+ timeout?: number;
3059
+ maxRetries?: number;
3060
+ }): ProofChain;
3012
3061
  /**
3013
3062
  * Create a client from environment variables.
3014
3063
  * Reads PROOFCHAIN_API_KEY and optionally PROOFCHAIN_BASE_URL.
@@ -3151,4 +3200,4 @@ declare class TimeoutError extends ProofChainError {
3151
3200
  constructor(message?: string);
3152
3201
  }
3153
3202
 
3154
- 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 };
3203
+ 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$1 as 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
@@ -119,17 +119,27 @@ var DEFAULT_TIMEOUT = 3e4;
119
119
  var USER_AGENT = "proofchain-js/0.1.0";
120
120
  var HttpClient = class {
121
121
  constructor(options) {
122
- this.apiKey = options.apiKey;
122
+ this.apiKey = options.apiKey || "";
123
+ this.userToken = options.userToken || "";
124
+ this.tenantId = options.tenantId || "";
123
125
  this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
124
126
  this.timeout = options.timeout || DEFAULT_TIMEOUT;
125
127
  this.maxRetries = options.maxRetries ?? 3;
126
128
  }
127
129
  getHeaders() {
128
- return {
129
- "X-API-Key": this.apiKey,
130
+ const headers = {
130
131
  "Content-Type": "application/json",
131
132
  "User-Agent": USER_AGENT
132
133
  };
134
+ if (this.userToken) {
135
+ headers["Authorization"] = `Bearer ${this.userToken}`;
136
+ if (this.tenantId) {
137
+ headers["X-Tenant-ID"] = this.tenantId;
138
+ }
139
+ } else if (this.apiKey) {
140
+ headers["X-API-Key"] = this.apiKey;
141
+ }
142
+ return headers;
133
143
  }
134
144
  async handleResponse(response) {
135
145
  const contentType = response.headers.get("content-type");
@@ -221,9 +231,16 @@ var HttpClient = class {
221
231
  async requestMultipart(path, formData) {
222
232
  const url = `${this.baseUrl}${path}`;
223
233
  const headers = {
224
- "X-API-Key": this.apiKey,
225
234
  "User-Agent": USER_AGENT
226
235
  };
236
+ if (this.userToken) {
237
+ headers["Authorization"] = `Bearer ${this.userToken}`;
238
+ if (this.tenantId) {
239
+ headers["X-Tenant-ID"] = this.tenantId;
240
+ }
241
+ } else if (this.apiKey) {
242
+ headers["X-API-Key"] = this.apiKey;
243
+ }
227
244
  return this.fetchWithRetry(url, {
228
245
  method: "POST",
229
246
  headers,
@@ -237,10 +254,7 @@ var HttpClient = class {
237
254
  try {
238
255
  const response = await fetch(url, {
239
256
  method: "GET",
240
- headers: {
241
- "X-API-Key": this.apiKey,
242
- "User-Agent": USER_AGENT
243
- },
257
+ headers: this.getHeaders(),
244
258
  signal: controller.signal
245
259
  });
246
260
  clearTimeout(timeoutId);
@@ -1451,10 +1465,14 @@ var RewardsClient = class {
1451
1465
  return this.http.get(`/rewards/earned?${params.toString()}`);
1452
1466
  }
1453
1467
  /**
1454
- * Get earned rewards for a user
1468
+ * Get earned rewards for a user (with full badge/reward details)
1455
1469
  */
1456
- async getUserRewards(userId) {
1457
- return this.http.get(`/rewards/earned/user/${userId}`);
1470
+ async getUserRewards(userId, options = {}) {
1471
+ const params = new URLSearchParams();
1472
+ if (options.status) params.append("status", options.status);
1473
+ if (options.reward_type) params.append("reward_type", options.reward_type);
1474
+ const query = params.toString();
1475
+ return this.http.get(`/rewards/users/${userId}/rewards${query ? "?" + query : ""}`);
1458
1476
  }
1459
1477
  /**
1460
1478
  * Manually award rewards to users
@@ -2322,6 +2340,23 @@ var ProofChain = class _ProofChain {
2322
2340
  this.cohorts = new CohortLeaderboardClient(this.http);
2323
2341
  this.fanpassLeaderboard = new FanpassLeaderboardClient(this.http);
2324
2342
  }
2343
+ /**
2344
+ * Create a client for end-user JWT authentication (PWA/frontend use).
2345
+ * Uses the end-user's JWT from their auth system instead of an API key.
2346
+ * End-user clients have read-only access scoped to their own data.
2347
+ *
2348
+ * @example
2349
+ * ```typescript
2350
+ * const client = ProofChain.forEndUser({
2351
+ * userToken: authSystem.getIdToken(),
2352
+ * tenantId: 'my-tenant-slug',
2353
+ * });
2354
+ * const passport = await client.passports.getUserPassport(myUserId);
2355
+ * ```
2356
+ */
2357
+ static forEndUser(options) {
2358
+ return new _ProofChain(options);
2359
+ }
2325
2360
  /**
2326
2361
  * Create a client from environment variables.
2327
2362
  * Reads PROOFCHAIN_API_KEY and optionally PROOFCHAIN_BASE_URL.
package/dist/index.mjs CHANGED
@@ -65,17 +65,27 @@ var DEFAULT_TIMEOUT = 3e4;
65
65
  var USER_AGENT = "proofchain-js/0.1.0";
66
66
  var HttpClient = class {
67
67
  constructor(options) {
68
- this.apiKey = options.apiKey;
68
+ this.apiKey = options.apiKey || "";
69
+ this.userToken = options.userToken || "";
70
+ this.tenantId = options.tenantId || "";
69
71
  this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
70
72
  this.timeout = options.timeout || DEFAULT_TIMEOUT;
71
73
  this.maxRetries = options.maxRetries ?? 3;
72
74
  }
73
75
  getHeaders() {
74
- return {
75
- "X-API-Key": this.apiKey,
76
+ const headers = {
76
77
  "Content-Type": "application/json",
77
78
  "User-Agent": USER_AGENT
78
79
  };
80
+ if (this.userToken) {
81
+ headers["Authorization"] = `Bearer ${this.userToken}`;
82
+ if (this.tenantId) {
83
+ headers["X-Tenant-ID"] = this.tenantId;
84
+ }
85
+ } else if (this.apiKey) {
86
+ headers["X-API-Key"] = this.apiKey;
87
+ }
88
+ return headers;
79
89
  }
80
90
  async handleResponse(response) {
81
91
  const contentType = response.headers.get("content-type");
@@ -167,9 +177,16 @@ var HttpClient = class {
167
177
  async requestMultipart(path, formData) {
168
178
  const url = `${this.baseUrl}${path}`;
169
179
  const headers = {
170
- "X-API-Key": this.apiKey,
171
180
  "User-Agent": USER_AGENT
172
181
  };
182
+ if (this.userToken) {
183
+ headers["Authorization"] = `Bearer ${this.userToken}`;
184
+ if (this.tenantId) {
185
+ headers["X-Tenant-ID"] = this.tenantId;
186
+ }
187
+ } else if (this.apiKey) {
188
+ headers["X-API-Key"] = this.apiKey;
189
+ }
173
190
  return this.fetchWithRetry(url, {
174
191
  method: "POST",
175
192
  headers,
@@ -183,10 +200,7 @@ var HttpClient = class {
183
200
  try {
184
201
  const response = await fetch(url, {
185
202
  method: "GET",
186
- headers: {
187
- "X-API-Key": this.apiKey,
188
- "User-Agent": USER_AGENT
189
- },
203
+ headers: this.getHeaders(),
190
204
  signal: controller.signal
191
205
  });
192
206
  clearTimeout(timeoutId);
@@ -1397,10 +1411,14 @@ var RewardsClient = class {
1397
1411
  return this.http.get(`/rewards/earned?${params.toString()}`);
1398
1412
  }
1399
1413
  /**
1400
- * Get earned rewards for a user
1414
+ * Get earned rewards for a user (with full badge/reward details)
1401
1415
  */
1402
- async getUserRewards(userId) {
1403
- return this.http.get(`/rewards/earned/user/${userId}`);
1416
+ async getUserRewards(userId, options = {}) {
1417
+ const params = new URLSearchParams();
1418
+ if (options.status) params.append("status", options.status);
1419
+ if (options.reward_type) params.append("reward_type", options.reward_type);
1420
+ const query = params.toString();
1421
+ return this.http.get(`/rewards/users/${userId}/rewards${query ? "?" + query : ""}`);
1404
1422
  }
1405
1423
  /**
1406
1424
  * Manually award rewards to users
@@ -2268,6 +2286,23 @@ var ProofChain = class _ProofChain {
2268
2286
  this.cohorts = new CohortLeaderboardClient(this.http);
2269
2287
  this.fanpassLeaderboard = new FanpassLeaderboardClient(this.http);
2270
2288
  }
2289
+ /**
2290
+ * Create a client for end-user JWT authentication (PWA/frontend use).
2291
+ * Uses the end-user's JWT from their auth system instead of an API key.
2292
+ * End-user clients have read-only access scoped to their own data.
2293
+ *
2294
+ * @example
2295
+ * ```typescript
2296
+ * const client = ProofChain.forEndUser({
2297
+ * userToken: authSystem.getIdToken(),
2298
+ * tenantId: 'my-tenant-slug',
2299
+ * });
2300
+ * const passport = await client.passports.getUserPassport(myUserId);
2301
+ * ```
2302
+ */
2303
+ static forEndUser(options) {
2304
+ return new _ProofChain(options);
2305
+ }
2271
2306
  /**
2272
2307
  * Create a client from environment variables.
2273
2308
  * Reads PROOFCHAIN_API_KEY and optionally PROOFCHAIN_BASE_URL.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proofchain/sdk",
3
- "version": "2.12.2",
3
+ "version": "2.13.0",
4
4
  "description": "Official JavaScript/TypeScript SDK for ProofChain - blockchain-anchored document attestation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",