@campnetwork/origin 1.2.0-2 → 1.2.0-3

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.
@@ -1,711 +1,711 @@
1
- import React, { JSX } from 'react';
2
- import { Address, Hex, WalletClient, Abi } from 'viem';
3
- import { UseQueryResult } from '@tanstack/react-query';
4
-
5
- interface Environment {
6
- NAME: string;
7
- AUTH_HUB_BASE_API: string;
8
- AUTH_ENDPOINT: string;
9
- ORIGIN_DASHBOARD: string;
10
- DATANFT_CONTRACT_ADDRESS: string;
11
- MARKETPLACE_CONTRACT_ADDRESS: string;
12
- CHAIN: any;
13
- IPNFT_ABI?: any;
14
- MARKETPLACE_ABI?: any;
15
- ROYALTY_VAULT_ABI?: any;
16
- TBA_ABI?: any;
17
- }
18
-
19
- /**
20
- * Represents the terms of a license for a digital asset.
21
- * @property price - The price of the asset in wei.
22
- * @property duration - The duration of the license in seconds.
23
- * @property royaltyBps - The royalty percentage in basis points (0-10000).
24
- * @property paymentToken - The address of the payment token (ERC20 / address(0) for native currency).
25
- */
26
- type LicenseTerms = {
27
- price: bigint;
28
- duration: number;
29
- royaltyBps: number;
30
- paymentToken: Address;
31
- };
32
- /**
33
- * Enum representing the status of data in the system.
34
- * * - ACTIVE: The data is currently active and available.
35
- * * - PENDING_DELETE: The data is scheduled for deletion but not yet removed.
36
- * * - DELETED: The data has been deleted and is no longer available.
37
- */
38
- declare enum DataStatus {
39
- ACTIVE = 0,
40
- PENDING_DELETE = 1,
41
- DELETED = 2
42
- }
43
- /**
44
- * Represents the source of an IpNFT.
45
- * This can be one of the supported social media platforms or a file upload.
46
- */
47
- type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
48
-
49
- /**
50
- * Mints a Data NFT with a signature.
51
- * @param to The address to mint the NFT to.
52
- * @param tokenId The ID of the token to mint.
53
- * @param parents The IDs of the parent NFTs, if applicable.
54
- * @param hash The hash of the data associated with the NFT.
55
- * @param uri The URI of the NFT metadata.
56
- * @param licenseTerms The terms of the license for the NFT.
57
- * @param deadline The deadline for the minting operation.
58
- * @param signature The signature for the minting operation.
59
- * @returns A promise that resolves when the minting is complete.
60
- */
61
- declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, parents: bigint[], isIp: boolean, hash: Hex, uri: string, licenseTerms: LicenseTerms, deadline: bigint, signature: Hex): Promise<any>;
62
- /**
63
- * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
64
- * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
65
- * @param deadline The deadline for the registration operation.
66
- * @param fileKey Optional file key for file uploads.
67
- * @return A promise that resolves with the registration data.
68
- */
69
- declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
70
-
71
- /**
72
- * Updates the license terms of a specified IPNFT.
73
- * @param tokenId The ID of the IPNFT to update.
74
- * @param newTerms The new license terms to set.
75
- * @returns A promise that resolves when the transaction is complete.
76
- */
77
- declare function updateTerms(this: Origin, tokenId: bigint, newTerms: LicenseTerms): Promise<any>;
78
-
79
- /**
80
- * Sets the IPNFT as deleted
81
- * @param tokenId The token ID to set as deleted.
82
- * @returns A promise that resolves when the transaction is complete.
83
- */
84
- declare function finalizeDelete(this: Origin, tokenId: bigint): Promise<any>;
85
-
86
- /**
87
- * Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
88
- * @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
89
- * @param simulateOnly If true, simulates the transaction without executing it.
90
- * @returns The address of the royalty vault associated with the specified token owner.
91
- */
92
- declare function getOrCreateRoyaltyVault(this: Origin, tokenOwner: Address, simulateOnly?: boolean): Promise<Address>;
93
-
94
- /**
95
- * Returns the license terms associated with a specific token ID.
96
- * @param tokenId The token ID to query.
97
- * @returns The license terms of the token ID.
98
- */
99
- declare function getTerms(this: Origin, tokenId: bigint): Promise<any>;
100
-
101
- /**
102
- * Returns the owner of the specified IPNFT.
103
- * @param tokenId The ID of the IPNFT to query.
104
- * @returns The address of the owner of the IPNFT.
105
- */
106
- declare function ownerOf(this: Origin, tokenId: bigint): Promise<any>;
107
-
108
- /**
109
- * Returns the number of IPNFTs owned by the given address.
110
- * @param owner The address to query.
111
- * @returns The number of IPNFTs owned by the address.
112
- */
113
- declare function balanceOf(this: Origin, owner: Address): Promise<any>;
114
-
115
- /**
116
- * Returns the metadata URI associated with a specific token ID.
117
- * @param tokenId The token ID to query.
118
- * @returns The metadata URI of the token ID.
119
- */
120
- declare function tokenURI(this: Origin, tokenId: bigint): Promise<any>;
121
-
122
- /**
123
- * Returns the data status of the given token ID.
124
- * @param tokenId The token ID to query.
125
- * @returns The data status of the token ID.
126
- */
127
- declare function dataStatus(this: Origin, tokenId: bigint): Promise<DataStatus>;
128
-
129
- /**
130
- * Checks if an operator is approved to manage all assets of a given owner.
131
- * @param owner The address of the asset owner.
132
- * @param operator The address of the operator to check.
133
- * @return A promise that resolves to a boolean indicating if the operator is approved for all assets of the owner.
134
- */
135
- declare function isApprovedForAll(this: Origin, owner: Address, operator: Address): Promise<boolean>;
136
-
137
- declare function transferFrom(this: Origin, from: Address, to: Address, tokenId: bigint): Promise<any>;
138
-
139
- declare function safeTransferFrom(this: Origin, from: Address, to: Address, tokenId: bigint, data?: Hex): Promise<any>;
140
-
141
- declare function approve(this: Origin, to: Address, tokenId: bigint): Promise<any>;
142
-
143
- declare function setApprovalForAll(this: Origin, operator: Address, approved: boolean): Promise<any>;
144
-
145
- /**
146
- * Buys access to a data NFT for a specified duration.
147
- * @param buyer The address of the buyer.
148
- * @param tokenId The ID of the data NFT.
149
- * @param expectedPrice The expected price for the access.
150
- * @param expectedDuration The expected duration of the access in seconds.
151
- * @param expectedPaymentToken The address of the payment token (use zero address for native token).
152
- * @param value The amount of native token to send (only required if paying with native token).
153
- * @returns A promise that resolves when the transaction is confirmed.
154
- */
155
- declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, value?: bigint): Promise<any>;
156
-
157
- /**
158
- * Checks if a user has access to a specific token based on subscription expiry.
159
- * @param user - The address of the user.
160
- * @param tokenId - The ID of the token.
161
- * @returns A promise that resolves to a boolean indicating if the user has access.
162
- */
163
- declare function hasAccess(this: Origin, user: Address, tokenId: bigint): Promise<boolean>;
164
-
165
- declare function subscriptionExpiry(this: Origin, tokenId: bigint, user: Address): Promise<bigint>;
166
-
167
- interface OriginUsageReturnType {
168
- user: {
169
- multiplier: number;
170
- points: number;
171
- active: boolean;
172
- };
173
- teams: Array<any>;
174
- dataSources: Array<any>;
175
- }
176
- interface RoyaltyInfo {
177
- tokenBoundAccount: Address;
178
- balance: bigint;
179
- balanceFormatted: string;
180
- }
181
- type CallOptions = {
182
- value?: bigint;
183
- gas?: bigint;
184
- waitForReceipt?: boolean;
185
- simulate?: boolean;
186
- };
187
- /**
188
- * The Origin class
189
- * Handles the upload of files to Origin, as well as querying the user's stats
190
- */
191
- declare class Origin {
192
- #private;
193
- mintWithSignature: typeof mintWithSignature;
194
- registerIpNFT: typeof registerIpNFT;
195
- updateTerms: typeof updateTerms;
196
- finalizeDelete: typeof finalizeDelete;
197
- getOrCreateRoyaltyVault: typeof getOrCreateRoyaltyVault;
198
- getTerms: typeof getTerms;
199
- ownerOf: typeof ownerOf;
200
- balanceOf: typeof balanceOf;
201
- tokenURI: typeof tokenURI;
202
- dataStatus: typeof dataStatus;
203
- isApprovedForAll: typeof isApprovedForAll;
204
- transferFrom: typeof transferFrom;
205
- safeTransferFrom: typeof safeTransferFrom;
206
- approve: typeof approve;
207
- setApprovalForAll: typeof setApprovalForAll;
208
- buyAccess: typeof buyAccess;
209
- hasAccess: typeof hasAccess;
210
- subscriptionExpiry: typeof subscriptionExpiry;
211
- private jwt;
212
- environment: Environment;
213
- private viemClient?;
214
- constructor(jwt: string, environment: Environment, viemClient?: WalletClient);
215
- getJwt(): string;
216
- setViemClient(client: WalletClient): void;
217
- uploadFile(file: File, options?: {
218
- progressCallback?: (percent: number) => void;
219
- }): Promise<any>;
220
- mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
221
- progressCallback?: (percent: number) => void;
222
- }): Promise<string | null>;
223
- mintSocial(source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms): Promise<string | null>;
224
- getOriginUploads(): Promise<any[] | null>;
225
- /**
226
- * Get the user's Origin stats (multiplier, consent, usage, etc.).
227
- * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
228
- */
229
- getOriginUsage(): Promise<OriginUsageReturnType>;
230
- /**
231
- * Set the user's consent for Origin usage.
232
- * @param {boolean} consent The user's consent.
233
- * @returns {Promise<void>}
234
- * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
235
- */
236
- setOriginConsent(consent: boolean): Promise<void>;
237
- /**
238
- * Call a contract method.
239
- * @param {string} contractAddress The contract address.
240
- * @param {Abi} abi The contract ABI.
241
- * @param {string} methodName The method name.
242
- * @param {any[]} params The method parameters.
243
- * @param {CallOptions} [options] The call options.
244
- * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
245
- * @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
246
- */
247
- callContractMethod(contractAddress: string, abi: Abi, methodName: string, params: any[], options?: CallOptions): Promise<any>;
248
- /**
249
- * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
250
- * @param {bigint} tokenId The token ID of the asset.
251
- * @returns {Promise<any>} The result of the buyAccess call.
252
- */
253
- buyAccessSmart(tokenId: bigint): Promise<any>;
254
- getData(tokenId: bigint): Promise<any>;
255
- /**
256
- * Get the Token Bound Account (TBA) address for a specific token ID.
257
- * @param {bigint} tokenId - The token ID to get the TBA address for.
258
- * @returns {Promise<Address>} A promise that resolves with the TBA address.
259
- * @throws {Error} Throws an error if the TBA address cannot be retrieved.
260
- * @example
261
- * ```typescript
262
- * const tbaAddress = await origin.getTokenBoundAccount(1n);
263
- * console.log(`TBA Address: ${tbaAddress}`);
264
- * ```
265
- */
266
- getTokenBoundAccount(tokenId: bigint): Promise<Address>;
267
- /**
268
- * Get royalty information for a token ID, including the token bound account address and its balance.
269
- * @param {bigint} tokenId - The token ID to check royalties for.
270
- * @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
271
- * @returns {Promise<RoyaltyInfo>} A promise that resolves with the token bound account address and balance information.
272
- * @throws {Error} Throws an error if the token bound account cannot be retrieved.
273
- * @example
274
- * ```typescript
275
- * // Get royalties for a specific token
276
- * const royalties = await origin.getRoyalties(1n);
277
- *
278
- * // Get ERC20 token royalties for a specific token
279
- * const royalties = await origin.getRoyalties(1n, "0x1234...");
280
- * ```
281
- */
282
- getRoyalties(tokenId: bigint, token?: Address): Promise<RoyaltyInfo>;
283
- /**
284
- * Claim royalties from a token's Token Bound Account (TBA).
285
- * @param {bigint} tokenId - The token ID to claim royalties from.
286
- * @param {Address} [recipient] - Optional recipient address. If not provided, uses the connected wallet.
287
- * @param {Address} [token] - Optional token address to claim royalties in. If not provided, claims in native token.
288
- * @returns {Promise<any>} A promise that resolves when the claim transaction is confirmed.
289
- * @throws {Error} Throws an error if no wallet is connected and no recipient address is provided.
290
- * @example
291
- * ```typescript
292
- * // Claim native token royalties for token #1 to connected wallet
293
- * await origin.claimRoyalties(1n);
294
- *
295
- * // Claim ERC20 token royalties to a specific address
296
- * await origin.claimRoyalties(1n, "0xRecipient...", "0xToken...");
297
- * ```
298
- */
299
- claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
300
- }
301
-
302
- interface StorageAdapter {
303
- getItem(key: string): Promise<string | null>;
304
- setItem(key: string, value: string): Promise<void>;
305
- removeItem(key: string): Promise<void>;
306
- }
307
-
308
- declare global {
309
- interface Window {
310
- ethereum?: any;
311
- }
312
- }
313
- /**
314
- * The Auth class.
315
- * @class
316
- * @classdesc The Auth class is used to authenticate the user.
317
- */
318
- declare class Auth {
319
- #private;
320
- redirectUri: Record<string, string>;
321
- clientId: string;
322
- isAuthenticated: boolean;
323
- jwt: string | null;
324
- walletAddress: string | null;
325
- userId: string | null;
326
- viem: any;
327
- origin: Origin | null;
328
- environment: Environment;
329
- /**
330
- * Constructor for the Auth class.
331
- * @param {object} options The options object.
332
- * @param {string} options.clientId The client ID.
333
- * @param {string|object} options.redirectUri The redirect URI used for oauth. Leave empty if you want to use the current URL. If you want different redirect URIs for different socials, pass an object with the socials as keys and the redirect URIs as values.
334
- * @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
335
- * @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
336
- * @throws {APIError} - Throws an error if the clientId is not provided.
337
- */
338
- constructor({ clientId, redirectUri, environment, storage, }: {
339
- clientId: string;
340
- redirectUri: string | Record<string, string>;
341
- environment?: "DEVELOPMENT" | "PRODUCTION";
342
- storage?: StorageAdapter;
343
- });
344
- /**
345
- * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
346
- * @param {("state"|"provider"|"providers"|"viem")} event The event.
347
- * @param {function} callback The callback function.
348
- * @returns {void}
349
- * @example
350
- * auth.on("state", (state) => {
351
- * console.log(state);
352
- * });
353
- */
354
- on(event: "state" | "provider" | "providers" | "viem", callback: Function): void;
355
- /**
356
- * Unsubscribe from an event. Possible events are "state", "provider", "providers", and "viem".
357
- * @param {("state"|"provider"|"providers"|"viem")} event The event.
358
- * @param {function} callback The callback function.
359
- * @returns {void}
360
- */
361
- off(event: "state" | "provider" | "providers" | "viem", callback: Function): void;
362
- /**
363
- * Set the loading state.
364
- * @param {boolean} loading The loading state.
365
- * @returns {void}
366
- */
367
- setLoading(loading: boolean): void;
368
- /**
369
- * Set the provider. This is useful for setting the provider when the user selects a provider from the UI or when dApp wishes to use a specific provider.
370
- * @param {object} options The options object. Includes the provider and the provider info.
371
- * @returns {void}
372
- * @throws {APIError} - Throws an error if the provider is not provided.
373
- */
374
- setProvider({ provider, info, address, }: {
375
- provider: any;
376
- info: any;
377
- address?: string;
378
- }): void;
379
- /**
380
- * Set the wallet address. This is useful for edge cases where the provider can't return the wallet address. Don't use this unless you know what you're doing.
381
- * @param {string} walletAddress The wallet address.
382
- * @returns {void}
383
- */
384
- setWalletAddress(walletAddress: string): void;
385
- /**
386
- * Recover the provider from local storage.
387
- * @returns {Promise<void>}
388
- */
389
- recoverProvider(): Promise<void>;
390
- /**
391
- * Disconnect the user.
392
- * @returns {Promise<void>}
393
- */
394
- disconnect(): Promise<void>;
395
- /**
396
- * Connect the user's wallet and sign the message.
397
- * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
398
- * @throws {APIError} - Throws an error if the user cannot be authenticated.
399
- */
400
- connect(): Promise<{
401
- success: boolean;
402
- message: string;
403
- walletAddress: string;
404
- }>;
405
- /**
406
- * Connect with a custom signer (for Node.js or custom wallet implementations).
407
- * This method bypasses browser wallet interactions and uses the provided signer directly.
408
- * @param {any} signer The signer instance (viem WalletClient, ethers Signer, or custom signer).
409
- * @param {object} [options] Optional configuration.
410
- * @param {string} [options.domain] The domain to use in SIWE message (defaults to 'localhost').
411
- * @param {string} [options.uri] The URI to use in SIWE message (defaults to 'http://localhost').
412
- * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
413
- * @throws {APIError} - Throws an error if authentication fails.
414
- * @example
415
- * // Using with ethers
416
- * const signer = new ethers.Wallet(privateKey, provider);
417
- * await auth.connectWithSigner(signer, { domain: 'myapp.com', uri: 'https://myapp.com' });
418
- *
419
- * // Using with viem
420
- * const account = privateKeyToAccount('0x...');
421
- * const client = createWalletClient({ account, chain: mainnet, transport: http() });
422
- * await auth.connectWithSigner(client);
423
- */
424
- connectWithSigner(signer: any, options?: {
425
- domain?: string;
426
- uri?: string;
427
- }): Promise<{
428
- success: boolean;
429
- message: string;
430
- walletAddress: string;
431
- }>;
432
- /**
433
- * Get the user's linked social accounts.
434
- * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
435
- * @throws {Error|APIError} - Throws an error if the user is not authenticated or if the request fails.
436
- * @example
437
- * const auth = new Auth({ clientId: "your-client-id" });
438
- * const socials = await auth.getLinkedSocials();
439
- * console.log(socials);
440
- */
441
- getLinkedSocials(): Promise<Record<string, boolean>>;
442
- /**
443
- * Link the user's Twitter account.
444
- * @returns {Promise<void>}
445
- * @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
446
- */
447
- linkTwitter(): Promise<void>;
448
- /**
449
- * Link the user's Discord account.
450
- * @returns {Promise<void>}
451
- * @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
452
- */
453
- linkDiscord(): Promise<void>;
454
- /**
455
- * Link the user's Spotify account.
456
- * @returns {Promise<void>}
457
- * @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
458
- */
459
- linkSpotify(): Promise<void>;
460
- /**
461
- * Link the user's TikTok account.
462
- * @param {string} handle The user's TikTok handle.
463
- * @returns {Promise<any>} A promise that resolves with the TikTok account data.
464
- * @throws {Error|APIError} - Throws an error if the user is not authenticated.
465
- */
466
- linkTikTok(handle: string): Promise<any>;
467
- /**
468
- * Send an OTP to the user's Telegram account.
469
- * @param {string} phoneNumber The user's phone number.
470
- * @returns {Promise<any>} A promise that resolves with the OTP data.
471
- * @throws {Error|APIError} - Throws an error if the user is not authenticated.
472
- */
473
- sendTelegramOTP(phoneNumber: string): Promise<any>;
474
- /**
475
- * Link the user's Telegram account.
476
- * @param {string} phoneNumber The user's phone number.
477
- * @param {string} otp The OTP.
478
- * @param {string} phoneCodeHash The phone code hash.
479
- * @returns {Promise<object>} A promise that resolves with the Telegram account data.
480
- * @throws {APIError|Error} - Throws an error if the user is not authenticated. Also throws an error if the phone number, OTP, and phone code hash are not provided.
481
- */
482
- linkTelegram(phoneNumber: string, otp: string, phoneCodeHash: string): Promise<any>;
483
- /**
484
- * Unlink the user's Twitter account.
485
- * @returns {Promise<any>} A promise that resolves with the unlink result.
486
- * @throws {Error} - Throws an error if the user is not authenticated.
487
- * @throws {APIError} - Throws an error if the request fails.
488
- */
489
- unlinkTwitter(): Promise<any>;
490
- /**
491
- * Unlink the user's Discord account.
492
- * @returns {Promise<any>} A promise that resolves with the unlink result.
493
- * @throws {Error} - Throws an error if the user is not authenticated.
494
- * @throws {APIError} - Throws an error if the request fails.
495
- */
496
- unlinkDiscord(): Promise<any>;
497
- /**
498
- * Unlink the user's Spotify account.
499
- * @returns {Promise<any>} A promise that resolves with the unlink result.
500
- * @throws {Error} - Throws an error if the user is not authenticated.
501
- * @throws {APIError} - Throws an error if the request fails.
502
- */
503
- unlinkSpotify(): Promise<any>;
504
- /**
505
- * Unlink the user's TikTok account.
506
- * @returns {Promise<any>} A promise that resolves with the unlink result.
507
- * @throws {Error} - Throws an error if the user is not authenticated.
508
- * @throws {APIError} - Throws an error if the request fails.
509
- */
510
- unlinkTikTok(): Promise<any>;
511
- /**
512
- * Unlink the user's Telegram account.
513
- * @returns {Promise<any>} A promise that resolves with the unlink result.
514
- * @throws {Error} - Throws an error if the user is not authenticated.
515
- * @throws {APIError} - Throws an error if the request fails.
516
- */
517
- unlinkTelegram(): Promise<any>;
518
- }
519
-
520
- /**
521
- * CampContext
522
- * @type {React.Context}
523
- * @property {string} clientId The Camp client ID
524
- * @property {Auth} auth The Camp Auth instance
525
- * @property {function} setAuth The function to set the Camp Auth instance
526
- * @property {boolean} wagmiAvailable Whether Wagmi is available
527
- */
528
- interface CampContextType {
529
- clientId: string | null;
530
- auth: Auth | null;
531
- setAuth: React.Dispatch<React.SetStateAction<Auth | null>>;
532
- wagmiAvailable: boolean;
533
- environment: Environment;
534
- }
535
- declare const CampContext: React.Context<CampContextType>;
536
- /**
537
- * CampProvider
538
- * @param {Object} props The props
539
- * @param {string} props.clientId The Camp client ID
540
- * @param {string} props.redirectUri The redirect URI to use after social oauths
541
- * @param {React.ReactNode} props.children The children components
542
- * @param {boolean} props.allowAnalytics Whether to allow analytics to be sent
543
- * @returns {JSX.Element} The CampProvider component
544
- */
545
- declare const CampProvider: ({ clientId, redirectUri, children, environment, }: {
546
- clientId: string;
547
- redirectUri?: string;
548
- children: React.ReactNode;
549
- allowAnalytics?: boolean;
550
- environment?: "DEVELOPMENT" | "PRODUCTION";
551
- }) => React.JSX.Element;
552
-
553
- interface ModalContextProps {
554
- isButtonDisabled: boolean;
555
- setIsButtonDisabled: (isButtonDisabled: boolean) => void;
556
- isVisible: boolean;
557
- setIsVisible: (isVisible: boolean) => void;
558
- isLinkingVisible: boolean;
559
- setIsLinkingVisible: (isLinkingVisible: boolean) => void;
560
- currentlyLinking: any;
561
- setCurrentlyLinking: (currentlyLinking: any) => void;
562
- }
563
- declare const ModalContext: React.Context<ModalContextProps>;
564
-
565
- interface Provider {
566
- info: {
567
- uuid: string;
568
- name?: string;
569
- icon?: string;
570
- };
571
- provider: any;
572
- }
573
-
574
- interface CampModalProps {
575
- injectButton?: boolean;
576
- wcProjectId?: string;
577
- onlyWagmi?: boolean;
578
- defaultProvider?: any;
579
- }
580
- /**
581
- * The CampModal component.
582
- * @param { { injectButton?: boolean, wcProjectId?: string, onlyWagmi?: boolean, defaultProvider?: object } } props The props.
583
- * @returns { JSX.Element } The CampModal component.
584
- */
585
- declare const CampModal: ({ injectButton, wcProjectId, onlyWagmi, defaultProvider, }: CampModalProps) => JSX.Element;
586
- /**
587
- * The MyCampModal component.
588
- * @param { { wcProvider: object } } props The props.
589
- * @returns { JSX.Element } The MyCampModal component.
590
- */
591
- declare const MyCampModal: ({ wcProvider, }: {
592
- wcProvider: any;
593
- }) => JSX.Element;
594
-
595
- declare const StandaloneCampButton: () => JSX.Element | null;
596
- interface LinkButtonProps {
597
- variant?: "default" | "icon";
598
- social: "twitter" | "spotify" | "discord" | "tiktok" | "telegram";
599
- theme?: "default" | "camp";
600
- }
601
- /**
602
- * The LinkButton component.
603
- * A button that will open the modal to link or unlink a social account.
604
- * @param { { variant: ("default"|"icon"), social: ("twitter"|"spotify"|"discord"), theme: ("default"|"camp") } } props The props.
605
- * @returns { JSX.Element } The LinkButton component.
606
- */
607
- declare const LinkButton: ({ variant, social, theme, }: LinkButtonProps) => JSX.Element | null;
608
-
609
- /**
610
- * Returns the Auth instance provided by the context.
611
- * @returns { Auth } The Auth instance provided by the context.
612
- * @example
613
- * const auth = useAuth();
614
- * auth.connect();
615
- */
616
- declare const useAuth: () => Auth;
617
- /**
618
- * Returns the functions to link and unlink socials.
619
- * @returns { { linkTwitter: function, unlinkTwitter: function, linkDiscord: function, unlinkDiscord: function, linkSpotify: function, unlinkSpotify: function } } The functions to link and unlink socials.
620
- * @example
621
- * const { linkTwitter, unlinkTwitter, linkDiscord, unlinkDiscord, linkSpotify, unlinkSpotify } = useLinkSocials();
622
- * linkTwitter();
623
- */
624
- declare const useLinkSocials: () => Record<string, Function>;
625
- /**
626
- * Fetches the provider from the context and sets the provider in the auth instance.
627
- * @returns { { provider: { provider: string, info: { name: string } }, setProvider: function } } The provider and a function to set the provider.
628
- */
629
- declare const useProvider: () => {
630
- provider: {
631
- provider: any;
632
- info: {
633
- name: string;
634
- };
635
- };
636
- setProvider: (provider: any, info?: any) => void;
637
- };
638
- /**
639
- * Returns the authenticated state and loading state.
640
- * @returns { { authenticated: boolean, loading: boolean } } The authenticated state and loading state.
641
- */
642
- declare const useAuthState: () => {
643
- authenticated: boolean;
644
- loading: boolean;
645
- };
646
- declare const useViem: () => {
647
- client: any;
648
- };
649
- /**
650
- * Connects and disconnects the user.
651
- * @returns { { connect: function, disconnect: function } } The connect and disconnect functions.
652
- */
653
- declare const useConnect: () => {
654
- connect: () => Promise<{
655
- success: boolean;
656
- message: string;
657
- walletAddress: string;
658
- }>;
659
- disconnect: () => Promise<void>;
660
- };
661
- /**
662
- * Returns the array of providers.
663
- * @returns { Array } The array of providers and the loading state.
664
- */
665
- declare const useProviders: () => Provider[];
666
- /**
667
- * Returns the modal state and functions to open and close the modal.
668
- * @returns { { isOpen: boolean, openModal: function, closeModal: function } } The modal state and functions to open and close the modal.
669
- */
670
- declare const useModal: () => {
671
- isOpen: boolean;
672
- openModal: () => void;
673
- closeModal: () => void;
674
- };
675
- /**
676
- * Returns the functions to open and close the link modal.
677
- * @returns { { isLinkingOpen: boolean, closeModal: function, handleOpen: function } } The link modal state and functions to open and close the modal.
678
- */
679
- declare const useLinkModal: () => Record<string, Function | boolean> & {
680
- isLinkingOpen: boolean;
681
- closeModal: () => void;
682
- handleOpen: (social: string) => void;
683
- };
684
- type UseSocialsResult<TData = unknown, TError = Error> = UseQueryResult<TData, TError> & {
685
- socials: Record<string, string>;
686
- };
687
- /**
688
- * Fetches the socials linked to the user.
689
- * @returns { { data: {}, socials: {}, error: Error, isLoading: boolean, refetch: () => {} } } react-query query object.
690
- */
691
- declare const useSocials: () => UseSocialsResult;
692
- /**
693
- * Fetches the Origin usage data and uploads data.
694
- * @returns { usage: { data: any, isError: boolean, isLoading: boolean, refetch: () => void }, uploads: { data: any, isError: boolean, isLoading: boolean, refetch: () => void } } The Origin usage data and uploads data.
695
- */
696
- declare const useOrigin: () => {
697
- stats: {
698
- data: any;
699
- isError: boolean;
700
- isLoading: boolean;
701
- refetch: () => void;
702
- };
703
- uploads: {
704
- data: any[];
705
- isError: boolean;
706
- isLoading: boolean;
707
- refetch: () => void;
708
- };
709
- };
710
-
711
- export { StandaloneCampButton as CampButton, CampContext, CampModal, CampProvider, LinkButton, ModalContext, MyCampModal, useAuth, useAuthState, useConnect, useLinkModal, useLinkSocials, useModal, useOrigin, useProvider, useProviders, useSocials, useViem };
1
+ import React, { JSX } from 'react';
2
+ import { Address, Hex, WalletClient, Abi } from 'viem';
3
+ import { UseQueryResult } from '@tanstack/react-query';
4
+
5
+ interface Environment {
6
+ NAME: string;
7
+ AUTH_HUB_BASE_API: string;
8
+ AUTH_ENDPOINT: string;
9
+ ORIGIN_DASHBOARD: string;
10
+ DATANFT_CONTRACT_ADDRESS: string;
11
+ MARKETPLACE_CONTRACT_ADDRESS: string;
12
+ CHAIN: any;
13
+ IPNFT_ABI?: any;
14
+ MARKETPLACE_ABI?: any;
15
+ ROYALTY_VAULT_ABI?: any;
16
+ TBA_ABI?: any;
17
+ }
18
+
19
+ /**
20
+ * Represents the terms of a license for a digital asset.
21
+ * @property price - The price of the asset in wei.
22
+ * @property duration - The duration of the license in seconds.
23
+ * @property royaltyBps - The royalty percentage in basis points (0-10000).
24
+ * @property paymentToken - The address of the payment token (ERC20 / address(0) for native currency).
25
+ */
26
+ type LicenseTerms = {
27
+ price: bigint;
28
+ duration: number;
29
+ royaltyBps: number;
30
+ paymentToken: Address;
31
+ };
32
+ /**
33
+ * Enum representing the status of data in the system.
34
+ * * - ACTIVE: The data is currently active and available.
35
+ * * - PENDING_DELETE: The data is scheduled for deletion but not yet removed.
36
+ * * - DELETED: The data has been deleted and is no longer available.
37
+ */
38
+ declare enum DataStatus {
39
+ ACTIVE = 0,
40
+ PENDING_DELETE = 1,
41
+ DELETED = 2
42
+ }
43
+ /**
44
+ * Represents the source of an IpNFT.
45
+ * This can be one of the supported social media platforms or a file upload.
46
+ */
47
+ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
48
+
49
+ /**
50
+ * Mints a Data NFT with a signature.
51
+ * @param to The address to mint the NFT to.
52
+ * @param tokenId The ID of the token to mint.
53
+ * @param parents The IDs of the parent NFTs, if applicable.
54
+ * @param hash The hash of the data associated with the NFT.
55
+ * @param uri The URI of the NFT metadata.
56
+ * @param licenseTerms The terms of the license for the NFT.
57
+ * @param deadline The deadline for the minting operation.
58
+ * @param signature The signature for the minting operation.
59
+ * @returns A promise that resolves when the minting is complete.
60
+ */
61
+ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, parents: bigint[], isIp: boolean, hash: Hex, uri: string, licenseTerms: LicenseTerms, deadline: bigint, signature: Hex): Promise<any>;
62
+ /**
63
+ * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
64
+ * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
65
+ * @param deadline The deadline for the registration operation.
66
+ * @param fileKey Optional file key for file uploads.
67
+ * @return A promise that resolves with the registration data.
68
+ */
69
+ declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
70
+
71
+ /**
72
+ * Updates the license terms of a specified IPNFT.
73
+ * @param tokenId The ID of the IPNFT to update.
74
+ * @param newTerms The new license terms to set.
75
+ * @returns A promise that resolves when the transaction is complete.
76
+ */
77
+ declare function updateTerms(this: Origin, tokenId: bigint, newTerms: LicenseTerms): Promise<any>;
78
+
79
+ /**
80
+ * Sets the IPNFT as deleted
81
+ * @param tokenId The token ID to set as deleted.
82
+ * @returns A promise that resolves when the transaction is complete.
83
+ */
84
+ declare function finalizeDelete(this: Origin, tokenId: bigint): Promise<any>;
85
+
86
+ /**
87
+ * Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
88
+ * @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
89
+ * @param simulateOnly If true, simulates the transaction without executing it.
90
+ * @returns The address of the royalty vault associated with the specified token owner.
91
+ */
92
+ declare function getOrCreateRoyaltyVault(this: Origin, tokenOwner: Address, simulateOnly?: boolean): Promise<Address>;
93
+
94
+ /**
95
+ * Returns the license terms associated with a specific token ID.
96
+ * @param tokenId The token ID to query.
97
+ * @returns The license terms of the token ID.
98
+ */
99
+ declare function getTerms(this: Origin, tokenId: bigint): Promise<any>;
100
+
101
+ /**
102
+ * Returns the owner of the specified IPNFT.
103
+ * @param tokenId The ID of the IPNFT to query.
104
+ * @returns The address of the owner of the IPNFT.
105
+ */
106
+ declare function ownerOf(this: Origin, tokenId: bigint): Promise<any>;
107
+
108
+ /**
109
+ * Returns the number of IPNFTs owned by the given address.
110
+ * @param owner The address to query.
111
+ * @returns The number of IPNFTs owned by the address.
112
+ */
113
+ declare function balanceOf(this: Origin, owner: Address): Promise<any>;
114
+
115
+ /**
116
+ * Returns the metadata URI associated with a specific token ID.
117
+ * @param tokenId The token ID to query.
118
+ * @returns The metadata URI of the token ID.
119
+ */
120
+ declare function tokenURI(this: Origin, tokenId: bigint): Promise<any>;
121
+
122
+ /**
123
+ * Returns the data status of the given token ID.
124
+ * @param tokenId The token ID to query.
125
+ * @returns The data status of the token ID.
126
+ */
127
+ declare function dataStatus(this: Origin, tokenId: bigint): Promise<DataStatus>;
128
+
129
+ /**
130
+ * Checks if an operator is approved to manage all assets of a given owner.
131
+ * @param owner The address of the asset owner.
132
+ * @param operator The address of the operator to check.
133
+ * @return A promise that resolves to a boolean indicating if the operator is approved for all assets of the owner.
134
+ */
135
+ declare function isApprovedForAll(this: Origin, owner: Address, operator: Address): Promise<boolean>;
136
+
137
+ declare function transferFrom(this: Origin, from: Address, to: Address, tokenId: bigint): Promise<any>;
138
+
139
+ declare function safeTransferFrom(this: Origin, from: Address, to: Address, tokenId: bigint, data?: Hex): Promise<any>;
140
+
141
+ declare function approve(this: Origin, to: Address, tokenId: bigint): Promise<any>;
142
+
143
+ declare function setApprovalForAll(this: Origin, operator: Address, approved: boolean): Promise<any>;
144
+
145
+ /**
146
+ * Buys access to a data NFT for a specified duration.
147
+ * @param buyer The address of the buyer.
148
+ * @param tokenId The ID of the data NFT.
149
+ * @param expectedPrice The expected price for the access.
150
+ * @param expectedDuration The expected duration of the access in seconds.
151
+ * @param expectedPaymentToken The address of the payment token (use zero address for native token).
152
+ * @param value The amount of native token to send (only required if paying with native token).
153
+ * @returns A promise that resolves when the transaction is confirmed.
154
+ */
155
+ declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, value?: bigint): Promise<any>;
156
+
157
+ /**
158
+ * Checks if a user has access to a specific token based on subscription expiry.
159
+ * @param user - The address of the user.
160
+ * @param tokenId - The ID of the token.
161
+ * @returns A promise that resolves to a boolean indicating if the user has access.
162
+ */
163
+ declare function hasAccess(this: Origin, user: Address, tokenId: bigint): Promise<boolean>;
164
+
165
+ declare function subscriptionExpiry(this: Origin, tokenId: bigint, user: Address): Promise<bigint>;
166
+
167
+ interface OriginUsageReturnType {
168
+ user: {
169
+ multiplier: number;
170
+ points: number;
171
+ active: boolean;
172
+ };
173
+ teams: Array<any>;
174
+ dataSources: Array<any>;
175
+ }
176
+ interface RoyaltyInfo {
177
+ tokenBoundAccount: Address;
178
+ balance: bigint;
179
+ balanceFormatted: string;
180
+ }
181
+ type CallOptions = {
182
+ value?: bigint;
183
+ gas?: bigint;
184
+ waitForReceipt?: boolean;
185
+ simulate?: boolean;
186
+ };
187
+ /**
188
+ * The Origin class
189
+ * Handles the upload of files to Origin, as well as querying the user's stats
190
+ */
191
+ declare class Origin {
192
+ #private;
193
+ mintWithSignature: typeof mintWithSignature;
194
+ registerIpNFT: typeof registerIpNFT;
195
+ updateTerms: typeof updateTerms;
196
+ finalizeDelete: typeof finalizeDelete;
197
+ getOrCreateRoyaltyVault: typeof getOrCreateRoyaltyVault;
198
+ getTerms: typeof getTerms;
199
+ ownerOf: typeof ownerOf;
200
+ balanceOf: typeof balanceOf;
201
+ tokenURI: typeof tokenURI;
202
+ dataStatus: typeof dataStatus;
203
+ isApprovedForAll: typeof isApprovedForAll;
204
+ transferFrom: typeof transferFrom;
205
+ safeTransferFrom: typeof safeTransferFrom;
206
+ approve: typeof approve;
207
+ setApprovalForAll: typeof setApprovalForAll;
208
+ buyAccess: typeof buyAccess;
209
+ hasAccess: typeof hasAccess;
210
+ subscriptionExpiry: typeof subscriptionExpiry;
211
+ private jwt;
212
+ environment: Environment;
213
+ private viemClient?;
214
+ constructor(jwt: string, environment: Environment, viemClient?: WalletClient);
215
+ getJwt(): string;
216
+ setViemClient(client: WalletClient): void;
217
+ uploadFile(file: File, options?: {
218
+ progressCallback?: (percent: number) => void;
219
+ }): Promise<any>;
220
+ mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
221
+ progressCallback?: (percent: number) => void;
222
+ }): Promise<string | null>;
223
+ mintSocial(source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms): Promise<string | null>;
224
+ getOriginUploads(): Promise<any[] | null>;
225
+ /**
226
+ * Get the user's Origin stats (multiplier, consent, usage, etc.).
227
+ * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
228
+ */
229
+ getOriginUsage(): Promise<OriginUsageReturnType>;
230
+ /**
231
+ * Set the user's consent for Origin usage.
232
+ * @param {boolean} consent The user's consent.
233
+ * @returns {Promise<void>}
234
+ * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
235
+ */
236
+ setOriginConsent(consent: boolean): Promise<void>;
237
+ /**
238
+ * Call a contract method.
239
+ * @param {string} contractAddress The contract address.
240
+ * @param {Abi} abi The contract ABI.
241
+ * @param {string} methodName The method name.
242
+ * @param {any[]} params The method parameters.
243
+ * @param {CallOptions} [options] The call options.
244
+ * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
245
+ * @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
246
+ */
247
+ callContractMethod(contractAddress: string, abi: Abi, methodName: string, params: any[], options?: CallOptions): Promise<any>;
248
+ /**
249
+ * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
250
+ * @param {bigint} tokenId The token ID of the asset.
251
+ * @returns {Promise<any>} The result of the buyAccess call.
252
+ */
253
+ buyAccessSmart(tokenId: bigint): Promise<any>;
254
+ getData(tokenId: bigint): Promise<any>;
255
+ /**
256
+ * Get the Token Bound Account (TBA) address for a specific token ID.
257
+ * @param {bigint} tokenId - The token ID to get the TBA address for.
258
+ * @returns {Promise<Address>} A promise that resolves with the TBA address.
259
+ * @throws {Error} Throws an error if the TBA address cannot be retrieved.
260
+ * @example
261
+ * ```typescript
262
+ * const tbaAddress = await origin.getTokenBoundAccount(1n);
263
+ * console.log(`TBA Address: ${tbaAddress}`);
264
+ * ```
265
+ */
266
+ getTokenBoundAccount(tokenId: bigint): Promise<Address>;
267
+ /**
268
+ * Get royalty information for a token ID, including the token bound account address and its balance.
269
+ * @param {bigint} tokenId - The token ID to check royalties for.
270
+ * @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
271
+ * @returns {Promise<RoyaltyInfo>} A promise that resolves with the token bound account address and balance information.
272
+ * @throws {Error} Throws an error if the token bound account cannot be retrieved.
273
+ * @example
274
+ * ```typescript
275
+ * // Get royalties for a specific token
276
+ * const royalties = await origin.getRoyalties(1n);
277
+ *
278
+ * // Get ERC20 token royalties for a specific token
279
+ * const royalties = await origin.getRoyalties(1n, "0x1234...");
280
+ * ```
281
+ */
282
+ getRoyalties(tokenId: bigint, token?: Address): Promise<RoyaltyInfo>;
283
+ /**
284
+ * Claim royalties from a token's Token Bound Account (TBA).
285
+ * @param {bigint} tokenId - The token ID to claim royalties from.
286
+ * @param {Address} [recipient] - Optional recipient address. If not provided, uses the connected wallet.
287
+ * @param {Address} [token] - Optional token address to claim royalties in. If not provided, claims in native token.
288
+ * @returns {Promise<any>} A promise that resolves when the claim transaction is confirmed.
289
+ * @throws {Error} Throws an error if no wallet is connected and no recipient address is provided.
290
+ * @example
291
+ * ```typescript
292
+ * // Claim native token royalties for token #1 to connected wallet
293
+ * await origin.claimRoyalties(1n);
294
+ *
295
+ * // Claim ERC20 token royalties to a specific address
296
+ * await origin.claimRoyalties(1n, "0xRecipient...", "0xToken...");
297
+ * ```
298
+ */
299
+ claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
300
+ }
301
+
302
+ interface StorageAdapter {
303
+ getItem(key: string): Promise<string | null>;
304
+ setItem(key: string, value: string): Promise<void>;
305
+ removeItem(key: string): Promise<void>;
306
+ }
307
+
308
+ declare global {
309
+ interface Window {
310
+ ethereum?: any;
311
+ }
312
+ }
313
+ /**
314
+ * The Auth class.
315
+ * @class
316
+ * @classdesc The Auth class is used to authenticate the user.
317
+ */
318
+ declare class Auth {
319
+ #private;
320
+ redirectUri: Record<string, string>;
321
+ clientId: string;
322
+ isAuthenticated: boolean;
323
+ jwt: string | null;
324
+ walletAddress: string | null;
325
+ userId: string | null;
326
+ viem: any;
327
+ origin: Origin | null;
328
+ environment: Environment;
329
+ /**
330
+ * Constructor for the Auth class.
331
+ * @param {object} options The options object.
332
+ * @param {string} options.clientId The client ID.
333
+ * @param {string|object} options.redirectUri The redirect URI used for oauth. Leave empty if you want to use the current URL. If you want different redirect URIs for different socials, pass an object with the socials as keys and the redirect URIs as values.
334
+ * @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
335
+ * @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
336
+ * @throws {APIError} - Throws an error if the clientId is not provided.
337
+ */
338
+ constructor({ clientId, redirectUri, environment, storage, }: {
339
+ clientId: string;
340
+ redirectUri: string | Record<string, string>;
341
+ environment?: "DEVELOPMENT" | "PRODUCTION";
342
+ storage?: StorageAdapter;
343
+ });
344
+ /**
345
+ * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
346
+ * @param {("state"|"provider"|"providers"|"viem")} event The event.
347
+ * @param {function} callback The callback function.
348
+ * @returns {void}
349
+ * @example
350
+ * auth.on("state", (state) => {
351
+ * console.log(state);
352
+ * });
353
+ */
354
+ on(event: "state" | "provider" | "providers" | "viem", callback: Function): void;
355
+ /**
356
+ * Unsubscribe from an event. Possible events are "state", "provider", "providers", and "viem".
357
+ * @param {("state"|"provider"|"providers"|"viem")} event The event.
358
+ * @param {function} callback The callback function.
359
+ * @returns {void}
360
+ */
361
+ off(event: "state" | "provider" | "providers" | "viem", callback: Function): void;
362
+ /**
363
+ * Set the loading state.
364
+ * @param {boolean} loading The loading state.
365
+ * @returns {void}
366
+ */
367
+ setLoading(loading: boolean): void;
368
+ /**
369
+ * Set the provider. This is useful for setting the provider when the user selects a provider from the UI or when dApp wishes to use a specific provider.
370
+ * @param {object} options The options object. Includes the provider and the provider info.
371
+ * @returns {void}
372
+ * @throws {APIError} - Throws an error if the provider is not provided.
373
+ */
374
+ setProvider({ provider, info, address, }: {
375
+ provider: any;
376
+ info: any;
377
+ address?: string;
378
+ }): void;
379
+ /**
380
+ * Set the wallet address. This is useful for edge cases where the provider can't return the wallet address. Don't use this unless you know what you're doing.
381
+ * @param {string} walletAddress The wallet address.
382
+ * @returns {void}
383
+ */
384
+ setWalletAddress(walletAddress: string): void;
385
+ /**
386
+ * Recover the provider from local storage.
387
+ * @returns {Promise<void>}
388
+ */
389
+ recoverProvider(): Promise<void>;
390
+ /**
391
+ * Disconnect the user.
392
+ * @returns {Promise<void>}
393
+ */
394
+ disconnect(): Promise<void>;
395
+ /**
396
+ * Connect the user's wallet and sign the message.
397
+ * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
398
+ * @throws {APIError} - Throws an error if the user cannot be authenticated.
399
+ */
400
+ connect(): Promise<{
401
+ success: boolean;
402
+ message: string;
403
+ walletAddress: string;
404
+ }>;
405
+ /**
406
+ * Connect with a custom signer (for Node.js or custom wallet implementations).
407
+ * This method bypasses browser wallet interactions and uses the provided signer directly.
408
+ * @param {any} signer The signer instance (viem WalletClient, ethers Signer, or custom signer).
409
+ * @param {object} [options] Optional configuration.
410
+ * @param {string} [options.domain] The domain to use in SIWE message (defaults to 'localhost').
411
+ * @param {string} [options.uri] The URI to use in SIWE message (defaults to 'http://localhost').
412
+ * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
413
+ * @throws {APIError} - Throws an error if authentication fails.
414
+ * @example
415
+ * // Using with ethers
416
+ * const signer = new ethers.Wallet(privateKey, provider);
417
+ * await auth.connectWithSigner(signer, { domain: 'myapp.com', uri: 'https://myapp.com' });
418
+ *
419
+ * // Using with viem
420
+ * const account = privateKeyToAccount('0x...');
421
+ * const client = createWalletClient({ account, chain: mainnet, transport: http() });
422
+ * await auth.connectWithSigner(client);
423
+ */
424
+ connectWithSigner(signer: any, options?: {
425
+ domain?: string;
426
+ uri?: string;
427
+ }): Promise<{
428
+ success: boolean;
429
+ message: string;
430
+ walletAddress: string;
431
+ }>;
432
+ /**
433
+ * Get the user's linked social accounts.
434
+ * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
435
+ * @throws {Error|APIError} - Throws an error if the user is not authenticated or if the request fails.
436
+ * @example
437
+ * const auth = new Auth({ clientId: "your-client-id" });
438
+ * const socials = await auth.getLinkedSocials();
439
+ * console.log(socials);
440
+ */
441
+ getLinkedSocials(): Promise<Record<string, boolean>>;
442
+ /**
443
+ * Link the user's Twitter account.
444
+ * @returns {Promise<void>}
445
+ * @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
446
+ */
447
+ linkTwitter(): Promise<void>;
448
+ /**
449
+ * Link the user's Discord account.
450
+ * @returns {Promise<void>}
451
+ * @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
452
+ */
453
+ linkDiscord(): Promise<void>;
454
+ /**
455
+ * Link the user's Spotify account.
456
+ * @returns {Promise<void>}
457
+ * @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
458
+ */
459
+ linkSpotify(): Promise<void>;
460
+ /**
461
+ * Link the user's TikTok account.
462
+ * @param {string} handle The user's TikTok handle.
463
+ * @returns {Promise<any>} A promise that resolves with the TikTok account data.
464
+ * @throws {Error|APIError} - Throws an error if the user is not authenticated.
465
+ */
466
+ linkTikTok(handle: string): Promise<any>;
467
+ /**
468
+ * Send an OTP to the user's Telegram account.
469
+ * @param {string} phoneNumber The user's phone number.
470
+ * @returns {Promise<any>} A promise that resolves with the OTP data.
471
+ * @throws {Error|APIError} - Throws an error if the user is not authenticated.
472
+ */
473
+ sendTelegramOTP(phoneNumber: string): Promise<any>;
474
+ /**
475
+ * Link the user's Telegram account.
476
+ * @param {string} phoneNumber The user's phone number.
477
+ * @param {string} otp The OTP.
478
+ * @param {string} phoneCodeHash The phone code hash.
479
+ * @returns {Promise<object>} A promise that resolves with the Telegram account data.
480
+ * @throws {APIError|Error} - Throws an error if the user is not authenticated. Also throws an error if the phone number, OTP, and phone code hash are not provided.
481
+ */
482
+ linkTelegram(phoneNumber: string, otp: string, phoneCodeHash: string): Promise<any>;
483
+ /**
484
+ * Unlink the user's Twitter account.
485
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
486
+ * @throws {Error} - Throws an error if the user is not authenticated.
487
+ * @throws {APIError} - Throws an error if the request fails.
488
+ */
489
+ unlinkTwitter(): Promise<any>;
490
+ /**
491
+ * Unlink the user's Discord account.
492
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
493
+ * @throws {Error} - Throws an error if the user is not authenticated.
494
+ * @throws {APIError} - Throws an error if the request fails.
495
+ */
496
+ unlinkDiscord(): Promise<any>;
497
+ /**
498
+ * Unlink the user's Spotify account.
499
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
500
+ * @throws {Error} - Throws an error if the user is not authenticated.
501
+ * @throws {APIError} - Throws an error if the request fails.
502
+ */
503
+ unlinkSpotify(): Promise<any>;
504
+ /**
505
+ * Unlink the user's TikTok account.
506
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
507
+ * @throws {Error} - Throws an error if the user is not authenticated.
508
+ * @throws {APIError} - Throws an error if the request fails.
509
+ */
510
+ unlinkTikTok(): Promise<any>;
511
+ /**
512
+ * Unlink the user's Telegram account.
513
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
514
+ * @throws {Error} - Throws an error if the user is not authenticated.
515
+ * @throws {APIError} - Throws an error if the request fails.
516
+ */
517
+ unlinkTelegram(): Promise<any>;
518
+ }
519
+
520
+ /**
521
+ * CampContext
522
+ * @type {React.Context}
523
+ * @property {string} clientId The Camp client ID
524
+ * @property {Auth} auth The Camp Auth instance
525
+ * @property {function} setAuth The function to set the Camp Auth instance
526
+ * @property {boolean} wagmiAvailable Whether Wagmi is available
527
+ */
528
+ interface CampContextType {
529
+ clientId: string | null;
530
+ auth: Auth | null;
531
+ setAuth: React.Dispatch<React.SetStateAction<Auth | null>>;
532
+ wagmiAvailable: boolean;
533
+ environment: Environment;
534
+ }
535
+ declare const CampContext: React.Context<CampContextType>;
536
+ /**
537
+ * CampProvider
538
+ * @param {Object} props The props
539
+ * @param {string} props.clientId The Camp client ID
540
+ * @param {string} props.redirectUri The redirect URI to use after social oauths
541
+ * @param {React.ReactNode} props.children The children components
542
+ * @param {boolean} props.allowAnalytics Whether to allow analytics to be sent
543
+ * @returns {JSX.Element} The CampProvider component
544
+ */
545
+ declare const CampProvider: ({ clientId, redirectUri, children, environment, }: {
546
+ clientId: string;
547
+ redirectUri?: string;
548
+ children: React.ReactNode;
549
+ allowAnalytics?: boolean;
550
+ environment?: "DEVELOPMENT" | "PRODUCTION";
551
+ }) => React.JSX.Element;
552
+
553
+ interface ModalContextProps {
554
+ isButtonDisabled: boolean;
555
+ setIsButtonDisabled: (isButtonDisabled: boolean) => void;
556
+ isVisible: boolean;
557
+ setIsVisible: (isVisible: boolean) => void;
558
+ isLinkingVisible: boolean;
559
+ setIsLinkingVisible: (isLinkingVisible: boolean) => void;
560
+ currentlyLinking: any;
561
+ setCurrentlyLinking: (currentlyLinking: any) => void;
562
+ }
563
+ declare const ModalContext: React.Context<ModalContextProps>;
564
+
565
+ interface Provider {
566
+ info: {
567
+ uuid: string;
568
+ name?: string;
569
+ icon?: string;
570
+ };
571
+ provider: any;
572
+ }
573
+
574
+ interface CampModalProps {
575
+ injectButton?: boolean;
576
+ wcProjectId?: string;
577
+ onlyWagmi?: boolean;
578
+ defaultProvider?: any;
579
+ }
580
+ /**
581
+ * The CampModal component.
582
+ * @param { { injectButton?: boolean, wcProjectId?: string, onlyWagmi?: boolean, defaultProvider?: object } } props The props.
583
+ * @returns { JSX.Element } The CampModal component.
584
+ */
585
+ declare const CampModal: ({ injectButton, wcProjectId, onlyWagmi, defaultProvider, }: CampModalProps) => JSX.Element;
586
+ /**
587
+ * The MyCampModal component.
588
+ * @param { { wcProvider: object } } props The props.
589
+ * @returns { JSX.Element } The MyCampModal component.
590
+ */
591
+ declare const MyCampModal: ({ wcProvider, }: {
592
+ wcProvider: any;
593
+ }) => JSX.Element;
594
+
595
+ declare const StandaloneCampButton: () => JSX.Element | null;
596
+ interface LinkButtonProps {
597
+ variant?: "default" | "icon";
598
+ social: "twitter" | "spotify" | "discord" | "tiktok" | "telegram";
599
+ theme?: "default" | "camp";
600
+ }
601
+ /**
602
+ * The LinkButton component.
603
+ * A button that will open the modal to link or unlink a social account.
604
+ * @param { { variant: ("default"|"icon"), social: ("twitter"|"spotify"|"discord"), theme: ("default"|"camp") } } props The props.
605
+ * @returns { JSX.Element } The LinkButton component.
606
+ */
607
+ declare const LinkButton: ({ variant, social, theme, }: LinkButtonProps) => JSX.Element | null;
608
+
609
+ /**
610
+ * Returns the Auth instance provided by the context.
611
+ * @returns { Auth } The Auth instance provided by the context.
612
+ * @example
613
+ * const auth = useAuth();
614
+ * auth.connect();
615
+ */
616
+ declare const useAuth: () => Auth;
617
+ /**
618
+ * Returns the functions to link and unlink socials.
619
+ * @returns { { linkTwitter: function, unlinkTwitter: function, linkDiscord: function, unlinkDiscord: function, linkSpotify: function, unlinkSpotify: function } } The functions to link and unlink socials.
620
+ * @example
621
+ * const { linkTwitter, unlinkTwitter, linkDiscord, unlinkDiscord, linkSpotify, unlinkSpotify } = useLinkSocials();
622
+ * linkTwitter();
623
+ */
624
+ declare const useLinkSocials: () => Record<string, Function>;
625
+ /**
626
+ * Fetches the provider from the context and sets the provider in the auth instance.
627
+ * @returns { { provider: { provider: string, info: { name: string } }, setProvider: function } } The provider and a function to set the provider.
628
+ */
629
+ declare const useProvider: () => {
630
+ provider: {
631
+ provider: any;
632
+ info: {
633
+ name: string;
634
+ };
635
+ };
636
+ setProvider: (provider: any, info?: any) => void;
637
+ };
638
+ /**
639
+ * Returns the authenticated state and loading state.
640
+ * @returns { { authenticated: boolean, loading: boolean } } The authenticated state and loading state.
641
+ */
642
+ declare const useAuthState: () => {
643
+ authenticated: boolean;
644
+ loading: boolean;
645
+ };
646
+ declare const useViem: () => {
647
+ client: any;
648
+ };
649
+ /**
650
+ * Connects and disconnects the user.
651
+ * @returns { { connect: function, disconnect: function } } The connect and disconnect functions.
652
+ */
653
+ declare const useConnect: () => {
654
+ connect: () => Promise<{
655
+ success: boolean;
656
+ message: string;
657
+ walletAddress: string;
658
+ }>;
659
+ disconnect: () => Promise<void>;
660
+ };
661
+ /**
662
+ * Returns the array of providers.
663
+ * @returns { Array } The array of providers and the loading state.
664
+ */
665
+ declare const useProviders: () => Provider[];
666
+ /**
667
+ * Returns the modal state and functions to open and close the modal.
668
+ * @returns { { isOpen: boolean, openModal: function, closeModal: function } } The modal state and functions to open and close the modal.
669
+ */
670
+ declare const useModal: () => {
671
+ isOpen: boolean;
672
+ openModal: () => void;
673
+ closeModal: () => void;
674
+ };
675
+ /**
676
+ * Returns the functions to open and close the link modal.
677
+ * @returns { { isLinkingOpen: boolean, closeModal: function, handleOpen: function } } The link modal state and functions to open and close the modal.
678
+ */
679
+ declare const useLinkModal: () => Record<string, Function | boolean> & {
680
+ isLinkingOpen: boolean;
681
+ closeModal: () => void;
682
+ handleOpen: (social: string) => void;
683
+ };
684
+ type UseSocialsResult<TData = unknown, TError = Error> = UseQueryResult<TData, TError> & {
685
+ socials: Record<string, string>;
686
+ };
687
+ /**
688
+ * Fetches the socials linked to the user.
689
+ * @returns { { data: {}, socials: {}, error: Error, isLoading: boolean, refetch: () => {} } } react-query query object.
690
+ */
691
+ declare const useSocials: () => UseSocialsResult;
692
+ /**
693
+ * Fetches the Origin usage data and uploads data.
694
+ * @returns { usage: { data: any, isError: boolean, isLoading: boolean, refetch: () => void }, uploads: { data: any, isError: boolean, isLoading: boolean, refetch: () => void } } The Origin usage data and uploads data.
695
+ */
696
+ declare const useOrigin: () => {
697
+ stats: {
698
+ data: any;
699
+ isError: boolean;
700
+ isLoading: boolean;
701
+ refetch: () => void;
702
+ };
703
+ uploads: {
704
+ data: any[];
705
+ isError: boolean;
706
+ isLoading: boolean;
707
+ refetch: () => void;
708
+ };
709
+ };
710
+
711
+ export { StandaloneCampButton as CampButton, CampContext, CampModal, CampProvider, LinkButton, ModalContext, MyCampModal, useAuth, useAuthState, useConnect, useLinkModal, useLinkSocials, useModal, useOrigin, useProvider, useProviders, useSocials, useViem };