@worldcoin/idkit-core 1.3.0 → 1.4.0

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.
@@ -1,8 +1,8 @@
1
1
  // src/lib/hashing.ts
2
2
  import { Buffer } from "buffer/index.js";
3
- import { encodePacked, isBytes, isHex, keccak256 } from "viem";
3
+ import { AbiParameters, Bytes, Hex, Hash } from "ox";
4
4
  function hashToField(input) {
5
- if (isBytes(input) || isHex(input)) return hashEncodedBytes(input);
5
+ if (Bytes.validate(input) || Hex.validate(input)) return hashEncodedBytes(input);
6
6
  return hashString(input);
7
7
  }
8
8
  function packAndEncode(input) {
@@ -14,14 +14,14 @@ function packAndEncode(input) {
14
14
  },
15
15
  [[], []]
16
16
  );
17
- return hashEncodedBytes(encodePacked(types, values));
17
+ return hashEncodedBytes(AbiParameters.encodePacked(types, values));
18
18
  }
19
19
  function hashString(input) {
20
20
  const bytesInput = Buffer.from(input);
21
21
  return hashEncodedBytes(bytesInput);
22
22
  }
23
23
  function hashEncodedBytes(input) {
24
- const hash = BigInt(keccak256(input)) >> 8n;
24
+ const hash = BigInt(Hash.keccak256(input, { as: "Hex" })) >> 8n;
25
25
  const rawDigest = hash.toString(16);
26
26
  return { hash, digest: `0x${rawDigest.padStart(64, "0")}` };
27
27
  }
@@ -11,10 +11,14 @@ type AbiEncodedValue = Brand<{
11
11
  */
12
12
  declare enum CredentialType {
13
13
  Orb = "orb",
14
+ SecureDocument = "secure_document",
15
+ Document = "document",
14
16
  Device = "device"
15
17
  }
16
18
  declare enum VerificationLevel {
17
19
  Orb = "orb",
20
+ SecureDocument = "secure_document",
21
+ Document = "document",
18
22
  Device = "device"
19
23
  }
20
24
  type IDKitConfig = {
@@ -11,10 +11,14 @@ type AbiEncodedValue = Brand<{
11
11
  */
12
12
  declare enum CredentialType {
13
13
  Orb = "orb",
14
+ SecureDocument = "secure_document",
15
+ Document = "document",
14
16
  Device = "device"
15
17
  }
16
18
  declare enum VerificationLevel {
17
19
  Orb = "orb",
20
+ SecureDocument = "secure_document",
21
+ Document = "document",
18
22
  Device = "device"
19
23
  }
20
24
  type IDKitConfig = {
package/build/index.cjs CHANGED
@@ -57,11 +57,15 @@ var VerificationState = /* @__PURE__ */ ((VerificationState2) => {
57
57
  // src/types/config.ts
58
58
  var CredentialType = /* @__PURE__ */ ((CredentialType2) => {
59
59
  CredentialType2["Orb"] = "orb";
60
+ CredentialType2["SecureDocument"] = "secure_document";
61
+ CredentialType2["Document"] = "document";
60
62
  CredentialType2["Device"] = "device";
61
63
  return CredentialType2;
62
64
  })(CredentialType || {});
63
65
  var VerificationLevel = /* @__PURE__ */ ((VerificationLevel2) => {
64
66
  VerificationLevel2["Orb"] = "orb";
67
+ VerificationLevel2["SecureDocument"] = "secure_document";
68
+ VerificationLevel2["Document"] = "document";
65
69
  VerificationLevel2["Device"] = "device";
66
70
  return VerificationLevel2;
67
71
  })(VerificationLevel || {});
@@ -110,9 +114,9 @@ function validate_bridge_url(bridge_url, is_staging) {
110
114
 
111
115
  // src/lib/hashing.ts
112
116
  var import_buffer = require("buffer/index.js");
113
- var import_viem = require("viem");
117
+ var import_ox = require("ox");
114
118
  function hashToField(input) {
115
- if ((0, import_viem.isBytes)(input) || (0, import_viem.isHex)(input)) return hashEncodedBytes(input);
119
+ if (import_ox.Bytes.validate(input) || import_ox.Hex.validate(input)) return hashEncodedBytes(input);
116
120
  return hashString(input);
117
121
  }
118
122
  function packAndEncode(input) {
@@ -124,14 +128,14 @@ function packAndEncode(input) {
124
128
  },
125
129
  [[], []]
126
130
  );
127
- return hashEncodedBytes((0, import_viem.encodePacked)(types, values));
131
+ return hashEncodedBytes(import_ox.AbiParameters.encodePacked(types, values));
128
132
  }
129
133
  function hashString(input) {
130
134
  const bytesInput = import_buffer.Buffer.from(input);
131
135
  return hashEncodedBytes(bytesInput);
132
136
  }
133
137
  function hashEncodedBytes(input) {
134
- const hash = BigInt((0, import_viem.keccak256)(input)) >> 8n;
138
+ const hash = BigInt(import_ox.Hash.keccak256(input, { as: "Hex" })) >> 8n;
135
139
  const rawDigest = hash.toString(16);
136
140
  return { hash, digest: `0x${rawDigest.padStart(64, "0")}` };
137
141
  }
@@ -157,7 +161,11 @@ var buffer_decode = (encoded) => {
157
161
  var verification_level_to_credential_types = (verification_level) => {
158
162
  switch (verification_level) {
159
163
  case "device" /* Device */:
160
- return ["orb" /* Orb */, "device" /* Device */];
164
+ return ["orb" /* Orb */, "device" /* Device */, "secure_document" /* SecureDocument */, "document" /* Document */];
165
+ case "document" /* Document */:
166
+ return ["document" /* Document */, "orb" /* Orb */];
167
+ case "secure_document" /* SecureDocument */:
168
+ return ["secure_document" /* SecureDocument */, "orb" /* Orb */];
161
169
  case "orb" /* Orb */:
162
170
  return ["orb" /* Orb */];
163
171
  default:
@@ -168,6 +176,10 @@ var credential_type_to_verification_level = (credential_type) => {
168
176
  switch (credential_type) {
169
177
  case "orb" /* Orb */:
170
178
  return "orb" /* Orb */;
179
+ case "secure_document" /* SecureDocument */:
180
+ return "secure_document" /* SecureDocument */;
181
+ case "document" /* Document */:
182
+ return "document" /* Document */;
171
183
  case "device" /* Device */:
172
184
  return "device" /* Device */;
173
185
  default:
package/build/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as ISuccessResult, A as AppErrorCodes, V as VerificationState } from './result-CzLWEJ3W.cjs';
2
- export { a as IErrorState } from './result-CzLWEJ3W.cjs';
3
- import { I as IDKitConfig, V as VerificationLevel } from './config-3PagjISh.cjs';
4
- export { A as AbiEncodedValue, C as CredentialType } from './config-3PagjISh.cjs';
1
+ import { I as ISuccessResult, A as AppErrorCodes, V as VerificationState } from './result-CUii5sPK.cjs';
2
+ export { a as IErrorState } from './result-CUii5sPK.cjs';
3
+ import { I as IDKitConfig, V as VerificationLevel } from './config-Cnqr_Fj4.cjs';
4
+ export { A as AbiEncodedValue, C as CredentialType } from './config-Cnqr_Fj4.cjs';
5
5
  import * as zustand from 'zustand';
6
6
 
7
7
  type WorldBridgeStore = {
package/build/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as ISuccessResult, A as AppErrorCodes, V as VerificationState } from './result-DBgbUYNh.js';
2
- export { a as IErrorState } from './result-DBgbUYNh.js';
3
- import { I as IDKitConfig, V as VerificationLevel } from './config-3PagjISh.js';
4
- export { A as AbiEncodedValue, C as CredentialType } from './config-3PagjISh.js';
1
+ import { I as ISuccessResult, A as AppErrorCodes, V as VerificationState } from './result-BIRE8gcC.js';
2
+ export { a as IErrorState } from './result-BIRE8gcC.js';
3
+ import { I as IDKitConfig, V as VerificationLevel } from './config-Cnqr_Fj4.js';
4
+ export { A as AbiEncodedValue, C as CredentialType } from './config-Cnqr_Fj4.js';
5
5
  import * as zustand from 'zustand';
6
6
 
7
7
  type WorldBridgeStore = {
package/build/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  encodeAction,
3
3
  generateSignal
4
- } from "./chunk-QN7JTJAQ.js";
4
+ } from "./chunk-HZ2SQA5V.js";
5
5
 
6
6
  // src/types/bridge.ts
7
7
  var AppErrorCodes = /* @__PURE__ */ ((AppErrorCodes2) => {
@@ -30,11 +30,15 @@ var VerificationState = /* @__PURE__ */ ((VerificationState2) => {
30
30
  // src/types/config.ts
31
31
  var CredentialType = /* @__PURE__ */ ((CredentialType2) => {
32
32
  CredentialType2["Orb"] = "orb";
33
+ CredentialType2["SecureDocument"] = "secure_document";
34
+ CredentialType2["Document"] = "document";
33
35
  CredentialType2["Device"] = "device";
34
36
  return CredentialType2;
35
37
  })(CredentialType || {});
36
38
  var VerificationLevel = /* @__PURE__ */ ((VerificationLevel2) => {
37
39
  VerificationLevel2["Orb"] = "orb";
40
+ VerificationLevel2["SecureDocument"] = "secure_document";
41
+ VerificationLevel2["Document"] = "document";
38
42
  VerificationLevel2["Device"] = "device";
39
43
  return VerificationLevel2;
40
44
  })(VerificationLevel || {});
@@ -93,7 +97,11 @@ var buffer_decode = (encoded) => {
93
97
  var verification_level_to_credential_types = (verification_level) => {
94
98
  switch (verification_level) {
95
99
  case "device" /* Device */:
96
- return ["orb" /* Orb */, "device" /* Device */];
100
+ return ["orb" /* Orb */, "device" /* Device */, "secure_document" /* SecureDocument */, "document" /* Document */];
101
+ case "document" /* Document */:
102
+ return ["document" /* Document */, "orb" /* Orb */];
103
+ case "secure_document" /* SecureDocument */:
104
+ return ["secure_document" /* SecureDocument */, "orb" /* Orb */];
97
105
  case "orb" /* Orb */:
98
106
  return ["orb" /* Orb */];
99
107
  default:
@@ -104,6 +112,10 @@ var credential_type_to_verification_level = (credential_type) => {
104
112
  switch (credential_type) {
105
113
  case "orb" /* Orb */:
106
114
  return "orb" /* Orb */;
115
+ case "secure_document" /* SecureDocument */:
116
+ return "secure_document" /* SecureDocument */;
117
+ case "document" /* Document */:
118
+ return "document" /* Document */;
107
119
  case "device" /* Device */:
108
120
  return "device" /* Device */;
109
121
  default:
@@ -26,9 +26,9 @@ module.exports = __toCommonJS(backend_exports);
26
26
 
27
27
  // src/lib/hashing.ts
28
28
  var import_buffer = require("buffer/index.js");
29
- var import_viem = require("viem");
29
+ var import_ox = require("ox");
30
30
  function hashToField(input) {
31
- if ((0, import_viem.isBytes)(input) || (0, import_viem.isHex)(input)) return hashEncodedBytes(input);
31
+ if (import_ox.Bytes.validate(input) || import_ox.Hex.validate(input)) return hashEncodedBytes(input);
32
32
  return hashString(input);
33
33
  }
34
34
  function hashString(input) {
@@ -36,7 +36,7 @@ function hashString(input) {
36
36
  return hashEncodedBytes(bytesInput);
37
37
  }
38
38
  function hashEncodedBytes(input) {
39
- const hash = BigInt((0, import_viem.keccak256)(input)) >> 8n;
39
+ const hash = BigInt(import_ox.Hash.keccak256(input, { as: "Hex" })) >> 8n;
40
40
  const rawDigest = hash.toString(16);
41
41
  return { hash, digest: `0x${rawDigest.padStart(64, "0")}` };
42
42
  }
@@ -1,5 +1,5 @@
1
- import { I as ISuccessResult } from '../result-CzLWEJ3W.cjs';
2
- import '../config-3PagjISh.cjs';
1
+ import { I as ISuccessResult } from '../result-CUii5sPK.cjs';
2
+ import '../config-Cnqr_Fj4.cjs';
3
3
 
4
4
  interface IVerifyResponse {
5
5
  success: boolean;
@@ -1,5 +1,5 @@
1
- import { I as ISuccessResult } from '../result-DBgbUYNh.js';
2
- import '../config-3PagjISh.js';
1
+ import { I as ISuccessResult } from '../result-BIRE8gcC.js';
2
+ import '../config-Cnqr_Fj4.js';
3
3
 
4
4
  interface IVerifyResponse {
5
5
  success: boolean;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  hashToField
3
- } from "../chunk-QN7JTJAQ.js";
3
+ } from "../chunk-HZ2SQA5V.js";
4
4
 
5
5
  // src/lib/backend.ts
6
6
  import { isBrowser } from "browser-or-node";
@@ -28,9 +28,9 @@ __export(hashing_exports, {
28
28
  });
29
29
  module.exports = __toCommonJS(hashing_exports);
30
30
  var import_buffer = require("buffer/index.js");
31
- var import_viem = require("viem");
31
+ var import_ox = require("ox");
32
32
  function hashToField(input) {
33
- if ((0, import_viem.isBytes)(input) || (0, import_viem.isHex)(input)) return hashEncodedBytes(input);
33
+ if (import_ox.Bytes.validate(input) || import_ox.Hex.validate(input)) return hashEncodedBytes(input);
34
34
  return hashString(input);
35
35
  }
36
36
  function packAndEncode(input) {
@@ -42,14 +42,14 @@ function packAndEncode(input) {
42
42
  },
43
43
  [[], []]
44
44
  );
45
- return hashEncodedBytes((0, import_viem.encodePacked)(types, values));
45
+ return hashEncodedBytes(import_ox.AbiParameters.encodePacked(types, values));
46
46
  }
47
47
  function hashString(input) {
48
48
  const bytesInput = import_buffer.Buffer.from(input);
49
49
  return hashEncodedBytes(bytesInput);
50
50
  }
51
51
  function hashEncodedBytes(input) {
52
- const hash = BigInt((0, import_viem.keccak256)(input)) >> 8n;
52
+ const hash = BigInt(import_ox.Hash.keccak256(input, { as: "Hex" })) >> 8n;
53
53
  const rawDigest = hash.toString(16);
54
54
  return { hash, digest: `0x${rawDigest.padStart(64, "0")}` };
55
55
  }
@@ -1,4 +1,5 @@
1
- import { A as AbiEncodedValue, I as IDKitConfig } from '../config-3PagjISh.cjs';
1
+ import { A as AbiEncodedValue, I as IDKitConfig } from '../config-Cnqr_Fj4.cjs';
2
+ import { Bytes } from 'ox';
2
3
 
3
4
  interface HashFunctionOutput {
4
5
  hash: bigint;
@@ -11,7 +12,7 @@ interface HashFunctionOutput {
11
12
  * @param input Any string, hex-like string, bytes represented as a hex string.
12
13
  * @returns
13
14
  */
14
- declare function hashToField(input: Uint8Array | string): HashFunctionOutput;
15
+ declare function hashToField(input: Bytes.Bytes | string): HashFunctionOutput;
15
16
  declare function packAndEncode(input: [string, unknown][]): HashFunctionOutput;
16
17
  declare const solidityEncode: (types: string[], values: unknown[]) => AbiEncodedValue;
17
18
  declare const generateSignal: (signal: IDKitConfig['signal']) => HashFunctionOutput;
@@ -1,4 +1,5 @@
1
- import { A as AbiEncodedValue, I as IDKitConfig } from '../config-3PagjISh.js';
1
+ import { A as AbiEncodedValue, I as IDKitConfig } from '../config-Cnqr_Fj4.js';
2
+ import { Bytes } from 'ox';
2
3
 
3
4
  interface HashFunctionOutput {
4
5
  hash: bigint;
@@ -11,7 +12,7 @@ interface HashFunctionOutput {
11
12
  * @param input Any string, hex-like string, bytes represented as a hex string.
12
13
  * @returns
13
14
  */
14
- declare function hashToField(input: Uint8Array | string): HashFunctionOutput;
15
+ declare function hashToField(input: Bytes.Bytes | string): HashFunctionOutput;
15
16
  declare function packAndEncode(input: [string, unknown][]): HashFunctionOutput;
16
17
  declare const solidityEncode: (types: string[], values: unknown[]) => AbiEncodedValue;
17
18
  declare const generateSignal: (signal: IDKitConfig['signal']) => HashFunctionOutput;
@@ -4,7 +4,7 @@ import {
4
4
  hashToField,
5
5
  packAndEncode,
6
6
  solidityEncode
7
- } from "../chunk-QN7JTJAQ.js";
7
+ } from "../chunk-HZ2SQA5V.js";
8
8
  export {
9
9
  encodeAction,
10
10
  generateSignal,
@@ -1,4 +1,4 @@
1
- import { V as VerificationLevel } from './config-3PagjISh.js';
1
+ import { V as VerificationLevel } from './config-Cnqr_Fj4.js';
2
2
 
3
3
  declare enum AppErrorCodes {
4
4
  ConnectionFailed = "connection_failed",
@@ -1,4 +1,4 @@
1
- import { V as VerificationLevel } from './config-3PagjISh.cjs';
1
+ import { V as VerificationLevel } from './config-Cnqr_Fj4.cjs';
2
2
 
3
3
  declare enum AppErrorCodes {
4
4
  ConnectionFailed = "connection_failed",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldcoin/idkit-core",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "homepage": "https://docs.worldcoin.org/id/idkit",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -58,14 +58,12 @@
58
58
  "dependencies": {
59
59
  "browser-or-node": "3.0.0-pre.0",
60
60
  "buffer": "^6.0.3",
61
- "viem": "^2.17.0",
61
+ "ox": "^0.1.0",
62
62
  "zustand": "^4.5"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@typescript-eslint/eslint-plugin": "^6.13.1",
66
66
  "@typescript-eslint/parser": "^6.13.1",
67
- "prettier": "^2.7.1",
68
- "prettier-plugin-sort-imports-desc": "^1.0.0",
69
67
  "tsup": "^8.1.0",
70
68
  "typescript": "^5.3.2"
71
69
  },