@campnetwork/origin 0.0.17 → 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.d.ts CHANGED
@@ -196,6 +196,18 @@ declare class SpotifyAPI {
196
196
  _fetchDataWithAuth(url: string): Promise<object>;
197
197
  }
198
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
+ }
210
+
199
211
  /**
200
212
  * Represents the terms of a license for a digital asset.
201
213
  * @property price - The price of the asset in wei.
@@ -230,7 +242,7 @@ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
230
242
  * Mints a Data NFT with a signature.
231
243
  * @param to The address to mint the NFT to.
232
244
  * @param tokenId The ID of the token to mint.
233
- * @param parentId The ID of the parent NFT, if applicable.
245
+ * @param parents The IDs of the parent NFTs, if applicable.
234
246
  * @param hash The hash of the data associated with the NFT.
235
247
  * @param uri The URI of the NFT metadata.
236
248
  * @param licenseTerms The terms of the license for the NFT.
@@ -238,7 +250,7 @@ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
238
250
  * @param signature The signature for the minting operation.
239
251
  * @returns A promise that resolves when the minting is complete.
240
252
  */
241
- declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, parentId: bigint, hash: Hex, uri: string, licenseTerms: LicenseTerms, deadline: bigint, signature: Hex): Promise<any>;
253
+ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, parents: bigint[], hash: Hex, uri: string, licenseTerms: LicenseTerms, deadline: bigint, signature: Hex): Promise<any>;
242
254
  /**
243
255
  * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
244
256
  * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
@@ -246,7 +258,7 @@ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, p
246
258
  * @param fileKey Optional file key for file uploads.
247
259
  * @return A promise that resolves with the registration data.
248
260
  */
249
- declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parentId?: bigint): Promise<any>;
261
+ declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
250
262
 
251
263
  declare function updateTerms(this: Origin, tokenId: bigint, royaltyReceiver: Address, newTerms: LicenseTerms): Promise<any>;
252
264
 
@@ -278,7 +290,7 @@ declare function approve(this: Origin, to: Address, tokenId: bigint): Promise<an
278
290
 
279
291
  declare function setApprovalForAll(this: Origin, operator: Address, approved: boolean): Promise<any>;
280
292
 
281
- declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, periods: number, value?: bigint): Promise<any>;
293
+ declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, value?: bigint): Promise<any>;
282
294
 
283
295
  declare function renewAccess(this: Origin, tokenId: bigint, buyer: Address, periods: number, value?: bigint): Promise<any>;
284
296
 
@@ -328,14 +340,15 @@ declare class Origin {
328
340
  hasAccess: typeof hasAccess;
329
341
  subscriptionExpiry: typeof subscriptionExpiry;
330
342
  private jwt;
343
+ environment: Environment;
331
344
  private viemClient?;
332
- constructor(jwt: string, viemClient?: any);
345
+ constructor(jwt: string, environment: Environment, viemClient?: any);
333
346
  getJwt(): string;
334
347
  setViemClient(client: any): void;
335
348
  uploadFile: (file: File, options?: {
336
349
  progressCallback?: (percent: number) => void;
337
350
  }) => Promise<any>;
338
- mintFile: (file: File, metadata: Record<string, unknown>, license: LicenseTerms, parentId?: bigint, options?: {
351
+ mintFile: (file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
339
352
  progressCallback?: (percent: number) => void;
340
353
  }) => Promise<string | null>;
341
354
  mintSocial: (source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms) => Promise<string | null>;
@@ -373,10 +386,9 @@ declare class Origin {
373
386
  /**
374
387
  * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
375
388
  * @param {bigint} tokenId The token ID of the asset.
376
- * @param {number} periods The number of periods to buy access for.
377
389
  * @returns {Promise<any>} The result of the buyAccess call.
378
390
  */
379
- buyAccessSmart(tokenId: bigint, periods: number): Promise<any>;
391
+ buyAccessSmart(tokenId: bigint): Promise<any>;
380
392
  getData(tokenId: bigint): Promise<any>;
381
393
  }
382
394
 
@@ -400,6 +412,7 @@ declare class Auth {
400
412
  userId: string | null;
401
413
  viem: any;
402
414
  origin: Origin | null;
415
+ environment: Environment;
403
416
  /**
404
417
  * Constructor for the Auth class.
405
418
  * @param {object} options The options object.
@@ -407,13 +420,15 @@ declare class Auth {
407
420
  * @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.
408
421
  * @param {boolean} [options.allowAnalytics=true] Whether to allow analytics to be sent.
409
422
  * @param {object} [options.ackeeInstance] The Ackee instance.
423
+ * @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
410
424
  * @throws {APIError} - Throws an error if the clientId is not provided.
411
425
  */
412
- constructor({ clientId, redirectUri, allowAnalytics, ackeeInstance, }: {
426
+ constructor({ clientId, redirectUri, allowAnalytics, ackeeInstance, environment, }: {
413
427
  clientId: string;
414
428
  redirectUri: string | Record<string, string>;
415
429
  allowAnalytics?: boolean;
416
430
  ackeeInstance?: any;
431
+ environment?: "DEVELOPMENT" | "PRODUCTION";
417
432
  });
418
433
  /**
419
434
  * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
@@ -449,6 +464,10 @@ declare class Auth {
449
464
  * @returns {void}
450
465
  */
451
466
  setWalletAddress(walletAddress: string): void;
467
+ /**
468
+ * Recover the provider from local storage.
469
+ * @returns {Promise<void>}
470
+ */
452
471
  recoverProvider(): Promise<void>;
453
472
  /**
454
473
  * Disconnect the user.
@@ -196,6 +196,18 @@ declare class SpotifyAPI {
196
196
  _fetchDataWithAuth(url: string): Promise<object>;
197
197
  }
198
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
+ }
210
+
199
211
  /**
200
212
  * Represents the terms of a license for a digital asset.
201
213
  * @property price - The price of the asset in wei.
@@ -230,7 +242,7 @@ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
230
242
  * Mints a Data NFT with a signature.
231
243
  * @param to The address to mint the NFT to.
232
244
  * @param tokenId The ID of the token to mint.
233
- * @param parentId The ID of the parent NFT, if applicable.
245
+ * @param parents The IDs of the parent NFTs, if applicable.
234
246
  * @param hash The hash of the data associated with the NFT.
235
247
  * @param uri The URI of the NFT metadata.
236
248
  * @param licenseTerms The terms of the license for the NFT.
@@ -238,7 +250,7 @@ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
238
250
  * @param signature The signature for the minting operation.
239
251
  * @returns A promise that resolves when the minting is complete.
240
252
  */
241
- declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, parentId: bigint, hash: Hex, uri: string, licenseTerms: LicenseTerms, deadline: bigint, signature: Hex): Promise<any>;
253
+ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, parents: bigint[], hash: Hex, uri: string, licenseTerms: LicenseTerms, deadline: bigint, signature: Hex): Promise<any>;
242
254
  /**
243
255
  * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
244
256
  * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
@@ -246,7 +258,7 @@ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, p
246
258
  * @param fileKey Optional file key for file uploads.
247
259
  * @return A promise that resolves with the registration data.
248
260
  */
249
- declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parentId?: bigint): Promise<any>;
261
+ declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
250
262
 
251
263
  declare function updateTerms(this: Origin, tokenId: bigint, royaltyReceiver: Address, newTerms: LicenseTerms): Promise<any>;
252
264
 
@@ -278,7 +290,7 @@ declare function approve(this: Origin, to: Address, tokenId: bigint): Promise<an
278
290
 
279
291
  declare function setApprovalForAll(this: Origin, operator: Address, approved: boolean): Promise<any>;
280
292
 
281
- declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, periods: number, value?: bigint): Promise<any>;
293
+ declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, value?: bigint): Promise<any>;
282
294
 
283
295
  declare function renewAccess(this: Origin, tokenId: bigint, buyer: Address, periods: number, value?: bigint): Promise<any>;
284
296
 
@@ -328,14 +340,15 @@ declare class Origin {
328
340
  hasAccess: typeof hasAccess;
329
341
  subscriptionExpiry: typeof subscriptionExpiry;
330
342
  private jwt;
343
+ environment: Environment;
331
344
  private viemClient?;
332
- constructor(jwt: string, viemClient?: any);
345
+ constructor(jwt: string, environment: Environment, viemClient?: any);
333
346
  getJwt(): string;
334
347
  setViemClient(client: any): void;
335
348
  uploadFile: (file: File, options?: {
336
349
  progressCallback?: (percent: number) => void;
337
350
  }) => Promise<any>;
338
- mintFile: (file: File, metadata: Record<string, unknown>, license: LicenseTerms, parentId?: bigint, options?: {
351
+ mintFile: (file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
339
352
  progressCallback?: (percent: number) => void;
340
353
  }) => Promise<string | null>;
341
354
  mintSocial: (source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms) => Promise<string | null>;
@@ -373,10 +386,9 @@ declare class Origin {
373
386
  /**
374
387
  * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
375
388
  * @param {bigint} tokenId The token ID of the asset.
376
- * @param {number} periods The number of periods to buy access for.
377
389
  * @returns {Promise<any>} The result of the buyAccess call.
378
390
  */
379
- buyAccessSmart(tokenId: bigint, periods: number): Promise<any>;
391
+ buyAccessSmart(tokenId: bigint): Promise<any>;
380
392
  getData(tokenId: bigint): Promise<any>;
381
393
  }
382
394
 
@@ -400,6 +412,7 @@ declare class Auth {
400
412
  userId: string | null;
401
413
  viem: any;
402
414
  origin: Origin | null;
415
+ environment: Environment;
403
416
  /**
404
417
  * Constructor for the Auth class.
405
418
  * @param {object} options The options object.
@@ -407,13 +420,15 @@ declare class Auth {
407
420
  * @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.
408
421
  * @param {boolean} [options.allowAnalytics=true] Whether to allow analytics to be sent.
409
422
  * @param {object} [options.ackeeInstance] The Ackee instance.
423
+ * @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
410
424
  * @throws {APIError} - Throws an error if the clientId is not provided.
411
425
  */
412
- constructor({ clientId, redirectUri, allowAnalytics, ackeeInstance, }: {
426
+ constructor({ clientId, redirectUri, allowAnalytics, ackeeInstance, environment, }: {
413
427
  clientId: string;
414
428
  redirectUri: string | Record<string, string>;
415
429
  allowAnalytics?: boolean;
416
430
  ackeeInstance?: any;
431
+ environment?: "DEVELOPMENT" | "PRODUCTION";
417
432
  });
418
433
  /**
419
434
  * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
@@ -449,6 +464,10 @@ declare class Auth {
449
464
  * @returns {void}
450
465
  */
451
466
  setWalletAddress(walletAddress: string): void;
467
+ /**
468
+ * Recover the provider from local storage.
469
+ * @returns {Promise<void>}
470
+ */
452
471
  recoverProvider(): Promise<void>;
453
472
  /**
454
473
  * Disconnect the user.