@worldcoin/idkit-core 2.0.2 → 4.0.0-dev.777cdbe

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/build/index.js DELETED
@@ -1,266 +0,0 @@
1
- import {
2
- encodeAction,
3
- generateSignal
4
- } from "./chunk-HZ2SQA5V.js";
5
-
6
- // src/types/bridge.ts
7
- var AppErrorCodes = /* @__PURE__ */ ((AppErrorCodes2) => {
8
- AppErrorCodes2["ConnectionFailed"] = "connection_failed";
9
- AppErrorCodes2["VerificationRejected"] = "verification_rejected";
10
- AppErrorCodes2["MaxVerificationsReached"] = "max_verifications_reached";
11
- AppErrorCodes2["CredentialUnavailable"] = "credential_unavailable";
12
- AppErrorCodes2["MalformedRequest"] = "malformed_request";
13
- AppErrorCodes2["InvalidNetwork"] = "invalid_network";
14
- AppErrorCodes2["InclusionProofFailed"] = "inclusion_proof_failed";
15
- AppErrorCodes2["InclusionProofPending"] = "inclusion_proof_pending";
16
- AppErrorCodes2["UnexpectedResponse"] = "unexpected_response";
17
- AppErrorCodes2["FailedByHostApp"] = "failed_by_host_app";
18
- AppErrorCodes2["GenericError"] = "generic_error";
19
- return AppErrorCodes2;
20
- })(AppErrorCodes || {});
21
- var VerificationState = /* @__PURE__ */ ((VerificationState2) => {
22
- VerificationState2["PreparingClient"] = "loading_widget";
23
- VerificationState2["WaitingForConnection"] = "awaiting_connection";
24
- VerificationState2["WaitingForApp"] = "awaiting_app";
25
- VerificationState2["Confirmed"] = "confirmed";
26
- VerificationState2["Failed"] = "failed";
27
- return VerificationState2;
28
- })(VerificationState || {});
29
-
30
- // src/types/config.ts
31
- var CredentialType = /* @__PURE__ */ ((CredentialType2) => {
32
- CredentialType2["Orb"] = "orb";
33
- CredentialType2["SecureDocument"] = "secure_document";
34
- CredentialType2["Document"] = "document";
35
- CredentialType2["Device"] = "device";
36
- return CredentialType2;
37
- })(CredentialType || {});
38
- var VerificationLevel = /* @__PURE__ */ ((VerificationLevel2) => {
39
- VerificationLevel2["Orb"] = "orb";
40
- VerificationLevel2["SecureDocument"] = "secure_document";
41
- VerificationLevel2["Document"] = "document";
42
- VerificationLevel2["Device"] = "device";
43
- return VerificationLevel2;
44
- })(VerificationLevel || {});
45
-
46
- // src/bridge.ts
47
- import { create } from "zustand";
48
-
49
- // src/lib/validation.ts
50
- function validate_bridge_url(bridge_url, is_staging) {
51
- try {
52
- new URL(bridge_url);
53
- } catch (e) {
54
- return { valid: false, errors: ["Failed to parse Bridge URL."] };
55
- }
56
- const test_url = new URL(bridge_url);
57
- const errors = [];
58
- if (is_staging && ["localhost", "127.0.0.1"].includes(test_url.hostname)) {
59
- console.log("Using staging app_id with localhost bridge_url. Skipping validation.");
60
- return { valid: true };
61
- }
62
- if (test_url.protocol !== "https:") {
63
- errors.push("Bridge URL must use HTTPS.");
64
- }
65
- if (test_url.port) {
66
- errors.push("Bridge URL must use the default port (443).");
67
- }
68
- if (test_url.pathname !== "/") {
69
- errors.push("Bridge URL must not have a path.");
70
- }
71
- if (test_url.search) {
72
- errors.push("Bridge URL must not have query parameters.");
73
- }
74
- if (test_url.hash) {
75
- errors.push("Bridge URL must not have a fragment.");
76
- }
77
- if (!test_url.hostname.endsWith(".worldcoin.org") && !test_url.hostname.endsWith(".toolsforhumanity.com")) {
78
- console.warn(
79
- "Bridge URL should be a subdomain of worldcoin.org or toolsforhumanity.com. The user's identity wallet may refuse to connect. This is a temporary measure and may be removed in the future."
80
- );
81
- }
82
- if (errors.length) {
83
- return { valid: false, errors };
84
- }
85
- return { valid: true };
86
- }
87
-
88
- // src/lib/utils.ts
89
- import { Buffer } from "buffer/index.js";
90
- var DEFAULT_VERIFICATION_LEVEL = "orb" /* Orb */;
91
- var buffer_encode = (buffer) => {
92
- return Buffer.from(buffer).toString("base64");
93
- };
94
- var buffer_decode = (encoded) => {
95
- return Buffer.from(encoded, "base64");
96
- };
97
- var verification_level_to_credential_types = (verification_level) => {
98
- switch (verification_level) {
99
- case "device" /* Device */:
100
- return ["orb" /* Orb */, "device" /* Device */];
101
- case "document" /* Document */:
102
- return ["document" /* Document */, "secure_document" /* SecureDocument */, "orb" /* Orb */];
103
- case "secure_document" /* SecureDocument */:
104
- return ["secure_document" /* SecureDocument */, "orb" /* Orb */];
105
- case "orb" /* Orb */:
106
- return ["orb" /* Orb */];
107
- default:
108
- throw new Error(`Unknown verification level: ${verification_level}`);
109
- }
110
- };
111
- var credential_type_to_verification_level = (credential_type) => {
112
- switch (credential_type) {
113
- case "orb" /* Orb */:
114
- return "orb" /* Orb */;
115
- case "secure_document" /* SecureDocument */:
116
- return "secure_document" /* SecureDocument */;
117
- case "document" /* Document */:
118
- return "document" /* Document */;
119
- case "device" /* Device */:
120
- return "device" /* Device */;
121
- default:
122
- throw new Error(`Unknown credential_type: ${credential_type}`);
123
- }
124
- };
125
-
126
- // src/lib/crypto.ts
127
- var encoder = new TextEncoder();
128
- var decoder = new TextDecoder();
129
- var generateKey = async () => {
130
- return {
131
- iv: window.crypto.getRandomValues(new Uint8Array(12)),
132
- key: await window.crypto.subtle.generateKey({ name: "AES-GCM", length: 256 }, true, ["encrypt", "decrypt"])
133
- };
134
- };
135
- var exportKey = async (key) => {
136
- return buffer_encode(await window.crypto.subtle.exportKey("raw", key));
137
- };
138
- var encryptRequest = async (key, iv, request) => {
139
- return {
140
- iv: buffer_encode(iv),
141
- payload: buffer_encode(
142
- await window.crypto.subtle.encrypt({ name: "AES-GCM", iv }, key, encoder.encode(request))
143
- )
144
- };
145
- };
146
- var decryptResponse = async (key, iv, payload) => {
147
- return decoder.decode(await window.crypto.subtle.decrypt({ name: "AES-GCM", iv }, key, buffer_decode(payload)));
148
- };
149
-
150
- // src/bridge.ts
151
- var DEFAULT_BRIDGE_URL = "https://bridge.worldcoin.org";
152
- var useWorldBridgeStore = create((set, get) => ({
153
- iv: null,
154
- key: null,
155
- result: null,
156
- errorCode: null,
157
- requestId: null,
158
- connectorURI: null,
159
- bridge_url: DEFAULT_BRIDGE_URL,
160
- verificationState: "loading_widget" /* PreparingClient */,
161
- createClient: async ({ bridge_url, app_id, verification_level, action_description, action, signal, partner }) => {
162
- const { key, iv } = await generateKey();
163
- if (bridge_url) {
164
- const validation = validate_bridge_url(bridge_url, app_id.includes("staging"));
165
- if (!validation.valid) {
166
- console.error(validation.errors.join("\n"));
167
- set({ verificationState: "failed" /* Failed */ });
168
- throw new Error("Invalid bridge_url. Please check the console for more details.");
169
- }
170
- }
171
- const res = await fetch(new URL("/request", bridge_url ?? DEFAULT_BRIDGE_URL), {
172
- method: "POST",
173
- headers: { "Content-Type": "application/json" },
174
- body: JSON.stringify(
175
- await encryptRequest(
176
- key,
177
- iv,
178
- JSON.stringify({
179
- app_id,
180
- action_description,
181
- action: encodeAction(action),
182
- signal: generateSignal(signal).digest,
183
- credential_types: verification_level_to_credential_types(
184
- verification_level ?? DEFAULT_VERIFICATION_LEVEL
185
- ),
186
- verification_level: verification_level ?? DEFAULT_VERIFICATION_LEVEL
187
- })
188
- )
189
- )
190
- });
191
- if (!res.ok) {
192
- set({ verificationState: "failed" /* Failed */ });
193
- throw new Error("Failed to create client");
194
- }
195
- const { request_id } = await res.json();
196
- set({
197
- iv,
198
- key,
199
- requestId: request_id,
200
- bridge_url: bridge_url ?? DEFAULT_BRIDGE_URL,
201
- verificationState: "awaiting_connection" /* WaitingForConnection */,
202
- connectorURI: `https://world.org/verify?t=wld&i=${request_id}&k=${encodeURIComponent(
203
- await exportKey(key)
204
- )}${bridge_url && bridge_url !== DEFAULT_BRIDGE_URL ? `&b=${encodeURIComponent(bridge_url)}` : ""}${partner ? `&partner=${encodeURIComponent(true)}` : ""}`
205
- });
206
- },
207
- pollForUpdates: async () => {
208
- const key = get().key;
209
- if (!key) throw new Error("No keypair found. Please call `createClient` first.");
210
- const res = await fetch(new URL(`/response/${get().requestId}`, get().bridge_url));
211
- if (!res.ok) {
212
- return set({
213
- errorCode: "connection_failed" /* ConnectionFailed */,
214
- verificationState: "failed" /* Failed */
215
- });
216
- }
217
- const { response, status } = await res.json();
218
- if (status != "completed" /* Completed */) {
219
- return set({
220
- verificationState: status == "retrieved" /* Retrieved */ ? "awaiting_app" /* WaitingForApp */ : "awaiting_connection" /* WaitingForConnection */
221
- });
222
- }
223
- let result = JSON.parse(
224
- await decryptResponse(key, buffer_decode(response.iv), response.payload)
225
- );
226
- if ("error_code" in result) {
227
- return set({
228
- errorCode: result.error_code,
229
- verificationState: "failed" /* Failed */
230
- });
231
- }
232
- if ("credential_type" in result) {
233
- result = {
234
- verification_level: credential_type_to_verification_level(result.credential_type),
235
- ...result
236
- };
237
- }
238
- set({
239
- result,
240
- key: null,
241
- requestId: null,
242
- connectorURI: null,
243
- verificationState: "confirmed" /* Confirmed */
244
- });
245
- },
246
- reset: () => {
247
- set({
248
- iv: null,
249
- key: null,
250
- result: null,
251
- errorCode: null,
252
- requestId: null,
253
- connectorURI: null,
254
- verificationState: "loading_widget" /* PreparingClient */
255
- });
256
- }
257
- }));
258
- export {
259
- AppErrorCodes,
260
- CredentialType,
261
- DEFAULT_VERIFICATION_LEVEL,
262
- VerificationLevel,
263
- VerificationState,
264
- useWorldBridgeStore,
265
- verification_level_to_credential_types
266
- };
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/lib/backend.ts
21
- var backend_exports = {};
22
- __export(backend_exports, {
23
- verifyCloudProof: () => verifyCloudProof
24
- });
25
- module.exports = __toCommonJS(backend_exports);
26
-
27
- // src/lib/hashing.ts
28
- var import_buffer = require("buffer/index.js");
29
- var import_ox = require("ox");
30
- function hashToField(input) {
31
- if (import_ox.Bytes.validate(input) || import_ox.Hex.validate(input)) return hashEncodedBytes(input);
32
- return hashString(input);
33
- }
34
- function hashString(input) {
35
- const bytesInput = import_buffer.Buffer.from(input);
36
- return hashEncodedBytes(bytesInput);
37
- }
38
- function hashEncodedBytes(input) {
39
- const hash = BigInt(import_ox.Hash.keccak256(input, { as: "Hex" })) >> 8n;
40
- const rawDigest = hash.toString(16);
41
- return { hash, digest: `0x${rawDigest.padStart(64, "0")}` };
42
- }
43
-
44
- // src/lib/backend.ts
45
- var import_browser_or_node = require("browser-or-node");
46
- async function verifyCloudProof(proof, app_id, action, signal, endpoint) {
47
- if (import_browser_or_node.isBrowser) {
48
- throw new Error("verifyCloudProof can only be used in the backend.");
49
- }
50
- const response = await fetch(endpoint ?? `https://developer.worldcoin.org/api/v2/verify/${app_id}`, {
51
- method: "POST",
52
- headers: {
53
- "Content-Type": "application/json"
54
- },
55
- body: JSON.stringify({
56
- ...proof,
57
- action,
58
- signal_hash: hashToField(signal ?? "").digest
59
- })
60
- });
61
- if (response.ok) {
62
- return { success: true };
63
- } else {
64
- return { success: false, ...await response.json() };
65
- }
66
- }
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- verifyCloudProof
70
- });
@@ -1,12 +0,0 @@
1
- import { I as ISuccessResult } from '../result-BZ4QXOc2.cjs';
2
- import '../config-fuwC_Hia.cjs';
3
-
4
- interface IVerifyResponse {
5
- success: boolean;
6
- code?: string;
7
- detail?: string;
8
- attribute?: string | null;
9
- }
10
- declare function verifyCloudProof(proof: ISuccessResult, app_id: `app_${string}`, action: string, signal?: string, endpoint?: URL | string): Promise<IVerifyResponse>;
11
-
12
- export { type IVerifyResponse, verifyCloudProof };
@@ -1,12 +0,0 @@
1
- import { I as ISuccessResult } from '../result-CqgtArQe.js';
2
- import '../config-fuwC_Hia.js';
3
-
4
- interface IVerifyResponse {
5
- success: boolean;
6
- code?: string;
7
- detail?: string;
8
- attribute?: string | null;
9
- }
10
- declare function verifyCloudProof(proof: ISuccessResult, app_id: `app_${string}`, action: string, signal?: string, endpoint?: URL | string): Promise<IVerifyResponse>;
11
-
12
- export { type IVerifyResponse, verifyCloudProof };
@@ -1,30 +0,0 @@
1
- import {
2
- hashToField
3
- } from "../chunk-HZ2SQA5V.js";
4
-
5
- // src/lib/backend.ts
6
- import { isBrowser } from "browser-or-node";
7
- async function verifyCloudProof(proof, app_id, action, signal, endpoint) {
8
- if (isBrowser) {
9
- throw new Error("verifyCloudProof can only be used in the backend.");
10
- }
11
- const response = await fetch(endpoint ?? `https://developer.worldcoin.org/api/v2/verify/${app_id}`, {
12
- method: "POST",
13
- headers: {
14
- "Content-Type": "application/json"
15
- },
16
- body: JSON.stringify({
17
- ...proof,
18
- action,
19
- signal_hash: hashToField(signal ?? "").digest
20
- })
21
- });
22
- if (response.ok) {
23
- return { success: true };
24
- } else {
25
- return { success: false, ...await response.json() };
26
- }
27
- }
28
- export {
29
- verifyCloudProof
30
- };
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/lib/hashing.ts
21
- var hashing_exports = {};
22
- __export(hashing_exports, {
23
- encodeAction: () => encodeAction,
24
- generateSignal: () => generateSignal,
25
- hashToField: () => hashToField,
26
- packAndEncode: () => packAndEncode,
27
- solidityEncode: () => solidityEncode
28
- });
29
- module.exports = __toCommonJS(hashing_exports);
30
- var import_buffer = require("buffer/index.js");
31
- var import_ox = require("ox");
32
- function hashToField(input) {
33
- if (import_ox.Bytes.validate(input) || import_ox.Hex.validate(input)) return hashEncodedBytes(input);
34
- return hashString(input);
35
- }
36
- function packAndEncode(input) {
37
- const [types, values] = input.reduce(
38
- ([types2, values2], [type, value]) => {
39
- types2.push(type);
40
- values2.push(value);
41
- return [types2, values2];
42
- },
43
- [[], []]
44
- );
45
- return hashEncodedBytes(import_ox.AbiParameters.encodePacked(types, values));
46
- }
47
- function hashString(input) {
48
- const bytesInput = import_buffer.Buffer.from(input);
49
- return hashEncodedBytes(bytesInput);
50
- }
51
- function hashEncodedBytes(input) {
52
- const hash = BigInt(import_ox.Hash.keccak256(input, { as: "Hex" })) >> 8n;
53
- const rawDigest = hash.toString(16);
54
- return { hash, digest: `0x${rawDigest.padStart(64, "0")}` };
55
- }
56
- var solidityEncode = (types, values) => {
57
- if (types.length !== values.length) {
58
- throw new Error("Types and values arrays must have the same length.");
59
- }
60
- return { types, values };
61
- };
62
- var generateSignal = (signal) => {
63
- if (!signal || typeof signal === "string") return hashToField(signal ?? "");
64
- return packAndEncode(signal.types.map((type, index) => [type, signal.values[index]]));
65
- };
66
- var encodeAction = (action) => {
67
- if (!action) return "";
68
- if (typeof action === "string") return action;
69
- return action.types.map((type, index) => `${type}(${action.values[index]})`).join(",");
70
- };
71
- // Annotate the CommonJS export names for ESM import in node:
72
- 0 && (module.exports = {
73
- encodeAction,
74
- generateSignal,
75
- hashToField,
76
- packAndEncode,
77
- solidityEncode
78
- });
@@ -1,21 +0,0 @@
1
- import { A as AbiEncodedValue, I as IDKitConfig } from '../config-fuwC_Hia.cjs';
2
- import { Bytes } from 'ox';
3
-
4
- interface HashFunctionOutput {
5
- hash: bigint;
6
- digest: `0x${string}`;
7
- }
8
- /**
9
- * Hashes an input using the `keccak256` hashing function used across the World ID protocol, to be used as
10
- * a ZKP input. The function will try to determine the best hashing mechanism, if the string already looks like hex-encoded
11
- * bytes (e.g. `0x0000000000000000000000000000000000000000`), it will be hashed directly.
12
- * @param input Any string, hex-like string, bytes represented as a hex string.
13
- * @returns
14
- */
15
- declare function hashToField(input: Bytes.Bytes | string): HashFunctionOutput;
16
- declare function packAndEncode(input: [string, unknown][]): HashFunctionOutput;
17
- declare const solidityEncode: (types: string[], values: unknown[]) => AbiEncodedValue;
18
- declare const generateSignal: (signal: IDKitConfig['signal']) => HashFunctionOutput;
19
- declare const encodeAction: (action: IDKitConfig['action']) => string;
20
-
21
- export { type HashFunctionOutput, encodeAction, generateSignal, hashToField, packAndEncode, solidityEncode };
@@ -1,21 +0,0 @@
1
- import { A as AbiEncodedValue, I as IDKitConfig } from '../config-fuwC_Hia.js';
2
- import { Bytes } from 'ox';
3
-
4
- interface HashFunctionOutput {
5
- hash: bigint;
6
- digest: `0x${string}`;
7
- }
8
- /**
9
- * Hashes an input using the `keccak256` hashing function used across the World ID protocol, to be used as
10
- * a ZKP input. The function will try to determine the best hashing mechanism, if the string already looks like hex-encoded
11
- * bytes (e.g. `0x0000000000000000000000000000000000000000`), it will be hashed directly.
12
- * @param input Any string, hex-like string, bytes represented as a hex string.
13
- * @returns
14
- */
15
- declare function hashToField(input: Bytes.Bytes | string): HashFunctionOutput;
16
- declare function packAndEncode(input: [string, unknown][]): HashFunctionOutput;
17
- declare const solidityEncode: (types: string[], values: unknown[]) => AbiEncodedValue;
18
- declare const generateSignal: (signal: IDKitConfig['signal']) => HashFunctionOutput;
19
- declare const encodeAction: (action: IDKitConfig['action']) => string;
20
-
21
- export { type HashFunctionOutput, encodeAction, generateSignal, hashToField, packAndEncode, solidityEncode };
@@ -1,14 +0,0 @@
1
- import {
2
- encodeAction,
3
- generateSignal,
4
- hashToField,
5
- packAndEncode,
6
- solidityEncode
7
- } from "../chunk-HZ2SQA5V.js";
8
- export {
9
- encodeAction,
10
- generateSignal,
11
- hashToField,
12
- packAndEncode,
13
- solidityEncode
14
- };
@@ -1,35 +0,0 @@
1
- import { V as VerificationLevel } from './config-fuwC_Hia.cjs';
2
-
3
- declare enum AppErrorCodes {
4
- ConnectionFailed = "connection_failed",
5
- VerificationRejected = "verification_rejected",
6
- MaxVerificationsReached = "max_verifications_reached",
7
- CredentialUnavailable = "credential_unavailable",
8
- MalformedRequest = "malformed_request",
9
- InvalidNetwork = "invalid_network",
10
- InclusionProofFailed = "inclusion_proof_failed",
11
- InclusionProofPending = "inclusion_proof_pending",
12
- UnexpectedResponse = "unexpected_response",// NOTE: when the World app returns an unexpected response
13
- FailedByHostApp = "failed_by_host_app",// NOTE: Host app failed/rejected verification (does not come from World App / simulator)
14
- GenericError = "generic_error"
15
- }
16
- declare enum VerificationState {
17
- PreparingClient = "loading_widget",
18
- WaitingForConnection = "awaiting_connection",// Awaiting connection from the wallet
19
- WaitingForApp = "awaiting_app",// Awaiting user confirmation in wallet
20
- Confirmed = "confirmed",
21
- Failed = "failed"
22
- }
23
-
24
- interface ISuccessResult {
25
- proof: string;
26
- merkle_root: string;
27
- nullifier_hash: string;
28
- verification_level: VerificationLevel;
29
- }
30
- interface IErrorState {
31
- code: AppErrorCodes;
32
- message?: string;
33
- }
34
-
35
- export { AppErrorCodes as A, type ISuccessResult as I, VerificationState as V, type IErrorState as a };
@@ -1,35 +0,0 @@
1
- import { V as VerificationLevel } from './config-fuwC_Hia.js';
2
-
3
- declare enum AppErrorCodes {
4
- ConnectionFailed = "connection_failed",
5
- VerificationRejected = "verification_rejected",
6
- MaxVerificationsReached = "max_verifications_reached",
7
- CredentialUnavailable = "credential_unavailable",
8
- MalformedRequest = "malformed_request",
9
- InvalidNetwork = "invalid_network",
10
- InclusionProofFailed = "inclusion_proof_failed",
11
- InclusionProofPending = "inclusion_proof_pending",
12
- UnexpectedResponse = "unexpected_response",// NOTE: when the World app returns an unexpected response
13
- FailedByHostApp = "failed_by_host_app",// NOTE: Host app failed/rejected verification (does not come from World App / simulator)
14
- GenericError = "generic_error"
15
- }
16
- declare enum VerificationState {
17
- PreparingClient = "loading_widget",
18
- WaitingForConnection = "awaiting_connection",// Awaiting connection from the wallet
19
- WaitingForApp = "awaiting_app",// Awaiting user confirmation in wallet
20
- Confirmed = "confirmed",
21
- Failed = "failed"
22
- }
23
-
24
- interface ISuccessResult {
25
- proof: string;
26
- merkle_root: string;
27
- nullifier_hash: string;
28
- verification_level: VerificationLevel;
29
- }
30
- interface IErrorState {
31
- code: AppErrorCodes;
32
- message?: string;
33
- }
34
-
35
- export { AppErrorCodes as A, type ISuccessResult as I, VerificationState as V, type IErrorState as a };