@fileverse/api 0.0.12 → 0.0.14

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.js CHANGED
@@ -1373,13 +1373,114 @@ var init_key_store = __esm({
1373
1373
  }
1374
1374
  });
1375
1375
 
1376
+ // src/sdk/ucan.ts
1377
+ import { sign, extractPublicKeyFromSecretKey } from "@stablelib/ed25519";
1378
+ import { toUint8Array } from "js-base64";
1379
+ function base58btcEncode(bytes) {
1380
+ const digits = [0];
1381
+ for (const byte of bytes) {
1382
+ let carry = byte;
1383
+ for (let j = 0; j < digits.length; j++) {
1384
+ carry += digits[j] << 8;
1385
+ digits[j] = carry % 58;
1386
+ carry = carry / 58 | 0;
1387
+ }
1388
+ while (carry > 0) {
1389
+ digits.push(carry % 58);
1390
+ carry = carry / 58 | 0;
1391
+ }
1392
+ }
1393
+ let result = "";
1394
+ for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {
1395
+ result += BASE58_ALPHABET[0];
1396
+ }
1397
+ for (let i = digits.length - 1; i >= 0; i--) {
1398
+ result += BASE58_ALPHABET[digits[i]];
1399
+ }
1400
+ return result;
1401
+ }
1402
+ function base64urlEncode(data) {
1403
+ const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
1404
+ let binary = "";
1405
+ for (let i = 0; i < bytes.length; i++) {
1406
+ binary += String.fromCharCode(bytes[i]);
1407
+ }
1408
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1409
+ }
1410
+ async function buildAndEncode(params) {
1411
+ const {
1412
+ issuer,
1413
+ audience,
1414
+ capabilities = [],
1415
+ lifetimeInSeconds = 30,
1416
+ expiration,
1417
+ notBefore,
1418
+ facts,
1419
+ proofs = []
1420
+ } = params;
1421
+ const currentTime = Math.floor(Date.now() / 1e3);
1422
+ const exp = expiration ?? currentTime + lifetimeInSeconds;
1423
+ const header = { alg: issuer.jwtAlg, typ: "JWT", ucv: "0.8.1" };
1424
+ const att = capabilities.map((cap) => ({
1425
+ with: `${cap.with.scheme}:${cap.with.hierPart}`,
1426
+ can: [cap.can.namespace, ...cap.can.segments].join("/")
1427
+ }));
1428
+ const payload = {
1429
+ iss: issuer.did(),
1430
+ aud: audience,
1431
+ exp,
1432
+ att,
1433
+ prf: proofs
1434
+ };
1435
+ if (notBefore !== void 0) payload.nbf = notBefore;
1436
+ if (facts !== void 0) payload.fct = facts;
1437
+ const encodedHeader = base64urlEncode(JSON.stringify(header));
1438
+ const encodedPayload = base64urlEncode(JSON.stringify(payload));
1439
+ const signedData = `${encodedHeader}.${encodedPayload}`;
1440
+ const sig = await issuer.sign(new TextEncoder().encode(signedData));
1441
+ const signature = base64urlEncode(sig);
1442
+ return `${signedData}.${signature}`;
1443
+ }
1444
+ var BASE58_ALPHABET, EDWARDS_DID_PREFIX, EdKeypair;
1445
+ var init_ucan = __esm({
1446
+ "src/sdk/ucan.ts"() {
1447
+ "use strict";
1448
+ init_esm_shims();
1449
+ BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
1450
+ EDWARDS_DID_PREFIX = new Uint8Array([237, 1]);
1451
+ EdKeypair = class _EdKeypair {
1452
+ jwtAlg = "EdDSA";
1453
+ secretKey;
1454
+ publicKey;
1455
+ constructor(secretKey, publicKey) {
1456
+ this.secretKey = secretKey;
1457
+ this.publicKey = publicKey;
1458
+ }
1459
+ static fromSecretKey(key) {
1460
+ const secretKey = toUint8Array(key);
1461
+ const publicKey = extractPublicKeyFromSecretKey(secretKey);
1462
+ return new _EdKeypair(secretKey, publicKey);
1463
+ }
1464
+ did() {
1465
+ const bytes = new Uint8Array(EDWARDS_DID_PREFIX.length + this.publicKey.length);
1466
+ bytes.set(EDWARDS_DID_PREFIX);
1467
+ bytes.set(this.publicKey, EDWARDS_DID_PREFIX.length);
1468
+ return "did:key:z" + base58btcEncode(bytes);
1469
+ }
1470
+ async sign(msg) {
1471
+ return sign(this.secretKey, msg);
1472
+ }
1473
+ };
1474
+ }
1475
+ });
1476
+
1376
1477
  // src/sdk/auth-token-provider.ts
1377
- import * as ucans from "@ucans/ucans";
1378
1478
  var AuthTokenProvider;
1379
1479
  var init_auth_token_provider = __esm({
1380
1480
  "src/sdk/auth-token-provider.ts"() {
1381
1481
  "use strict";
1382
1482
  init_esm_shims();
1483
+ init_ucan();
1383
1484
  AuthTokenProvider = class {
1384
1485
  DEFAULT_OPTIONS = {
1385
1486
  namespace: "file",
@@ -1393,7 +1494,7 @@ var init_auth_token_provider = __esm({
1393
1494
  this.portalAddress = portalAddress;
1394
1495
  }
1395
1496
  async getAuthToken(audienceDid, options = this.DEFAULT_OPTIONS) {
1396
- const ucan = await ucans.build({
1497
+ return buildAndEncode({
1397
1498
  audience: audienceDid,
1398
1499
  issuer: this.keyPair,
1399
1500
  lifetimeInSeconds: 7 * 86400,
@@ -1407,7 +1508,6 @@ var init_auth_token_provider = __esm({
1407
1508
  }
1408
1509
  ]
1409
1510
  });
1410
- return ucans.encode(ucan);
1411
1511
  }
1412
1512
  };
1413
1513
  }
@@ -2581,7 +2681,7 @@ import { derivePBKDF2Key, encryptAesCBC } from "@fileverse/crypto/kdf";
2581
2681
  import { secretBoxEncrypt } from "@fileverse/crypto/nacl";
2582
2682
  import hkdf from "futoin-hkdf";
2583
2683
  import tweetnacl from "tweetnacl";
2584
- import { fromUint8Array, toUint8Array } from "js-base64";
2684
+ import { fromUint8Array, toUint8Array as toUint8Array2 } from "js-base64";
2585
2685
  import { toAESKey, aesEncrypt } from "@fileverse/crypto/webcrypto";
2586
2686
  import axios from "axios";
2587
2687
  import { encodeFunctionData, parseEventLogs } from "viem";
@@ -2599,15 +2699,15 @@ var init_file_utils = __esm({
2599
2699
  });
2600
2700
  };
2601
2701
  getExistingEncryptionMaterial = async (existingEncryptedSecretKey, existingNonce, docId) => {
2602
- const derivedKey = await deriveKeyFromAg2Hash(docId, toUint8Array(existingNonce));
2702
+ const derivedKey = await deriveKeyFromAg2Hash(docId, toUint8Array2(existingNonce));
2603
2703
  const secretKey = tweetnacl.secretbox.open(
2604
- toUint8Array(existingEncryptedSecretKey),
2605
- toUint8Array(existingNonce),
2704
+ toUint8Array2(existingEncryptedSecretKey),
2705
+ toUint8Array2(existingNonce),
2606
2706
  derivedKey
2607
2707
  );
2608
2708
  return {
2609
2709
  encryptedSecretKey: existingEncryptedSecretKey,
2610
- nonce: toUint8Array(existingNonce),
2710
+ nonce: toUint8Array2(existingNonce),
2611
2711
  secretKey,
2612
2712
  derivedKey: new Uint8Array(derivedKey)
2613
2713
  };
@@ -2660,8 +2760,8 @@ var init_file_utils = __esm({
2660
2760
  const encryptedBlob = new Blob([ciphertext], { type: file2.type });
2661
2761
  const encryptedBlobWithAuthTagIv = await appendAuthTagIvToBlob(
2662
2762
  encryptedBlob,
2663
- toUint8Array(authTag),
2664
- toUint8Array(iv)
2763
+ toUint8Array2(authTag),
2764
+ toUint8Array2(iv)
2665
2765
  );
2666
2766
  return {
2667
2767
  encryptedFile: new File([encryptedBlobWithAuthTagIv], file2.name),
@@ -2707,7 +2807,7 @@ var init_file_utils = __esm({
2707
2807
  };
2708
2808
  };
2709
2809
  encryptTitleWithFileKey = async (args) => {
2710
- const key = await toAESKey(toUint8Array(args.key));
2810
+ const key = await toAESKey(toUint8Array2(args.key));
2711
2811
  if (!key) throw new Error("Key is undefined");
2712
2812
  const titleBytes = new TextEncoder().encode(args.title);
2713
2813
  const encryptedTitle = await aesEncrypt(key, titleBytes, "base64");
@@ -2825,7 +2925,7 @@ var init_file_utils = __esm({
2825
2925
  });
2826
2926
 
2827
2927
  // src/sdk/file-manager.ts
2828
- import { fromUint8Array as fromUint8Array2, toUint8Array as toUint8Array2 } from "js-base64";
2928
+ import { fromUint8Array as fromUint8Array2, toUint8Array as toUint8Array3 } from "js-base64";
2829
2929
  import { generateAESKey, exportAESKey } from "@fileverse/crypto/webcrypto";
2830
2930
  import { markdownToYjs } from "@fileverse/content-processor";
2831
2931
  var FileManager;
@@ -2846,8 +2946,8 @@ var init_file_manager = __esm({
2846
2946
  }
2847
2947
  createLocks(key, encryptedSecretKey, commentKey) {
2848
2948
  const appLock = {
2849
- lockedFileKey: this.keyStore.encryptData(toUint8Array2(key)),
2850
- lockedLinkKey: this.keyStore.encryptData(toUint8Array2(encryptedSecretKey)),
2949
+ lockedFileKey: this.keyStore.encryptData(toUint8Array3(key)),
2950
+ lockedLinkKey: this.keyStore.encryptData(toUint8Array3(encryptedSecretKey)),
2851
2951
  lockedChatKey: this.keyStore.encryptData(commentKey)
2852
2952
  };
2853
2953
  return { appLock, ownerLock: { ...appLock } };
@@ -2881,20 +2981,28 @@ var init_file_manager = __esm({
2881
2981
  return this.agentClient.getAuthParams();
2882
2982
  }
2883
2983
  async submitAddFileTrx(file2) {
2984
+ console.log("Submitting add file trx");
2884
2985
  logger.debug(`Preparing to add file ${file2.ddocId}`);
2885
2986
  const encryptedSecretKey = file2.linkKey;
2886
- const nonce = toUint8Array2(file2.linkKeyNonce);
2887
- const secretKey = toUint8Array2(file2.secretKey);
2987
+ const nonce = toUint8Array3(file2.linkKeyNonce);
2988
+ const secretKey = toUint8Array3(file2.secretKey);
2989
+ console.log("Got encrypted secret key, nonce, and secret key");
2888
2990
  const yJSContent = markdownToYjs(file2.content);
2991
+ console.log("Generated yjs content");
2889
2992
  const { encryptedFile, key } = await createEncryptedContentFile(yJSContent);
2993
+ console.log("Generated encrypted content file");
2890
2994
  logger.debug(`Generated encrypted content file for file ${file2.ddocId}`);
2891
2995
  const commentKey = await exportAESKey(await generateAESKey(128));
2996
+ console.log("Generated comment key");
2892
2997
  const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
2893
- const linkLock = buildLinklock(secretKey, toUint8Array2(key), commentKey);
2998
+ console.log("Built app lock and owner lock");
2999
+ const linkLock = buildLinklock(secretKey, toUint8Array3(key), commentKey);
3000
+ console.log("Built link lock");
2894
3001
  const encryptedTitle = await encryptTitleWithFileKey({
2895
3002
  title: file2.title || "Untitled",
2896
3003
  key
2897
3004
  });
3005
+ console.log("Built encrypted title");
2898
3006
  const metadata = buildFileMetadata({
2899
3007
  encryptedTitle,
2900
3008
  encryptedFileSize: encryptedFile.size,
@@ -2904,11 +3012,15 @@ var init_file_manager = __esm({
2904
3012
  nonce: fromUint8Array2(nonce),
2905
3013
  owner: this.agentClient.getAgentAddress()
2906
3014
  });
3015
+ console.log("Built metadata");
2907
3016
  const authParams = await this.getAuthParams();
3017
+ console.log("Got auth params");
3018
+ console.log("Uploading files to IPFS");
2908
3019
  const { metadataHash, contentHash, gateHash } = await uploadAllFilesToIPFS(
2909
3020
  { metadata, encryptedFile, linkLock, ddocId: file2.ddocId },
2910
3021
  authParams
2911
3022
  );
3023
+ console.log("Uploaded files to IPFS");
2912
3024
  logger.debug(`Uploaded files to IPFS for file ${file2.ddocId}`);
2913
3025
  const callData = prepareCallData({
2914
3026
  metadataHash,
@@ -2917,8 +3029,10 @@ var init_file_manager = __esm({
2917
3029
  appFileId: file2.ddocId,
2918
3030
  fileId: file2.fileId
2919
3031
  });
3032
+ console.log("Prepared call data");
2920
3033
  logger.debug(`Prepared call data for file ${file2.ddocId}`);
2921
3034
  const userOpHash = await this.sendFileOperation(callData);
3035
+ console.log("Submitted user op");
2922
3036
  logger.debug(`Submitted user op for file ${file2.ddocId}`);
2923
3037
  return {
2924
3038
  userOpHash,
@@ -2931,13 +3045,13 @@ var init_file_manager = __esm({
2931
3045
  async submitUpdateFile(file2) {
2932
3046
  logger.debug(`Submitting update for file ${file2.ddocId} with onChainFileId ${file2.onChainFileId}`);
2933
3047
  const encryptedSecretKey = file2.linkKey;
2934
- const nonce = toUint8Array2(file2.linkKeyNonce);
2935
- const secretKey = toUint8Array2(file2.secretKey);
3048
+ const nonce = toUint8Array3(file2.linkKeyNonce);
3049
+ const secretKey = toUint8Array3(file2.secretKey);
2936
3050
  const yjsContent = markdownToYjs(file2.content);
2937
3051
  const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
2938
- const commentKey = toUint8Array2(file2.commentKey);
3052
+ const commentKey = toUint8Array3(file2.commentKey);
2939
3053
  const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
2940
- const linkLock = buildLinklock(secretKey, toUint8Array2(key), commentKey);
3054
+ const linkLock = buildLinklock(secretKey, toUint8Array3(key), commentKey);
2941
3055
  const encryptedTitle = await encryptTitleWithFileKey({
2942
3056
  title: file2.title || "Untitled",
2943
3057
  key
@@ -2979,14 +3093,14 @@ var init_file_manager = __esm({
2979
3093
  async updateFile(file2) {
2980
3094
  logger.debug(`Updating file ${file2.ddocId} with onChainFileId ${file2.onChainFileId}`);
2981
3095
  const encryptedSecretKey = file2.linkKey;
2982
- const nonce = toUint8Array2(file2.linkKeyNonce);
2983
- const secretKey = toUint8Array2(file2.secretKey);
3096
+ const nonce = toUint8Array3(file2.linkKeyNonce);
3097
+ const secretKey = toUint8Array3(file2.secretKey);
2984
3098
  logger.debug(`Generating encrypted content file for file ${file2.ddocId} with onChainFileId ${file2.onChainFileId}`);
2985
3099
  const yjsContent = markdownToYjs(file2.content);
2986
3100
  const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
2987
- const commentKey = toUint8Array2(file2.commentKey);
3101
+ const commentKey = toUint8Array3(file2.commentKey);
2988
3102
  const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
2989
- const linkLock = buildLinklock(secretKey, toUint8Array2(key), commentKey);
3103
+ const linkLock = buildLinklock(secretKey, toUint8Array3(key), commentKey);
2990
3104
  const encryptedTitle = await encryptTitleWithFileKey({
2991
3105
  title: file2.title || "Untitled",
2992
3106
  key
@@ -3038,11 +3152,10 @@ var init_file_manager = __esm({
3038
3152
  });
3039
3153
 
3040
3154
  // src/domain/portal/publish.ts
3041
- import { fromUint8Array as fromUint8Array3, toUint8Array as toUint8Array3 } from "js-base64";
3155
+ import { fromUint8Array as fromUint8Array3, toUint8Array as toUint8Array4 } from "js-base64";
3042
3156
  import { stringToBytes } from "viem";
3043
3157
  import { deriveHKDFKey } from "@fileverse/crypto/kdf";
3044
3158
  import { generateKeyPairFromSeed } from "@stablelib/ed25519";
3045
- import * as ucans2 from "@ucans/ucans";
3046
3159
  async function getPortalData(fileId) {
3047
3160
  const file2 = await FilesModel.findByIdIncludingDeleted(fileId);
3048
3161
  if (!file2) {
@@ -3074,16 +3187,15 @@ var init_publish = __esm({
3074
3187
  init_infra();
3075
3188
  init_key_store();
3076
3189
  init_auth_token_provider();
3190
+ init_ucan();
3077
3191
  init_smart_agent();
3078
3192
  init_file_manager();
3079
3193
  init_config();
3080
3194
  init_pimlico_utils();
3081
3195
  createFileManager = async (portalSeed, portalAddress, ucanSecret, privateAccountKey) => {
3082
- const keyPair = ucans2.EdKeypair.fromSecretKey(fromUint8Array3(ucanSecret), {
3083
- exportable: true
3084
- });
3196
+ const keyPair = EdKeypair.fromSecretKey(fromUint8Array3(ucanSecret));
3085
3197
  const authTokenProvider = new AuthTokenProvider(keyPair, portalAddress);
3086
- const keyStore = new KeyStore(toUint8Array3(portalSeed), portalAddress, authTokenProvider);
3198
+ const keyStore = new KeyStore(toUint8Array4(portalSeed), portalAddress, authTokenProvider);
3087
3199
  const agentClient = new AgentClient(authTokenProvider);
3088
3200
  await agentClient.initializeAgentClient(privateAccountKey);
3089
3201
  return new FileManager(keyStore, agentClient);
@@ -3102,7 +3214,7 @@ var init_publish = __esm({
3102
3214
  handleExistingFileOp = async (fileId, operation) => {
3103
3215
  try {
3104
3216
  const { file: file2, portalDetails, apiKey } = await getPortalData(fileId);
3105
- const apiKeySeed = toUint8Array3(apiKey);
3217
+ const apiKeySeed = toUint8Array4(apiKey);
3106
3218
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
3107
3219
  const fileManager = await createFileManager(
3108
3220
  portalDetails.portalSeed,
@@ -3118,19 +3230,22 @@ var init_publish = __esm({
3118
3230
  };
3119
3231
  handleNewFileOp = async (fileId) => {
3120
3232
  const { file: file2, portalDetails, apiKey } = await getPortalData(fileId);
3121
- const apiKeySeed = toUint8Array3(apiKey);
3233
+ console.log("Got portal data");
3234
+ const apiKeySeed = toUint8Array4(apiKey);
3122
3235
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
3236
+ console.log("Derived collaborator keys");
3123
3237
  const fileManager = await createFileManager(
3124
3238
  portalDetails.portalSeed,
3125
3239
  portalDetails.portalAddress,
3126
3240
  ucanSecret,
3127
3241
  privateAccountKey
3128
3242
  );
3243
+ console.log("Created file manager");
3129
3244
  return fileManager.submitAddFileTrx(file2);
3130
3245
  };
3131
3246
  getProxyAuthParams = async (fileId) => {
3132
3247
  const { portalDetails, apiKey } = await getPortalData(fileId);
3133
- const apiKeySeed = toUint8Array3(apiKey);
3248
+ const apiKeySeed = toUint8Array4(apiKey);
3134
3249
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
3135
3250
  const fileManager = await createFileManager(
3136
3251
  portalDetails.portalSeed,
@@ -3736,11 +3851,11 @@ init_esm_shims();
3736
3851
  init_esm_shims();
3737
3852
  init_constants();
3738
3853
  import axios2 from "axios";
3739
- import { toUint8Array as toUint8Array4 } from "js-base64";
3854
+ import { toUint8Array as toUint8Array5 } from "js-base64";
3740
3855
  import { sha256 } from "viem";
3741
3856
  var fetchApiKeyData = async (apiKey) => {
3742
3857
  try {
3743
- const keyHash = sha256(toUint8Array4(apiKey));
3858
+ const keyHash = sha256(toUint8Array5(apiKey));
3744
3859
  const fullUrl = BASE_CONFIG.API_URL + `api-access/${keyHash}`;
3745
3860
  const response = await axios2.get(fullUrl);
3746
3861
  const { encryptedKeyMaterial, encryptedAppMaterial, id } = response.data;
@@ -3768,7 +3883,7 @@ init_saveApiKey();
3768
3883
  init_apikeys_model();
3769
3884
  init_infra();
3770
3885
  import { deriveHKDFKey as deriveHKDFKey2 } from "@fileverse/crypto/hkdf";
3771
- import { toUint8Array as toUint8Array5 } from "js-base64";
3886
+ import { toUint8Array as toUint8Array6 } from "js-base64";
3772
3887
  import { stringToBytes as stringToBytes2 } from "viem";
3773
3888
  import { toAESKey as toAESKey2, aesDecrypt } from "@fileverse/crypto/webcrypto";
3774
3889
  var SAVED_DATA_ENCRYPTION_KEY_INFO = "SAVED_DATA_ENCRYPTION_KEY";
@@ -3793,7 +3908,7 @@ async function initializeWithData(data) {
3793
3908
  }
3794
3909
  var getAesKeyFromApiKey = async (apiKey) => {
3795
3910
  const rawSecret = deriveHKDFKey2(
3796
- toUint8Array5(apiKey),
3911
+ toUint8Array6(apiKey),
3797
3912
  new Uint8Array([0]),
3798
3913
  stringToBytes2(SAVED_DATA_ENCRYPTION_KEY_INFO)
3799
3914
  );
@@ -3804,7 +3919,7 @@ var bytestToJSON = (bytes) => {
3804
3919
  };
3805
3920
  var decryptSavedData = async (apiKey, encryptedData) => {
3806
3921
  const aesKey = await getAesKeyFromApiKey(apiKey);
3807
- const decryptedBytes = await aesDecrypt(aesKey, toUint8Array5(encryptedData));
3922
+ const decryptedBytes = await aesDecrypt(aesKey, toUint8Array6(encryptedData));
3808
3923
  const data = bytestToJSON(decryptedBytes);
3809
3924
  return data;
3810
3925
  };
@@ -4728,7 +4843,7 @@ __export(external_exports, {
4728
4843
  e164: () => e1642,
4729
4844
  email: () => email2,
4730
4845
  emoji: () => emoji2,
4731
- encode: () => encode3,
4846
+ encode: () => encode2,
4732
4847
  encodeAsync: () => encodeAsync2,
4733
4848
  endsWith: () => _endsWith,
4734
4849
  enum: () => _enum2,
@@ -5102,7 +5217,7 @@ __export(core_exports2, {
5102
5217
  decode: () => decode,
5103
5218
  decodeAsync: () => decodeAsync,
5104
5219
  describe: () => describe,
5105
- encode: () => encode2,
5220
+ encode: () => encode,
5106
5221
  encodeAsync: () => encodeAsync,
5107
5222
  extractDefs: () => extractDefs,
5108
5223
  finalize: () => finalize,
@@ -6089,7 +6204,7 @@ var _encode = (_Err) => (schema, value, _ctx) => {
6089
6204
  const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
6090
6205
  return _parse(_Err)(schema, value, ctx);
6091
6206
  };
6092
- var encode2 = /* @__PURE__ */ _encode($ZodRealError);
6207
+ var encode = /* @__PURE__ */ _encode($ZodRealError);
6093
6208
  var _decode = (_Err) => (schema, value, _ctx) => {
6094
6209
  return _parse(_Err)(schema, value, _ctx);
6095
6210
  };
@@ -16853,7 +16968,7 @@ var parse2 = /* @__PURE__ */ _parse(ZodRealError);
16853
16968
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
16854
16969
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
16855
16970
  var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
16856
- var encode3 = /* @__PURE__ */ _encode(ZodRealError);
16971
+ var encode2 = /* @__PURE__ */ _encode(ZodRealError);
16857
16972
  var decode2 = /* @__PURE__ */ _decode(ZodRealError);
16858
16973
  var encodeAsync2 = /* @__PURE__ */ _encodeAsync(ZodRealError);
16859
16974
  var decodeAsync2 = /* @__PURE__ */ _decodeAsync(ZodRealError);
@@ -16897,7 +17012,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
16897
17012
  inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
16898
17013
  inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
16899
17014
  inst.spa = inst.safeParseAsync;
16900
- inst.encode = (data, params) => encode3(inst, data, params);
17015
+ inst.encode = (data, params) => encode2(inst, data, params);
16901
17016
  inst.decode = (data, params) => decode2(inst, data, params);
16902
17017
  inst.encodeAsync = async (data, params) => encodeAsync2(inst, data, params);
16903
17018
  inst.decodeAsync = async (data, params) => decodeAsync2(inst, data, params);