@campnetwork/origin 1.2.0-0 → 1.2.0-2

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,679 +1,843 @@
1
- import { Address, Hex, WalletClient, Abi } from 'viem';
2
-
3
- /**
4
- * The TwitterAPI class.
5
- * @class
6
- * @classdesc The TwitterAPI class is used to interact with the Twitter API.
7
- */
8
- declare class TwitterAPI {
9
- apiKey: string;
10
- /**
11
- * Constructor for the TwitterAPI class.
12
- * @param {object} options - The options object.
13
- * @param {string} options.apiKey - The API key. (Needed for data fetching)
14
- */
15
- constructor({ apiKey }: {
16
- apiKey: string;
17
- });
18
- /**
19
- * Fetch Twitter user details by username.
20
- * @param {string} twitterUserName - The Twitter username.
21
- * @returns {Promise<object>} - The user details.
22
- * @throws {APIError} - Throws an error if the request fails.
23
- */
24
- fetchUserByUsername(twitterUserName: string): Promise<object>;
25
- /**
26
- * Fetch tweets by Twitter username.
27
- * @param {string} twitterUserName - The Twitter username.
28
- * @param {number} page - The page number.
29
- * @param {number} limit - The number of items per page.
30
- * @returns {Promise<object>} - The tweets.
31
- * @throws {APIError} - Throws an error if the request fails.
32
- */
33
- fetchTweetsByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
34
- /**
35
- * Fetch followers by Twitter username.
36
- * @param {string} twitterUserName - The Twitter username.
37
- * @param {number} page - The page number.
38
- * @param {number} limit - The number of items per page.
39
- * @returns {Promise<object>} - The followers.
40
- * @throws {APIError} - Throws an error if the request fails.
41
- */
42
- fetchFollowersByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
43
- /**
44
- * Fetch following by Twitter username.
45
- * @param {string} twitterUserName - The Twitter username.
46
- * @param {number} page - The page number.
47
- * @param {number} limit - The number of items per page.
48
- * @returns {Promise<object>} - The following.
49
- * @throws {APIError} - Throws an error if the request fails.
50
- */
51
- fetchFollowingByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
52
- /**
53
- * Fetch tweet by tweet ID.
54
- * @param {string} tweetId - The tweet ID.
55
- * @returns {Promise<object>} - The tweet.
56
- * @throws {APIError} - Throws an error if the request fails.
57
- */
58
- fetchTweetById(tweetId: string): Promise<object>;
59
- /**
60
- * Fetch user by wallet address.
61
- * @param {string} walletAddress - The wallet address.
62
- * @param {number} page - The page number.
63
- * @param {number} limit - The number of items per page.
64
- * @returns {Promise<object>} - The user data.
65
- * @throws {APIError} - Throws an error if the request fails.
66
- */
67
- fetchUserByWalletAddress(walletAddress: string, page?: number, limit?: number): Promise<object>;
68
- /**
69
- * Fetch reposted tweets by Twitter username.
70
- * @param {string} twitterUserName - The Twitter username.
71
- * @param {number} page - The page number.
72
- * @param {number} limit - The number of items per page.
73
- * @returns {Promise<object>} - The reposted tweets.
74
- * @throws {APIError} - Throws an error if the request fails.
75
- */
76
- fetchRepostedByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
77
- /**
78
- * Fetch replies by Twitter username.
79
- * @param {string} twitterUserName - The Twitter username.
80
- * @param {number} page - The page number.
81
- * @param {number} limit - The number of items per page.
82
- * @returns {Promise<object>} - The replies.
83
- * @throws {APIError} - Throws an error if the request fails.
84
- */
85
- fetchRepliesByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
86
- /**
87
- * Fetch likes by Twitter username.
88
- * @param {string} twitterUserName - The Twitter username.
89
- * @param {number} page - The page number.
90
- * @param {number} limit - The number of items per page.
91
- * @returns {Promise<object>} - The likes.
92
- * @throws {APIError} - Throws an error if the request fails.
93
- */
94
- fetchLikesByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
95
- /**
96
- * Fetch follows by Twitter username.
97
- * @param {string} twitterUserName - The Twitter username.
98
- * @param {number} page - The page number.
99
- * @param {number} limit - The number of items per page.
100
- * @returns {Promise<object>} - The follows.
101
- * @throws {APIError} - Throws an error if the request fails.
102
- */
103
- fetchFollowsByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
104
- /**
105
- * Fetch viewed tweets by Twitter username.
106
- * @param {string} twitterUserName - The Twitter username.
107
- * @param {number} page - The page number.
108
- * @param {number} limit - The number of items per page.
109
- * @returns {Promise<object>} - The viewed tweets.
110
- * @throws {APIError} - Throws an error if the request fails.
111
- */
112
- fetchViewedTweetsByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
113
- /**
114
- * Private method to fetch data with authorization header.
115
- * @param {string} url - The URL to fetch.
116
- * @returns {Promise<object>} - The response data.
117
- * @throws {APIError} - Throws an error if the request fails.
118
- */
119
- _fetchDataWithAuth(url: string): Promise<object>;
120
- }
121
-
122
- interface SpotifyAPIOptions {
123
- apiKey: string;
124
- }
125
- /**
126
- * The SpotifyAPI class.
127
- * @class
128
- */
129
- declare class SpotifyAPI {
130
- apiKey: string;
131
- /**
132
- * Constructor for the SpotifyAPI class.
133
- * @constructor
134
- * @param {SpotifyAPIOptions} options - The Spotify API options.
135
- * @param {string} options.apiKey - The Spotify API key.
136
- * @throws {Error} - Throws an error if the API key is not provided.
137
- */
138
- constructor(options: SpotifyAPIOptions);
139
- /**
140
- * Fetch the user's saved tracks by Spotify user ID.
141
- * @param {string} spotifyId - The user's Spotify ID.
142
- * @returns {Promise<object>} - The saved tracks.
143
- * @throws {APIError} - Throws an error if the request fails.
144
- */
145
- fetchSavedTracksById(spotifyId: string): Promise<object>;
146
- /**
147
- * Fetch the played tracks of a user by Spotify ID.
148
- * @param {string} spotifyId - The user's Spotify ID.
149
- * @returns {Promise<object>} - The played tracks.
150
- * @throws {APIError} - Throws an error if the request fails.
151
- */
152
- fetchPlayedTracksById(spotifyId: string): Promise<object>;
153
- /**
154
- * Fetch the user's saved albums by Spotify user ID.
155
- * @param {string} spotifyId - The user's Spotify ID.
156
- * @returns {Promise<object>} - The saved albums.
157
- * @throws {APIError} - Throws an error if the request fails.
158
- */
159
- fetchSavedAlbumsById(spotifyId: string): Promise<object>;
160
- /**
161
- * Fetch the user's saved playlists by Spotify user ID.
162
- * @param {string} spotifyId - The user's Spotify ID.
163
- * @returns {Promise<object>} - The saved playlists.
164
- * @throws {APIError} - Throws an error if the request fails.
165
- */
166
- fetchSavedPlaylistsById(spotifyId: string): Promise<object>;
167
- /**
168
- * Fetch the tracks of an album by album ID.
169
- * @param {string} spotifyId - The Spotify ID of the user.
170
- * @param {string} albumId - The album ID.
171
- * @returns {Promise<object>} - The tracks in the album.
172
- * @throws {APIError} - Throws an error if the request fails.
173
- */
174
- fetchTracksInAlbum(spotifyId: string, albumId: string): Promise<object>;
175
- /**
176
- * Fetch the tracks in a playlist by playlist ID.
177
- * @param {string} spotifyId - The Spotify ID of the user.
178
- * @param {string} playlistId - The playlist ID.
179
- * @returns {Promise<object>} - The tracks in the playlist.
180
- * @throws {APIError} - Throws an error if the request fails.
181
- */
182
- fetchTracksInPlaylist(spotifyId: string, playlistId: string): Promise<object>;
183
- /**
184
- * Fetch the user's Spotify data by wallet address.
185
- * @param {string} walletAddress - The wallet address.
186
- * @returns {Promise<object>} - The user's Spotify data.
187
- * @throws {APIError} - Throws an error if the request fails.
188
- */
189
- fetchUserByWalletAddress(walletAddress: string): Promise<object>;
190
- /**
191
- * Private method to fetch data with authorization header.
192
- * @param {string} url - The URL to fetch.
193
- * @returns {Promise<object>} - The response data.
194
- * @throws {APIError} - Throws an error if the request fails.
195
- */
196
- _fetchDataWithAuth(url: string): Promise<object>;
197
- }
198
-
199
- interface Environment {
200
- NAME: string;
201
- AUTH_HUB_BASE_API: string;
202
- AUTH_ENDPOINT: string;
203
- ORIGIN_DASHBOARD: string;
204
- DATANFT_CONTRACT_ADDRESS: string;
205
- MARKETPLACE_CONTRACT_ADDRESS: string;
206
- CHAIN: any;
207
- IPNFT_ABI?: any;
208
- MARKETPLACE_ABI?: any;
209
- ROYALTY_VAULT_ABI?: any;
210
- TBA_ABI?: any;
211
- }
212
-
213
- /**
214
- * Represents the terms of a license for a digital asset.
215
- * @property price - The price of the asset in wei.
216
- * @property duration - The duration of the license in seconds.
217
- * @property royaltyBps - The royalty percentage in basis points (0-10000).
218
- * @property paymentToken - The address of the payment token (ERC20 / address(0) for native currency).
219
- */
220
- type LicenseTerms = {
221
- price: bigint;
222
- duration: number;
223
- royaltyBps: number;
224
- paymentToken: Address;
225
- };
226
- /**
227
- * Enum representing the status of data in the system.
228
- * * - ACTIVE: The data is currently active and available.
229
- * * - PENDING_DELETE: The data is scheduled for deletion but not yet removed.
230
- * * - DELETED: The data has been deleted and is no longer available.
231
- */
232
- declare enum DataStatus {
233
- ACTIVE = 0,
234
- PENDING_DELETE = 1,
235
- DELETED = 2
236
- }
237
- /**
238
- * Represents the source of an IpNFT.
239
- * This can be one of the supported social media platforms or a file upload.
240
- */
241
- type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
242
-
243
- /**
244
- * Mints a Data NFT with a signature.
245
- * @param to The address to mint the NFT to.
246
- * @param tokenId The ID of the token to mint.
247
- * @param parents The IDs of the parent NFTs, if applicable.
248
- * @param hash The hash of the data associated with the NFT.
249
- * @param uri The URI of the NFT metadata.
250
- * @param licenseTerms The terms of the license for the NFT.
251
- * @param deadline The deadline for the minting operation.
252
- * @param signature The signature for the minting operation.
253
- * @returns A promise that resolves when the minting is complete.
254
- */
255
- 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>;
256
- /**
257
- * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
258
- * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
259
- * @param deadline The deadline for the registration operation.
260
- * @param fileKey Optional file key for file uploads.
261
- * @return A promise that resolves with the registration data.
262
- */
263
- declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
264
-
265
- /**
266
- * Updates the license terms of a specified IPNFT.
267
- * @param tokenId The ID of the IPNFT to update.
268
- * @param newTerms The new license terms to set.
269
- * @returns A promise that resolves when the transaction is complete.
270
- */
271
- declare function updateTerms(this: Origin, tokenId: bigint, newTerms: LicenseTerms): Promise<any>;
272
-
273
- /**
274
- * Sets the IPNFT as deleted
275
- * @param tokenId The token ID to set as deleted.
276
- * @returns A promise that resolves when the transaction is complete.
277
- */
278
- declare function finalizeDelete(this: Origin, tokenId: bigint): Promise<any>;
279
-
280
- /**
281
- * Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
282
- * @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
283
- * @param simulateOnly If true, simulates the transaction without executing it.
284
- * @returns The address of the royalty vault associated with the specified token owner.
285
- */
286
- declare function getOrCreateRoyaltyVault(this: Origin, tokenOwner: Address, simulateOnly?: boolean): Promise<Address>;
287
-
288
- /**
289
- * Returns the license terms associated with a specific token ID.
290
- * @param tokenId The token ID to query.
291
- * @returns The license terms of the token ID.
292
- */
293
- declare function getTerms(this: Origin, tokenId: bigint): Promise<any>;
294
-
295
- /**
296
- * Returns the owner of the specified IPNFT.
297
- * @param tokenId The ID of the IPNFT to query.
298
- * @returns The address of the owner of the IPNFT.
299
- */
300
- declare function ownerOf(this: Origin, tokenId: bigint): Promise<any>;
301
-
302
- /**
303
- * Returns the number of IPNFTs owned by the given address.
304
- * @param owner The address to query.
305
- * @returns The number of IPNFTs owned by the address.
306
- */
307
- declare function balanceOf(this: Origin, owner: Address): Promise<any>;
308
-
309
- /**
310
- * Returns the metadata URI associated with a specific token ID.
311
- * @param tokenId The token ID to query.
312
- * @returns The metadata URI of the token ID.
313
- */
314
- declare function tokenURI(this: Origin, tokenId: bigint): Promise<any>;
315
-
316
- /**
317
- * Returns the data status of the given token ID.
318
- * @param tokenId The token ID to query.
319
- * @returns The data status of the token ID.
320
- */
321
- declare function dataStatus(this: Origin, tokenId: bigint): Promise<DataStatus>;
322
-
323
- /**
324
- * Checks if an operator is approved to manage all assets of a given owner.
325
- * @param owner The address of the asset owner.
326
- * @param operator The address of the operator to check.
327
- * @return A promise that resolves to a boolean indicating if the operator is approved for all assets of the owner.
328
- */
329
- declare function isApprovedForAll(this: Origin, owner: Address, operator: Address): Promise<boolean>;
330
-
331
- declare function transferFrom(this: Origin, from: Address, to: Address, tokenId: bigint): Promise<any>;
332
-
333
- declare function safeTransferFrom(this: Origin, from: Address, to: Address, tokenId: bigint, data?: Hex): Promise<any>;
334
-
335
- declare function approve(this: Origin, to: Address, tokenId: bigint): Promise<any>;
336
-
337
- declare function setApprovalForAll(this: Origin, operator: Address, approved: boolean): Promise<any>;
338
-
339
- /**
340
- * Buys access to a data NFT for a specified duration.
341
- * @param buyer The address of the buyer.
342
- * @param tokenId The ID of the data NFT.
343
- * @param expectedPrice The expected price for the access.
344
- * @param expectedDuration The expected duration of the access in seconds.
345
- * @param expectedPaymentToken The address of the payment token (use zero address for native token).
346
- * @param value The amount of native token to send (only required if paying with native token).
347
- * @returns A promise that resolves when the transaction is confirmed.
348
- */
349
- declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, value?: bigint): Promise<any>;
350
-
351
- /**
352
- * Checks if a user has access to a specific token based on subscription expiry.
353
- * @param user - The address of the user.
354
- * @param tokenId - The ID of the token.
355
- * @returns A promise that resolves to a boolean indicating if the user has access.
356
- */
357
- declare function hasAccess(this: Origin, user: Address, tokenId: bigint): Promise<boolean>;
358
-
359
- declare function subscriptionExpiry(this: Origin, tokenId: bigint, user: Address): Promise<bigint>;
360
-
361
- interface OriginUsageReturnType {
362
- user: {
363
- multiplier: number;
364
- points: number;
365
- active: boolean;
366
- };
367
- teams: Array<any>;
368
- dataSources: Array<any>;
369
- }
370
- interface RoyaltyInfo {
371
- tokenBoundAccount: Address;
372
- balance: bigint;
373
- balanceFormatted: string;
374
- }
375
- type CallOptions = {
376
- value?: bigint;
377
- gas?: bigint;
378
- waitForReceipt?: boolean;
379
- simulate?: boolean;
380
- };
381
- /**
382
- * The Origin class
383
- * Handles the upload of files to Origin, as well as querying the user's stats
384
- */
385
- declare class Origin {
386
- #private;
387
- mintWithSignature: typeof mintWithSignature;
388
- registerIpNFT: typeof registerIpNFT;
389
- updateTerms: typeof updateTerms;
390
- finalizeDelete: typeof finalizeDelete;
391
- getOrCreateRoyaltyVault: typeof getOrCreateRoyaltyVault;
392
- getTerms: typeof getTerms;
393
- ownerOf: typeof ownerOf;
394
- balanceOf: typeof balanceOf;
395
- tokenURI: typeof tokenURI;
396
- dataStatus: typeof dataStatus;
397
- isApprovedForAll: typeof isApprovedForAll;
398
- transferFrom: typeof transferFrom;
399
- safeTransferFrom: typeof safeTransferFrom;
400
- approve: typeof approve;
401
- setApprovalForAll: typeof setApprovalForAll;
402
- buyAccess: typeof buyAccess;
403
- hasAccess: typeof hasAccess;
404
- subscriptionExpiry: typeof subscriptionExpiry;
405
- private jwt;
406
- environment: Environment;
407
- private viemClient?;
408
- constructor(jwt: string, environment: Environment, viemClient?: WalletClient);
409
- getJwt(): string;
410
- setViemClient(client: WalletClient): void;
411
- uploadFile(file: File, options?: {
412
- progressCallback?: (percent: number) => void;
413
- }): Promise<any>;
414
- mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
415
- progressCallback?: (percent: number) => void;
416
- }): Promise<string | null>;
417
- mintSocial(source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms): Promise<string | null>;
418
- getOriginUploads(): Promise<any[] | null>;
419
- /**
420
- * Get the user's Origin stats (multiplier, consent, usage, etc.).
421
- * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
422
- */
423
- getOriginUsage(): Promise<OriginUsageReturnType>;
424
- /**
425
- * Set the user's consent for Origin usage.
426
- * @param {boolean} consent The user's consent.
427
- * @returns {Promise<void>}
428
- * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
429
- */
430
- setOriginConsent(consent: boolean): Promise<void>;
431
- /**
432
- * Call a contract method.
433
- * @param {string} contractAddress The contract address.
434
- * @param {Abi} abi The contract ABI.
435
- * @param {string} methodName The method name.
436
- * @param {any[]} params The method parameters.
437
- * @param {CallOptions} [options] The call options.
438
- * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
439
- * @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
440
- */
441
- callContractMethod(contractAddress: string, abi: Abi, methodName: string, params: any[], options?: CallOptions): Promise<any>;
442
- /**
443
- * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
444
- * @param {bigint} tokenId The token ID of the asset.
445
- * @returns {Promise<any>} The result of the buyAccess call.
446
- */
447
- buyAccessSmart(tokenId: bigint): Promise<any>;
448
- getData(tokenId: bigint): Promise<any>;
449
- /**
450
- * Get the Token Bound Account (TBA) address for a specific token ID.
451
- * @param {bigint} tokenId - The token ID to get the TBA address for.
452
- * @returns {Promise<Address>} A promise that resolves with the TBA address.
453
- * @throws {Error} Throws an error if the TBA address cannot be retrieved.
454
- * @example
455
- * ```typescript
456
- * const tbaAddress = await origin.getTokenBoundAccount(1n);
457
- * console.log(`TBA Address: ${tbaAddress}`);
458
- * ```
459
- */
460
- getTokenBoundAccount(tokenId: bigint): Promise<Address>;
461
- /**
462
- * Get royalty information for a token ID, including the token bound account address and its balance.
463
- * @param {bigint} tokenId - The token ID to check royalties for.
464
- * @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
465
- * @returns {Promise<RoyaltyInfo>} A promise that resolves with the token bound account address and balance information.
466
- * @throws {Error} Throws an error if the token bound account cannot be retrieved.
467
- * @example
468
- * ```typescript
469
- * // Get royalties for a specific token
470
- * const royalties = await origin.getRoyalties(1n);
471
- *
472
- * // Get ERC20 token royalties for a specific token
473
- * const royalties = await origin.getRoyalties(1n, "0x1234...");
474
- * ```
475
- */
476
- getRoyalties(tokenId: bigint, token?: Address): Promise<RoyaltyInfo>;
477
- /**
478
- * Claim royalties from a token's Token Bound Account (TBA).
479
- * @param {bigint} tokenId - The token ID to claim royalties from.
480
- * @param {Address} [recipient] - Optional recipient address. If not provided, uses the connected wallet.
481
- * @param {Address} [token] - Optional token address to claim royalties in. If not provided, claims in native token.
482
- * @returns {Promise<any>} A promise that resolves when the claim transaction is confirmed.
483
- * @throws {Error} Throws an error if no wallet is connected and no recipient address is provided.
484
- * @example
485
- * ```typescript
486
- * // Claim native token royalties for token #1 to connected wallet
487
- * await origin.claimRoyalties(1n);
488
- *
489
- * // Claim ERC20 token royalties to a specific address
490
- * await origin.claimRoyalties(1n, "0xRecipient...", "0xToken...");
491
- * ```
492
- */
493
- claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
494
- }
495
-
496
- declare global {
497
- interface Window {
498
- ethereum?: any;
499
- }
500
- }
501
- /**
502
- * The Auth class.
503
- * @class
504
- * @classdesc The Auth class is used to authenticate the user.
505
- */
506
- declare class Auth {
507
- #private;
508
- redirectUri: Record<string, string>;
509
- clientId: string;
510
- isAuthenticated: boolean;
511
- jwt: string | null;
512
- walletAddress: string | null;
513
- userId: string | null;
514
- viem: any;
515
- origin: Origin | null;
516
- environment: Environment;
517
- /**
518
- * Constructor for the Auth class.
519
- * @param {object} options The options object.
520
- * @param {string} options.clientId The client ID.
521
- * @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.
522
- * @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
523
- * @throws {APIError} - Throws an error if the clientId is not provided.
524
- */
525
- constructor({ clientId, redirectUri, environment, }: {
526
- clientId: string;
527
- redirectUri: string | Record<string, string>;
528
- environment?: "DEVELOPMENT" | "PRODUCTION";
529
- });
530
- /**
531
- * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
532
- * @param {("state"|"provider"|"providers"|"viem")} event The event.
533
- * @param {function} callback The callback function.
534
- * @returns {void}
535
- * @example
536
- * auth.on("state", (state) => {
537
- * console.log(state);
538
- * });
539
- */
540
- on(event: "state" | "provider" | "providers" | "viem", callback: Function): void;
541
- /**
542
- * Unsubscribe from an event. Possible events are "state", "provider", "providers", and "viem".
543
- * @param {("state"|"provider"|"providers"|"viem")} event The event.
544
- * @param {function} callback The callback function.
545
- * @returns {void}
546
- */
547
- off(event: "state" | "provider" | "providers" | "viem", callback: Function): void;
548
- /**
549
- * Set the loading state.
550
- * @param {boolean} loading The loading state.
551
- * @returns {void}
552
- */
553
- setLoading(loading: boolean): void;
554
- /**
555
- * 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.
556
- * @param {object} options The options object. Includes the provider and the provider info.
557
- * @returns {void}
558
- * @throws {APIError} - Throws an error if the provider is not provided.
559
- */
560
- setProvider({ provider, info, address, }: {
561
- provider: any;
562
- info: any;
563
- address?: string;
564
- }): void;
565
- /**
566
- * 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.
567
- * @param {string} walletAddress The wallet address.
568
- * @returns {void}
569
- */
570
- setWalletAddress(walletAddress: string): void;
571
- /**
572
- * Recover the provider from local storage.
573
- * @returns {Promise<void>}
574
- */
575
- recoverProvider(): Promise<void>;
576
- /**
577
- * Disconnect the user.
578
- * @returns {Promise<void>}
579
- */
580
- disconnect(): Promise<void>;
581
- /**
582
- * Connect the user's wallet and sign the message.
583
- * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
584
- * @throws {APIError} - Throws an error if the user cannot be authenticated.
585
- */
586
- connect(): Promise<{
587
- success: boolean;
588
- message: string;
589
- walletAddress: string;
590
- }>;
591
- /**
592
- * Get the user's linked social accounts.
593
- * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
594
- * @throws {Error|APIError} - Throws an error if the user is not authenticated or if the request fails.
595
- * @example
596
- * const auth = new Auth({ clientId: "your-client-id" });
597
- * const socials = await auth.getLinkedSocials();
598
- * console.log(socials);
599
- */
600
- getLinkedSocials(): Promise<Record<string, boolean>>;
601
- /**
602
- * Link the user's Twitter account.
603
- * @returns {Promise<void>}
604
- * @throws {Error} - Throws an error if the user is not authenticated.
605
- */
606
- linkTwitter(): Promise<void>;
607
- /**
608
- * Link the user's Discord account.
609
- * @returns {Promise<void>}
610
- * @throws {Error} - Throws an error if the user is not authenticated.
611
- */
612
- linkDiscord(): Promise<void>;
613
- /**
614
- * Link the user's Spotify account.
615
- * @returns {Promise<void>}
616
- * @throws {Error} - Throws an error if the user is not authenticated.
617
- */
618
- linkSpotify(): Promise<void>;
619
- /**
620
- * Link the user's TikTok account.
621
- * @param {string} handle The user's TikTok handle.
622
- * @returns {Promise<any>} A promise that resolves with the TikTok account data.
623
- * @throws {Error|APIError} - Throws an error if the user is not authenticated.
624
- */
625
- linkTikTok(handle: string): Promise<any>;
626
- /**
627
- * Send an OTP to the user's Telegram account.
628
- * @param {string} phoneNumber The user's phone number.
629
- * @returns {Promise<any>} A promise that resolves with the OTP data.
630
- * @throws {Error|APIError} - Throws an error if the user is not authenticated.
631
- */
632
- sendTelegramOTP(phoneNumber: string): Promise<any>;
633
- /**
634
- * Link the user's Telegram account.
635
- * @param {string} phoneNumber The user's phone number.
636
- * @param {string} otp The OTP.
637
- * @param {string} phoneCodeHash The phone code hash.
638
- * @returns {Promise<object>} A promise that resolves with the Telegram account data.
639
- * @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.
640
- */
641
- linkTelegram(phoneNumber: string, otp: string, phoneCodeHash: string): Promise<any>;
642
- /**
643
- * Unlink the user's Twitter account.
644
- * @returns {Promise<any>} A promise that resolves with the unlink result.
645
- * @throws {Error} - Throws an error if the user is not authenticated.
646
- * @throws {APIError} - Throws an error if the request fails.
647
- */
648
- unlinkTwitter(): Promise<any>;
649
- /**
650
- * Unlink the user's Discord account.
651
- * @returns {Promise<any>} A promise that resolves with the unlink result.
652
- * @throws {Error} - Throws an error if the user is not authenticated.
653
- * @throws {APIError} - Throws an error if the request fails.
654
- */
655
- unlinkDiscord(): Promise<any>;
656
- /**
657
- * Unlink the user's Spotify account.
658
- * @returns {Promise<any>} A promise that resolves with the unlink result.
659
- * @throws {Error} - Throws an error if the user is not authenticated.
660
- * @throws {APIError} - Throws an error if the request fails.
661
- */
662
- unlinkSpotify(): Promise<any>;
663
- /**
664
- * Unlink the user's TikTok account.
665
- * @returns {Promise<any>} A promise that resolves with the unlink result.
666
- * @throws {Error} - Throws an error if the user is not authenticated.
667
- * @throws {APIError} - Throws an error if the request fails.
668
- */
669
- unlinkTikTok(): Promise<any>;
670
- /**
671
- * Unlink the user's Telegram account.
672
- * @returns {Promise<any>} A promise that resolves with the unlink result.
673
- * @throws {Error} - Throws an error if the user is not authenticated.
674
- * @throws {APIError} - Throws an error if the request fails.
675
- */
676
- unlinkTelegram(): Promise<any>;
677
- }
678
-
679
- export { Auth, SpotifyAPI, TwitterAPI };
1
+ import { Address, Hex, WalletClient, Abi, Account, Chain } from 'viem';
2
+
3
+ /**
4
+ * The TwitterAPI class.
5
+ * @class
6
+ * @classdesc The TwitterAPI class is used to interact with the Twitter API.
7
+ */
8
+ declare class TwitterAPI {
9
+ apiKey: string;
10
+ /**
11
+ * Constructor for the TwitterAPI class.
12
+ * @param {object} options - The options object.
13
+ * @param {string} options.apiKey - The API key. (Needed for data fetching)
14
+ */
15
+ constructor({ apiKey }: {
16
+ apiKey: string;
17
+ });
18
+ /**
19
+ * Fetch Twitter user details by username.
20
+ * @param {string} twitterUserName - The Twitter username.
21
+ * @returns {Promise<object>} - The user details.
22
+ * @throws {APIError} - Throws an error if the request fails.
23
+ */
24
+ fetchUserByUsername(twitterUserName: string): Promise<object>;
25
+ /**
26
+ * Fetch tweets by Twitter username.
27
+ * @param {string} twitterUserName - The Twitter username.
28
+ * @param {number} page - The page number.
29
+ * @param {number} limit - The number of items per page.
30
+ * @returns {Promise<object>} - The tweets.
31
+ * @throws {APIError} - Throws an error if the request fails.
32
+ */
33
+ fetchTweetsByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
34
+ /**
35
+ * Fetch followers by Twitter username.
36
+ * @param {string} twitterUserName - The Twitter username.
37
+ * @param {number} page - The page number.
38
+ * @param {number} limit - The number of items per page.
39
+ * @returns {Promise<object>} - The followers.
40
+ * @throws {APIError} - Throws an error if the request fails.
41
+ */
42
+ fetchFollowersByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
43
+ /**
44
+ * Fetch following by Twitter username.
45
+ * @param {string} twitterUserName - The Twitter username.
46
+ * @param {number} page - The page number.
47
+ * @param {number} limit - The number of items per page.
48
+ * @returns {Promise<object>} - The following.
49
+ * @throws {APIError} - Throws an error if the request fails.
50
+ */
51
+ fetchFollowingByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
52
+ /**
53
+ * Fetch tweet by tweet ID.
54
+ * @param {string} tweetId - The tweet ID.
55
+ * @returns {Promise<object>} - The tweet.
56
+ * @throws {APIError} - Throws an error if the request fails.
57
+ */
58
+ fetchTweetById(tweetId: string): Promise<object>;
59
+ /**
60
+ * Fetch user by wallet address.
61
+ * @param {string} walletAddress - The wallet address.
62
+ * @param {number} page - The page number.
63
+ * @param {number} limit - The number of items per page.
64
+ * @returns {Promise<object>} - The user data.
65
+ * @throws {APIError} - Throws an error if the request fails.
66
+ */
67
+ fetchUserByWalletAddress(walletAddress: string, page?: number, limit?: number): Promise<object>;
68
+ /**
69
+ * Fetch reposted tweets by Twitter username.
70
+ * @param {string} twitterUserName - The Twitter username.
71
+ * @param {number} page - The page number.
72
+ * @param {number} limit - The number of items per page.
73
+ * @returns {Promise<object>} - The reposted tweets.
74
+ * @throws {APIError} - Throws an error if the request fails.
75
+ */
76
+ fetchRepostedByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
77
+ /**
78
+ * Fetch replies by Twitter username.
79
+ * @param {string} twitterUserName - The Twitter username.
80
+ * @param {number} page - The page number.
81
+ * @param {number} limit - The number of items per page.
82
+ * @returns {Promise<object>} - The replies.
83
+ * @throws {APIError} - Throws an error if the request fails.
84
+ */
85
+ fetchRepliesByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
86
+ /**
87
+ * Fetch likes by Twitter username.
88
+ * @param {string} twitterUserName - The Twitter username.
89
+ * @param {number} page - The page number.
90
+ * @param {number} limit - The number of items per page.
91
+ * @returns {Promise<object>} - The likes.
92
+ * @throws {APIError} - Throws an error if the request fails.
93
+ */
94
+ fetchLikesByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
95
+ /**
96
+ * Fetch follows by Twitter username.
97
+ * @param {string} twitterUserName - The Twitter username.
98
+ * @param {number} page - The page number.
99
+ * @param {number} limit - The number of items per page.
100
+ * @returns {Promise<object>} - The follows.
101
+ * @throws {APIError} - Throws an error if the request fails.
102
+ */
103
+ fetchFollowsByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
104
+ /**
105
+ * Fetch viewed tweets by Twitter username.
106
+ * @param {string} twitterUserName - The Twitter username.
107
+ * @param {number} page - The page number.
108
+ * @param {number} limit - The number of items per page.
109
+ * @returns {Promise<object>} - The viewed tweets.
110
+ * @throws {APIError} - Throws an error if the request fails.
111
+ */
112
+ fetchViewedTweetsByUsername(twitterUserName: string, page?: number, limit?: number): Promise<object>;
113
+ /**
114
+ * Private method to fetch data with authorization header.
115
+ * @param {string} url - The URL to fetch.
116
+ * @returns {Promise<object>} - The response data.
117
+ * @throws {APIError} - Throws an error if the request fails.
118
+ */
119
+ _fetchDataWithAuth(url: string): Promise<object>;
120
+ }
121
+
122
+ interface SpotifyAPIOptions {
123
+ apiKey: string;
124
+ }
125
+ /**
126
+ * The SpotifyAPI class.
127
+ * @class
128
+ */
129
+ declare class SpotifyAPI {
130
+ apiKey: string;
131
+ /**
132
+ * Constructor for the SpotifyAPI class.
133
+ * @constructor
134
+ * @param {SpotifyAPIOptions} options - The Spotify API options.
135
+ * @param {string} options.apiKey - The Spotify API key.
136
+ * @throws {Error} - Throws an error if the API key is not provided.
137
+ */
138
+ constructor(options: SpotifyAPIOptions);
139
+ /**
140
+ * Fetch the user's saved tracks by Spotify user ID.
141
+ * @param {string} spotifyId - The user's Spotify ID.
142
+ * @returns {Promise<object>} - The saved tracks.
143
+ * @throws {APIError} - Throws an error if the request fails.
144
+ */
145
+ fetchSavedTracksById(spotifyId: string): Promise<object>;
146
+ /**
147
+ * Fetch the played tracks of a user by Spotify ID.
148
+ * @param {string} spotifyId - The user's Spotify ID.
149
+ * @returns {Promise<object>} - The played tracks.
150
+ * @throws {APIError} - Throws an error if the request fails.
151
+ */
152
+ fetchPlayedTracksById(spotifyId: string): Promise<object>;
153
+ /**
154
+ * Fetch the user's saved albums by Spotify user ID.
155
+ * @param {string} spotifyId - The user's Spotify ID.
156
+ * @returns {Promise<object>} - The saved albums.
157
+ * @throws {APIError} - Throws an error if the request fails.
158
+ */
159
+ fetchSavedAlbumsById(spotifyId: string): Promise<object>;
160
+ /**
161
+ * Fetch the user's saved playlists by Spotify user ID.
162
+ * @param {string} spotifyId - The user's Spotify ID.
163
+ * @returns {Promise<object>} - The saved playlists.
164
+ * @throws {APIError} - Throws an error if the request fails.
165
+ */
166
+ fetchSavedPlaylistsById(spotifyId: string): Promise<object>;
167
+ /**
168
+ * Fetch the tracks of an album by album ID.
169
+ * @param {string} spotifyId - The Spotify ID of the user.
170
+ * @param {string} albumId - The album ID.
171
+ * @returns {Promise<object>} - The tracks in the album.
172
+ * @throws {APIError} - Throws an error if the request fails.
173
+ */
174
+ fetchTracksInAlbum(spotifyId: string, albumId: string): Promise<object>;
175
+ /**
176
+ * Fetch the tracks in a playlist by playlist ID.
177
+ * @param {string} spotifyId - The Spotify ID of the user.
178
+ * @param {string} playlistId - The playlist ID.
179
+ * @returns {Promise<object>} - The tracks in the playlist.
180
+ * @throws {APIError} - Throws an error if the request fails.
181
+ */
182
+ fetchTracksInPlaylist(spotifyId: string, playlistId: string): Promise<object>;
183
+ /**
184
+ * Fetch the user's Spotify data by wallet address.
185
+ * @param {string} walletAddress - The wallet address.
186
+ * @returns {Promise<object>} - The user's Spotify data.
187
+ * @throws {APIError} - Throws an error if the request fails.
188
+ */
189
+ fetchUserByWalletAddress(walletAddress: string): Promise<object>;
190
+ /**
191
+ * Private method to fetch data with authorization header.
192
+ * @param {string} url - The URL to fetch.
193
+ * @returns {Promise<object>} - The response data.
194
+ * @throws {APIError} - Throws an error if the request fails.
195
+ */
196
+ _fetchDataWithAuth(url: string): Promise<object>;
197
+ }
198
+
199
+ interface Environment {
200
+ NAME: string;
201
+ AUTH_HUB_BASE_API: string;
202
+ AUTH_ENDPOINT: string;
203
+ ORIGIN_DASHBOARD: string;
204
+ DATANFT_CONTRACT_ADDRESS: string;
205
+ MARKETPLACE_CONTRACT_ADDRESS: string;
206
+ CHAIN: any;
207
+ IPNFT_ABI?: any;
208
+ MARKETPLACE_ABI?: any;
209
+ ROYALTY_VAULT_ABI?: any;
210
+ TBA_ABI?: any;
211
+ }
212
+
213
+ /**
214
+ * Represents the terms of a license for a digital asset.
215
+ * @property price - The price of the asset in wei.
216
+ * @property duration - The duration of the license in seconds.
217
+ * @property royaltyBps - The royalty percentage in basis points (0-10000).
218
+ * @property paymentToken - The address of the payment token (ERC20 / address(0) for native currency).
219
+ */
220
+ type LicenseTerms = {
221
+ price: bigint;
222
+ duration: number;
223
+ royaltyBps: number;
224
+ paymentToken: Address;
225
+ };
226
+ /**
227
+ * Enum representing the status of data in the system.
228
+ * * - ACTIVE: The data is currently active and available.
229
+ * * - PENDING_DELETE: The data is scheduled for deletion but not yet removed.
230
+ * * - DELETED: The data has been deleted and is no longer available.
231
+ */
232
+ declare enum DataStatus {
233
+ ACTIVE = 0,
234
+ PENDING_DELETE = 1,
235
+ DELETED = 2
236
+ }
237
+ /**
238
+ * Creates license terms for a digital asset.
239
+ * @param price The price of the asset in wei.
240
+ * @param duration The duration of the license in seconds.
241
+ * @param royaltyBps The royalty percentage in basis points (0-10000).
242
+ * @param paymentToken The address of the payment token (ERC20 / address(0) for native currency).
243
+ * @returns The created license terms.
244
+ */
245
+ declare const createLicenseTerms: (price: bigint, duration: number, royaltyBps: number, paymentToken: Address) => LicenseTerms;
246
+ /**
247
+ * Represents the source of an IpNFT.
248
+ * This can be one of the supported social media platforms or a file upload.
249
+ */
250
+ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
251
+
252
+ /**
253
+ * Mints a Data NFT with a signature.
254
+ * @param to The address to mint the NFT to.
255
+ * @param tokenId The ID of the token to mint.
256
+ * @param parents The IDs of the parent NFTs, if applicable.
257
+ * @param hash The hash of the data associated with the NFT.
258
+ * @param uri The URI of the NFT metadata.
259
+ * @param licenseTerms The terms of the license for the NFT.
260
+ * @param deadline The deadline for the minting operation.
261
+ * @param signature The signature for the minting operation.
262
+ * @returns A promise that resolves when the minting is complete.
263
+ */
264
+ 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>;
265
+ /**
266
+ * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
267
+ * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
268
+ * @param deadline The deadline for the registration operation.
269
+ * @param fileKey Optional file key for file uploads.
270
+ * @return A promise that resolves with the registration data.
271
+ */
272
+ declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
273
+
274
+ /**
275
+ * Updates the license terms of a specified IPNFT.
276
+ * @param tokenId The ID of the IPNFT to update.
277
+ * @param newTerms The new license terms to set.
278
+ * @returns A promise that resolves when the transaction is complete.
279
+ */
280
+ declare function updateTerms(this: Origin, tokenId: bigint, newTerms: LicenseTerms): Promise<any>;
281
+
282
+ /**
283
+ * Sets the IPNFT as deleted
284
+ * @param tokenId The token ID to set as deleted.
285
+ * @returns A promise that resolves when the transaction is complete.
286
+ */
287
+ declare function finalizeDelete(this: Origin, tokenId: bigint): Promise<any>;
288
+
289
+ /**
290
+ * Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
291
+ * @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
292
+ * @param simulateOnly If true, simulates the transaction without executing it.
293
+ * @returns The address of the royalty vault associated with the specified token owner.
294
+ */
295
+ declare function getOrCreateRoyaltyVault(this: Origin, tokenOwner: Address, simulateOnly?: boolean): Promise<Address>;
296
+
297
+ /**
298
+ * Returns the license terms associated with a specific token ID.
299
+ * @param tokenId The token ID to query.
300
+ * @returns The license terms of the token ID.
301
+ */
302
+ declare function getTerms(this: Origin, tokenId: bigint): Promise<any>;
303
+
304
+ /**
305
+ * Returns the owner of the specified IPNFT.
306
+ * @param tokenId The ID of the IPNFT to query.
307
+ * @returns The address of the owner of the IPNFT.
308
+ */
309
+ declare function ownerOf(this: Origin, tokenId: bigint): Promise<any>;
310
+
311
+ /**
312
+ * Returns the number of IPNFTs owned by the given address.
313
+ * @param owner The address to query.
314
+ * @returns The number of IPNFTs owned by the address.
315
+ */
316
+ declare function balanceOf(this: Origin, owner: Address): Promise<any>;
317
+
318
+ /**
319
+ * Returns the metadata URI associated with a specific token ID.
320
+ * @param tokenId The token ID to query.
321
+ * @returns The metadata URI of the token ID.
322
+ */
323
+ declare function tokenURI(this: Origin, tokenId: bigint): Promise<any>;
324
+
325
+ /**
326
+ * Returns the data status of the given token ID.
327
+ * @param tokenId The token ID to query.
328
+ * @returns The data status of the token ID.
329
+ */
330
+ declare function dataStatus(this: Origin, tokenId: bigint): Promise<DataStatus>;
331
+
332
+ /**
333
+ * Checks if an operator is approved to manage all assets of a given owner.
334
+ * @param owner The address of the asset owner.
335
+ * @param operator The address of the operator to check.
336
+ * @return A promise that resolves to a boolean indicating if the operator is approved for all assets of the owner.
337
+ */
338
+ declare function isApprovedForAll(this: Origin, owner: Address, operator: Address): Promise<boolean>;
339
+
340
+ declare function transferFrom(this: Origin, from: Address, to: Address, tokenId: bigint): Promise<any>;
341
+
342
+ declare function safeTransferFrom(this: Origin, from: Address, to: Address, tokenId: bigint, data?: Hex): Promise<any>;
343
+
344
+ declare function approve(this: Origin, to: Address, tokenId: bigint): Promise<any>;
345
+
346
+ declare function setApprovalForAll(this: Origin, operator: Address, approved: boolean): Promise<any>;
347
+
348
+ /**
349
+ * Buys access to a data NFT for a specified duration.
350
+ * @param buyer The address of the buyer.
351
+ * @param tokenId The ID of the data NFT.
352
+ * @param expectedPrice The expected price for the access.
353
+ * @param expectedDuration The expected duration of the access in seconds.
354
+ * @param expectedPaymentToken The address of the payment token (use zero address for native token).
355
+ * @param value The amount of native token to send (only required if paying with native token).
356
+ * @returns A promise that resolves when the transaction is confirmed.
357
+ */
358
+ declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, value?: bigint): Promise<any>;
359
+
360
+ /**
361
+ * Checks if a user has access to a specific token based on subscription expiry.
362
+ * @param user - The address of the user.
363
+ * @param tokenId - The ID of the token.
364
+ * @returns A promise that resolves to a boolean indicating if the user has access.
365
+ */
366
+ declare function hasAccess(this: Origin, user: Address, tokenId: bigint): Promise<boolean>;
367
+
368
+ declare function subscriptionExpiry(this: Origin, tokenId: bigint, user: Address): Promise<bigint>;
369
+
370
+ interface OriginUsageReturnType {
371
+ user: {
372
+ multiplier: number;
373
+ points: number;
374
+ active: boolean;
375
+ };
376
+ teams: Array<any>;
377
+ dataSources: Array<any>;
378
+ }
379
+ interface RoyaltyInfo {
380
+ tokenBoundAccount: Address;
381
+ balance: bigint;
382
+ balanceFormatted: string;
383
+ }
384
+ type CallOptions = {
385
+ value?: bigint;
386
+ gas?: bigint;
387
+ waitForReceipt?: boolean;
388
+ simulate?: boolean;
389
+ };
390
+ /**
391
+ * The Origin class
392
+ * Handles the upload of files to Origin, as well as querying the user's stats
393
+ */
394
+ declare class Origin {
395
+ #private;
396
+ mintWithSignature: typeof mintWithSignature;
397
+ registerIpNFT: typeof registerIpNFT;
398
+ updateTerms: typeof updateTerms;
399
+ finalizeDelete: typeof finalizeDelete;
400
+ getOrCreateRoyaltyVault: typeof getOrCreateRoyaltyVault;
401
+ getTerms: typeof getTerms;
402
+ ownerOf: typeof ownerOf;
403
+ balanceOf: typeof balanceOf;
404
+ tokenURI: typeof tokenURI;
405
+ dataStatus: typeof dataStatus;
406
+ isApprovedForAll: typeof isApprovedForAll;
407
+ transferFrom: typeof transferFrom;
408
+ safeTransferFrom: typeof safeTransferFrom;
409
+ approve: typeof approve;
410
+ setApprovalForAll: typeof setApprovalForAll;
411
+ buyAccess: typeof buyAccess;
412
+ hasAccess: typeof hasAccess;
413
+ subscriptionExpiry: typeof subscriptionExpiry;
414
+ private jwt;
415
+ environment: Environment;
416
+ private viemClient?;
417
+ constructor(jwt: string, environment: Environment, viemClient?: WalletClient);
418
+ getJwt(): string;
419
+ setViemClient(client: WalletClient): void;
420
+ uploadFile(file: File, options?: {
421
+ progressCallback?: (percent: number) => void;
422
+ }): Promise<any>;
423
+ mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
424
+ progressCallback?: (percent: number) => void;
425
+ }): Promise<string | null>;
426
+ mintSocial(source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms): Promise<string | null>;
427
+ getOriginUploads(): Promise<any[] | null>;
428
+ /**
429
+ * Get the user's Origin stats (multiplier, consent, usage, etc.).
430
+ * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
431
+ */
432
+ getOriginUsage(): Promise<OriginUsageReturnType>;
433
+ /**
434
+ * Set the user's consent for Origin usage.
435
+ * @param {boolean} consent The user's consent.
436
+ * @returns {Promise<void>}
437
+ * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
438
+ */
439
+ setOriginConsent(consent: boolean): Promise<void>;
440
+ /**
441
+ * Call a contract method.
442
+ * @param {string} contractAddress The contract address.
443
+ * @param {Abi} abi The contract ABI.
444
+ * @param {string} methodName The method name.
445
+ * @param {any[]} params The method parameters.
446
+ * @param {CallOptions} [options] The call options.
447
+ * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
448
+ * @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
449
+ */
450
+ callContractMethod(contractAddress: string, abi: Abi, methodName: string, params: any[], options?: CallOptions): Promise<any>;
451
+ /**
452
+ * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
453
+ * @param {bigint} tokenId The token ID of the asset.
454
+ * @returns {Promise<any>} The result of the buyAccess call.
455
+ */
456
+ buyAccessSmart(tokenId: bigint): Promise<any>;
457
+ getData(tokenId: bigint): Promise<any>;
458
+ /**
459
+ * Get the Token Bound Account (TBA) address for a specific token ID.
460
+ * @param {bigint} tokenId - The token ID to get the TBA address for.
461
+ * @returns {Promise<Address>} A promise that resolves with the TBA address.
462
+ * @throws {Error} Throws an error if the TBA address cannot be retrieved.
463
+ * @example
464
+ * ```typescript
465
+ * const tbaAddress = await origin.getTokenBoundAccount(1n);
466
+ * console.log(`TBA Address: ${tbaAddress}`);
467
+ * ```
468
+ */
469
+ getTokenBoundAccount(tokenId: bigint): Promise<Address>;
470
+ /**
471
+ * Get royalty information for a token ID, including the token bound account address and its balance.
472
+ * @param {bigint} tokenId - The token ID to check royalties for.
473
+ * @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
474
+ * @returns {Promise<RoyaltyInfo>} A promise that resolves with the token bound account address and balance information.
475
+ * @throws {Error} Throws an error if the token bound account cannot be retrieved.
476
+ * @example
477
+ * ```typescript
478
+ * // Get royalties for a specific token
479
+ * const royalties = await origin.getRoyalties(1n);
480
+ *
481
+ * // Get ERC20 token royalties for a specific token
482
+ * const royalties = await origin.getRoyalties(1n, "0x1234...");
483
+ * ```
484
+ */
485
+ getRoyalties(tokenId: bigint, token?: Address): Promise<RoyaltyInfo>;
486
+ /**
487
+ * Claim royalties from a token's Token Bound Account (TBA).
488
+ * @param {bigint} tokenId - The token ID to claim royalties from.
489
+ * @param {Address} [recipient] - Optional recipient address. If not provided, uses the connected wallet.
490
+ * @param {Address} [token] - Optional token address to claim royalties in. If not provided, claims in native token.
491
+ * @returns {Promise<any>} A promise that resolves when the claim transaction is confirmed.
492
+ * @throws {Error} Throws an error if no wallet is connected and no recipient address is provided.
493
+ * @example
494
+ * ```typescript
495
+ * // Claim native token royalties for token #1 to connected wallet
496
+ * await origin.claimRoyalties(1n);
497
+ *
498
+ * // Claim ERC20 token royalties to a specific address
499
+ * await origin.claimRoyalties(1n, "0xRecipient...", "0xToken...");
500
+ * ```
501
+ */
502
+ claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
503
+ }
504
+
505
+ interface StorageAdapter {
506
+ getItem(key: string): Promise<string | null>;
507
+ setItem(key: string, value: string): Promise<void>;
508
+ removeItem(key: string): Promise<void>;
509
+ }
510
+ /**
511
+ * Browser localStorage adapter
512
+ */
513
+ declare class BrowserStorage implements StorageAdapter {
514
+ getItem(key: string): Promise<string | null>;
515
+ setItem(key: string, value: string): Promise<void>;
516
+ removeItem(key: string): Promise<void>;
517
+ }
518
+ /**
519
+ * In-memory storage adapter for Node.js
520
+ */
521
+ declare class MemoryStorage implements StorageAdapter {
522
+ private storage;
523
+ getItem(key: string): Promise<string | null>;
524
+ setItem(key: string, value: string): Promise<void>;
525
+ removeItem(key: string): Promise<void>;
526
+ clear(): void;
527
+ }
528
+
529
+ declare global {
530
+ interface Window {
531
+ ethereum?: any;
532
+ }
533
+ }
534
+ /**
535
+ * The Auth class.
536
+ * @class
537
+ * @classdesc The Auth class is used to authenticate the user.
538
+ */
539
+ declare class Auth {
540
+ #private;
541
+ redirectUri: Record<string, string>;
542
+ clientId: string;
543
+ isAuthenticated: boolean;
544
+ jwt: string | null;
545
+ walletAddress: string | null;
546
+ userId: string | null;
547
+ viem: any;
548
+ origin: Origin | null;
549
+ environment: Environment;
550
+ /**
551
+ * Constructor for the Auth class.
552
+ * @param {object} options The options object.
553
+ * @param {string} options.clientId The client ID.
554
+ * @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.
555
+ * @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
556
+ * @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
557
+ * @throws {APIError} - Throws an error if the clientId is not provided.
558
+ */
559
+ constructor({ clientId, redirectUri, environment, storage, }: {
560
+ clientId: string;
561
+ redirectUri: string | Record<string, string>;
562
+ environment?: "DEVELOPMENT" | "PRODUCTION";
563
+ storage?: StorageAdapter;
564
+ });
565
+ /**
566
+ * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
567
+ * @param {("state"|"provider"|"providers"|"viem")} event The event.
568
+ * @param {function} callback The callback function.
569
+ * @returns {void}
570
+ * @example
571
+ * auth.on("state", (state) => {
572
+ * console.log(state);
573
+ * });
574
+ */
575
+ on(event: "state" | "provider" | "providers" | "viem", callback: Function): void;
576
+ /**
577
+ * Unsubscribe from an event. Possible events are "state", "provider", "providers", and "viem".
578
+ * @param {("state"|"provider"|"providers"|"viem")} event The event.
579
+ * @param {function} callback The callback function.
580
+ * @returns {void}
581
+ */
582
+ off(event: "state" | "provider" | "providers" | "viem", callback: Function): void;
583
+ /**
584
+ * Set the loading state.
585
+ * @param {boolean} loading The loading state.
586
+ * @returns {void}
587
+ */
588
+ setLoading(loading: boolean): void;
589
+ /**
590
+ * 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.
591
+ * @param {object} options The options object. Includes the provider and the provider info.
592
+ * @returns {void}
593
+ * @throws {APIError} - Throws an error if the provider is not provided.
594
+ */
595
+ setProvider({ provider, info, address, }: {
596
+ provider: any;
597
+ info: any;
598
+ address?: string;
599
+ }): void;
600
+ /**
601
+ * 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.
602
+ * @param {string} walletAddress The wallet address.
603
+ * @returns {void}
604
+ */
605
+ setWalletAddress(walletAddress: string): void;
606
+ /**
607
+ * Recover the provider from local storage.
608
+ * @returns {Promise<void>}
609
+ */
610
+ recoverProvider(): Promise<void>;
611
+ /**
612
+ * Disconnect the user.
613
+ * @returns {Promise<void>}
614
+ */
615
+ disconnect(): Promise<void>;
616
+ /**
617
+ * Connect the user's wallet and sign the message.
618
+ * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
619
+ * @throws {APIError} - Throws an error if the user cannot be authenticated.
620
+ */
621
+ connect(): Promise<{
622
+ success: boolean;
623
+ message: string;
624
+ walletAddress: string;
625
+ }>;
626
+ /**
627
+ * Connect with a custom signer (for Node.js or custom wallet implementations).
628
+ * This method bypasses browser wallet interactions and uses the provided signer directly.
629
+ * @param {any} signer The signer instance (viem WalletClient, ethers Signer, or custom signer).
630
+ * @param {object} [options] Optional configuration.
631
+ * @param {string} [options.domain] The domain to use in SIWE message (defaults to 'localhost').
632
+ * @param {string} [options.uri] The URI to use in SIWE message (defaults to 'http://localhost').
633
+ * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
634
+ * @throws {APIError} - Throws an error if authentication fails.
635
+ * @example
636
+ * // Using with ethers
637
+ * const signer = new ethers.Wallet(privateKey, provider);
638
+ * await auth.connectWithSigner(signer, { domain: 'myapp.com', uri: 'https://myapp.com' });
639
+ *
640
+ * // Using with viem
641
+ * const account = privateKeyToAccount('0x...');
642
+ * const client = createWalletClient({ account, chain: mainnet, transport: http() });
643
+ * await auth.connectWithSigner(client);
644
+ */
645
+ connectWithSigner(signer: any, options?: {
646
+ domain?: string;
647
+ uri?: string;
648
+ }): Promise<{
649
+ success: boolean;
650
+ message: string;
651
+ walletAddress: string;
652
+ }>;
653
+ /**
654
+ * Get the user's linked social accounts.
655
+ * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
656
+ * @throws {Error|APIError} - Throws an error if the user is not authenticated or if the request fails.
657
+ * @example
658
+ * const auth = new Auth({ clientId: "your-client-id" });
659
+ * const socials = await auth.getLinkedSocials();
660
+ * console.log(socials);
661
+ */
662
+ getLinkedSocials(): Promise<Record<string, boolean>>;
663
+ /**
664
+ * Link the user's Twitter account.
665
+ * @returns {Promise<void>}
666
+ * @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
667
+ */
668
+ linkTwitter(): Promise<void>;
669
+ /**
670
+ * Link the user's Discord account.
671
+ * @returns {Promise<void>}
672
+ * @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
673
+ */
674
+ linkDiscord(): Promise<void>;
675
+ /**
676
+ * Link the user's Spotify account.
677
+ * @returns {Promise<void>}
678
+ * @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
679
+ */
680
+ linkSpotify(): Promise<void>;
681
+ /**
682
+ * Link the user's TikTok account.
683
+ * @param {string} handle The user's TikTok handle.
684
+ * @returns {Promise<any>} A promise that resolves with the TikTok account data.
685
+ * @throws {Error|APIError} - Throws an error if the user is not authenticated.
686
+ */
687
+ linkTikTok(handle: string): Promise<any>;
688
+ /**
689
+ * Send an OTP to the user's Telegram account.
690
+ * @param {string} phoneNumber The user's phone number.
691
+ * @returns {Promise<any>} A promise that resolves with the OTP data.
692
+ * @throws {Error|APIError} - Throws an error if the user is not authenticated.
693
+ */
694
+ sendTelegramOTP(phoneNumber: string): Promise<any>;
695
+ /**
696
+ * Link the user's Telegram account.
697
+ * @param {string} phoneNumber The user's phone number.
698
+ * @param {string} otp The OTP.
699
+ * @param {string} phoneCodeHash The phone code hash.
700
+ * @returns {Promise<object>} A promise that resolves with the Telegram account data.
701
+ * @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.
702
+ */
703
+ linkTelegram(phoneNumber: string, otp: string, phoneCodeHash: string): Promise<any>;
704
+ /**
705
+ * Unlink the user's Twitter account.
706
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
707
+ * @throws {Error} - Throws an error if the user is not authenticated.
708
+ * @throws {APIError} - Throws an error if the request fails.
709
+ */
710
+ unlinkTwitter(): Promise<any>;
711
+ /**
712
+ * Unlink the user's Discord account.
713
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
714
+ * @throws {Error} - Throws an error if the user is not authenticated.
715
+ * @throws {APIError} - Throws an error if the request fails.
716
+ */
717
+ unlinkDiscord(): Promise<any>;
718
+ /**
719
+ * Unlink the user's Spotify account.
720
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
721
+ * @throws {Error} - Throws an error if the user is not authenticated.
722
+ * @throws {APIError} - Throws an error if the request fails.
723
+ */
724
+ unlinkSpotify(): Promise<any>;
725
+ /**
726
+ * Unlink the user's TikTok account.
727
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
728
+ * @throws {Error} - Throws an error if the user is not authenticated.
729
+ * @throws {APIError} - Throws an error if the request fails.
730
+ */
731
+ unlinkTikTok(): Promise<any>;
732
+ /**
733
+ * Unlink the user's Telegram account.
734
+ * @returns {Promise<any>} A promise that resolves with the unlink result.
735
+ * @throws {Error} - Throws an error if the user is not authenticated.
736
+ * @throws {APIError} - Throws an error if the request fails.
737
+ */
738
+ unlinkTelegram(): Promise<any>;
739
+ }
740
+
741
+ interface BaseSigner {
742
+ getAddress(): Promise<string>;
743
+ signMessage(message: string): Promise<string>;
744
+ getChainId(): Promise<number>;
745
+ }
746
+ type SignerType = "viem" | "ethers" | "custom";
747
+ interface SignerAdapter {
748
+ type: SignerType;
749
+ signer: any;
750
+ getAddress(): Promise<string>;
751
+ signMessage(message: string): Promise<string>;
752
+ getChainId(): Promise<number>;
753
+ }
754
+
755
+ /**
756
+ * Adapter for viem WalletClient
757
+ */
758
+ declare class ViemSignerAdapter implements SignerAdapter {
759
+ type: SignerType;
760
+ signer: WalletClient;
761
+ constructor(signer: WalletClient);
762
+ getAddress(): Promise<string>;
763
+ signMessage(message: string): Promise<string>;
764
+ getChainId(): Promise<number>;
765
+ }
766
+ /**
767
+ * Adapter for ethers Signer (v5 and v6)
768
+ */
769
+ declare class EthersSignerAdapter implements SignerAdapter {
770
+ type: SignerType;
771
+ signer: any;
772
+ constructor(signer: any);
773
+ getAddress(): Promise<string>;
774
+ signMessage(message: string): Promise<string>;
775
+ getChainId(): Promise<number>;
776
+ }
777
+ /**
778
+ * Adapter for custom signer implementations
779
+ */
780
+ declare class CustomSignerAdapter implements SignerAdapter {
781
+ type: SignerType;
782
+ signer: any;
783
+ constructor(signer: any);
784
+ getAddress(): Promise<string>;
785
+ signMessage(message: string): Promise<string>;
786
+ getChainId(): Promise<number>;
787
+ }
788
+ /**
789
+ * Factory function to create appropriate adapter based on signer type
790
+ */
791
+ declare function createSignerAdapter(signer: any): SignerAdapter;
792
+
793
+ /**
794
+ * Create a wallet client for Node.js environment
795
+ * @param account The viem account
796
+ * @param chain The chain to use
797
+ * @param rpcUrl Optional RPC URL (defaults to chain's default RPC)
798
+ * @returns WalletClient
799
+ */
800
+ declare function createNodeWalletClient(account: Account, chain: Chain, rpcUrl?: string): WalletClient;
801
+
802
+ declare const testnet: {
803
+ id: number;
804
+ name: string;
805
+ nativeCurrency: {
806
+ decimals: number;
807
+ name: string;
808
+ symbol: string;
809
+ };
810
+ rpcUrls: {
811
+ default: {
812
+ http: string[];
813
+ };
814
+ };
815
+ blockExplorers: {
816
+ default: {
817
+ name: string;
818
+ url: string;
819
+ };
820
+ };
821
+ };
822
+ declare const mainnet: {
823
+ id: number;
824
+ name: string;
825
+ nativeCurrency: {
826
+ decimals: number;
827
+ name: string;
828
+ symbol: string;
829
+ };
830
+ rpcUrls: {
831
+ default: {
832
+ http: string[];
833
+ };
834
+ };
835
+ blockExplorers: {
836
+ default: {
837
+ name: string;
838
+ url: string;
839
+ };
840
+ };
841
+ };
842
+
843
+ export { Auth, type BaseSigner, BrowserStorage, CustomSignerAdapter, DataStatus, EthersSignerAdapter, type LicenseTerms, MemoryStorage, type SignerAdapter, type SignerType, SpotifyAPI, type StorageAdapter, TwitterAPI, ViemSignerAdapter, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };