@worldcoin/idkit-core 4.0.1-dev.123c6a8 → 4.0.1-dev.eebacb1

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.d.cts CHANGED
@@ -1,9 +1,3 @@
1
- /**
2
- * Configuration types for IDKit
3
- *
4
- * Note: CredentialType, CredentialRequestType, and ConstraintNode are now
5
- * re-exported from WASM (source of truth: rust/core/src/wasm_bindings.rs)
6
- */
7
1
  declare const brand: unique symbol;
8
2
  type Brand<T, TBrand extends string> = T & {
9
3
  [brand]: TBrand;
@@ -12,6 +6,26 @@ type AbiEncodedValue = Brand<{
12
6
  types: string[];
13
7
  values: unknown[];
14
8
  }, "AbiEncodedValue">;
9
+ type CredentialType = "orb" | "face" | "secure_document" | "document" | "device";
10
+ /**
11
+ * A single credential request item
12
+ */
13
+ interface CredentialRequestType {
14
+ /** The type of credential being requested */
15
+ type: CredentialType;
16
+ /** Optional signal string for cryptographic binding */
17
+ signal?: string;
18
+ /** Optional minimum genesis timestamp constraint */
19
+ genesis_issued_at_min?: number;
20
+ }
21
+ /**
22
+ * Constraint node - can be a CredentialRequest or a combinator (any/all)
23
+ */
24
+ type ConstraintNode = CredentialRequestType | {
25
+ any: ConstraintNode[];
26
+ } | {
27
+ all: ConstraintNode[];
28
+ };
15
29
  /**
16
30
  * Relying Party context for protocol-level proof requests
17
31
  *
@@ -47,85 +61,44 @@ type IDKitRequestConfig = {
47
61
  bridge_url?: string;
48
62
  };
49
63
 
50
- /** V4 response item (protocol version 4.0 / World ID v4) */
51
- interface ResponseItemV4 {
52
- /** Credential identifier */
53
- identifier: CredentialType;
54
- /** Compressed Groth16 proof (hex) */
55
- proof: string;
56
- /** RP-scoped nullifier (hex) */
57
- nullifier: string;
58
- /** Authenticator merkle root (hex) */
59
- merkle_root: string;
60
- /** Unix timestamp when proof was generated */
61
- proof_timestamp: number;
62
- /** Credential issuer schema ID (hex) */
63
- issuer_schema_id: string;
64
+ declare enum AppErrorCodes {
65
+ ConnectionFailed = "connection_failed",
66
+ VerificationRejected = "verification_rejected",
67
+ MaxVerificationsReached = "max_verifications_reached",
68
+ CredentialUnavailable = "credential_unavailable",
69
+ MalformedRequest = "malformed_request",
70
+ InvalidNetwork = "invalid_network",
71
+ InclusionProofFailed = "inclusion_proof_failed",
72
+ InclusionProofPending = "inclusion_proof_pending",
73
+ UnexpectedResponse = "unexpected_response",
74
+ FailedByHostApp = "failed_by_host_app",
75
+ GenericError = "generic_error"
76
+ }
77
+ declare enum VerificationState {
78
+ PreparingClient = "loading_widget",
79
+ WaitingForConnection = "awaiting_connection",
80
+ WaitingForApp = "awaiting_app",
81
+ Confirmed = "confirmed",
82
+ Failed = "failed"
83
+ }
84
+ declare enum ResponseStatus {
85
+ Retrieved = "retrieved",
86
+ Completed = "completed",
87
+ Initialized = "initialized"
64
88
  }
65
89
 
66
- /** V3 response item (protocol version 3.0 / World ID v3 - legacy format) */
67
- interface ResponseItemV3 {
68
- /** Credential identifier */
69
- identifier: CredentialType;
70
- /** ABI-encoded proof (hex) */
90
+ interface ISuccessResult {
71
91
  proof: string;
72
- /** Merkle root (hex) */
73
92
  merkle_root: string;
74
- /** Nullifier hash (hex) */
75
93
  nullifier_hash: string;
94
+ /** The credential type used to generate the proof */
95
+ verification_level: CredentialType;
76
96
  }
77
-
78
- /**
79
- * A single credential response item - unified type for both bridge and SDK.
80
- * Type narrowing: use 'proof_timestamp' in item for V4, 'nullifier_hash' in item for V3.
81
- */
82
- type ResponseItem = ResponseItemV4 | ResponseItemV3;
83
-
84
- /** V3 result (legacy format - no session support) */
85
- interface IDKitResultV3 {
86
- /** Protocol version 3.0 */
87
- protocol_version: "3.0";
88
- /** Array of V3 credential responses */
89
- responses: ResponseItemV3[];
90
- }
91
-
92
- /** V4 result (current format - supports sessions) */
93
- interface IDKitResultV4 {
94
- /** Protocol version 4.0 */
95
- protocol_version: "4.0";
96
- /** Session ID (for session proofs) */
97
- session_id?: string;
98
- /** Array of V4 credential responses */
99
- responses: ResponseItemV4[];
100
- }
101
-
102
- /** The unified response structure - discriminated union by protocol_version */
103
- type IDKitResult = IDKitResultV3 | IDKitResultV4;
104
-
105
- /** Status returned from pollForStatus() */
106
- type Status$1 =
107
- | { type: "waiting_for_connection" }
108
- | { type: "awaiting_confirmation" }
109
- | { type: "confirmed"; result: IDKitResult }
110
- | { type: "failed"; error: string };
111
-
112
-
113
-
114
- type CredentialType = "orb" | "face" | "secure_document" | "document" | "device";
115
-
116
- interface CredentialRequestType {
117
- type: CredentialType;
118
- signal?: string;
119
- genesis_issued_at_min?: number;
97
+ interface IErrorState {
98
+ code: AppErrorCodes;
99
+ message?: string;
120
100
  }
121
101
 
122
- type ConstraintNode =
123
- | CredentialRequestType
124
- | { any: ConstraintNode[] }
125
- | { all: ConstraintNode[] };
126
-
127
-
128
-
129
102
  interface RpSignature {
130
103
  sig: string;
131
104
  nonce: string;
@@ -182,32 +155,6 @@ declare function initIDKit(): Promise<void>;
182
155
  */
183
156
  declare function initIDKitServer(): Promise<void>;
184
157
 
185
- declare enum AppErrorCodes {
186
- ConnectionFailed = "connection_failed",
187
- VerificationRejected = "verification_rejected",
188
- MaxVerificationsReached = "max_verifications_reached",
189
- CredentialUnavailable = "credential_unavailable",
190
- MalformedRequest = "malformed_request",
191
- InvalidNetwork = "invalid_network",
192
- InclusionProofFailed = "inclusion_proof_failed",
193
- InclusionProofPending = "inclusion_proof_pending",
194
- UnexpectedResponse = "unexpected_response",
195
- FailedByHostApp = "failed_by_host_app",
196
- GenericError = "generic_error"
197
- }
198
- declare enum VerificationState {
199
- PreparingClient = "loading_widget",
200
- WaitingForConnection = "awaiting_connection",
201
- WaitingForApp = "awaiting_app",
202
- Confirmed = "confirmed",
203
- Failed = "failed"
204
- }
205
- declare enum ResponseStatus {
206
- Retrieved = "retrieved",
207
- Completed = "completed",
208
- Initialized = "initialized"
209
- }
210
-
211
158
  /**
212
159
  * IDKit Request
213
160
  * Pure functional API for World ID verification - no dependencies
@@ -225,7 +172,7 @@ interface WaitOptions {
225
172
  /** Status returned from pollOnce() */
226
173
  interface Status {
227
174
  type: "waiting_for_connection" | "awaiting_confirmation" | "confirmed" | "failed";
228
- result?: IDKitResult;
175
+ proof?: ISuccessResult;
229
176
  error?: AppErrorCodes;
230
177
  }
231
178
 
@@ -243,7 +190,7 @@ interface IDKitRequest {
243
190
  /** Poll once for current status (for manual polling) */
244
191
  pollOnce(): Promise<Status>;
245
192
  /** Poll continuously until completion or timeout */
246
- pollForUpdates(options?: WaitOptions): Promise<IDKitResult>;
193
+ pollForUpdates(options?: WaitOptions): Promise<ISuccessResult>;
247
194
  }
248
195
  /**
249
196
  * Creates a CredentialRequest for a credential type
@@ -487,4 +434,4 @@ declare const isNode: () => boolean;
487
434
  */
488
435
  declare function signRequest(action: string, signingKeyHex: string, ttlSeconds?: number): RpSignature;
489
436
 
490
- export { type AbiEncodedValue, AppErrorCodes, type ConstraintNode, CredentialRequest, type CredentialRequestType, type CredentialType, IDKit, type IDKitRequest, type IDKitRequestConfig, type IDKitResult, type OrbLegacyPreset, type Preset, type ResponseItem, type ResponseItemV3, type ResponseItemV4, ResponseStatus, type RpContext, RpSignature, type Status$1 as Status, VerificationState, type WaitOptions, all, any, isNode, isReactNative, isWeb, orbLegacy, signRequest };
437
+ export { type AbiEncodedValue, AppErrorCodes, type ConstraintNode, CredentialRequest, type CredentialRequestType, type CredentialType, IDKit, type IDKitRequest, type IDKitRequestConfig, type IErrorState, type ISuccessResult, type OrbLegacyPreset, type Preset, ResponseStatus, type RpContext, RpSignature, type Status, VerificationState, type WaitOptions, all, any, isNode, isReactNative, isWeb, orbLegacy, signRequest };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,3 @@
1
- /**
2
- * Configuration types for IDKit
3
- *
4
- * Note: CredentialType, CredentialRequestType, and ConstraintNode are now
5
- * re-exported from WASM (source of truth: rust/core/src/wasm_bindings.rs)
6
- */
7
1
  declare const brand: unique symbol;
8
2
  type Brand<T, TBrand extends string> = T & {
9
3
  [brand]: TBrand;
@@ -12,6 +6,26 @@ type AbiEncodedValue = Brand<{
12
6
  types: string[];
13
7
  values: unknown[];
14
8
  }, "AbiEncodedValue">;
9
+ type CredentialType = "orb" | "face" | "secure_document" | "document" | "device";
10
+ /**
11
+ * A single credential request item
12
+ */
13
+ interface CredentialRequestType {
14
+ /** The type of credential being requested */
15
+ type: CredentialType;
16
+ /** Optional signal string for cryptographic binding */
17
+ signal?: string;
18
+ /** Optional minimum genesis timestamp constraint */
19
+ genesis_issued_at_min?: number;
20
+ }
21
+ /**
22
+ * Constraint node - can be a CredentialRequest or a combinator (any/all)
23
+ */
24
+ type ConstraintNode = CredentialRequestType | {
25
+ any: ConstraintNode[];
26
+ } | {
27
+ all: ConstraintNode[];
28
+ };
15
29
  /**
16
30
  * Relying Party context for protocol-level proof requests
17
31
  *
@@ -47,85 +61,44 @@ type IDKitRequestConfig = {
47
61
  bridge_url?: string;
48
62
  };
49
63
 
50
- /** V4 response item (protocol version 4.0 / World ID v4) */
51
- interface ResponseItemV4 {
52
- /** Credential identifier */
53
- identifier: CredentialType;
54
- /** Compressed Groth16 proof (hex) */
55
- proof: string;
56
- /** RP-scoped nullifier (hex) */
57
- nullifier: string;
58
- /** Authenticator merkle root (hex) */
59
- merkle_root: string;
60
- /** Unix timestamp when proof was generated */
61
- proof_timestamp: number;
62
- /** Credential issuer schema ID (hex) */
63
- issuer_schema_id: string;
64
+ declare enum AppErrorCodes {
65
+ ConnectionFailed = "connection_failed",
66
+ VerificationRejected = "verification_rejected",
67
+ MaxVerificationsReached = "max_verifications_reached",
68
+ CredentialUnavailable = "credential_unavailable",
69
+ MalformedRequest = "malformed_request",
70
+ InvalidNetwork = "invalid_network",
71
+ InclusionProofFailed = "inclusion_proof_failed",
72
+ InclusionProofPending = "inclusion_proof_pending",
73
+ UnexpectedResponse = "unexpected_response",
74
+ FailedByHostApp = "failed_by_host_app",
75
+ GenericError = "generic_error"
76
+ }
77
+ declare enum VerificationState {
78
+ PreparingClient = "loading_widget",
79
+ WaitingForConnection = "awaiting_connection",
80
+ WaitingForApp = "awaiting_app",
81
+ Confirmed = "confirmed",
82
+ Failed = "failed"
83
+ }
84
+ declare enum ResponseStatus {
85
+ Retrieved = "retrieved",
86
+ Completed = "completed",
87
+ Initialized = "initialized"
64
88
  }
65
89
 
66
- /** V3 response item (protocol version 3.0 / World ID v3 - legacy format) */
67
- interface ResponseItemV3 {
68
- /** Credential identifier */
69
- identifier: CredentialType;
70
- /** ABI-encoded proof (hex) */
90
+ interface ISuccessResult {
71
91
  proof: string;
72
- /** Merkle root (hex) */
73
92
  merkle_root: string;
74
- /** Nullifier hash (hex) */
75
93
  nullifier_hash: string;
94
+ /** The credential type used to generate the proof */
95
+ verification_level: CredentialType;
76
96
  }
77
-
78
- /**
79
- * A single credential response item - unified type for both bridge and SDK.
80
- * Type narrowing: use 'proof_timestamp' in item for V4, 'nullifier_hash' in item for V3.
81
- */
82
- type ResponseItem = ResponseItemV4 | ResponseItemV3;
83
-
84
- /** V3 result (legacy format - no session support) */
85
- interface IDKitResultV3 {
86
- /** Protocol version 3.0 */
87
- protocol_version: "3.0";
88
- /** Array of V3 credential responses */
89
- responses: ResponseItemV3[];
90
- }
91
-
92
- /** V4 result (current format - supports sessions) */
93
- interface IDKitResultV4 {
94
- /** Protocol version 4.0 */
95
- protocol_version: "4.0";
96
- /** Session ID (for session proofs) */
97
- session_id?: string;
98
- /** Array of V4 credential responses */
99
- responses: ResponseItemV4[];
100
- }
101
-
102
- /** The unified response structure - discriminated union by protocol_version */
103
- type IDKitResult = IDKitResultV3 | IDKitResultV4;
104
-
105
- /** Status returned from pollForStatus() */
106
- type Status$1 =
107
- | { type: "waiting_for_connection" }
108
- | { type: "awaiting_confirmation" }
109
- | { type: "confirmed"; result: IDKitResult }
110
- | { type: "failed"; error: string };
111
-
112
-
113
-
114
- type CredentialType = "orb" | "face" | "secure_document" | "document" | "device";
115
-
116
- interface CredentialRequestType {
117
- type: CredentialType;
118
- signal?: string;
119
- genesis_issued_at_min?: number;
97
+ interface IErrorState {
98
+ code: AppErrorCodes;
99
+ message?: string;
120
100
  }
121
101
 
122
- type ConstraintNode =
123
- | CredentialRequestType
124
- | { any: ConstraintNode[] }
125
- | { all: ConstraintNode[] };
126
-
127
-
128
-
129
102
  interface RpSignature {
130
103
  sig: string;
131
104
  nonce: string;
@@ -182,32 +155,6 @@ declare function initIDKit(): Promise<void>;
182
155
  */
183
156
  declare function initIDKitServer(): Promise<void>;
184
157
 
185
- declare enum AppErrorCodes {
186
- ConnectionFailed = "connection_failed",
187
- VerificationRejected = "verification_rejected",
188
- MaxVerificationsReached = "max_verifications_reached",
189
- CredentialUnavailable = "credential_unavailable",
190
- MalformedRequest = "malformed_request",
191
- InvalidNetwork = "invalid_network",
192
- InclusionProofFailed = "inclusion_proof_failed",
193
- InclusionProofPending = "inclusion_proof_pending",
194
- UnexpectedResponse = "unexpected_response",
195
- FailedByHostApp = "failed_by_host_app",
196
- GenericError = "generic_error"
197
- }
198
- declare enum VerificationState {
199
- PreparingClient = "loading_widget",
200
- WaitingForConnection = "awaiting_connection",
201
- WaitingForApp = "awaiting_app",
202
- Confirmed = "confirmed",
203
- Failed = "failed"
204
- }
205
- declare enum ResponseStatus {
206
- Retrieved = "retrieved",
207
- Completed = "completed",
208
- Initialized = "initialized"
209
- }
210
-
211
158
  /**
212
159
  * IDKit Request
213
160
  * Pure functional API for World ID verification - no dependencies
@@ -225,7 +172,7 @@ interface WaitOptions {
225
172
  /** Status returned from pollOnce() */
226
173
  interface Status {
227
174
  type: "waiting_for_connection" | "awaiting_confirmation" | "confirmed" | "failed";
228
- result?: IDKitResult;
175
+ proof?: ISuccessResult;
229
176
  error?: AppErrorCodes;
230
177
  }
231
178
 
@@ -243,7 +190,7 @@ interface IDKitRequest {
243
190
  /** Poll once for current status (for manual polling) */
244
191
  pollOnce(): Promise<Status>;
245
192
  /** Poll continuously until completion or timeout */
246
- pollForUpdates(options?: WaitOptions): Promise<IDKitResult>;
193
+ pollForUpdates(options?: WaitOptions): Promise<ISuccessResult>;
247
194
  }
248
195
  /**
249
196
  * Creates a CredentialRequest for a credential type
@@ -487,4 +434,4 @@ declare const isNode: () => boolean;
487
434
  */
488
435
  declare function signRequest(action: string, signingKeyHex: string, ttlSeconds?: number): RpSignature;
489
436
 
490
- export { type AbiEncodedValue, AppErrorCodes, type ConstraintNode, CredentialRequest, type CredentialRequestType, type CredentialType, IDKit, type IDKitRequest, type IDKitRequestConfig, type IDKitResult, type OrbLegacyPreset, type Preset, type ResponseItem, type ResponseItemV3, type ResponseItemV4, ResponseStatus, type RpContext, RpSignature, type Status$1 as Status, VerificationState, type WaitOptions, all, any, isNode, isReactNative, isWeb, orbLegacy, signRequest };
437
+ export { type AbiEncodedValue, AppErrorCodes, type ConstraintNode, CredentialRequest, type CredentialRequestType, type CredentialType, IDKit, type IDKitRequest, type IDKitRequestConfig, type IErrorState, type ISuccessResult, type OrbLegacyPreset, type Preset, ResponseStatus, type RpContext, RpSignature, type Status, VerificationState, type WaitOptions, all, any, isNode, isReactNative, isWeb, orbLegacy, signRequest };
package/dist/index.js CHANGED
@@ -386,14 +386,14 @@ function signRequest(action, signing_key_hex, ttl_seconds) {
386
386
  wasm.__wbindgen_add_to_stack_pointer(16);
387
387
  }
388
388
  }
389
- function __wasm_bindgen_func_elem_551(arg0, arg1) {
390
- wasm.__wasm_bindgen_func_elem_551(arg0, arg1);
389
+ function __wasm_bindgen_func_elem_510(arg0, arg1) {
390
+ wasm.__wasm_bindgen_func_elem_510(arg0, arg1);
391
391
  }
392
- function __wasm_bindgen_func_elem_914(arg0, arg1, arg2) {
393
- wasm.__wasm_bindgen_func_elem_914(arg0, arg1, addHeapObject(arg2));
392
+ function __wasm_bindgen_func_elem_873(arg0, arg1, arg2) {
393
+ wasm.__wasm_bindgen_func_elem_873(arg0, arg1, addHeapObject(arg2));
394
394
  }
395
- function __wasm_bindgen_func_elem_1281(arg0, arg1, arg2, arg3) {
396
- wasm.__wasm_bindgen_func_elem_1281(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
395
+ function __wasm_bindgen_func_elem_1238(arg0, arg1, arg2, arg3) {
396
+ wasm.__wasm_bindgen_func_elem_1238(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
397
397
  }
398
398
  var __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
399
399
  var __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -726,7 +726,7 @@ var IDKitProof = class {
726
726
  wasm.__wbg_idkitproof_free(ptr, 0);
727
727
  }
728
728
  /**
729
- * Creates a new legacy proof (protocol v1 / World ID v3)
729
+ * Creates a new proof
730
730
  *
731
731
  * # Errors
732
732
  *
@@ -1439,7 +1439,7 @@ function __wbg_get_imports() {
1439
1439
  const a = state0.a;
1440
1440
  state0.a = 0;
1441
1441
  try {
1442
- return __wasm_bindgen_func_elem_1281(a, state0.b, arg02, arg12);
1442
+ return __wasm_bindgen_func_elem_1238(a, state0.b, arg02, arg12);
1443
1443
  } finally {
1444
1444
  state0.a = a;
1445
1445
  }
@@ -1648,6 +1648,10 @@ function __wbg_get_imports() {
1648
1648
  const ret = getObject(arg0).versions;
1649
1649
  return addHeapObject(ret);
1650
1650
  };
1651
+ imports.wbg.__wbindgen_cast_20b7882efa3c21d9 = function(arg0, arg1) {
1652
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_872, __wasm_bindgen_func_elem_873);
1653
+ return addHeapObject(ret);
1654
+ };
1651
1655
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1652
1656
  const ret = getStringFromWasm0(arg0, arg1);
1653
1657
  return addHeapObject(ret);
@@ -1656,16 +1660,12 @@ function __wbg_get_imports() {
1656
1660
  const ret = BigInt.asUintN(64, arg0);
1657
1661
  return addHeapObject(ret);
1658
1662
  };
1659
- imports.wbg.__wbindgen_cast_91c43ecf1f8dafb8 = function(arg0, arg1) {
1660
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_550, __wasm_bindgen_func_elem_551);
1661
- return addHeapObject(ret);
1662
- };
1663
1663
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
1664
1664
  const ret = arg0;
1665
1665
  return addHeapObject(ret);
1666
1666
  };
1667
- imports.wbg.__wbindgen_cast_ab10518eebecf9a3 = function(arg0, arg1) {
1668
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_913, __wasm_bindgen_func_elem_914);
1667
+ imports.wbg.__wbindgen_cast_c84362f2a853c6d7 = function(arg0, arg1) {
1668
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_509, __wasm_bindgen_func_elem_510);
1669
1669
  return addHeapObject(ret);
1670
1670
  };
1671
1671
  imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
@@ -1802,8 +1802,8 @@ var IDKitRequestImpl = class {
1802
1802
  throw new Error(`Timeout waiting for proof after ${timeout}ms`);
1803
1803
  }
1804
1804
  const status = await this.pollOnce();
1805
- if (status.type === "confirmed" && status.result) {
1806
- return status.result;
1805
+ if (status.type === "confirmed" && status.proof) {
1806
+ return status.proof;
1807
1807
  }
1808
1808
  if (status.type === "failed") {
1809
1809
  const errorCode = status.error ?? "generic_error" /* GenericError */;