@campnetwork/origin 1.4.0-alpha.4 → 1.4.0-alpha.5

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.
@@ -794,7 +794,7 @@ interface MintParams {
794
794
  * creatorContentHash: "0x...",
795
795
  * uri: "ipfs://...",
796
796
  * licenseTerms: { price: 1000n, duration: 86400, royaltyBps: 500, paymentToken: zeroAddress, licenseType: 0 },
797
- * deadline: BigInt(Date.now() + 600000),
797
+ * deadline: BigInt(Math.floor(Date.now() / 1000) + 600),
798
798
  * parents: [],
799
799
  * isIP: true,
800
800
  * appId: "myApp",
@@ -821,6 +821,103 @@ declare function bulkMint(this: Origin, mints: MintParams[]): Promise<any>;
821
821
  */
822
822
  declare function bulkMintTolerant(this: Origin, mints: MintParams[]): Promise<any>;
823
823
 
824
+ interface OriginContext {
825
+ environment: {
826
+ AUTH_HUB_BASE_API: string;
827
+ };
828
+ [key: string]: any;
829
+ }
830
+ type IpfsPinningProvider = "pinata" | "infura" | "web3storage";
831
+ interface IpfsCredentials {
832
+ provider: IpfsPinningProvider;
833
+ apiKey?: string;
834
+ apiSecret?: string;
835
+ jwt?: string;
836
+ token?: string;
837
+ projectId?: string;
838
+ projectSecret?: string;
839
+ }
840
+ interface IpfsUploadConfig {
841
+ provider: IpfsPinningProvider;
842
+ pinata?: {
843
+ jwt?: string;
844
+ apiKey?: string;
845
+ apiSecret?: string;
846
+ };
847
+ infura?: {
848
+ projectId: string;
849
+ projectSecret: string;
850
+ endpoint: string;
851
+ };
852
+ web3storage?: {
853
+ token: string;
854
+ };
855
+ }
856
+ /**
857
+ * Save IPFS credentials for large file uploads.
858
+ * Users can configure their own IPFS pinning service (Pinata, Infura, or web3.storage).
859
+ * @param credentials The IPFS credentials to save.
860
+ * @throws {APIError} If saving credentials fails.
861
+ * @example
862
+ * ```typescript
863
+ * // Save Pinata credentials
864
+ * await origin.saveIpfsCredentials({
865
+ * provider: 'pinata',
866
+ * jwt: 'your-pinata-jwt-token'
867
+ * });
868
+ *
869
+ * // Save Infura credentials
870
+ * await origin.saveIpfsCredentials({
871
+ * provider: 'infura',
872
+ * projectId: 'your-project-id',
873
+ * projectSecret: 'your-project-secret'
874
+ * });
875
+ * ```
876
+ */
877
+ declare function saveIpfsCredentials(this: OriginContext, credentials: IpfsCredentials): Promise<void>;
878
+ /**
879
+ * Verify that saved IPFS credentials are valid.
880
+ * @returns Object with valid boolean and optional error message.
881
+ * @throws {APIError} If verification request fails.
882
+ */
883
+ declare function verifyIpfsCredentials(this: OriginContext): Promise<{
884
+ valid: boolean;
885
+ error?: string;
886
+ }>;
887
+ /**
888
+ * Delete saved IPFS credentials.
889
+ * @throws {APIError} If deletion fails.
890
+ */
891
+ declare function deleteIpfsCredentials(this: OriginContext): Promise<void>;
892
+ /**
893
+ * Check if user has IPFS credentials configured.
894
+ * @returns True if credentials are configured, false otherwise.
895
+ */
896
+ declare function hasIpfsCredentials(this: OriginContext): Promise<boolean>;
897
+ /**
898
+ * Get IPFS upload config for client-side uploads.
899
+ * @returns IPFS config or null if not configured.
900
+ */
901
+ declare function getIpfsUploadConfig(this: OriginContext): Promise<IpfsUploadConfig | null>;
902
+ /**
903
+ * Upload a file to user's IPFS pinning service.
904
+ * @param file The file to upload.
905
+ * @param config The IPFS upload config.
906
+ * @param progressCallback Optional progress callback with intermediate upload progress.
907
+ * @returns The IPFS CID of the uploaded file.
908
+ */
909
+ declare function uploadToUserIPFS(this: OriginContext, file: File, config: IpfsUploadConfig, progressCallback?: (percent: number) => void): Promise<string>;
910
+ /**
911
+ * Register an IPFS file with the backend after client-side upload.
912
+ * @param cid The IPFS CID of the uploaded file.
913
+ * @param fileName The original file name.
914
+ * @param fileType The file MIME type.
915
+ * @returns The registered file key.
916
+ */
917
+ declare function registerIpfsFile(this: OriginContext, cid: string, fileName: string, fileType: string): Promise<{
918
+ fileKey: string;
919
+ }>;
920
+
824
921
  interface RoyaltyInfo {
825
922
  tokenBoundAccount: Address;
826
923
  balance: bigint;
@@ -891,6 +988,13 @@ declare class Origin {
891
988
  deployVaultForExistingNFT: typeof deployVaultForExistingNFT;
892
989
  getRoyaltyTokenBalance: typeof getRoyaltyTokenBalance;
893
990
  getAppInfo: typeof getAppInfo;
991
+ saveIpfsCredentials: typeof saveIpfsCredentials;
992
+ verifyIpfsCredentials: typeof verifyIpfsCredentials;
993
+ deleteIpfsCredentials: typeof deleteIpfsCredentials;
994
+ hasIpfsCredentials: typeof hasIpfsCredentials;
995
+ getIpfsUploadConfig: typeof getIpfsUploadConfig;
996
+ uploadToUserIPFS: typeof uploadToUserIPFS;
997
+ registerIpfsFile: typeof registerIpfsFile;
894
998
  private jwt?;
895
999
  environment: Environment;
896
1000
  private viemClient?;
@@ -920,13 +1024,14 @@ declare class Origin {
920
1024
  * @param metadata The metadata associated with the file.
921
1025
  * @param license The license terms for the IpNFT.
922
1026
  * @param parents Optional parent token IDs for lineage tracking.
923
- * @param options Optional parameters including progress callback, preview image, and use asset as preview flag.
1027
+ * @param options Optional parameters including progress callback, preview image, use asset as preview flag, and forceIpfs.
924
1028
  * @returns The token ID of the minted IpNFT as a string, or null if minting failed.
925
1029
  */
926
1030
  mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
927
1031
  progressCallback?: (percent: number) => void;
928
1032
  previewImage?: File | null;
929
1033
  useAssetAsPreview?: boolean;
1034
+ forceIpfs?: boolean;
930
1035
  }): Promise<string | null>;
931
1036
  /**
932
1037
  * Mints multiple file-based IpNFTs in a single transaction using the BatchOperations contract.
@@ -950,6 +1055,7 @@ declare class Origin {
950
1055
  */
951
1056
  bulkMintFile(entries: BulkMintFileEntry[], options?: {
952
1057
  tolerant?: boolean;
1058
+ forceIpfs?: boolean;
953
1059
  progressCallback?: (progress: {
954
1060
  fileIndex: number;
955
1061
  fileCount: number;