@zkid/zktls-js-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.js +13 -0
- package/dist/api/index.js.map +1 -0
- package/dist/classes/AttRequest.d.ts +24 -0
- package/dist/classes/AttRequest.js +64 -0
- package/dist/classes/AttRequest.js.map +1 -0
- package/dist/config/constants.d.ts +16 -0
- package/dist/config/constants.js +21 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/constants/index.d.ts +26 -0
- package/dist/constants/index.js +30 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/error.d.ts +49 -0
- package/dist/error.js +70 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -0
- package/dist/types/messages.d.ts +67 -0
- package/dist/types/messages.js +3 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/utils/httpRequest.d.ts +13 -0
- package/dist/utils/httpRequest.js +99 -0
- package/dist/utils/httpRequest.js.map +1 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +125 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/messages.d.ts +16 -0
- package/dist/utils/messages.js +40 -0
- package/dist/utils/messages.js.map +1 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAppQuote = getAppQuote;
|
|
4
|
+
const httpRequest_1 = require("../utils/httpRequest");
|
|
5
|
+
const constants_1 = require("../config/constants");
|
|
6
|
+
function getAppQuote(params) {
|
|
7
|
+
return (0, httpRequest_1.request)({
|
|
8
|
+
url: `${constants_1.BASEAPI}/public/app/quote`,
|
|
9
|
+
method: 'GET',
|
|
10
|
+
params
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;AAGA,kCAMC;AATD,sDAA+C;AAC/C,mDAA8C;AAE9C,SAAgB,WAAW,CAAC,MAAuB;IACjD,OAAO,IAAA,qBAAO,EAAuD;QACnE,GAAG,EAAE,GAAG,mBAAO,mBAAmB;QAClC,MAAM,EAAE,KAAK;QACb,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AttMode, BaseAttestationParams, AttConditions, ComputeMode } from '../types/index.d';
|
|
2
|
+
export declare class AttRequest {
|
|
3
|
+
appId: string;
|
|
4
|
+
attTemplateID: string;
|
|
5
|
+
userAddress: string;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
attMode?: AttMode;
|
|
8
|
+
attConditions?: AttConditions;
|
|
9
|
+
additionParams?: string;
|
|
10
|
+
requestid?: string;
|
|
11
|
+
backUrl?: string;
|
|
12
|
+
computeMode?: ComputeMode;
|
|
13
|
+
noProxy?: boolean;
|
|
14
|
+
allJsonResponseFlag?: 'true' | 'false';
|
|
15
|
+
constructor(baseAttestationParams: BaseAttestationParams);
|
|
16
|
+
setAdditionParams(additionParams: string): void;
|
|
17
|
+
setAttMode({ algorithmType, resultType }: AttMode): void;
|
|
18
|
+
setAttConditions(attConditions: AttConditions): void;
|
|
19
|
+
setBackUrl(url: string): void;
|
|
20
|
+
setComputeMode(computeMode: ComputeMode): void;
|
|
21
|
+
setNoProxy(noProxy: boolean): void;
|
|
22
|
+
setAllJsonResponseFlag(allJsonResponseFlag: string): void;
|
|
23
|
+
toJsonString(): string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttRequest = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
class AttRequest {
|
|
7
|
+
appId;
|
|
8
|
+
attTemplateID;
|
|
9
|
+
userAddress;
|
|
10
|
+
timestamp;
|
|
11
|
+
attMode;
|
|
12
|
+
attConditions;
|
|
13
|
+
additionParams;
|
|
14
|
+
requestid;
|
|
15
|
+
backUrl;
|
|
16
|
+
computeMode;
|
|
17
|
+
noProxy;
|
|
18
|
+
allJsonResponseFlag;
|
|
19
|
+
constructor(baseAttestationParams) {
|
|
20
|
+
const { appId, attTemplateID, userAddress } = baseAttestationParams;
|
|
21
|
+
this.appId = appId;
|
|
22
|
+
this.attTemplateID = attTemplateID;
|
|
23
|
+
this.userAddress = userAddress;
|
|
24
|
+
this.timestamp = +new Date();
|
|
25
|
+
this.attMode = {
|
|
26
|
+
algorithmType: 'proxytls',
|
|
27
|
+
resultType: 'plain'
|
|
28
|
+
}; // TODO
|
|
29
|
+
this.requestid = (0, uuid_1.v4)();
|
|
30
|
+
this.backUrl = '';
|
|
31
|
+
this.computeMode = 'normal';
|
|
32
|
+
this.noProxy = true;
|
|
33
|
+
this.allJsonResponseFlag = 'false';
|
|
34
|
+
}
|
|
35
|
+
setAdditionParams(additionParams) {
|
|
36
|
+
this.additionParams = additionParams;
|
|
37
|
+
}
|
|
38
|
+
setAttMode({ algorithmType, resultType = 'plain' }) {
|
|
39
|
+
this.attMode = {
|
|
40
|
+
algorithmType,
|
|
41
|
+
resultType
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
setAttConditions(attConditions) {
|
|
45
|
+
this.attConditions = attConditions;
|
|
46
|
+
}
|
|
47
|
+
setBackUrl(url) {
|
|
48
|
+
this.backUrl = url;
|
|
49
|
+
}
|
|
50
|
+
setComputeMode(computeMode) {
|
|
51
|
+
this.computeMode = computeMode;
|
|
52
|
+
}
|
|
53
|
+
setNoProxy(noProxy) {
|
|
54
|
+
this.noProxy = noProxy;
|
|
55
|
+
}
|
|
56
|
+
setAllJsonResponseFlag(allJsonResponseFlag) {
|
|
57
|
+
this.allJsonResponseFlag = allJsonResponseFlag === 'true' ? 'true' : 'false';
|
|
58
|
+
}
|
|
59
|
+
toJsonString() {
|
|
60
|
+
return JSON.stringify((0, utils_1.getInstanceProperties)(this));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.AttRequest = AttRequest;
|
|
64
|
+
//# sourceMappingURL=AttRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttRequest.js","sourceRoot":"","sources":["../../src/classes/AttRequest.ts"],"names":[],"mappings":";;;AACA,oCAAiD;AACjD,+BAAoC;AAEpC,MAAa,UAAU;IACrB,KAAK,CAAS;IACd,aAAa,CAAS;IACtB,WAAW,CAAS;IACpB,SAAS,CAAS;IAClB,OAAO,CAAW;IAClB,aAAa,CAAiB;IAC9B,cAAc,CAAU;IACxB,SAAS,CAAU;IACnB,OAAO,CAAU;IACjB,WAAW,CAAe;IAC1B,OAAO,CAAW;IAClB,mBAAmB,CAAoB;IAEvC,YAAY,qBAA4C;QACtD,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,qBAAqB,CAAC;QACpE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG;YACb,aAAa,EAAE,UAAU;YACzB,UAAU,EAAE,OAAO;SACpB,CAAC,CAAC,OAAO;QACV,IAAI,CAAC,SAAS,GAAG,IAAA,SAAM,GAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC;IACrC,CAAC;IACD,iBAAiB,CAAC,cAAsB;QACtC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IACD,UAAU,CAAC,EAAE,aAAa,EAAE,UAAU,GAAG,OAAO,EAAW;QACzD,IAAI,CAAC,OAAO,GAAG;YACb,aAAa;YACb,UAAU;SACX,CAAC;IACJ,CAAC;IACD,gBAAgB,CAAC,aAA4B;QAC3C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IACD,UAAU,CAAC,GAAW;QACpB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;IACrB,CAAC;IACD,cAAc,CAAC,WAAwB;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IACD,UAAU,CAAC,OAAgB;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD,sBAAsB,CAAC,mBAA2B;QAChD,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/E,CAAC;IACD,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,IAAA,6BAAqB,EAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;CACF;AAzDD,gCAyDC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const PADOEXTENSIONID = "oeiomhmbaapihbilkfkhmlajkeegnjhe";
|
|
2
|
+
export declare const ONESECOND = 1000;
|
|
3
|
+
export declare const ONEMINUTE: number;
|
|
4
|
+
export declare const ATTESTATIONPOLLINGTIME: number;
|
|
5
|
+
export declare const ATTESTATIONPOLLINGTIMEOUT: number;
|
|
6
|
+
export declare const ATTESTATIONPOLLINGTIMEOUTMOBILE: number;
|
|
7
|
+
export declare const PADOADDRESSMAP: {
|
|
8
|
+
development: string;
|
|
9
|
+
production: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const ENV = "production";
|
|
12
|
+
export declare const BASEAPIMAP: {
|
|
13
|
+
development: string;
|
|
14
|
+
production: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const BASEAPI: string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BASEAPI = exports.BASEAPIMAP = exports.ENV = exports.PADOADDRESSMAP = exports.ATTESTATIONPOLLINGTIMEOUTMOBILE = exports.ATTESTATIONPOLLINGTIMEOUT = exports.ATTESTATIONPOLLINGTIME = exports.ONEMINUTE = exports.ONESECOND = exports.PADOEXTENSIONID = void 0;
|
|
4
|
+
exports.PADOEXTENSIONID = "oeiomhmbaapihbilkfkhmlajkeegnjhe";
|
|
5
|
+
exports.ONESECOND = 1000;
|
|
6
|
+
exports.ONEMINUTE = 60 * exports.ONESECOND;
|
|
7
|
+
exports.ATTESTATIONPOLLINGTIME = 1 * exports.ONESECOND;
|
|
8
|
+
exports.ATTESTATIONPOLLINGTIMEOUT = 2 * exports.ONEMINUTE;
|
|
9
|
+
exports.ATTESTATIONPOLLINGTIMEOUTMOBILE = 5 * exports.ONEMINUTE;
|
|
10
|
+
exports.PADOADDRESSMAP = {
|
|
11
|
+
development: '0xe02bd7a6c8aa401189aebb5bad755c2610940a73',
|
|
12
|
+
production: '0xDB736B13E2f522dBE18B2015d0291E4b193D8eF6',
|
|
13
|
+
};
|
|
14
|
+
exports.ENV = 'production';
|
|
15
|
+
exports.BASEAPIMAP = {
|
|
16
|
+
development: 'https://api-dev.padolabs.org',
|
|
17
|
+
production: 'https://api.padolabs.org',
|
|
18
|
+
// production: 'https://api.padolabs.org',
|
|
19
|
+
};
|
|
20
|
+
exports.BASEAPI = exports.BASEAPIMAP[exports.ENV];
|
|
21
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/config/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,kCAAkC,CAAC;AAErD,QAAA,SAAS,GAAG,IAAI,CAAC;AACjB,QAAA,SAAS,GAAG,EAAE,GAAG,iBAAS,CAAC;AAC3B,QAAA,sBAAsB,GAAG,CAAC,GAAG,iBAAS,CAAC;AACvC,QAAA,yBAAyB,GAAG,CAAC,GAAG,iBAAS,CAAC;AAC1C,QAAA,+BAA+B,GAAG,CAAC,GAAG,iBAAS,CAAC;AAEhD,QAAA,cAAc,GAAG;IAC5B,WAAW,EAAE,4CAA4C;IACzD,UAAU,EAAE,4CAA4C;CACzD,CAAC;AAEW,QAAA,GAAG,GAAG,YAAY,CAAC;AACnB,QAAA,UAAU,GAAG;IACxB,WAAW,EAAE,8BAA8B;IAC3C,UAAU,EAAE,0BAA0B;IACtC,0CAA0C;CAC3C,CAAC;AACW,QAAA,OAAO,GAAG,kBAAU,CAAC,WAAG,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const EXTENSION_METHODS: {
|
|
2
|
+
readonly INIT: "init";
|
|
3
|
+
readonly CHECK_DATA_SOURCE: "checkDataSource";
|
|
4
|
+
readonly CHECK_DATA_SOURCE_RES: "checkDataSourceRes";
|
|
5
|
+
readonly CLOSE_DATA_SOURCE: "closeDataSource";
|
|
6
|
+
readonly VISITED_PAGE_PATHS: "visitedPagePaths";
|
|
7
|
+
readonly FAVICON_URL_CHANGED: "faviconUrlChanged";
|
|
8
|
+
readonly INIT_ATT: "initAttestation";
|
|
9
|
+
readonly START_ATT: "startAttestation";
|
|
10
|
+
readonly GET_ATT_RESULT: "getAttestationResult";
|
|
11
|
+
readonly GET_ATT_RESULT_TIMEOUT: "getAttestationResultTimeout";
|
|
12
|
+
readonly INIT_ATT_RES: "initAttestationRes";
|
|
13
|
+
readonly GET_ATT_RES: "getAttestationRes";
|
|
14
|
+
readonly START_ATT_RES: "startAttestationRes";
|
|
15
|
+
};
|
|
16
|
+
export type ExtensionMethod = (typeof EXTENSION_METHODS)[keyof typeof EXTENSION_METHODS];
|
|
17
|
+
export declare const EXTENSION_TARGET: {
|
|
18
|
+
readonly EXTENSION: "hashKeyExtension";
|
|
19
|
+
readonly DEVCONSOLE: "devconsole";
|
|
20
|
+
readonly SDK: "sdk";
|
|
21
|
+
readonly BACKGROUND: "background";
|
|
22
|
+
readonly CONTENT: "content";
|
|
23
|
+
readonly POPUP: "popup";
|
|
24
|
+
readonly SIDEPANEL: "sidepanel";
|
|
25
|
+
};
|
|
26
|
+
export type ExtensionTarget = (typeof EXTENSION_TARGET)[keyof typeof EXTENSION_TARGET];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EXTENSION_TARGET = exports.EXTENSION_METHODS = void 0;
|
|
4
|
+
exports.EXTENSION_METHODS = {
|
|
5
|
+
INIT: "init",
|
|
6
|
+
CHECK_DATA_SOURCE: "checkDataSource",
|
|
7
|
+
CHECK_DATA_SOURCE_RES: "checkDataSourceRes",
|
|
8
|
+
CLOSE_DATA_SOURCE: "closeDataSource",
|
|
9
|
+
VISITED_PAGE_PATHS: "visitedPagePaths",
|
|
10
|
+
FAVICON_URL_CHANGED: "faviconUrlChanged",
|
|
11
|
+
// attestation — outbound (SDK → Extension)
|
|
12
|
+
INIT_ATT: "initAttestation",
|
|
13
|
+
START_ATT: "startAttestation",
|
|
14
|
+
GET_ATT_RESULT: "getAttestationResult",
|
|
15
|
+
GET_ATT_RESULT_TIMEOUT: "getAttestationResultTimeout",
|
|
16
|
+
// attestation — inbound (Extension → SDK)
|
|
17
|
+
INIT_ATT_RES: "initAttestationRes",
|
|
18
|
+
GET_ATT_RES: "getAttestationRes",
|
|
19
|
+
START_ATT_RES: "startAttestationRes",
|
|
20
|
+
};
|
|
21
|
+
exports.EXTENSION_TARGET = {
|
|
22
|
+
EXTENSION: "hashKeyExtension",
|
|
23
|
+
DEVCONSOLE: "devconsole",
|
|
24
|
+
SDK: "sdk",
|
|
25
|
+
BACKGROUND: "background",
|
|
26
|
+
CONTENT: "content",
|
|
27
|
+
POPUP: "popup",
|
|
28
|
+
SIDEPANEL: "sidepanel",
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG;IAC7B,IAAI,EAAE,MAAM;IAEZ,iBAAiB,EAAE,iBAAiB;IACpC,qBAAqB,EAAE,oBAAoB;IAC3C,iBAAiB,EAAE,iBAAiB;IAEpC,kBAAkB,EAAE,kBAAkB;IACtC,mBAAmB,EAAE,mBAAmB;IAExC,2CAA2C;IAC3C,QAAQ,EAAE,iBAAiB;IAC3B,SAAS,EAAE,kBAAkB;IAC7B,cAAc,EAAE,sBAAsB;IACtC,sBAAsB,EAAE,6BAA6B;IAErD,0CAA0C;IAC1C,YAAY,EAAE,oBAAoB;IAClC,WAAW,EAAE,mBAAmB;IAChC,aAAa,EAAE,qBAAqB;CAC9B,CAAC;AAIE,QAAA,gBAAgB,GAAG;IAC5B,SAAS,EAAE,kBAAkB;IAC7B,UAAU,EAAE,YAAY;IACxB,GAAG,EAAE,KAAK;IAEV,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;CAChB,CAAC"}
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type AttestationErrorCode = '00001' | '00002' | '00003' | '00004' | '00005' | '00006' | '00009' | '00010' | '00101' | '00102' | '00103' | '00104' | '01000' | '10001' | '10002' | '10003' | '10004' | '20001' | '20002' | '20003' | '20004' | '20005' | '30001' | '30002' | '30003' | '30004' | '40001' | '40002' | '50002' | '50003' | '50004' | '50005' | '50006' | '50007' | '50008' | '50009' | '50010' | '50011' | '99999' | '-1200010' | '-1002001' | '-1002002' | '-1002003' | '-1002004' | '-1002005';
|
|
2
|
+
export type OnChainErrorCode = '00007' | '00008';
|
|
3
|
+
export type ErrorCode = AttestationErrorCode | OnChainErrorCode;
|
|
4
|
+
export declare const ErrorCodeMAP: {
|
|
5
|
+
'00000': string;
|
|
6
|
+
'00001': string;
|
|
7
|
+
'00002': string;
|
|
8
|
+
'00003': string;
|
|
9
|
+
'00004': string;
|
|
10
|
+
'00005': string;
|
|
11
|
+
'00012': string;
|
|
12
|
+
'00013': string;
|
|
13
|
+
'00014': string;
|
|
14
|
+
'00104': string;
|
|
15
|
+
'01000': string;
|
|
16
|
+
'10001': string;
|
|
17
|
+
'10002': string;
|
|
18
|
+
'10003': string;
|
|
19
|
+
'10004': string;
|
|
20
|
+
'20001': string;
|
|
21
|
+
'20003': string;
|
|
22
|
+
'20005': string;
|
|
23
|
+
'30001': string;
|
|
24
|
+
'30002': string;
|
|
25
|
+
'30004': string;
|
|
26
|
+
'40002': string;
|
|
27
|
+
'50001': string;
|
|
28
|
+
'50003': string;
|
|
29
|
+
'50004': string;
|
|
30
|
+
'50006': string;
|
|
31
|
+
'50007': string;
|
|
32
|
+
'50008': string;
|
|
33
|
+
'50009': string;
|
|
34
|
+
'50010': string;
|
|
35
|
+
'50011': string;
|
|
36
|
+
'99999': string;
|
|
37
|
+
'-1200010': string;
|
|
38
|
+
'-1002001': string;
|
|
39
|
+
'-1002002': string;
|
|
40
|
+
'-1002003': string;
|
|
41
|
+
'-1002004': string;
|
|
42
|
+
'-1002005': string;
|
|
43
|
+
};
|
|
44
|
+
export declare class ZkAttestationError {
|
|
45
|
+
code: ErrorCode;
|
|
46
|
+
message: string;
|
|
47
|
+
data?: any;
|
|
48
|
+
constructor(code: ErrorCode, message?: string, data?: any);
|
|
49
|
+
}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZkAttestationError = exports.ErrorCodeMAP = void 0;
|
|
4
|
+
exports.ErrorCodeMAP = {
|
|
5
|
+
'00000': 'Operation too frequent. Please try again later.',
|
|
6
|
+
'00001': 'Algorithm startup exception.',
|
|
7
|
+
'00002': 'The verification process timed out.',
|
|
8
|
+
'00003': 'A verification process is in progress. Please try again later.',
|
|
9
|
+
'00004': 'The user closes or cancels the verification process.',
|
|
10
|
+
'00005': 'Wrong SDK parameters.',
|
|
11
|
+
// '00006':'No ZKID extension version 0.3.15 or above was detected as installed.',
|
|
12
|
+
// '00007':'Insufficient wallet balance.',
|
|
13
|
+
// '00008':'Failed to submit the proof on-chain. Or other errors in the Wallet operations.',
|
|
14
|
+
// '00009':'Your dApp is not registered. Please contact the ZKID team.',
|
|
15
|
+
// '00010':'Verification failed. Please try again later.',
|
|
16
|
+
// '00011':'Launch failed: unstable connection.',
|
|
17
|
+
'00012': 'Invalid Template ID.',
|
|
18
|
+
'00013': 'Target data missing. Please check whether the data json path in the request URL’s response aligns with your template.',
|
|
19
|
+
'00014': 'The verification process timed out.',
|
|
20
|
+
// "00101":'Insufficient assets in your Trading Account. Please confirm and try again later.',
|
|
21
|
+
// '00102':'Attestation requirements not met. Insufficient assets balance in Binance Spot Account.',
|
|
22
|
+
// "00103": 'This account may have already been bound to a wallet address, or your wallet address may already have a zkAttestation with another Binance account.',
|
|
23
|
+
'00104': 'Not met the verification requirements.',
|
|
24
|
+
'01000': 'Attestation timeout.',
|
|
25
|
+
'10001': 'Unstable internet connection. Please try again.',
|
|
26
|
+
'10002': 'Unstable internet connection. Please try again.',
|
|
27
|
+
'10003': 'Unstable internet connection. Please try again.',
|
|
28
|
+
'10004': 'Unstable internet connection. Please try again.',
|
|
29
|
+
'20001': 'An internal error occurred.',
|
|
30
|
+
// '20002':"Something went wrong. Please try again later.",
|
|
31
|
+
'20003': 'Invalid algorithm parameters.',
|
|
32
|
+
// '20004': "Something went wrong. Please try again later.",
|
|
33
|
+
'20005': "Can't complete the attestation due to some workflow error. Please try again later.",
|
|
34
|
+
'30001': 'Response error. Please try again.',
|
|
35
|
+
'30002': 'Response check error.',
|
|
36
|
+
// '30003': "Can't complete the attestation flow due to response error. Please try again later.",
|
|
37
|
+
'30004': 'Response parse error.',
|
|
38
|
+
// '40001':"Something went wrong. Please try again later.",
|
|
39
|
+
'40002': 'SSLCertificateError',
|
|
40
|
+
'50001': 'An internal error occurred.',
|
|
41
|
+
// '50002': "Something went wrong. Please try again later.",
|
|
42
|
+
'50003': 'The client encountered an unexpected error.',
|
|
43
|
+
'50004': 'The client not started. Please try again.',
|
|
44
|
+
// '50005':"Something went wrong. Please try again later.",
|
|
45
|
+
'50006': 'The algorithm server not started. Please try again.',
|
|
46
|
+
'50007': 'Algorithm execution issues.',
|
|
47
|
+
'50008': 'Abnormal execution results.',
|
|
48
|
+
'50009': 'Algorithm service timed out.',
|
|
49
|
+
'50010': 'Compatibility issues during algorithm execution.',
|
|
50
|
+
'50011': 'Unsupported TLS version.',
|
|
51
|
+
'99999': 'Undefined error.',
|
|
52
|
+
'-1200010': 'Invalid message.',
|
|
53
|
+
'-1002001': 'Invalid App ID.',
|
|
54
|
+
'-1002002': 'Invalid App Secret.',
|
|
55
|
+
'-1002003': 'Trial quota exhausted.',
|
|
56
|
+
'-1002004': 'Subscription expired.',
|
|
57
|
+
'-1002005': 'Quota exhausted.'
|
|
58
|
+
};
|
|
59
|
+
class ZkAttestationError {
|
|
60
|
+
code;
|
|
61
|
+
message;
|
|
62
|
+
data;
|
|
63
|
+
constructor(code, message, data) {
|
|
64
|
+
this.message = message || exports.ErrorCodeMAP[code];
|
|
65
|
+
this.code = code;
|
|
66
|
+
this.data = data;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.ZkAttestationError = ZkAttestationError;
|
|
70
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAmDa,QAAA,YAAY,GAAG;IAC1B,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,8BAA8B;IACvC,OAAO,EAAE,qCAAqC;IAC9C,OAAO,EAAE,gEAAgE;IACzE,OAAO,EAAE,sDAAsD;IAC/D,OAAO,EAAE,uBAAuB;IAChC,kFAAkF;IAClF,0CAA0C;IAC1C,4FAA4F;IAC5F,wEAAwE;IACxE,0DAA0D;IAC1D,iDAAiD;IACjD,OAAO,EAAE,sBAAsB;IAC/B,OAAO,EACL,uHAAuH;IACzH,OAAO,EAAE,qCAAqC;IAC9C,8FAA8F;IAE9F,oGAAoG;IACpG,mKAAmK;IACnK,OAAO,EAAE,wCAAwC;IAEjD,OAAO,EAAE,sBAAsB;IAE/B,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,6BAA6B;IACtC,2DAA2D;IAC3D,OAAO,EAAE,+BAA+B;IACxC,4DAA4D;IAC5D,OAAO,EAAE,oFAAoF;IAC7F,OAAO,EAAE,mCAAmC;IAC5C,OAAO,EAAE,uBAAuB;IAChC,iGAAiG;IACjG,OAAO,EAAE,uBAAuB;IAChC,2DAA2D;IAC3D,OAAO,EAAE,qBAAqB;IAC9B,OAAO,EAAE,6BAA6B;IACtC,4DAA4D;IAC5D,OAAO,EAAE,6CAA6C;IACtD,OAAO,EAAE,2CAA2C;IACpD,2DAA2D;IAC3D,OAAO,EAAE,qDAAqD;IAC9D,OAAO,EAAE,6BAA6B;IACtC,OAAO,EAAE,6BAA6B;IACtC,OAAO,EAAE,8BAA8B;IACvC,OAAO,EAAE,kDAAkD;IAC3D,OAAO,EAAE,0BAA0B;IACnC,OAAO,EAAE,kBAAkB;IAC3B,UAAU,EAAE,kBAAkB;IAC9B,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,qBAAqB;IACjC,UAAU,EAAE,wBAAwB;IACpC,UAAU,EAAE,uBAAuB;IACnC,UAAU,EAAE,kBAAkB;CAC/B,CAAC;AACF,MAAa,kBAAkB;IAC7B,IAAI,CAAY;IAChB,OAAO,CAAS;IAChB,IAAI,CAAO;IACX,YAAY,IAAe,EAAE,OAAgB,EAAE,IAAU;QACvD,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,oBAAY,CAAC,IAAiC,CAAC,CAAC;QAC1E,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AATD,gDASC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Attestation, SignedAttRequest, InitOptions } from './types/index.d';
|
|
2
|
+
import { AttRequest } from './classes/AttRequest';
|
|
3
|
+
declare class PrimusZKTLS {
|
|
4
|
+
private _padoAddress;
|
|
5
|
+
isInstalled?: boolean;
|
|
6
|
+
isInitialized: boolean;
|
|
7
|
+
padoExtensionVersion: string;
|
|
8
|
+
appId: string;
|
|
9
|
+
appSecret?: string;
|
|
10
|
+
options: InitOptions;
|
|
11
|
+
extendedData: Record<string, any>;
|
|
12
|
+
latestRunningMobileRequest?: string;
|
|
13
|
+
allJsonResponseFlag?: 'true' | 'false';
|
|
14
|
+
_allJsonResponse: any;
|
|
15
|
+
constructor();
|
|
16
|
+
init(appId: string, appSecret?: string, options?: InitOptions): Promise<string | boolean>;
|
|
17
|
+
generateRequestParams(attTemplateID: string, userAddress?: string): AttRequest;
|
|
18
|
+
sign(signParams: string): Promise<string>;
|
|
19
|
+
startAttestation(attestationParamsStr: string): Promise<Attestation>;
|
|
20
|
+
startAttestationMobile(attestationParamsStr: string): Promise<Attestation>;
|
|
21
|
+
GetAttestationMobileUrl(attestationParamsStr: string): string;
|
|
22
|
+
verifyAttestation(attestation: Attestation): boolean;
|
|
23
|
+
getExtendedData(requestid: string): any;
|
|
24
|
+
/**
|
|
25
|
+
* Check app quote and perform business logic based on the result
|
|
26
|
+
* @private
|
|
27
|
+
* @throws {ZkAttestationError} Only throws business logic errors, network errors are caught and ignored
|
|
28
|
+
*/
|
|
29
|
+
private _checkAppQuote;
|
|
30
|
+
_verifyAttestationParams(attestationParams: SignedAttRequest): boolean;
|
|
31
|
+
getAllJsonResponse(requestid: string): string | undefined;
|
|
32
|
+
}
|
|
33
|
+
export { PrimusZKTLS, AttRequest };
|