├── .eslintignore ├── .eslintrc.js ├── .github ├── dependabot.yml └── workflows │ ├── check-release.yml │ ├── release.yml │ ├── size.yml │ └── test.yml ├── .gitignore ├── .prettierrc.json ├── LICENSE ├── README.md ├── __tests__ └── main.test.ts ├── action.yml ├── dist └── index.js ├── docs └── assets │ └── screenshot.png ├── jest.config.js ├── package.json ├── src └── main.ts ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true, 4 | "es2021": true 5 | }, 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/recommended" 9 | ], 10 | "parser": "@typescript-eslint/parser", 11 | "parserOptions": { 12 | "ecmaVersion": 2021, 13 | "sourceType": "module" 14 | }, 15 | "plugins": [ 16 | "@typescript-eslint" 17 | ], 18 | "rules": { 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates 2 | 3 | version: 2 4 | updates: 5 | - package-ecosystem: npm 6 | directory: "/" 7 | schedule: 8 | interval: weekly 9 | time: "09:00" 10 | open-pull-requests-limit: 5 11 | labels: 12 | - dependencies 13 | - dependencies/dependabot 14 | - dependencies/npm 15 | -------------------------------------------------------------------------------- /.github/workflows/check-release.yml: -------------------------------------------------------------------------------- 1 | name: Check Release 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - labeled 7 | 8 | jobs: 9 | release: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | 14 | - uses: actions-ecosystem/action-release-label@v1 15 | id: release-label 16 | if: ${{ startsWith(github.event.label.name, 'release/') }} 17 | 18 | - uses: actions-ecosystem/action-get-latest-tag@v1 19 | id: get-latest-tag 20 | if: ${{ steps.release-label.outputs.level != null }} 21 | with: 22 | semver_only: true 23 | 24 | - uses: actions-ecosystem/action-bump-semver@v1 25 | id: bump-semver 26 | if: ${{ steps.release-label.outputs.level != null }} 27 | with: 28 | current_version: ${{ steps.get-latest-tag.outputs.tag }} 29 | level: ${{ steps.release-label.outputs.level }} 30 | 31 | - uses: actions-ecosystem/action-create-comment@v1 32 | if: ${{ steps.bump-semver.outputs.new_version != null }} 33 | with: 34 | github_token: ${{ secrets.GITHUB_TOKEN }} 35 | body: | 36 | This PR will update [${{ github.repository }}](https://github.com/${{ github.repository }}) from [${{ steps.get-latest-tag.outputs.tag }}](https://github.com/${{ github.repository }}/releases/tag/${{ steps.get-latest-tag.outputs.tag }}) to ${{ steps.bump-semver.outputs.new_version }} :rocket: 37 | 38 | If this update isn't as you expected, you may want to change or remove the *release label*. 39 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Create Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | release: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | 14 | - uses: actions-ecosystem/action-get-merged-pull-request@v1 15 | id: get-merged-pull-request 16 | with: 17 | github_token: ${{ secrets.GITHUB_TOKEN }} 18 | 19 | - uses: actions-ecosystem/action-release-label@v1 20 | id: release-label 21 | if: ${{ steps.get-merged-pull-request.outputs.title != null }} 22 | with: 23 | github_token: ${{ secrets.GITHUB_TOKEN }} 24 | labels: ${{ steps.get-merged-pull-request.outputs.labels }} 25 | 26 | - uses: actions-ecosystem/action-get-latest-tag@v1 27 | id: get-latest-tag 28 | if: ${{ steps.release-label.outputs.level != null }} 29 | with: 30 | semver_only: true 31 | 32 | - uses: actions-ecosystem/action-bump-semver@v1 33 | id: bump-semver 34 | if: ${{ steps.release-label.outputs.level != null }} 35 | with: 36 | current_version: ${{ steps.get-latest-tag.outputs.tag }} 37 | level: ${{ steps.release-label.outputs.level }} 38 | 39 | - uses: actions-ecosystem/action-regex-match@v2 40 | id: regex-match 41 | if: ${{ steps.bump-semver.outputs.new_version != null }} 42 | with: 43 | text: ${{ steps.get-merged-pull-request.outputs.body }} 44 | regex: '```release_note([\s\S]*)```' 45 | 46 | - uses: actions-ecosystem/action-push-tag@v1 47 | if: ${{ steps.bump-semver.outputs.new_version != null }} 48 | with: 49 | tag: ${{ steps.bump-semver.outputs.new_version }} 50 | message: "${{ steps.bump-semver.outputs.new_version }}: PR #${{ steps.get-merged-pull-request.outputs.number }} ${{ steps.get-merged-pull-request.outputs.title }}" 51 | 52 | - uses: actions/create-release@v1 53 | if: ${{ steps.release-label.outputs.level == 'major' || steps.release-label.outputs.level == 'minor' }} 54 | env: 55 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 56 | with: 57 | tag_name: ${{ steps.bump-semver.outputs.new_version }} 58 | release_name: ${{ steps.bump-semver.outputs.new_version }} 59 | body: ${{ steps.regex-match.outputs.group1 }} 60 | 61 | - uses: actions-ecosystem/action-create-comment@v1 62 | if: ${{ steps.bump-semver.outputs.new_version != null }} 63 | with: 64 | github_token: ${{ secrets.GITHUB_TOKEN }} 65 | number: ${{ steps.get-merged-pull-request.outputs.number }} 66 | body: | 67 | The new version [${{ steps.bump-semver.outputs.new_version }}](https://github.com/${{ github.repository }}/releases/tag/${{ steps.bump-semver.outputs.new_version }}) has been released :tada: 68 | -------------------------------------------------------------------------------- /.github/workflows/size.yml: -------------------------------------------------------------------------------- 1 | name: Size 2 | 3 | on: 4 | pull_request_target: 5 | types: [opened, synchronize] 6 | 7 | jobs: 8 | update_labels: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | 13 | - uses: actions-ecosystem/action-size@v2 14 | id: size 15 | 16 | - uses: actions-ecosystem/action-remove-labels@v1 17 | with: 18 | github_token: ${{ secrets.github_token }} 19 | labels: ${{ steps.size.outputs.stale_labels }} 20 | 21 | - uses: actions-ecosystem/action-add-labels@v1 22 | with: 23 | github_token: ${{ secrets.github_token }} 24 | labels: ${{ steps.size.outputs.new_label }} 25 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: push 4 | 5 | jobs: 6 | test: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | 11 | - uses: actions/setup-node@v2 12 | with: 13 | node-version: "16.x" 14 | 15 | - run: yarn install 16 | 17 | - run: yarn test 18 | 19 | - run: yarn format-check 20 | 21 | - run: yarn lint 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | lib/ 3 | __tests__/runner/* 4 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "none", 8 | "bracketSpacing": true, 9 | "arrowParens": "avoid", 10 | "parser": "typescript" 11 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2020 The Actions Ecosystem Authors 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Action Regex Match 2 | 3 | [![actions-workflow-test][actions-workflow-test-badge]][actions-workflow-test] 4 | [![release][release-badge]][release] 5 | [![license][license-badge]][license] 6 | 7 | This is a GitHub Action to do regex matching and output the matched text and groups captured by the given regex. 8 | 9 | GitHub Actions natively supports some helpful functions, like `contains` and `startsWith`, but doesn't regex matching. 10 | This actions provides the missing, useful function. 11 | 12 | It would be more useful to use this with other GitHub Actions' outputs. 13 | 14 | ## Inputs 15 | 16 | | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT | 17 | | ------- | ----------------------------------------------------- | -------- | -------- | ------- | 18 | | `text` | A text as the target for `inputs.regex`. | `string` | `true` | `N/A` | 19 | | `regex` | A regex for `inputs.text`. Supports capturing groups. | `string` | `true` | `N/A` | 20 | | `flags` | Flags for inputs.regex. e.g.) `'g'`, `'gm'` | `string` | `false` | `''` | 21 | 22 | ## Outputs 23 | 24 | | NAME | DESCRIPTION | TYPE | 25 | | -------- | ---------------------------------------------------------------------------------------------- | -------- | 26 | | `match` | The whole matched text. If the `inputs.regex` doesn't match `inputs.text`, this value is `''`. | `string` | 27 | | `group1` | The 1st captured group. | `string` | 28 | | `group2` | The 2nd captured group. | `string` | 29 | | `group3` | The 3rd captured group. | `string` | 30 | | `group4` | The 4th captured group. | `string` | 31 | | `group5` | The 5th captured group. | `string` | 32 | | `group6` | The 6th captured group. | `string` | 33 | | `group7` | The 7th captured group. | `string` | 34 | | `group8` | The 8th captured group. | `string` | 35 | | `group9` | The 9th captured group. | `string` | 36 | 37 | ## Example 38 | 39 | ```yaml 40 | name: Add Label with Comment 41 | 42 | on: [issue_comment] 43 | 44 | jobs: 45 | create_comment: 46 | runs-on: ubuntu-latest 47 | steps: 48 | - uses: actions/checkout@v2 49 | 50 | - uses: actions-ecosystem/action-regex-match@v2 51 | id: regex-match 52 | with: 53 | text: ${{ github.event.comment.body }} 54 | regex: '^/label\s*(.*?)\s*$' 55 | 56 | - uses: actions-ecosystem/action-add-labels@v1 57 | if: ${{ steps.regex-match.outputs.match != '' }} 58 | with: 59 | github_token: ${{ secrets.GITHUB_TOKEN }} 60 | labels: ${{ steps.regex-match.outputs.group1 }} 61 | ``` 62 | 63 | ```yaml 64 | name: Create Comment with Regex Match 65 | 66 | on: [issue_comment] 67 | 68 | jobs: 69 | create_comment: 70 | runs-on: ubuntu-latest 71 | steps: 72 | - uses: actions/checkout@v2 73 | 74 | - uses: actions-ecosystem/action-regex-match@v2 75 | id: regex-match 76 | with: 77 | text: ${{ github.event.comment.body }} 78 | regex: '```typescript([\s\S]*)```' 79 | flags: gm 80 | 81 | - uses: actions-ecosystem/action-create-comment@v1 82 | if: ${{ steps.regex-match.outputs.match != '' }} 83 | with: 84 | github_token: ${{ secrets.github_token }} 85 | body: | 86 | Hello, @${{ github.actor }}! 87 | 88 | The raw TypeScript code is here. 89 | 90 | --- 91 | 92 | ${{ steps.regex-match.outputs.group1 }} 93 | 94 | --- 95 | ``` 96 | 97 | ## License 98 | 99 | Copyright 2020 The Actions Ecosystem Authors. 100 | 101 | Action Regex Match is released under the [Apache License 2.0](./LICENSE). 102 | 103 | 104 | 105 | [actions-workflow-test]: https://github.com/actions-ecosystem/action-regex-match/actions?query=workflow%3ATest 106 | [actions-workflow-test-badge]: https://img.shields.io/github/workflow/status/actions-ecosystem/action-regex-match/Test?label=Test&style=for-the-badge&logo=github 107 | 108 | [release]: https://github.com/actions-ecosystem/action-regex-match/releases 109 | [release-badge]: https://img.shields.io/github/v/release/actions-ecosystem/action-regex-match?style=for-the-badge&logo=github 110 | 111 | [license]: LICENSE 112 | [license-badge]: https://img.shields.io/github/license/actions-ecosystem/action-add-labels?style=for-the-badge 113 | -------------------------------------------------------------------------------- /__tests__/main.test.ts: -------------------------------------------------------------------------------- 1 | describe('TODO - Add a test suite', () => { 2 | it('TODO - Add a test', async () => {}); 3 | }); 4 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Actions Ecosystem Action Regex Match 2 | description: Match a input text with a input regex. 3 | author: Actions Ecosystem 4 | inputs: 5 | text: 6 | description: A text as the target for inputs.regex. 7 | required: true 8 | regex: 9 | description: A regex for inputs.text. Supports capturing groups. 10 | required: true 11 | flags: 12 | description: Flags for inputs.regex. e.g.) 'g', 'gm' 13 | required: false 14 | outputs: 15 | match: 16 | description: The whole matched text. If the inputs.regex doesn't match inputs.text, this value is ''. 17 | group1: 18 | description: The 1st captured group. 19 | group2: 20 | description: The 2nd captured group. 21 | group3: 22 | description: The 3rd captured group. 23 | group4: 24 | description: The 4th captured group. 25 | group5: 26 | description: The 5th captured group. 27 | group6: 28 | description: The 6th captured group. 29 | group7: 30 | description: The 7th captured group. 31 | group8: 32 | description: The 8th captured group. 33 | group9: 34 | description: The 9th captured group. 35 | runs: 36 | using: node16 37 | main: dist/index.js 38 | branding: 39 | icon: search 40 | color: yellow 41 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | module.exports = 2 | /******/ (() => { // webpackBootstrap 3 | /******/ var __webpack_modules__ = ({ 4 | 5 | /***/ 109: 6 | /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 7 | 8 | "use strict"; 9 | 10 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 11 | if (k2 === undefined) k2 = k; 12 | var desc = Object.getOwnPropertyDescriptor(m, k); 13 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 14 | desc = { enumerable: true, get: function() { return m[k]; } }; 15 | } 16 | Object.defineProperty(o, k2, desc); 17 | }) : (function(o, m, k, k2) { 18 | if (k2 === undefined) k2 = k; 19 | o[k2] = m[k]; 20 | })); 21 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 22 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 23 | }) : function(o, v) { 24 | o["default"] = v; 25 | }); 26 | var __importStar = (this && this.__importStar) || function (mod) { 27 | if (mod && mod.__esModule) return mod; 28 | var result = {}; 29 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 30 | __setModuleDefault(result, mod); 31 | return result; 32 | }; 33 | Object.defineProperty(exports, "__esModule", ({ value: true })); 34 | const core = __importStar(__webpack_require__(186)); 35 | async function run() { 36 | try { 37 | const text = core.getInput('text'); 38 | const regex = core.getInput('regex'); 39 | const flags = core.getInput('flags'); 40 | const re = new RegExp(regex, flags); 41 | const result = re.exec(text); 42 | if (result) { 43 | for (const [index, x] of result.entries()) { 44 | if (index === 10) { 45 | return; 46 | } 47 | if (index === 0) { 48 | core.setOutput('match', x); 49 | continue; 50 | } 51 | core.setOutput(`group${index}`, x); 52 | } 53 | } 54 | } 55 | catch (error) { 56 | core.error(error); 57 | core.setFailed(error.message); 58 | } 59 | } 60 | run(); 61 | 62 | 63 | /***/ }), 64 | 65 | /***/ 351: 66 | /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 67 | 68 | "use strict"; 69 | 70 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 71 | if (k2 === undefined) k2 = k; 72 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 73 | }) : (function(o, m, k, k2) { 74 | if (k2 === undefined) k2 = k; 75 | o[k2] = m[k]; 76 | })); 77 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 78 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 79 | }) : function(o, v) { 80 | o["default"] = v; 81 | }); 82 | var __importStar = (this && this.__importStar) || function (mod) { 83 | if (mod && mod.__esModule) return mod; 84 | var result = {}; 85 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 86 | __setModuleDefault(result, mod); 87 | return result; 88 | }; 89 | Object.defineProperty(exports, "__esModule", ({ value: true })); 90 | exports.issue = exports.issueCommand = void 0; 91 | const os = __importStar(__webpack_require__(87)); 92 | const utils_1 = __webpack_require__(278); 93 | /** 94 | * Commands 95 | * 96 | * Command Format: 97 | * ::name key=value,key=value::message 98 | * 99 | * Examples: 100 | * ::warning::This is the message 101 | * ::set-env name=MY_VAR::some value 102 | */ 103 | function issueCommand(command, properties, message) { 104 | const cmd = new Command(command, properties, message); 105 | process.stdout.write(cmd.toString() + os.EOL); 106 | } 107 | exports.issueCommand = issueCommand; 108 | function issue(name, message = '') { 109 | issueCommand(name, {}, message); 110 | } 111 | exports.issue = issue; 112 | const CMD_STRING = '::'; 113 | class Command { 114 | constructor(command, properties, message) { 115 | if (!command) { 116 | command = 'missing.command'; 117 | } 118 | this.command = command; 119 | this.properties = properties; 120 | this.message = message; 121 | } 122 | toString() { 123 | let cmdStr = CMD_STRING + this.command; 124 | if (this.properties && Object.keys(this.properties).length > 0) { 125 | cmdStr += ' '; 126 | let first = true; 127 | for (const key in this.properties) { 128 | if (this.properties.hasOwnProperty(key)) { 129 | const val = this.properties[key]; 130 | if (val) { 131 | if (first) { 132 | first = false; 133 | } 134 | else { 135 | cmdStr += ','; 136 | } 137 | cmdStr += `${key}=${escapeProperty(val)}`; 138 | } 139 | } 140 | } 141 | } 142 | cmdStr += `${CMD_STRING}${escapeData(this.message)}`; 143 | return cmdStr; 144 | } 145 | } 146 | function escapeData(s) { 147 | return utils_1.toCommandValue(s) 148 | .replace(/%/g, '%25') 149 | .replace(/\r/g, '%0D') 150 | .replace(/\n/g, '%0A'); 151 | } 152 | function escapeProperty(s) { 153 | return utils_1.toCommandValue(s) 154 | .replace(/%/g, '%25') 155 | .replace(/\r/g, '%0D') 156 | .replace(/\n/g, '%0A') 157 | .replace(/:/g, '%3A') 158 | .replace(/,/g, '%2C'); 159 | } 160 | //# sourceMappingURL=command.js.map 161 | 162 | /***/ }), 163 | 164 | /***/ 186: 165 | /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 166 | 167 | "use strict"; 168 | 169 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 170 | if (k2 === undefined) k2 = k; 171 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 172 | }) : (function(o, m, k, k2) { 173 | if (k2 === undefined) k2 = k; 174 | o[k2] = m[k]; 175 | })); 176 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 177 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 178 | }) : function(o, v) { 179 | o["default"] = v; 180 | }); 181 | var __importStar = (this && this.__importStar) || function (mod) { 182 | if (mod && mod.__esModule) return mod; 183 | var result = {}; 184 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 185 | __setModuleDefault(result, mod); 186 | return result; 187 | }; 188 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 189 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 190 | return new (P || (P = Promise))(function (resolve, reject) { 191 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 192 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 193 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 194 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 195 | }); 196 | }; 197 | Object.defineProperty(exports, "__esModule", ({ value: true })); 198 | exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; 199 | const command_1 = __webpack_require__(351); 200 | const file_command_1 = __webpack_require__(717); 201 | const utils_1 = __webpack_require__(278); 202 | const os = __importStar(__webpack_require__(87)); 203 | const path = __importStar(__webpack_require__(622)); 204 | const oidc_utils_1 = __webpack_require__(41); 205 | /** 206 | * The code to exit an action 207 | */ 208 | var ExitCode; 209 | (function (ExitCode) { 210 | /** 211 | * A code indicating that the action was successful 212 | */ 213 | ExitCode[ExitCode["Success"] = 0] = "Success"; 214 | /** 215 | * A code indicating that the action was a failure 216 | */ 217 | ExitCode[ExitCode["Failure"] = 1] = "Failure"; 218 | })(ExitCode = exports.ExitCode || (exports.ExitCode = {})); 219 | //----------------------------------------------------------------------- 220 | // Variables 221 | //----------------------------------------------------------------------- 222 | /** 223 | * Sets env variable for this action and future actions in the job 224 | * @param name the name of the variable to set 225 | * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify 226 | */ 227 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 228 | function exportVariable(name, val) { 229 | const convertedVal = utils_1.toCommandValue(val); 230 | process.env[name] = convertedVal; 231 | const filePath = process.env['GITHUB_ENV'] || ''; 232 | if (filePath) { 233 | return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); 234 | } 235 | command_1.issueCommand('set-env', { name }, convertedVal); 236 | } 237 | exports.exportVariable = exportVariable; 238 | /** 239 | * Registers a secret which will get masked from logs 240 | * @param secret value of the secret 241 | */ 242 | function setSecret(secret) { 243 | command_1.issueCommand('add-mask', {}, secret); 244 | } 245 | exports.setSecret = setSecret; 246 | /** 247 | * Prepends inputPath to the PATH (for this action and future actions) 248 | * @param inputPath 249 | */ 250 | function addPath(inputPath) { 251 | const filePath = process.env['GITHUB_PATH'] || ''; 252 | if (filePath) { 253 | file_command_1.issueFileCommand('PATH', inputPath); 254 | } 255 | else { 256 | command_1.issueCommand('add-path', {}, inputPath); 257 | } 258 | process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; 259 | } 260 | exports.addPath = addPath; 261 | /** 262 | * Gets the value of an input. 263 | * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed. 264 | * Returns an empty string if the value is not defined. 265 | * 266 | * @param name name of the input to get 267 | * @param options optional. See InputOptions. 268 | * @returns string 269 | */ 270 | function getInput(name, options) { 271 | const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; 272 | if (options && options.required && !val) { 273 | throw new Error(`Input required and not supplied: ${name}`); 274 | } 275 | if (options && options.trimWhitespace === false) { 276 | return val; 277 | } 278 | return val.trim(); 279 | } 280 | exports.getInput = getInput; 281 | /** 282 | * Gets the values of an multiline input. Each value is also trimmed. 283 | * 284 | * @param name name of the input to get 285 | * @param options optional. See InputOptions. 286 | * @returns string[] 287 | * 288 | */ 289 | function getMultilineInput(name, options) { 290 | const inputs = getInput(name, options) 291 | .split('\n') 292 | .filter(x => x !== ''); 293 | if (options && options.trimWhitespace === false) { 294 | return inputs; 295 | } 296 | return inputs.map(input => input.trim()); 297 | } 298 | exports.getMultilineInput = getMultilineInput; 299 | /** 300 | * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification. 301 | * Support boolean input list: `true | True | TRUE | false | False | FALSE` . 302 | * The return value is also in boolean type. 303 | * ref: https://yaml.org/spec/1.2/spec.html#id2804923 304 | * 305 | * @param name name of the input to get 306 | * @param options optional. See InputOptions. 307 | * @returns boolean 308 | */ 309 | function getBooleanInput(name, options) { 310 | const trueValue = ['true', 'True', 'TRUE']; 311 | const falseValue = ['false', 'False', 'FALSE']; 312 | const val = getInput(name, options); 313 | if (trueValue.includes(val)) 314 | return true; 315 | if (falseValue.includes(val)) 316 | return false; 317 | throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` + 318 | `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); 319 | } 320 | exports.getBooleanInput = getBooleanInput; 321 | /** 322 | * Sets the value of an output. 323 | * 324 | * @param name name of the output to set 325 | * @param value value to store. Non-string values will be converted to a string via JSON.stringify 326 | */ 327 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 328 | function setOutput(name, value) { 329 | const filePath = process.env['GITHUB_OUTPUT'] || ''; 330 | if (filePath) { 331 | return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); 332 | } 333 | process.stdout.write(os.EOL); 334 | command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); 335 | } 336 | exports.setOutput = setOutput; 337 | /** 338 | * Enables or disables the echoing of commands into stdout for the rest of the step. 339 | * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. 340 | * 341 | */ 342 | function setCommandEcho(enabled) { 343 | command_1.issue('echo', enabled ? 'on' : 'off'); 344 | } 345 | exports.setCommandEcho = setCommandEcho; 346 | //----------------------------------------------------------------------- 347 | // Results 348 | //----------------------------------------------------------------------- 349 | /** 350 | * Sets the action status to failed. 351 | * When the action exits it will be with an exit code of 1 352 | * @param message add error issue message 353 | */ 354 | function setFailed(message) { 355 | process.exitCode = ExitCode.Failure; 356 | error(message); 357 | } 358 | exports.setFailed = setFailed; 359 | //----------------------------------------------------------------------- 360 | // Logging Commands 361 | //----------------------------------------------------------------------- 362 | /** 363 | * Gets whether Actions Step Debug is on or not 364 | */ 365 | function isDebug() { 366 | return process.env['RUNNER_DEBUG'] === '1'; 367 | } 368 | exports.isDebug = isDebug; 369 | /** 370 | * Writes debug message to user log 371 | * @param message debug message 372 | */ 373 | function debug(message) { 374 | command_1.issueCommand('debug', {}, message); 375 | } 376 | exports.debug = debug; 377 | /** 378 | * Adds an error issue 379 | * @param message error issue message. Errors will be converted to string via toString() 380 | * @param properties optional properties to add to the annotation. 381 | */ 382 | function error(message, properties = {}) { 383 | command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); 384 | } 385 | exports.error = error; 386 | /** 387 | * Adds a warning issue 388 | * @param message warning issue message. Errors will be converted to string via toString() 389 | * @param properties optional properties to add to the annotation. 390 | */ 391 | function warning(message, properties = {}) { 392 | command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); 393 | } 394 | exports.warning = warning; 395 | /** 396 | * Adds a notice issue 397 | * @param message notice issue message. Errors will be converted to string via toString() 398 | * @param properties optional properties to add to the annotation. 399 | */ 400 | function notice(message, properties = {}) { 401 | command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); 402 | } 403 | exports.notice = notice; 404 | /** 405 | * Writes info to log with console.log. 406 | * @param message info message 407 | */ 408 | function info(message) { 409 | process.stdout.write(message + os.EOL); 410 | } 411 | exports.info = info; 412 | /** 413 | * Begin an output group. 414 | * 415 | * Output until the next `groupEnd` will be foldable in this group 416 | * 417 | * @param name The name of the output group 418 | */ 419 | function startGroup(name) { 420 | command_1.issue('group', name); 421 | } 422 | exports.startGroup = startGroup; 423 | /** 424 | * End an output group. 425 | */ 426 | function endGroup() { 427 | command_1.issue('endgroup'); 428 | } 429 | exports.endGroup = endGroup; 430 | /** 431 | * Wrap an asynchronous function call in a group. 432 | * 433 | * Returns the same type as the function itself. 434 | * 435 | * @param name The name of the group 436 | * @param fn The function to wrap in the group 437 | */ 438 | function group(name, fn) { 439 | return __awaiter(this, void 0, void 0, function* () { 440 | startGroup(name); 441 | let result; 442 | try { 443 | result = yield fn(); 444 | } 445 | finally { 446 | endGroup(); 447 | } 448 | return result; 449 | }); 450 | } 451 | exports.group = group; 452 | //----------------------------------------------------------------------- 453 | // Wrapper action state 454 | //----------------------------------------------------------------------- 455 | /** 456 | * Saves state for current action, the state can only be retrieved by this action's post job execution. 457 | * 458 | * @param name name of the state to store 459 | * @param value value to store. Non-string values will be converted to a string via JSON.stringify 460 | */ 461 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 462 | function saveState(name, value) { 463 | const filePath = process.env['GITHUB_STATE'] || ''; 464 | if (filePath) { 465 | return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); 466 | } 467 | command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); 468 | } 469 | exports.saveState = saveState; 470 | /** 471 | * Gets the value of an state set by this action's main execution. 472 | * 473 | * @param name name of the state to get 474 | * @returns string 475 | */ 476 | function getState(name) { 477 | return process.env[`STATE_${name}`] || ''; 478 | } 479 | exports.getState = getState; 480 | function getIDToken(aud) { 481 | return __awaiter(this, void 0, void 0, function* () { 482 | return yield oidc_utils_1.OidcClient.getIDToken(aud); 483 | }); 484 | } 485 | exports.getIDToken = getIDToken; 486 | /** 487 | * Summary exports 488 | */ 489 | var summary_1 = __webpack_require__(327); 490 | Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); 491 | /** 492 | * @deprecated use core.summary 493 | */ 494 | var summary_2 = __webpack_require__(327); 495 | Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); 496 | /** 497 | * Path exports 498 | */ 499 | var path_utils_1 = __webpack_require__(981); 500 | Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); 501 | Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); 502 | Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); 503 | //# sourceMappingURL=core.js.map 504 | 505 | /***/ }), 506 | 507 | /***/ 717: 508 | /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 509 | 510 | "use strict"; 511 | 512 | // For internal use, subject to change. 513 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 514 | if (k2 === undefined) k2 = k; 515 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 516 | }) : (function(o, m, k, k2) { 517 | if (k2 === undefined) k2 = k; 518 | o[k2] = m[k]; 519 | })); 520 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 521 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 522 | }) : function(o, v) { 523 | o["default"] = v; 524 | }); 525 | var __importStar = (this && this.__importStar) || function (mod) { 526 | if (mod && mod.__esModule) return mod; 527 | var result = {}; 528 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 529 | __setModuleDefault(result, mod); 530 | return result; 531 | }; 532 | Object.defineProperty(exports, "__esModule", ({ value: true })); 533 | exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; 534 | // We use any as a valid input type 535 | /* eslint-disable @typescript-eslint/no-explicit-any */ 536 | const fs = __importStar(__webpack_require__(747)); 537 | const os = __importStar(__webpack_require__(87)); 538 | const uuid_1 = __webpack_require__(521); 539 | const utils_1 = __webpack_require__(278); 540 | function issueFileCommand(command, message) { 541 | const filePath = process.env[`GITHUB_${command}`]; 542 | if (!filePath) { 543 | throw new Error(`Unable to find environment variable for file command ${command}`); 544 | } 545 | if (!fs.existsSync(filePath)) { 546 | throw new Error(`Missing file at path: ${filePath}`); 547 | } 548 | fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { 549 | encoding: 'utf8' 550 | }); 551 | } 552 | exports.issueFileCommand = issueFileCommand; 553 | function prepareKeyValueMessage(key, value) { 554 | const delimiter = `ghadelimiter_${uuid_1.v4()}`; 555 | const convertedValue = utils_1.toCommandValue(value); 556 | // These should realistically never happen, but just in case someone finds a 557 | // way to exploit uuid generation let's not allow keys or values that contain 558 | // the delimiter. 559 | if (key.includes(delimiter)) { 560 | throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); 561 | } 562 | if (convertedValue.includes(delimiter)) { 563 | throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); 564 | } 565 | return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; 566 | } 567 | exports.prepareKeyValueMessage = prepareKeyValueMessage; 568 | //# sourceMappingURL=file-command.js.map 569 | 570 | /***/ }), 571 | 572 | /***/ 41: 573 | /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 574 | 575 | "use strict"; 576 | 577 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 578 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 579 | return new (P || (P = Promise))(function (resolve, reject) { 580 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 581 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 582 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 583 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 584 | }); 585 | }; 586 | Object.defineProperty(exports, "__esModule", ({ value: true })); 587 | exports.OidcClient = void 0; 588 | const http_client_1 = __webpack_require__(404); 589 | const auth_1 = __webpack_require__(758); 590 | const core_1 = __webpack_require__(186); 591 | class OidcClient { 592 | static createHttpClient(allowRetry = true, maxRetry = 10) { 593 | const requestOptions = { 594 | allowRetries: allowRetry, 595 | maxRetries: maxRetry 596 | }; 597 | return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions); 598 | } 599 | static getRequestToken() { 600 | const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN']; 601 | if (!token) { 602 | throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable'); 603 | } 604 | return token; 605 | } 606 | static getIDTokenUrl() { 607 | const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL']; 608 | if (!runtimeUrl) { 609 | throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable'); 610 | } 611 | return runtimeUrl; 612 | } 613 | static getCall(id_token_url) { 614 | var _a; 615 | return __awaiter(this, void 0, void 0, function* () { 616 | const httpclient = OidcClient.createHttpClient(); 617 | const res = yield httpclient 618 | .getJson(id_token_url) 619 | .catch(error => { 620 | throw new Error(`Failed to get ID Token. \n 621 | Error Code : ${error.statusCode}\n 622 | Error Message: ${error.result.message}`); 623 | }); 624 | const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; 625 | if (!id_token) { 626 | throw new Error('Response json body do not have ID Token field'); 627 | } 628 | return id_token; 629 | }); 630 | } 631 | static getIDToken(audience) { 632 | return __awaiter(this, void 0, void 0, function* () { 633 | try { 634 | // New ID Token is requested from action service 635 | let id_token_url = OidcClient.getIDTokenUrl(); 636 | if (audience) { 637 | const encodedAudience = encodeURIComponent(audience); 638 | id_token_url = `${id_token_url}&audience=${encodedAudience}`; 639 | } 640 | core_1.debug(`ID token url is ${id_token_url}`); 641 | const id_token = yield OidcClient.getCall(id_token_url); 642 | core_1.setSecret(id_token); 643 | return id_token; 644 | } 645 | catch (error) { 646 | throw new Error(`Error message: ${error.message}`); 647 | } 648 | }); 649 | } 650 | } 651 | exports.OidcClient = OidcClient; 652 | //# sourceMappingURL=oidc-utils.js.map 653 | 654 | /***/ }), 655 | 656 | /***/ 981: 657 | /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 658 | 659 | "use strict"; 660 | 661 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 662 | if (k2 === undefined) k2 = k; 663 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 664 | }) : (function(o, m, k, k2) { 665 | if (k2 === undefined) k2 = k; 666 | o[k2] = m[k]; 667 | })); 668 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 669 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 670 | }) : function(o, v) { 671 | o["default"] = v; 672 | }); 673 | var __importStar = (this && this.__importStar) || function (mod) { 674 | if (mod && mod.__esModule) return mod; 675 | var result = {}; 676 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 677 | __setModuleDefault(result, mod); 678 | return result; 679 | }; 680 | Object.defineProperty(exports, "__esModule", ({ value: true })); 681 | exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; 682 | const path = __importStar(__webpack_require__(622)); 683 | /** 684 | * toPosixPath converts the given path to the posix form. On Windows, \\ will be 685 | * replaced with /. 686 | * 687 | * @param pth. Path to transform. 688 | * @return string Posix path. 689 | */ 690 | function toPosixPath(pth) { 691 | return pth.replace(/[\\]/g, '/'); 692 | } 693 | exports.toPosixPath = toPosixPath; 694 | /** 695 | * toWin32Path converts the given path to the win32 form. On Linux, / will be 696 | * replaced with \\. 697 | * 698 | * @param pth. Path to transform. 699 | * @return string Win32 path. 700 | */ 701 | function toWin32Path(pth) { 702 | return pth.replace(/[/]/g, '\\'); 703 | } 704 | exports.toWin32Path = toWin32Path; 705 | /** 706 | * toPlatformPath converts the given path to a platform-specific path. It does 707 | * this by replacing instances of / and \ with the platform-specific path 708 | * separator. 709 | * 710 | * @param pth The path to platformize. 711 | * @return string The platform-specific path. 712 | */ 713 | function toPlatformPath(pth) { 714 | return pth.replace(/[/\\]/g, path.sep); 715 | } 716 | exports.toPlatformPath = toPlatformPath; 717 | //# sourceMappingURL=path-utils.js.map 718 | 719 | /***/ }), 720 | 721 | /***/ 327: 722 | /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 723 | 724 | "use strict"; 725 | 726 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 727 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 728 | return new (P || (P = Promise))(function (resolve, reject) { 729 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 730 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 731 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 732 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 733 | }); 734 | }; 735 | Object.defineProperty(exports, "__esModule", ({ value: true })); 736 | exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; 737 | const os_1 = __webpack_require__(87); 738 | const fs_1 = __webpack_require__(747); 739 | const { access, appendFile, writeFile } = fs_1.promises; 740 | exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; 741 | exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; 742 | class Summary { 743 | constructor() { 744 | this._buffer = ''; 745 | } 746 | /** 747 | * Finds the summary file path from the environment, rejects if env var is not found or file does not exist 748 | * Also checks r/w permissions. 749 | * 750 | * @returns step summary file path 751 | */ 752 | filePath() { 753 | return __awaiter(this, void 0, void 0, function* () { 754 | if (this._filePath) { 755 | return this._filePath; 756 | } 757 | const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; 758 | if (!pathFromEnv) { 759 | throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); 760 | } 761 | try { 762 | yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); 763 | } 764 | catch (_a) { 765 | throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); 766 | } 767 | this._filePath = pathFromEnv; 768 | return this._filePath; 769 | }); 770 | } 771 | /** 772 | * Wraps content in an HTML tag, adding any HTML attributes 773 | * 774 | * @param {string} tag HTML tag to wrap 775 | * @param {string | null} content content within the tag 776 | * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add 777 | * 778 | * @returns {string} content wrapped in HTML element 779 | */ 780 | wrap(tag, content, attrs = {}) { 781 | const htmlAttrs = Object.entries(attrs) 782 | .map(([key, value]) => ` ${key}="${value}"`) 783 | .join(''); 784 | if (!content) { 785 | return `<${tag}${htmlAttrs}>`; 786 | } 787 | return `<${tag}${htmlAttrs}>${content}`; 788 | } 789 | /** 790 | * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. 791 | * 792 | * @param {SummaryWriteOptions} [options] (optional) options for write operation 793 | * 794 | * @returns {Promise} summary instance 795 | */ 796 | write(options) { 797 | return __awaiter(this, void 0, void 0, function* () { 798 | const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); 799 | const filePath = yield this.filePath(); 800 | const writeFunc = overwrite ? writeFile : appendFile; 801 | yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); 802 | return this.emptyBuffer(); 803 | }); 804 | } 805 | /** 806 | * Clears the summary buffer and wipes the summary file 807 | * 808 | * @returns {Summary} summary instance 809 | */ 810 | clear() { 811 | return __awaiter(this, void 0, void 0, function* () { 812 | return this.emptyBuffer().write({ overwrite: true }); 813 | }); 814 | } 815 | /** 816 | * Returns the current summary buffer as a string 817 | * 818 | * @returns {string} string of summary buffer 819 | */ 820 | stringify() { 821 | return this._buffer; 822 | } 823 | /** 824 | * If the summary buffer is empty 825 | * 826 | * @returns {boolen} true if the buffer is empty 827 | */ 828 | isEmptyBuffer() { 829 | return this._buffer.length === 0; 830 | } 831 | /** 832 | * Resets the summary buffer without writing to summary file 833 | * 834 | * @returns {Summary} summary instance 835 | */ 836 | emptyBuffer() { 837 | this._buffer = ''; 838 | return this; 839 | } 840 | /** 841 | * Adds raw text to the summary buffer 842 | * 843 | * @param {string} text content to add 844 | * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) 845 | * 846 | * @returns {Summary} summary instance 847 | */ 848 | addRaw(text, addEOL = false) { 849 | this._buffer += text; 850 | return addEOL ? this.addEOL() : this; 851 | } 852 | /** 853 | * Adds the operating system-specific end-of-line marker to the buffer 854 | * 855 | * @returns {Summary} summary instance 856 | */ 857 | addEOL() { 858 | return this.addRaw(os_1.EOL); 859 | } 860 | /** 861 | * Adds an HTML codeblock to the summary buffer 862 | * 863 | * @param {string} code content to render within fenced code block 864 | * @param {string} lang (optional) language to syntax highlight code 865 | * 866 | * @returns {Summary} summary instance 867 | */ 868 | addCodeBlock(code, lang) { 869 | const attrs = Object.assign({}, (lang && { lang })); 870 | const element = this.wrap('pre', this.wrap('code', code), attrs); 871 | return this.addRaw(element).addEOL(); 872 | } 873 | /** 874 | * Adds an HTML list to the summary buffer 875 | * 876 | * @param {string[]} items list of items to render 877 | * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) 878 | * 879 | * @returns {Summary} summary instance 880 | */ 881 | addList(items, ordered = false) { 882 | const tag = ordered ? 'ol' : 'ul'; 883 | const listItems = items.map(item => this.wrap('li', item)).join(''); 884 | const element = this.wrap(tag, listItems); 885 | return this.addRaw(element).addEOL(); 886 | } 887 | /** 888 | * Adds an HTML table to the summary buffer 889 | * 890 | * @param {SummaryTableCell[]} rows table rows 891 | * 892 | * @returns {Summary} summary instance 893 | */ 894 | addTable(rows) { 895 | const tableBody = rows 896 | .map(row => { 897 | const cells = row 898 | .map(cell => { 899 | if (typeof cell === 'string') { 900 | return this.wrap('td', cell); 901 | } 902 | const { header, data, colspan, rowspan } = cell; 903 | const tag = header ? 'th' : 'td'; 904 | const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); 905 | return this.wrap(tag, data, attrs); 906 | }) 907 | .join(''); 908 | return this.wrap('tr', cells); 909 | }) 910 | .join(''); 911 | const element = this.wrap('table', tableBody); 912 | return this.addRaw(element).addEOL(); 913 | } 914 | /** 915 | * Adds a collapsable HTML details element to the summary buffer 916 | * 917 | * @param {string} label text for the closed state 918 | * @param {string} content collapsable content 919 | * 920 | * @returns {Summary} summary instance 921 | */ 922 | addDetails(label, content) { 923 | const element = this.wrap('details', this.wrap('summary', label) + content); 924 | return this.addRaw(element).addEOL(); 925 | } 926 | /** 927 | * Adds an HTML image tag to the summary buffer 928 | * 929 | * @param {string} src path to the image you to embed 930 | * @param {string} alt text description of the image 931 | * @param {SummaryImageOptions} options (optional) addition image attributes 932 | * 933 | * @returns {Summary} summary instance 934 | */ 935 | addImage(src, alt, options) { 936 | const { width, height } = options || {}; 937 | const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); 938 | const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); 939 | return this.addRaw(element).addEOL(); 940 | } 941 | /** 942 | * Adds an HTML section heading element 943 | * 944 | * @param {string} text heading text 945 | * @param {number | string} [level=1] (optional) the heading level, default: 1 946 | * 947 | * @returns {Summary} summary instance 948 | */ 949 | addHeading(text, level) { 950 | const tag = `h${level}`; 951 | const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) 952 | ? tag 953 | : 'h1'; 954 | const element = this.wrap(allowedTag, text); 955 | return this.addRaw(element).addEOL(); 956 | } 957 | /** 958 | * Adds an HTML thematic break (
) to the summary buffer 959 | * 960 | * @returns {Summary} summary instance 961 | */ 962 | addSeparator() { 963 | const element = this.wrap('hr', null); 964 | return this.addRaw(element).addEOL(); 965 | } 966 | /** 967 | * Adds an HTML line break (
) to the summary buffer 968 | * 969 | * @returns {Summary} summary instance 970 | */ 971 | addBreak() { 972 | const element = this.wrap('br', null); 973 | return this.addRaw(element).addEOL(); 974 | } 975 | /** 976 | * Adds an HTML blockquote to the summary buffer 977 | * 978 | * @param {string} text quote text 979 | * @param {string} cite (optional) citation url 980 | * 981 | * @returns {Summary} summary instance 982 | */ 983 | addQuote(text, cite) { 984 | const attrs = Object.assign({}, (cite && { cite })); 985 | const element = this.wrap('blockquote', text, attrs); 986 | return this.addRaw(element).addEOL(); 987 | } 988 | /** 989 | * Adds an HTML anchor tag to the summary buffer 990 | * 991 | * @param {string} text link text/content 992 | * @param {string} href hyperlink 993 | * 994 | * @returns {Summary} summary instance 995 | */ 996 | addLink(text, href) { 997 | const element = this.wrap('a', text, { href }); 998 | return this.addRaw(element).addEOL(); 999 | } 1000 | } 1001 | const _summary = new Summary(); 1002 | /** 1003 | * @deprecated use `core.summary` 1004 | */ 1005 | exports.markdownSummary = _summary; 1006 | exports.summary = _summary; 1007 | //# sourceMappingURL=summary.js.map 1008 | 1009 | /***/ }), 1010 | 1011 | /***/ 278: 1012 | /***/ ((__unused_webpack_module, exports) => { 1013 | 1014 | "use strict"; 1015 | 1016 | // We use any as a valid input type 1017 | /* eslint-disable @typescript-eslint/no-explicit-any */ 1018 | Object.defineProperty(exports, "__esModule", ({ value: true })); 1019 | exports.toCommandProperties = exports.toCommandValue = void 0; 1020 | /** 1021 | * Sanitizes an input into a string so it can be passed into issueCommand safely 1022 | * @param input input to sanitize into a string 1023 | */ 1024 | function toCommandValue(input) { 1025 | if (input === null || input === undefined) { 1026 | return ''; 1027 | } 1028 | else if (typeof input === 'string' || input instanceof String) { 1029 | return input; 1030 | } 1031 | return JSON.stringify(input); 1032 | } 1033 | exports.toCommandValue = toCommandValue; 1034 | /** 1035 | * 1036 | * @param annotationProperties 1037 | * @returns The command properties to send with the actual annotation command 1038 | * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646 1039 | */ 1040 | function toCommandProperties(annotationProperties) { 1041 | if (!Object.keys(annotationProperties).length) { 1042 | return {}; 1043 | } 1044 | return { 1045 | title: annotationProperties.title, 1046 | file: annotationProperties.file, 1047 | line: annotationProperties.startLine, 1048 | endLine: annotationProperties.endLine, 1049 | col: annotationProperties.startColumn, 1050 | endColumn: annotationProperties.endColumn 1051 | }; 1052 | } 1053 | exports.toCommandProperties = toCommandProperties; 1054 | //# sourceMappingURL=utils.js.map 1055 | 1056 | /***/ }), 1057 | 1058 | /***/ 758: 1059 | /***/ (function(__unused_webpack_module, exports) { 1060 | 1061 | "use strict"; 1062 | 1063 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 1064 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 1065 | return new (P || (P = Promise))(function (resolve, reject) { 1066 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 1067 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 1068 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 1069 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 1070 | }); 1071 | }; 1072 | Object.defineProperty(exports, "__esModule", ({ value: true })); 1073 | exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0; 1074 | class BasicCredentialHandler { 1075 | constructor(username, password) { 1076 | this.username = username; 1077 | this.password = password; 1078 | } 1079 | prepareRequest(options) { 1080 | if (!options.headers) { 1081 | throw Error('The request has no headers'); 1082 | } 1083 | options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`; 1084 | } 1085 | // This handler cannot handle 401 1086 | canHandleAuthentication() { 1087 | return false; 1088 | } 1089 | handleAuthentication() { 1090 | return __awaiter(this, void 0, void 0, function* () { 1091 | throw new Error('not implemented'); 1092 | }); 1093 | } 1094 | } 1095 | exports.BasicCredentialHandler = BasicCredentialHandler; 1096 | class BearerCredentialHandler { 1097 | constructor(token) { 1098 | this.token = token; 1099 | } 1100 | // currently implements pre-authorization 1101 | // TODO: support preAuth = false where it hooks on 401 1102 | prepareRequest(options) { 1103 | if (!options.headers) { 1104 | throw Error('The request has no headers'); 1105 | } 1106 | options.headers['Authorization'] = `Bearer ${this.token}`; 1107 | } 1108 | // This handler cannot handle 401 1109 | canHandleAuthentication() { 1110 | return false; 1111 | } 1112 | handleAuthentication() { 1113 | return __awaiter(this, void 0, void 0, function* () { 1114 | throw new Error('not implemented'); 1115 | }); 1116 | } 1117 | } 1118 | exports.BearerCredentialHandler = BearerCredentialHandler; 1119 | class PersonalAccessTokenCredentialHandler { 1120 | constructor(token) { 1121 | this.token = token; 1122 | } 1123 | // currently implements pre-authorization 1124 | // TODO: support preAuth = false where it hooks on 401 1125 | prepareRequest(options) { 1126 | if (!options.headers) { 1127 | throw Error('The request has no headers'); 1128 | } 1129 | options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`; 1130 | } 1131 | // This handler cannot handle 401 1132 | canHandleAuthentication() { 1133 | return false; 1134 | } 1135 | handleAuthentication() { 1136 | return __awaiter(this, void 0, void 0, function* () { 1137 | throw new Error('not implemented'); 1138 | }); 1139 | } 1140 | } 1141 | exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; 1142 | //# sourceMappingURL=auth.js.map 1143 | 1144 | /***/ }), 1145 | 1146 | /***/ 404: 1147 | /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 1148 | 1149 | "use strict"; 1150 | 1151 | /* eslint-disable @typescript-eslint/no-explicit-any */ 1152 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 1153 | if (k2 === undefined) k2 = k; 1154 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 1155 | }) : (function(o, m, k, k2) { 1156 | if (k2 === undefined) k2 = k; 1157 | o[k2] = m[k]; 1158 | })); 1159 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 1160 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 1161 | }) : function(o, v) { 1162 | o["default"] = v; 1163 | }); 1164 | var __importStar = (this && this.__importStar) || function (mod) { 1165 | if (mod && mod.__esModule) return mod; 1166 | var result = {}; 1167 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 1168 | __setModuleDefault(result, mod); 1169 | return result; 1170 | }; 1171 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 1172 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 1173 | return new (P || (P = Promise))(function (resolve, reject) { 1174 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 1175 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 1176 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 1177 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 1178 | }); 1179 | }; 1180 | Object.defineProperty(exports, "__esModule", ({ value: true })); 1181 | exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0; 1182 | const http = __importStar(__webpack_require__(605)); 1183 | const https = __importStar(__webpack_require__(211)); 1184 | const pm = __importStar(__webpack_require__(843)); 1185 | const tunnel = __importStar(__webpack_require__(294)); 1186 | var HttpCodes; 1187 | (function (HttpCodes) { 1188 | HttpCodes[HttpCodes["OK"] = 200] = "OK"; 1189 | HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; 1190 | HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; 1191 | HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; 1192 | HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; 1193 | HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; 1194 | HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; 1195 | HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; 1196 | HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; 1197 | HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; 1198 | HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; 1199 | HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; 1200 | HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; 1201 | HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; 1202 | HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; 1203 | HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; 1204 | HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; 1205 | HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; 1206 | HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; 1207 | HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; 1208 | HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; 1209 | HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; 1210 | HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; 1211 | HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; 1212 | HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; 1213 | HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; 1214 | HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; 1215 | })(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); 1216 | var Headers; 1217 | (function (Headers) { 1218 | Headers["Accept"] = "accept"; 1219 | Headers["ContentType"] = "content-type"; 1220 | })(Headers = exports.Headers || (exports.Headers = {})); 1221 | var MediaTypes; 1222 | (function (MediaTypes) { 1223 | MediaTypes["ApplicationJson"] = "application/json"; 1224 | })(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); 1225 | /** 1226 | * Returns the proxy URL, depending upon the supplied url and proxy environment variables. 1227 | * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com 1228 | */ 1229 | function getProxyUrl(serverUrl) { 1230 | const proxyUrl = pm.getProxyUrl(new URL(serverUrl)); 1231 | return proxyUrl ? proxyUrl.href : ''; 1232 | } 1233 | exports.getProxyUrl = getProxyUrl; 1234 | const HttpRedirectCodes = [ 1235 | HttpCodes.MovedPermanently, 1236 | HttpCodes.ResourceMoved, 1237 | HttpCodes.SeeOther, 1238 | HttpCodes.TemporaryRedirect, 1239 | HttpCodes.PermanentRedirect 1240 | ]; 1241 | const HttpResponseRetryCodes = [ 1242 | HttpCodes.BadGateway, 1243 | HttpCodes.ServiceUnavailable, 1244 | HttpCodes.GatewayTimeout 1245 | ]; 1246 | const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; 1247 | const ExponentialBackoffCeiling = 10; 1248 | const ExponentialBackoffTimeSlice = 5; 1249 | class HttpClientError extends Error { 1250 | constructor(message, statusCode) { 1251 | super(message); 1252 | this.name = 'HttpClientError'; 1253 | this.statusCode = statusCode; 1254 | Object.setPrototypeOf(this, HttpClientError.prototype); 1255 | } 1256 | } 1257 | exports.HttpClientError = HttpClientError; 1258 | class HttpClientResponse { 1259 | constructor(message) { 1260 | this.message = message; 1261 | } 1262 | readBody() { 1263 | return __awaiter(this, void 0, void 0, function* () { 1264 | return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { 1265 | let output = Buffer.alloc(0); 1266 | this.message.on('data', (chunk) => { 1267 | output = Buffer.concat([output, chunk]); 1268 | }); 1269 | this.message.on('end', () => { 1270 | resolve(output.toString()); 1271 | }); 1272 | })); 1273 | }); 1274 | } 1275 | } 1276 | exports.HttpClientResponse = HttpClientResponse; 1277 | function isHttps(requestUrl) { 1278 | const parsedUrl = new URL(requestUrl); 1279 | return parsedUrl.protocol === 'https:'; 1280 | } 1281 | exports.isHttps = isHttps; 1282 | class HttpClient { 1283 | constructor(userAgent, handlers, requestOptions) { 1284 | this._ignoreSslError = false; 1285 | this._allowRedirects = true; 1286 | this._allowRedirectDowngrade = false; 1287 | this._maxRedirects = 50; 1288 | this._allowRetries = false; 1289 | this._maxRetries = 1; 1290 | this._keepAlive = false; 1291 | this._disposed = false; 1292 | this.userAgent = userAgent; 1293 | this.handlers = handlers || []; 1294 | this.requestOptions = requestOptions; 1295 | if (requestOptions) { 1296 | if (requestOptions.ignoreSslError != null) { 1297 | this._ignoreSslError = requestOptions.ignoreSslError; 1298 | } 1299 | this._socketTimeout = requestOptions.socketTimeout; 1300 | if (requestOptions.allowRedirects != null) { 1301 | this._allowRedirects = requestOptions.allowRedirects; 1302 | } 1303 | if (requestOptions.allowRedirectDowngrade != null) { 1304 | this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; 1305 | } 1306 | if (requestOptions.maxRedirects != null) { 1307 | this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); 1308 | } 1309 | if (requestOptions.keepAlive != null) { 1310 | this._keepAlive = requestOptions.keepAlive; 1311 | } 1312 | if (requestOptions.allowRetries != null) { 1313 | this._allowRetries = requestOptions.allowRetries; 1314 | } 1315 | if (requestOptions.maxRetries != null) { 1316 | this._maxRetries = requestOptions.maxRetries; 1317 | } 1318 | } 1319 | } 1320 | options(requestUrl, additionalHeaders) { 1321 | return __awaiter(this, void 0, void 0, function* () { 1322 | return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); 1323 | }); 1324 | } 1325 | get(requestUrl, additionalHeaders) { 1326 | return __awaiter(this, void 0, void 0, function* () { 1327 | return this.request('GET', requestUrl, null, additionalHeaders || {}); 1328 | }); 1329 | } 1330 | del(requestUrl, additionalHeaders) { 1331 | return __awaiter(this, void 0, void 0, function* () { 1332 | return this.request('DELETE', requestUrl, null, additionalHeaders || {}); 1333 | }); 1334 | } 1335 | post(requestUrl, data, additionalHeaders) { 1336 | return __awaiter(this, void 0, void 0, function* () { 1337 | return this.request('POST', requestUrl, data, additionalHeaders || {}); 1338 | }); 1339 | } 1340 | patch(requestUrl, data, additionalHeaders) { 1341 | return __awaiter(this, void 0, void 0, function* () { 1342 | return this.request('PATCH', requestUrl, data, additionalHeaders || {}); 1343 | }); 1344 | } 1345 | put(requestUrl, data, additionalHeaders) { 1346 | return __awaiter(this, void 0, void 0, function* () { 1347 | return this.request('PUT', requestUrl, data, additionalHeaders || {}); 1348 | }); 1349 | } 1350 | head(requestUrl, additionalHeaders) { 1351 | return __awaiter(this, void 0, void 0, function* () { 1352 | return this.request('HEAD', requestUrl, null, additionalHeaders || {}); 1353 | }); 1354 | } 1355 | sendStream(verb, requestUrl, stream, additionalHeaders) { 1356 | return __awaiter(this, void 0, void 0, function* () { 1357 | return this.request(verb, requestUrl, stream, additionalHeaders); 1358 | }); 1359 | } 1360 | /** 1361 | * Gets a typed object from an endpoint 1362 | * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise 1363 | */ 1364 | getJson(requestUrl, additionalHeaders = {}) { 1365 | return __awaiter(this, void 0, void 0, function* () { 1366 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 1367 | const res = yield this.get(requestUrl, additionalHeaders); 1368 | return this._processResponse(res, this.requestOptions); 1369 | }); 1370 | } 1371 | postJson(requestUrl, obj, additionalHeaders = {}) { 1372 | return __awaiter(this, void 0, void 0, function* () { 1373 | const data = JSON.stringify(obj, null, 2); 1374 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 1375 | additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); 1376 | const res = yield this.post(requestUrl, data, additionalHeaders); 1377 | return this._processResponse(res, this.requestOptions); 1378 | }); 1379 | } 1380 | putJson(requestUrl, obj, additionalHeaders = {}) { 1381 | return __awaiter(this, void 0, void 0, function* () { 1382 | const data = JSON.stringify(obj, null, 2); 1383 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 1384 | additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); 1385 | const res = yield this.put(requestUrl, data, additionalHeaders); 1386 | return this._processResponse(res, this.requestOptions); 1387 | }); 1388 | } 1389 | patchJson(requestUrl, obj, additionalHeaders = {}) { 1390 | return __awaiter(this, void 0, void 0, function* () { 1391 | const data = JSON.stringify(obj, null, 2); 1392 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 1393 | additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); 1394 | const res = yield this.patch(requestUrl, data, additionalHeaders); 1395 | return this._processResponse(res, this.requestOptions); 1396 | }); 1397 | } 1398 | /** 1399 | * Makes a raw http request. 1400 | * All other methods such as get, post, patch, and request ultimately call this. 1401 | * Prefer get, del, post and patch 1402 | */ 1403 | request(verb, requestUrl, data, headers) { 1404 | return __awaiter(this, void 0, void 0, function* () { 1405 | if (this._disposed) { 1406 | throw new Error('Client has already been disposed.'); 1407 | } 1408 | const parsedUrl = new URL(requestUrl); 1409 | let info = this._prepareRequest(verb, parsedUrl, headers); 1410 | // Only perform retries on reads since writes may not be idempotent. 1411 | const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) 1412 | ? this._maxRetries + 1 1413 | : 1; 1414 | let numTries = 0; 1415 | let response; 1416 | do { 1417 | response = yield this.requestRaw(info, data); 1418 | // Check if it's an authentication challenge 1419 | if (response && 1420 | response.message && 1421 | response.message.statusCode === HttpCodes.Unauthorized) { 1422 | let authenticationHandler; 1423 | for (const handler of this.handlers) { 1424 | if (handler.canHandleAuthentication(response)) { 1425 | authenticationHandler = handler; 1426 | break; 1427 | } 1428 | } 1429 | if (authenticationHandler) { 1430 | return authenticationHandler.handleAuthentication(this, info, data); 1431 | } 1432 | else { 1433 | // We have received an unauthorized response but have no handlers to handle it. 1434 | // Let the response return to the caller. 1435 | return response; 1436 | } 1437 | } 1438 | let redirectsRemaining = this._maxRedirects; 1439 | while (response.message.statusCode && 1440 | HttpRedirectCodes.includes(response.message.statusCode) && 1441 | this._allowRedirects && 1442 | redirectsRemaining > 0) { 1443 | const redirectUrl = response.message.headers['location']; 1444 | if (!redirectUrl) { 1445 | // if there's no location to redirect to, we won't 1446 | break; 1447 | } 1448 | const parsedRedirectUrl = new URL(redirectUrl); 1449 | if (parsedUrl.protocol === 'https:' && 1450 | parsedUrl.protocol !== parsedRedirectUrl.protocol && 1451 | !this._allowRedirectDowngrade) { 1452 | throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); 1453 | } 1454 | // we need to finish reading the response before reassigning response 1455 | // which will leak the open socket. 1456 | yield response.readBody(); 1457 | // strip authorization header if redirected to a different hostname 1458 | if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { 1459 | for (const header in headers) { 1460 | // header names are case insensitive 1461 | if (header.toLowerCase() === 'authorization') { 1462 | delete headers[header]; 1463 | } 1464 | } 1465 | } 1466 | // let's make the request with the new redirectUrl 1467 | info = this._prepareRequest(verb, parsedRedirectUrl, headers); 1468 | response = yield this.requestRaw(info, data); 1469 | redirectsRemaining--; 1470 | } 1471 | if (!response.message.statusCode || 1472 | !HttpResponseRetryCodes.includes(response.message.statusCode)) { 1473 | // If not a retry code, return immediately instead of retrying 1474 | return response; 1475 | } 1476 | numTries += 1; 1477 | if (numTries < maxTries) { 1478 | yield response.readBody(); 1479 | yield this._performExponentialBackoff(numTries); 1480 | } 1481 | } while (numTries < maxTries); 1482 | return response; 1483 | }); 1484 | } 1485 | /** 1486 | * Needs to be called if keepAlive is set to true in request options. 1487 | */ 1488 | dispose() { 1489 | if (this._agent) { 1490 | this._agent.destroy(); 1491 | } 1492 | this._disposed = true; 1493 | } 1494 | /** 1495 | * Raw request. 1496 | * @param info 1497 | * @param data 1498 | */ 1499 | requestRaw(info, data) { 1500 | return __awaiter(this, void 0, void 0, function* () { 1501 | return new Promise((resolve, reject) => { 1502 | function callbackForResult(err, res) { 1503 | if (err) { 1504 | reject(err); 1505 | } 1506 | else if (!res) { 1507 | // If `err` is not passed, then `res` must be passed. 1508 | reject(new Error('Unknown error')); 1509 | } 1510 | else { 1511 | resolve(res); 1512 | } 1513 | } 1514 | this.requestRawWithCallback(info, data, callbackForResult); 1515 | }); 1516 | }); 1517 | } 1518 | /** 1519 | * Raw request with callback. 1520 | * @param info 1521 | * @param data 1522 | * @param onResult 1523 | */ 1524 | requestRawWithCallback(info, data, onResult) { 1525 | if (typeof data === 'string') { 1526 | if (!info.options.headers) { 1527 | info.options.headers = {}; 1528 | } 1529 | info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); 1530 | } 1531 | let callbackCalled = false; 1532 | function handleResult(err, res) { 1533 | if (!callbackCalled) { 1534 | callbackCalled = true; 1535 | onResult(err, res); 1536 | } 1537 | } 1538 | const req = info.httpModule.request(info.options, (msg) => { 1539 | const res = new HttpClientResponse(msg); 1540 | handleResult(undefined, res); 1541 | }); 1542 | let socket; 1543 | req.on('socket', sock => { 1544 | socket = sock; 1545 | }); 1546 | // If we ever get disconnected, we want the socket to timeout eventually 1547 | req.setTimeout(this._socketTimeout || 3 * 60000, () => { 1548 | if (socket) { 1549 | socket.end(); 1550 | } 1551 | handleResult(new Error(`Request timeout: ${info.options.path}`)); 1552 | }); 1553 | req.on('error', function (err) { 1554 | // err has statusCode property 1555 | // res should have headers 1556 | handleResult(err); 1557 | }); 1558 | if (data && typeof data === 'string') { 1559 | req.write(data, 'utf8'); 1560 | } 1561 | if (data && typeof data !== 'string') { 1562 | data.on('close', function () { 1563 | req.end(); 1564 | }); 1565 | data.pipe(req); 1566 | } 1567 | else { 1568 | req.end(); 1569 | } 1570 | } 1571 | /** 1572 | * Gets an http agent. This function is useful when you need an http agent that handles 1573 | * routing through a proxy server - depending upon the url and proxy environment variables. 1574 | * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com 1575 | */ 1576 | getAgent(serverUrl) { 1577 | const parsedUrl = new URL(serverUrl); 1578 | return this._getAgent(parsedUrl); 1579 | } 1580 | _prepareRequest(method, requestUrl, headers) { 1581 | const info = {}; 1582 | info.parsedUrl = requestUrl; 1583 | const usingSsl = info.parsedUrl.protocol === 'https:'; 1584 | info.httpModule = usingSsl ? https : http; 1585 | const defaultPort = usingSsl ? 443 : 80; 1586 | info.options = {}; 1587 | info.options.host = info.parsedUrl.hostname; 1588 | info.options.port = info.parsedUrl.port 1589 | ? parseInt(info.parsedUrl.port) 1590 | : defaultPort; 1591 | info.options.path = 1592 | (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); 1593 | info.options.method = method; 1594 | info.options.headers = this._mergeHeaders(headers); 1595 | if (this.userAgent != null) { 1596 | info.options.headers['user-agent'] = this.userAgent; 1597 | } 1598 | info.options.agent = this._getAgent(info.parsedUrl); 1599 | // gives handlers an opportunity to participate 1600 | if (this.handlers) { 1601 | for (const handler of this.handlers) { 1602 | handler.prepareRequest(info.options); 1603 | } 1604 | } 1605 | return info; 1606 | } 1607 | _mergeHeaders(headers) { 1608 | if (this.requestOptions && this.requestOptions.headers) { 1609 | return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {})); 1610 | } 1611 | return lowercaseKeys(headers || {}); 1612 | } 1613 | _getExistingOrDefaultHeader(additionalHeaders, header, _default) { 1614 | let clientHeader; 1615 | if (this.requestOptions && this.requestOptions.headers) { 1616 | clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; 1617 | } 1618 | return additionalHeaders[header] || clientHeader || _default; 1619 | } 1620 | _getAgent(parsedUrl) { 1621 | let agent; 1622 | const proxyUrl = pm.getProxyUrl(parsedUrl); 1623 | const useProxy = proxyUrl && proxyUrl.hostname; 1624 | if (this._keepAlive && useProxy) { 1625 | agent = this._proxyAgent; 1626 | } 1627 | if (this._keepAlive && !useProxy) { 1628 | agent = this._agent; 1629 | } 1630 | // if agent is already assigned use that agent. 1631 | if (agent) { 1632 | return agent; 1633 | } 1634 | const usingSsl = parsedUrl.protocol === 'https:'; 1635 | let maxSockets = 100; 1636 | if (this.requestOptions) { 1637 | maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; 1638 | } 1639 | // This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis. 1640 | if (proxyUrl && proxyUrl.hostname) { 1641 | const agentOptions = { 1642 | maxSockets, 1643 | keepAlive: this._keepAlive, 1644 | proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && { 1645 | proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` 1646 | })), { host: proxyUrl.hostname, port: proxyUrl.port }) 1647 | }; 1648 | let tunnelAgent; 1649 | const overHttps = proxyUrl.protocol === 'https:'; 1650 | if (usingSsl) { 1651 | tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; 1652 | } 1653 | else { 1654 | tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; 1655 | } 1656 | agent = tunnelAgent(agentOptions); 1657 | this._proxyAgent = agent; 1658 | } 1659 | // if reusing agent across request and tunneling agent isn't assigned create a new agent 1660 | if (this._keepAlive && !agent) { 1661 | const options = { keepAlive: this._keepAlive, maxSockets }; 1662 | agent = usingSsl ? new https.Agent(options) : new http.Agent(options); 1663 | this._agent = agent; 1664 | } 1665 | // if not using private agent and tunnel agent isn't setup then use global agent 1666 | if (!agent) { 1667 | agent = usingSsl ? https.globalAgent : http.globalAgent; 1668 | } 1669 | if (usingSsl && this._ignoreSslError) { 1670 | // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process 1671 | // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options 1672 | // we have to cast it to any and change it directly 1673 | agent.options = Object.assign(agent.options || {}, { 1674 | rejectUnauthorized: false 1675 | }); 1676 | } 1677 | return agent; 1678 | } 1679 | _performExponentialBackoff(retryNumber) { 1680 | return __awaiter(this, void 0, void 0, function* () { 1681 | retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); 1682 | const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); 1683 | return new Promise(resolve => setTimeout(() => resolve(), ms)); 1684 | }); 1685 | } 1686 | _processResponse(res, options) { 1687 | return __awaiter(this, void 0, void 0, function* () { 1688 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { 1689 | const statusCode = res.message.statusCode || 0; 1690 | const response = { 1691 | statusCode, 1692 | result: null, 1693 | headers: {} 1694 | }; 1695 | // not found leads to null obj returned 1696 | if (statusCode === HttpCodes.NotFound) { 1697 | resolve(response); 1698 | } 1699 | // get the result from the body 1700 | function dateTimeDeserializer(key, value) { 1701 | if (typeof value === 'string') { 1702 | const a = new Date(value); 1703 | if (!isNaN(a.valueOf())) { 1704 | return a; 1705 | } 1706 | } 1707 | return value; 1708 | } 1709 | let obj; 1710 | let contents; 1711 | try { 1712 | contents = yield res.readBody(); 1713 | if (contents && contents.length > 0) { 1714 | if (options && options.deserializeDates) { 1715 | obj = JSON.parse(contents, dateTimeDeserializer); 1716 | } 1717 | else { 1718 | obj = JSON.parse(contents); 1719 | } 1720 | response.result = obj; 1721 | } 1722 | response.headers = res.message.headers; 1723 | } 1724 | catch (err) { 1725 | // Invalid resource (contents not json); leaving result obj null 1726 | } 1727 | // note that 3xx redirects are handled by the http layer. 1728 | if (statusCode > 299) { 1729 | let msg; 1730 | // if exception/error in body, attempt to get better error 1731 | if (obj && obj.message) { 1732 | msg = obj.message; 1733 | } 1734 | else if (contents && contents.length > 0) { 1735 | // it may be the case that the exception is in the body message as string 1736 | msg = contents; 1737 | } 1738 | else { 1739 | msg = `Failed request: (${statusCode})`; 1740 | } 1741 | const err = new HttpClientError(msg, statusCode); 1742 | err.result = response.result; 1743 | reject(err); 1744 | } 1745 | else { 1746 | resolve(response); 1747 | } 1748 | })); 1749 | }); 1750 | } 1751 | } 1752 | exports.HttpClient = HttpClient; 1753 | const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); 1754 | //# sourceMappingURL=index.js.map 1755 | 1756 | /***/ }), 1757 | 1758 | /***/ 843: 1759 | /***/ ((__unused_webpack_module, exports) => { 1760 | 1761 | "use strict"; 1762 | 1763 | Object.defineProperty(exports, "__esModule", ({ value: true })); 1764 | exports.checkBypass = exports.getProxyUrl = void 0; 1765 | function getProxyUrl(reqUrl) { 1766 | const usingSsl = reqUrl.protocol === 'https:'; 1767 | if (checkBypass(reqUrl)) { 1768 | return undefined; 1769 | } 1770 | const proxyVar = (() => { 1771 | if (usingSsl) { 1772 | return process.env['https_proxy'] || process.env['HTTPS_PROXY']; 1773 | } 1774 | else { 1775 | return process.env['http_proxy'] || process.env['HTTP_PROXY']; 1776 | } 1777 | })(); 1778 | if (proxyVar) { 1779 | return new URL(proxyVar); 1780 | } 1781 | else { 1782 | return undefined; 1783 | } 1784 | } 1785 | exports.getProxyUrl = getProxyUrl; 1786 | function checkBypass(reqUrl) { 1787 | if (!reqUrl.hostname) { 1788 | return false; 1789 | } 1790 | const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; 1791 | if (!noProxy) { 1792 | return false; 1793 | } 1794 | // Determine the request port 1795 | let reqPort; 1796 | if (reqUrl.port) { 1797 | reqPort = Number(reqUrl.port); 1798 | } 1799 | else if (reqUrl.protocol === 'http:') { 1800 | reqPort = 80; 1801 | } 1802 | else if (reqUrl.protocol === 'https:') { 1803 | reqPort = 443; 1804 | } 1805 | // Format the request hostname and hostname with port 1806 | const upperReqHosts = [reqUrl.hostname.toUpperCase()]; 1807 | if (typeof reqPort === 'number') { 1808 | upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); 1809 | } 1810 | // Compare request host against noproxy 1811 | for (const upperNoProxyItem of noProxy 1812 | .split(',') 1813 | .map(x => x.trim().toUpperCase()) 1814 | .filter(x => x)) { 1815 | if (upperReqHosts.some(x => x === upperNoProxyItem)) { 1816 | return true; 1817 | } 1818 | } 1819 | return false; 1820 | } 1821 | exports.checkBypass = checkBypass; 1822 | //# sourceMappingURL=proxy.js.map 1823 | 1824 | /***/ }), 1825 | 1826 | /***/ 294: 1827 | /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1828 | 1829 | module.exports = __webpack_require__(219); 1830 | 1831 | 1832 | /***/ }), 1833 | 1834 | /***/ 219: 1835 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 1836 | 1837 | "use strict"; 1838 | 1839 | 1840 | var net = __webpack_require__(631); 1841 | var tls = __webpack_require__(16); 1842 | var http = __webpack_require__(605); 1843 | var https = __webpack_require__(211); 1844 | var events = __webpack_require__(614); 1845 | var assert = __webpack_require__(357); 1846 | var util = __webpack_require__(669); 1847 | 1848 | 1849 | exports.httpOverHttp = httpOverHttp; 1850 | exports.httpsOverHttp = httpsOverHttp; 1851 | exports.httpOverHttps = httpOverHttps; 1852 | exports.httpsOverHttps = httpsOverHttps; 1853 | 1854 | 1855 | function httpOverHttp(options) { 1856 | var agent = new TunnelingAgent(options); 1857 | agent.request = http.request; 1858 | return agent; 1859 | } 1860 | 1861 | function httpsOverHttp(options) { 1862 | var agent = new TunnelingAgent(options); 1863 | agent.request = http.request; 1864 | agent.createSocket = createSecureSocket; 1865 | agent.defaultPort = 443; 1866 | return agent; 1867 | } 1868 | 1869 | function httpOverHttps(options) { 1870 | var agent = new TunnelingAgent(options); 1871 | agent.request = https.request; 1872 | return agent; 1873 | } 1874 | 1875 | function httpsOverHttps(options) { 1876 | var agent = new TunnelingAgent(options); 1877 | agent.request = https.request; 1878 | agent.createSocket = createSecureSocket; 1879 | agent.defaultPort = 443; 1880 | return agent; 1881 | } 1882 | 1883 | 1884 | function TunnelingAgent(options) { 1885 | var self = this; 1886 | self.options = options || {}; 1887 | self.proxyOptions = self.options.proxy || {}; 1888 | self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; 1889 | self.requests = []; 1890 | self.sockets = []; 1891 | 1892 | self.on('free', function onFree(socket, host, port, localAddress) { 1893 | var options = toOptions(host, port, localAddress); 1894 | for (var i = 0, len = self.requests.length; i < len; ++i) { 1895 | var pending = self.requests[i]; 1896 | if (pending.host === options.host && pending.port === options.port) { 1897 | // Detect the request to connect same origin server, 1898 | // reuse the connection. 1899 | self.requests.splice(i, 1); 1900 | pending.request.onSocket(socket); 1901 | return; 1902 | } 1903 | } 1904 | socket.destroy(); 1905 | self.removeSocket(socket); 1906 | }); 1907 | } 1908 | util.inherits(TunnelingAgent, events.EventEmitter); 1909 | 1910 | TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { 1911 | var self = this; 1912 | var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); 1913 | 1914 | if (self.sockets.length >= this.maxSockets) { 1915 | // We are over limit so we'll add it to the queue. 1916 | self.requests.push(options); 1917 | return; 1918 | } 1919 | 1920 | // If we are under maxSockets create a new one. 1921 | self.createSocket(options, function(socket) { 1922 | socket.on('free', onFree); 1923 | socket.on('close', onCloseOrRemove); 1924 | socket.on('agentRemove', onCloseOrRemove); 1925 | req.onSocket(socket); 1926 | 1927 | function onFree() { 1928 | self.emit('free', socket, options); 1929 | } 1930 | 1931 | function onCloseOrRemove(err) { 1932 | self.removeSocket(socket); 1933 | socket.removeListener('free', onFree); 1934 | socket.removeListener('close', onCloseOrRemove); 1935 | socket.removeListener('agentRemove', onCloseOrRemove); 1936 | } 1937 | }); 1938 | }; 1939 | 1940 | TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { 1941 | var self = this; 1942 | var placeholder = {}; 1943 | self.sockets.push(placeholder); 1944 | 1945 | var connectOptions = mergeOptions({}, self.proxyOptions, { 1946 | method: 'CONNECT', 1947 | path: options.host + ':' + options.port, 1948 | agent: false, 1949 | headers: { 1950 | host: options.host + ':' + options.port 1951 | } 1952 | }); 1953 | if (options.localAddress) { 1954 | connectOptions.localAddress = options.localAddress; 1955 | } 1956 | if (connectOptions.proxyAuth) { 1957 | connectOptions.headers = connectOptions.headers || {}; 1958 | connectOptions.headers['Proxy-Authorization'] = 'Basic ' + 1959 | new Buffer(connectOptions.proxyAuth).toString('base64'); 1960 | } 1961 | 1962 | debug('making CONNECT request'); 1963 | var connectReq = self.request(connectOptions); 1964 | connectReq.useChunkedEncodingByDefault = false; // for v0.6 1965 | connectReq.once('response', onResponse); // for v0.6 1966 | connectReq.once('upgrade', onUpgrade); // for v0.6 1967 | connectReq.once('connect', onConnect); // for v0.7 or later 1968 | connectReq.once('error', onError); 1969 | connectReq.end(); 1970 | 1971 | function onResponse(res) { 1972 | // Very hacky. This is necessary to avoid http-parser leaks. 1973 | res.upgrade = true; 1974 | } 1975 | 1976 | function onUpgrade(res, socket, head) { 1977 | // Hacky. 1978 | process.nextTick(function() { 1979 | onConnect(res, socket, head); 1980 | }); 1981 | } 1982 | 1983 | function onConnect(res, socket, head) { 1984 | connectReq.removeAllListeners(); 1985 | socket.removeAllListeners(); 1986 | 1987 | if (res.statusCode !== 200) { 1988 | debug('tunneling socket could not be established, statusCode=%d', 1989 | res.statusCode); 1990 | socket.destroy(); 1991 | var error = new Error('tunneling socket could not be established, ' + 1992 | 'statusCode=' + res.statusCode); 1993 | error.code = 'ECONNRESET'; 1994 | options.request.emit('error', error); 1995 | self.removeSocket(placeholder); 1996 | return; 1997 | } 1998 | if (head.length > 0) { 1999 | debug('got illegal response body from proxy'); 2000 | socket.destroy(); 2001 | var error = new Error('got illegal response body from proxy'); 2002 | error.code = 'ECONNRESET'; 2003 | options.request.emit('error', error); 2004 | self.removeSocket(placeholder); 2005 | return; 2006 | } 2007 | debug('tunneling connection has established'); 2008 | self.sockets[self.sockets.indexOf(placeholder)] = socket; 2009 | return cb(socket); 2010 | } 2011 | 2012 | function onError(cause) { 2013 | connectReq.removeAllListeners(); 2014 | 2015 | debug('tunneling socket could not be established, cause=%s\n', 2016 | cause.message, cause.stack); 2017 | var error = new Error('tunneling socket could not be established, ' + 2018 | 'cause=' + cause.message); 2019 | error.code = 'ECONNRESET'; 2020 | options.request.emit('error', error); 2021 | self.removeSocket(placeholder); 2022 | } 2023 | }; 2024 | 2025 | TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { 2026 | var pos = this.sockets.indexOf(socket) 2027 | if (pos === -1) { 2028 | return; 2029 | } 2030 | this.sockets.splice(pos, 1); 2031 | 2032 | var pending = this.requests.shift(); 2033 | if (pending) { 2034 | // If we have pending requests and a socket gets closed a new one 2035 | // needs to be created to take over in the pool for the one that closed. 2036 | this.createSocket(pending, function(socket) { 2037 | pending.request.onSocket(socket); 2038 | }); 2039 | } 2040 | }; 2041 | 2042 | function createSecureSocket(options, cb) { 2043 | var self = this; 2044 | TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { 2045 | var hostHeader = options.request.getHeader('host'); 2046 | var tlsOptions = mergeOptions({}, self.options, { 2047 | socket: socket, 2048 | servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host 2049 | }); 2050 | 2051 | // 0 is dummy port for v0.6 2052 | var secureSocket = tls.connect(0, tlsOptions); 2053 | self.sockets[self.sockets.indexOf(socket)] = secureSocket; 2054 | cb(secureSocket); 2055 | }); 2056 | } 2057 | 2058 | 2059 | function toOptions(host, port, localAddress) { 2060 | if (typeof host === 'string') { // since v0.10 2061 | return { 2062 | host: host, 2063 | port: port, 2064 | localAddress: localAddress 2065 | }; 2066 | } 2067 | return host; // for v0.11 or later 2068 | } 2069 | 2070 | function mergeOptions(target) { 2071 | for (var i = 1, len = arguments.length; i < len; ++i) { 2072 | var overrides = arguments[i]; 2073 | if (typeof overrides === 'object') { 2074 | var keys = Object.keys(overrides); 2075 | for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { 2076 | var k = keys[j]; 2077 | if (overrides[k] !== undefined) { 2078 | target[k] = overrides[k]; 2079 | } 2080 | } 2081 | } 2082 | } 2083 | return target; 2084 | } 2085 | 2086 | 2087 | var debug; 2088 | if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { 2089 | debug = function() { 2090 | var args = Array.prototype.slice.call(arguments); 2091 | if (typeof args[0] === 'string') { 2092 | args[0] = 'TUNNEL: ' + args[0]; 2093 | } else { 2094 | args.unshift('TUNNEL:'); 2095 | } 2096 | console.error.apply(console, args); 2097 | } 2098 | } else { 2099 | debug = function() {}; 2100 | } 2101 | exports.debug = debug; // for test 2102 | 2103 | 2104 | /***/ }), 2105 | 2106 | /***/ 521: 2107 | /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 2108 | 2109 | "use strict"; 2110 | // ESM COMPAT FLAG 2111 | __webpack_require__.r(__webpack_exports__); 2112 | 2113 | // EXPORTS 2114 | __webpack_require__.d(__webpack_exports__, { 2115 | "NIL": () => /* reexport */ nil, 2116 | "parse": () => /* reexport */ esm_node_parse, 2117 | "stringify": () => /* reexport */ esm_node_stringify, 2118 | "v1": () => /* reexport */ esm_node_v1, 2119 | "v3": () => /* reexport */ esm_node_v3, 2120 | "v4": () => /* reexport */ esm_node_v4, 2121 | "v5": () => /* reexport */ esm_node_v5, 2122 | "validate": () => /* reexport */ esm_node_validate, 2123 | "version": () => /* reexport */ esm_node_version 2124 | }); 2125 | 2126 | // CONCATENATED MODULE: external "crypto" 2127 | const external_crypto_namespaceObject = require("crypto");; 2128 | var external_crypto_default = /*#__PURE__*/__webpack_require__.n(external_crypto_namespaceObject); 2129 | 2130 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/rng.js 2131 | 2132 | const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate 2133 | 2134 | let poolPtr = rnds8Pool.length; 2135 | function rng() { 2136 | if (poolPtr > rnds8Pool.length - 16) { 2137 | external_crypto_default().randomFillSync(rnds8Pool); 2138 | poolPtr = 0; 2139 | } 2140 | 2141 | return rnds8Pool.slice(poolPtr, poolPtr += 16); 2142 | } 2143 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/regex.js 2144 | /* harmony default export */ const regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i); 2145 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/validate.js 2146 | 2147 | 2148 | function validate(uuid) { 2149 | return typeof uuid === 'string' && regex.test(uuid); 2150 | } 2151 | 2152 | /* harmony default export */ const esm_node_validate = (validate); 2153 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/stringify.js 2154 | 2155 | /** 2156 | * Convert array of 16 byte values to UUID string format of the form: 2157 | * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 2158 | */ 2159 | 2160 | const byteToHex = []; 2161 | 2162 | for (let i = 0; i < 256; ++i) { 2163 | byteToHex.push((i + 0x100).toString(16).substr(1)); 2164 | } 2165 | 2166 | function stringify(arr, offset = 0) { 2167 | // Note: Be careful editing this code! It's been tuned for performance 2168 | // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 2169 | const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one 2170 | // of the following: 2171 | // - One or more input array values don't map to a hex octet (leading to 2172 | // "undefined" in the uuid) 2173 | // - Invalid input values for the RFC `version` or `variant` fields 2174 | 2175 | if (!esm_node_validate(uuid)) { 2176 | throw TypeError('Stringified UUID is invalid'); 2177 | } 2178 | 2179 | return uuid; 2180 | } 2181 | 2182 | /* harmony default export */ const esm_node_stringify = (stringify); 2183 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/v1.js 2184 | 2185 | // **`v1()` - Generate time-based UUID** 2186 | // 2187 | // Inspired by https://github.com/LiosK/UUID.js 2188 | // and http://docs.python.org/library/uuid.html 2189 | 2190 | let _nodeId; 2191 | 2192 | let _clockseq; // Previous uuid creation time 2193 | 2194 | 2195 | let _lastMSecs = 0; 2196 | let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details 2197 | 2198 | function v1(options, buf, offset) { 2199 | let i = buf && offset || 0; 2200 | const b = buf || new Array(16); 2201 | options = options || {}; 2202 | let node = options.node || _nodeId; 2203 | let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not 2204 | // specified. We do this lazily to minimize issues related to insufficient 2205 | // system entropy. See #189 2206 | 2207 | if (node == null || clockseq == null) { 2208 | const seedBytes = options.random || (options.rng || rng)(); 2209 | 2210 | if (node == null) { 2211 | // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) 2212 | node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; 2213 | } 2214 | 2215 | if (clockseq == null) { 2216 | // Per 4.2.2, randomize (14 bit) clockseq 2217 | clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; 2218 | } 2219 | } // UUID timestamps are 100 nano-second units since the Gregorian epoch, 2220 | // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so 2221 | // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' 2222 | // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. 2223 | 2224 | 2225 | let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock 2226 | // cycle to simulate higher resolution clock 2227 | 2228 | let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) 2229 | 2230 | const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression 2231 | 2232 | if (dt < 0 && options.clockseq === undefined) { 2233 | clockseq = clockseq + 1 & 0x3fff; 2234 | } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new 2235 | // time interval 2236 | 2237 | 2238 | if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { 2239 | nsecs = 0; 2240 | } // Per 4.2.1.2 Throw error if too many uuids are requested 2241 | 2242 | 2243 | if (nsecs >= 10000) { 2244 | throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); 2245 | } 2246 | 2247 | _lastMSecs = msecs; 2248 | _lastNSecs = nsecs; 2249 | _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch 2250 | 2251 | msecs += 12219292800000; // `time_low` 2252 | 2253 | const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; 2254 | b[i++] = tl >>> 24 & 0xff; 2255 | b[i++] = tl >>> 16 & 0xff; 2256 | b[i++] = tl >>> 8 & 0xff; 2257 | b[i++] = tl & 0xff; // `time_mid` 2258 | 2259 | const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; 2260 | b[i++] = tmh >>> 8 & 0xff; 2261 | b[i++] = tmh & 0xff; // `time_high_and_version` 2262 | 2263 | b[i++] = tmh >>> 24 & 0xf | 0x10; // include version 2264 | 2265 | b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) 2266 | 2267 | b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` 2268 | 2269 | b[i++] = clockseq & 0xff; // `node` 2270 | 2271 | for (let n = 0; n < 6; ++n) { 2272 | b[i + n] = node[n]; 2273 | } 2274 | 2275 | return buf || esm_node_stringify(b); 2276 | } 2277 | 2278 | /* harmony default export */ const esm_node_v1 = (v1); 2279 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/parse.js 2280 | 2281 | 2282 | function parse(uuid) { 2283 | if (!esm_node_validate(uuid)) { 2284 | throw TypeError('Invalid UUID'); 2285 | } 2286 | 2287 | let v; 2288 | const arr = new Uint8Array(16); // Parse ########-....-....-....-............ 2289 | 2290 | arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; 2291 | arr[1] = v >>> 16 & 0xff; 2292 | arr[2] = v >>> 8 & 0xff; 2293 | arr[3] = v & 0xff; // Parse ........-####-....-....-............ 2294 | 2295 | arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; 2296 | arr[5] = v & 0xff; // Parse ........-....-####-....-............ 2297 | 2298 | arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; 2299 | arr[7] = v & 0xff; // Parse ........-....-....-####-............ 2300 | 2301 | arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; 2302 | arr[9] = v & 0xff; // Parse ........-....-....-....-############ 2303 | // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) 2304 | 2305 | arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; 2306 | arr[11] = v / 0x100000000 & 0xff; 2307 | arr[12] = v >>> 24 & 0xff; 2308 | arr[13] = v >>> 16 & 0xff; 2309 | arr[14] = v >>> 8 & 0xff; 2310 | arr[15] = v & 0xff; 2311 | return arr; 2312 | } 2313 | 2314 | /* harmony default export */ const esm_node_parse = (parse); 2315 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/v35.js 2316 | 2317 | 2318 | 2319 | function stringToBytes(str) { 2320 | str = unescape(encodeURIComponent(str)); // UTF8 escape 2321 | 2322 | const bytes = []; 2323 | 2324 | for (let i = 0; i < str.length; ++i) { 2325 | bytes.push(str.charCodeAt(i)); 2326 | } 2327 | 2328 | return bytes; 2329 | } 2330 | 2331 | const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; 2332 | const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; 2333 | /* harmony default export */ function v35(name, version, hashfunc) { 2334 | function generateUUID(value, namespace, buf, offset) { 2335 | if (typeof value === 'string') { 2336 | value = stringToBytes(value); 2337 | } 2338 | 2339 | if (typeof namespace === 'string') { 2340 | namespace = esm_node_parse(namespace); 2341 | } 2342 | 2343 | if (namespace.length !== 16) { 2344 | throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); 2345 | } // Compute hash of namespace and value, Per 4.3 2346 | // Future: Use spread syntax when supported on all platforms, e.g. `bytes = 2347 | // hashfunc([...namespace, ... value])` 2348 | 2349 | 2350 | let bytes = new Uint8Array(16 + value.length); 2351 | bytes.set(namespace); 2352 | bytes.set(value, namespace.length); 2353 | bytes = hashfunc(bytes); 2354 | bytes[6] = bytes[6] & 0x0f | version; 2355 | bytes[8] = bytes[8] & 0x3f | 0x80; 2356 | 2357 | if (buf) { 2358 | offset = offset || 0; 2359 | 2360 | for (let i = 0; i < 16; ++i) { 2361 | buf[offset + i] = bytes[i]; 2362 | } 2363 | 2364 | return buf; 2365 | } 2366 | 2367 | return esm_node_stringify(bytes); 2368 | } // Function#name is not settable on some platforms (#270) 2369 | 2370 | 2371 | try { 2372 | generateUUID.name = name; // eslint-disable-next-line no-empty 2373 | } catch (err) {} // For CommonJS default export support 2374 | 2375 | 2376 | generateUUID.DNS = DNS; 2377 | generateUUID.URL = URL; 2378 | return generateUUID; 2379 | } 2380 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/md5.js 2381 | 2382 | 2383 | function md5(bytes) { 2384 | if (Array.isArray(bytes)) { 2385 | bytes = Buffer.from(bytes); 2386 | } else if (typeof bytes === 'string') { 2387 | bytes = Buffer.from(bytes, 'utf8'); 2388 | } 2389 | 2390 | return external_crypto_default().createHash('md5').update(bytes).digest(); 2391 | } 2392 | 2393 | /* harmony default export */ const esm_node_md5 = (md5); 2394 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/v3.js 2395 | 2396 | 2397 | const v3 = v35('v3', 0x30, esm_node_md5); 2398 | /* harmony default export */ const esm_node_v3 = (v3); 2399 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/v4.js 2400 | 2401 | 2402 | 2403 | function v4(options, buf, offset) { 2404 | options = options || {}; 2405 | const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` 2406 | 2407 | rnds[6] = rnds[6] & 0x0f | 0x40; 2408 | rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided 2409 | 2410 | if (buf) { 2411 | offset = offset || 0; 2412 | 2413 | for (let i = 0; i < 16; ++i) { 2414 | buf[offset + i] = rnds[i]; 2415 | } 2416 | 2417 | return buf; 2418 | } 2419 | 2420 | return esm_node_stringify(rnds); 2421 | } 2422 | 2423 | /* harmony default export */ const esm_node_v4 = (v4); 2424 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/sha1.js 2425 | 2426 | 2427 | function sha1(bytes) { 2428 | if (Array.isArray(bytes)) { 2429 | bytes = Buffer.from(bytes); 2430 | } else if (typeof bytes === 'string') { 2431 | bytes = Buffer.from(bytes, 'utf8'); 2432 | } 2433 | 2434 | return external_crypto_default().createHash('sha1').update(bytes).digest(); 2435 | } 2436 | 2437 | /* harmony default export */ const esm_node_sha1 = (sha1); 2438 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/v5.js 2439 | 2440 | 2441 | const v5 = v35('v5', 0x50, esm_node_sha1); 2442 | /* harmony default export */ const esm_node_v5 = (v5); 2443 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/nil.js 2444 | /* harmony default export */ const nil = ('00000000-0000-0000-0000-000000000000'); 2445 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/version.js 2446 | 2447 | 2448 | function version(uuid) { 2449 | if (!esm_node_validate(uuid)) { 2450 | throw TypeError('Invalid UUID'); 2451 | } 2452 | 2453 | return parseInt(uuid.substr(14, 1), 16); 2454 | } 2455 | 2456 | /* harmony default export */ const esm_node_version = (version); 2457 | // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-node/index.js 2458 | 2459 | 2460 | 2461 | 2462 | 2463 | 2464 | 2465 | 2466 | 2467 | 2468 | /***/ }), 2469 | 2470 | /***/ 357: 2471 | /***/ ((module) => { 2472 | 2473 | "use strict"; 2474 | module.exports = require("assert");; 2475 | 2476 | /***/ }), 2477 | 2478 | /***/ 614: 2479 | /***/ ((module) => { 2480 | 2481 | "use strict"; 2482 | module.exports = require("events");; 2483 | 2484 | /***/ }), 2485 | 2486 | /***/ 747: 2487 | /***/ ((module) => { 2488 | 2489 | "use strict"; 2490 | module.exports = require("fs");; 2491 | 2492 | /***/ }), 2493 | 2494 | /***/ 605: 2495 | /***/ ((module) => { 2496 | 2497 | "use strict"; 2498 | module.exports = require("http");; 2499 | 2500 | /***/ }), 2501 | 2502 | /***/ 211: 2503 | /***/ ((module) => { 2504 | 2505 | "use strict"; 2506 | module.exports = require("https");; 2507 | 2508 | /***/ }), 2509 | 2510 | /***/ 631: 2511 | /***/ ((module) => { 2512 | 2513 | "use strict"; 2514 | module.exports = require("net");; 2515 | 2516 | /***/ }), 2517 | 2518 | /***/ 87: 2519 | /***/ ((module) => { 2520 | 2521 | "use strict"; 2522 | module.exports = require("os");; 2523 | 2524 | /***/ }), 2525 | 2526 | /***/ 622: 2527 | /***/ ((module) => { 2528 | 2529 | "use strict"; 2530 | module.exports = require("path");; 2531 | 2532 | /***/ }), 2533 | 2534 | /***/ 16: 2535 | /***/ ((module) => { 2536 | 2537 | "use strict"; 2538 | module.exports = require("tls");; 2539 | 2540 | /***/ }), 2541 | 2542 | /***/ 669: 2543 | /***/ ((module) => { 2544 | 2545 | "use strict"; 2546 | module.exports = require("util");; 2547 | 2548 | /***/ }) 2549 | 2550 | /******/ }); 2551 | /************************************************************************/ 2552 | /******/ // The module cache 2553 | /******/ var __webpack_module_cache__ = {}; 2554 | /******/ 2555 | /******/ // The require function 2556 | /******/ function __webpack_require__(moduleId) { 2557 | /******/ // Check if module is in cache 2558 | /******/ if(__webpack_module_cache__[moduleId]) { 2559 | /******/ return __webpack_module_cache__[moduleId].exports; 2560 | /******/ } 2561 | /******/ // Create a new module (and put it into the cache) 2562 | /******/ var module = __webpack_module_cache__[moduleId] = { 2563 | /******/ // no module.id needed 2564 | /******/ // no module.loaded needed 2565 | /******/ exports: {} 2566 | /******/ }; 2567 | /******/ 2568 | /******/ // Execute the module function 2569 | /******/ var threw = true; 2570 | /******/ try { 2571 | /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 2572 | /******/ threw = false; 2573 | /******/ } finally { 2574 | /******/ if(threw) delete __webpack_module_cache__[moduleId]; 2575 | /******/ } 2576 | /******/ 2577 | /******/ // Return the exports of the module 2578 | /******/ return module.exports; 2579 | /******/ } 2580 | /******/ 2581 | /************************************************************************/ 2582 | /******/ /* webpack/runtime/compat get default export */ 2583 | /******/ (() => { 2584 | /******/ // getDefaultExport function for compatibility with non-harmony modules 2585 | /******/ __webpack_require__.n = (module) => { 2586 | /******/ var getter = module && module.__esModule ? 2587 | /******/ () => module['default'] : 2588 | /******/ () => module; 2589 | /******/ __webpack_require__.d(getter, { a: getter }); 2590 | /******/ return getter; 2591 | /******/ }; 2592 | /******/ })(); 2593 | /******/ 2594 | /******/ /* webpack/runtime/define property getters */ 2595 | /******/ (() => { 2596 | /******/ // define getter functions for harmony exports 2597 | /******/ __webpack_require__.d = (exports, definition) => { 2598 | /******/ for(var key in definition) { 2599 | /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 2600 | /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 2601 | /******/ } 2602 | /******/ } 2603 | /******/ }; 2604 | /******/ })(); 2605 | /******/ 2606 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ 2607 | /******/ (() => { 2608 | /******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop) 2609 | /******/ })(); 2610 | /******/ 2611 | /******/ /* webpack/runtime/make namespace object */ 2612 | /******/ (() => { 2613 | /******/ // define __esModule on exports 2614 | /******/ __webpack_require__.r = (exports) => { 2615 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 2616 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 2617 | /******/ } 2618 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 2619 | /******/ }; 2620 | /******/ })(); 2621 | /******/ 2622 | /******/ /* webpack/runtime/compat */ 2623 | /******/ 2624 | /******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/ 2625 | /******/ // module exports must be returned from runtime so entry inlining is disabled 2626 | /******/ // startup 2627 | /******/ // Load entry module and return exports 2628 | /******/ return __webpack_require__(109); 2629 | /******/ })() 2630 | ; -------------------------------------------------------------------------------- /docs/assets/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/actions-ecosystem/action-regex-match/d50fd2e7a37d0e617aea3d7ada663bd56862b9cc/docs/assets/screenshot.png -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | clearMocks: true, 3 | moduleFileExtensions: ['js', 'ts'], 4 | testEnvironment: 'node', 5 | testMatch: ['**/*.test.ts'], 6 | testRunner: 'jest-circus/runner', 7 | transform: { 8 | '^.+\\.ts$': 'ts-jest' 9 | }, 10 | verbose: true 11 | }; 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "action-regex-match", 3 | "version": "2.0.2", 4 | "private": true, 5 | "description": "Do regex matching", 6 | "main": "lib/main.js", 7 | "scripts": { 8 | "build": "tsc && ncc build", 9 | "format": "prettier --write **/*.ts", 10 | "format-check": "prettier --check **/*.ts", 11 | "lint": "eslint src/**/*.ts", 12 | "test": "jest" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/actions-ecosystem/action-regex-match.git" 17 | }, 18 | "keywords": [ 19 | "actions", 20 | "github", 21 | "regex" 22 | ], 23 | "author": "The Actions Ecosystem Authors", 24 | "license": "Apache 2.0", 25 | "dependencies": { 26 | "@actions/core": "^1.10.0", 27 | "@actions/github": "^4.0.0", 28 | "@octokit/rest": "^18.0.9", 29 | "semver": "^7.3.2" 30 | }, 31 | "devDependencies": { 32 | "@octokit/webhooks": "^7.15.1", 33 | "@types/jest": "^26.0.15", 34 | "@types/node": "^14.14.7", 35 | "@types/semver": "^7.3.4", 36 | "@typescript-eslint/parser": "^5.39", 37 | "@vercel/ncc": "^0.25.1", 38 | "eslint": "^8.0.1", 39 | "eslint-plugin-github": "^4.1.1", 40 | "eslint-plugin-jest": "^24.1.3", 41 | "eslint-plugin-prettier": "^3.1.4", 42 | "jest": "^26.6.3", 43 | "jest-circus": "^26.6.3", 44 | "js-yaml": "^3.14.0", 45 | "prettier": "^2.1.2", 46 | "ts-jest": "^26.4.4", 47 | "typescript": "^4.0.5" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core'; 2 | 3 | async function run(): Promise { 4 | try { 5 | const text = core.getInput('text'); 6 | const regex = core.getInput('regex'); 7 | const flags = core.getInput('flags'); 8 | 9 | const re = new RegExp(regex, flags); 10 | 11 | const result = re.exec(text); 12 | 13 | if (result) { 14 | for (const [index, x] of result.entries()) { 15 | if (index === 10) { 16 | return; 17 | } 18 | 19 | if (index === 0) { 20 | core.setOutput('match', x); 21 | continue; 22 | } 23 | 24 | core.setOutput(`group${index}`, x); 25 | } 26 | } 27 | } catch (error: any) { 28 | core.error(error); 29 | core.setFailed(error.message); 30 | } 31 | } 32 | 33 | run(); 34 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "outDir": "./lib", 6 | "rootDir": "./src", 7 | "strict": true, 8 | "noImplicitAny": true, 9 | "esModuleInterop": true, 10 | "moduleResolution": "node" 11 | }, 12 | "exclude": ["node_modules", "**/*.test.ts"] 13 | } 14 | --------------------------------------------------------------------------------