@fileverse/api 0.0.13 → 0.0.15

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.
@@ -972,13 +972,114 @@ var init_key_store = __esm({
972
972
  }
973
973
  });
974
974
 
975
+ // src/sdk/ucan.ts
976
+ import { sign, extractPublicKeyFromSecretKey } from "@stablelib/ed25519";
977
+ import { toUint8Array } from "js-base64";
978
+ function base58btcEncode(bytes) {
979
+ const digits = [0];
980
+ for (const byte of bytes) {
981
+ let carry = byte;
982
+ for (let j = 0; j < digits.length; j++) {
983
+ carry += digits[j] << 8;
984
+ digits[j] = carry % 58;
985
+ carry = carry / 58 | 0;
986
+ }
987
+ while (carry > 0) {
988
+ digits.push(carry % 58);
989
+ carry = carry / 58 | 0;
990
+ }
991
+ }
992
+ let result = "";
993
+ for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {
994
+ result += BASE58_ALPHABET[0];
995
+ }
996
+ for (let i = digits.length - 1; i >= 0; i--) {
997
+ result += BASE58_ALPHABET[digits[i]];
998
+ }
999
+ return result;
1000
+ }
1001
+ function base64urlEncode(data) {
1002
+ const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
1003
+ let binary = "";
1004
+ for (let i = 0; i < bytes.length; i++) {
1005
+ binary += String.fromCharCode(bytes[i]);
1006
+ }
1007
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1008
+ }
1009
+ async function buildAndEncode(params) {
1010
+ const {
1011
+ issuer,
1012
+ audience,
1013
+ capabilities = [],
1014
+ lifetimeInSeconds = 30,
1015
+ expiration,
1016
+ notBefore,
1017
+ facts,
1018
+ proofs = []
1019
+ } = params;
1020
+ const currentTime = Math.floor(Date.now() / 1e3);
1021
+ const exp = expiration ?? currentTime + lifetimeInSeconds;
1022
+ const header = { alg: issuer.jwtAlg, typ: "JWT", ucv: "0.8.1" };
1023
+ const att = capabilities.map((cap) => ({
1024
+ with: `${cap.with.scheme}:${cap.with.hierPart}`,
1025
+ can: [cap.can.namespace, ...cap.can.segments].join("/")
1026
+ }));
1027
+ const payload = {
1028
+ iss: issuer.did(),
1029
+ aud: audience,
1030
+ exp,
1031
+ att,
1032
+ prf: proofs
1033
+ };
1034
+ if (notBefore !== void 0) payload.nbf = notBefore;
1035
+ if (facts !== void 0) payload.fct = facts;
1036
+ const encodedHeader = base64urlEncode(JSON.stringify(header));
1037
+ const encodedPayload = base64urlEncode(JSON.stringify(payload));
1038
+ const signedData = `${encodedHeader}.${encodedPayload}`;
1039
+ const sig = await issuer.sign(new TextEncoder().encode(signedData));
1040
+ const signature = base64urlEncode(sig);
1041
+ return `${signedData}.${signature}`;
1042
+ }
1043
+ var BASE58_ALPHABET, EDWARDS_DID_PREFIX, EdKeypair;
1044
+ var init_ucan = __esm({
1045
+ "src/sdk/ucan.ts"() {
1046
+ "use strict";
1047
+ init_esm_shims();
1048
+ BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
1049
+ EDWARDS_DID_PREFIX = new Uint8Array([237, 1]);
1050
+ EdKeypair = class _EdKeypair {
1051
+ jwtAlg = "EdDSA";
1052
+ secretKey;
1053
+ publicKey;
1054
+ constructor(secretKey, publicKey) {
1055
+ this.secretKey = secretKey;
1056
+ this.publicKey = publicKey;
1057
+ }
1058
+ static fromSecretKey(key) {
1059
+ const secretKey = toUint8Array(key);
1060
+ const publicKey = extractPublicKeyFromSecretKey(secretKey);
1061
+ return new _EdKeypair(secretKey, publicKey);
1062
+ }
1063
+ did() {
1064
+ const bytes = new Uint8Array(EDWARDS_DID_PREFIX.length + this.publicKey.length);
1065
+ bytes.set(EDWARDS_DID_PREFIX);
1066
+ bytes.set(this.publicKey, EDWARDS_DID_PREFIX.length);
1067
+ return "did:key:z" + base58btcEncode(bytes);
1068
+ }
1069
+ async sign(msg) {
1070
+ return sign(this.secretKey, msg);
1071
+ }
1072
+ };
1073
+ }
1074
+ });
1075
+
975
1076
  // src/sdk/auth-token-provider.ts
976
- import * as ucans from "@ucans/ucans";
977
1077
  var AuthTokenProvider;
978
1078
  var init_auth_token_provider = __esm({
979
1079
  "src/sdk/auth-token-provider.ts"() {
980
1080
  "use strict";
981
1081
  init_esm_shims();
1082
+ init_ucan();
982
1083
  AuthTokenProvider = class {
983
1084
  DEFAULT_OPTIONS = {
984
1085
  namespace: "file",
@@ -992,7 +1093,7 @@ var init_auth_token_provider = __esm({
992
1093
  this.portalAddress = portalAddress;
993
1094
  }
994
1095
  async getAuthToken(audienceDid, options = this.DEFAULT_OPTIONS) {
995
- const ucan = await ucans.build({
1096
+ return buildAndEncode({
996
1097
  audience: audienceDid,
997
1098
  issuer: this.keyPair,
998
1099
  lifetimeInSeconds: 7 * 86400,
@@ -1006,7 +1107,6 @@ var init_auth_token_provider = __esm({
1006
1107
  }
1007
1108
  ]
1008
1109
  });
1009
- return ucans.encode(ucan);
1010
1110
  }
1011
1111
  };
1012
1112
  }
@@ -2188,7 +2288,7 @@ import { derivePBKDF2Key, encryptAesCBC } from "@fileverse/crypto/kdf";
2188
2288
  import { secretBoxEncrypt } from "@fileverse/crypto/nacl";
2189
2289
  import hkdf from "futoin-hkdf";
2190
2290
  import tweetnacl from "tweetnacl";
2191
- import { fromUint8Array, toUint8Array } from "js-base64";
2291
+ import { fromUint8Array, toUint8Array as toUint8Array2 } from "js-base64";
2192
2292
  import { toAESKey, aesEncrypt } from "@fileverse/crypto/webcrypto";
2193
2293
  import axios from "axios";
2194
2294
  import { encodeFunctionData, parseEventLogs } from "viem";
@@ -2206,15 +2306,15 @@ var init_file_utils = __esm({
2206
2306
  });
2207
2307
  };
2208
2308
  getExistingEncryptionMaterial = async (existingEncryptedSecretKey, existingNonce, docId) => {
2209
- const derivedKey = await deriveKeyFromAg2Hash(docId, toUint8Array(existingNonce));
2309
+ const derivedKey = await deriveKeyFromAg2Hash(docId, toUint8Array2(existingNonce));
2210
2310
  const secretKey = tweetnacl.secretbox.open(
2211
- toUint8Array(existingEncryptedSecretKey),
2212
- toUint8Array(existingNonce),
2311
+ toUint8Array2(existingEncryptedSecretKey),
2312
+ toUint8Array2(existingNonce),
2213
2313
  derivedKey
2214
2314
  );
2215
2315
  return {
2216
2316
  encryptedSecretKey: existingEncryptedSecretKey,
2217
- nonce: toUint8Array(existingNonce),
2317
+ nonce: toUint8Array2(existingNonce),
2218
2318
  secretKey,
2219
2319
  derivedKey: new Uint8Array(derivedKey)
2220
2320
  };
@@ -2267,8 +2367,8 @@ var init_file_utils = __esm({
2267
2367
  const encryptedBlob = new Blob([ciphertext], { type: file2.type });
2268
2368
  const encryptedBlobWithAuthTagIv = await appendAuthTagIvToBlob(
2269
2369
  encryptedBlob,
2270
- toUint8Array(authTag),
2271
- toUint8Array(iv)
2370
+ toUint8Array2(authTag),
2371
+ toUint8Array2(iv)
2272
2372
  );
2273
2373
  return {
2274
2374
  encryptedFile: new File([encryptedBlobWithAuthTagIv], file2.name),
@@ -2314,7 +2414,7 @@ var init_file_utils = __esm({
2314
2414
  };
2315
2415
  };
2316
2416
  encryptTitleWithFileKey = async (args) => {
2317
- const key = await toAESKey(toUint8Array(args.key));
2417
+ const key = await toAESKey(toUint8Array2(args.key));
2318
2418
  if (!key) throw new Error("Key is undefined");
2319
2419
  const titleBytes = new TextEncoder().encode(args.title);
2320
2420
  const encryptedTitle = await aesEncrypt(key, titleBytes, "base64");
@@ -2432,7 +2532,7 @@ var init_file_utils = __esm({
2432
2532
  });
2433
2533
 
2434
2534
  // src/sdk/file-manager.ts
2435
- import { fromUint8Array as fromUint8Array2, toUint8Array as toUint8Array2 } from "js-base64";
2535
+ import { fromUint8Array as fromUint8Array2, toUint8Array as toUint8Array3 } from "js-base64";
2436
2536
  import { generateAESKey, exportAESKey } from "@fileverse/crypto/webcrypto";
2437
2537
  import { markdownToYjs } from "@fileverse/content-processor";
2438
2538
  var FileManager;
@@ -2453,8 +2553,8 @@ var init_file_manager = __esm({
2453
2553
  }
2454
2554
  createLocks(key, encryptedSecretKey, commentKey) {
2455
2555
  const appLock = {
2456
- lockedFileKey: this.keyStore.encryptData(toUint8Array2(key)),
2457
- lockedLinkKey: this.keyStore.encryptData(toUint8Array2(encryptedSecretKey)),
2556
+ lockedFileKey: this.keyStore.encryptData(toUint8Array3(key)),
2557
+ lockedLinkKey: this.keyStore.encryptData(toUint8Array3(encryptedSecretKey)),
2458
2558
  lockedChatKey: this.keyStore.encryptData(commentKey)
2459
2559
  };
2460
2560
  return { appLock, ownerLock: { ...appLock } };
@@ -2491,8 +2591,8 @@ var init_file_manager = __esm({
2491
2591
  console.log("Submitting add file trx");
2492
2592
  logger.debug(`Preparing to add file ${file2.ddocId}`);
2493
2593
  const encryptedSecretKey = file2.linkKey;
2494
- const nonce = toUint8Array2(file2.linkKeyNonce);
2495
- const secretKey = toUint8Array2(file2.secretKey);
2594
+ const nonce = toUint8Array3(file2.linkKeyNonce);
2595
+ const secretKey = toUint8Array3(file2.secretKey);
2496
2596
  console.log("Got encrypted secret key, nonce, and secret key");
2497
2597
  const yJSContent = markdownToYjs(file2.content);
2498
2598
  console.log("Generated yjs content");
@@ -2503,7 +2603,7 @@ var init_file_manager = __esm({
2503
2603
  console.log("Generated comment key");
2504
2604
  const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
2505
2605
  console.log("Built app lock and owner lock");
2506
- const linkLock = buildLinklock(secretKey, toUint8Array2(key), commentKey);
2606
+ const linkLock = buildLinklock(secretKey, toUint8Array3(key), commentKey);
2507
2607
  console.log("Built link lock");
2508
2608
  const encryptedTitle = await encryptTitleWithFileKey({
2509
2609
  title: file2.title || "Untitled",
@@ -2552,13 +2652,13 @@ var init_file_manager = __esm({
2552
2652
  async submitUpdateFile(file2) {
2553
2653
  logger.debug(`Submitting update for file ${file2.ddocId} with onChainFileId ${file2.onChainFileId}`);
2554
2654
  const encryptedSecretKey = file2.linkKey;
2555
- const nonce = toUint8Array2(file2.linkKeyNonce);
2556
- const secretKey = toUint8Array2(file2.secretKey);
2655
+ const nonce = toUint8Array3(file2.linkKeyNonce);
2656
+ const secretKey = toUint8Array3(file2.secretKey);
2557
2657
  const yjsContent = markdownToYjs(file2.content);
2558
2658
  const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
2559
- const commentKey = toUint8Array2(file2.commentKey);
2659
+ const commentKey = toUint8Array3(file2.commentKey);
2560
2660
  const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
2561
- const linkLock = buildLinklock(secretKey, toUint8Array2(key), commentKey);
2661
+ const linkLock = buildLinklock(secretKey, toUint8Array3(key), commentKey);
2562
2662
  const encryptedTitle = await encryptTitleWithFileKey({
2563
2663
  title: file2.title || "Untitled",
2564
2664
  key
@@ -2600,14 +2700,14 @@ var init_file_manager = __esm({
2600
2700
  async updateFile(file2) {
2601
2701
  logger.debug(`Updating file ${file2.ddocId} with onChainFileId ${file2.onChainFileId}`);
2602
2702
  const encryptedSecretKey = file2.linkKey;
2603
- const nonce = toUint8Array2(file2.linkKeyNonce);
2604
- const secretKey = toUint8Array2(file2.secretKey);
2703
+ const nonce = toUint8Array3(file2.linkKeyNonce);
2704
+ const secretKey = toUint8Array3(file2.secretKey);
2605
2705
  logger.debug(`Generating encrypted content file for file ${file2.ddocId} with onChainFileId ${file2.onChainFileId}`);
2606
2706
  const yjsContent = markdownToYjs(file2.content);
2607
2707
  const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
2608
- const commentKey = toUint8Array2(file2.commentKey);
2708
+ const commentKey = toUint8Array3(file2.commentKey);
2609
2709
  const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
2610
- const linkLock = buildLinklock(secretKey, toUint8Array2(key), commentKey);
2710
+ const linkLock = buildLinklock(secretKey, toUint8Array3(key), commentKey);
2611
2711
  const encryptedTitle = await encryptTitleWithFileKey({
2612
2712
  title: file2.title || "Untitled",
2613
2713
  key
@@ -2659,11 +2759,10 @@ var init_file_manager = __esm({
2659
2759
  });
2660
2760
 
2661
2761
  // src/domain/portal/publish.ts
2662
- import { fromUint8Array as fromUint8Array3, toUint8Array as toUint8Array3 } from "js-base64";
2762
+ import { fromUint8Array as fromUint8Array3, toUint8Array as toUint8Array4 } from "js-base64";
2663
2763
  import { stringToBytes } from "viem";
2664
2764
  import { deriveHKDFKey } from "@fileverse/crypto/kdf";
2665
2765
  import { generateKeyPairFromSeed } from "@stablelib/ed25519";
2666
- import * as ucans2 from "@ucans/ucans";
2667
2766
  async function getPortalData(fileId) {
2668
2767
  const file2 = await FilesModel.findByIdIncludingDeleted(fileId);
2669
2768
  if (!file2) {
@@ -2695,18 +2794,23 @@ var init_publish = __esm({
2695
2794
  init_infra();
2696
2795
  init_key_store();
2697
2796
  init_auth_token_provider();
2797
+ init_ucan();
2698
2798
  init_smart_agent();
2699
2799
  init_file_manager();
2700
2800
  init_config();
2701
2801
  init_pimlico_utils();
2702
2802
  createFileManager = async (portalSeed, portalAddress, ucanSecret, privateAccountKey) => {
2703
- const keyPair = ucans2.EdKeypair.fromSecretKey(fromUint8Array3(ucanSecret), {
2704
- exportable: true
2705
- });
2803
+ console.log("Creating file manager");
2804
+ const keyPair = EdKeypair.fromSecretKey(fromUint8Array3(ucanSecret));
2805
+ console.log("Created key pair");
2706
2806
  const authTokenProvider = new AuthTokenProvider(keyPair, portalAddress);
2707
- const keyStore = new KeyStore(toUint8Array3(portalSeed), portalAddress, authTokenProvider);
2807
+ console.log("Created auth token provider");
2808
+ const keyStore = new KeyStore(toUint8Array4(portalSeed), portalAddress, authTokenProvider);
2809
+ console.log("Created key store");
2708
2810
  const agentClient = new AgentClient(authTokenProvider);
2811
+ console.log("Created agent client");
2709
2812
  await agentClient.initializeAgentClient(privateAccountKey);
2813
+ console.log("Initialized agent client");
2710
2814
  return new FileManager(keyStore, agentClient);
2711
2815
  };
2712
2816
  executeOperation = async (fileManager, file2, operation) => {
@@ -2723,7 +2827,7 @@ var init_publish = __esm({
2723
2827
  handleExistingFileOp = async (fileId, operation) => {
2724
2828
  try {
2725
2829
  const { file: file2, portalDetails, apiKey } = await getPortalData(fileId);
2726
- const apiKeySeed = toUint8Array3(apiKey);
2830
+ const apiKeySeed = toUint8Array4(apiKey);
2727
2831
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
2728
2832
  const fileManager = await createFileManager(
2729
2833
  portalDetails.portalSeed,
@@ -2740,7 +2844,7 @@ var init_publish = __esm({
2740
2844
  handleNewFileOp = async (fileId) => {
2741
2845
  const { file: file2, portalDetails, apiKey } = await getPortalData(fileId);
2742
2846
  console.log("Got portal data");
2743
- const apiKeySeed = toUint8Array3(apiKey);
2847
+ const apiKeySeed = toUint8Array4(apiKey);
2744
2848
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
2745
2849
  console.log("Derived collaborator keys");
2746
2850
  const fileManager = await createFileManager(
@@ -2754,7 +2858,7 @@ var init_publish = __esm({
2754
2858
  };
2755
2859
  getProxyAuthParams = async (fileId) => {
2756
2860
  const { portalDetails, apiKey } = await getPortalData(fileId);
2757
- const apiKeySeed = toUint8Array3(apiKey);
2861
+ const apiKeySeed = toUint8Array4(apiKey);
2758
2862
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
2759
2863
  const fileManager = await createFileManager(
2760
2864
  portalDetails.portalSeed,
@@ -2766,7 +2870,7 @@ var init_publish = __esm({
2766
2870
  };
2767
2871
  submitUpdateFileOp = async (fileId) => {
2768
2872
  const { file: file2, portalDetails, apiKey } = await getPortalData(fileId);
2769
- const apiKeySeed = toUint8Array3(apiKey);
2873
+ const apiKeySeed = toUint8Array4(apiKey);
2770
2874
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
2771
2875
  const fileManager = await createFileManager(
2772
2876
  portalDetails.portalSeed,
@@ -2778,7 +2882,7 @@ var init_publish = __esm({
2778
2882
  };
2779
2883
  submitDeleteFileOp = async (fileId) => {
2780
2884
  const { file: file2, portalDetails, apiKey } = await getPortalData(fileId);
2781
- const apiKeySeed = toUint8Array3(apiKey);
2885
+ const apiKeySeed = toUint8Array4(apiKey);
2782
2886
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
2783
2887
  const fileManager = await createFileManager(
2784
2888
  portalDetails.portalSeed,
@@ -2790,7 +2894,7 @@ var init_publish = __esm({
2790
2894
  };
2791
2895
  resolveFileOp = async (fileId, userOpHash, eventType) => {
2792
2896
  const { portalDetails, apiKey } = await getPortalData(fileId);
2793
- const apiKeySeed = toUint8Array3(apiKey);
2897
+ const apiKeySeed = toUint8Array4(apiKey);
2794
2898
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
2795
2899
  const fileManager = await createFileManager(
2796
2900
  portalDetails.portalSeed,
@@ -2959,9 +3063,6 @@ var init_eventProcessor = __esm({
2959
3063
  const result = await handleNewFileOp(fileId);
2960
3064
  console.log("New file op submitted");
2961
3065
  await EventsModel.setEventPendingOp(event._id, result.userOpHash, {
2962
- linkKey: result.linkKey,
2963
- linkKeyNonce: result.linkKeyNonce,
2964
- commentKey: result.commentKey,
2965
3066
  metadata: result.metadata
2966
3067
  });
2967
3068
  logger.info(`File ${file2.ddocId} create op submitted (hash: ${result.userOpHash})`);
@@ -3950,11 +4051,11 @@ init_esm_shims();
3950
4051
  init_esm_shims();
3951
4052
  init_constants();
3952
4053
  import axios2 from "axios";
3953
- import { toUint8Array as toUint8Array4 } from "js-base64";
4054
+ import { toUint8Array as toUint8Array5 } from "js-base64";
3954
4055
  import { sha256 } from "viem";
3955
4056
  var fetchApiKeyData = async (apiKey) => {
3956
4057
  try {
3957
- const keyHash = sha256(toUint8Array4(apiKey));
4058
+ const keyHash = sha256(toUint8Array5(apiKey));
3958
4059
  const fullUrl = BASE_CONFIG.API_URL + `api-access/${keyHash}`;
3959
4060
  const response = await axios2.get(fullUrl);
3960
4061
  const { encryptedKeyMaterial, encryptedAppMaterial, id } = response.data;
@@ -3982,7 +4083,7 @@ init_saveApiKey();
3982
4083
  init_apikeys_model();
3983
4084
  init_infra();
3984
4085
  import { deriveHKDFKey as deriveHKDFKey2 } from "@fileverse/crypto/hkdf";
3985
- import { toUint8Array as toUint8Array5 } from "js-base64";
4086
+ import { toUint8Array as toUint8Array6 } from "js-base64";
3986
4087
  import { stringToBytes as stringToBytes2 } from "viem";
3987
4088
  import { toAESKey as toAESKey2, aesDecrypt } from "@fileverse/crypto/webcrypto";
3988
4089
  var SAVED_DATA_ENCRYPTION_KEY_INFO = "SAVED_DATA_ENCRYPTION_KEY";
@@ -4007,7 +4108,7 @@ async function initializeWithData(data) {
4007
4108
  }
4008
4109
  var getAesKeyFromApiKey = async (apiKey) => {
4009
4110
  const rawSecret = deriveHKDFKey2(
4010
- toUint8Array5(apiKey),
4111
+ toUint8Array6(apiKey),
4011
4112
  new Uint8Array([0]),
4012
4113
  stringToBytes2(SAVED_DATA_ENCRYPTION_KEY_INFO)
4013
4114
  );
@@ -4018,7 +4119,7 @@ var bytestToJSON = (bytes) => {
4018
4119
  };
4019
4120
  var decryptSavedData = async (apiKey, encryptedData) => {
4020
4121
  const aesKey = await getAesKeyFromApiKey(apiKey);
4021
- const decryptedBytes = await aesDecrypt(aesKey, toUint8Array5(encryptedData));
4122
+ const decryptedBytes = await aesDecrypt(aesKey, toUint8Array6(encryptedData));
4022
4123
  const data = bytestToJSON(decryptedBytes);
4023
4124
  return data;
4024
4125
  };
@@ -4240,7 +4341,7 @@ __export(external_exports, {
4240
4341
  e164: () => e1642,
4241
4342
  email: () => email2,
4242
4343
  emoji: () => emoji2,
4243
- encode: () => encode3,
4344
+ encode: () => encode2,
4244
4345
  encodeAsync: () => encodeAsync2,
4245
4346
  endsWith: () => _endsWith,
4246
4347
  enum: () => _enum2,
@@ -4614,7 +4715,7 @@ __export(core_exports2, {
4614
4715
  decode: () => decode,
4615
4716
  decodeAsync: () => decodeAsync,
4616
4717
  describe: () => describe,
4617
- encode: () => encode2,
4718
+ encode: () => encode,
4618
4719
  encodeAsync: () => encodeAsync,
4619
4720
  extractDefs: () => extractDefs,
4620
4721
  finalize: () => finalize,
@@ -5601,7 +5702,7 @@ var _encode = (_Err) => (schema, value, _ctx) => {
5601
5702
  const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
5602
5703
  return _parse(_Err)(schema, value, ctx);
5603
5704
  };
5604
- var encode2 = /* @__PURE__ */ _encode($ZodRealError);
5705
+ var encode = /* @__PURE__ */ _encode($ZodRealError);
5605
5706
  var _decode = (_Err) => (schema, value, _ctx) => {
5606
5707
  return _parse(_Err)(schema, value, _ctx);
5607
5708
  };
@@ -16365,7 +16466,7 @@ var parse2 = /* @__PURE__ */ _parse(ZodRealError);
16365
16466
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
16366
16467
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
16367
16468
  var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
16368
- var encode3 = /* @__PURE__ */ _encode(ZodRealError);
16469
+ var encode2 = /* @__PURE__ */ _encode(ZodRealError);
16369
16470
  var decode2 = /* @__PURE__ */ _decode(ZodRealError);
16370
16471
  var encodeAsync2 = /* @__PURE__ */ _encodeAsync(ZodRealError);
16371
16472
  var decodeAsync2 = /* @__PURE__ */ _decodeAsync(ZodRealError);
@@ -16409,7 +16510,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
16409
16510
  inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
16410
16511
  inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
16411
16512
  inst.spa = inst.safeParseAsync;
16412
- inst.encode = (data, params) => encode3(inst, data, params);
16513
+ inst.encode = (data, params) => encode2(inst, data, params);
16413
16514
  inst.decode = (data, params) => decode2(inst, data, params);
16414
16515
  inst.encodeAsync = async (data, params) => encodeAsync2(inst, data, params);
16415
16516
  inst.decodeAsync = async (data, params) => decodeAsync2(inst, data, params);