codatta-frontier-sdk 0.1.5 → 0.1.8
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/index.cjs +1 -1
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("axios");/*! js-cookie v3.0.5 | MIT */function u(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)r[o]=t[o]}return r}var h={read:function(r){return r[0]==='"'&&(r=r.slice(1,-1)),r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(r){return encodeURIComponent(r).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function l(r,e){function t(s,i,n){if(!(typeof document>"u")){n=u({},e,n),typeof n.expires=="number"&&(n.expires=new Date(Date.now()+n.expires*864e5)),n.expires&&(n.expires=n.expires.toUTCString()),s=encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in n)n[c]&&(a+="; "+c,n[c]!==!0&&(a+="="+n[c].split(";")[0]));return document.cookie=s+"="+r.write(i,s)+a}}function o(s){if(!(typeof document>"u"||arguments.length&&!s)){for(var i=document.cookie?document.cookie.split("; "):[],n={},a=0;a<i.length;a++){var c=i[a].split("="),m=c.slice(1).join("=");try{var p=decodeURIComponent(c[0]);if(n[p]=r.read(m,p),s===p)break}catch{}}return s?n[s]:n}}return Object.create({set:t,get:o,remove:function(s,i){t(s,"",u({},i,{expires:-1}))},withAttributes:function(s){return l(this.converter,u({},this.attributes,s))},withConverter:function(s){return l(u({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(r)}})}var g=l(h,{path:"/"});class v{constructor(){this.request=d.create({timeout:3e4}),this.setupRequestInterceptor(),this.setupResponseInterceptor()}setupRequestInterceptor(){this.request.interceptors.request.use(e=>{var n;const t=navigator.userAgent.toLowerCase(),o=t.includes("codatta")||((n=location.hash)==null?void 0:n.toLowerCase().includes("codatta")),s=g.get("auth")||localStorage.getItem("auth"),i=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(t);return s&&(e.headers.token=s),e.headers.channel=o?"codatta-ios-app":"codatta-platform-website",e.headers.device=i?"mobile":"web",e})}setupResponseInterceptor(){this.request.interceptors.response.use(e=>{const t=e.data,o=Object.getOwnPropertyNames(t).includes("code"),s=Object.getOwnPropertyNames(t).includes("success");return o&&(t==null?void 0:t.code)!=="000000"?Promise.reject(new d.AxiosError(t==null?void 0:t.message,t==null?void 0:t.code,e.config,e.request,e)):s&&(t==null?void 0:t.success)!==!0?Promise.reject(new d.AxiosError(t==null?void 0:t.errorMessage,t==null?void 0:t.errorCode,e.config,e.request,e)):e},e=>{if(e.status===401){localStorage.removeItem("uid"),localStorage.removeItem("token"),localStorage.removeItem("auth");const t=new URL(window.location.href),o=t.pathname+t.search;window.location.href=`/account/signin?from=${encodeURIComponent(o)}`}return Promise.reject(e)})}async getTaskDetail(e){return(await this.request.post("/api/v2/frontier/task/detail",{task_id:e})).data}async submitTask(e,t){return(await this.request.post("/api/v2/frontier/task/submit",{task_id:e,data_submission:{data:t,task_id:e}})).data}async getTaskList(e){return(await this.request.post("/api/v2/frontier/task/list",e)).data}async getSubmissionList(e){return(await this.request.post("/api/v2/submission/list",e)).data}async getFrontierInfo(e){return(await this.request.get(`/api/v2/frontier/info?frontier_id=${e}`)).data}async getSubmissionDetail(e){return(await this.request.get("/api/v2/submission/user/detail",{params:{submission_id:e}})).data}async uploadFile(e,t){const o=new FormData;return o.append("file",e),(await this.request.post("/api/file/upload",o,{params:{content_type:e.type},onUploadProgress:t})).data}async getSpecTaskInfo(e){return(await this.request.get(`/v2/spec/task/info?task_id=${e}`)).data}async getSpecTaskInfos(e){return(await this.request.get(`/v2/spec/task/infos?task_ids=${e}`)).data}async submitSpecTask(e,t,o){return(await this.request.post("/v2/spec/task/submit",{task_id:e,status:o??2,content:t})).data}async getVerificationCode({account_type:e,email:t,opt:o}){return(await this.request.post("/v2/user/get_code",{account_type:e??"email",email:t??"",opt:o??"verify"})).data.data}async checkEmail({email:e,code:t,task_id:o}){return(await this.request.post("/v2/frontier/email/check",{email:e,code:t,task_id:o})).data.data}}var f=(r=>(r.TWITTER="x",r.TELEGRAM="telegram",r.DISCORD="discord",r.WEBSITE="website",r.DOC="doc",r))(f||{});exports.FrontierSDK=v;exports.MediaName=f;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("axios");/*! js-cookie v3.0.5 | MIT */function u(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)r[o]=t[o]}return r}var h={read:function(r){return r[0]==='"'&&(r=r.slice(1,-1)),r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(r){return encodeURIComponent(r).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function l(r,e){function t(s,i,n){if(!(typeof document>"u")){n=u({},e,n),typeof n.expires=="number"&&(n.expires=new Date(Date.now()+n.expires*864e5)),n.expires&&(n.expires=n.expires.toUTCString()),s=encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in n)n[c]&&(a+="; "+c,n[c]!==!0&&(a+="="+n[c].split(";")[0]));return document.cookie=s+"="+r.write(i,s)+a}}function o(s){if(!(typeof document>"u"||arguments.length&&!s)){for(var i=document.cookie?document.cookie.split("; "):[],n={},a=0;a<i.length;a++){var c=i[a].split("="),m=c.slice(1).join("=");try{var p=decodeURIComponent(c[0]);if(n[p]=r.read(m,p),s===p)break}catch{}}return s?n[s]:n}}return Object.create({set:t,get:o,remove:function(s,i){t(s,"",u({},i,{expires:-1}))},withAttributes:function(s){return l(this.converter,u({},this.attributes,s))},withConverter:function(s){return l(u({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(r)}})}var g=l(h,{path:"/"});class v{constructor(){this.request=d.create({timeout:3e4}),this.setupRequestInterceptor(),this.setupResponseInterceptor()}setupRequestInterceptor(){this.request.interceptors.request.use(e=>{var n;const t=navigator.userAgent.toLowerCase(),o=t.includes("codatta")||((n=location.hash)==null?void 0:n.toLowerCase().includes("codatta")),s=g.get("auth")||localStorage.getItem("auth"),i=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(t);return s&&(e.headers.token=s),e.headers.channel=o?"codatta-ios-app":"codatta-platform-website",e.headers.device=i?"mobile":"web",e})}setupResponseInterceptor(){this.request.interceptors.response.use(e=>{const t=e.data,o=Object.getOwnPropertyNames(t).includes("code"),s=Object.getOwnPropertyNames(t).includes("success");return o&&(t==null?void 0:t.code)!=="000000"?Promise.reject(new d.AxiosError(t==null?void 0:t.message,t==null?void 0:t.code,e.config,e.request,e)):s&&(t==null?void 0:t.success)!==!0?Promise.reject(new d.AxiosError(t==null?void 0:t.errorMessage,t==null?void 0:t.errorCode,e.config,e.request,e)):e},e=>{if(e.status===401){localStorage.removeItem("uid"),localStorage.removeItem("token"),localStorage.removeItem("auth");const t=new URL(window.location.href),o=t.pathname+t.search;window.location.href=`/account/signin?from=${encodeURIComponent(o)}`}return Promise.reject(e)})}async getTaskDetail(e){return(await this.request.post("/api/v2/frontier/task/detail",{task_id:e})).data}async submitTask(e,t){return(await this.request.post("/api/v2/frontier/task/submit",{task_id:e,data_submission:{data:t,task_id:e}})).data}async getTaskList(e){return(await this.request.post("/api/v2/frontier/task/list",e)).data}async getSubmissionList(e){return(await this.request.post("/api/v2/submission/list",e)).data}async getFrontierInfo(e){return(await this.request.get(`/api/v2/frontier/info?frontier_id=${e}`)).data}async getSubmissionDetail(e){return(await this.request.get("/api/v2/submission/user/detail",{params:{submission_id:e}})).data}async uploadFile(e,t){const o=new FormData;return o.append("file",e),(await this.request.post("/api/file/upload",o,{params:{content_type:e.type},onUploadProgress:t})).data}async getSpecTaskInfo(e){return(await this.request.get(`/api/v2/spec/task/info?task_id=${e}`)).data}async getSpecTaskInfos(e){return(await this.request.get(`/api/v2/spec/task/infos?task_ids=${e}`)).data}async submitSpecTask(e,t,o){return(await this.request.post("/api/v2/spec/task/submit",{task_id:e,status:o??2,content:t})).data}async getVerificationCode({account_type:e,email:t,opt:o}){return(await this.request.post("/api/v2/user/get_code",{account_type:e??"email",email:t??"",opt:o??"verify"})).data.data}async checkEmail({email:e,code:t,task_id:o}){return(await this.request.post("/api/v2/frontier/email/check",{email:e,code:t,task_id:o})).data.data}}var f=(r=>(r.TWITTER="x",r.TELEGRAM="telegram",r.DISCORD="discord",r.WEBSITE="website",r.DOC="doc",r))(f||{});exports.FrontierSDK=v;exports.MediaName=f;
|
package/dist/index.mjs
CHANGED
|
@@ -183,7 +183,7 @@ class y {
|
|
|
183
183
|
* @returns Task info including status (`1` = pending, `2` = completed) and optional content.
|
|
184
184
|
*/
|
|
185
185
|
async getSpecTaskInfo(e) {
|
|
186
|
-
return (await this.request.get(`/v2/spec/task/info?task_id=${e}`)).data;
|
|
186
|
+
return (await this.request.get(`/api/v2/spec/task/info?task_id=${e}`)).data;
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
189
|
* Fetch info for multiple spec tasks in a single request.
|
|
@@ -191,7 +191,7 @@ class y {
|
|
|
191
191
|
* @returns Array of task info objects.
|
|
192
192
|
*/
|
|
193
193
|
async getSpecTaskInfos(e) {
|
|
194
|
-
return (await this.request.get(`/v2/spec/task/infos?task_ids=${e}`)).data;
|
|
194
|
+
return (await this.request.get(`/api/v2/spec/task/infos?task_ids=${e}`)).data;
|
|
195
195
|
}
|
|
196
196
|
/**
|
|
197
197
|
* Submit or update a spec task.
|
|
@@ -201,7 +201,7 @@ class y {
|
|
|
201
201
|
* @returns Updated task info after submission.
|
|
202
202
|
*/
|
|
203
203
|
async submitSpecTask(e, t, o) {
|
|
204
|
-
return (await this.request.post("/v2/spec/task/submit", {
|
|
204
|
+
return (await this.request.post("/api/v2/spec/task/submit", {
|
|
205
205
|
task_id: e,
|
|
206
206
|
status: o ?? 2,
|
|
207
207
|
content: t
|
|
@@ -219,7 +219,7 @@ class y {
|
|
|
219
219
|
email: t,
|
|
220
220
|
opt: o
|
|
221
221
|
}) {
|
|
222
|
-
return (await this.request.post("/v2/user/get_code", {
|
|
222
|
+
return (await this.request.post("/api/v2/user/get_code", {
|
|
223
223
|
account_type: e ?? "email",
|
|
224
224
|
email: t ?? "",
|
|
225
225
|
opt: o ?? "verify"
|
|
@@ -237,7 +237,7 @@ class y {
|
|
|
237
237
|
code: t,
|
|
238
238
|
task_id: o
|
|
239
239
|
}) {
|
|
240
|
-
return (await this.request.post("/v2/frontier/email/check", {
|
|
240
|
+
return (await this.request.post("/api/v2/frontier/email/check", {
|
|
241
241
|
email: e,
|
|
242
242
|
code: t,
|
|
243
243
|
task_id: o
|