CodeSampleX

サンプル

builder-util 25.1.7

検証済みサンプル — npm builder-util 25.1.7. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: archFromString maps valid architecture names to Arch enum…

sha256:d583f02a679a0b81d14f3e5416dcd509d30abae2cf843b433eaeb4b303127d17

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-27

ケース

HOW
ゴール
verify pkg:npm/builder-util@25.1.7
パッケージ
環境
node 22.23.2
作成日
2026-08-27T17:09:58Z

コントラクト

  1. archFromString maps valid architecture names to Arch enum values and throws for invalid architecture names
  2. toLinuxArchString formats architecture names according to package target type
  3. getArchSuffix returns empty string for default arch and hyphenated suffix for target arch
  4. getArtifactArchName maps architecture and target artifact extensions to distribution architecture names
  5. serializeToYaml serializes objects to YAML format string
  6. deepAssign performs deep property assignment and deduplicates merged arrays
  7. safeStringifyJson serializes objects to JSON while masking specified skipped keys
  8. isEmptyOrSpaces and isEnvTrue validate strings and evaluate boolean environment variable strings
  9. replaceDefault expands default placeholder with provided default list
  10. removePassword sanitizes password arguments in command strings with SHA-256 hashes
  11. InvalidConfigurationError constructs configuration error with message and error code

ファイル

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

ソースアーティファクトをダウンロード (tar.gz)

ソース

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:npm/builder-util@25.1.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/builder-util@25.1.7
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:828685aec300aa704e20acee4ca18edf5d9c9f14c535b92fdb89e6bf730c5fd1","constraints":{"executionContext":"node"},"contract":["archFromString maps valid architecture names to Arch enum values and throws for invalid architecture names","toLinuxArchString formats architecture names according to package target type","getArchSuffix returns empty string for default arch and hyphenated suffix for target arch","getArtifactArchName maps architecture and target artifact extensions to distribution architecture names","serializeToYaml serializes objects to YAML format string","deepAssign performs deep property assignment and deduplicates merged arrays","safeStringifyJson serializes objects to JSON while masking specified skipped keys","isEmptyOrSpaces and isEnvTrue validate strings and evaluate boolean environment variable strings","replaceDefault expands default placeholder with provided default list","removePassword sanitizes password arguments in command strings with SHA-256 hashes","InvalidConfigurationError constructs configuration error with message and error code"],"goal":"verify pkg:npm/builder-util@25.1.7","kind":"HOW","packages":["pkg:npm/builder-util@25.1.7"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/builder-util@25.1.7"],"schemaVersion":1,"subject":"pkg:npm/builder-util@25.1.7","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-builder-util",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-builder-util",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "builder-util": "25.1.7"
      }
    },
    "node_modules/@types/debug": {
      "version": "4.1.13",
      "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz",
      "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==",
      "license": "MIT",
      "dependencies": {
        "@types/ms": "*"
      }
    },
    "node_modules/@types/ms": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz",
      "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
      "license": "MIT"
    },
    "node_modules/7zip-bin": {
      "version": "5.2.0",
      "resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-5.2.0.tgz",
      "integrity": "sha512-ukTPVhqG4jNzMro2qA9HSCSSVJN3aN7tlb+hfqYCt3ER0yWroeA2VR38MNrOHLQ/cVj+DaIMad0kFCtWWowh/A==",
      "license": "MIT"
    },
    "node_modules/agent-base": {
      "version": "7.1.4",
      "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
      "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
      "license": "MIT",
      "engines": {
        "node": ">= 14"
      }
    },
    "node_modules/ansi-styles": {
      "version": "4.3.0",
      "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
      "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
      "license": "MIT",
      "dependencies": {
        "color-convert": "^2.0.1"
      },
      "engines": {
        "node": ">=8"
      },
      "funding": {
        "url": "https://github.com/chalk/ansi-styles?sponsor=1"
      }
    },
    "node_modules/app-builder-bin": {
      "version": "5.0.0-alpha.10",
      "resolved": "https://registry.npmjs.org/app-builder-bin/-/app-builder-bin-5.0.0-alpha.10.tgz",
      "integrity": "sha512-Ev4jj3D7Bo+O0GPD2NMvJl+PGiBAfS7pUGawntBNpCbxtpncfUixqFj9z9Jme7V7s3LBGqsWZZP54fxBX3JKJw==",
      "license": "MIT"
    },
    "node_modules/argparse": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
      "license": "Python-2.0"
    },
    "node_modules/async-exit-hook": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/async-exit-hook/-/async-exit-hook-2.0.1.tgz",
      "integrity": "sha512-NW2cX8m1Q7KPA7a5M2ULQeZ2wR5qI5PAbw5L0UOMxdioVk9PMZ0h1TmyZEkPYrCvYjDlFICusOu1dlEKAAeXBw==",
      "license": "MIT",
      "engines": {
        "node": ">=0.12.0"
      }
    },
    "node_modules/bluebird": {
      "version": "3.7.2",
      "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
      "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==",
      "license": "MIT"
    },
    "node_modules/bluebird-lst": {
      "version": "1.0.9",
      "resolved": "https://registry.npmjs.org/bluebird-lst/-/bluebird-lst-1.0.9.tgz",
      "integrity": "sha512-7B1Rtx82hjnSD4PGLAjVWeYH3tHAcVUmChh85a3lltKQm6FresXh9ErQo6oAv6CqxttczC3/kEg8SY5NluPuUw==",
      "license": "MIT",
      "dependencies": {
        "bluebird": "^3.5.5"
      }
    },
    "node_modules/buffer-from": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
      "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
      "license": "MIT"
    },
    "node_modules/builder-util": {
      "version": "25.1.7",
      "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-25.1.7.tgz",
      "integrity": "sha512-7jPjzBwEGRbwNcep0gGNpLXG9P94VA3CPAZQCzxkFXiV2GMQKlziMbY//rXPI7WKfhsvGgFXjTcXdBEwgXw9ww==",
      "license": "MIT",
      "dependencies": {
        "@types/debug": "^4.1.6",
        "7zip-bin": "~5.2.0",
        "app-builder-bin": "5.0.0-alpha.10",
        "bluebird-lst": "^1.0.9",
        "builder-util-runtime": "9.2.10",
        "chalk": "^4.1.2",
        "cross-spawn": "^7.0.3",
        "debug": "^4.3.4",
        "fs-extra": "^10.1.0",
        "http-proxy-agent": "^7.0.0",
        "https-proxy-agent": "^7.0.0",
        "is-ci": "^3.0.0",
        "js-yaml": "^4.1.0",
        "source-map-support": "^0.5.19",
        "stat-mode": "^1.0.0",
        "temp-file": "^3.4.0"
      }
    },
    "node_modules/builder-util-runtime": {
      "version": "9.2.10",
      "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.2.10.tgz",
      "integrity": "sha512-6p/gfG1RJSQeIbz8TK5aPNkoztgY1q5TgmGFMAXcY8itsGW6Y2ld1ALsZ5UJn8rog7hKF3zHx5iQbNQ8uLcRlw==",
      "license": "MIT",
      "dependencies": {
        "debug": "^4.3.4",
        "sax": "^1.2.4"
      },
      "engines": {
        "node": ">=12.0.0"
      }
    },
    "node_modules/chalk": {
      "version": "4.1.2",
      "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
      "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
      "license": "MIT",
      "dependencies": {
        "ansi-styles": "^4.1.0",
        "supports-color": "^7.1.0"
      },
      "engines": {
        "node": ">=10"
      },
      "funding": {
        "url": "https://github.com/chalk/chalk?sponsor=1"
      }
    },
    "node_modules/ci-info": {
      "version": "3.9.0",
      "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz",
      "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/sibiraj-s"
        }
      ],
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/color-convert": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
      "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
      "license": "MIT",
      "dependencies": {
        "color-name": "~1.1.4"
      },
      "engines": {
        "node": ">=7.0.0"
      }
    },
    "node_modules/color-name": {
      "version": "1.1.4",
      "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
      "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
      "license": "MIT"
    },
    "node_modules/cross-spawn": {
      "version": "7.0.6",
      "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
      "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
      "license": "MIT",
      "dependencies": {
        "path-key": "^3.1.0",
        "shebang-command": "^2.0.0",
        "which": "^2.0.1"
      },
      "engines": {
        "node": ">= 8"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/fs-extra": {
      "version": "10.1.0",
      "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
      "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
      "license": "MIT",
      "dependencies": {
        "graceful-fs": "^4.2.0",
        "jsonfile": "^6.0.1",
        "universalify": "^2.0.0"
      },
      "engines": {
        "node": ">=12"
      }
    },
    "node_modules/graceful-fs": {
      "version": "4.2.11",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
      "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
      "license": "ISC"
    },
    "node_modules/has-flag": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
      "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/http-proxy-agent": {
      "version": "7.0.2",
      "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz",
      "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==",
      "license": "MIT",
      "dependencies": {
        "agent-base": "^7.1.0",
        "debug": "^4.3.4"
      },
      "engines": {
        "node": ">= 14"
      }
    },
    "node_modules/https-proxy-agent": {
      "version": "7.0.6",
      "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
      "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
      "license": "MIT",
      "dependencies": {
        "agent-base": "^7.1.2",
        "debug": "4"
      },
      "engines": {
        "node": ">= 14"
      }
    },
    "node_modules/is-ci": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz",
      "integrity": "sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==",
      "license": "MIT",
      "dependencies": {
        "ci-info": "^3.2.0"
      },
      "bin": {
        "is-ci": "bin.js"
      }
    },
    "node_modules/isexe": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
      "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
      "license": "ISC"
    },
    "node_modules/js-yaml": {
      "version": "4.3.2",
      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz",
      "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/puzrin"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/nodeca"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "argparse": "^2.0.1"
      },
      "bin": {
        "js-yaml": "bin/js-yaml.js"
      }
    },
    "node_modules/jsonfile": {
      "version": "6.2.1",
      "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
      "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
      "license": "MIT",
      "dependencies": {
        "universalify": "^2.0.0"
      },
      "optionalDependencies": {
        "graceful-fs": "^4.1.6"
      }
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "node_modules/path-key": {
      "version": "3.1.1",
      "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
      "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/sax": {
      "version": "1.6.1",
      "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz",
      "integrity": "sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==",
      "license": "BlueOak-1.0.0",
      "engines": {
        "node": ">=11.0.0"
      }
    },
    "node_modules/shebang-command": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
      "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
      "license": "MIT",
      "dependencies": {
        "shebang-regex": "^3.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/shebang-regex": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
      "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/source-map": {
      "version": "0.6.1",
      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
      "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
      "license": "BSD-3-Clause",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/source-map-support": {
      "version": "0.5.21",
      "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
      "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
      "license": "MIT",
      "dependencies": {
        "buffer-from": "^1.0.0",
        "source-map": "^0.6.0"
      }
    },
    "node_modules/stat-mode": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/stat-mode/-/stat-mode-1.0.0.tgz",
      "integrity": "sha512-jH9EhtKIjuXZ2cWxmXS8ZP80XyC3iasQxMDV8jzhNJpfDb7VbQLVW4Wvsxz9QZvzV+G4YoSfBUVKDOyxLzi/sg==",
      "license": "MIT",
      "engines": {
        "node": ">= 6"
      }
    },
    "node_modules/supports-color": {
      "version": "7.2.0",
      "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
      "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
      "license": "MIT",
      "dependencies": {
        "has-flag": "^4.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/temp-file": {
      "version": "3.4.0",
      "resolved": "https://registry.npmjs.org/temp-file/-/temp-file-3.4.0.tgz",
      "integrity": "sha512-C5tjlC/HCtVUOi3KWVokd4vHVViOmGjtLwIh4MuzPo/nMYTV/p1urt3RnMz2IWXDdKEGJH3k5+KPxtqRsUYGtg==",
      "license": "MIT",
      "dependencies": {
        "async-exit-hook": "^2.0.1",
        "fs-extra": "^10.0.0"
      }
    },
    "node_modules/universalify": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
      "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
      "license": "MIT",
      "engines": {
        "node": ">= 10.0.0"
      }
    },
    "node_modules/which": {
      "version": "2.0.2",
      "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
      "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
      "license": "ISC",
      "dependencies": {
        "isexe": "^2.0.0"
      },
      "bin": {
        "node-which": "bin/node-which"
      },
      "engines": {
        "node": ">= 8"
      }
    }
  }
}
package.json
{
  "name": "sample-builder-util",
  "version": "1.0.0",
  "description": "verify pkg:npm/builder-util@25.1.7",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "builder-util": "25.1.7"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/builder-util@25.1.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/builder-util@25.1.7"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const {
  Arch,
  archFromString,
  defaultArchFromString,
  toLinuxArchString,
  getArchSuffix,
  getArchCliNames,
  getArtifactArchName,
  serializeToYaml,
  deepAssign,
  safeStringifyJson,
  asArray,
  isEmptyOrSpaces,
  isEnvTrue,
  isTokenCharValid,
  replaceDefault,
  removePassword,
  getPlatformIconFileName,
  InvalidConfigurationError,
  ExecError
} = require('builder-util');

/**
 * Resolves an architecture string to its enum value.
 * @param {string} name
 * @returns {number}
 */
function resolveArch(name) {
  return archFromString(name);
}

/**
 * Formats a Linux architecture string for a given target.
 * @param {number} arch
 * @param {string} [targetName]
 * @returns {string}
 */
function formatLinuxArch(arch, targetName) {
  return toLinuxArchString(arch, targetName);
}

/**
 * Converts a JavaScript object to a YAML formatted string.
 * @param {object} obj
 * @param {boolean} [skipInvalid=false]
 * @param {boolean} [noRefs=false]
 * @returns {string}
 */
function dumpYaml(obj, skipInvalid, noRefs) {
  return serializeToYaml(obj, skipInvalid, noRefs);
}

/**
 * Deeply merges multiple objects into a target object.
 * @param {object} target
 * @param {...object} sources
 * @returns {object}
 */
function mergeDeep(target, ...sources) {
  return deepAssign(target, ...sources);
}

/**
 * Safely stringifies a JavaScript value to JSON, filtering omitted keys.
 * @param {any} data
 * @param {Set<string>} [skippedKeys]
 * @returns {string}
 */
function stringifySafeJson(data, skippedKeys) {
  return safeStringifyJson(data, skippedKeys);
}

/**
 * Strips/hashes passwords from a command string.
 * @param {string} command
 * @returns {string}
 */
function sanitizeCommand(command) {
  return removePassword(command);
}

module.exports = {
  Arch,
  archFromString,
  defaultArchFromString,
  toLinuxArchString,
  getArchSuffix,
  getArchCliNames,
  getArtifactArchName,
  serializeToYaml,
  deepAssign,
  safeStringifyJson,
  asArray,
  isEmptyOrSpaces,
  isEnvTrue,
  isTokenCharValid,
  replaceDefault,
  removePassword,
  getPlatformIconFileName,
  InvalidConfigurationError,
  ExecError,
  resolveArch,
  formatLinuxArch,
  dumpYaml,
  mergeDeep,
  stringifySafeJson,
  sanitizeCommand
};
test/contract.js
'use strict';

const assert = require('assert');
const crypto = require('crypto');
const {
  Arch,
  defaultArchFromString,
  getArchSuffix,
  getArtifactArchName,
  isEmptyOrSpaces,
  isEnvTrue,
  replaceDefault,
  InvalidConfigurationError,
  resolveArch,
  formatLinuxArch,
  dumpYaml,
  mergeDeep,
  stringifySafeJson,
  sanitizeCommand
} = require('../src/index');

// 1. archFromString maps valid architecture names to Arch enum values and throws for invalid architecture names
{
  assert.strictEqual(resolveArch('x64'), Arch.x64);
  assert.strictEqual(resolveArch('ia32'), Arch.ia32);
  assert.strictEqual(resolveArch('arm64'), Arch.arm64);
  assert.strictEqual(resolveArch('armv7l'), Arch.armv7l);
  assert.strictEqual(resolveArch('arm'), Arch.armv7l);
  assert.strictEqual(resolveArch('universal'), Arch.universal);
  assert.strictEqual(defaultArchFromString(undefined), Arch.x64);
  assert.strictEqual(defaultArchFromString('arm64'), Arch.arm64);
  assert.throws(() => resolveArch('invalid_arch'), /^Error: Unsupported arch invalid_arch/);
}

// 2. toLinuxArchString formats architecture names according to package target type
{
  assert.strictEqual(formatLinuxArch(Arch.x64), 'amd64');
  assert.strictEqual(formatLinuxArch(Arch.x64, 'flatpak'), 'x86_64');
  assert.strictEqual(formatLinuxArch(Arch.ia32), 'i386');
  assert.strictEqual(formatLinuxArch(Arch.ia32, 'pacman'), 'i686');
  assert.strictEqual(formatLinuxArch(Arch.arm64), 'arm64');
  assert.strictEqual(formatLinuxArch(Arch.arm64, 'rpm'), 'aarch64');
  assert.strictEqual(formatLinuxArch(Arch.arm64, 'pacman'), 'aarch64');
  assert.strictEqual(formatLinuxArch(Arch.arm64, 'flatpak'), 'aarch64');
  assert.strictEqual(formatLinuxArch(Arch.armv7l), 'armv7l');
  assert.strictEqual(formatLinuxArch(Arch.armv7l, 'deb'), 'armhf');
  assert.strictEqual(formatLinuxArch(Arch.armv7l, 'snap'), 'armhf');
  assert.strictEqual(formatLinuxArch(Arch.armv7l, 'flatpak'), 'arm');
  assert.throws(() => formatLinuxArch(Arch.universal), /^Error: Unsupported arch 4/);
}

// 3. getArchSuffix returns empty string for default arch and hyphenated suffix for target arch
{
  assert.strictEqual(getArchSuffix(Arch.x64), '');
  assert.strictEqual(getArchSuffix(Arch.arm64), '-arm64');
  assert.strictEqual(getArchSuffix(Arch.ia32), '-ia32');
  assert.strictEqual(getArchSuffix(Arch.armv7l), '-armv7l');
  assert.strictEqual(getArchSuffix(Arch.arm64, 'arm64'), '');
}

// 4. getArtifactArchName maps architecture and target artifact extensions to distribution architecture names
{
  assert.strictEqual(getArtifactArchName(Arch.x64, 'deb'), 'amd64');
  assert.strictEqual(getArtifactArchName(Arch.x64, 'rpm'), 'x86_64');
  assert.strictEqual(getArtifactArchName(Arch.x64, 'AppImage'), 'x86_64');
  assert.strictEqual(getArtifactArchName(Arch.ia32, 'deb'), 'i386');
  assert.strictEqual(getArtifactArchName(Arch.ia32, 'rpm'), 'i686');
  assert.strictEqual(getArtifactArchName(Arch.armv7l, 'snap'), 'armhf');
  assert.strictEqual(getArtifactArchName(Arch.armv7l, 'flatpak'), 'arm');
  assert.strictEqual(getArtifactArchName(Arch.arm64, 'rpm'), 'aarch64');
  assert.strictEqual(getArtifactArchName(Arch.arm64, 'deb'), 'arm64');
}

// 5. serializeToYaml serializes objects to YAML format string
{
  const config = {
    appId: 'com.example.sampleapp',
    productName: 'SampleApp',
    directories: {
      output: 'dist'
    },
    linux: {
      target: ['deb', 'rpm']
    }
  };
  const yamlOutput = dumpYaml(config);
  assert.strictEqual(typeof yamlOutput, 'string');
  assert(yamlOutput.includes('appId: com.example.sampleapp'));
  assert(yamlOutput.includes('productName: SampleApp'));
  assert(yamlOutput.includes('output: dist'));
  assert(yamlOutput.includes('- deb'));
  assert(yamlOutput.includes('- rpm'));
}

// 6. deepAssign performs deep property assignment and deduplicates merged arrays
{
  const baseConfig = {
    appName: 'Base',
    files: ['src/**', 'assets/**'],
    buildOptions: {
      minify: false,
      debug: true
    }
  };
  const overrideConfig = {
    appName: 'Overridden',
    files: ['assets/**', 'extra/**'],
    buildOptions: {
      minify: true
    },
    version: '1.0.0'
  };
  const merged = mergeDeep(baseConfig, overrideConfig);
  assert.strictEqual(merged.appName, 'Overridden');
  assert.strictEqual(merged.version, '1.0.0');
  assert.deepStrictEqual(merged.files, ['src/**', 'assets/**', 'extra/**']);
  assert.deepStrictEqual(merged.buildOptions, {
    minify: true,
    debug: true
  });
}

// 7. safeStringifyJson serializes objects to JSON while masking specified skipped keys
{
  const payload = {
    id: 101,
    name: 'package-test',
    secretToken: 'sensitive-token-12345',
    metadata: {
      env: 'production'
    }
  };
  const jsonStr = stringifySafeJson(payload, new Set(['secretToken']));
  assert.strictEqual(typeof jsonStr, 'string');
  const parsed = JSON.parse(jsonStr);
  assert.strictEqual(parsed.id, 101);
  assert.strictEqual(parsed.name, 'package-test');
  assert.strictEqual(parsed.secretToken, '<stripped sensitive data>');
  assert(!jsonStr.includes('sensitive-token-12345'));
  assert.deepStrictEqual(parsed.metadata, { env: 'production' });
}

// 8. isEmptyOrSpaces and isEnvTrue validate strings and evaluate boolean environment variable strings
{
  assert.strictEqual(isEmptyOrSpaces(null), true);
  assert.strictEqual(isEmptyOrSpaces(undefined), true);
  assert.strictEqual(isEmptyOrSpaces(''), true);
  assert.strictEqual(isEmptyOrSpaces('   '), true);
  assert.strictEqual(isEmptyOrSpaces('\t\n'), true);
  assert.strictEqual(isEmptyOrSpaces('builder-util'), false);

  assert.strictEqual(isEnvTrue(undefined), false);
  assert.strictEqual(isEnvTrue(''), true);
  assert.strictEqual(isEnvTrue('false'), false);
  assert.strictEqual(isEnvTrue('0'), false);
  assert.strictEqual(isEnvTrue('true'), true);
  assert.strictEqual(isEnvTrue('1'), true);
}

// 9. replaceDefault expands default placeholder with provided default list
{
  const defaultList = ['common/**', 'lib/**'];
  assert.deepStrictEqual(replaceDefault(['default'], defaultList), ['common/**', 'lib/**']);
  assert.deepStrictEqual(
    replaceDefault(['custom/prefix/**', 'default', 'custom/suffix/**'], defaultList),
    ['custom/prefix/**', 'common/**', 'lib/**', 'custom/suffix/**']
  );
  assert.deepStrictEqual(replaceDefault(['fixed/**'], defaultList), ['fixed/**']);
}

// 10. removePassword sanitizes password arguments in command strings with SHA-256 hashes
{
  const rawCommand = 'signtool.exe sign -p mySecretPassword123 /f cert.pfx';
  const sanitized = sanitizeCommand(rawCommand);
  const expectedHash = crypto.createHash('sha256').update('mySecretPassword123').digest('hex');
  assert(!sanitized.includes('mySecretPassword123'));
  assert(sanitized.includes(expectedHash));
  assert(sanitized.includes('(sha256 hash)'));
}

// 11. InvalidConfigurationError constructs configuration error with message and error code
{
  const customErr = new InvalidConfigurationError('Field appId is required', 'ERR_APP_ID_MISSING');
  assert(customErr instanceof Error);
  assert(customErr instanceof InvalidConfigurationError);
  assert.strictEqual(customErr.message, 'Field appId is required');
  assert.strictEqual(customErr.code, 'ERR_APP_ID_MISSING');

  const defaultErr = new InvalidConfigurationError('Invalid schema');
  assert.strictEqual(defaultErr.code, 'ERR_ELECTRON_BUILDER_INVALID_CONFIGURATION');
}

console.log('All builder-util contract tests passed successfully.');

オリジンシーダー

匿名