ua.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.getUserAgent = void 0;
  7. /*
  8. Copyright 2023 The Sigstore Authors.
  9. Licensed under the Apache License, Version 2.0 (the "License");
  10. you may not use this file except in compliance with the License.
  11. You may obtain a copy of the License at
  12. http://www.apache.org/licenses/LICENSE-2.0
  13. Unless required by applicable law or agreed to in writing, software
  14. distributed under the License is distributed on an "AS IS" BASIS,
  15. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. See the License for the specific language governing permissions and
  17. limitations under the License.
  18. */
  19. const os_1 = __importDefault(require("os"));
  20. // Format User-Agent: <product> / <product-version> (<platform>)
  21. // source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
  22. const getUserAgent = () => {
  23. const packageVersion = require('../../package.json').version;
  24. const nodeVersion = process.version;
  25. const platformName = os_1.default.platform();
  26. const archName = os_1.default.arch();
  27. return `sigstore-js/${packageVersion} (Node ${nodeVersion}) (${platformName}/${archName})`;
  28. };
  29. exports.getUserAgent = getUserAgent;