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

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";
@@ -467,6 +467,36 @@ declare const ERRORS: {
467
467
  readonly user: null;
468
468
  readonly logOnly: true;
469
469
  };
470
+ readonly 'service.boot': {
471
+ readonly surfaces: readonly ["gateway", "seller", "indexer"];
472
+ readonly status: null;
473
+ readonly title: "Service started";
474
+ readonly paymentState: "not_charged";
475
+ readonly retry: "never";
476
+ readonly nextAction: "none";
477
+ readonly user: null;
478
+ readonly logOnly: true;
479
+ };
480
+ readonly 'service.lifecycle': {
481
+ readonly surfaces: readonly ["gateway", "seller", "indexer"];
482
+ readonly status: null;
483
+ readonly title: "Background work progressed";
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.diagnostic': {
491
+ readonly surfaces: readonly ["gateway", "seller", "indexer"];
492
+ readonly status: null;
493
+ readonly title: "Diagnostic detail";
494
+ readonly paymentState: "not_charged";
495
+ readonly retry: "never";
496
+ readonly nextAction: "none";
497
+ readonly user: null;
498
+ readonly logOnly: true;
499
+ };
470
500
  readonly 'limit.concurrency_exceeded': {
471
501
  readonly surfaces: readonly ["gateway"];
472
502
  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",
@@ -2093,6 +2093,39 @@ var SERVICE_CODES = {
2093
2093
  nextAction: "none",
2094
2094
  user: null,
2095
2095
  logOnly: true
2096
+ },
2097
+ // What a process started with: network, posture, rails, gas pool. Healthy.
2098
+ "service.boot": {
2099
+ surfaces: ["gateway", "seller", "indexer"],
2100
+ status: null,
2101
+ title: "Service started",
2102
+ paymentState: "not_charged",
2103
+ retry: "never",
2104
+ nextAction: "none",
2105
+ user: null,
2106
+ logOnly: true
2107
+ },
2108
+ // A background worker started, stopped, swept or retried on schedule. Healthy.
2109
+ "service.lifecycle": {
2110
+ surfaces: ["gateway", "seller", "indexer"],
2111
+ status: null,
2112
+ title: "Background work progressed",
2113
+ paymentState: "not_charged",
2114
+ retry: "never",
2115
+ nextAction: "none",
2116
+ user: null,
2117
+ logOnly: true
2118
+ },
2119
+ // Detail about healthy traffic an operator may want when reading a trace.
2120
+ "service.diagnostic": {
2121
+ surfaces: ["gateway", "seller", "indexer"],
2122
+ status: null,
2123
+ title: "Diagnostic detail",
2124
+ paymentState: "not_charged",
2125
+ retry: "never",
2126
+ nextAction: "none",
2127
+ user: null,
2128
+ logOnly: true
2096
2129
  }
2097
2130
  };
2098
2131
 
@@ -2793,6 +2826,233 @@ function newTraceId(randomBytes2 = cryptoRandomBytes) {
2793
2826
  return /^0+$/.test(hex) ? newTraceId(randomBytes2) : hex;
2794
2827
  }
2795
2828
 
2829
+ // ../core/dist/errors/context-allowlist.js
2830
+ var CONTEXT_ALLOWLIST = /* @__PURE__ */ new Set([
2831
+ // Settlement and request identifiers.
2832
+ "txDigest",
2833
+ "digest",
2834
+ "challengeId",
2835
+ "paymentId",
2836
+ "paymentHash",
2837
+ "paymentKey",
2838
+ "paymentState",
2839
+ "requestId",
2840
+ "traceId",
2841
+ "clientId",
2842
+ "serviceId",
2843
+ "configId",
2844
+ "seedId",
2845
+ "grantId",
2846
+ "grantObjectId",
2847
+ "sameGrantObjectId",
2848
+ "verifiedGrant",
2849
+ "poolObjectId",
2850
+ "packageId",
2851
+ "activePackageId",
2852
+ "expectedPackageId",
2853
+ "actualPackageId",
2854
+ "mandateId",
2855
+ "session",
2856
+ "coinId",
2857
+ "coinIds",
2858
+ "id",
2859
+ "dedupeKey",
2860
+ "hook",
2861
+ // Addresses (public on chain).
2862
+ "owner",
2863
+ "payTo",
2864
+ "recipient",
2865
+ "delegateAddress",
2866
+ // Codes, kinds and states.
2867
+ "code",
2868
+ "innerCode",
2869
+ "requestedCode",
2870
+ "failureCode",
2871
+ "oauthError",
2872
+ "errorKind",
2873
+ "kind",
2874
+ "mode",
2875
+ "effectiveMode",
2876
+ "state",
2877
+ "outcome",
2878
+ "status",
2879
+ "httpStatus",
2880
+ "reason",
2881
+ "action",
2882
+ "stage",
2883
+ "paid",
2884
+ "delivery",
2885
+ "sellerStatus",
2886
+ "sellerCode",
2887
+ "bindingCode",
2888
+ "errorName",
2889
+ "gasStationStatus",
2890
+ "readFailure",
2891
+ "refusal",
2892
+ "refusedAs",
2893
+ "registryCode",
2894
+ "sessionDecision",
2895
+ "settleCode",
2896
+ "signedRequest",
2897
+ "signerCode",
2898
+ "consentCode",
2899
+ "publicReason",
2900
+ "details",
2901
+ "event",
2902
+ "eventType",
2903
+ "surface",
2904
+ "scope",
2905
+ "field",
2906
+ "header",
2907
+ "dependency",
2908
+ "network",
2909
+ "rails",
2910
+ "shard",
2911
+ "metric",
2912
+ "alarm",
2913
+ "alert",
2914
+ "from",
2915
+ "to",
2916
+ "expected",
2917
+ "required",
2918
+ "violated",
2919
+ "diverged",
2920
+ "replaced",
2921
+ "suppressed",
2922
+ "unknown",
2923
+ "verified",
2924
+ "verification",
2925
+ "simulation",
2926
+ "isNew",
2927
+ "needsTopup",
2928
+ "operatorCapSet",
2929
+ "wantAgent",
2930
+ "wantGrant",
2931
+ "wantPool",
2932
+ "limitedBy",
2933
+ "peer",
2934
+ // Counts, amounts and timings.
2935
+ "amount",
2936
+ "scanned",
2937
+ "deleted",
2938
+ "intents",
2939
+ "policies",
2940
+ "connections",
2941
+ "events",
2942
+ "maxQueueSize",
2943
+ "bytes",
2944
+ "sha256",
2945
+ "ts",
2946
+ "count",
2947
+ "countRaw",
2948
+ "matchingCount",
2949
+ "registry_field_count",
2950
+ "applied",
2951
+ "attempt",
2952
+ "attempts",
2953
+ "cap",
2954
+ "max",
2955
+ "maxChallenges",
2956
+ "MAX_GAS_COIN_PAGES",
2957
+ "pagesScanned",
2958
+ "size",
2959
+ "free",
2960
+ "used",
2961
+ "fill",
2962
+ "limits",
2963
+ "refills",
2964
+ "refilled",
2965
+ "split",
2966
+ "unconfirmed",
2967
+ "spent",
2968
+ "reserveAfter",
2969
+ "claimedUntilMs",
2970
+ "repaired",
2971
+ "splits",
2972
+ "spend",
2973
+ "reserve",
2974
+ "reserveBalance",
2975
+ "ownerDailyMist",
2976
+ "ownerHourlyMist",
2977
+ "ownerIdentityDailyMist",
2978
+ "delegateDailyMist",
2979
+ "delegateHourlyMist",
2980
+ "delegateIdentityDailyMist",
2981
+ "consecutiveFailures",
2982
+ "failuresInARow",
2983
+ "epochReadFailures",
2984
+ "daysRemaining",
2985
+ "deadline",
2986
+ "delay",
2987
+ "delayMs",
2988
+ "ageMs",
2989
+ "timeoutMs",
2990
+ "nowMs",
2991
+ "switchedAtMs",
2992
+ "observeUntil",
2993
+ "window",
2994
+ "checkpointSeq",
2995
+ "eventSeq",
2996
+ "sampleSubjects",
2997
+ // Operator-facing error text. Redacted and length-capped like every string.
2998
+ "error",
2999
+ "errors",
3000
+ "err",
3001
+ "lastError",
3002
+ "outcomeError",
3003
+ "detail",
3004
+ "raw",
3005
+ "value"
3006
+ ]);
3007
+ var MAX_CONTEXT_STRING = 512;
3008
+ var MAX_CONTEXT_ARRAY = 32;
3009
+ var MAX_CONTEXT_DEPTH = 4;
3010
+ function filterContext(context) {
3011
+ let dropped = 0;
3012
+ const filterValue = (value2, depth) => {
3013
+ if (typeof value2 === "bigint")
3014
+ return value2.toString();
3015
+ if (value2 === null || typeof value2 !== "object")
3016
+ return value2;
3017
+ if (depth >= MAX_CONTEXT_DEPTH) {
3018
+ dropped += 1;
3019
+ return void 0;
3020
+ }
3021
+ if (Array.isArray(value2)) {
3022
+ return value2.slice(0, MAX_CONTEXT_ARRAY).map((item) => filterValue(item, depth + 1));
3023
+ }
3024
+ if (value2 instanceof Date)
3025
+ return value2.toISOString();
3026
+ return filterObject(value2, depth + 1);
3027
+ };
3028
+ const filterObject = (object, depth) => {
3029
+ const out = {};
3030
+ for (const [key, value2] of Object.entries(object)) {
3031
+ if (!CONTEXT_ALLOWLIST.has(key)) {
3032
+ dropped += 1;
3033
+ continue;
3034
+ }
3035
+ const kept = filterValue(value2, depth);
3036
+ if (kept !== void 0)
3037
+ out[key] = kept;
3038
+ }
3039
+ return out;
3040
+ };
3041
+ const value = filterObject(context, 0);
3042
+ return { value, dropped };
3043
+ }
3044
+ function capContextStrings(value) {
3045
+ if (typeof value === "string") {
3046
+ return value.length > MAX_CONTEXT_STRING ? `${value.slice(0, MAX_CONTEXT_STRING)}\u2026` : value;
3047
+ }
3048
+ if (Array.isArray(value))
3049
+ return value.map(capContextStrings);
3050
+ if (value !== null && typeof value === "object") {
3051
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, capContextStrings(v)]));
3052
+ }
3053
+ return value;
3054
+ }
3055
+
2796
3056
  // ../core/dist/errors/log.js
2797
3057
  var MAX_CAUSE_DEPTH = 5;
2798
3058
  function causeChain(error) {
@@ -2843,6 +3103,7 @@ function safeStringify(value) {
2843
3103
  function errorLogLine(context, error, now = /* @__PURE__ */ new Date()) {
2844
3104
  const wantStack = context.withStack ?? (context.httpStatus !== void 0 && context.httpStatus >= 500);
2845
3105
  const stack = wantStack && error instanceof Error && error.stack ? redactSecrets(error.stack) : void 0;
3106
+ const filtered = context.context ? filterContext(context.context) : void 0;
2846
3107
  return {
2847
3108
  level: context.level ?? "error",
2848
3109
  time: now.toISOString(),
@@ -2854,10 +3115,12 @@ function errorLogLine(context, error, now = /* @__PURE__ */ new Date()) {
2854
3115
  trace_id: context.traceId || newTraceId(),
2855
3116
  cause: error === void 0 ? [] : causeChain(error),
2856
3117
  ...stack ? { stack } : {},
2857
- ...context.context ? { context: redactValue(context.context) } : {}
3118
+ ...filtered ? { context: capContextStrings(redactValue(filtered.value)) } : {},
3119
+ ...filtered && filtered.dropped > 0 ? { context_dropped: filtered.dropped } : {}
2858
3120
  };
2859
3121
  }
2860
3122
  var stderrWriter = (line) => console.error(line);
3123
+ var lineShipper = null;
2861
3124
  function logError(context, error, write = stderrWriter) {
2862
3125
  let line;
2863
3126
  let traceId = "";
@@ -2878,6 +3141,12 @@ function logError(context, error, write = stderrWriter) {
2878
3141
  write(line);
2879
3142
  } catch {
2880
3143
  }
3144
+ if (write === stderrWriter && lineShipper) {
3145
+ try {
3146
+ lineShipper.enqueue(line, context.level ?? "error");
3147
+ } catch {
3148
+ }
3149
+ }
2881
3150
  }
2882
3151
 
2883
3152
  // ../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.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "SuiPay embeddable client — quote and pay a 402 from a spend-account grant.",
@@ -37,8 +37,8 @@
37
37
  "tsup": "^8.0.0",
38
38
  "typescript": "^6.0.3",
39
39
  "vitest": "^4.1.10",
40
- "@cmdoss/suipay-core": "0.1.0",
41
- "@cmdoss/suipay-sdk": "0.1.0"
40
+ "@cmdoss/suipay-sdk": "0.1.0",
41
+ "@cmdoss/suipay-core": "0.1.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsup",