@campnetwork/origin 0.0.2 → 0.0.4

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var t=require("axios"),e=require("viem"),i=require("viem/accounts"),n=require("viem/siwe");
1
+ "use strict";var t=require("axios"),e=require("viem"),n=require("viem/accounts"),i=require("viem/siwe");
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -14,7 +14,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
16
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
17
- function s(t,e,i,n){return new(i||(i=Promise))((function(s,r){function o(t){try{d(n.next(t))}catch(t){r(t)}}function a(t){try{d(n.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}d((n=n.apply(t,e||[])).next())}))}function r(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}function o(t,e,i,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(t,i):s?s.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;class a extends Error{constructor(t,e){super(t),this.name="APIError",this.statusCode=e||500,Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:this.statusCode||500}}}
17
+ function a(t,e,n,i){return new(n||(n=Promise))((function(a,r){function s(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,o)}d((i=i.apply(t,e||[])).next())}))}function r(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function s(t,e,n,i,a){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?a.call(t,n):a?a.value=n:e.set(t,n),n}"function"==typeof SuppressedError&&SuppressedError;class o extends Error{constructor(t,e){super(t),this.name="APIError",this.statusCode=e||500,Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:this.statusCode||500}}}
18
18
  /**
19
19
  * Makes a GET request to the given URL with the provided headers.
20
20
  *
@@ -22,7 +22,7 @@ function s(t,e,i,n){return new(i||(i=Promise))((function(s,r){function o(t){try{
22
22
  * @param {object} headers - The headers to include in the request.
23
23
  * @returns {Promise<object>} - The response data.
24
24
  * @throws {APIError} - Throws an error if the request fails.
25
- */function d(e){return s(this,arguments,void 0,(function*(e,i={}){try{return(yield t.get(e,{headers:i})).data}catch(t){if(t.response)throw new a(t.response.data.message||"API request failed",t.response.status);throw new a("Network error or server is unavailable",500)}}))}
25
+ */function d(e){return a(this,arguments,void 0,(function*(e,n={}){try{return(yield t.get(e,{headers:n})).data}catch(t){if(t.response)throw new o(t.response.data.message||"API request failed",t.response.status);throw new o("Network error or server is unavailable",500)}}))}
26
26
  /**
27
27
  * Constructs a query string from an object of query parameters.
28
28
  *
@@ -36,43 +36,91 @@ function s(t,e,i,n){return new(i||(i=Promise))((function(s,r){function o(t){try{
36
36
  * @param {object} params - An object representing query parameters.
37
37
  * @returns {string} - The complete URL with query string.
38
38
  */
39
- function c(t,e={}){const i=function(t={}){return Object.keys(t).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`)).join("&")}(e);return i?`${t}?${i}`:t}const h="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/twitter",l="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/spotify";const u={id:123420001114,name:"Basecamp",nativeCurrency:{decimals:18,name:"Camp",symbol:"CAMP"},rpcUrls:{default:{http:["https://rpc-campnetwork.xyz","https://rpc.basecamp.t.raas.gelato.cloud"]}},blockExplorers:{default:{name:"Explorer",url:"https://basecamp.cloud.blockscout.com/"}}};
39
+ function u(t,e={}){const n=function(t={}){return Object.keys(t).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`)).join("&")}(e);return n?`${t}?${n}`:t}const l="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/twitter",p="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/spotify";const c={id:123420001114,name:"Basecamp",nativeCurrency:{decimals:18,name:"Camp",symbol:"CAMP"},rpcUrls:{default:{http:["https://rpc-campnetwork.xyz","https://rpc.basecamp.t.raas.gelato.cloud"]}},blockExplorers:{default:{name:"Explorer",url:"https://basecamp.cloud.blockscout.com/"}}};
40
40
  // @ts-ignore
41
- let f=null,w=null;const m=(t,n="window.ethereum",s)=>{var r;if(!t&&!f)return console.warn("Provider is required to create a client."),null;if(!f||f.transport.name!==n&&t||s!==(null===(r=f.account)||void 0===r?void 0:r.address)&&t){const r={chain:u,transport:e.custom(t,{name:n})};s&&(r.account=i.toAccount(s)),f=e.createWalletClient(r)}return f},p=()=>(w||(w=e.createPublicClient({chain:u,transport:e.http()})),w);var v="Connect with Camp Network",y="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",g={USER_CONNECTED:"ed42542d-b676-4112-b6d9-6db98048b2e0",USER_DISCONNECTED:"20af31ac-e602-442e-9e0e-b589f4dd4016",TWITTER_LINKED:"7fbea086-90ef-4679-ba69-f47f9255b34c",DISCORD_LINKED:"d73f5ae3-a8e8-48f2-8532-85e0c7780d6a",SPOTIFY_LINKED:"fc1788b4-c984-42c8-96f4-c87f6bb0b8f7",TIKTOK_LINKED:"4a2ffdd3-f0e9-4784-8b49-ff76ec1c0a6a",TELEGRAM_LINKED:"9006bc5d-bcc9-4d01-a860-4f1a201e8e47"};let I=[];const A=()=>I,T=t=>{function e(e){I.some((t=>t.info.uuid===e.detail.info.uuid))||(I=[...I,e.detail],t(I))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)};var k,b,E,S,$,j,C,U,O,P,N,_,D,B;
41
+ let y=null,h=null;const m=()=>(h||(h=e.createPublicClient({chain:c,transport:e.http()})),h);var f="Connect with Camp Network",w="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",v={USER_CONNECTED:"ed42542d-b676-4112-b6d9-6db98048b2e0",USER_DISCONNECTED:"20af31ac-e602-442e-9e0e-b589f4dd4016",TWITTER_LINKED:"7fbea086-90ef-4679-ba69-f47f9255b34c",DISCORD_LINKED:"d73f5ae3-a8e8-48f2-8532-85e0c7780d6a",SPOTIFY_LINKED:"fc1788b4-c984-42c8-96f4-c87f6bb0b8f7",TIKTOK_LINKED:"4a2ffdd3-f0e9-4784-8b49-ff76ec1c0a6a",TELEGRAM_LINKED:"9006bc5d-bcc9-4d01-a860-4f1a201e8e47"},T="0xd064817Dc0Af032c3fb5dd4671fd10E0a5F0515D",b="0x3B782d053de8910cC0EF3DC09EEA055229a70c6b";let g=[];const I=()=>g,A=t=>{function e(e){g.some((t=>t.info.uuid===e.detail.info.uuid))||(g=[...g,e.detail],t(g))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)};var k=[{inputs:[{internalType:"string",name:"_name",type:"string"},{internalType:"string",name:"_symbol",type:"string"},{internalType:"string",name:"_baseURI",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"DurationZero",type:"error"},{inputs:[{internalType:"uint16",name:"royaltyBps",type:"uint16"}],name:"InvalidRoyalty",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"caller",type:"address"}],name:"NotTokenOwner",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"TokenAlreadyExists",type:"error"},{inputs:[],name:"URIQueryForNonexistentToken",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"Verifier_InvalidDeadline",type:"error"},{inputs:[],name:"Verifier_InvalidSignature",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"buyer",type:"address"},{indexed:!1,internalType:"uint32",name:"periods",type:"uint32"},{indexed:!1,internalType:"uint64",name:"newExpiry",type:"uint64"},{indexed:!1,internalType:"uint256",name:"amountPaid",type:"uint256"}],name:"AccessPurchased",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"DataDeleted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"}],name:"DataDeletionRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"bytes32",name:"contentHash",type:"bytes32"}],name:"DataMinted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"royaltyAmount",type:"uint256"},{indexed:!1,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"uint256",name:"protocolAmount",type:"uint256"}],name:"RoyaltyPaid",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"newPrice",type:"uint128"},{indexed:!1,internalType:"uint32",name:"newDuration",type:"uint32"},{indexed:!1,internalType:"uint16",name:"newRoyaltyBps",type:"uint16"},{indexed:!1,internalType:"address",name:"paymentToken",type:"address"}],name:"TermsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"creator",type:"address"}],name:"addCreator",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"pauser",type:"address"}],name:"addPauser",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner_",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"contentHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"creators",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"dataStatus",outputs:[{internalType:"enum DataNFT.DataStatus",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"finalizeDelete",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getTerms",outputs:[{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct DataNFT.LicenseTerms",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner_",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes32",name:"hash",type:"bytes32"},{internalType:"string",name:"uri",type:"string"},{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct DataNFT.LicenseTerms",name:"licenseTerms",type:"tuple"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"mintWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"pausers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"creator",type:"address"}],name:"removeCreator",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"pauser",type:"address"}],name:"removePauser",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"requestDelete",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"salePrice",type:"uint256"}],name:"royaltyInfo",outputs:[{internalType:"address",name:"receiver",type:"address"},{internalType:"uint256",name:"royaltyAmount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"royaltyPercentages",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"royaltyReceivers",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"terms",outputs:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct DataNFT.LicenseTerms",name:"newTerms",type:"tuple"}],name:"updateTerms",outputs:[],stateMutability:"nonpayable",type:"function"}];
42
+ /**
43
+ * Mints a Data NFT with a signature.
44
+ * @param to The address to mint the NFT to.
45
+ * @param tokenId The ID of the token to mint.
46
+ * @param hash The hash of the data associated with the NFT.
47
+ * @param uri The URI of the NFT metadata.
48
+ * @param licenseTerms The terms of the license for the NFT.
49
+ * @param deadline The deadline for the minting operation.
50
+ * @param signature The signature for the minting operation.
51
+ * @returns A promise that resolves when the minting is complete.
52
+ */function C(t,e,n,i,r,s,o){return a(this,void 0,void 0,(function*(){return yield this.callContractMethod(T,k,"mintWithSignature",[t,e,n,i,r,s,o.v,o.r,o.s],{waitForReceipt:!0})}))}
53
+ /**
54
+ * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
55
+ * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
56
+ * @param deadline The deadline for the registration operation.
57
+ * @param fileKey Optional file key for file uploads.
58
+ * @return A promise that resolves with the registration data.
59
+ */function M(t,e,n){return a(this,void 0,void 0,(function*(){const i={source:t,deadline:e.toString()};void 0!==n&&(i.fileKey=n);const a=yield fetch(`${w}/auth/origin/register`,{method:"POST",headers:{Authorization:`Bearer ${this.getJwt()}`},body:JSON.stringify(i)});if(!a.ok)throw new Error(`Failed to get signature: ${a.statusText}`);const r=yield a.json();if(r.isError)throw new Error(`Failed to get signature: ${r.message}`);return r.data}))}function E(t,e){return this.callContractMethod(T,k,"updateTerms",[t,e],{waitForReceipt:!0})}function x(t){return this.callContractMethod(T,k,"requestDelete",[t])}function S(t){return this.callContractMethod(T,k,"getTerms",[t])}function $(t){return this.callContractMethod(T,k,"ownerOf",[t])}function D(t){return this.callContractMethod(T,k,"balanceOf",[t])}function F(t){return this.callContractMethod(T,k,"contentHash",[t])}function j(t){return this.callContractMethod(T,k,"tokenURI",[t])}function P(t){return this.callContractMethod(T,k,"dataStatus",[t])}function U(t,e){return a(this,void 0,void 0,(function*(){return this.callContractMethod(T,k,"royaltyInfo",[t,e])}))}function N(t){return this.callContractMethod(T,k,"getApproved",[t])}function O(t,e){return this.callContractMethod(T,k,"isApprovedForAll",[t,e])}function B(t,e,n){return this.callContractMethod(T,k,"transferFrom",[t,e,n])}function _(t,e,n,i){const a=i?[t,e,n,i]:[t,e,n];return this.callContractMethod(T,k,"safeTransferFrom",a)}function W(t,e){return this.callContractMethod(T,k,"approve",[t,e])}function q(t,e){return this.callContractMethod(T,k,"setApprovalForAll",[t,e])}var R,z,L,K,J,H,G,V,Z,Q,Y,X,tt,et,nt,it=[{type:"constructor",inputs:[{name:"dataNFT_",type:"address",internalType:"address"},{name:"router_",type:"address",internalType:"address"},{name:"protocolFeeBps_",type:"uint16",internalType:"uint16"}],stateMutability:"nonpayable"},{type:"function",name:"addFeeManager",inputs:[{name:"feeManager",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"addPauser",inputs:[{name:"pauser",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"buyAccess",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"periods",type:"uint32",internalType:"uint32"}],outputs:[],stateMutability:"payable"},{type:"function",name:"dataNFT",inputs:[],outputs:[{name:"",type:"address",internalType:"contract DataNFT"}],stateMutability:"view"},{type:"function",name:"feeManagers",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"hasAccess",inputs:[{name:"user",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"pause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"paused",inputs:[],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"pausers",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"protocolFeeBps",inputs:[],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"removeFeeManager",inputs:[{name:"feeManager",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"removePauser",inputs:[{name:"pauser",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"renewAccess",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"buyer",type:"address",internalType:"address"},{name:"periods",type:"uint32",internalType:"uint32"}],outputs:[],stateMutability:"payable"},{type:"function",name:"router",inputs:[],outputs:[{name:"",type:"address",internalType:"contract RoyaltyRouter"}],stateMutability:"view"},{type:"function",name:"subscriptionExpiry",inputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint64",internalType:"uint64"}],stateMutability:"view"},{type:"function",name:"unpause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateProtocolFee",inputs:[{name:"newFeeBps",type:"uint16",internalType:"uint16"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"AccessPurchased",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"buyer",type:"address",indexed:!0,internalType:"address"},{name:"periods",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newExpiry",type:"uint64",indexed:!1,internalType:"uint64"},{name:"amountPaid",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeleted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeletionRequested",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DataMinted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"},{name:"contentHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"RoyaltyPaid",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"royaltyAmount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"creator",type:"address",indexed:!1,internalType:"address"},{name:"protocolAmount",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"TermsUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"newPrice",type:"uint128",indexed:!1,internalType:"uint128"},{name:"newDuration",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"},{name:"paymentToken",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"error",name:"DurationZero",inputs:[]},{type:"error",name:"InvalidPayment",inputs:[{name:"expected",type:"uint256",internalType:"uint256"},{name:"actual",type:"uint256",internalType:"uint256"}]},{type:"error",name:"InvalidPeriods",inputs:[{name:"periods",type:"uint32",internalType:"uint32"}]},{type:"error",name:"InvalidRoyalty",inputs:[{name:"royaltyBps",type:"uint16",internalType:"uint16"}]},{type:"error",name:"Unauthorized",inputs:[]},{type:"error",name:"ZeroAddress",inputs:[]}];function at(t,e,n){return this.callContractMethod(b,it,"buyAccess",[t,e],{waitForReceipt:!0,value:n})}function rt(t,e,n,i){return this.callContractMethod(b,it,"renewAccess",[t,e,n],void 0!==i?{value:i}:void 0)}function st(t,e){return this.callContractMethod(b,it,"hasAccess",[t,e])}function ot(t,e){return this.callContractMethod(b,it,"subscriptionExpiry",[t,e])}
60
+ /**
61
+ * Approves a spender to spend a specified amount of tokens on behalf of the owner.
62
+ * If the current allowance is less than the specified amount, it will perform the approval.
63
+ * @param {ApproveParams} params - The parameters for the approval.
64
+ */
42
65
  /**
43
66
  * The Origin class
44
67
  * Handles the upload of files to Origin, as well as querying the user's stats
45
- */class W{constructor(e){k.set(this,(t=>s(this,void 0,void 0,(function*(){const e=yield fetch(`${y}/auth/origin/upload-url`,{method:"POST",body:JSON.stringify({name:t.name,type:t.type}),headers:{Authorization:`Bearer ${this.jwt}`}}),i=yield e.json();return i.isError?i.message:i.data})))),b.set(this,((t,e)=>s(this,void 0,void 0,(function*(){(yield fetch(`${y}/auth/origin/update-status`,{method:"PATCH",body:JSON.stringify({status:e,fileKey:t}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}})).ok||console.error("Failed to update origin status")})))),this.uploadFile=(e,i)=>s(this,void 0,void 0,(function*(){const n=yield r(this,k,"f").call(this,e);if(n){try{yield((e,i,n)=>new Promise(((s,r)=>{t.put(i,e,Object.assign({headers:{"Content-Type":e.type}},"undefined"!=typeof window&&"function"==typeof n?{onUploadProgress:t=>{if(t.total){const e=t.loaded/t.total*100;n(e)}}}:{})).then((t=>{s(t.data)})).catch((t=>{var e;const i=(null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.data)||(null==t?void 0:t.message)||"Upload failed";r(i)}))})))(e,n.url,(null==i?void 0:i.progressCallback)||(()=>{}))}catch(t){throw yield r(this,b,"f").call(this,n.key,"failed"),new Error("Failed to upload file: "+t)}yield r(this,b,"f").call(this,n.key,"success")}else console.error("Failed to generate upload URL")})),this.getOriginUploads=()=>s(this,void 0,void 0,(function*(){const t=yield fetch(`${y}/auth/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!t.ok)return console.error("Failed to get origin uploads"),null;return(yield t.json()).data})),this.jwt=e}
68
+ */
69
+ class dt{constructor(e,n){R.add(this),z.set(this,(t=>a(this,void 0,void 0,(function*(){const e=yield fetch(`${w}/auth/origin/upload-url`,{method:"POST",body:JSON.stringify({name:t.name,type:t.type}),headers:{Authorization:`Bearer ${this.jwt}`}}),n=yield e.json();return n.isError?n.message:n.data})))),L.set(this,((t,e)=>a(this,void 0,void 0,(function*(){(yield fetch(`${w}/auth/origin/update-status`,{method:"PATCH",body:JSON.stringify({status:e,fileKey:t}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}})).ok||console.error("Failed to update origin status")})))),this.uploadFile=(e,n)=>a(this,void 0,void 0,(function*(){const i=yield r(this,z,"f").call(this,e);if(i){try{yield((e,n,i)=>new Promise(((a,r)=>{t.put(n,e,Object.assign({headers:{"Content-Type":e.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:t=>{if(t.total){const e=t.loaded/t.total*100;i(e)}}}:{})).then((t=>{a(t.data)})).catch((t=>{var e;const n=(null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.data)||(null==t?void 0:t.message)||"Upload failed";r(n)}))})))(e,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(t){throw yield r(this,L,"f").call(this,i.key,"failed"),new Error("Failed to upload file: "+t)}return yield r(this,L,"f").call(this,i.key,"success"),i}console.error("Failed to generate upload URL")})),this.mintFile=(t,e,n)=>a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");try{const i=yield this.uploadFile(t,n);if(!i||!i.key)return console.error("Invalid upload info:",i),null;const a=BigInt(Math.floor(Date.now()/1e3)+600),r=yield this.registerDataNFT("file",a,i.key),{tokenId:s,signerAddress:o,hash:d,v:u,r:l,s:p}=r;// 10 minutes from now
70
+ if(!s||!o||!d||void 0===u||void 0===l||void 0===p)return console.error("Invalid registration data:",r),null;const[c]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),y={v:u,r:l,s:p};yield this.mintWithSignature(c,s,d,i.url,e,a,y);return s.toString()}catch(t){return console.error("Failed to upload file:",t),null}})),this.mintSocial=t=>a(this,void 0,void 0,(function*(){try{const e=BigInt(Math.floor(Date.now()/1e3)+600),n=yield this.registerDataNFT(t,e);// 10 minutes from now (temp)
71
+ return n?n.tokenId.toString():(console.error("Failed to register DataNFT"),null)}catch(t){return console.error("Failed to mint social DataNFT:",t),null}})),this.getOriginUploads=()=>a(this,void 0,void 0,(function*(){const t=yield fetch(`${w}/auth/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!t.ok)return console.error("Failed to get origin uploads"),null;return(yield t.json()).data})),this.jwt=e,this.viemClient=n,
72
+ // DataNFT methods
73
+ this.mintWithSignature=C.bind(this),this.registerDataNFT=M.bind(this),this.updateTerms=E.bind(this),this.requestDelete=x.bind(this),this.getTerms=S.bind(this),this.ownerOf=$.bind(this),this.balanceOf=D.bind(this),this.contentHash=F.bind(this),this.tokenURI=j.bind(this),this.dataStatus=P.bind(this),this.royaltyInfo=U.bind(this),this.getApproved=N.bind(this),this.isApprovedForAll=O.bind(this),this.transferFrom=B.bind(this),this.safeTransferFrom=_.bind(this),this.approve=W.bind(this),this.setApprovalForAll=q.bind(this),
74
+ // Marketplace methods
75
+ this.buyAccess=at.bind(this),this.renewAccess=rt.bind(this),this.hasAccess=st.bind(this),this.subscriptionExpiry=ot.bind(this)}getJwt(){return this.jwt}setViemClient(t){this.viemClient=t}
46
76
  /**
47
77
  * Get the user's Origin stats (multiplier, consent, usage, etc.).
48
78
  * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
49
- */getOriginUsage(){return s(this,void 0,void 0,(function*(){const t=yield fetch(`${y}/auth/origin/usage`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,
79
+ */getOriginUsage(){return a(this,void 0,void 0,(function*(){const t=yield fetch(`${w}/auth/origin/usage`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,
50
80
  // "x-client-id": this.clientId,
51
- "Content-Type":"application/json"}}).then((t=>t.json()));if(!t.isError&&t.data.user)return t;throw new a(t.message||"Failed to fetch Origin usage")}))}
81
+ "Content-Type":"application/json"}}).then((t=>t.json()));if(!t.isError&&t.data.user)return t;throw new o(t.message||"Failed to fetch Origin usage")}))}
52
82
  /**
53
83
  * Set the user's consent for Origin usage.
54
84
  * @param {boolean} consent The user's consent.
55
85
  * @returns {Promise<void>}
56
86
  * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
57
- */setOriginConsent(t){return s(this,void 0,void 0,(function*(){if(void 0===t)throw new a("Consent is required");const e=yield fetch(`${y}/auth/origin/status`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
87
+ */setOriginConsent(t){return a(this,void 0,void 0,(function*(){if(void 0===t)throw new o("Consent is required");const e=yield fetch(`${w}/auth/origin/status`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
58
88
  // "x-client-id": this.clientId,
59
- "Content-Type":"application/json"},body:JSON.stringify({active:t})}).then((t=>t.json()));if(e.isError)throw new a(e.message||"Failed to set Origin consent")}))}
89
+ "Content-Type":"application/json"},body:JSON.stringify({active:t})}).then((t=>t.json()));if(e.isError)throw new o(e.message||"Failed to set Origin consent")}))}
60
90
  /**
61
91
  * Set the user's Origin multiplier.
62
92
  * @param {number} multiplier The user's Origin multiplier.
63
93
  * @returns {Promise<void>}
64
94
  * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the multiplier is not provided.
65
- */setOriginMultiplier(t){return s(this,void 0,void 0,(function*(){if(void 0===t)throw new a("Multiplier is required");const e=yield fetch(`${y}/auth/origin/multiplier`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
95
+ */setOriginMultiplier(t){return a(this,void 0,void 0,(function*(){if(void 0===t)throw new o("Multiplier is required");const e=yield fetch(`${w}/auth/origin/multiplier`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
66
96
  // "x-client-id": this.clientId,
67
- "Content-Type":"application/json"},body:JSON.stringify({multiplier:t})}).then((t=>t.json()));if(e.isError)throw new a(e.message||"Failed to set Origin multiplier")}))}}k=new WeakMap,b=new WeakMap;S=new WeakMap,$=new WeakMap,E=new WeakSet,j=function(t,e){r(this,S,"f")[t]&&r(this,S,"f")[t].forEach((t=>t(e)))},C=function(t){return s(this,void 0,void 0,(function*(){var e,i;if("undefined"==typeof localStorage)return;const n=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:wallet-address"),s=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:user-id"),o=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:jwt");if(n&&s&&o){this.walletAddress=n,this.userId=s,this.jwt=o,this.origin=new W(this.jwt),this.isAuthenticated=!0;let a=t;if(!a){const t=null!==(e=A())&&void 0!==e?e:[];for(const e of t)try{if((null===(i=(yield e.provider.request({method:"eth_accounts"}))[0])||void 0===i?void 0:i.toLowerCase())===n.toLowerCase()){a=e.provider;break}}catch(t){console.warn("Failed to fetch accounts from provider:",t)}}a&&(this.viem=m(a,(new Date).getTime().toString(),n),r(this,E,"m",j).call(this,"viem",this.viem))}else this.isAuthenticated=!1}))},U=function(){return s(this,void 0,void 0,(function*(){try{const[t]=yield this.viem.requestAddresses();return this.walletAddress=t,t}catch(t){throw new a(t)}}))},O=function(){return s(this,void 0,void 0,(function*(){try{const t=yield fetch(`${y}/auth/client-user/nonce`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({walletAddress:this.walletAddress})}),e=yield t.json();return 200!==t.status?Promise.reject(e.message||"Failed to fetch nonce"):e.data}catch(t){throw new Error(t)}}))},P=function(t,e){return s(this,void 0,void 0,(function*(){try{const i=yield fetch(`${y}/auth/client-user/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({message:t,signature:e,walletAddress:this.walletAddress})}),n=yield i.json(),s=n.data.split(".")[1],r=JSON.parse(atob(s));return{success:!n.isError,userId:r.id,token:n.data}}catch(t){throw new a(t)}}))},N=function(t){return n.createSiweMessage({domain:window.location.host,address:this.walletAddress,statement:v,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:t})},_=function(t,e){return s(this,arguments,void 0,(function*(t,e,i=1){
97
+ "Content-Type":"application/json"},body:JSON.stringify({multiplier:t})}).then((t=>t.json()));if(e.isError)throw new o(e.message||"Failed to set Origin multiplier")}))}
98
+ /**
99
+ * Call a contract method.
100
+ * @param {string} contractAddress The contract address.
101
+ * @param {Abi} abi The contract ABI.
102
+ * @param {string} methodName The method name.
103
+ * @param {any[]} params The method parameters.
104
+ * @param {CallOptions} [options] The call options.
105
+ * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
106
+ * @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
107
+ */callContractMethod(t,n,i,s){return a(this,arguments,void 0,(function*(t,n,i,a,s={}){const o=e.getAbiItem({abi:n,name:i}),d=o&&"stateMutability"in o&&("view"===o.stateMutability||"pure"===o.stateMutability);if(!d&&!this.viemClient)throw new Error("WalletClient not connected.");if(d){const e=m();return(yield e.readContract({address:t,abi:n,functionName:i,args:a}))||null}{const[o]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),d=e.encodeFunctionData({abi:n,functionName:i,args:a});yield r(this,R,"m",J).call(this,c);const u=yield this.viemClient.sendTransaction({to:t,data:d,account:o,value:s.value,gas:s.gas});if("string"!=typeof u)throw new Error("Transaction failed to send.");if(!s.waitForReceipt)return u;return yield r(this,R,"m",K).call(this,u)}}))}
108
+ /**
109
+ * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
110
+ * @param {bigint} tokenId The token ID of the asset.
111
+ * @param {number} periods The number of periods to buy access for.
112
+ * @returns {Promise<any>} The result of the buyAccess call.
113
+ */buyAccessSmart(t,n){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const i=yield this.getTerms(t);if(!i)throw new Error("Failed to fetch terms for asset");const{price:r,paymentToken:s}=i;if(void 0===r||void 0===s)throw new Error("Terms missing price or paymentToken");const o=r*BigInt(n);if(s===e.zeroAddress)return this.buyAccess(t,n,o);const d=yield this.viemClient.getAddress();return yield function(t){return a(this,arguments,void 0,(function*({walletClient:t,publicClient:n,tokenAddress:i,owner:a,spender:r,amount:s}){(yield n.readContract({address:i,abi:e.erc20Abi,functionName:"allowance",args:[a,r]}))<s&&(yield t.writeContract({address:i,account:a,abi:e.erc20Abi,functionName:"approve",args:[r,s],chain:c}))}))}({walletClient:this.viemClient,publicClient:m(),tokenAddress:s,owner:d,spender:b,amount:o}),this.buyAccess(t,n)}))}getData(t){return a(this,void 0,void 0,(function*(){const e=yield fetch(`${w}/auth/origin/data/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!e.ok)throw new Error("Failed to fetch data");return e.json()}))}}z=new WeakMap,L=new WeakMap,R=new WeakSet,K=function(t){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");for(;;){const e=yield this.viemClient.request({method:"eth_getTransactionReceipt",params:[t]});if(e&&e.blockNumber)return e;yield new Promise((t=>setTimeout(t,1e3)))}}))},J=function(t){return a(this,void 0,void 0,(function*(){
114
+ // return;
115
+ if(!this.viemClient)throw new Error("WalletClient not connected.");let e=yield this.viemClient.request({method:"eth_chainId",params:[]});if("string"==typeof e&&(e=parseInt(e,16)),e!==t.id)try{yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}catch(e){
116
+ // Unrecognized chain
117
+ if(4902!==e.code)throw e;yield this.viemClient.request({method:"wallet_addEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16),chainName:t.name,rpcUrls:t.rpcUrls.default.http,nativeCurrency:t.nativeCurrency}]}),yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}}))};G=new WeakMap,V=new WeakMap,H=new WeakSet,Z=function(t,e){r(this,G,"f")[t]&&r(this,G,"f")[t].forEach((t=>t(e)))},Q=function(t){return a(this,void 0,void 0,(function*(){var e,n;if("undefined"==typeof localStorage)return;const i=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:wallet-address"),a=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:user-id"),r=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:jwt");if(i&&a&&r){this.walletAddress=i,this.userId=a,this.jwt=r,this.origin=new dt(this.jwt),this.isAuthenticated=!0;let s=t;if(!s){const t=null!==(e=I())&&void 0!==e?e:[];for(const e of t)try{if((null===(n=(yield e.provider.request({method:"eth_requestAccounts"}))[0])||void 0===n?void 0:n.toLowerCase())===i.toLowerCase()){s=e;break}}catch(t){console.warn("Failed to fetch accounts from provider:",t)}}s?this.setProvider({provider:s.provider,info:s.info||{name:"Unknown"},address:i}):
118
+ // await this.disconnect();
119
+ console.warn("No matching provider found for the stored wallet address. User disconnected.")}else this.isAuthenticated=!1}))},Y=function(){return a(this,void 0,void 0,(function*(){try{const[t]=yield this.viem.requestAddresses();return this.walletAddress=t,t}catch(t){throw new o(t)}}))},X=function(){return a(this,void 0,void 0,(function*(){try{const t=yield fetch(`${w}/auth/client-user/nonce`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({walletAddress:this.walletAddress})}),e=yield t.json();return 200!==t.status?Promise.reject(e.message||"Failed to fetch nonce"):e.data}catch(t){throw new Error(t)}}))},tt=function(t,e){return a(this,void 0,void 0,(function*(){try{const n=yield fetch(`${w}/auth/client-user/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({message:t,signature:e,walletAddress:this.walletAddress})}),i=yield n.json(),a=i.data.split(".")[1],r=JSON.parse(atob(a));return{success:!i.isError,userId:r.id,token:i.data}}catch(t){throw new o(t)}}))},et=function(t){return i.createSiweMessage({domain:window.location.host,address:this.walletAddress,statement:f,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:t})},nt=function(t,e){return a(this,arguments,void 0,(function*(t,e,n=1){
68
120
  // if (this.#ackeeInstance)
69
121
  // await sendAnalyticsEvent(this.#ackeeInstance, event, message, count);
70
122
  // else return;
71
- }))},D=function(t){return s(this,void 0,void 0,(function*(){if(!this.viem)throw new Error("WalletClient not connected.");for(;;){const e=yield this.viem.request({method:"eth_getTransactionReceipt",params:[t]});if(e&&e.blockNumber)return e;yield new Promise((t=>setTimeout(t,1e3)))}}))},B=function(t){return s(this,void 0,void 0,(function*(){
72
- // return;
73
- if(!this.viem)throw new Error("WalletClient not connected.");let e=yield this.viem.request({method:"eth_chainId",params:[]});if("string"==typeof e&&(e=parseInt(e,16)),e!==t.id)try{yield this.viem.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}catch(e){
74
- // Unrecognized chain
75
- if(4902!==e.code)throw e;yield this.viem.request({method:"wallet_addEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16),chainName:t.name,rpcUrls:t.rpcUrls.default.http,nativeCurrency:t.nativeCurrency}]}),yield this.viem.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}}))},exports.Auth=
123
+ }))},exports.Auth=
76
124
  /**
77
125
  * The Auth class.
78
126
  * @class
@@ -88,11 +136,11 @@ class{
88
136
  * @param {object} [options.ackeeInstance] The Ackee instance.
89
137
  * @throws {APIError} - Throws an error if the clientId is not provided.
90
138
  */
91
- constructor({clientId:t,redirectUri:e,allowAnalytics:i=!0,ackeeInstance:n}){if(E.add(this),S.set(this,void 0),$.set(this,void 0),!t)throw new Error("clientId is required");this.viem=null,
139
+ constructor({clientId:t,redirectUri:e,allowAnalytics:n=!0,ackeeInstance:i}){if(H.add(this),G.set(this,void 0),V.set(this,void 0),!t)throw new Error("clientId is required");this.viem=null,
92
140
  // if (typeof window !== "undefined") {
93
141
  // if (window.ethereum) this.viem = getClient(window.ethereum);
94
142
  // }
95
- this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==typeof t?e.reduce(((e,i)=>(e[i]=t[i]||("undefined"!=typeof window?window.location.href:""),e)),{}):"string"==typeof t?e.reduce(((e,i)=>(e[i]=t,e)),{}):t?{}:e.reduce(((t,e)=>(t[e]="undefined"!=typeof window?window.location.href:"",t)),{})})(e),n&&o(this,$,n,"f"),i&&r(this,$,"f"),this.clientId=t,this.isAuthenticated=!1,this.jwt=null,this.origin=null,this.walletAddress=null,this.userId=null,o(this,S,{},"f"),T((t=>{r(this,E,"m",j).call(this,"providers",t)})),r(this,E,"m",C).call(this)}
143
+ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==typeof t?e.reduce(((e,n)=>(e[n]=t[n]||("undefined"!=typeof window?window.location.href:""),e)),{}):"string"==typeof t?e.reduce(((e,n)=>(e[n]=t,e)),{}):t?{}:e.reduce(((t,e)=>(t[e]="undefined"!=typeof window?window.location.href:"",t)),{})})(e),i&&s(this,V,i,"f"),n&&r(this,V,"f"),this.clientId=t,this.isAuthenticated=!1,this.jwt=null,this.origin=null,this.walletAddress=null,this.userId=null,s(this,G,{},"f"),A((t=>{r(this,H,"m",Z).call(this,"providers",t)})),r(this,H,"m",Q).call(this)}
96
144
  /**
97
145
  * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
98
146
  * @param {("state"|"provider"|"providers"|"viem")} event The event.
@@ -102,18 +150,18 @@ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==ty
102
150
  * auth.on("state", (state) => {
103
151
  * console.log(state);
104
152
  * });
105
- */on(t,e){r(this,S,"f")[t]||(r(this,S,"f")[t]=[]),r(this,S,"f")[t].push(e),"providers"===t&&e(A())}
153
+ */on(t,e){r(this,G,"f")[t]||(r(this,G,"f")[t]=[]),r(this,G,"f")[t].push(e),"providers"===t&&e(I())}
106
154
  /**
107
155
  * Set the loading state.
108
156
  * @param {boolean} loading The loading state.
109
157
  * @returns {void}
110
- */setLoading(t){r(this,E,"m",j).call(this,"state",t?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
158
+ */setLoading(t){r(this,H,"m",Z).call(this,"state",t?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
111
159
  /**
112
160
  * 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.
113
161
  * @param {object} options The options object. Includes the provider and the provider info.
114
162
  * @returns {void}
115
163
  * @throws {APIError} - Throws an error if the provider is not provided.
116
- */setProvider({provider:t,info:e,address:i}){if(!t)throw new a("provider is required");this.viem=m(t,e.name,i),r(this,E,"m",j).call(this,"viem",this.viem),r(this,E,"m",j).call(this,"provider",{provider:t,info:e})}
164
+ */setProvider({provider:t,info:i,address:a}){if(!t)throw new o("provider is required");this.viem=((t,i="window.ethereum",a)=>{var r;if(!t&&!y)return console.warn("Provider is required to create a client."),null;if(!y||y.transport.name!==i&&t||a!==(null===(r=y.account)||void 0===r?void 0:r.address)&&t){const r={chain:c,transport:e.custom(t,{name:i})};a&&(r.account=n.toAccount(a)),y=e.createWalletClient(r)}return y})(t,i.name,a),this.origin&&this.origin.setViemClient(this.viem),r(this,H,"m",Z).call(this,"viem",this.viem),r(this,H,"m",Z).call(this,"provider",{provider:t,info:i})}
117
165
  /**
118
166
  * 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.
119
167
  * @param {string} walletAddress The wallet address.
@@ -122,12 +170,12 @@ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==ty
122
170
  /**
123
171
  * Disconnect the user.
124
172
  * @returns {Promise<void>}
125
- */disconnect(){return s(this,void 0,void 0,(function*(){this.isAuthenticated&&(this.isAuthenticated=!1,this.walletAddress=null,this.userId=null,this.jwt=null,this.origin=null,localStorage.removeItem("camp-sdk:wallet-address"),localStorage.removeItem("camp-sdk:user-id"),localStorage.removeItem("camp-sdk:jwt"),r(this,E,"m",j).call(this,"state","unauthenticated"),yield r(this,E,"m",_).call(this,g.USER_DISCONNECTED,"User Disconnected"))}))}
173
+ */disconnect(){return a(this,void 0,void 0,(function*(){this.isAuthenticated&&(r(this,H,"m",Z).call(this,"state","unauthenticated"),this.isAuthenticated=!1,this.walletAddress=null,this.userId=null,this.jwt=null,this.origin=null,localStorage.removeItem("camp-sdk:wallet-address"),localStorage.removeItem("camp-sdk:user-id"),localStorage.removeItem("camp-sdk:jwt"))}))}
126
174
  /**
127
175
  * Connect the user's wallet and sign the message.
128
176
  * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
129
177
  * @throws {APIError} - Throws an error if the user cannot be authenticated.
130
- */connect(){return s(this,void 0,void 0,(function*(){r(this,E,"m",j).call(this,"state","loading");try{this.walletAddress||(yield r(this,E,"m",U).call(this));const t=yield r(this,E,"m",O).call(this),e=r(this,E,"m",N).call(this,t),i=yield this.viem.signMessage({account:this.walletAddress,message:e}),n=yield r(this,E,"m",P).call(this,e,i);if(n.success)return this.isAuthenticated=!0,this.userId=n.userId,this.jwt=n.token,this.origin=new W(this.jwt),localStorage.setItem("camp-sdk:jwt",this.jwt),localStorage.setItem("camp-sdk:wallet-address",this.walletAddress),localStorage.setItem("camp-sdk:user-id",this.userId),r(this,E,"m",j).call(this,"state","authenticated"),yield r(this,E,"m",_).call(this,g.USER_CONNECTED,"User Connected"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,r(this,E,"m",j).call(this,"state","unauthenticated"),new a("Failed to authenticate")}catch(t){throw this.isAuthenticated=!1,r(this,E,"m",j).call(this,"state","unauthenticated"),new a(t)}}))}
178
+ */connect(){return a(this,void 0,void 0,(function*(){r(this,H,"m",Z).call(this,"state","loading");try{this.walletAddress||(yield r(this,H,"m",Y).call(this));const t=yield r(this,H,"m",X).call(this),e=r(this,H,"m",et).call(this,t),n=yield this.viem.signMessage({account:this.walletAddress,message:e}),i=yield r(this,H,"m",tt).call(this,e,n);if(i.success)return this.isAuthenticated=!0,this.userId=i.userId,this.jwt=i.token,this.origin=new dt(this.jwt,this.viem),localStorage.setItem("camp-sdk:jwt",this.jwt),localStorage.setItem("camp-sdk:wallet-address",this.walletAddress),localStorage.setItem("camp-sdk:user-id",this.userId),r(this,H,"m",Z).call(this,"state","authenticated"),yield r(this,H,"m",nt).call(this,v.USER_CONNECTED,"User Connected"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,r(this,H,"m",Z).call(this,"state","unauthenticated"),new o("Failed to authenticate")}catch(t){throw this.isAuthenticated=!1,r(this,H,"m",Z).call(this,"state","unauthenticated"),new o(t)}}))}
131
179
  /**
132
180
  * Get the user's linked social accounts.
133
181
  * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
@@ -136,49 +184,49 @@ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==ty
136
184
  * const auth = new Auth({ clientId: "your-client-id" });
137
185
  * const socials = await auth.getLinkedSocials();
138
186
  * console.log(socials);
139
- */getLinkedSocials(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${y}/auth/client-user/connections-sdk`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"}}).then((t=>t.json()));if(t.isError)throw new a(t.message||"Failed to fetch connections");{const e={};return Object.keys(t.data.data).forEach((i=>{e[i.split("User")[0]]=t.data.data[i]})),e}}))}
187
+ */getLinkedSocials(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${w}/auth/client-user/connections-sdk`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"}}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to fetch connections");{const e={};return Object.keys(t.data.data).forEach((n=>{e[n.split("User")[0]]=t.data.data[n]})),e}}))}
140
188
  /**
141
189
  * Link the user's Twitter account.
142
190
  * @returns {Promise<void>}
143
191
  * @throws {Error} - Throws an error if the user is not authenticated.
144
- */linkTwitter(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
192
+ */linkTwitter(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
145
193
  // await this.#sendAnalyticsEvent(
146
194
  // constants.ACKEE_EVENTS.TWITTER_LINKED,
147
195
  // "Twitter Linked"
148
196
  // );
149
- window.location.href=`${y}/twitter/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.twitter}`}))}
197
+ window.location.href=`${w}/twitter/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.twitter}`}))}
150
198
  /**
151
199
  * Link the user's Discord account.
152
200
  * @returns {Promise<void>}
153
201
  * @throws {Error} - Throws an error if the user is not authenticated.
154
- */linkDiscord(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
202
+ */linkDiscord(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
155
203
  // await this.#sendAnalyticsEvent(
156
204
  // constants.ACKEE_EVENTS.DISCORD_LINKED,
157
205
  // "Discord Linked"
158
206
  // );
159
- window.location.href=`${y}/discord/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.discord}`}))}
207
+ window.location.href=`${w}/discord/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.discord}`}))}
160
208
  /**
161
209
  * Link the user's Spotify account.
162
210
  * @returns {Promise<void>}
163
211
  * @throws {Error} - Throws an error if the user is not authenticated.
164
- */linkSpotify(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
212
+ */linkSpotify(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
165
213
  // await this.#sendAnalyticsEvent(
166
214
  // constants.ACKEE_EVENTS.SPOTIFY_LINKED,
167
215
  // "Spotify Linked"
168
216
  // );
169
- window.location.href=`${y}/spotify/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.spotify}`}))}
217
+ window.location.href=`${w}/spotify/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.spotify}`}))}
170
218
  /**
171
219
  * Link the user's TikTok account.
172
220
  * @param {string} handle The user's TikTok handle.
173
221
  * @returns {Promise<any>} A promise that resolves with the TikTok account data.
174
222
  * @throws {Error|APIError} - Throws an error if the user is not authenticated.
175
- */linkTikTok(t){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${y}/tiktok/connect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userHandle:t,clientId:this.clientId,userId:this.userId})}).then((t=>t.json()));if(e.isError)throw"Request failed with status code 502"===e.message?new a("TikTok service is currently unavailable, try again later"):new a(e.message||"Failed to link TikTok account");return r(this,E,"m",_).call(this,g.TIKTOK_LINKED,"TikTok Linked"),e.data}))}
223
+ */linkTikTok(t){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${w}/tiktok/connect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userHandle:t,clientId:this.clientId,userId:this.userId})}).then((t=>t.json()));if(e.isError)throw"Request failed with status code 502"===e.message?new o("TikTok service is currently unavailable, try again later"):new o(e.message||"Failed to link TikTok account");return r(this,H,"m",nt).call(this,v.TIKTOK_LINKED,"TikTok Linked"),e.data}))}
176
224
  /**
177
225
  * Send an OTP to the user's Telegram account.
178
226
  * @param {string} phoneNumber The user's phone number.
179
227
  * @returns {Promise<any>} A promise that resolves with the OTP data.
180
228
  * @throws {Error|APIError} - Throws an error if the user is not authenticated.
181
- */sendTelegramOTP(t){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t)throw new a("Phone number is required");yield this.unlinkTelegram();const e=yield fetch(`${y}/telegram/sendOTP-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t})}).then((t=>t.json()));if(e.isError)throw new a(e.message||"Failed to send Telegram OTP");return e.data}))}
229
+ */sendTelegramOTP(t){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t)throw new o("Phone number is required");yield this.unlinkTelegram();const e=yield fetch(`${w}/telegram/sendOTP-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t})}).then((t=>t.json()));if(e.isError)throw new o(e.message||"Failed to send Telegram OTP");return e.data}))}
182
230
  /**
183
231
  * Link the user's Telegram account.
184
232
  * @param {string} phoneNumber The user's phone number.
@@ -186,47 +234,37 @@ window.location.href=`${y}/spotify/connect?clientId=${this.clientId}&userId=${th
186
234
  * @param {string} phoneCodeHash The phone code hash.
187
235
  * @returns {Promise<object>} A promise that resolves with the Telegram account data.
188
236
  * @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.
189
- */linkTelegram(t,e,i){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t||!e||!i)throw new a("Phone number, OTP, and phone code hash are required");const n=yield fetch(`${y}/telegram/signIn-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t,code:e,phone_code_hash:i,userId:this.userId,clientId:this.clientId})}).then((t=>t.json()));if(n.isError)throw new a(n.message||"Failed to link Telegram account");return r(this,E,"m",_).call(this,g.TELEGRAM_LINKED,"Telegram Linked"),n.data}))}
237
+ */linkTelegram(t,e,n){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t||!e||!n)throw new o("Phone number, OTP, and phone code hash are required");const i=yield fetch(`${w}/telegram/signIn-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t,code:e,phone_code_hash:n,userId:this.userId,clientId:this.clientId})}).then((t=>t.json()));if(i.isError)throw new o(i.message||"Failed to link Telegram account");return r(this,H,"m",nt).call(this,v.TELEGRAM_LINKED,"Telegram Linked"),i.data}))}
190
238
  /**
191
239
  * Unlink the user's Twitter account.
192
240
  * @returns {Promise<any>} A promise that resolves with the unlink result.
193
241
  * @throws {Error} - Throws an error if the user is not authenticated.
194
242
  * @throws {APIError} - Throws an error if the request fails.
195
- */unlinkTwitter(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${y}/twitter/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new a(t.message||"Failed to unlink Twitter account");return t.data}))}
243
+ */unlinkTwitter(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${w}/twitter/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink Twitter account");return t.data}))}
196
244
  /**
197
245
  * Unlink the user's Discord account.
198
246
  * @returns {Promise<any>} A promise that resolves with the unlink result.
199
247
  * @throws {Error} - Throws an error if the user is not authenticated.
200
248
  * @throws {APIError} - Throws an error if the request fails.
201
- */unlinkDiscord(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new a("User needs to be authenticated");const t=yield fetch(`${y}/discord/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new a(t.message||"Failed to unlink Discord account");return t.data}))}
249
+ */unlinkDiscord(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const t=yield fetch(`${w}/discord/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink Discord account");return t.data}))}
202
250
  /**
203
251
  * Unlink the user's Spotify account.
204
252
  * @returns {Promise<any>} A promise that resolves with the unlink result.
205
253
  * @throws {Error} - Throws an error if the user is not authenticated.
206
254
  * @throws {APIError} - Throws an error if the request fails.
207
- */unlinkSpotify(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new a("User needs to be authenticated");const t=yield fetch(`${y}/spotify/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new a(t.message||"Failed to unlink Spotify account");return t.data}))}
255
+ */unlinkSpotify(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const t=yield fetch(`${w}/spotify/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink Spotify account");return t.data}))}
208
256
  /**
209
257
  * Unlink the user's TikTok account.
210
258
  * @returns {Promise<any>} A promise that resolves with the unlink result.
211
259
  * @throws {Error} - Throws an error if the user is not authenticated.
212
260
  * @throws {APIError} - Throws an error if the request fails.
213
- */unlinkTikTok(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new a("User needs to be authenticated");const t=yield fetch(`${y}/tiktok/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new a(t.message||"Failed to unlink TikTok account");return t.data}))}
261
+ */unlinkTikTok(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const t=yield fetch(`${w}/tiktok/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink TikTok account");return t.data}))}
214
262
  /**
215
263
  * Unlink the user's Telegram account.
216
264
  * @returns {Promise<any>} A promise that resolves with the unlink result.
217
265
  * @throws {Error} - Throws an error if the user is not authenticated.
218
266
  * @throws {APIError} - Throws an error if the request fails.
219
- */unlinkTelegram(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new a("User needs to be authenticated");const t=yield fetch(`${y}/telegram/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new a(t.message||"Failed to unlink Telegram account");return t.data}))}
220
- /**
221
- * Call a contract method.
222
- * @param {string} contractAddress The contract address.
223
- * @param {Abi} abi The contract ABI.
224
- * @param {string} methodName The method name.
225
- * @param {any[]} params The method parameters.
226
- * @param {CallOptions} [options] The call options.
227
- * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
228
- * @throws {Error} - Throws an error if the wallet client is not connected or if the method is not a view function.
229
- */callContractMethod(t,i,n,o){return s(this,arguments,void 0,(function*(t,i,n,s,o={}){const a=e.getAbiItem({abi:i,name:n}),d=a&&"stateMutability"in a&&("view"===a.stateMutability||"pure"===a.stateMutability);if(!d&&!this.viem)throw new Error("WalletClient not connected.");if(d){const e=p();return(yield e.readContract({address:t,abi:i,functionName:n,args:s}))||null}{const[a]=yield this.viem.getAddresses(),d=e.encodeFunctionData({abi:i,functionName:n,args:s});yield r(this,E,"m",B).call(this,u);const c=yield this.viem.sendTransaction({to:t,data:d,account:a,value:o.value,gas:o.gas});if(o.waitForReceipt){return yield r(this,E,"m",D).call(this,c)}return c}}))}},exports.SpotifyAPI=
267
+ */unlinkTelegram(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const t=yield fetch(`${w}/telegram/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink Telegram account");return t.data}))}},exports.SpotifyAPI=
230
268
  /**
231
269
  * The SpotifyAPI class.
232
270
  * @class
@@ -245,51 +283,51 @@ constructor(t){this.apiKey=t.apiKey}
245
283
  * @param {string} spotifyId - The user's Spotify ID.
246
284
  * @returns {Promise<object>} - The saved tracks.
247
285
  * @throws {APIError} - Throws an error if the request fails.
248
- */fetchSavedTracksById(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/save-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
286
+ */fetchSavedTracksById(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/save-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
249
287
  /**
250
288
  * Fetch the played tracks of a user by Spotify ID.
251
289
  * @param {string} spotifyId - The user's Spotify ID.
252
290
  * @returns {Promise<object>} - The played tracks.
253
291
  * @throws {APIError} - Throws an error if the request fails.
254
- */fetchPlayedTracksById(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/played-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
292
+ */fetchPlayedTracksById(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/played-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
255
293
  /**
256
294
  * Fetch the user's saved albums by Spotify user ID.
257
295
  * @param {string} spotifyId - The user's Spotify ID.
258
296
  * @returns {Promise<object>} - The saved albums.
259
297
  * @throws {APIError} - Throws an error if the request fails.
260
- */fetchSavedAlbumsById(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/saved-albums`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
298
+ */fetchSavedAlbumsById(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/saved-albums`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
261
299
  /**
262
300
  * Fetch the user's saved playlists by Spotify user ID.
263
301
  * @param {string} spotifyId - The user's Spotify ID.
264
302
  * @returns {Promise<object>} - The saved playlists.
265
303
  * @throws {APIError} - Throws an error if the request fails.
266
- */fetchSavedPlaylistsById(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/saved-playlists`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
304
+ */fetchSavedPlaylistsById(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/saved-playlists`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
267
305
  /**
268
306
  * Fetch the tracks of an album by album ID.
269
307
  * @param {string} spotifyId - The Spotify ID of the user.
270
308
  * @param {string} albumId - The album ID.
271
309
  * @returns {Promise<object>} - The tracks in the album.
272
310
  * @throws {APIError} - Throws an error if the request fails.
273
- */fetchTracksInAlbum(t,e){return s(this,void 0,void 0,(function*(){const i=c(`${l}/album/tracks`,{spotifyId:t,albumId:e});return this._fetchDataWithAuth(i)}))}
311
+ */fetchTracksInAlbum(t,e){return a(this,void 0,void 0,(function*(){const n=u(`${p}/album/tracks`,{spotifyId:t,albumId:e});return this._fetchDataWithAuth(n)}))}
274
312
  /**
275
313
  * Fetch the tracks in a playlist by playlist ID.
276
314
  * @param {string} spotifyId - The Spotify ID of the user.
277
315
  * @param {string} playlistId - The playlist ID.
278
316
  * @returns {Promise<object>} - The tracks in the playlist.
279
317
  * @throws {APIError} - Throws an error if the request fails.
280
- */fetchTracksInPlaylist(t,e){return s(this,void 0,void 0,(function*(){const i=c(`${l}/playlist/tracks`,{spotifyId:t,playlistId:e});return this._fetchDataWithAuth(i)}))}
318
+ */fetchTracksInPlaylist(t,e){return a(this,void 0,void 0,(function*(){const n=u(`${p}/playlist/tracks`,{spotifyId:t,playlistId:e});return this._fetchDataWithAuth(n)}))}
281
319
  /**
282
320
  * Fetch the user's Spotify data by wallet address.
283
321
  * @param {string} walletAddress - The wallet address.
284
322
  * @returns {Promise<object>} - The user's Spotify data.
285
323
  * @throws {APIError} - Throws an error if the request fails.
286
- */fetchUserByWalletAddress(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/wallet-spotify-data`,{walletAddress:t});return this._fetchDataWithAuth(e)}))}
324
+ */fetchUserByWalletAddress(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/wallet-spotify-data`,{walletAddress:t});return this._fetchDataWithAuth(e)}))}
287
325
  /**
288
326
  * Private method to fetch data with authorization header.
289
327
  * @param {string} url - The URL to fetch.
290
328
  * @returns {Promise<object>} - The response data.
291
329
  * @throws {APIError} - Throws an error if the request fails.
292
- */_fetchDataWithAuth(t){return s(this,void 0,void 0,(function*(){if(!this.apiKey)throw new a("API key is required for fetching data",401);try{return yield d(t,{"x-api-key":this.apiKey})}catch(t){throw new a(t.message,t.statusCode)}}))}},exports.TwitterAPI=
330
+ */_fetchDataWithAuth(t){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new o("API key is required for fetching data",401);try{return yield d(t,{"x-api-key":this.apiKey})}catch(t){throw new o(t.message,t.statusCode)}}))}},exports.TwitterAPI=
293
331
  /**
294
332
  * The TwitterAPI class.
295
333
  * @class
@@ -307,7 +345,7 @@ constructor({apiKey:t}){this.apiKey=t}
307
345
  * @param {string} twitterUserName - The Twitter username.
308
346
  * @returns {Promise<object>} - The user details.
309
347
  * @throws {APIError} - Throws an error if the request fails.
310
- */fetchUserByUsername(t){return s(this,void 0,void 0,(function*(){const e=c(`${h}/user`,{twitterUserName:t});return this._fetchDataWithAuth(e)}))}
348
+ */fetchUserByUsername(t){return a(this,void 0,void 0,(function*(){const e=u(`${l}/user`,{twitterUserName:t});return this._fetchDataWithAuth(e)}))}
311
349
  /**
312
350
  * Fetch tweets by Twitter username.
313
351
  * @param {string} twitterUserName - The Twitter username.
@@ -315,7 +353,7 @@ constructor({apiKey:t}){this.apiKey=t}
315
353
  * @param {number} limit - The number of items per page.
316
354
  * @returns {Promise<object>} - The tweets.
317
355
  * @throws {APIError} - Throws an error if the request fails.
318
- */fetchTweetsByUsername(t){return s(this,arguments,void 0,(function*(t,e=1,i=10){const n=c(`${h}/tweets`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
356
+ */fetchTweetsByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/tweets`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
319
357
  /**
320
358
  * Fetch followers by Twitter username.
321
359
  * @param {string} twitterUserName - The Twitter username.
@@ -323,7 +361,7 @@ constructor({apiKey:t}){this.apiKey=t}
323
361
  * @param {number} limit - The number of items per page.
324
362
  * @returns {Promise<object>} - The followers.
325
363
  * @throws {APIError} - Throws an error if the request fails.
326
- */fetchFollowersByUsername(t){return s(this,arguments,void 0,(function*(t,e=1,i=10){const n=c(`${h}/followers`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
364
+ */fetchFollowersByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/followers`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
327
365
  /**
328
366
  * Fetch following by Twitter username.
329
367
  * @param {string} twitterUserName - The Twitter username.
@@ -331,13 +369,13 @@ constructor({apiKey:t}){this.apiKey=t}
331
369
  * @param {number} limit - The number of items per page.
332
370
  * @returns {Promise<object>} - The following.
333
371
  * @throws {APIError} - Throws an error if the request fails.
334
- */fetchFollowingByUsername(t){return s(this,arguments,void 0,(function*(t,e=1,i=10){const n=c(`${h}/following`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
372
+ */fetchFollowingByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/following`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
335
373
  /**
336
374
  * Fetch tweet by tweet ID.
337
375
  * @param {string} tweetId - The tweet ID.
338
376
  * @returns {Promise<object>} - The tweet.
339
377
  * @throws {APIError} - Throws an error if the request fails.
340
- */fetchTweetById(t){return s(this,void 0,void 0,(function*(){const e=c(`${h}/getTweetById`,{tweetId:t});return this._fetchDataWithAuth(e)}))}
378
+ */fetchTweetById(t){return a(this,void 0,void 0,(function*(){const e=u(`${l}/getTweetById`,{tweetId:t});return this._fetchDataWithAuth(e)}))}
341
379
  /**
342
380
  * Fetch user by wallet address.
343
381
  * @param {string} walletAddress - The wallet address.
@@ -345,7 +383,7 @@ constructor({apiKey:t}){this.apiKey=t}
345
383
  * @param {number} limit - The number of items per page.
346
384
  * @returns {Promise<object>} - The user data.
347
385
  * @throws {APIError} - Throws an error if the request fails.
348
- */fetchUserByWalletAddress(t){return s(this,arguments,void 0,(function*(t,e=1,i=10){const n=c(`${h}/wallet-twitter-data`,{walletAddress:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
386
+ */fetchUserByWalletAddress(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/wallet-twitter-data`,{walletAddress:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
349
387
  /**
350
388
  * Fetch reposted tweets by Twitter username.
351
389
  * @param {string} twitterUserName - The Twitter username.
@@ -353,7 +391,7 @@ constructor({apiKey:t}){this.apiKey=t}
353
391
  * @param {number} limit - The number of items per page.
354
392
  * @returns {Promise<object>} - The reposted tweets.
355
393
  * @throws {APIError} - Throws an error if the request fails.
356
- */fetchRepostedByUsername(t){return s(this,arguments,void 0,(function*(t,e=1,i=10){const n=c(`${h}/reposted`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
394
+ */fetchRepostedByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/reposted`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
357
395
  /**
358
396
  * Fetch replies by Twitter username.
359
397
  * @param {string} twitterUserName - The Twitter username.
@@ -361,7 +399,7 @@ constructor({apiKey:t}){this.apiKey=t}
361
399
  * @param {number} limit - The number of items per page.
362
400
  * @returns {Promise<object>} - The replies.
363
401
  * @throws {APIError} - Throws an error if the request fails.
364
- */fetchRepliesByUsername(t){return s(this,arguments,void 0,(function*(t,e=1,i=10){const n=c(`${h}/replies`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
402
+ */fetchRepliesByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/replies`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
365
403
  /**
366
404
  * Fetch likes by Twitter username.
367
405
  * @param {string} twitterUserName - The Twitter username.
@@ -369,7 +407,7 @@ constructor({apiKey:t}){this.apiKey=t}
369
407
  * @param {number} limit - The number of items per page.
370
408
  * @returns {Promise<object>} - The likes.
371
409
  * @throws {APIError} - Throws an error if the request fails.
372
- */fetchLikesByUsername(t){return s(this,arguments,void 0,(function*(t,e=1,i=10){const n=c(`${h}/event/likes/${t}`,{page:e,limit:i});return this._fetchDataWithAuth(n)}))}
410
+ */fetchLikesByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/event/likes/${t}`,{page:e,limit:n});return this._fetchDataWithAuth(i)}))}
373
411
  /**
374
412
  * Fetch follows by Twitter username.
375
413
  * @param {string} twitterUserName - The Twitter username.
@@ -377,7 +415,7 @@ constructor({apiKey:t}){this.apiKey=t}
377
415
  * @param {number} limit - The number of items per page.
378
416
  * @returns {Promise<object>} - The follows.
379
417
  * @throws {APIError} - Throws an error if the request fails.
380
- */fetchFollowsByUsername(t){return s(this,arguments,void 0,(function*(t,e=1,i=10){const n=c(`${h}/event/follows/${t}`,{page:e,limit:i});return this._fetchDataWithAuth(n)}))}
418
+ */fetchFollowsByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/event/follows/${t}`,{page:e,limit:n});return this._fetchDataWithAuth(i)}))}
381
419
  /**
382
420
  * Fetch viewed tweets by Twitter username.
383
421
  * @param {string} twitterUserName - The Twitter username.
@@ -385,10 +423,10 @@ constructor({apiKey:t}){this.apiKey=t}
385
423
  * @param {number} limit - The number of items per page.
386
424
  * @returns {Promise<object>} - The viewed tweets.
387
425
  * @throws {APIError} - Throws an error if the request fails.
388
- */fetchViewedTweetsByUsername(t){return s(this,arguments,void 0,(function*(t,e=1,i=10){const n=c(`${h}/event/viewed-tweets/${t}`,{page:e,limit:i});return this._fetchDataWithAuth(n)}))}
426
+ */fetchViewedTweetsByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/event/viewed-tweets/${t}`,{page:e,limit:n});return this._fetchDataWithAuth(i)}))}
389
427
  /**
390
428
  * Private method to fetch data with authorization header.
391
429
  * @param {string} url - The URL to fetch.
392
430
  * @returns {Promise<object>} - The response data.
393
431
  * @throws {APIError} - Throws an error if the request fails.
394
- */_fetchDataWithAuth(t){return s(this,void 0,void 0,(function*(){if(!this.apiKey)throw new a("API key is required for fetching data",401);try{return yield d(t,{"x-api-key":this.apiKey})}catch(t){throw new a(t.message,t.statusCode)}}))}};
432
+ */_fetchDataWithAuth(t){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new o("API key is required for fetching data",401);try{return yield d(t,{"x-api-key":this.apiKey})}catch(t){throw new o(t.message,t.statusCode)}}))}};