@solana/web3.js 1.94.0 → 1.95.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.
package/lib/index.iife.js CHANGED
@@ -2842,9 +2842,9 @@ var solanaWeb3 = (function (exports) {
2842
2842
  // This is OK: `abstract` directory does not use noble-hashes.
2843
2843
  // User may opt-in into using different hashing library. This way, noble-hashes
2844
2844
  // won't be included into their bundle.
2845
- const _0n$5 = BigInt(0);
2846
- const _1n$7 = BigInt(1);
2847
- const _2n$5 = BigInt(2);
2845
+ const _0n$5 = /* @__PURE__ */ BigInt(0);
2846
+ const _1n$7 = /* @__PURE__ */ BigInt(1);
2847
+ const _2n$5 = /* @__PURE__ */ BigInt(2);
2848
2848
  function isBytes(a) {
2849
2849
  return (a instanceof Uint8Array ||
2850
2850
  (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
@@ -3156,7 +3156,7 @@ var solanaWeb3 = (function (exports) {
3156
3156
  // prettier-ignore
3157
3157
  const _0n$4 = BigInt(0), _1n$6 = BigInt(1), _2n$4 = BigInt(2), _3n$1 = BigInt(3);
3158
3158
  // prettier-ignore
3159
- const _4n = BigInt(4), _5n$1 = BigInt(5), _8n$1 = BigInt(8);
3159
+ const _4n = BigInt(4), _5n$1 = BigInt(5), _8n$2 = BigInt(8);
3160
3160
  // prettier-ignore
3161
3161
  BigInt(9); BigInt(16);
3162
3162
  // Calculates a modulo b
@@ -3302,8 +3302,8 @@ var solanaWeb3 = (function (exports) {
3302
3302
  };
3303
3303
  }
3304
3304
  // Atkin algorithm for q ≡ 5 (mod 8), https://eprint.iacr.org/2012/685.pdf (page 10)
3305
- if (P % _8n$1 === _5n$1) {
3306
- const c1 = (P - _5n$1) / _8n$1;
3305
+ if (P % _8n$2 === _5n$1) {
3306
+ const c1 = (P - _5n$1) / _8n$2;
3307
3307
  return function sqrt5mod8(Fp, n) {
3308
3308
  const n2 = Fp.mul(n, _2n$4);
3309
3309
  const v = Fp.pow(n2, c1);
@@ -3456,12 +3456,6 @@ var solanaWeb3 = (function (exports) {
3456
3456
  });
3457
3457
  return Object.freeze(f);
3458
3458
  }
3459
- function FpSqrtEven(Fp, elm) {
3460
- if (!Fp.isOdd)
3461
- throw new Error(`Field doesn't have isOdd`);
3462
- const root = Fp.sqrt(elm);
3463
- return Fp.isOdd(root) ? Fp.neg(root) : root;
3464
- }
3465
3459
  /**
3466
3460
  * Returns total number of bytes consumed by the field element.
3467
3461
  * For example, 32 bytes for usual 256-bit weierstrass curve.
@@ -3669,7 +3663,7 @@ var solanaWeb3 = (function (exports) {
3669
3663
  // Twisted Edwards curve. The formula is: ax² + y² = 1 + dx²y²
3670
3664
  // Be friendly to bad ECMAScript parsers by not using bigint literals
3671
3665
  // prettier-ignore
3672
- const _0n$2 = BigInt(0), _1n$4 = BigInt(1), _2n$3 = BigInt(2), _8n = BigInt(8);
3666
+ const _0n$2 = BigInt(0), _1n$4 = BigInt(1), _2n$3 = BigInt(2), _8n$1 = BigInt(8);
3673
3667
  // verification rule is either zip215 or rfc8032 / nist186-5. Consult fromHex:
3674
3668
  const VERIFY_DEFAULT = { zip215: true };
3675
3669
  function validateOpts$1(curve) {
@@ -3918,7 +3912,7 @@ var solanaWeb3 = (function (exports) {
3918
3912
  const { ex: x, ey: y, ez: z } = this;
3919
3913
  const is0 = this.is0();
3920
3914
  if (iz == null)
3921
- iz = is0 ? _8n : Fp.inv(z); // 8 was chosen arbitrarily
3915
+ iz = is0 ? _8n$1 : Fp.inv(z); // 8 was chosen arbitrarily
3922
3916
  const ax = modP(x * iz);
3923
3917
  const ay = modP(y * iz);
3924
3918
  const zz = modP(z * iz);
@@ -4093,12 +4087,14 @@ var solanaWeb3 = (function (exports) {
4093
4087
  */
4094
4088
  const ED25519_P = BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819949');
4095
4089
  // √(-1) aka √(a) aka 2^((p-1)/4)
4096
- const ED25519_SQRT_M1 = BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');
4090
+ const ED25519_SQRT_M1 = /* @__PURE__ */ BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');
4097
4091
  // prettier-ignore
4098
- BigInt(0); const _1n$3 = BigInt(1), _2n$2 = BigInt(2), _5n = BigInt(5);
4092
+ BigInt(0); const _1n$3 = BigInt(1), _2n$2 = BigInt(2); BigInt(3);
4099
4093
  // prettier-ignore
4100
- const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);
4094
+ const _5n = BigInt(5), _8n = BigInt(8);
4101
4095
  function ed25519_pow_2_252_3(x) {
4096
+ // prettier-ignore
4097
+ const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);
4102
4098
  const P = ED25519_P;
4103
4099
  const x2 = (x * x) % P;
4104
4100
  const b2 = (x2 * x) % P; // x^3, 11
@@ -4147,8 +4143,8 @@ var solanaWeb3 = (function (exports) {
4147
4143
  x = mod(-x, P);
4148
4144
  return { isValid: useRoot1 || useRoot2, value: x };
4149
4145
  }
4150
- const Fp$1 = Field(ED25519_P, undefined, true);
4151
- const ed25519Defaults = {
4146
+ const Fp$1 = /* @__PURE__ */ (() => Field(ED25519_P, undefined, true))();
4147
+ const ed25519Defaults = /* @__PURE__ */ (() => ({
4152
4148
  // Param: a
4153
4149
  a: BigInt(-1), // Fp.create(-1) is proper; our way still works and is faster
4154
4150
  // d is equal to -121665/121666 over finite field.
@@ -4160,7 +4156,7 @@ var solanaWeb3 = (function (exports) {
4160
4156
  // 2n**252n + 27742317777372353535851937790883648493n;
4161
4157
  n: BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989'),
4162
4158
  // Cofactor
4163
- h: BigInt(8),
4159
+ h: _8n,
4164
4160
  // Base point (x, y) aka generator point
4165
4161
  Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'),
4166
4162
  Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'),
@@ -4171,40 +4167,8 @@ var solanaWeb3 = (function (exports) {
4171
4167
  // Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.
4172
4168
  // Constant-time, u/√v
4173
4169
  uvRatio,
4174
- };
4175
- const ed25519 = /* @__PURE__ */ twistedEdwards(ed25519Defaults);
4176
- function ed25519_domain(data, ctx, phflag) {
4177
- if (ctx.length > 255)
4178
- throw new Error('Context is too big');
4179
- return concatBytes$1(utf8ToBytes$1('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
4180
- }
4181
- /* @__PURE__ */ twistedEdwards({
4182
- ...ed25519Defaults,
4183
- domain: ed25519_domain,
4184
- });
4185
- /* @__PURE__ */ twistedEdwards({
4186
- ...ed25519Defaults,
4187
- domain: ed25519_domain,
4188
- prehash: sha512,
4189
- });
4190
- // Hash To Curve Elligator2 Map (NOTE: different from ristretto255 elligator)
4191
- // NOTE: very important part is usage of FpSqrtEven for ELL2_C1_EDWARDS, since
4192
- // SageMath returns different root first and everything falls apart
4193
- const ELL2_C1 = (Fp$1.ORDER + BigInt(3)) / BigInt(8); // 1. c1 = (q + 3) / 8 # Integer arithmetic
4194
- Fp$1.pow(_2n$2, ELL2_C1); // 2. c2 = 2^c1
4195
- Fp$1.sqrt(Fp$1.neg(Fp$1.ONE)); // 3. c3 = sqrt(-1)
4196
- (Fp$1.ORDER - BigInt(5)) / BigInt(8); // 4. c4 = (q - 5) / 8 # Integer arithmetic
4197
- BigInt(486662);
4198
- FpSqrtEven(Fp$1, Fp$1.neg(BigInt(486664))); // sgn0(c1) MUST equal 0
4199
- // √(ad - 1)
4200
- BigInt('25063068953384623474111414158702152701244531502492656460079210482610430750235');
4201
- // 1 / √(a-d)
4202
- BigInt('54469307008909316920995813868745141605393597292927456921205312896311721017578');
4203
- // 1-d²
4204
- BigInt('1159843021668779879193775521855586647937357759715417654439879720876111806838');
4205
- // (d-1)²
4206
- BigInt('40440834346308536858101042469323190826248399146238708352240133220865137265952');
4207
- BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
4170
+ }))();
4171
+ const ed25519 = /* @__PURE__ */ (() => twistedEdwards(ed25519Defaults))();
4208
4172
 
4209
4173
  /**
4210
4174
  * A 64 byte secret key, the first 32 bytes of which is the
@@ -14776,6 +14740,12 @@ var solanaWeb3 = (function (exports) {
14776
14740
  function isObject(x) {
14777
14741
  return typeof x === 'object' && x != null;
14778
14742
  }
14743
+ /**
14744
+ * Check if a value is a non-array object.
14745
+ */
14746
+ function isNonArrayObject(x) {
14747
+ return isObject(x) && !Array.isArray(x);
14748
+ }
14779
14749
  /**
14780
14750
  * Return a value as a printable string.
14781
14751
  */
@@ -14840,20 +14810,9 @@ var solanaWeb3 = (function (exports) {
14840
14810
  */
14841
14811
  function* run(value, struct, options = {}) {
14842
14812
  const { path = [], branch = [value], coerce = false, mask = false } = options;
14843
- const ctx = { path, branch };
14813
+ const ctx = { path, branch, mask };
14844
14814
  if (coerce) {
14845
14815
  value = struct.coercer(value, ctx);
14846
- if (mask &&
14847
- struct.type !== 'type' &&
14848
- isObject(struct.schema) &&
14849
- isObject(value) &&
14850
- !Array.isArray(value)) {
14851
- for (const key in value) {
14852
- if (struct.schema[key] === undefined) {
14853
- delete value[key];
14854
- }
14855
- }
14856
- }
14857
14816
  }
14858
14817
  let status = 'valid';
14859
14818
  for (const failure of struct.validator(value, ctx)) {
@@ -14955,7 +14914,8 @@ var solanaWeb3 = (function (exports) {
14955
14914
  }
14956
14915
  /**
14957
14916
  * Mask a value, coercing and validating it, but returning only the subset of
14958
- * properties defined by the struct's schema.
14917
+ * properties defined by the struct's schema. Masking applies recursively to
14918
+ * props of `object` structs only.
14959
14919
  */
14960
14920
  mask(value, message) {
14961
14921
  return mask(value, this, message);
@@ -14964,9 +14924,10 @@ var solanaWeb3 = (function (exports) {
14964
14924
  * Validate a value with the struct's validation logic, returning a tuple
14965
14925
  * representing the result.
14966
14926
  *
14967
- * You may optionally pass `true` for the `withCoercion` argument to coerce
14927
+ * You may optionally pass `true` for the `coerce` argument to coerce
14968
14928
  * the value before attempting to validate it. If you do, the result will
14969
- * contain the coerced result when successful.
14929
+ * contain the coerced result when successful. Also, `mask` will turn on
14930
+ * masking of the unknown `object` props recursively if passed.
14970
14931
  */
14971
14932
  validate(value, options = {}) {
14972
14933
  return validate$1(value, this, options);
@@ -15151,7 +15112,11 @@ var solanaWeb3 = (function (exports) {
15151
15112
  }
15152
15113
  },
15153
15114
  validator(value) {
15154
- return (isObject(value) || `Expected an object, but received: ${print(value)}`);
15115
+ return (isNonArrayObject(value) ||
15116
+ `Expected an object, but received: ${print(value)}`);
15117
+ },
15118
+ coercer(value) {
15119
+ return isNonArrayObject(value) ? { ...value } : value;
15155
15120
  },
15156
15121
  });
15157
15122
  }
@@ -15185,6 +15150,9 @@ var solanaWeb3 = (function (exports) {
15185
15150
  return (Array.isArray(value) ||
15186
15151
  `Expected an array, but received: ${print(value)}`);
15187
15152
  },
15153
+ coercer(value) {
15154
+ return Array.isArray(value) ? value.slice() : value;
15155
+ },
15188
15156
  });
15189
15157
  }
15190
15158
  /**
@@ -15206,10 +15174,11 @@ var solanaWeb3 = (function (exports) {
15206
15174
  }
15207
15175
  },
15208
15176
  validator(value) {
15209
- return (isObject(value) || `Expected an object, but received: ${print(value)}`);
15177
+ return (isNonArrayObject(value) ||
15178
+ `Expected an object, but received: ${print(value)}`);
15210
15179
  },
15211
15180
  coercer(value) {
15212
- return isObject(value) ? { ...value } : value;
15181
+ return isNonArrayObject(value) ? { ...value } : value;
15213
15182
  },
15214
15183
  });
15215
15184
  }
@@ -15221,9 +15190,12 @@ var solanaWeb3 = (function (exports) {
15221
15190
  return new Struct({
15222
15191
  type: 'union',
15223
15192
  schema: null,
15224
- coercer(value) {
15193
+ coercer(value, ctx) {
15225
15194
  for (const S of Structs) {
15226
- const [error, coerced] = S.validate(value, { coerce: true });
15195
+ const [error, coerced] = S.validate(value, {
15196
+ coerce: true,
15197
+ mask: ctx.mask,
15198
+ });
15227
15199
  if (!error) {
15228
15200
  return coerced;
15229
15201
  }
@@ -22332,6 +22304,81 @@ var solanaWeb3 = (function (exports) {
22332
22304
  */
22333
22305
  const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);
22334
22306
 
22307
+ // HMAC (RFC 2104)
22308
+ class HMAC extends Hash {
22309
+ constructor(hash$1, _key) {
22310
+ super();
22311
+ this.finished = false;
22312
+ this.destroyed = false;
22313
+ hash(hash$1);
22314
+ const key = toBytes(_key);
22315
+ this.iHash = hash$1.create();
22316
+ if (typeof this.iHash.update !== 'function')
22317
+ throw new Error('Expected instance of class which extends utils.Hash');
22318
+ this.blockLen = this.iHash.blockLen;
22319
+ this.outputLen = this.iHash.outputLen;
22320
+ const blockLen = this.blockLen;
22321
+ const pad = new Uint8Array(blockLen);
22322
+ // blockLen can be bigger than outputLen
22323
+ pad.set(key.length > blockLen ? hash$1.create().update(key).digest() : key);
22324
+ for (let i = 0; i < pad.length; i++)
22325
+ pad[i] ^= 0x36;
22326
+ this.iHash.update(pad);
22327
+ // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone
22328
+ this.oHash = hash$1.create();
22329
+ // Undo internal XOR && apply outer XOR
22330
+ for (let i = 0; i < pad.length; i++)
22331
+ pad[i] ^= 0x36 ^ 0x5c;
22332
+ this.oHash.update(pad);
22333
+ pad.fill(0);
22334
+ }
22335
+ update(buf) {
22336
+ exists(this);
22337
+ this.iHash.update(buf);
22338
+ return this;
22339
+ }
22340
+ digestInto(out) {
22341
+ exists(this);
22342
+ bytes(out, this.outputLen);
22343
+ this.finished = true;
22344
+ this.iHash.digestInto(out);
22345
+ this.oHash.update(out);
22346
+ this.oHash.digestInto(out);
22347
+ this.destroy();
22348
+ }
22349
+ digest() {
22350
+ const out = new Uint8Array(this.oHash.outputLen);
22351
+ this.digestInto(out);
22352
+ return out;
22353
+ }
22354
+ _cloneInto(to) {
22355
+ // Create new instance without calling constructor since key already in state and we don't know it.
22356
+ to || (to = Object.create(Object.getPrototypeOf(this), {}));
22357
+ const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
22358
+ to = to;
22359
+ to.finished = finished;
22360
+ to.destroyed = destroyed;
22361
+ to.blockLen = blockLen;
22362
+ to.outputLen = outputLen;
22363
+ to.oHash = oHash._cloneInto(to.oHash);
22364
+ to.iHash = iHash._cloneInto(to.iHash);
22365
+ return to;
22366
+ }
22367
+ destroy() {
22368
+ this.destroyed = true;
22369
+ this.oHash.destroy();
22370
+ this.iHash.destroy();
22371
+ }
22372
+ }
22373
+ /**
22374
+ * HMAC: RFC2104 message authentication code.
22375
+ * @param hash - function that would be used e.g. sha256
22376
+ * @param key - message key
22377
+ * @param message - message data
22378
+ */
22379
+ const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
22380
+ hmac.create = (hash, key) => new HMAC(hash, key);
22381
+
22335
22382
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
22336
22383
  // Short Weierstrass curve. The formula is: y² = x³ + ax + b
22337
22384
  function validatePointOpts(curve) {
@@ -23268,81 +23315,6 @@ var solanaWeb3 = (function (exports) {
23268
23315
  };
23269
23316
  }
23270
23317
 
23271
- // HMAC (RFC 2104)
23272
- class HMAC extends Hash {
23273
- constructor(hash$1, _key) {
23274
- super();
23275
- this.finished = false;
23276
- this.destroyed = false;
23277
- hash(hash$1);
23278
- const key = toBytes(_key);
23279
- this.iHash = hash$1.create();
23280
- if (typeof this.iHash.update !== 'function')
23281
- throw new Error('Expected instance of class which extends utils.Hash');
23282
- this.blockLen = this.iHash.blockLen;
23283
- this.outputLen = this.iHash.outputLen;
23284
- const blockLen = this.blockLen;
23285
- const pad = new Uint8Array(blockLen);
23286
- // blockLen can be bigger than outputLen
23287
- pad.set(key.length > blockLen ? hash$1.create().update(key).digest() : key);
23288
- for (let i = 0; i < pad.length; i++)
23289
- pad[i] ^= 0x36;
23290
- this.iHash.update(pad);
23291
- // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone
23292
- this.oHash = hash$1.create();
23293
- // Undo internal XOR && apply outer XOR
23294
- for (let i = 0; i < pad.length; i++)
23295
- pad[i] ^= 0x36 ^ 0x5c;
23296
- this.oHash.update(pad);
23297
- pad.fill(0);
23298
- }
23299
- update(buf) {
23300
- exists(this);
23301
- this.iHash.update(buf);
23302
- return this;
23303
- }
23304
- digestInto(out) {
23305
- exists(this);
23306
- bytes(out, this.outputLen);
23307
- this.finished = true;
23308
- this.iHash.digestInto(out);
23309
- this.oHash.update(out);
23310
- this.oHash.digestInto(out);
23311
- this.destroy();
23312
- }
23313
- digest() {
23314
- const out = new Uint8Array(this.oHash.outputLen);
23315
- this.digestInto(out);
23316
- return out;
23317
- }
23318
- _cloneInto(to) {
23319
- // Create new instance without calling constructor since key already in state and we don't know it.
23320
- to || (to = Object.create(Object.getPrototypeOf(this), {}));
23321
- const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
23322
- to = to;
23323
- to.finished = finished;
23324
- to.destroyed = destroyed;
23325
- to.blockLen = blockLen;
23326
- to.outputLen = outputLen;
23327
- to.oHash = oHash._cloneInto(to.oHash);
23328
- to.iHash = iHash._cloneInto(to.iHash);
23329
- return to;
23330
- }
23331
- destroy() {
23332
- this.destroyed = true;
23333
- this.oHash.destroy();
23334
- this.iHash.destroy();
23335
- }
23336
- }
23337
- /**
23338
- * HMAC: RFC2104 message authentication code.
23339
- * @param hash - function that would be used e.g. sha256
23340
- * @param key - message key
23341
- * @param message - message data
23342
- */
23343
- const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
23344
- hmac.create = (hash, key) => new HMAC(hash, key);
23345
-
23346
23318
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
23347
23319
  // connects noble-curves to noble-hashes
23348
23320
  function getHash(hash) {
@@ -24851,6 +24823,7 @@ var solanaWeb3 = (function (exports) {
24851
24823
  name: string(),
24852
24824
  website: optional(string()),
24853
24825
  details: optional(string()),
24826
+ iconUrl: optional(string()),
24854
24827
  keybaseUsername: optional(string())
24855
24828
  });
24856
24829