@orangecheck/sdk 1.16.2 → 1.17.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/dist/index.mjs CHANGED
@@ -221,6 +221,44 @@ function rfc3339Ms(value) {
221
221
  return Number.isNaN(ms) ? null : ms;
222
222
  }
223
223
 
224
+ // src/options.ts
225
+ var CHECK_OPTIONS = /* @__PURE__ */ new Set([
226
+ "addr",
227
+ "id",
228
+ "identity",
229
+ "minSats",
230
+ "minDays",
231
+ "relays",
232
+ "verifyOptions"
233
+ ]);
234
+ var VERIFY_OPTIONS = /* @__PURE__ */ new Set([
235
+ "testMode",
236
+ "demoMode",
237
+ "expectedAud",
238
+ "esploraMainnetBase",
239
+ "esploraSignetBase",
240
+ "esploraTestnetBase",
241
+ "coverSats"
242
+ ]);
243
+ function refuseUnknown(where, opts, known) {
244
+ if (opts === null || typeof opts !== "object") {
245
+ throw new TypeError(`@orangecheck/sdk: ${where} must be an object`);
246
+ }
247
+ const unknown = Object.keys(opts).filter((k) => !known.has(k));
248
+ if (unknown.length > 0) {
249
+ throw new TypeError(
250
+ `@orangecheck/sdk: ${where}: unknown option ${unknown.join(", ")}. It reads only ${[...known].join(", ")}.`
251
+ );
252
+ }
253
+ }
254
+ function checkCheckParams(params) {
255
+ refuseUnknown("check()", params, CHECK_OPTIONS);
256
+ if (params.verifyOptions !== void 0) checkVerifyOptions(params.verifyOptions, "verifyOptions");
257
+ }
258
+ function checkVerifyOptions(opts, where = "verify()") {
259
+ refuseUnknown(where, opts, VERIFY_OPTIONS);
260
+ }
261
+
224
262
  // src/scoring.ts
225
263
  function scoreV0(sats, days) {
226
264
  if (sats <= 0 || days <= 0) return 0;
@@ -432,6 +470,7 @@ function computeMetrics(utxos, bondAmount, coverSats) {
432
470
  return { sats_bonded, days_unspent, confirmed_balance };
433
471
  }
434
472
  async function verify(input, opts = {}) {
473
+ checkVerifyOptions(opts);
435
474
  const codes = [];
436
475
  let network = "mainnet";
437
476
  try {
@@ -1110,6 +1149,7 @@ function extractAttestationIdFromUrl(url) {
1110
1149
 
1111
1150
  // src/check.ts
1112
1151
  async function check(params) {
1152
+ checkCheckParams(params);
1113
1153
  const {
1114
1154
  addr,
1115
1155
  id,