@mysten-incubation/suipay 0.2.0-dev.0 → 0.2.0-dev.2

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.d.ts CHANGED
@@ -448,7 +448,7 @@ declare const ERRORS: {
448
448
  readonly logOnly: true;
449
449
  };
450
450
  readonly 'service.config_degraded': {
451
- readonly surfaces: readonly ["gateway"];
451
+ readonly surfaces: readonly ["gateway", "console_server"];
452
452
  readonly status: null;
453
453
  readonly title: "Service started with degraded configuration";
454
454
  readonly paymentState: "not_charged";
@@ -457,6 +457,16 @@ declare const ERRORS: {
457
457
  readonly user: null;
458
458
  readonly logOnly: true;
459
459
  };
460
+ readonly 'service.readiness': {
461
+ readonly surfaces: readonly ["gateway"];
462
+ readonly status: null;
463
+ readonly title: "Readiness gauge updated";
464
+ readonly paymentState: "not_charged";
465
+ readonly retry: "never";
466
+ readonly nextAction: "none";
467
+ readonly user: null;
468
+ readonly logOnly: true;
469
+ };
460
470
  readonly 'service.bookkeeping_failed': {
461
471
  readonly surfaces: readonly ["gateway"];
462
472
  readonly status: null;
@@ -467,6 +477,36 @@ declare const ERRORS: {
467
477
  readonly user: null;
468
478
  readonly logOnly: true;
469
479
  };
480
+ readonly 'service.boot': {
481
+ readonly surfaces: readonly ["gateway", "seller", "indexer"];
482
+ readonly status: null;
483
+ readonly title: "Service started";
484
+ readonly paymentState: "not_charged";
485
+ readonly retry: "never";
486
+ readonly nextAction: "none";
487
+ readonly user: null;
488
+ readonly logOnly: true;
489
+ };
490
+ readonly 'service.lifecycle': {
491
+ readonly surfaces: readonly ["gateway", "seller", "indexer"];
492
+ readonly status: null;
493
+ readonly title: "Background work progressed";
494
+ readonly paymentState: "not_charged";
495
+ readonly retry: "never";
496
+ readonly nextAction: "none";
497
+ readonly user: null;
498
+ readonly logOnly: true;
499
+ };
500
+ readonly 'service.diagnostic': {
501
+ readonly surfaces: readonly ["gateway", "seller", "indexer"];
502
+ readonly status: null;
503
+ readonly title: "Diagnostic detail";
504
+ readonly paymentState: "not_charged";
505
+ readonly retry: "never";
506
+ readonly nextAction: "none";
507
+ readonly user: null;
508
+ readonly logOnly: true;
509
+ };
470
510
  readonly 'limit.concurrency_exceeded': {
471
511
  readonly surfaces: readonly ["gateway"];
472
512
  readonly status: 429;
package/dist/index.js CHANGED
@@ -2073,7 +2073,7 @@ var SERVICE_CODES = {
2073
2073
  },
2074
2074
  // Boot or configuration fell back to a degraded mode instead of failing.
2075
2075
  "service.config_degraded": {
2076
- surfaces: ["gateway"],
2076
+ surfaces: ["gateway", "console_server"],
2077
2077
  status: null,
2078
2078
  title: "Service started with degraded configuration",
2079
2079
  paymentState: "not_charged",
@@ -2082,6 +2082,19 @@ var SERVICE_CODES = {
2082
2082
  user: null,
2083
2083
  logOnly: true
2084
2084
  },
2085
+ // A readiness gauge moved while the process is still serving. Not a degraded
2086
+ // boot: `service.config_degraded` is reserved for that, and for the sample
2087
+ // that actually fails closed.
2088
+ "service.readiness": {
2089
+ surfaces: ["gateway"],
2090
+ status: null,
2091
+ title: "Readiness gauge updated",
2092
+ paymentState: "not_charged",
2093
+ retry: "never",
2094
+ nextAction: "none",
2095
+ user: null,
2096
+ logOnly: true
2097
+ },
2085
2098
  // A best-effort write (a trace event, a receipt, a delivery record) failed.
2086
2099
  // The request it belongs to keeps its answer.
2087
2100
  "service.bookkeeping_failed": {
@@ -2093,6 +2106,39 @@ var SERVICE_CODES = {
2093
2106
  nextAction: "none",
2094
2107
  user: null,
2095
2108
  logOnly: true
2109
+ },
2110
+ // What a process started with: network, posture, rails, gas pool. Healthy.
2111
+ "service.boot": {
2112
+ surfaces: ["gateway", "seller", "indexer"],
2113
+ status: null,
2114
+ title: "Service started",
2115
+ paymentState: "not_charged",
2116
+ retry: "never",
2117
+ nextAction: "none",
2118
+ user: null,
2119
+ logOnly: true
2120
+ },
2121
+ // A background worker started, stopped, swept or retried on schedule. Healthy.
2122
+ "service.lifecycle": {
2123
+ surfaces: ["gateway", "seller", "indexer"],
2124
+ status: null,
2125
+ title: "Background work progressed",
2126
+ paymentState: "not_charged",
2127
+ retry: "never",
2128
+ nextAction: "none",
2129
+ user: null,
2130
+ logOnly: true
2131
+ },
2132
+ // Detail about healthy traffic an operator may want when reading a trace.
2133
+ "service.diagnostic": {
2134
+ surfaces: ["gateway", "seller", "indexer"],
2135
+ status: null,
2136
+ title: "Diagnostic detail",
2137
+ paymentState: "not_charged",
2138
+ retry: "never",
2139
+ nextAction: "none",
2140
+ user: null,
2141
+ logOnly: true
2096
2142
  }
2097
2143
  };
2098
2144
 
@@ -2793,6 +2839,233 @@ function newTraceId(randomBytes2 = cryptoRandomBytes) {
2793
2839
  return /^0+$/.test(hex) ? newTraceId(randomBytes2) : hex;
2794
2840
  }
2795
2841
 
2842
+ // ../core/dist/errors/context-allowlist.js
2843
+ var CONTEXT_ALLOWLIST = /* @__PURE__ */ new Set([
2844
+ // Settlement and request identifiers.
2845
+ "txDigest",
2846
+ "digest",
2847
+ "challengeId",
2848
+ "paymentId",
2849
+ "paymentHash",
2850
+ "paymentKey",
2851
+ "paymentState",
2852
+ "requestId",
2853
+ "traceId",
2854
+ "clientId",
2855
+ "serviceId",
2856
+ "configId",
2857
+ "seedId",
2858
+ "grantId",
2859
+ "grantObjectId",
2860
+ "sameGrantObjectId",
2861
+ "verifiedGrant",
2862
+ "poolObjectId",
2863
+ "packageId",
2864
+ "activePackageId",
2865
+ "expectedPackageId",
2866
+ "actualPackageId",
2867
+ "mandateId",
2868
+ "session",
2869
+ "coinId",
2870
+ "coinIds",
2871
+ "id",
2872
+ "dedupeKey",
2873
+ "hook",
2874
+ // Addresses (public on chain).
2875
+ "owner",
2876
+ "payTo",
2877
+ "recipient",
2878
+ "delegateAddress",
2879
+ // Codes, kinds and states.
2880
+ "code",
2881
+ "innerCode",
2882
+ "requestedCode",
2883
+ "failureCode",
2884
+ "oauthError",
2885
+ "errorKind",
2886
+ "kind",
2887
+ "mode",
2888
+ "effectiveMode",
2889
+ "state",
2890
+ "outcome",
2891
+ "status",
2892
+ "httpStatus",
2893
+ "reason",
2894
+ "action",
2895
+ "stage",
2896
+ "paid",
2897
+ "delivery",
2898
+ "sellerStatus",
2899
+ "sellerCode",
2900
+ "bindingCode",
2901
+ "errorName",
2902
+ "gasStationStatus",
2903
+ "readFailure",
2904
+ "refusal",
2905
+ "refusedAs",
2906
+ "registryCode",
2907
+ "sessionDecision",
2908
+ "settleCode",
2909
+ "signedRequest",
2910
+ "signerCode",
2911
+ "consentCode",
2912
+ "publicReason",
2913
+ "details",
2914
+ "event",
2915
+ "eventType",
2916
+ "surface",
2917
+ "scope",
2918
+ "field",
2919
+ "header",
2920
+ "dependency",
2921
+ "network",
2922
+ "rails",
2923
+ "shard",
2924
+ "metric",
2925
+ "alarm",
2926
+ "alert",
2927
+ "from",
2928
+ "to",
2929
+ "expected",
2930
+ "required",
2931
+ "violated",
2932
+ "diverged",
2933
+ "replaced",
2934
+ "suppressed",
2935
+ "unknown",
2936
+ "verified",
2937
+ "verification",
2938
+ "simulation",
2939
+ "isNew",
2940
+ "needsTopup",
2941
+ "operatorCapSet",
2942
+ "wantAgent",
2943
+ "wantGrant",
2944
+ "wantPool",
2945
+ "limitedBy",
2946
+ "peer",
2947
+ // Counts, amounts and timings.
2948
+ "amount",
2949
+ "scanned",
2950
+ "deleted",
2951
+ "intents",
2952
+ "policies",
2953
+ "connections",
2954
+ "events",
2955
+ "maxQueueSize",
2956
+ "bytes",
2957
+ "sha256",
2958
+ "ts",
2959
+ "count",
2960
+ "countRaw",
2961
+ "matchingCount",
2962
+ "registry_field_count",
2963
+ "applied",
2964
+ "attempt",
2965
+ "attempts",
2966
+ "cap",
2967
+ "max",
2968
+ "maxChallenges",
2969
+ "MAX_GAS_COIN_PAGES",
2970
+ "pagesScanned",
2971
+ "size",
2972
+ "free",
2973
+ "used",
2974
+ "fill",
2975
+ "limits",
2976
+ "refills",
2977
+ "refilled",
2978
+ "split",
2979
+ "unconfirmed",
2980
+ "spent",
2981
+ "reserveAfter",
2982
+ "claimedUntilMs",
2983
+ "repaired",
2984
+ "splits",
2985
+ "spend",
2986
+ "reserve",
2987
+ "reserveBalance",
2988
+ "ownerDailyMist",
2989
+ "ownerHourlyMist",
2990
+ "ownerIdentityDailyMist",
2991
+ "delegateDailyMist",
2992
+ "delegateHourlyMist",
2993
+ "delegateIdentityDailyMist",
2994
+ "consecutiveFailures",
2995
+ "failuresInARow",
2996
+ "epochReadFailures",
2997
+ "daysRemaining",
2998
+ "deadline",
2999
+ "delay",
3000
+ "delayMs",
3001
+ "ageMs",
3002
+ "timeoutMs",
3003
+ "nowMs",
3004
+ "switchedAtMs",
3005
+ "observeUntil",
3006
+ "window",
3007
+ "checkpointSeq",
3008
+ "eventSeq",
3009
+ "sampleSubjects",
3010
+ // Operator-facing error text. Redacted and length-capped like every string.
3011
+ "error",
3012
+ "errors",
3013
+ "err",
3014
+ "lastError",
3015
+ "outcomeError",
3016
+ "detail",
3017
+ "raw",
3018
+ "value"
3019
+ ]);
3020
+ var MAX_CONTEXT_STRING = 512;
3021
+ var MAX_CONTEXT_ARRAY = 32;
3022
+ var MAX_CONTEXT_DEPTH = 4;
3023
+ function filterContext(context) {
3024
+ let dropped = 0;
3025
+ const filterValue = (value2, depth) => {
3026
+ if (typeof value2 === "bigint")
3027
+ return value2.toString();
3028
+ if (value2 === null || typeof value2 !== "object")
3029
+ return value2;
3030
+ if (depth >= MAX_CONTEXT_DEPTH) {
3031
+ dropped += 1;
3032
+ return void 0;
3033
+ }
3034
+ if (Array.isArray(value2)) {
3035
+ return value2.slice(0, MAX_CONTEXT_ARRAY).map((item) => filterValue(item, depth + 1));
3036
+ }
3037
+ if (value2 instanceof Date)
3038
+ return value2.toISOString();
3039
+ return filterObject(value2, depth + 1);
3040
+ };
3041
+ const filterObject = (object, depth) => {
3042
+ const out = {};
3043
+ for (const [key, value2] of Object.entries(object)) {
3044
+ if (!CONTEXT_ALLOWLIST.has(key)) {
3045
+ dropped += 1;
3046
+ continue;
3047
+ }
3048
+ const kept = filterValue(value2, depth);
3049
+ if (kept !== void 0)
3050
+ out[key] = kept;
3051
+ }
3052
+ return out;
3053
+ };
3054
+ const value = filterObject(context, 0);
3055
+ return { value, dropped };
3056
+ }
3057
+ function capContextStrings(value) {
3058
+ if (typeof value === "string") {
3059
+ return value.length > MAX_CONTEXT_STRING ? `${value.slice(0, MAX_CONTEXT_STRING)}\u2026` : value;
3060
+ }
3061
+ if (Array.isArray(value))
3062
+ return value.map(capContextStrings);
3063
+ if (value !== null && typeof value === "object") {
3064
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, capContextStrings(v)]));
3065
+ }
3066
+ return value;
3067
+ }
3068
+
2796
3069
  // ../core/dist/errors/log.js
2797
3070
  var MAX_CAUSE_DEPTH = 5;
2798
3071
  function causeChain(error) {
@@ -2843,6 +3116,7 @@ function safeStringify(value) {
2843
3116
  function errorLogLine(context, error, now = /* @__PURE__ */ new Date()) {
2844
3117
  const wantStack = context.withStack ?? (context.httpStatus !== void 0 && context.httpStatus >= 500);
2845
3118
  const stack = wantStack && error instanceof Error && error.stack ? redactSecrets(error.stack) : void 0;
3119
+ const filtered = context.context ? filterContext(context.context) : void 0;
2846
3120
  return {
2847
3121
  level: context.level ?? "error",
2848
3122
  time: now.toISOString(),
@@ -2854,10 +3128,12 @@ function errorLogLine(context, error, now = /* @__PURE__ */ new Date()) {
2854
3128
  trace_id: context.traceId || newTraceId(),
2855
3129
  cause: error === void 0 ? [] : causeChain(error),
2856
3130
  ...stack ? { stack } : {},
2857
- ...context.context ? { context: redactValue(context.context) } : {}
3131
+ ...filtered ? { context: capContextStrings(redactValue(filtered.value)) } : {},
3132
+ ...filtered && filtered.dropped > 0 ? { context_dropped: filtered.dropped } : {}
2858
3133
  };
2859
3134
  }
2860
3135
  var stderrWriter = (line) => console.error(line);
3136
+ var lineShipper = null;
2861
3137
  function logError(context, error, write = stderrWriter) {
2862
3138
  let line;
2863
3139
  let traceId = "";
@@ -2878,6 +3154,12 @@ function logError(context, error, write = stderrWriter) {
2878
3154
  write(line);
2879
3155
  } catch {
2880
3156
  }
3157
+ if (write === stderrWriter && lineShipper) {
3158
+ try {
3159
+ lineShipper.enqueue(line, context.level ?? "error");
3160
+ } catch {
3161
+ }
3162
+ }
2881
3163
  }
2882
3164
 
2883
3165
  // ../core/dist/errors/suipay-error.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten-incubation/suipay",
3
- "version": "0.2.0-dev.0",
3
+ "version": "0.2.0-dev.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "SuiPay embeddable client — quote and pay a 402 from a spend-account grant.",