@campnetwork/origin 1.0.1-alpha.0 → 1.0.1-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.cjs +2 -2
- package/dist/core.esm.js +2 -2
- package/dist/react/index.esm.js +4 -0
- package/package.json +2 -2
package/dist/core.cjs
CHANGED
|
@@ -134,8 +134,8 @@ let f=null,v=null,w=null;const A=e=>{var n;const i=w||o;return v&&(null===(n=v.c
|
|
|
134
134
|
// DataNFT methods
|
|
135
135
|
this.mintWithSignature=E.bind(this),this.registerIpNFT=_.bind(this),this.updateTerms=C.bind(this),this.finalizeDelete=k.bind(this),this.getOrCreateRoyaltyVault=S.bind(this),this.getTerms=P.bind(this),this.ownerOf=x.bind(this),this.balanceOf=N.bind(this),this.tokenURI=D.bind(this),this.dataStatus=O.bind(this),this.isApprovedForAll=M.bind(this),this.transferFrom=U.bind(this),this.safeTransferFrom=B.bind(this),this.approve=F.bind(this),this.setApprovalForAll=R.bind(this),
|
|
136
136
|
// Marketplace methods
|
|
137
|
-
this.buyAccess=$.bind(this),this.hasAccess=H.bind(this),this.subscriptionExpiry=j.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return a(this,void 0,void 0,(function*(){let i;try{i=yield r(this,L,"m",W).call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield r(this,L,"m",q).call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield r(this,L,"m",q).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,s){return a(this,void 0,void 0,(function*(){let a,o=null;try{o=yield r(this,L,"m",K).call(this)}catch(e){throw new Error("Failed to mint file IP. Wallet not connected.")}try{if(a=yield this.uploadFile(e,s),!a||!a.key)throw new Error("Failed to upload file or get upload info.")}catch(e){throw new Error(`File upload failed: ${e instanceof Error?e.message:String(e)}`)}const d=BigInt(Date.now()+6e5);// 10 minutes from now
|
|
138
|
-
let u;try{u=yield this.registerIpNFT("file",d,n,t,a.key,i)}catch(e){throw yield r(this,L,"m",q).call(this,a.key,"failed"),new Error(`Failed to register IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:l,signerAddress:p,creatorContentHash:y,signature:c,uri:h}=u;if(!(l&&p&&y&&void 0!==c&&h))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(o,l,i||[],y,h,n,d,c);if(-1===["0x1","success"].indexOf(e.receipt.status))throw yield r(this,L,"m",q).call(this,a.key,"failed"),new Error(`Minting failed with status: ${e.receipt.status}`)}catch(e){throw yield r(this,L,"m",q).call(this,a.key,"failed"),new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return l.toString()}))}mintSocial(e,t,n){return a(this,void 0,void 0,(function*(){let i=null;try{i=yield r(this,L,"m",K).call(this)}catch(e){throw new Error("Failed to mint social IP. Wallet not connected.")}const a=BigInt(Math.floor(Date.now()/1e3)+600);// 10 minutes from now
|
|
137
|
+
this.buyAccess=$.bind(this),this.hasAccess=H.bind(this),this.subscriptionExpiry=j.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return a(this,void 0,void 0,(function*(){let i;try{i=yield r(this,L,"m",W).call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield r(this,L,"m",q).call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield r(this,L,"m",q).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,s){return a(this,void 0,void 0,(function*(){let a,o=null;try{o=yield r(this,L,"m",K).call(this)}catch(e){throw new Error("Failed to mint file IP. Wallet not connected.")}try{if(a=yield this.uploadFile(e,s),!a||!a.key)throw new Error("Failed to upload file or get upload info.")}catch(e){throw new Error(`File upload failed: ${e instanceof Error?e.message:String(e)}`)}e.type&&(t.mimetype=e.type);const d=BigInt(Date.now()+6e5);// 10 minutes from now
|
|
138
|
+
let u;try{u=yield this.registerIpNFT("file",d,n,t,a.key,i)}catch(e){throw yield r(this,L,"m",q).call(this,a.key,"failed"),new Error(`Failed to register IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:l,signerAddress:p,creatorContentHash:y,signature:c,uri:h}=u;if(!(l&&p&&y&&void 0!==c&&h))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(o,l,i||[],y,h,n,d,c);if(-1===["0x1","success"].indexOf(e.receipt.status))throw yield r(this,L,"m",q).call(this,a.key,"failed"),new Error(`Minting failed with status: ${e.receipt.status}`)}catch(e){throw yield r(this,L,"m",q).call(this,a.key,"failed"),new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return l.toString()}))}mintSocial(e,t,n){return a(this,void 0,void 0,(function*(){let i=null;try{i=yield r(this,L,"m",K).call(this)}catch(e){throw new Error("Failed to mint social IP. Wallet not connected.")}t.mimetype=`social/${e}`;const a=BigInt(Math.floor(Date.now()/1e3)+600);// 10 minutes from now
|
|
139
139
|
let s;try{s=yield this.registerIpNFT(e,a,n,t)}catch(e){throw new Error(`Failed to register Social IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:o,signerAddress:d,creatorContentHash:u,signature:l,uri:p}=s;if(!(o&&d&&u&&void 0!==l&&p))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(i,o,[],u,p,n,a,l);if(-1===["0x1","success"].indexOf(e.receipt.status))throw new Error(`Minting Social IpNFT failed with status: ${e.receipt.status}`)}catch(e){throw new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return o.toString()}))}getOriginUploads(){return a(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!e.ok)return console.error("Failed to get origin uploads"),null;return(yield e.json()).data}))}
|
|
140
140
|
/**
|
|
141
141
|
* Get the user's Origin stats (multiplier, consent, usage, etc.).
|
package/dist/core.esm.js
CHANGED
|
@@ -297,8 +297,8 @@ let S=null,P=null,x=null;const N=e=>{var t;const n=x||T;return P&&(null===(t=P.c
|
|
|
297
297
|
// DataNFT methods
|
|
298
298
|
this.mintWithSignature=U.bind(this),this.registerIpNFT=B.bind(this),this.updateTerms=F.bind(this),this.finalizeDelete=R.bind(this),this.getOrCreateRoyaltyVault=$.bind(this),this.getTerms=H.bind(this),this.ownerOf=j.bind(this),this.balanceOf=L.bind(this),this.tokenURI=W.bind(this),this.dataStatus=q.bind(this),this.isApprovedForAll=z.bind(this),this.transferFrom=J.bind(this),this.safeTransferFrom=K.bind(this),this.approve=V.bind(this),this.setApprovalForAll=G.bind(this),
|
|
299
299
|
// Marketplace methods
|
|
300
|
-
this.buyAccess=Y.bind(this),this.hasAccess=X.bind(this),this.subscriptionExpiry=Z.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return c(this,void 0,void 0,(function*(){let i;try{i=yield h(this,Q,"m",ee).call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield h(this,Q,"m",te).call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield h(this,Q,"m",te).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,a){return c(this,void 0,void 0,(function*(){let r,s=null;try{s=yield h(this,Q,"m",ae).call(this)}catch(e){throw new Error("Failed to mint file IP. Wallet not connected.")}try{if(r=yield this.uploadFile(e,a),!r||!r.key)throw new Error("Failed to upload file or get upload info.")}catch(e){throw new Error(`File upload failed: ${e instanceof Error?e.message:String(e)}`)}const o=BigInt(Date.now()+6e5);// 10 minutes from now
|
|
301
|
-
let d;try{d=yield this.registerIpNFT("file",o,n,t,r.key,i)}catch(e){throw yield h(this,Q,"m",te).call(this,r.key,"failed"),new Error(`Failed to register IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:u,signerAddress:l,creatorContentHash:p,signature:y,uri:c}=d;if(!(u&&l&&p&&void 0!==y&&c))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(s,u,i||[],p,c,n,o,y);if(-1===["0x1","success"].indexOf(e.receipt.status))throw yield h(this,Q,"m",te).call(this,r.key,"failed"),new Error(`Minting failed with status: ${e.receipt.status}`)}catch(e){throw yield h(this,Q,"m",te).call(this,r.key,"failed"),new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return u.toString()}))}mintSocial(e,t,n){return c(this,void 0,void 0,(function*(){let i=null;try{i=yield h(this,Q,"m",ae).call(this)}catch(e){throw new Error("Failed to mint social IP. Wallet not connected.")}const a=BigInt(Math.floor(Date.now()/1e3)+600);// 10 minutes from now
|
|
300
|
+
this.buyAccess=Y.bind(this),this.hasAccess=X.bind(this),this.subscriptionExpiry=Z.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return c(this,void 0,void 0,(function*(){let i;try{i=yield h(this,Q,"m",ee).call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield h(this,Q,"m",te).call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield h(this,Q,"m",te).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,a){return c(this,void 0,void 0,(function*(){let r,s=null;try{s=yield h(this,Q,"m",ae).call(this)}catch(e){throw new Error("Failed to mint file IP. Wallet not connected.")}try{if(r=yield this.uploadFile(e,a),!r||!r.key)throw new Error("Failed to upload file or get upload info.")}catch(e){throw new Error(`File upload failed: ${e instanceof Error?e.message:String(e)}`)}e.type&&(t.mimetype=e.type);const o=BigInt(Date.now()+6e5);// 10 minutes from now
|
|
301
|
+
let d;try{d=yield this.registerIpNFT("file",o,n,t,r.key,i)}catch(e){throw yield h(this,Q,"m",te).call(this,r.key,"failed"),new Error(`Failed to register IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:u,signerAddress:l,creatorContentHash:p,signature:y,uri:c}=d;if(!(u&&l&&p&&void 0!==y&&c))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(s,u,i||[],p,c,n,o,y);if(-1===["0x1","success"].indexOf(e.receipt.status))throw yield h(this,Q,"m",te).call(this,r.key,"failed"),new Error(`Minting failed with status: ${e.receipt.status}`)}catch(e){throw yield h(this,Q,"m",te).call(this,r.key,"failed"),new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return u.toString()}))}mintSocial(e,t,n){return c(this,void 0,void 0,(function*(){let i=null;try{i=yield h(this,Q,"m",ae).call(this)}catch(e){throw new Error("Failed to mint social IP. Wallet not connected.")}t.mimetype=`social/${e}`;const a=BigInt(Math.floor(Date.now()/1e3)+600);// 10 minutes from now
|
|
302
302
|
let r;try{r=yield this.registerIpNFT(e,a,n,t)}catch(e){throw new Error(`Failed to register Social IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:s,signerAddress:o,creatorContentHash:d,signature:u,uri:l}=r;if(!(s&&o&&d&&void 0!==u&&l))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(i,s,[],d,l,n,a,u);if(-1===["0x1","success"].indexOf(e.receipt.status))throw new Error(`Minting Social IpNFT failed with status: ${e.receipt.status}`)}catch(e){throw new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return s.toString()}))}getOriginUploads(){return c(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!e.ok)return console.error("Failed to get origin uploads"),null;return(yield e.json()).data}))}
|
|
303
303
|
/**
|
|
304
304
|
* Get the user's Origin stats (multiplier, consent, usage, etc.).
|
package/dist/react/index.esm.js
CHANGED
|
@@ -3027,6 +3027,9 @@ class Origin {
|
|
|
3027
3027
|
catch (error) {
|
|
3028
3028
|
throw new Error(`File upload failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
3029
3029
|
}
|
|
3030
|
+
if (file.type) {
|
|
3031
|
+
metadata.mimetype = file.type;
|
|
3032
|
+
}
|
|
3030
3033
|
const deadline = BigInt(Date.now() + 600000); // 10 minutes from now
|
|
3031
3034
|
let registration;
|
|
3032
3035
|
try {
|
|
@@ -3067,6 +3070,7 @@ class Origin {
|
|
|
3067
3070
|
catch (error) {
|
|
3068
3071
|
throw new Error("Failed to mint social IP. Wallet not connected.");
|
|
3069
3072
|
}
|
|
3073
|
+
metadata.mimetype = `social/${source}`;
|
|
3070
3074
|
const deadline = BigInt(Math.floor(Date.now() / 1000) + 600); // 10 minutes from now
|
|
3071
3075
|
let registration;
|
|
3072
3076
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@campnetwork/origin",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.1",
|
|
4
4
|
"main": "dist/core.cjs",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"preset": "conventionalcommits",
|
|
89
89
|
"infile": "CHANGELOG.md",
|
|
90
90
|
"header": "# Changelog\n\nAll notable changes to this project will be documented in this file.\n",
|
|
91
|
-
"
|
|
91
|
+
"ignoreRecommendedBump": true
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|