@campnetwork/origin 1.4.0-alpha.4 → 1.4.0-alpha.6
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.cjs +213 -142
- package/dist/core.d.ts +108 -2
- package/dist/core.esm.d.ts +108 -2
- package/dist/core.esm.js +229 -158
- package/dist/react/index.esm.d.ts +108 -2
- package/dist/react/index.esm.js +406 -29
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
|
@@ -962,7 +962,7 @@ interface TolerantMintResult {
|
|
|
962
962
|
* creatorContentHash: "0x...",
|
|
963
963
|
* uri: "ipfs://...",
|
|
964
964
|
* licenseTerms: { price: 1000n, duration: 86400, royaltyBps: 500, paymentToken: zeroAddress, licenseType: 0 },
|
|
965
|
-
* deadline: BigInt(Date.now() +
|
|
965
|
+
* deadline: BigInt(Math.floor(Date.now() / 1000) + 600),
|
|
966
966
|
* parents: [],
|
|
967
967
|
* isIP: true,
|
|
968
968
|
* appId: "myApp",
|
|
@@ -989,6 +989,103 @@ declare function bulkMint(this: Origin, mints: MintParams[]): Promise<any>;
|
|
|
989
989
|
*/
|
|
990
990
|
declare function bulkMintTolerant(this: Origin, mints: MintParams[]): Promise<any>;
|
|
991
991
|
|
|
992
|
+
interface OriginContext {
|
|
993
|
+
environment: {
|
|
994
|
+
AUTH_HUB_BASE_API: string;
|
|
995
|
+
};
|
|
996
|
+
[key: string]: any;
|
|
997
|
+
}
|
|
998
|
+
type IpfsPinningProvider = "pinata" | "infura" | "web3storage";
|
|
999
|
+
interface IpfsCredentials {
|
|
1000
|
+
provider: IpfsPinningProvider;
|
|
1001
|
+
apiKey?: string;
|
|
1002
|
+
apiSecret?: string;
|
|
1003
|
+
jwt?: string;
|
|
1004
|
+
token?: string;
|
|
1005
|
+
projectId?: string;
|
|
1006
|
+
projectSecret?: string;
|
|
1007
|
+
}
|
|
1008
|
+
interface IpfsUploadConfig {
|
|
1009
|
+
provider: IpfsPinningProvider;
|
|
1010
|
+
pinata?: {
|
|
1011
|
+
jwt?: string;
|
|
1012
|
+
apiKey?: string;
|
|
1013
|
+
apiSecret?: string;
|
|
1014
|
+
};
|
|
1015
|
+
infura?: {
|
|
1016
|
+
projectId: string;
|
|
1017
|
+
projectSecret: string;
|
|
1018
|
+
endpoint: string;
|
|
1019
|
+
};
|
|
1020
|
+
web3storage?: {
|
|
1021
|
+
token: string;
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Save IPFS credentials for large file uploads.
|
|
1026
|
+
* Users can configure their own IPFS pinning service (Pinata, Infura, or web3.storage).
|
|
1027
|
+
* @param credentials The IPFS credentials to save.
|
|
1028
|
+
* @throws {APIError} If saving credentials fails.
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```typescript
|
|
1031
|
+
* // Save Pinata credentials
|
|
1032
|
+
* await origin.saveIpfsCredentials({
|
|
1033
|
+
* provider: 'pinata',
|
|
1034
|
+
* jwt: 'your-pinata-jwt-token'
|
|
1035
|
+
* });
|
|
1036
|
+
*
|
|
1037
|
+
* // Save Infura credentials
|
|
1038
|
+
* await origin.saveIpfsCredentials({
|
|
1039
|
+
* provider: 'infura',
|
|
1040
|
+
* projectId: 'your-project-id',
|
|
1041
|
+
* projectSecret: 'your-project-secret'
|
|
1042
|
+
* });
|
|
1043
|
+
* ```
|
|
1044
|
+
*/
|
|
1045
|
+
declare function saveIpfsCredentials(this: OriginContext, credentials: IpfsCredentials): Promise<void>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Verify that saved IPFS credentials are valid.
|
|
1048
|
+
* @returns Object with valid boolean and optional error message.
|
|
1049
|
+
* @throws {APIError} If verification request fails.
|
|
1050
|
+
*/
|
|
1051
|
+
declare function verifyIpfsCredentials(this: OriginContext): Promise<{
|
|
1052
|
+
valid: boolean;
|
|
1053
|
+
error?: string;
|
|
1054
|
+
}>;
|
|
1055
|
+
/**
|
|
1056
|
+
* Delete saved IPFS credentials.
|
|
1057
|
+
* @throws {APIError} If deletion fails.
|
|
1058
|
+
*/
|
|
1059
|
+
declare function deleteIpfsCredentials(this: OriginContext): Promise<void>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Check if user has IPFS credentials configured.
|
|
1062
|
+
* @returns True if credentials are configured, false otherwise.
|
|
1063
|
+
*/
|
|
1064
|
+
declare function hasIpfsCredentials(this: OriginContext): Promise<boolean>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Get IPFS upload config for client-side uploads.
|
|
1067
|
+
* @returns IPFS config or null if not configured.
|
|
1068
|
+
*/
|
|
1069
|
+
declare function getIpfsUploadConfig(this: OriginContext): Promise<IpfsUploadConfig | null>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Upload a file to user's IPFS pinning service.
|
|
1072
|
+
* @param file The file to upload.
|
|
1073
|
+
* @param config The IPFS upload config.
|
|
1074
|
+
* @param progressCallback Optional progress callback with intermediate upload progress.
|
|
1075
|
+
* @returns The IPFS CID of the uploaded file.
|
|
1076
|
+
*/
|
|
1077
|
+
declare function uploadToUserIPFS(this: OriginContext, file: File, config: IpfsUploadConfig, progressCallback?: (percent: number) => void): Promise<string>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Register an IPFS file with the backend after client-side upload.
|
|
1080
|
+
* @param cid The IPFS CID of the uploaded file.
|
|
1081
|
+
* @param fileName The original file name.
|
|
1082
|
+
* @param fileType The file MIME type.
|
|
1083
|
+
* @returns The registered file key.
|
|
1084
|
+
*/
|
|
1085
|
+
declare function registerIpfsFile(this: OriginContext, cid: string, fileName: string, fileType: string): Promise<{
|
|
1086
|
+
fileKey: string;
|
|
1087
|
+
}>;
|
|
1088
|
+
|
|
992
1089
|
interface RoyaltyInfo {
|
|
993
1090
|
tokenBoundAccount: Address;
|
|
994
1091
|
balance: bigint;
|
|
@@ -1059,6 +1156,13 @@ declare class Origin {
|
|
|
1059
1156
|
deployVaultForExistingNFT: typeof deployVaultForExistingNFT;
|
|
1060
1157
|
getRoyaltyTokenBalance: typeof getRoyaltyTokenBalance;
|
|
1061
1158
|
getAppInfo: typeof getAppInfo;
|
|
1159
|
+
saveIpfsCredentials: typeof saveIpfsCredentials;
|
|
1160
|
+
verifyIpfsCredentials: typeof verifyIpfsCredentials;
|
|
1161
|
+
deleteIpfsCredentials: typeof deleteIpfsCredentials;
|
|
1162
|
+
hasIpfsCredentials: typeof hasIpfsCredentials;
|
|
1163
|
+
getIpfsUploadConfig: typeof getIpfsUploadConfig;
|
|
1164
|
+
uploadToUserIPFS: typeof uploadToUserIPFS;
|
|
1165
|
+
registerIpfsFile: typeof registerIpfsFile;
|
|
1062
1166
|
private jwt?;
|
|
1063
1167
|
environment: Environment;
|
|
1064
1168
|
private viemClient?;
|
|
@@ -1088,13 +1192,14 @@ declare class Origin {
|
|
|
1088
1192
|
* @param metadata The metadata associated with the file.
|
|
1089
1193
|
* @param license The license terms for the IpNFT.
|
|
1090
1194
|
* @param parents Optional parent token IDs for lineage tracking.
|
|
1091
|
-
* @param options Optional parameters including progress callback, preview image,
|
|
1195
|
+
* @param options Optional parameters including progress callback, preview image, use asset as preview flag, and forceIpfs.
|
|
1092
1196
|
* @returns The token ID of the minted IpNFT as a string, or null if minting failed.
|
|
1093
1197
|
*/
|
|
1094
1198
|
mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
|
|
1095
1199
|
progressCallback?: (percent: number) => void;
|
|
1096
1200
|
previewImage?: File | null;
|
|
1097
1201
|
useAssetAsPreview?: boolean;
|
|
1202
|
+
forceIpfs?: boolean;
|
|
1098
1203
|
}): Promise<string | null>;
|
|
1099
1204
|
/**
|
|
1100
1205
|
* Mints multiple file-based IpNFTs in a single transaction using the BatchOperations contract.
|
|
@@ -1118,6 +1223,7 @@ declare class Origin {
|
|
|
1118
1223
|
*/
|
|
1119
1224
|
bulkMintFile(entries: BulkMintFileEntry[], options?: {
|
|
1120
1225
|
tolerant?: boolean;
|
|
1226
|
+
forceIpfs?: boolean;
|
|
1121
1227
|
progressCallback?: (progress: {
|
|
1122
1228
|
fileIndex: number;
|
|
1123
1229
|
fileCount: number;
|
package/dist/core.esm.d.ts
CHANGED
|
@@ -962,7 +962,7 @@ interface TolerantMintResult {
|
|
|
962
962
|
* creatorContentHash: "0x...",
|
|
963
963
|
* uri: "ipfs://...",
|
|
964
964
|
* licenseTerms: { price: 1000n, duration: 86400, royaltyBps: 500, paymentToken: zeroAddress, licenseType: 0 },
|
|
965
|
-
* deadline: BigInt(Date.now() +
|
|
965
|
+
* deadline: BigInt(Math.floor(Date.now() / 1000) + 600),
|
|
966
966
|
* parents: [],
|
|
967
967
|
* isIP: true,
|
|
968
968
|
* appId: "myApp",
|
|
@@ -989,6 +989,103 @@ declare function bulkMint(this: Origin, mints: MintParams[]): Promise<any>;
|
|
|
989
989
|
*/
|
|
990
990
|
declare function bulkMintTolerant(this: Origin, mints: MintParams[]): Promise<any>;
|
|
991
991
|
|
|
992
|
+
interface OriginContext {
|
|
993
|
+
environment: {
|
|
994
|
+
AUTH_HUB_BASE_API: string;
|
|
995
|
+
};
|
|
996
|
+
[key: string]: any;
|
|
997
|
+
}
|
|
998
|
+
type IpfsPinningProvider = "pinata" | "infura" | "web3storage";
|
|
999
|
+
interface IpfsCredentials {
|
|
1000
|
+
provider: IpfsPinningProvider;
|
|
1001
|
+
apiKey?: string;
|
|
1002
|
+
apiSecret?: string;
|
|
1003
|
+
jwt?: string;
|
|
1004
|
+
token?: string;
|
|
1005
|
+
projectId?: string;
|
|
1006
|
+
projectSecret?: string;
|
|
1007
|
+
}
|
|
1008
|
+
interface IpfsUploadConfig {
|
|
1009
|
+
provider: IpfsPinningProvider;
|
|
1010
|
+
pinata?: {
|
|
1011
|
+
jwt?: string;
|
|
1012
|
+
apiKey?: string;
|
|
1013
|
+
apiSecret?: string;
|
|
1014
|
+
};
|
|
1015
|
+
infura?: {
|
|
1016
|
+
projectId: string;
|
|
1017
|
+
projectSecret: string;
|
|
1018
|
+
endpoint: string;
|
|
1019
|
+
};
|
|
1020
|
+
web3storage?: {
|
|
1021
|
+
token: string;
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Save IPFS credentials for large file uploads.
|
|
1026
|
+
* Users can configure their own IPFS pinning service (Pinata, Infura, or web3.storage).
|
|
1027
|
+
* @param credentials The IPFS credentials to save.
|
|
1028
|
+
* @throws {APIError} If saving credentials fails.
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```typescript
|
|
1031
|
+
* // Save Pinata credentials
|
|
1032
|
+
* await origin.saveIpfsCredentials({
|
|
1033
|
+
* provider: 'pinata',
|
|
1034
|
+
* jwt: 'your-pinata-jwt-token'
|
|
1035
|
+
* });
|
|
1036
|
+
*
|
|
1037
|
+
* // Save Infura credentials
|
|
1038
|
+
* await origin.saveIpfsCredentials({
|
|
1039
|
+
* provider: 'infura',
|
|
1040
|
+
* projectId: 'your-project-id',
|
|
1041
|
+
* projectSecret: 'your-project-secret'
|
|
1042
|
+
* });
|
|
1043
|
+
* ```
|
|
1044
|
+
*/
|
|
1045
|
+
declare function saveIpfsCredentials(this: OriginContext, credentials: IpfsCredentials): Promise<void>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Verify that saved IPFS credentials are valid.
|
|
1048
|
+
* @returns Object with valid boolean and optional error message.
|
|
1049
|
+
* @throws {APIError} If verification request fails.
|
|
1050
|
+
*/
|
|
1051
|
+
declare function verifyIpfsCredentials(this: OriginContext): Promise<{
|
|
1052
|
+
valid: boolean;
|
|
1053
|
+
error?: string;
|
|
1054
|
+
}>;
|
|
1055
|
+
/**
|
|
1056
|
+
* Delete saved IPFS credentials.
|
|
1057
|
+
* @throws {APIError} If deletion fails.
|
|
1058
|
+
*/
|
|
1059
|
+
declare function deleteIpfsCredentials(this: OriginContext): Promise<void>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Check if user has IPFS credentials configured.
|
|
1062
|
+
* @returns True if credentials are configured, false otherwise.
|
|
1063
|
+
*/
|
|
1064
|
+
declare function hasIpfsCredentials(this: OriginContext): Promise<boolean>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Get IPFS upload config for client-side uploads.
|
|
1067
|
+
* @returns IPFS config or null if not configured.
|
|
1068
|
+
*/
|
|
1069
|
+
declare function getIpfsUploadConfig(this: OriginContext): Promise<IpfsUploadConfig | null>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Upload a file to user's IPFS pinning service.
|
|
1072
|
+
* @param file The file to upload.
|
|
1073
|
+
* @param config The IPFS upload config.
|
|
1074
|
+
* @param progressCallback Optional progress callback with intermediate upload progress.
|
|
1075
|
+
* @returns The IPFS CID of the uploaded file.
|
|
1076
|
+
*/
|
|
1077
|
+
declare function uploadToUserIPFS(this: OriginContext, file: File, config: IpfsUploadConfig, progressCallback?: (percent: number) => void): Promise<string>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Register an IPFS file with the backend after client-side upload.
|
|
1080
|
+
* @param cid The IPFS CID of the uploaded file.
|
|
1081
|
+
* @param fileName The original file name.
|
|
1082
|
+
* @param fileType The file MIME type.
|
|
1083
|
+
* @returns The registered file key.
|
|
1084
|
+
*/
|
|
1085
|
+
declare function registerIpfsFile(this: OriginContext, cid: string, fileName: string, fileType: string): Promise<{
|
|
1086
|
+
fileKey: string;
|
|
1087
|
+
}>;
|
|
1088
|
+
|
|
992
1089
|
interface RoyaltyInfo {
|
|
993
1090
|
tokenBoundAccount: Address;
|
|
994
1091
|
balance: bigint;
|
|
@@ -1059,6 +1156,13 @@ declare class Origin {
|
|
|
1059
1156
|
deployVaultForExistingNFT: typeof deployVaultForExistingNFT;
|
|
1060
1157
|
getRoyaltyTokenBalance: typeof getRoyaltyTokenBalance;
|
|
1061
1158
|
getAppInfo: typeof getAppInfo;
|
|
1159
|
+
saveIpfsCredentials: typeof saveIpfsCredentials;
|
|
1160
|
+
verifyIpfsCredentials: typeof verifyIpfsCredentials;
|
|
1161
|
+
deleteIpfsCredentials: typeof deleteIpfsCredentials;
|
|
1162
|
+
hasIpfsCredentials: typeof hasIpfsCredentials;
|
|
1163
|
+
getIpfsUploadConfig: typeof getIpfsUploadConfig;
|
|
1164
|
+
uploadToUserIPFS: typeof uploadToUserIPFS;
|
|
1165
|
+
registerIpfsFile: typeof registerIpfsFile;
|
|
1062
1166
|
private jwt?;
|
|
1063
1167
|
environment: Environment;
|
|
1064
1168
|
private viemClient?;
|
|
@@ -1088,13 +1192,14 @@ declare class Origin {
|
|
|
1088
1192
|
* @param metadata The metadata associated with the file.
|
|
1089
1193
|
* @param license The license terms for the IpNFT.
|
|
1090
1194
|
* @param parents Optional parent token IDs for lineage tracking.
|
|
1091
|
-
* @param options Optional parameters including progress callback, preview image,
|
|
1195
|
+
* @param options Optional parameters including progress callback, preview image, use asset as preview flag, and forceIpfs.
|
|
1092
1196
|
* @returns The token ID of the minted IpNFT as a string, or null if minting failed.
|
|
1093
1197
|
*/
|
|
1094
1198
|
mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
|
|
1095
1199
|
progressCallback?: (percent: number) => void;
|
|
1096
1200
|
previewImage?: File | null;
|
|
1097
1201
|
useAssetAsPreview?: boolean;
|
|
1202
|
+
forceIpfs?: boolean;
|
|
1098
1203
|
}): Promise<string | null>;
|
|
1099
1204
|
/**
|
|
1100
1205
|
* Mints multiple file-based IpNFTs in a single transaction using the BatchOperations contract.
|
|
@@ -1118,6 +1223,7 @@ declare class Origin {
|
|
|
1118
1223
|
*/
|
|
1119
1224
|
bulkMintFile(entries: BulkMintFileEntry[], options?: {
|
|
1120
1225
|
tolerant?: boolean;
|
|
1226
|
+
forceIpfs?: boolean;
|
|
1121
1227
|
progressCallback?: (progress: {
|
|
1122
1228
|
fileIndex: number;
|
|
1123
1229
|
fileCount: number;
|