@proofchain/sdk 2.17.0 → 2.19.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/README.md +104 -0
- package/dist/index.d.mts +375 -1
- package/dist/index.d.ts +375 -1
- package/dist/index.js +375 -0
- package/dist/index.mjs +374 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -240,6 +240,110 @@ console.log('Quest completed:', result.quest_completed);
|
|
|
240
240
|
| `quick_hit` | Short, easy quests. Auto-enrolls when user triggers a matching event. |
|
|
241
241
|
| `challenge` | Time-limited or competitive. Auto-enrolls when user triggers a matching event. |
|
|
242
242
|
|
|
243
|
+
### Real-Time Notifications (SSE)
|
|
244
|
+
|
|
245
|
+
Push notifications to your frontend in real-time when quest/reward events happen. Uses Server-Sent Events (SSE) — no WebSocket setup needed.
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { ProofChain } from '@proofchain/sdk';
|
|
249
|
+
|
|
250
|
+
const client = new ProofChain({ apiKey: 'your-api-key' });
|
|
251
|
+
|
|
252
|
+
// Subscribe to notifications for a user
|
|
253
|
+
const unsubscribe = client.notifications.subscribe('user-123', (event) => {
|
|
254
|
+
console.log('Notification:', event.event, event.data);
|
|
255
|
+
|
|
256
|
+
switch (event.event) {
|
|
257
|
+
case 'quest_step_completed':
|
|
258
|
+
showToast(`Step completed: ${event.data.step_name}`);
|
|
259
|
+
break;
|
|
260
|
+
|
|
261
|
+
case 'quest_completed':
|
|
262
|
+
showConfetti();
|
|
263
|
+
showToast(`Quest completed: ${event.data.quest_name}! 🎉`);
|
|
264
|
+
break;
|
|
265
|
+
|
|
266
|
+
case 'badge_earned':
|
|
267
|
+
showBadgeModal({
|
|
268
|
+
name: event.data.reward_name,
|
|
269
|
+
image: event.data.image_url,
|
|
270
|
+
});
|
|
271
|
+
break;
|
|
272
|
+
|
|
273
|
+
case 'reward_claimable':
|
|
274
|
+
showClaimButton(event.data.quest_id);
|
|
275
|
+
break;
|
|
276
|
+
|
|
277
|
+
case 'reward_earned':
|
|
278
|
+
showToast(`Reward earned: ${event.data.reward_name}`);
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}, {
|
|
282
|
+
onConnect: () => console.log('Connected to notifications'),
|
|
283
|
+
onDisconnect: () => console.log('Disconnected, will auto-reconnect...'),
|
|
284
|
+
onError: (err) => console.error('Notification error:', err),
|
|
285
|
+
autoReconnect: true, // default: true
|
|
286
|
+
reconnectDelay: 3000, // default: 3000ms
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// Cleanup when component unmounts or user logs out
|
|
290
|
+
unsubscribe();
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**React example:**
|
|
294
|
+
|
|
295
|
+
```tsx
|
|
296
|
+
import { useEffect } from 'react';
|
|
297
|
+
import { ProofChain } from '@proofchain/sdk';
|
|
298
|
+
|
|
299
|
+
function useNotifications(client: ProofChain, userId: string) {
|
|
300
|
+
useEffect(() => {
|
|
301
|
+
const unsub = client.notifications.subscribe(userId, (event) => {
|
|
302
|
+
// Handle notification (show toast, update UI, etc.)
|
|
303
|
+
console.log(event.event, event.data);
|
|
304
|
+
});
|
|
305
|
+
return () => unsub(); // cleanup on unmount
|
|
306
|
+
}, [client, userId]);
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**End-user JWT auth (for PWA/frontend without API key):**
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
const client = ProofChain.forEndUser({
|
|
314
|
+
userToken: auth.getIdToken(),
|
|
315
|
+
tenantId: 'my-tenant-slug',
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
// End-user can only subscribe to their own notifications
|
|
319
|
+
const unsub = client.notifications.subscribe(myUserId, (event) => {
|
|
320
|
+
// ...
|
|
321
|
+
});
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Notification event types:**
|
|
325
|
+
|
|
326
|
+
| Event | When | Data fields |
|
|
327
|
+
|-------|------|-------------|
|
|
328
|
+
| `quest_step_completed` | A quest step is completed | `quest_id`, `quest_name`, `step_index`, `step_name`, `steps_completed`, `total_steps`, `points_earned` |
|
|
329
|
+
| `quest_completed` | A quest is fully completed (auto-award) | `quest_id`, `quest_name`, `points_earned`, `completion_count` |
|
|
330
|
+
| `reward_claimable` | A quest is completed (claimable mode) | `quest_id`, `quest_name`, `points_earned`, `reward_definition_id` |
|
|
331
|
+
| `badge_earned` | A badge reward is distributed | `quest_id`, `quest_name`, `reward_id`, `reward_name`, `reward_type`, `image_url` |
|
|
332
|
+
| `reward_earned` | A non-badge reward is distributed | `quest_id`, `quest_name`, `reward_id`, `reward_name`, `reward_type`, `value`, `image_url` |
|
|
333
|
+
|
|
334
|
+
**Notification payload shape:**
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
interface NotificationEvent {
|
|
338
|
+
id: string; // unique event ID
|
|
339
|
+
event: string; // event type (see table above)
|
|
340
|
+
data: Record<string, any>; // event-specific data
|
|
341
|
+
tenant_id: string;
|
|
342
|
+
user_id: string;
|
|
343
|
+
timestamp: string; // ISO 8601
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
243
347
|
## Error Handling
|
|
244
348
|
|
|
245
349
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -1840,6 +1840,8 @@ interface RewardDefinition {
|
|
|
1840
1840
|
is_active: boolean;
|
|
1841
1841
|
icon_url?: string;
|
|
1842
1842
|
badge_color?: string;
|
|
1843
|
+
attest_on_earn: boolean;
|
|
1844
|
+
anchoring_mode: 'none' | 'immediate' | 'batch' | 'on_demand';
|
|
1843
1845
|
created_at: string;
|
|
1844
1846
|
}
|
|
1845
1847
|
interface EarnedReward {
|
|
@@ -1851,6 +1853,8 @@ interface EarnedReward {
|
|
|
1851
1853
|
status: string;
|
|
1852
1854
|
nft_token_id?: number;
|
|
1853
1855
|
nft_tx_hash?: string;
|
|
1856
|
+
attestation_id?: string;
|
|
1857
|
+
attestation_status?: string;
|
|
1854
1858
|
earned_at: string;
|
|
1855
1859
|
distributed_at?: string;
|
|
1856
1860
|
}
|
|
@@ -1908,6 +1912,8 @@ interface CreateRewardDefinitionRequest {
|
|
|
1908
1912
|
icon_url?: string;
|
|
1909
1913
|
badge_color?: string;
|
|
1910
1914
|
is_public?: boolean;
|
|
1915
|
+
attest_on_earn?: boolean;
|
|
1916
|
+
anchoring_mode?: 'none' | 'immediate' | 'batch' | 'on_demand';
|
|
1911
1917
|
}
|
|
1912
1918
|
interface ManualRewardRequest {
|
|
1913
1919
|
definition_id: string;
|
|
@@ -1932,6 +1938,38 @@ interface RevokeResult {
|
|
|
1932
1938
|
reward_id: string;
|
|
1933
1939
|
status: string;
|
|
1934
1940
|
}
|
|
1941
|
+
interface RewardAttestationResult {
|
|
1942
|
+
attestation_id: string;
|
|
1943
|
+
attestation_uid: string;
|
|
1944
|
+
status: string;
|
|
1945
|
+
signature?: string;
|
|
1946
|
+
tx_hash?: string;
|
|
1947
|
+
subject_address: string;
|
|
1948
|
+
reward_id: string;
|
|
1949
|
+
reward_name: string;
|
|
1950
|
+
earned_at: string;
|
|
1951
|
+
created_at: string;
|
|
1952
|
+
}
|
|
1953
|
+
interface AnchorResult {
|
|
1954
|
+
success: boolean;
|
|
1955
|
+
reward_id: string;
|
|
1956
|
+
attestation_id: string;
|
|
1957
|
+
tx_hash: string;
|
|
1958
|
+
status: string;
|
|
1959
|
+
}
|
|
1960
|
+
interface VerifyResult {
|
|
1961
|
+
is_valid: boolean;
|
|
1962
|
+
attestation_uid: string;
|
|
1963
|
+
status: string;
|
|
1964
|
+
subject_address: string;
|
|
1965
|
+
attester_address: string;
|
|
1966
|
+
signature_type: string;
|
|
1967
|
+
on_chain: boolean;
|
|
1968
|
+
tx_hash?: string;
|
|
1969
|
+
reward_id: string;
|
|
1970
|
+
reward_name: string;
|
|
1971
|
+
earned_at?: string;
|
|
1972
|
+
}
|
|
1935
1973
|
interface ListRewardsOptions {
|
|
1936
1974
|
is_active?: boolean;
|
|
1937
1975
|
reward_type?: string;
|
|
@@ -2090,6 +2128,60 @@ declare class RewardsClient {
|
|
|
2090
2128
|
* List assets for a reward definition
|
|
2091
2129
|
*/
|
|
2092
2130
|
listAssets(definitionId: string): Promise<RewardAsset[]>;
|
|
2131
|
+
/**
|
|
2132
|
+
* Create a signed attestation for an earned reward.
|
|
2133
|
+
*
|
|
2134
|
+
* Binds the reward to the user's wallet with an EIP-712 signature.
|
|
2135
|
+
* The anchoring mode is determined by the reward definition or tenant config.
|
|
2136
|
+
*
|
|
2137
|
+
* @param earnedRewardId - The earned reward ID to attest
|
|
2138
|
+
* @returns The attestation details including signature and on-chain status
|
|
2139
|
+
*
|
|
2140
|
+
* @example
|
|
2141
|
+
* ```ts
|
|
2142
|
+
* const attestation = await client.rewards.attest('earned-reward-id');
|
|
2143
|
+
* console.log(attestation.attestation_uid, attestation.status);
|
|
2144
|
+
* ```
|
|
2145
|
+
*/
|
|
2146
|
+
attest(earnedRewardId: string): Promise<RewardAttestationResult>;
|
|
2147
|
+
/**
|
|
2148
|
+
* Anchor an earned reward's attestation on-chain (on-demand).
|
|
2149
|
+
*
|
|
2150
|
+
* The reward must already have a signed attestation.
|
|
2151
|
+
* Writes the attestation hash to the Base blockchain contract.
|
|
2152
|
+
*
|
|
2153
|
+
* @param earnedRewardId - The earned reward ID whose attestation to anchor
|
|
2154
|
+
*
|
|
2155
|
+
* @example
|
|
2156
|
+
* ```ts
|
|
2157
|
+
* const result = await client.rewards.anchor('earned-reward-id');
|
|
2158
|
+
* console.log('Anchored on-chain:', result.tx_hash);
|
|
2159
|
+
* ```
|
|
2160
|
+
*/
|
|
2161
|
+
anchor(earnedRewardId: string): Promise<AnchorResult>;
|
|
2162
|
+
/**
|
|
2163
|
+
* Get the attestation for an earned reward.
|
|
2164
|
+
*
|
|
2165
|
+
* @param earnedRewardId - The earned reward ID
|
|
2166
|
+
*/
|
|
2167
|
+
getAttestation(earnedRewardId: string): Promise<RewardAttestationResult>;
|
|
2168
|
+
/**
|
|
2169
|
+
* Verify a reward attestation's signature and on-chain status.
|
|
2170
|
+
*
|
|
2171
|
+
* @param earnedRewardId - The earned reward ID to verify
|
|
2172
|
+
*
|
|
2173
|
+
* @example
|
|
2174
|
+
* ```ts
|
|
2175
|
+
* const result = await client.rewards.verifyAttestation('earned-reward-id');
|
|
2176
|
+
* if (result.is_valid) {
|
|
2177
|
+
* console.log('Reward is cryptographically verified!');
|
|
2178
|
+
* if (result.on_chain) {
|
|
2179
|
+
* console.log('Also anchored on Base:', result.tx_hash);
|
|
2180
|
+
* }
|
|
2181
|
+
* }
|
|
2182
|
+
* ```
|
|
2183
|
+
*/
|
|
2184
|
+
verifyAttestation(earnedRewardId: string): Promise<VerifyResult>;
|
|
2093
2185
|
}
|
|
2094
2186
|
|
|
2095
2187
|
/**
|
|
@@ -2125,6 +2217,8 @@ interface Quest {
|
|
|
2125
2217
|
reward_mode: 'auto_award' | 'claimable';
|
|
2126
2218
|
is_public: boolean;
|
|
2127
2219
|
is_featured: boolean;
|
|
2220
|
+
/** Sort weight for ordering quests (lower = first). Default 0. */
|
|
2221
|
+
display_order: number;
|
|
2128
2222
|
tags: string[];
|
|
2129
2223
|
status: 'draft' | 'active' | 'paused' | 'completed' | 'archived';
|
|
2130
2224
|
steps: QuestStep[];
|
|
@@ -2145,6 +2239,10 @@ interface QuestStep {
|
|
|
2145
2239
|
criteria?: Record<string, any>;
|
|
2146
2240
|
required_data_fields?: string[];
|
|
2147
2241
|
step_points?: number;
|
|
2242
|
+
/** Button text for call-to-action (e.g., "Read Article", "Visit Store") */
|
|
2243
|
+
cta_text?: string;
|
|
2244
|
+
/** URL or deeplink for the call-to-action button */
|
|
2245
|
+
cta_url?: string;
|
|
2148
2246
|
icon_url?: string;
|
|
2149
2247
|
is_optional: boolean;
|
|
2150
2248
|
}
|
|
@@ -2229,6 +2327,8 @@ interface CreateQuestRequest {
|
|
|
2229
2327
|
reward_mode?: 'auto_award' | 'claimable';
|
|
2230
2328
|
is_public?: boolean;
|
|
2231
2329
|
is_featured?: boolean;
|
|
2330
|
+
/** Sort weight for ordering quests (lower = first). Default 0. */
|
|
2331
|
+
display_order?: number;
|
|
2232
2332
|
tags?: string[];
|
|
2233
2333
|
steps: CreateQuestStepRequest[];
|
|
2234
2334
|
}
|
|
@@ -2242,6 +2342,10 @@ interface CreateQuestStepRequest {
|
|
|
2242
2342
|
criteria?: Record<string, any>;
|
|
2243
2343
|
required_data_fields?: string[];
|
|
2244
2344
|
step_points?: number;
|
|
2345
|
+
/** Button text for call-to-action (e.g., "Read Article", "Visit Store") */
|
|
2346
|
+
cta_text?: string;
|
|
2347
|
+
/** URL or deeplink for the call-to-action button */
|
|
2348
|
+
cta_url?: string;
|
|
2245
2349
|
icon_url?: string;
|
|
2246
2350
|
is_optional?: boolean;
|
|
2247
2351
|
}
|
|
@@ -2979,6 +3083,14 @@ declare class FanpassLeaderboardClient {
|
|
|
2979
3083
|
* ```
|
|
2980
3084
|
*/
|
|
2981
3085
|
|
|
3086
|
+
/** Web Push subscription info as returned by the browser Push API. */
|
|
3087
|
+
interface PushSubscriptionJSON {
|
|
3088
|
+
endpoint: string;
|
|
3089
|
+
keys: {
|
|
3090
|
+
p256dh: string;
|
|
3091
|
+
auth: string;
|
|
3092
|
+
};
|
|
3093
|
+
}
|
|
2982
3094
|
/** Notification event types pushed by the server. */
|
|
2983
3095
|
type NotificationEventType = 'connected' | 'quest_step_completed' | 'quest_completed' | 'reward_earned' | 'reward_distributed' | 'reward_claimable' | 'points_awarded' | 'badge_earned' | 'level_up';
|
|
2984
3096
|
/** A notification event received from the SSE stream. */
|
|
@@ -3014,6 +3126,7 @@ interface SubscribeOptions {
|
|
|
3014
3126
|
/** Function to call to unsubscribe / close the SSE connection. */
|
|
3015
3127
|
type Unsubscribe = () => void;
|
|
3016
3128
|
declare class NotificationsClient {
|
|
3129
|
+
private http;
|
|
3017
3130
|
private baseUrl;
|
|
3018
3131
|
private authHeaders;
|
|
3019
3132
|
constructor(http: HttpClient);
|
|
@@ -3034,6 +3147,265 @@ declare class NotificationsClient {
|
|
|
3034
3147
|
* @returns Unsubscribe function to close the connection
|
|
3035
3148
|
*/
|
|
3036
3149
|
subscribe(userId: string, callback: NotificationCallback, options?: SubscribeOptions): Unsubscribe;
|
|
3150
|
+
/**
|
|
3151
|
+
* Get the tenant's VAPID public key for Web Push.
|
|
3152
|
+
*
|
|
3153
|
+
* This key is needed to call `pushManager.subscribe()` in the browser.
|
|
3154
|
+
* Returns null if Web Push is not configured for this tenant.
|
|
3155
|
+
*/
|
|
3156
|
+
getVapidKey(): Promise<string | null>;
|
|
3157
|
+
/**
|
|
3158
|
+
* Register a browser push subscription with the server.
|
|
3159
|
+
*
|
|
3160
|
+
* Call this after the user grants notification permission and you
|
|
3161
|
+
* obtain a PushSubscription from `pushManager.subscribe()`.
|
|
3162
|
+
*
|
|
3163
|
+
* @param userId - External user ID
|
|
3164
|
+
* @param subscription - The PushSubscription object (or its JSON)
|
|
3165
|
+
* @returns Subscription ID from the server
|
|
3166
|
+
*/
|
|
3167
|
+
registerPush(userId: string, subscription: PushSubscriptionJSON | PushSubscription): Promise<{
|
|
3168
|
+
status: string;
|
|
3169
|
+
subscription_id: string;
|
|
3170
|
+
}>;
|
|
3171
|
+
/**
|
|
3172
|
+
* Remove a push subscription from the server.
|
|
3173
|
+
*
|
|
3174
|
+
* Call this when the user logs out or revokes notification permission.
|
|
3175
|
+
*
|
|
3176
|
+
* @param userId - External user ID
|
|
3177
|
+
* @param endpoint - The push endpoint URL to remove
|
|
3178
|
+
*/
|
|
3179
|
+
unregisterPush(userId: string, endpoint: string): Promise<{
|
|
3180
|
+
status: string;
|
|
3181
|
+
}>;
|
|
3182
|
+
/**
|
|
3183
|
+
* High-level helper: request permission, subscribe to push, and register.
|
|
3184
|
+
*
|
|
3185
|
+
* Handles the full Web Push registration flow:
|
|
3186
|
+
* 1. Fetches the VAPID public key from the server
|
|
3187
|
+
* 2. Requests notification permission from the user
|
|
3188
|
+
* 3. Registers a Service Worker (if not already registered)
|
|
3189
|
+
* 4. Subscribes to push via the Push API
|
|
3190
|
+
* 5. Sends the subscription to the server
|
|
3191
|
+
*
|
|
3192
|
+
* @param userId - External user ID
|
|
3193
|
+
* @param serviceWorkerPath - Path to the service worker file (default: '/sw.js')
|
|
3194
|
+
* @returns The PushSubscription, or null if denied/unavailable
|
|
3195
|
+
*
|
|
3196
|
+
* @example
|
|
3197
|
+
* ```typescript
|
|
3198
|
+
* const sub = await client.notifications.requestPermissionAndSubscribe(
|
|
3199
|
+
* 'user-123',
|
|
3200
|
+
* '/proofchain-sw.js'
|
|
3201
|
+
* );
|
|
3202
|
+
* if (sub) {
|
|
3203
|
+
* console.log('Push notifications enabled!');
|
|
3204
|
+
* }
|
|
3205
|
+
* ```
|
|
3206
|
+
*/
|
|
3207
|
+
requestPermissionAndSubscribe(userId: string, serviceWorkerPath?: string): Promise<PushSubscription | null>;
|
|
3208
|
+
/**
|
|
3209
|
+
* Generate a basic Service Worker script for handling push notifications.
|
|
3210
|
+
*
|
|
3211
|
+
* Returns JavaScript source code that can be saved as your sw.js file.
|
|
3212
|
+
* The generated worker handles `push` events (shows notification) and
|
|
3213
|
+
* `notificationclick` events (opens the app).
|
|
3214
|
+
*
|
|
3215
|
+
* @param defaultIcon - Optional default icon URL for notifications
|
|
3216
|
+
* @param defaultUrl - URL to open when notification is clicked (default: '/')
|
|
3217
|
+
* @returns Service Worker JavaScript source code as a string
|
|
3218
|
+
*
|
|
3219
|
+
* @example
|
|
3220
|
+
* ```typescript
|
|
3221
|
+
* // Save the output as /public/sw.js in your project
|
|
3222
|
+
* const swCode = client.notifications.generateServiceWorker({
|
|
3223
|
+
* defaultIcon: '/icon-192.png',
|
|
3224
|
+
* defaultUrl: '/',
|
|
3225
|
+
* });
|
|
3226
|
+
* ```
|
|
3227
|
+
*/
|
|
3228
|
+
generateServiceWorker(options?: {
|
|
3229
|
+
defaultIcon?: string;
|
|
3230
|
+
defaultUrl?: string;
|
|
3231
|
+
}): string;
|
|
3232
|
+
/** Convert a base64url-encoded VAPID key to a Uint8Array for the Push API. */
|
|
3233
|
+
private _urlBase64ToUint8Array;
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3236
|
+
/**
|
|
3237
|
+
* Identity Credentials API Client
|
|
3238
|
+
*
|
|
3239
|
+
* Manage portable, verifiable credentials for end users.
|
|
3240
|
+
* Credentials are opt-in, issued by tenants, and publicly verifiable.
|
|
3241
|
+
*/
|
|
3242
|
+
|
|
3243
|
+
interface CredentialType {
|
|
3244
|
+
id: string;
|
|
3245
|
+
name: string;
|
|
3246
|
+
slug: string;
|
|
3247
|
+
description?: string;
|
|
3248
|
+
category?: string;
|
|
3249
|
+
icon_url?: string;
|
|
3250
|
+
badge_color?: string;
|
|
3251
|
+
display_order: number;
|
|
3252
|
+
schema_definition: Record<string, any>;
|
|
3253
|
+
is_revocable: boolean;
|
|
3254
|
+
default_expiry_days?: number;
|
|
3255
|
+
max_active_per_user: number;
|
|
3256
|
+
auto_renew: boolean;
|
|
3257
|
+
default_visibility: 'public' | 'tenant_only' | 'user_controlled';
|
|
3258
|
+
requires_opt_in: boolean;
|
|
3259
|
+
status: 'draft' | 'active' | 'archived';
|
|
3260
|
+
total_issued: number;
|
|
3261
|
+
total_active: number;
|
|
3262
|
+
created_at: string;
|
|
3263
|
+
}
|
|
3264
|
+
interface IssuedCredential {
|
|
3265
|
+
id: string;
|
|
3266
|
+
credential_type_id: string;
|
|
3267
|
+
credential_type_name: string;
|
|
3268
|
+
credential_type_slug: string;
|
|
3269
|
+
user_id: string;
|
|
3270
|
+
user_external_id?: string;
|
|
3271
|
+
verification_code: string;
|
|
3272
|
+
credential_data: Record<string, any>;
|
|
3273
|
+
issued_by?: string;
|
|
3274
|
+
issue_reason?: string;
|
|
3275
|
+
visibility: 'public' | 'tenant_only' | 'user_controlled';
|
|
3276
|
+
status: 'active' | 'suspended' | 'revoked' | 'expired';
|
|
3277
|
+
is_valid: boolean;
|
|
3278
|
+
expires_at?: string;
|
|
3279
|
+
issued_at: string;
|
|
3280
|
+
verification_count: number;
|
|
3281
|
+
last_verified_at?: string;
|
|
3282
|
+
}
|
|
3283
|
+
interface CredentialVerifyResult {
|
|
3284
|
+
valid: boolean;
|
|
3285
|
+
status: string;
|
|
3286
|
+
credential_type: string;
|
|
3287
|
+
credential_type_slug: string;
|
|
3288
|
+
category?: string;
|
|
3289
|
+
icon_url?: string;
|
|
3290
|
+
badge_color?: string;
|
|
3291
|
+
credential_data: Record<string, any>;
|
|
3292
|
+
issued_at: string;
|
|
3293
|
+
expires_at?: string;
|
|
3294
|
+
issuer: string;
|
|
3295
|
+
verification_count: number;
|
|
3296
|
+
}
|
|
3297
|
+
interface UserCredentialsSummary {
|
|
3298
|
+
credentials_enabled: boolean;
|
|
3299
|
+
total_credentials: number;
|
|
3300
|
+
active_credentials: number;
|
|
3301
|
+
credentials: IssuedCredential[];
|
|
3302
|
+
}
|
|
3303
|
+
interface CreateCredentialTypeRequest {
|
|
3304
|
+
name: string;
|
|
3305
|
+
slug?: string;
|
|
3306
|
+
description?: string;
|
|
3307
|
+
category?: string;
|
|
3308
|
+
icon_url?: string;
|
|
3309
|
+
badge_color?: string;
|
|
3310
|
+
display_order?: number;
|
|
3311
|
+
schema_definition?: Record<string, any>;
|
|
3312
|
+
is_revocable?: boolean;
|
|
3313
|
+
default_expiry_days?: number;
|
|
3314
|
+
max_active_per_user?: number;
|
|
3315
|
+
auto_renew?: boolean;
|
|
3316
|
+
default_visibility?: 'public' | 'tenant_only' | 'user_controlled';
|
|
3317
|
+
requires_opt_in?: boolean;
|
|
3318
|
+
auto_issue_on_quest?: string;
|
|
3319
|
+
auto_issue_on_segment?: string;
|
|
3320
|
+
}
|
|
3321
|
+
interface IssueCredentialRequest {
|
|
3322
|
+
credential_type_id: string;
|
|
3323
|
+
user_id: string;
|
|
3324
|
+
credential_data?: Record<string, any>;
|
|
3325
|
+
issue_reason?: string;
|
|
3326
|
+
visibility?: 'public' | 'tenant_only' | 'user_controlled';
|
|
3327
|
+
expires_at?: string;
|
|
3328
|
+
}
|
|
3329
|
+
interface ListIssuedCredentialsOptions {
|
|
3330
|
+
user_id?: string;
|
|
3331
|
+
credential_type_id?: string;
|
|
3332
|
+
status?: 'active' | 'suspended' | 'revoked' | 'expired';
|
|
3333
|
+
limit?: number;
|
|
3334
|
+
offset?: number;
|
|
3335
|
+
}
|
|
3336
|
+
declare class CredentialsClient {
|
|
3337
|
+
private http;
|
|
3338
|
+
constructor(http: HttpClient);
|
|
3339
|
+
/**
|
|
3340
|
+
* Create a new credential type
|
|
3341
|
+
*/
|
|
3342
|
+
createType(request: CreateCredentialTypeRequest): Promise<CredentialType>;
|
|
3343
|
+
/**
|
|
3344
|
+
* List credential types
|
|
3345
|
+
*/
|
|
3346
|
+
listTypes(options?: {
|
|
3347
|
+
status?: string;
|
|
3348
|
+
category?: string;
|
|
3349
|
+
}): Promise<CredentialType[]>;
|
|
3350
|
+
/**
|
|
3351
|
+
* Get a specific credential type
|
|
3352
|
+
*/
|
|
3353
|
+
getType(typeId: string): Promise<CredentialType>;
|
|
3354
|
+
/**
|
|
3355
|
+
* Update a credential type
|
|
3356
|
+
*/
|
|
3357
|
+
updateType(typeId: string, request: CreateCredentialTypeRequest): Promise<CredentialType>;
|
|
3358
|
+
/**
|
|
3359
|
+
* Activate a credential type
|
|
3360
|
+
*/
|
|
3361
|
+
activateType(typeId: string): Promise<CredentialType>;
|
|
3362
|
+
/**
|
|
3363
|
+
* Archive a credential type
|
|
3364
|
+
*/
|
|
3365
|
+
archiveType(typeId: string): Promise<CredentialType>;
|
|
3366
|
+
/**
|
|
3367
|
+
* Issue a credential to a user
|
|
3368
|
+
*/
|
|
3369
|
+
issue(request: IssueCredentialRequest): Promise<IssuedCredential>;
|
|
3370
|
+
/**
|
|
3371
|
+
* List issued credentials
|
|
3372
|
+
*/
|
|
3373
|
+
listIssued(options?: ListIssuedCredentialsOptions): Promise<IssuedCredential[]>;
|
|
3374
|
+
/**
|
|
3375
|
+
* Revoke an issued credential
|
|
3376
|
+
*/
|
|
3377
|
+
revoke(credentialId: string, reason?: string): Promise<IssuedCredential>;
|
|
3378
|
+
/**
|
|
3379
|
+
* Suspend an issued credential
|
|
3380
|
+
*/
|
|
3381
|
+
suspend(credentialId: string, reason?: string): Promise<IssuedCredential>;
|
|
3382
|
+
/**
|
|
3383
|
+
* Reinstate a suspended credential
|
|
3384
|
+
*/
|
|
3385
|
+
reinstate(credentialId: string): Promise<IssuedCredential>;
|
|
3386
|
+
/**
|
|
3387
|
+
* Opt a user in to identity credentials (tenant admin)
|
|
3388
|
+
*/
|
|
3389
|
+
optInUser(userExternalId: string): Promise<{
|
|
3390
|
+
status: string;
|
|
3391
|
+
credentials_enabled: boolean;
|
|
3392
|
+
}>;
|
|
3393
|
+
/**
|
|
3394
|
+
* Opt a user out of identity credentials (tenant admin)
|
|
3395
|
+
*/
|
|
3396
|
+
optOutUser(userExternalId: string): Promise<{
|
|
3397
|
+
status: string;
|
|
3398
|
+
credentials_enabled: boolean;
|
|
3399
|
+
}>;
|
|
3400
|
+
/**
|
|
3401
|
+
* Get all credentials for a user
|
|
3402
|
+
*/
|
|
3403
|
+
getUserCredentials(userExternalId: string): Promise<UserCredentialsSummary>;
|
|
3404
|
+
/**
|
|
3405
|
+
* Verify a credential by its verification code.
|
|
3406
|
+
* This is a public endpoint — no authentication required.
|
|
3407
|
+
*/
|
|
3408
|
+
verify(verificationCode: string): Promise<CredentialVerifyResult>;
|
|
3037
3409
|
}
|
|
3038
3410
|
|
|
3039
3411
|
/**
|
|
@@ -3232,6 +3604,8 @@ declare class ProofChain {
|
|
|
3232
3604
|
fanpassLeaderboard: FanpassLeaderboardClient;
|
|
3233
3605
|
/** Notifications client for real-time SSE streaming */
|
|
3234
3606
|
notifications: NotificationsClient;
|
|
3607
|
+
/** Credentials client for portable identity credentials */
|
|
3608
|
+
credentials: CredentialsClient;
|
|
3235
3609
|
constructor(options: ProofChainOptions);
|
|
3236
3610
|
/**
|
|
3237
3611
|
* Create a client for end-user JWT authentication (PWA/frontend use).
|
|
@@ -3447,4 +3821,4 @@ declare class TimeoutError extends ProofChainError {
|
|
|
3447
3821
|
constructor(message?: string);
|
|
3448
3822
|
}
|
|
3449
3823
|
|
|
3450
|
-
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 ClaimNFTResult, 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, type DistributeResult, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, EndUserIngestionClient, type EndUserIngestionClientOptions, 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 NotificationCallback, type NotificationEvent, type NotificationEventType, NotificationsClient, 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 RevokeResult, 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 SubscribeOptions, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type Unsubscribe, 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 };
|
|
3824
|
+
export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type AnchorResult, 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 ClaimNFTResult, type ClaimRewardResult, type CohortDefinition, type CohortGroupStats, CohortLeaderboardClient, type CohortLeaderboardEntry, type CohortLeaderboardOptions, type CohortLeaderboardResponse, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateCredentialTypeRequest, 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 CredentialType, type CredentialVerifyResult, CredentialsClient, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, type DistributeResult, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, EndUserIngestionClient, type EndUserIngestionClientOptions, 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 IssueCredentialRequest, type IssuedCredential, type LeaderboardUserProfile$1 as LeaderboardUserProfile, type LinkWalletRequest, type ListCertificatesRequest, type ListCohortsOptions, type ListEndUsersOptions, type ListEventsRequest, type ListIssuedCredentialsOptions, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type NotificationCallback, type NotificationEvent, type NotificationEventType, NotificationsClient, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type PushSubscriptionJSON, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RegisterWalletRequest, type RevokeResult, type RewardAsset, type RewardAttestationResult, type RewardDefinition, type RewardEarned, type VerifyResult as RewardVerifyResult, 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 SubscribeOptions, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type Unsubscribe, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserBreakdownResponse, type UserCohortBreakdownEntry, type UserCredentialsSummary, 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 };
|