@campnetwork/origin 0.0.1 → 0.0.2

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
@@ -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 r(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{d(n.next(t))}catch(t){o(t)}}function a(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}d((n=n.apply(t,e||[])).next())}))}function o(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 s(t,e,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(t,i):r?r.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 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}}}
18
18
  /**
19
19
  * Makes a GET request to the given URL with the provided headers.
20
20
  *
@@ -22,7 +22,7 @@ function r(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(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 r(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 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)}}))}
26
26
  /**
27
27
  * Constructs a query string from an object of query parameters.
28
28
  *
@@ -36,17 +36,17 @@ function r(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(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",u="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/spotify";const l={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 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/"}}};
40
40
  // @ts-ignore
41
- let f=null,w=null;const p=(t,n="window.ethereum",r)=>{var o;if(!t&&!f)return console.warn("Provider is required to create a client."),null;if(!f||f.transport.name!==n&&t||r!==(null===(o=f.account)||void 0===o?void 0:o.address)&&t){const o={chain:l,transport:e.custom(t,{name:n})};r&&(o.account=i.toAccount(r)),f=e.createWalletClient(o)}return f},m=()=>(w||(w=e.createPublicClient({chain:l,transport:e.http()})),w);var v="Connect with Camp Network",y="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",g="https://ackee-production-01bd.up.railway.app",I={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 A=[];const T=()=>A,k=t=>{function e(e){A.some((t=>t.info.uuid===e.detail.info.uuid))||(A=[...A,e.detail],t(A))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)};var b,$,E,S,j,C,O,U,P,D,N,_,W,B;
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;
42
42
  /**
43
43
  * The Origin class
44
44
  * Handles the upload of files to Origin, as well as querying the user's stats
45
- */class x{constructor(t){b.set(this,(t=>r(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})))),$.set(this,((t,e)=>r(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=(t,e)=>r(this,void 0,void 0,(function*(){const i=yield o(this,b,"f").call(this,t);if(i){try{yield((t,e,i)=>new Promise(((n,r)=>{const o=new XMLHttpRequest;o.open("PUT",e,!0),o.upload.onprogress=t=>{if(t.lengthComputable){const e=t.loaded/t.total*100;i(e)}},o.onload=()=>{o.status>=200&&o.status<300?n(o.response):r(o.statusText)},o.onerror=()=>r(o.statusText),o.send(t)})))(t,i.url,(null==e?void 0:e.progressCallback)||(()=>{}))}catch(t){throw yield o(this,$,"f").call(this,i.key,"failed"),new Error("Failed to upload file: "+t)}yield o(this,$,"f").call(this,i.key,"success")}else console.error("Failed to generate upload URL")})),this.getOriginUploads=()=>r(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=t}
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}
46
46
  /**
47
47
  * Get the user's Origin stats (multiplier, consent, usage, etc.).
48
48
  * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
49
- */getOriginUsage(){return r(this,void 0,void 0,(function*(){const t=yield fetch(`${y}/auth/origin/usage`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,
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}`,
50
50
  // "x-client-id": this.clientId,
51
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")}))}
52
52
  /**
@@ -54,7 +54,7 @@ let f=null,w=null;const p=(t,n="window.ethereum",r)=>{var o;if(!t&&!f)return con
54
54
  * @param {boolean} consent The user's consent.
55
55
  * @returns {Promise<void>}
56
56
  * @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 r(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}`,
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}`,
58
58
  // "x-client-id": this.clientId,
59
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")}))}
60
60
  /**
@@ -62,66 +62,17 @@ let f=null,w=null;const p=(t,n="window.ethereum",r)=>{var o;if(!t&&!f)return con
62
62
  * @param {number} multiplier The user's Origin multiplier.
63
63
  * @returns {Promise<void>}
64
64
  * @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 r(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}`,
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}`,
66
66
  // "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")}))}}b=new WeakMap,$=new WeakMap;S=new WeakMap,j=new WeakMap,E=new WeakSet,C=function(t,e){o(this,S,"f")[t]&&o(this,S,"f")[t].forEach((t=>t(e)))},O=function(t){return r(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"),r=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:user-id"),s=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:jwt");if(n&&r&&s){this.walletAddress=n,this.userId=r,this.jwt=s,this.origin=new x(this.jwt),this.isAuthenticated=!0;let a=t;if(!a){const t=null!==(e=T())&&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=p(a,(new Date).getTime().toString(),n),o(this,E,"m",C).call(this,"viem",this.viem))}else this.isAuthenticated=!1}))},U=function(){return r(this,void 0,void 0,(function*(){try{const[t]=yield this.viem.requestAddresses();return this.walletAddress=t,t}catch(t){throw new a(t)}}))},P=function(){return r(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)}}))},D=function(t,e){return r(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(),r=n.data.split(".")[1],o=JSON.parse(atob(r));return{success:!n.isError,userId:o.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 r(this,arguments,void 0,(function*(t,e,i=1){o(this,j,"f")&&(yield((t,e,i,n)=>r(void 0,void 0,void 0,(function*(){return new Promise(((r,o)=>{if("undefined"!=typeof window&&t)try{t.action(e,{key:i,value:n},(t=>{r(t)}))}catch(t){console.error(t),o(t)}else o(new Error("Unable to send analytics event. If you are using the library, you can ignore this error."))}))})))(o(this,j,"f"),t,e,i))}))},W=function(t){return r(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 r(this,void 0,void 0,(function*(){
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){
68
+ // if (this.#ackeeInstance)
69
+ // await sendAnalyticsEvent(this.#ackeeInstance, event, message, count);
70
+ // 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*(){
68
72
  // return;
69
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){
70
74
  // Unrecognized chain
71
- 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)}]})}}))};
72
- /**
73
- The MIT License (MIT)
74
-
75
- Copyright (c) Tobias Reich
76
-
77
- Permission is hereby granted, free of charge, to any person obtaining a copy
78
- of this software and associated documentation files (the "Software"), to deal
79
- in the Software without restriction, including without limitation the rights
80
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
81
- copies of the Software, and to permit persons to whom the Software is
82
- furnished to do so, subject to the following conditions:
83
-
84
- The above copyright notice and this permission notice shall be included in
85
- all copies or substantial portions of the Software.
86
-
87
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
90
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
92
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
93
- THE SOFTWARE.
94
- */
95
- const q="undefined"!=typeof window,F=q?null===window||void 0===window?void 0:window.navigator:{userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",language:"en",languages:[],platform:"",vendor:"",maxTouchPoints:0,hardwareConcurrency:0,deviceMemory:0},L=q?null===window||void 0===window?void 0:window.location:{href:"",protocol:"",host:"",hostname:"",port:"",pathname:"",search:"",hash:""},R=function(t){return"88888888-8888-8888-8888-888888888888"===t},K=function(){return"hidden"===document.visibilityState},z=function(){const t=(L.search.split("source=")[1]||"").split("&")[0];return""===t?void 0:t},M=function(t=!1){var e;const i={siteLocation:null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href,siteReferrer:document.referrer,source:z()},n={siteLanguage:F?((null==F?void 0:F.language)||(null==F?void 0:F.language)||"").substr(0,2):"",screenWidth:screen.width,screenHeight:screen.height,screenColorDepth:screen.colorDepth,browserWidth:null===window||void 0===window?void 0:window.outerWidth,browserHeight:null===window||void 0===window?void 0:window.outerHeight};return Object.assign(Object.assign({},i),!0===t?n:{})},J=function(t){return{query:"\n\t\t\tmutation updateRecord($recordId: ID!) {\n\t\t\t\tupdateRecord(id: $recordId) {\n\t\t\t\t\tsuccess\n\t\t\t\t}\n\t\t\t}\n\t\t",variables:{recordId:t}}},H=function(t,e,i,n){const r=new XMLHttpRequest;r.open("POST",t),r.onload=()=>{if(200!==r.status)throw new Error("Server returned with an unhandled status");let t=null;try{t=JSON.parse(r.responseText)}catch(t){throw new Error("Failed to parse response from server")}if(null!=t.errors)throw new Error(t.errors[0].message);if("function"==typeof n)return n(t)},r.setRequestHeader("Content-Type","application/json;charset=UTF-8"),
96
- // xhr.withCredentials = opts.ignoreOwnVisits ?? false;
97
- r.withCredentials=!1,r.send(JSON.stringify(e))},G=function(){const t=document.querySelector("[data-ackee-domain-id]");if(null==t)return;const e=t.getAttribute("data-ackee-server")||"",i=t.getAttribute("data-ackee-domain-id")||"",n=t.getAttribute("data-ackee-opts")||"{}";V(e,JSON.parse(n)).record(i)},V=function(t,e){e=function(t={}){
98
- // Create new object to avoid changes by reference
99
- const e={};
100
- // Defaults to false
101
- return e.detailed=!0===t.detailed,
102
- // Defaults to true
103
- e.ignoreLocalhost=!1!==t.ignoreLocalhost,
104
- // Defaults to true
105
- e.ignoreOwnVisits=!1!==t.ignoreOwnVisits,e}(e);const i=function(t){const e="/"===t.substr(-1);return t+(!0===e?"":"/")+"api"}(t),n=()=>{},r={record:()=>({stop:n}),updateRecord:()=>({stop:n}),action:n,updateAction:n};if(!0===e.ignoreLocalhost&&!0==(""===(o=L.hostname)||"localhost"===o||"127.0.0.1"===o||"::1"===o)&&!0===q)
106
- // console.warn("Ackee ignores you because you are on localhost");
107
- return r;var o,s;if(!0===(s=F?F.userAgent:"",/bot|crawler|spider|crawling/i.test(s)))
108
- // console.warn("Ackee ignores you because you are a bot");
109
- return r;
110
- // Creates a new record on the server and updates the record
111
- // very x seconds to track the duration of the visit. Tries to use
112
- // the default attributes when there're no custom attributes defined.
113
- // Return the real instance
114
- return{record:(t,n=M(e.detailed),r)=>{
115
- // Function to stop updating the record
116
- let o=!1;return H(i,function(t,e){return{query:"\n\t\t\tmutation createRecord($domainId: ID!, $input: CreateRecordInput!) {\n\t\t\t\tcreateRecord(domainId: $domainId, input: $input) {\n\t\t\t\t\tpayload {\n\t\t\t\t\t\tid\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t",variables:{domainId:t,input:e}}}(t,n),0,(t=>{const e=t.data.createRecord.payload.id;if(!0===R(e))
117
- // return console.warn("Ackee ignores you because this is your own site");
118
- return;const n=setInterval((()=>{!0!==o?!0!==K()&&H(i,J(e)):clearInterval(n)}),15e3);return"function"==typeof r?r(e):void 0})),{stop:()=>{o=!0}}},updateRecord:t=>{
119
- // Function to stop updating the record
120
- let e=!1;const n=()=>{e=!0};if(!0===R(t))
121
- // console.warn("Ackee ignores you because this is your own site");
122
- return{stop:n};const r=setInterval((()=>{!0!==e?!0!==K()&&H(i,J(t)):clearInterval(r)}),15e3);return{stop:n}},action:(t,e,n)=>{H(i,function(t,e){return{query:"\n\t\t\tmutation createAction($eventId: ID!, $input: CreateActionInput!) {\n\t\t\t\tcreateAction(eventId: $eventId, input: $input) {\n\t\t\t\t\tpayload {\n\t\t\t\t\t\tid\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t",variables:{eventId:t,input:e}}}(t,e),0,(t=>{const e=t.data.createAction.payload.id;if(!0!==R(e))return"function"==typeof n?n(e):void 0}))},updateAction:(t,e)=>{!0!==R(t)&&H(i,function(t,e){return{query:"\n\t\t\tmutation updateAction($actionId: ID!, $input: UpdateActionInput!) {\n\t\t\t\tupdateAction(id: $actionId, input: $input) {\n\t\t\t\t\tsuccess\n\t\t\t\t}\n\t\t\t}\n\t\t",variables:{actionId:t,input:e}}}(t,e))}}};
123
- // Only run Ackee automatically when executed in a browser environment
124
- !0===q&&G();var X=Object.freeze({__proto__:null,attributes:M,create:V,detect:G});exports.Ackee=X,exports.Auth=
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=
125
76
  /**
126
77
  * The Auth class.
127
78
  * @class
@@ -137,11 +88,11 @@ class{
137
88
  * @param {object} [options.ackeeInstance] The Ackee instance.
138
89
  * @throws {APIError} - Throws an error if the clientId is not provided.
139
90
  */
140
- constructor({clientId:t,redirectUri:e,allowAnalytics:i=!0,ackeeInstance:n}){if(E.add(this),S.set(this,void 0),j.set(this,void 0),!t)throw new Error("clientId is required");this.viem=null,
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,
141
92
  // if (typeof window !== "undefined") {
142
93
  // if (window.ethereum) this.viem = getClient(window.ethereum);
143
94
  // }
144
- 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&&s(this,j,n,"f"),i&&!o(this,j,"f")&&"undefined"!=typeof window&&s(this,j,V(g,{detailed:!1,ignoreLocalhost:!0,ignoreOwnVisits:!1}),"f"),this.clientId=t,this.isAuthenticated=!1,this.jwt=null,this.origin=null,this.walletAddress=null,this.userId=null,s(this,S,{},"f"),k((t=>{o(this,E,"m",C).call(this,"providers",t)})),o(this,E,"m",O).call(this)}
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)}
145
96
  /**
146
97
  * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
147
98
  * @param {("state"|"provider"|"providers"|"viem")} event The event.
@@ -151,21 +102,18 @@ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==ty
151
102
  * auth.on("state", (state) => {
152
103
  * console.log(state);
153
104
  * });
154
- */on(t,e){o(this,S,"f")[t]||(o(this,S,"f")[t]=[]),o(this,S,"f")[t].push(e),"providers"===t&&e(T())}
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())}
155
106
  /**
156
107
  * Set the loading state.
157
108
  * @param {boolean} loading The loading state.
158
109
  * @returns {void}
159
- */setLoading(t){o(this,E,"m",C).call(this,"state",t?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
110
+ */setLoading(t){r(this,E,"m",j).call(this,"state",t?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
160
111
  /**
161
112
  * 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.
162
113
  * @param {object} options The options object. Includes the provider and the provider info.
163
114
  * @returns {void}
164
115
  * @throws {APIError} - Throws an error if the provider is not provided.
165
- */setProvider({provider:t,info:e,address:i}){if(!t)throw new a("provider is required");
166
- // const addr = provider.selectedAddress || provider.accounts[0];
167
- // TOFIX: the address can be the leftover address, make sure it resets after disconnection
168
- this.viem=p(t,e.name,i),o(this,E,"m",C).call(this,"viem",this.viem),o(this,E,"m",C).call(this,"provider",{provider:t,info:e})}
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})}
169
117
  /**
170
118
  * 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.
171
119
  * @param {string} walletAddress The wallet address.
@@ -174,13 +122,12 @@ this.viem=p(t,e.name,i),o(this,E,"m",C).call(this,"viem",this.viem),o(this,E,"m"
174
122
  /**
175
123
  * Disconnect the user.
176
124
  * @returns {Promise<void>}
177
- */disconnect(){return r(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"),o(this,E,"m",C).call(this,"state","unauthenticated"),yield o(this,E,"m",_).call(this,I.USER_DISCONNECTED,"User Disconnected"))}))}
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"))}))}
178
126
  /**
179
127
  * Connect the user's wallet and sign the message.
180
128
  * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
181
129
  * @throws {APIError} - Throws an error if the user cannot be authenticated.
182
- */connect(){return r(this,void 0,void 0,(function*(){o(this,E,"m",C).call(this,"state","loading");try{this.walletAddress||(yield o(this,E,"m",U).call(this));const t=yield o(this,E,"m",P).call(this),e=o(this,E,"m",N).call(this,t),i=yield this.viem.signMessage({account:this.walletAddress,message:e}),n=yield o(this,E,"m",D).call(this,e,i);if(n.success)return this.isAuthenticated=!0,this.userId=n.userId,this.jwt=n.token,this.origin=new x(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),o(this,E,"m",C).call(this,"state","authenticated"),yield o(this,E,"m",_).call(this,I.USER_CONNECTED,"User Connected"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,o(this,E,"m",C).call(this,"state","unauthenticated"),new a("Failed to authenticate")}catch(t){throw this.isAuthenticated=!1,o(this,E,"m",C).call(this,"state","unauthenticated"),new a(t)}}))}
183
- // ORIGIN
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)}}))}
184
131
  /**
185
132
  * Get the user's linked social accounts.
186
133
  * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
@@ -189,13 +136,12 @@ this.viem=p(t,e.name,i),o(this,E,"m",C).call(this,"viem",this.viem),o(this,E,"m"
189
136
  * const auth = new Auth({ clientId: "your-client-id" });
190
137
  * const socials = await auth.getLinkedSocials();
191
138
  * console.log(socials);
192
- */
193
- getLinkedSocials(){return r(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}}))}
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}}))}
194
140
  /**
195
141
  * Link the user's Twitter account.
196
142
  * @returns {Promise<void>}
197
143
  * @throws {Error} - Throws an error if the user is not authenticated.
198
- */linkTwitter(){return r(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
144
+ */linkTwitter(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
199
145
  // await this.#sendAnalyticsEvent(
200
146
  // constants.ACKEE_EVENTS.TWITTER_LINKED,
201
147
  // "Twitter Linked"
@@ -205,7 +151,7 @@ window.location.href=`${y}/twitter/connect?clientId=${this.clientId}&userId=${th
205
151
  * Link the user's Discord account.
206
152
  * @returns {Promise<void>}
207
153
  * @throws {Error} - Throws an error if the user is not authenticated.
208
- */linkDiscord(){return r(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
154
+ */linkDiscord(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
209
155
  // await this.#sendAnalyticsEvent(
210
156
  // constants.ACKEE_EVENTS.DISCORD_LINKED,
211
157
  // "Discord Linked"
@@ -215,7 +161,7 @@ window.location.href=`${y}/discord/connect?clientId=${this.clientId}&userId=${th
215
161
  * Link the user's Spotify account.
216
162
  * @returns {Promise<void>}
217
163
  * @throws {Error} - Throws an error if the user is not authenticated.
218
- */linkSpotify(){return r(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
164
+ */linkSpotify(){return s(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
219
165
  // await this.#sendAnalyticsEvent(
220
166
  // constants.ACKEE_EVENTS.SPOTIFY_LINKED,
221
167
  // "Spotify Linked"
@@ -226,13 +172,13 @@ window.location.href=`${y}/spotify/connect?clientId=${this.clientId}&userId=${th
226
172
  * @param {string} handle The user's TikTok handle.
227
173
  * @returns {Promise<any>} A promise that resolves with the TikTok account data.
228
174
  * @throws {Error|APIError} - Throws an error if the user is not authenticated.
229
- */linkTikTok(t){return r(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 o(this,E,"m",_).call(this,I.TIKTOK_LINKED,"TikTok Linked"),e.data}))}
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}))}
230
176
  /**
231
177
  * Send an OTP to the user's Telegram account.
232
178
  * @param {string} phoneNumber The user's phone number.
233
179
  * @returns {Promise<any>} A promise that resolves with the OTP data.
234
180
  * @throws {Error|APIError} - Throws an error if the user is not authenticated.
235
- */sendTelegramOTP(t){return r(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}))}
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}))}
236
182
  /**
237
183
  * Link the user's Telegram account.
238
184
  * @param {string} phoneNumber The user's phone number.
@@ -240,37 +186,37 @@ window.location.href=`${y}/spotify/connect?clientId=${this.clientId}&userId=${th
240
186
  * @param {string} phoneCodeHash The phone code hash.
241
187
  * @returns {Promise<object>} A promise that resolves with the Telegram account data.
242
188
  * @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.
243
- */linkTelegram(t,e,i){return r(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 o(this,E,"m",_).call(this,I.TELEGRAM_LINKED,"Telegram Linked"),n.data}))}
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}))}
244
190
  /**
245
191
  * Unlink the user's Twitter account.
246
192
  * @returns {Promise<any>} A promise that resolves with the unlink result.
247
193
  * @throws {Error} - Throws an error if the user is not authenticated.
248
194
  * @throws {APIError} - Throws an error if the request fails.
249
- */unlinkTwitter(){return r(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}))}
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}))}
250
196
  /**
251
197
  * Unlink the user's Discord account.
252
198
  * @returns {Promise<any>} A promise that resolves with the unlink result.
253
199
  * @throws {Error} - Throws an error if the user is not authenticated.
254
200
  * @throws {APIError} - Throws an error if the request fails.
255
- */unlinkDiscord(){return r(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}))}
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}))}
256
202
  /**
257
203
  * Unlink the user's Spotify account.
258
204
  * @returns {Promise<any>} A promise that resolves with the unlink result.
259
205
  * @throws {Error} - Throws an error if the user is not authenticated.
260
206
  * @throws {APIError} - Throws an error if the request fails.
261
- */unlinkSpotify(){return r(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}))}
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}))}
262
208
  /**
263
209
  * Unlink the user's TikTok account.
264
210
  * @returns {Promise<any>} A promise that resolves with the unlink result.
265
211
  * @throws {Error} - Throws an error if the user is not authenticated.
266
212
  * @throws {APIError} - Throws an error if the request fails.
267
- */unlinkTikTok(){return r(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}))}
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}))}
268
214
  /**
269
215
  * Unlink the user's Telegram account.
270
216
  * @returns {Promise<any>} A promise that resolves with the unlink result.
271
217
  * @throws {Error} - Throws an error if the user is not authenticated.
272
218
  * @throws {APIError} - Throws an error if the request fails.
273
- */unlinkTelegram(){return r(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}))}
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}))}
274
220
  /**
275
221
  * Call a contract method.
276
222
  * @param {string} contractAddress The contract address.
@@ -280,7 +226,7 @@ window.location.href=`${y}/spotify/connect?clientId=${this.clientId}&userId=${th
280
226
  * @param {CallOptions} [options] The call options.
281
227
  * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
282
228
  * @throws {Error} - Throws an error if the wallet client is not connected or if the method is not a view function.
283
- */callContractMethod(t,i,n,s){return r(this,arguments,void 0,(function*(t,i,n,r,s={}){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=m();return(yield e.readContract({address:t,abi:i,functionName:n,args:r}))||null}{const[a]=yield this.viem.getAddresses(),d=e.encodeFunctionData({abi:i,functionName:n,args:r});yield o(this,E,"m",B).call(this,l);const c=yield this.viem.sendTransaction({to:t,data:d,account:a,value:s.value,gas:s.gas});if(s.waitForReceipt){return yield o(this,E,"m",W).call(this,c)}return c}}))}},exports.SpotifyAPI=
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=
284
230
  /**
285
231
  * The SpotifyAPI class.
286
232
  * @class
@@ -299,51 +245,51 @@ constructor(t){this.apiKey=t.apiKey}
299
245
  * @param {string} spotifyId - The user's Spotify ID.
300
246
  * @returns {Promise<object>} - The saved tracks.
301
247
  * @throws {APIError} - Throws an error if the request fails.
302
- */fetchSavedTracksById(t){return r(this,void 0,void 0,(function*(){const e=c(`${u}/save-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
248
+ */fetchSavedTracksById(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/save-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
303
249
  /**
304
250
  * Fetch the played tracks of a user by Spotify ID.
305
251
  * @param {string} spotifyId - The user's Spotify ID.
306
252
  * @returns {Promise<object>} - The played tracks.
307
253
  * @throws {APIError} - Throws an error if the request fails.
308
- */fetchPlayedTracksById(t){return r(this,void 0,void 0,(function*(){const e=c(`${u}/played-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
254
+ */fetchPlayedTracksById(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/played-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
309
255
  /**
310
256
  * Fetch the user's saved albums by Spotify user ID.
311
257
  * @param {string} spotifyId - The user's Spotify ID.
312
258
  * @returns {Promise<object>} - The saved albums.
313
259
  * @throws {APIError} - Throws an error if the request fails.
314
- */fetchSavedAlbumsById(t){return r(this,void 0,void 0,(function*(){const e=c(`${u}/saved-albums`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
260
+ */fetchSavedAlbumsById(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/saved-albums`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
315
261
  /**
316
262
  * Fetch the user's saved playlists by Spotify user ID.
317
263
  * @param {string} spotifyId - The user's Spotify ID.
318
264
  * @returns {Promise<object>} - The saved playlists.
319
265
  * @throws {APIError} - Throws an error if the request fails.
320
- */fetchSavedPlaylistsById(t){return r(this,void 0,void 0,(function*(){const e=c(`${u}/saved-playlists`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
266
+ */fetchSavedPlaylistsById(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/saved-playlists`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
321
267
  /**
322
268
  * Fetch the tracks of an album by album ID.
323
269
  * @param {string} spotifyId - The Spotify ID of the user.
324
270
  * @param {string} albumId - The album ID.
325
271
  * @returns {Promise<object>} - The tracks in the album.
326
272
  * @throws {APIError} - Throws an error if the request fails.
327
- */fetchTracksInAlbum(t,e){return r(this,void 0,void 0,(function*(){const i=c(`${u}/album/tracks`,{spotifyId:t,albumId:e});return this._fetchDataWithAuth(i)}))}
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)}))}
328
274
  /**
329
275
  * Fetch the tracks in a playlist by playlist ID.
330
276
  * @param {string} spotifyId - The Spotify ID of the user.
331
277
  * @param {string} playlistId - The playlist ID.
332
278
  * @returns {Promise<object>} - The tracks in the playlist.
333
279
  * @throws {APIError} - Throws an error if the request fails.
334
- */fetchTracksInPlaylist(t,e){return r(this,void 0,void 0,(function*(){const i=c(`${u}/playlist/tracks`,{spotifyId:t,playlistId:e});return this._fetchDataWithAuth(i)}))}
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)}))}
335
281
  /**
336
282
  * Fetch the user's Spotify data by wallet address.
337
283
  * @param {string} walletAddress - The wallet address.
338
284
  * @returns {Promise<object>} - The user's Spotify data.
339
285
  * @throws {APIError} - Throws an error if the request fails.
340
- */fetchUserByWalletAddress(t){return r(this,void 0,void 0,(function*(){const e=c(`${u}/wallet-spotify-data`,{walletAddress:t});return this._fetchDataWithAuth(e)}))}
286
+ */fetchUserByWalletAddress(t){return s(this,void 0,void 0,(function*(){const e=c(`${l}/wallet-spotify-data`,{walletAddress:t});return this._fetchDataWithAuth(e)}))}
341
287
  /**
342
288
  * Private method to fetch data with authorization header.
343
289
  * @param {string} url - The URL to fetch.
344
290
  * @returns {Promise<object>} - The response data.
345
291
  * @throws {APIError} - Throws an error if the request fails.
346
- */_fetchDataWithAuth(t){return r(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=
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=
347
293
  /**
348
294
  * The TwitterAPI class.
349
295
  * @class
@@ -361,7 +307,7 @@ constructor({apiKey:t}){this.apiKey=t}
361
307
  * @param {string} twitterUserName - The Twitter username.
362
308
  * @returns {Promise<object>} - The user details.
363
309
  * @throws {APIError} - Throws an error if the request fails.
364
- */fetchUserByUsername(t){return r(this,void 0,void 0,(function*(){const e=c(`${h}/user`,{twitterUserName:t});return this._fetchDataWithAuth(e)}))}
310
+ */fetchUserByUsername(t){return s(this,void 0,void 0,(function*(){const e=c(`${h}/user`,{twitterUserName:t});return this._fetchDataWithAuth(e)}))}
365
311
  /**
366
312
  * Fetch tweets by Twitter username.
367
313
  * @param {string} twitterUserName - The Twitter username.
@@ -369,7 +315,7 @@ constructor({apiKey:t}){this.apiKey=t}
369
315
  * @param {number} limit - The number of items per page.
370
316
  * @returns {Promise<object>} - The tweets.
371
317
  * @throws {APIError} - Throws an error if the request fails.
372
- */fetchTweetsByUsername(t){return r(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)}))}
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)}))}
373
319
  /**
374
320
  * Fetch followers by Twitter username.
375
321
  * @param {string} twitterUserName - The Twitter username.
@@ -377,7 +323,7 @@ constructor({apiKey:t}){this.apiKey=t}
377
323
  * @param {number} limit - The number of items per page.
378
324
  * @returns {Promise<object>} - The followers.
379
325
  * @throws {APIError} - Throws an error if the request fails.
380
- */fetchFollowersByUsername(t){return r(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)}))}
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)}))}
381
327
  /**
382
328
  * Fetch following by Twitter username.
383
329
  * @param {string} twitterUserName - The Twitter username.
@@ -385,13 +331,13 @@ constructor({apiKey:t}){this.apiKey=t}
385
331
  * @param {number} limit - The number of items per page.
386
332
  * @returns {Promise<object>} - The following.
387
333
  * @throws {APIError} - Throws an error if the request fails.
388
- */fetchFollowingByUsername(t){return r(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)}))}
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)}))}
389
335
  /**
390
336
  * Fetch tweet by tweet ID.
391
337
  * @param {string} tweetId - The tweet ID.
392
338
  * @returns {Promise<object>} - The tweet.
393
339
  * @throws {APIError} - Throws an error if the request fails.
394
- */fetchTweetById(t){return r(this,void 0,void 0,(function*(){const e=c(`${h}/getTweetById`,{tweetId:t});return this._fetchDataWithAuth(e)}))}
340
+ */fetchTweetById(t){return s(this,void 0,void 0,(function*(){const e=c(`${h}/getTweetById`,{tweetId:t});return this._fetchDataWithAuth(e)}))}
395
341
  /**
396
342
  * Fetch user by wallet address.
397
343
  * @param {string} walletAddress - The wallet address.
@@ -399,7 +345,7 @@ constructor({apiKey:t}){this.apiKey=t}
399
345
  * @param {number} limit - The number of items per page.
400
346
  * @returns {Promise<object>} - The user data.
401
347
  * @throws {APIError} - Throws an error if the request fails.
402
- */fetchUserByWalletAddress(t){return r(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)}))}
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)}))}
403
349
  /**
404
350
  * Fetch reposted tweets by Twitter username.
405
351
  * @param {string} twitterUserName - The Twitter username.
@@ -407,7 +353,7 @@ constructor({apiKey:t}){this.apiKey=t}
407
353
  * @param {number} limit - The number of items per page.
408
354
  * @returns {Promise<object>} - The reposted tweets.
409
355
  * @throws {APIError} - Throws an error if the request fails.
410
- */fetchRepostedByUsername(t){return r(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)}))}
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)}))}
411
357
  /**
412
358
  * Fetch replies by Twitter username.
413
359
  * @param {string} twitterUserName - The Twitter username.
@@ -415,7 +361,7 @@ constructor({apiKey:t}){this.apiKey=t}
415
361
  * @param {number} limit - The number of items per page.
416
362
  * @returns {Promise<object>} - The replies.
417
363
  * @throws {APIError} - Throws an error if the request fails.
418
- */fetchRepliesByUsername(t){return r(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)}))}
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)}))}
419
365
  /**
420
366
  * Fetch likes by Twitter username.
421
367
  * @param {string} twitterUserName - The Twitter username.
@@ -423,7 +369,7 @@ constructor({apiKey:t}){this.apiKey=t}
423
369
  * @param {number} limit - The number of items per page.
424
370
  * @returns {Promise<object>} - The likes.
425
371
  * @throws {APIError} - Throws an error if the request fails.
426
- */fetchLikesByUsername(t){return r(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)}))}
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)}))}
427
373
  /**
428
374
  * Fetch follows by Twitter username.
429
375
  * @param {string} twitterUserName - The Twitter username.
@@ -431,7 +377,7 @@ constructor({apiKey:t}){this.apiKey=t}
431
377
  * @param {number} limit - The number of items per page.
432
378
  * @returns {Promise<object>} - The follows.
433
379
  * @throws {APIError} - Throws an error if the request fails.
434
- */fetchFollowsByUsername(t){return r(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)}))}
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)}))}
435
381
  /**
436
382
  * Fetch viewed tweets by Twitter username.
437
383
  * @param {string} twitterUserName - The Twitter username.
@@ -439,10 +385,10 @@ constructor({apiKey:t}){this.apiKey=t}
439
385
  * @param {number} limit - The number of items per page.
440
386
  * @returns {Promise<object>} - The viewed tweets.
441
387
  * @throws {APIError} - Throws an error if the request fails.
442
- */fetchViewedTweetsByUsername(t){return r(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)}))}
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)}))}
443
389
  /**
444
390
  * Private method to fetch data with authorization header.
445
391
  * @param {string} url - The URL to fetch.
446
392
  * @returns {Promise<object>} - The response data.
447
393
  * @throws {APIError} - Throws an error if the request fails.
448
- */_fetchDataWithAuth(t){return r(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)}}))}};
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)}}))}};
package/dist/core.d.ts CHANGED
@@ -426,78 +426,4 @@ declare class Auth {
426
426
  callContractMethod(contractAddress: string, abi: Abi, methodName: string, params: any[], options?: CallOptions): Promise<any>;
427
427
  }
428
428
 
429
- /**
430
- The MIT License (MIT)
431
-
432
- Copyright (c) Tobias Reich
433
-
434
- Permission is hereby granted, free of charge, to any person obtaining a copy
435
- of this software and associated documentation files (the "Software"), to deal
436
- in the Software without restriction, including without limitation the rights
437
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
438
- copies of the Software, and to permit persons to whom the Software is
439
- furnished to do so, subject to the following conditions:
440
-
441
- The above copyright notice and this permission notice shall be included in
442
- all copies or substantial portions of the Software.
443
-
444
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
445
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
446
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
447
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
448
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
449
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
450
- THE SOFTWARE.
451
- */
452
- interface Options {
453
- detailed?: boolean;
454
- ignoreLocalhost?: boolean;
455
- ignoreOwnVisits?: boolean;
456
- }
457
- interface Attributes {
458
- siteLocation: string;
459
- siteReferrer: string;
460
- source?: string;
461
- siteLanguage?: string;
462
- screenWidth?: number;
463
- screenHeight?: number;
464
- screenColorDepth?: number;
465
- browserWidth?: number;
466
- browserHeight?: number;
467
- }
468
- /**
469
- * Gathers all platform-, screen- and user-related information.
470
- * @param {Boolean} detailed - Include personal data.
471
- * @returns {Object} attributes - User-related information.
472
- */
473
- declare const attributes: (detailed?: boolean) => Attributes;
474
- /**
475
- * Looks for an element with Ackee attributes and executes Ackee with the given attributes.
476
- * Fails silently.
477
- */
478
- declare const detect: () => void;
479
- /**
480
- * Creates a new instance.
481
- * @param {String} server - URL of the Ackee server.
482
- * @param {?Object} opts
483
- * @returns {Object} instance
484
- */
485
- declare const create: (server: string, opts?: Options) => {
486
- record: (domainId: string, attrs?: Attributes, next?: (recordId: string) => void) => {
487
- stop: () => void;
488
- };
489
- updateRecord: (recordId: string) => {
490
- stop: () => void;
491
- };
492
- action: (eventId: string, attrs: any, next?: (actionId: string) => void) => void;
493
- updateAction: (actionId: string, attrs: any) => void;
494
- };
495
-
496
- declare const ackeeUtil_attributes: typeof attributes;
497
- declare const ackeeUtil_create: typeof create;
498
- declare const ackeeUtil_detect: typeof detect;
499
- declare namespace ackeeUtil {
500
- export { ackeeUtil_attributes as attributes, ackeeUtil_create as create, ackeeUtil_detect as detect };
501
- }
502
-
503
- export { ackeeUtil as Ackee, Auth, SpotifyAPI, TwitterAPI };
429
+ export { Auth, SpotifyAPI, TwitterAPI };