├── .github └── workflows │ └── main.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── composer.json ├── composer.lock ├── phpunit.xml ├── src └── IndieAuth │ ├── Client.php │ └── ErrorResponse.php └── tests ├── ClientTest.php ├── DiscoveryTest.php ├── MetadataTest.php ├── NormalizeTest.php ├── ScopeTest.php └── bootstrap.php /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Unit Tests 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | build: 14 | 15 | strategy: 16 | matrix: 17 | php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] 18 | 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | 24 | - name: Validate composer.json and composer.lock 25 | run: composer validate --strict 26 | 27 | - name: Cache Composer packages 28 | id: composer-cache 29 | uses: actions/cache@v3 30 | with: 31 | path: vendor 32 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 33 | restore-keys: | 34 | ${{ runner.os }}-php- 35 | 36 | - name: Install dependencies 37 | run: composer install --prefer-dist --no-progress 38 | 39 | - name: Run test suite 40 | run: ./vendor/bin/phpunit 41 | 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | By contributing to this project, you agree to irrevocably release your contributions under the same licenses as this project. See README.md for more details. 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Aaron Parecki and contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | ------------------------------------------------------------------------------------- 24 | 25 | Apache License 26 | 27 | Version 2.0, January 2004 28 | http://www.apache.org/licenses/ 29 | 30 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 31 | 32 | 1. Definitions. 33 | 34 | "License" shall mean the terms and conditions for use, reproduction, 35 | and distribution as defined by Sections 1 through 9 of this document. 36 | 37 | "Licensor" shall mean the copyright owner or entity authorized by 38 | the copyright owner that is granting the License. 39 | 40 | "Legal Entity" shall mean the union of the acting entity and all 41 | other entities that control, are controlled by, or are under common 42 | control with that entity. For the purposes of this definition, 43 | "control" means (i) the power, direct or indirect, to cause the 44 | direction or management of such entity, whether by contract or 45 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 46 | outstanding shares, or (iii) beneficial ownership of such entity. 47 | 48 | "You" (or "Your") shall mean an individual or Legal Entity 49 | exercising permissions granted by this License. 50 | 51 | "Source" form shall mean the preferred form for making modifications, 52 | including but not limited to software source code, documentation 53 | source, and configuration files. 54 | 55 | "Object" form shall mean any form resulting from mechanical 56 | transformation or translation of a Source form, including but 57 | not limited to compiled object code, generated documentation, 58 | and conversions to other media types. 59 | 60 | "Work" shall mean the work of authorship, whether in Source or 61 | Object form, made available under the License, as indicated by a 62 | copyright notice that is included in or attached to the work 63 | (an example is provided in the Appendix below). 64 | 65 | "Derivative Works" shall mean any work, whether in Source or Object 66 | form, that is based on (or derived from) the Work and for which the 67 | editorial revisions, annotations, elaborations, or other modifications 68 | represent, as a whole, an original work of authorship. For the purposes 69 | of this License, Derivative Works shall not include works that remain 70 | separable from, or merely link (or bind by name) to the interfaces of, 71 | the Work and Derivative Works thereof. 72 | 73 | "Contribution" shall mean any work of authorship, including 74 | the original version of the Work and any modifications or additions 75 | to that Work or Derivative Works thereof, that is intentionally 76 | submitted to Licensor for inclusion in the Work by the copyright owner 77 | or by an individual or Legal Entity authorized to submit on behalf of 78 | the copyright owner. For the purposes of this definition, "submitted" 79 | means any form of electronic, verbal, or written communication sent 80 | to the Licensor or its representatives, including but not limited to 81 | communication on electronic mailing lists, source code control systems, 82 | and issue tracking systems that are managed by, or on behalf of, the 83 | Licensor for the purpose of discussing and improving the Work, but 84 | excluding communication that is conspicuously marked or otherwise 85 | designated in writing by the copyright owner as "Not a Contribution." 86 | 87 | "Contributor" shall mean Licensor and any individual or Legal Entity 88 | on behalf of whom a Contribution has been received by Licensor and 89 | subsequently incorporated within the Work. 90 | 91 | 2. Grant of Copyright License. Subject to the terms and conditions of 92 | this License, each Contributor hereby grants to You a perpetual, 93 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 94 | copyright license to reproduce, prepare Derivative Works of, 95 | publicly display, publicly perform, sublicense, and distribute the 96 | Work and such Derivative Works in Source or Object form. 97 | 98 | 3. Grant of Patent License. Subject to the terms and conditions of 99 | this License, each Contributor hereby grants to You a perpetual, 100 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 101 | (except as stated in this section) patent license to make, have made, 102 | use, offer to sell, sell, import, and otherwise transfer the Work, 103 | where such license applies only to those patent claims licensable 104 | by such Contributor that are necessarily infringed by their 105 | Contribution(s) alone or by combination of their Contribution(s) 106 | with the Work to which such Contribution(s) was submitted. If You 107 | institute patent litigation against any entity (including a 108 | cross-claim or counterclaim in a lawsuit) alleging that the Work 109 | or a Contribution incorporated within the Work constitutes direct 110 | or contributory patent infringement, then any patent licenses 111 | granted to You under this License for that Work shall terminate 112 | as of the date such litigation is filed. 113 | 114 | 4. Redistribution. You may reproduce and distribute copies of the 115 | Work or Derivative Works thereof in any medium, with or without 116 | modifications, and in Source or Object form, provided that You 117 | meet the following conditions: 118 | 119 | (a) You must give any other recipients of the Work or 120 | Derivative Works a copy of this License; and 121 | 122 | (b) You must cause any modified files to carry prominent notices 123 | stating that You changed the files; and 124 | 125 | (c) You must retain, in the Source form of any Derivative Works 126 | that You distribute, all copyright, patent, trademark, and 127 | attribution notices from the Source form of the Work, 128 | excluding those notices that do not pertain to any part of 129 | the Derivative Works; and 130 | 131 | (d) If the Work includes a "NOTICE" text file as part of its 132 | distribution, then any Derivative Works that You distribute must 133 | include a readable copy of the attribution notices contained 134 | within such NOTICE file, excluding those notices that do not 135 | pertain to any part of the Derivative Works, in at least one 136 | of the following places: within a NOTICE text file distributed 137 | as part of the Derivative Works; within the Source form or 138 | documentation, if provided along with the Derivative Works; or, 139 | within a display generated by the Derivative Works, if and 140 | wherever such third-party notices normally appear. The contents 141 | of the NOTICE file are for informational purposes only and 142 | do not modify the License. You may add Your own attribution 143 | notices within Derivative Works that You distribute, alongside 144 | or as an addendum to the NOTICE text from the Work, provided 145 | that such additional attribution notices cannot be construed 146 | as modifying the License. 147 | 148 | You may add Your own copyright statement to Your modifications and 149 | may provide additional or different license terms and conditions 150 | for use, reproduction, or distribution of Your modifications, or 151 | for any such Derivative Works as a whole, provided Your use, 152 | reproduction, and distribution of the Work otherwise complies with 153 | the conditions stated in this License. 154 | 155 | 5. Submission of Contributions. Unless You explicitly state otherwise, 156 | any Contribution intentionally submitted for inclusion in the Work 157 | by You to the Licensor shall be under the terms and conditions of 158 | this License, without any additional terms or conditions. 159 | Notwithstanding the above, nothing herein shall supersede or modify 160 | the terms of any separate license agreement you may have executed 161 | with Licensor regarding such Contributions. 162 | 163 | 6. Trademarks. This License does not grant permission to use the trade 164 | names, trademarks, service marks, or product names of the Licensor, 165 | except as required for reasonable and customary use in describing the 166 | origin of the Work and reproducing the content of the NOTICE file. 167 | 168 | 7. Disclaimer of Warranty. Unless required by applicable law or 169 | agreed to in writing, Licensor provides the Work (and each 170 | Contributor provides its Contributions) on an "AS IS" BASIS, 171 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 172 | implied, including, without limitation, any warranties or conditions 173 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 174 | PARTICULAR PURPOSE. You are solely responsible for determining the 175 | appropriateness of using or redistributing the Work and assume any 176 | risks associated with Your exercise of permissions under this License. 177 | 178 | 8. Limitation of Liability. In no event and under no legal theory, 179 | whether in tort (including negligence), contract, or otherwise, 180 | unless required by applicable law (such as deliberate and grossly 181 | negligent acts) or agreed to in writing, shall any Contributor be 182 | liable to You for damages, including any direct, indirect, special, 183 | incidental, or consequential damages of any character arising as a 184 | result of this License or out of the use or inability to use the 185 | Work (including but not limited to damages for loss of goodwill, 186 | work stoppage, computer failure or malfunction, or any and all 187 | other commercial damages or losses), even if such Contributor 188 | has been advised of the possibility of such damages. 189 | 190 | 9. Accepting Warranty or Additional Liability. While redistributing 191 | the Work or Derivative Works thereof, You may choose to offer, 192 | and charge a fee for, acceptance of support, warranty, indemnity, 193 | or other liability obligations and/or rights consistent with this 194 | License. However, in accepting such obligations, You may act only 195 | on Your own behalf and on Your sole responsibility, not on behalf 196 | of any other Contributor, and only if You agree to indemnify, 197 | defend, and hold each Contributor harmless for any liability 198 | incurred by, or claims asserted against, such Contributor by reason 199 | of your accepting any such warranty or additional liability. 200 | 201 | END OF TERMS AND CONDITIONS 202 | 203 | APPENDIX: How to apply the Apache License to your work. 204 | 205 | To apply the Apache License to your work, attach the following 206 | boilerplate notice, with the fields enclosed by brackets "{}" 207 | replaced with your own identifying information. (Don't include 208 | the brackets!) The text should be enclosed in the appropriate 209 | comment syntax for the file format. We also recommend that a 210 | file or class name and description of purpose be included on the 211 | same "printed page" as the copyright notice for easier 212 | identification within third-party archives. 213 | 214 | Copyright {yyyy} {name of copyright owner} 215 | 216 | Licensed under the Apache License, Version 2.0 (the "License"); 217 | you may not use this file except in compliance with the License. 218 | You may obtain a copy of the License at 219 | 220 | http://www.apache.org/licenses/LICENSE-2.0 221 | 222 | Unless required by applicable law or agreed to in writing, software 223 | distributed under the License is distributed on an "AS IS" BASIS, 224 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 225 | See the License for the specific language governing permissions and 226 | limitations under the License. 227 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IndieAuth Client 2 | 3 | This is a simple library to help with IndieAuth. There are two ways you may want to use it, either when developing an application that signs people in using IndieAuth, or when developing your own endpoint for issuing access tokens and you need to verify auth codes. 4 | 5 | ![Build Status](https://github.com/indieweb/indieauth-client-php/actions/workflows/main.yml/badge.svg) 6 | 7 | ## Installation 8 | 9 | To install using [Composer](http://getcomposer.org), run: 10 | 11 | ``` 12 | composer require indieauth/client 13 | ``` 14 | 15 | This library follows [PSR-4](https://www.php-fig.org/psr/psr-4/) for autoloading. To autoload, ensure that your application requires the Composer autoload file: 16 | 17 | ```php 18 | 33 | 34 | 35 | 36 | ``` 37 | 38 | ### Begin the Login Flow 39 | 40 | In the `login.php` file, you'll need to initialize the session, and tell this library to discover the user's endpoints. If everything succeeds, the library will return a URL that you can use to redirect the user to begin the flow. 41 | 42 | The example below will have some really basic error handling, which you'll probably want to replace with something nicer looking. 43 | 44 | Example `login.php` file: 45 | 46 | ```php 47 | Error: ".$error['error']."

"; 75 | echo "

".$error['error_description']."

"; 76 | } else { 77 | // Redirect the user to their authorization endpoint 78 | header('Location: '.$authorizationURL); 79 | } 80 | ``` 81 | 82 | The following scopes have special meaning to the authorization server and will request the user's full profile info instead of just verifying their profile URL: 83 | 84 | * `profile` 85 | * `email` 86 | 87 | Any other scopes requested are assumed to be scopes that will request an access token be returned and the library will request an access token from the token endpoint in the next step. 88 | 89 | 90 | ### Handling the Redirect 91 | 92 | In your redirect file, pass all the query string parameters to the library and it will take care of things! It will use the authorization or token endpoint it found in the initial step, and will use the authorization code to verify the profile information or get an access token depending on whether you've requested any scopes. 93 | 94 | The result will be the response from the authorization endpoint or token, which will contain the user's final `me` URL as well as the access token if you requested one or more scopes. 95 | 96 | If there were any problems, the error information will be returned to you as well. 97 | 98 | The library takes care of verifying the final returned profile URL has the same authorization endpoint as the entered URL. 99 | 100 | Example `redirect.php` file: 101 | 102 | ```php 103 | Error: ".$error['error']."

"; 112 | echo "

".$error['error_description']."

"; 113 | } else { 114 | // Login succeeded! 115 | // The library will return the user's profile URL in the property "me" 116 | // It will also return the full response from the authorization or token endpoint, as well as debug info 117 | echo "URL: ".$response['me']."
"; 118 | if(isset($response['response']['access_token'])) { 119 | echo "Access Token: ".$response['response']['access_token']."
"; 120 | echo "Scope: ".$response['response']['scope']."
"; 121 | } 122 | 123 | // The full parsed response from the endpoint will be available as: 124 | // $response['response'] 125 | 126 | // The raw response: 127 | // $response['raw_response'] 128 | 129 | // The HTTP response code: 130 | // $response['response_code'] 131 | 132 | // You'll probably want to save the user's URL in the session 133 | $_SESSION['user'] = $user['me']; 134 | } 135 | ``` 136 | 137 | 138 | ## Detailed Usage for Clients 139 | 140 | The first thing an IndieAuth client needs to do is to prompt the user to enter their web address. This is the basis of IndieAuth, where user identifiers are URLs. A typical IndieAuth sign-in form may look something like the following. 141 | 142 | ``` 143 | Your URL: [ example.com ] 144 | 145 | [ Sign In ] 146 | ``` 147 | 148 | This form will make a POST request to your app's server, at which point you can begin the IndieAuth discovery. 149 | 150 | ### Discovering the required endpoints 151 | 152 | The user will need to define endpoints for their URL before a client can perform authorization. These endpoints should be specified in the [IndieAuth Server Metadata](https://indieauth.spec.indieweb.org/#discovery-by-clients) endpoint using either an HTTP `Link` header or a `` tag with relation `indieauth-metadata`: 153 | 154 | ```html 155 | 156 | ``` 157 | 158 | These discovery methods can be run all sequentially and the library will avoid making duplicate HTTP requests if it has already fetched the page once. 159 | 160 | #### Metadata Endpoint 161 | 162 | You should first attempt to discover the metadata endpoint. 163 | 164 | ```php 165 | // Normalize whatever the user entered to be a URL, e.g. "example.com" to "https://example.com/" 166 | $url = IndieAuth\Client::normalizeMeURL($url); 167 | $metadataEndpoint = IndieAuth\Client::discoverMetadataEndpoint($url); 168 | ``` 169 | 170 | If it is found, then discover and verify the `issuer` parameter in the metadata: 171 | 172 | ```php 173 | if ($metadataEndpoint) { 174 | $response = self::discoverIssuer($metadataEndpoint); 175 | if ($response instanceof IndieAuth\ErrorResponse) { 176 | // handle the error response, array with keys `error` and `error_description` 177 | die(json_encode($response->getArray())); 178 | } 179 | 180 | $_SESSION['indieauth_issuer'] = $response; 181 | } 182 | ``` 183 | 184 | The `issuer` value should be stored in the session to verify the Authorization Response later in the process (see below). 185 | 186 | If the metadata endpoint is not found, the methods below will try to discover the individual `` relations for backwards compability. 187 | 188 | #### Authorization Endpoint 189 | 190 | In IndieAuth Server Metadata: 191 | ```json 192 | { 193 | "authorization_endpoint": "https://indieauth.example.com/auth" 194 | } 195 | ``` 196 | 197 | Or backwards compatible relations: 198 | ```html 199 | 200 | ``` 201 | 202 | ``` 203 | Link: ; rel="authorization_endpoint" 204 | ``` 205 | 206 | The authorization endpoint allows a website to specify the location to direct the user's browser to when performing the initial authorization request. 207 | 208 | Since this can be a full URL, this allows a website to use an external server as its authorization endpoint. This allows people to delegate the handling and verification of authorization and authentication to an external service to speed up development. Of course at any point, the authorization server can be changed, and API clients and users will not need any modifications. 209 | 210 | The following function will fetch the user's home page and return the authorization endpoint, or `false` if none was found. 211 | 212 | ```php 213 | // Normalize whatever the user entered to be a URL, e.g. "example.com" to "http://example.com/" 214 | $url = IndieAuth\Client::normalizeMeURL($url); 215 | $authorizationEndpoint = IndieAuth\Client::discoverAuthorizationEndpoint($url); 216 | ``` 217 | 218 | #### Token Endpoint 219 | 220 | In IndieAuth Server Metadata: 221 | ```json 222 | { 223 | "token_endpoint": "https://indieauth.example.com/token" 224 | } 225 | ``` 226 | 227 | Or backwards compatible relations: 228 | ```html 229 | 230 | ``` 231 | 232 | ``` 233 | Link: ; rel="token_endpoint" 234 | ``` 235 | 236 | The token endpoint is where API clients will request access tokens. This will typically be a URL on the user's own website, although this can delegated to an external service as well. 237 | 238 | The token endpoint is responsible for issuing an access token. 239 | 240 | The following function will fetch the user's home page and return the token endpoint, or `false` if none was found. 241 | 242 | ```php 243 | $url = IndieAuth\Client::normalizeMeURL($url); 244 | $tokenEndpoint = IndieAuth\Client::discoverTokenEndpoint($url); 245 | ``` 246 | 247 | #### Micropub Endpoint 248 | 249 | ```html 250 | 251 | ``` 252 | 253 | ``` 254 | Link: ; rel="micropub" 255 | ``` 256 | 257 | The [Micropub](https://indieweb.org/Micropub) endpoint defines where Micropub clients will make POST requests to create new posts on the user's website. When a Micropub client makes a request, the request will contain the previously-issued access token in the header, and the micropub endpoint will be able to validate the request given that access token. 258 | 259 | The following function will fetch the user's home page and return the Micropub endpoint, or `false` if none was found. 260 | 261 | ```php 262 | $url = IndieAuth\Client::normalizeMeURL($url); 263 | $micropubEndpoint = IndieAuth\Client::discoverMicropubEndpoint($url); 264 | ``` 265 | 266 | The client may wish to discover all endpoints at the beginning, and cache the values in a session for later use. 267 | 268 | #### Microsub Endpoint 269 | 270 | ```html 271 | 272 | ``` 273 | 274 | ``` 275 | Link: ; rel="microsub" 276 | ``` 277 | 278 | The [Microsub](https://indieweb.comorg/Microsub) endpoint is for [readers](https://indieweb.org/reader). When a Micropub client makes a request, the request will contain the previously-issued access token in the header, and the endpoint will be able to validate the request given that access token. 279 | 280 | The following function will fetch the user's home page and return the Microsub endpoint, or `false` if none was found. 281 | 282 | ```php 283 | $url = IndieAuth\Client::normalizeMeURL($url); 284 | $microsubEndpoint = IndieAuth\Client::discoverMicrosubEndpoint($url); 285 | ``` 286 | 287 | The client may wish to discover all endpoints at the beginning, and cache the values in a session for later use. 288 | 289 | #### Additional Endpoints 290 | 291 | IndieAuth Server Metadata allows defining some additional endpoints: 292 | 293 | **Token Revocation** 294 | 295 | Return the `revocation_endpoint` or false if none was found: 296 | ```php 297 | $url = IndieAuth\Client::normalizeMeURL($url); 298 | $revocationEndpoint = IndieAuth\Client::discoverRevocationEndpoint($url); 299 | ``` 300 | 301 | **Token Introspection** 302 | 303 | Return the `introspection_endpoint` or false if none was found: 304 | ```php 305 | $url = IndieAuth\Client::normalizeMeURL($url); 306 | $introspectionEndpoint = IndieAuth\Client::discoverIntrospectionEndpoint($url); 307 | ``` 308 | 309 | **Userinfo** 310 | 311 | Return the `userinfo_endpoint` or false if none was found: 312 | ```php 313 | $url = IndieAuth\Client::normalizeMeURL($url); 314 | $userinfoEndpoint = IndieAuth\Client::discoverUserinfoEndpoint($url); 315 | ``` 316 | 317 | ### Building the authorization URL 318 | 319 | Once the client has discovered the authorization server, it will need to build the authorization URL and direct the user's browser there. 320 | 321 | For web sites, the client should send a 301 redirect to the authorization URL, or can open a new browser window. Native apps must launch a native browser window to the authorization URL and handle the redirect back to the native app appropriately. 322 | 323 | #### Authorization Endpoint Parameters 324 | * `me` - the URL the user entered to begin the flow. 325 | * `redirect_uri` - where the authorization server should redirect after authorization is complete. 326 | * `client_id` - the full URL to a web page of the application. This is used by the authorization server to discover the app's name and icon, and to validate the redirect URI. 327 | * `state` - the "state" parameter can be whatever the client wishes, and must also be sent to the token endpoint when the client exchanges the authorization code for an access token. 328 | * `scope` - the "scope" value is a space-separated list of permissions the client is requesting. 329 | * `code_challenge` - for [PKCE](https://oauth.net/2/pkce/) support, this is the hashed version of a secret the client generates when it starts. 330 | * `code_challenge_method` - this library will always use S256 as the hash method. 331 | 332 | The following function will build the authorization URL given all the required parameters. If the authorization endpoint contains a query string, this function handles merging the existing query string parameters with the new parameters. 333 | 334 | The following scopes have special meaning to the authorization server and will request the user's full profile info instead of just verifying their profile URL: 335 | 336 | * `profile` 337 | * `email` 338 | 339 | ```php 340 | $url = IndieAuth\Client::normalizeMeURL($url); 341 | 342 | $scope = 'profile create'; // Request profile info as well as an access token with the "create" scope 343 | 344 | // These are two random strings. The helper methods in the library will use an available random number generaton depending on the PHP version. 345 | $_SESSION['state'] = IndieAuth\Client::generateStateParameter(); 346 | $_SESSION['code_verifier'] = IndieAuth\Client::generatePKCECodeVerifier(); 347 | 348 | // you'll need to verify these later 349 | $_SESSION['user_entered_url'] = $url; 350 | $_SESSION['authorization_endpoint'] = $authorizationEndpoint; 351 | 352 | $authorizationURL = IndieAuth\Client::buildAuthorizationURL($authorizationEndpoint, [ 353 | 'me' => $url, 354 | 'redirect_uri' => $redirect_uri, 355 | 'client_id' => $client_id, 356 | 'scope' => $scope, 357 | 'state' => $_SESSION['state'], 358 | 'code_verifier' => $_SESSION['code_verifier'], 359 | ]); 360 | ``` 361 | 362 | Note: Your code should include the plaintext random code verifier, the `IndieAuth\Client` library will deal with hashing it for you in the request. 363 | 364 | ### Getting authorization from the user 365 | 366 | At this point, the authorization server interacts with the user, presenting them with a description of the request. This will look something like the following typical OAuth prompt: 367 | 368 | ``` 369 | An application, "Quill" is requesting access to your website, "aaronparecki.com" 370 | 371 | This application would like to be able to 372 | * **create** new entries on your website 373 | 374 | [ Approve ] [ Deny ] 375 | ``` 376 | 377 | If the user approves the request, the authorization server will redirect back to the redirect URL specified, with the following parameters added to the query string: 378 | 379 | * `code` - the authorization code 380 | * `state` - the state value provided in the request 381 | * `iss` - the issuer identifier for client validation 382 | 383 | 384 | ### Validate the Authorization Response 385 | 386 | Next, the `state` and `iss` parameters must be verified to match the authorization request: 387 | 388 | ```php 389 | $response = self::validateStateMatch($_GET, $_SESSION['indieauth_state']); 390 | if ($response instanceof IndieAuth\ErrorResponse) { 391 | // handle the error response, array with keys `error` and `error_description` 392 | die(json_encode($response->getArray())); 393 | } 394 | 395 | if (isset($_SESSION['indieauth_issuer'])) { 396 | $response = self::validateIssuerMatch($_GET, $_SESSION['indieauth_issuer']); 397 | if ($response instanceof IndieAuth\ErrorResponse) { 398 | // handle the error response, array with keys `error` and `error_description` 399 | die(json_encode($response->getArray())); 400 | } 401 | } 402 | ``` 403 | 404 | If both are valid, you can continue to exchange the authorization code. 405 | 406 | 407 | ### Exchanging the authorization code for profile info 408 | 409 | If the client is not trying to get an access token, just trying to verify the user's URL, then it will need to exchange the authorization code for profile information at the authorization endpoint. 410 | 411 | The following function will make a POST request to the authorization endpoint and parse the result. 412 | 413 | ```php 414 | $response = IndieAuth\Client::exchangeAuthorizationCode($authorizationEndpoint, [ 415 | 'code' => $_GET['code'], 416 | 'redirect_uri' => $redirect_uri, 417 | 'client_id' => $client_id, 418 | 'code_verifier' => $_SESSION['code_verifier'], 419 | ]); 420 | ``` 421 | 422 | The `$response` variable will include the response from the endpoint, such as the following: 423 | 424 | ```php 425 | array( 426 | 'me' => 'https://aaronparecki.com/', 427 | 'response' => [ 428 | 'me' => 'https://aaronparecki.com/', 429 | 'profile' => [ 430 | 'name' => 'Aaron Parecki', 431 | 'url' => 'https://aaronparecki.com/', 432 | 'photo' => 'https://aaronparecki.com/images/profile.jpg' 433 | ] 434 | ], 435 | 'raw_response' => '{"me":"https://aaronparecki.com/","profile":{"name":"Aaron Parecki","url":"https://aaronparecki.com/","photo":"https://aaronparecki.com/images/profile.jpg"}}', 436 | 'response_code' => 200 437 | ); 438 | ``` 439 | 440 | 441 | ### Exchanging the authorization code for an access token 442 | 443 | If the client requested any scopes beyond profile scopes and is expecting an access token, it needs to exchange the authorization code for an access token at the token endpoint. 444 | 445 | To get an access token, the client makes a POST request to the token endpoint, passing in the authorization code as well as the following parameters: 446 | 447 | * `code` - the authorization code obtained 448 | * `me` - the user's URL 449 | * `redirect_uri` - must match the redirect URI used in the request to obtain the authorization code 450 | * `client_id` - must match the client ID used in the initial request 451 | * `code_verifier` - if the client included a code challenge in the authorization request, then it must include the plaintext secret in the code exchange step here 452 | 453 | The following function will make a POST request to the token endpoint and parse the result. 454 | 455 | ```php 456 | $response = IndieAuth\Client::exchangeAuthorizationCode($tokenEndpoint, [ 457 | 'code' => $_GET['code'], 458 | 'redirect_uri' => $redirect_uri, 459 | 'client_id' => $client_id, 460 | 'code_verifier' => $_SESSION['code_verifier'], 461 | ]); 462 | ``` 463 | 464 | The `$response` variable will include the response from the token endpoint, such as the following: 465 | 466 | ```php 467 | array( 468 | 'response' => [ 469 | 'me' => 'https://aaronparecki.com/', 470 | 'access_token' => 'xxxxxxxxx', 471 | 'scope' => 'create' 472 | ], 473 | 'raw_response' => '{"me":"https://aaronparecki.com/","access_token":"xxxxxxxxx","scope":"create"}', 474 | 'response_code' => 200 475 | ); 476 | ``` 477 | 478 | 479 | ### Verifying the Authorization Server 480 | 481 | If you are using the individual methods instead of the begin/complete wrapper, then you'll need to double check that the URL returned has the same authorization endpoint as the one you used to begin the flow. 482 | 483 | ```php 484 | if($response['me'] != $_SESSION['user_entered_url']) { 485 | $authorizationEndpoint = IndieAuth\Client::discoverAuthorizationEndpoint($response['me']); 486 | if($authorizationEndpoint != $_SESSION['authorization_endpoint']) { 487 | die("The authorization endpoint at the profile URL is not the same as the one used to begin the flow!"); 488 | } 489 | } 490 | ``` 491 | 492 | 493 | ### Making API requests 494 | 495 | At this point, you are done using the IndieAuth client library and can begin making API requests directly to the user's website and micropub endpoint. 496 | 497 | To make an API request, include the access token in an HTTP "Authorization" header like the following: 498 | 499 | ``` 500 | Authorization: Bearer xxxxxxxx 501 | ``` 502 | 503 | ### Additional Settings 504 | 505 | There are a couple settings you can update if necessary: 506 | 507 | **HTTP User Agent** 508 | 509 | The default UA mimics a browser by default. You can customize this by calling: 510 | 511 | ```php 512 | IndieAuth\Client::$http->set_user_agent('Your User Agent String'); 513 | ``` 514 | 515 | **Number of bytes in state parameter** 516 | 517 | The default state parameter is generated with 8 random bytes. You can change the number of bytes by calling: 518 | 519 | ```php 520 | IndieAuth\Client::$random_byte_count = 16; 521 | ``` 522 | 523 | 524 | # License 525 | 526 | Copyright 2013-2022 by Aaron Parecki and contributors 527 | 528 | Available under the MIT and Apache 2.0 licenses. See LICENSE.txt 529 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "indieauth/client", 3 | "description": "IndieAuth Client Library", 4 | "require": { 5 | "php": ">5.6.0", 6 | "mf2/mf2": "^0.5", 7 | "p3k/http": "^0.1", 8 | "indieweb/representative-h-card": "^0.1.2" 9 | }, 10 | "license": "Apache-2.0", 11 | "authors": [ 12 | { 13 | "name": "Aaron Parecki", 14 | "homepage": "https://aaronparecki.com" 15 | } 16 | ], 17 | "funding": [ 18 | { 19 | "type": "opencollective", 20 | "url": "https://opencollective.com/indieweb" 21 | } 22 | ], 23 | "autoload": { 24 | "psr-4": { 25 | "IndieAuth\\": "src/IndieAuth/" 26 | } 27 | }, 28 | "require-dev": { 29 | "yoast/phpunit-polyfills": "^1.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "1d221f852b9b766467b14242355a1296", 8 | "packages": [ 9 | { 10 | "name": "indieweb/link-rel-parser", 11 | "version": "0.1.3", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/indieweb/link-rel-parser-php.git", 15 | "reference": "295420e4f16d9a9d262a3c25a7a583794428f055" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/indieweb/link-rel-parser-php/zipball/295420e4f16d9a9d262a3c25a7a583794428f055", 20 | "reference": "295420e4f16d9a9d262a3c25a7a583794428f055", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "php": ">=5.3.0" 25 | }, 26 | "type": "library", 27 | "autoload": { 28 | "files": [ 29 | "src/IndieWeb/link_rel_parser.php" 30 | ] 31 | }, 32 | "notification-url": "https://packagist.org/downloads/", 33 | "license": [ 34 | "Apache-2.0" 35 | ], 36 | "authors": [ 37 | { 38 | "name": "Aaron Parecki", 39 | "homepage": "http://aaronparecki.com" 40 | }, 41 | { 42 | "name": "Tantek Çelik", 43 | "homepage": "http://tantek.com" 44 | } 45 | ], 46 | "description": "Parse rel values from HTTP headers", 47 | "homepage": "https://github.com/indieweb/link-rel-parser-php", 48 | "keywords": [ 49 | "http", 50 | "indieweb", 51 | "microformats2" 52 | ], 53 | "support": { 54 | "issues": "https://github.com/indieweb/link-rel-parser-php/issues", 55 | "source": "https://github.com/indieweb/link-rel-parser-php/tree/master" 56 | }, 57 | "time": "2017-01-11T17:14:49+00:00" 58 | }, 59 | { 60 | "name": "indieweb/representative-h-card", 61 | "version": "0.1.2", 62 | "source": { 63 | "type": "git", 64 | "url": "https://github.com/indieweb/representative-h-card-php.git", 65 | "reference": "b70b01bd0dd7f2a940602137335dbf46ab6e2e38" 66 | }, 67 | "dist": { 68 | "type": "zip", 69 | "url": "https://api.github.com/repos/indieweb/representative-h-card-php/zipball/b70b01bd0dd7f2a940602137335dbf46ab6e2e38", 70 | "reference": "b70b01bd0dd7f2a940602137335dbf46ab6e2e38", 71 | "shasum": "" 72 | }, 73 | "require": { 74 | "php": ">=5.4" 75 | }, 76 | "require-dev": { 77 | "mf2/mf2": "0.2.*", 78 | "phpunit/phpunit": "*" 79 | }, 80 | "type": "library", 81 | "autoload": { 82 | "files": [ 83 | "src/mf2/representative-h-card.php" 84 | ] 85 | }, 86 | "notification-url": "https://packagist.org/downloads/", 87 | "license": [ 88 | "Apache-2.0" 89 | ], 90 | "authors": [ 91 | { 92 | "name": "Aaron Parecki", 93 | "homepage": "http://aaronparecki.com" 94 | } 95 | ], 96 | "keywords": [ 97 | "h-card", 98 | "indieweb", 99 | "mf2", 100 | "microformats" 101 | ], 102 | "support": { 103 | "issues": "https://github.com/indieweb/representative-h-card-php/issues", 104 | "source": "https://github.com/indieweb/representative-h-card-php/tree/0.1.2" 105 | }, 106 | "time": "2015-12-23T18:11:19+00:00" 107 | }, 108 | { 109 | "name": "mf2/mf2", 110 | "version": "v0.5.0", 111 | "source": { 112 | "type": "git", 113 | "url": "https://github.com/microformats/php-mf2.git", 114 | "reference": "ddc56de6be62ed4a21f569de9b80e17af678ca50" 115 | }, 116 | "dist": { 117 | "type": "zip", 118 | "url": "https://api.github.com/repos/microformats/php-mf2/zipball/ddc56de6be62ed4a21f569de9b80e17af678ca50", 119 | "reference": "ddc56de6be62ed4a21f569de9b80e17af678ca50", 120 | "shasum": "" 121 | }, 122 | "require": { 123 | "php": ">=5.6.0" 124 | }, 125 | "require-dev": { 126 | "dealerdirect/phpcodesniffer-composer-installer": "^0.7", 127 | "mf2/tests": "dev-master#e9e2b905821ba0a5b59dab1a8eaf40634ce9cd49", 128 | "phpcompatibility/php-compatibility": "^9.3", 129 | "phpunit/phpunit": "^5.7", 130 | "squizlabs/php_codesniffer": "^3.6.2" 131 | }, 132 | "suggest": { 133 | "barnabywalters/mf-cleaner": "To more easily handle the canonical data php-mf2 gives you", 134 | "masterminds/html5": "Alternative HTML parser for PHP, for better HTML5 support." 135 | }, 136 | "bin": [ 137 | "bin/fetch-mf2", 138 | "bin/parse-mf2" 139 | ], 140 | "type": "library", 141 | "autoload": { 142 | "files": [ 143 | "Mf2/Parser.php" 144 | ] 145 | }, 146 | "notification-url": "https://packagist.org/downloads/", 147 | "license": [ 148 | "CC0-1.0" 149 | ], 150 | "authors": [ 151 | { 152 | "name": "Barnaby Walters", 153 | "homepage": "http://waterpigs.co.uk" 154 | } 155 | ], 156 | "description": "A pure, generic microformats2 parser — makes HTML as easy to consume as a JSON API", 157 | "keywords": [ 158 | "html", 159 | "microformats", 160 | "microformats 2", 161 | "parser", 162 | "semantic" 163 | ], 164 | "support": { 165 | "issues": "https://github.com/microformats/php-mf2/issues", 166 | "source": "https://github.com/microformats/php-mf2/tree/v0.5.0" 167 | }, 168 | "time": "2022-02-10T01:05:27+00:00" 169 | }, 170 | { 171 | "name": "p3k/http", 172 | "version": "0.1.12", 173 | "source": { 174 | "type": "git", 175 | "url": "https://github.com/aaronpk/p3k-http.git", 176 | "reference": "cf9c5b7cdbe1800bfb9587a20953ed8d20322e0b" 177 | }, 178 | "dist": { 179 | "type": "zip", 180 | "url": "https://api.github.com/repos/aaronpk/p3k-http/zipball/cf9c5b7cdbe1800bfb9587a20953ed8d20322e0b", 181 | "reference": "cf9c5b7cdbe1800bfb9587a20953ed8d20322e0b", 182 | "shasum": "" 183 | }, 184 | "require": { 185 | "indieweb/link-rel-parser": "0.1.*", 186 | "mf2/mf2": ">=0.3.2" 187 | }, 188 | "type": "library", 189 | "autoload": { 190 | "psr-4": { 191 | "p3k\\": "src/p3k" 192 | } 193 | }, 194 | "notification-url": "https://packagist.org/downloads/", 195 | "license": [ 196 | "MIT" 197 | ], 198 | "authors": [ 199 | { 200 | "name": "Aaron Parecki", 201 | "homepage": "https://aaronparecki.com" 202 | } 203 | ], 204 | "description": "A simple wrapper API around the PHP curl functions", 205 | "homepage": "https://github.com/aaronpk/p3k-http", 206 | "support": { 207 | "issues": "https://github.com/aaronpk/p3k-http/issues", 208 | "source": "https://github.com/aaronpk/p3k-http/tree/0.1.12" 209 | }, 210 | "time": "2021-10-12T14:12:29+00:00" 211 | } 212 | ], 213 | "packages-dev": [ 214 | { 215 | "name": "doctrine/instantiator", 216 | "version": "1.4.1", 217 | "source": { 218 | "type": "git", 219 | "url": "https://github.com/doctrine/instantiator.git", 220 | "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" 221 | }, 222 | "dist": { 223 | "type": "zip", 224 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", 225 | "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", 226 | "shasum": "" 227 | }, 228 | "require": { 229 | "php": "^7.1 || ^8.0" 230 | }, 231 | "require-dev": { 232 | "doctrine/coding-standard": "^9", 233 | "ext-pdo": "*", 234 | "ext-phar": "*", 235 | "phpbench/phpbench": "^0.16 || ^1", 236 | "phpstan/phpstan": "^1.4", 237 | "phpstan/phpstan-phpunit": "^1", 238 | "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", 239 | "vimeo/psalm": "^4.22" 240 | }, 241 | "type": "library", 242 | "autoload": { 243 | "psr-4": { 244 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 245 | } 246 | }, 247 | "notification-url": "https://packagist.org/downloads/", 248 | "license": [ 249 | "MIT" 250 | ], 251 | "authors": [ 252 | { 253 | "name": "Marco Pivetta", 254 | "email": "ocramius@gmail.com", 255 | "homepage": "https://ocramius.github.io/" 256 | } 257 | ], 258 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 259 | "homepage": "https://www.doctrine-project.org/projects/instantiator.html", 260 | "keywords": [ 261 | "constructor", 262 | "instantiate" 263 | ], 264 | "support": { 265 | "issues": "https://github.com/doctrine/instantiator/issues", 266 | "source": "https://github.com/doctrine/instantiator/tree/1.4.1" 267 | }, 268 | "funding": [ 269 | { 270 | "url": "https://www.doctrine-project.org/sponsorship.html", 271 | "type": "custom" 272 | }, 273 | { 274 | "url": "https://www.patreon.com/phpdoctrine", 275 | "type": "patreon" 276 | }, 277 | { 278 | "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", 279 | "type": "tidelift" 280 | } 281 | ], 282 | "time": "2022-03-03T08:28:38+00:00" 283 | }, 284 | { 285 | "name": "myclabs/deep-copy", 286 | "version": "1.11.0", 287 | "source": { 288 | "type": "git", 289 | "url": "https://github.com/myclabs/DeepCopy.git", 290 | "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" 291 | }, 292 | "dist": { 293 | "type": "zip", 294 | "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", 295 | "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", 296 | "shasum": "" 297 | }, 298 | "require": { 299 | "php": "^7.1 || ^8.0" 300 | }, 301 | "conflict": { 302 | "doctrine/collections": "<1.6.8", 303 | "doctrine/common": "<2.13.3 || >=3,<3.2.2" 304 | }, 305 | "require-dev": { 306 | "doctrine/collections": "^1.6.8", 307 | "doctrine/common": "^2.13.3 || ^3.2.2", 308 | "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" 309 | }, 310 | "type": "library", 311 | "autoload": { 312 | "files": [ 313 | "src/DeepCopy/deep_copy.php" 314 | ], 315 | "psr-4": { 316 | "DeepCopy\\": "src/DeepCopy/" 317 | } 318 | }, 319 | "notification-url": "https://packagist.org/downloads/", 320 | "license": [ 321 | "MIT" 322 | ], 323 | "description": "Create deep copies (clones) of your objects", 324 | "keywords": [ 325 | "clone", 326 | "copy", 327 | "duplicate", 328 | "object", 329 | "object graph" 330 | ], 331 | "support": { 332 | "issues": "https://github.com/myclabs/DeepCopy/issues", 333 | "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" 334 | }, 335 | "funding": [ 336 | { 337 | "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", 338 | "type": "tidelift" 339 | } 340 | ], 341 | "time": "2022-03-03T13:19:32+00:00" 342 | }, 343 | { 344 | "name": "nikic/php-parser", 345 | "version": "v4.15.1", 346 | "source": { 347 | "type": "git", 348 | "url": "https://github.com/nikic/PHP-Parser.git", 349 | "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900" 350 | }, 351 | "dist": { 352 | "type": "zip", 353 | "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", 354 | "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", 355 | "shasum": "" 356 | }, 357 | "require": { 358 | "ext-tokenizer": "*", 359 | "php": ">=7.0" 360 | }, 361 | "require-dev": { 362 | "ircmaxell/php-yacc": "^0.0.7", 363 | "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" 364 | }, 365 | "bin": [ 366 | "bin/php-parse" 367 | ], 368 | "type": "library", 369 | "extra": { 370 | "branch-alias": { 371 | "dev-master": "4.9-dev" 372 | } 373 | }, 374 | "autoload": { 375 | "psr-4": { 376 | "PhpParser\\": "lib/PhpParser" 377 | } 378 | }, 379 | "notification-url": "https://packagist.org/downloads/", 380 | "license": [ 381 | "BSD-3-Clause" 382 | ], 383 | "authors": [ 384 | { 385 | "name": "Nikita Popov" 386 | } 387 | ], 388 | "description": "A PHP parser written in PHP", 389 | "keywords": [ 390 | "parser", 391 | "php" 392 | ], 393 | "support": { 394 | "issues": "https://github.com/nikic/PHP-Parser/issues", 395 | "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1" 396 | }, 397 | "time": "2022-09-04T07:30:47+00:00" 398 | }, 399 | { 400 | "name": "phar-io/manifest", 401 | "version": "2.0.3", 402 | "source": { 403 | "type": "git", 404 | "url": "https://github.com/phar-io/manifest.git", 405 | "reference": "97803eca37d319dfa7826cc2437fc020857acb53" 406 | }, 407 | "dist": { 408 | "type": "zip", 409 | "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", 410 | "reference": "97803eca37d319dfa7826cc2437fc020857acb53", 411 | "shasum": "" 412 | }, 413 | "require": { 414 | "ext-dom": "*", 415 | "ext-phar": "*", 416 | "ext-xmlwriter": "*", 417 | "phar-io/version": "^3.0.1", 418 | "php": "^7.2 || ^8.0" 419 | }, 420 | "type": "library", 421 | "extra": { 422 | "branch-alias": { 423 | "dev-master": "2.0.x-dev" 424 | } 425 | }, 426 | "autoload": { 427 | "classmap": [ 428 | "src/" 429 | ] 430 | }, 431 | "notification-url": "https://packagist.org/downloads/", 432 | "license": [ 433 | "BSD-3-Clause" 434 | ], 435 | "authors": [ 436 | { 437 | "name": "Arne Blankerts", 438 | "email": "arne@blankerts.de", 439 | "role": "Developer" 440 | }, 441 | { 442 | "name": "Sebastian Heuer", 443 | "email": "sebastian@phpeople.de", 444 | "role": "Developer" 445 | }, 446 | { 447 | "name": "Sebastian Bergmann", 448 | "email": "sebastian@phpunit.de", 449 | "role": "Developer" 450 | } 451 | ], 452 | "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", 453 | "support": { 454 | "issues": "https://github.com/phar-io/manifest/issues", 455 | "source": "https://github.com/phar-io/manifest/tree/2.0.3" 456 | }, 457 | "time": "2021-07-20T11:28:43+00:00" 458 | }, 459 | { 460 | "name": "phar-io/version", 461 | "version": "3.2.1", 462 | "source": { 463 | "type": "git", 464 | "url": "https://github.com/phar-io/version.git", 465 | "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" 466 | }, 467 | "dist": { 468 | "type": "zip", 469 | "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", 470 | "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", 471 | "shasum": "" 472 | }, 473 | "require": { 474 | "php": "^7.2 || ^8.0" 475 | }, 476 | "type": "library", 477 | "autoload": { 478 | "classmap": [ 479 | "src/" 480 | ] 481 | }, 482 | "notification-url": "https://packagist.org/downloads/", 483 | "license": [ 484 | "BSD-3-Clause" 485 | ], 486 | "authors": [ 487 | { 488 | "name": "Arne Blankerts", 489 | "email": "arne@blankerts.de", 490 | "role": "Developer" 491 | }, 492 | { 493 | "name": "Sebastian Heuer", 494 | "email": "sebastian@phpeople.de", 495 | "role": "Developer" 496 | }, 497 | { 498 | "name": "Sebastian Bergmann", 499 | "email": "sebastian@phpunit.de", 500 | "role": "Developer" 501 | } 502 | ], 503 | "description": "Library for handling version information and constraints", 504 | "support": { 505 | "issues": "https://github.com/phar-io/version/issues", 506 | "source": "https://github.com/phar-io/version/tree/3.2.1" 507 | }, 508 | "time": "2022-02-21T01:04:05+00:00" 509 | }, 510 | { 511 | "name": "phpunit/php-code-coverage", 512 | "version": "9.2.17", 513 | "source": { 514 | "type": "git", 515 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 516 | "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8" 517 | }, 518 | "dist": { 519 | "type": "zip", 520 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8", 521 | "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8", 522 | "shasum": "" 523 | }, 524 | "require": { 525 | "ext-dom": "*", 526 | "ext-libxml": "*", 527 | "ext-xmlwriter": "*", 528 | "nikic/php-parser": "^4.14", 529 | "php": ">=7.3", 530 | "phpunit/php-file-iterator": "^3.0.3", 531 | "phpunit/php-text-template": "^2.0.2", 532 | "sebastian/code-unit-reverse-lookup": "^2.0.2", 533 | "sebastian/complexity": "^2.0", 534 | "sebastian/environment": "^5.1.2", 535 | "sebastian/lines-of-code": "^1.0.3", 536 | "sebastian/version": "^3.0.1", 537 | "theseer/tokenizer": "^1.2.0" 538 | }, 539 | "require-dev": { 540 | "phpunit/phpunit": "^9.3" 541 | }, 542 | "suggest": { 543 | "ext-pcov": "*", 544 | "ext-xdebug": "*" 545 | }, 546 | "type": "library", 547 | "extra": { 548 | "branch-alias": { 549 | "dev-master": "9.2-dev" 550 | } 551 | }, 552 | "autoload": { 553 | "classmap": [ 554 | "src/" 555 | ] 556 | }, 557 | "notification-url": "https://packagist.org/downloads/", 558 | "license": [ 559 | "BSD-3-Clause" 560 | ], 561 | "authors": [ 562 | { 563 | "name": "Sebastian Bergmann", 564 | "email": "sebastian@phpunit.de", 565 | "role": "lead" 566 | } 567 | ], 568 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 569 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 570 | "keywords": [ 571 | "coverage", 572 | "testing", 573 | "xunit" 574 | ], 575 | "support": { 576 | "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", 577 | "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17" 578 | }, 579 | "funding": [ 580 | { 581 | "url": "https://github.com/sebastianbergmann", 582 | "type": "github" 583 | } 584 | ], 585 | "time": "2022-08-30T12:24:04+00:00" 586 | }, 587 | { 588 | "name": "phpunit/php-file-iterator", 589 | "version": "3.0.6", 590 | "source": { 591 | "type": "git", 592 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 593 | "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" 594 | }, 595 | "dist": { 596 | "type": "zip", 597 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", 598 | "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", 599 | "shasum": "" 600 | }, 601 | "require": { 602 | "php": ">=7.3" 603 | }, 604 | "require-dev": { 605 | "phpunit/phpunit": "^9.3" 606 | }, 607 | "type": "library", 608 | "extra": { 609 | "branch-alias": { 610 | "dev-master": "3.0-dev" 611 | } 612 | }, 613 | "autoload": { 614 | "classmap": [ 615 | "src/" 616 | ] 617 | }, 618 | "notification-url": "https://packagist.org/downloads/", 619 | "license": [ 620 | "BSD-3-Clause" 621 | ], 622 | "authors": [ 623 | { 624 | "name": "Sebastian Bergmann", 625 | "email": "sebastian@phpunit.de", 626 | "role": "lead" 627 | } 628 | ], 629 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 630 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 631 | "keywords": [ 632 | "filesystem", 633 | "iterator" 634 | ], 635 | "support": { 636 | "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", 637 | "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" 638 | }, 639 | "funding": [ 640 | { 641 | "url": "https://github.com/sebastianbergmann", 642 | "type": "github" 643 | } 644 | ], 645 | "time": "2021-12-02T12:48:52+00:00" 646 | }, 647 | { 648 | "name": "phpunit/php-invoker", 649 | "version": "3.1.1", 650 | "source": { 651 | "type": "git", 652 | "url": "https://github.com/sebastianbergmann/php-invoker.git", 653 | "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" 654 | }, 655 | "dist": { 656 | "type": "zip", 657 | "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", 658 | "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", 659 | "shasum": "" 660 | }, 661 | "require": { 662 | "php": ">=7.3" 663 | }, 664 | "require-dev": { 665 | "ext-pcntl": "*", 666 | "phpunit/phpunit": "^9.3" 667 | }, 668 | "suggest": { 669 | "ext-pcntl": "*" 670 | }, 671 | "type": "library", 672 | "extra": { 673 | "branch-alias": { 674 | "dev-master": "3.1-dev" 675 | } 676 | }, 677 | "autoload": { 678 | "classmap": [ 679 | "src/" 680 | ] 681 | }, 682 | "notification-url": "https://packagist.org/downloads/", 683 | "license": [ 684 | "BSD-3-Clause" 685 | ], 686 | "authors": [ 687 | { 688 | "name": "Sebastian Bergmann", 689 | "email": "sebastian@phpunit.de", 690 | "role": "lead" 691 | } 692 | ], 693 | "description": "Invoke callables with a timeout", 694 | "homepage": "https://github.com/sebastianbergmann/php-invoker/", 695 | "keywords": [ 696 | "process" 697 | ], 698 | "support": { 699 | "issues": "https://github.com/sebastianbergmann/php-invoker/issues", 700 | "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" 701 | }, 702 | "funding": [ 703 | { 704 | "url": "https://github.com/sebastianbergmann", 705 | "type": "github" 706 | } 707 | ], 708 | "time": "2020-09-28T05:58:55+00:00" 709 | }, 710 | { 711 | "name": "phpunit/php-text-template", 712 | "version": "2.0.4", 713 | "source": { 714 | "type": "git", 715 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 716 | "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" 717 | }, 718 | "dist": { 719 | "type": "zip", 720 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", 721 | "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", 722 | "shasum": "" 723 | }, 724 | "require": { 725 | "php": ">=7.3" 726 | }, 727 | "require-dev": { 728 | "phpunit/phpunit": "^9.3" 729 | }, 730 | "type": "library", 731 | "extra": { 732 | "branch-alias": { 733 | "dev-master": "2.0-dev" 734 | } 735 | }, 736 | "autoload": { 737 | "classmap": [ 738 | "src/" 739 | ] 740 | }, 741 | "notification-url": "https://packagist.org/downloads/", 742 | "license": [ 743 | "BSD-3-Clause" 744 | ], 745 | "authors": [ 746 | { 747 | "name": "Sebastian Bergmann", 748 | "email": "sebastian@phpunit.de", 749 | "role": "lead" 750 | } 751 | ], 752 | "description": "Simple template engine.", 753 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 754 | "keywords": [ 755 | "template" 756 | ], 757 | "support": { 758 | "issues": "https://github.com/sebastianbergmann/php-text-template/issues", 759 | "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" 760 | }, 761 | "funding": [ 762 | { 763 | "url": "https://github.com/sebastianbergmann", 764 | "type": "github" 765 | } 766 | ], 767 | "time": "2020-10-26T05:33:50+00:00" 768 | }, 769 | { 770 | "name": "phpunit/php-timer", 771 | "version": "5.0.3", 772 | "source": { 773 | "type": "git", 774 | "url": "https://github.com/sebastianbergmann/php-timer.git", 775 | "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" 776 | }, 777 | "dist": { 778 | "type": "zip", 779 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", 780 | "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", 781 | "shasum": "" 782 | }, 783 | "require": { 784 | "php": ">=7.3" 785 | }, 786 | "require-dev": { 787 | "phpunit/phpunit": "^9.3" 788 | }, 789 | "type": "library", 790 | "extra": { 791 | "branch-alias": { 792 | "dev-master": "5.0-dev" 793 | } 794 | }, 795 | "autoload": { 796 | "classmap": [ 797 | "src/" 798 | ] 799 | }, 800 | "notification-url": "https://packagist.org/downloads/", 801 | "license": [ 802 | "BSD-3-Clause" 803 | ], 804 | "authors": [ 805 | { 806 | "name": "Sebastian Bergmann", 807 | "email": "sebastian@phpunit.de", 808 | "role": "lead" 809 | } 810 | ], 811 | "description": "Utility class for timing", 812 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 813 | "keywords": [ 814 | "timer" 815 | ], 816 | "support": { 817 | "issues": "https://github.com/sebastianbergmann/php-timer/issues", 818 | "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" 819 | }, 820 | "funding": [ 821 | { 822 | "url": "https://github.com/sebastianbergmann", 823 | "type": "github" 824 | } 825 | ], 826 | "time": "2020-10-26T13:16:10+00:00" 827 | }, 828 | { 829 | "name": "phpunit/phpunit", 830 | "version": "9.5.25", 831 | "source": { 832 | "type": "git", 833 | "url": "https://github.com/sebastianbergmann/phpunit.git", 834 | "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d" 835 | }, 836 | "dist": { 837 | "type": "zip", 838 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", 839 | "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", 840 | "shasum": "" 841 | }, 842 | "require": { 843 | "doctrine/instantiator": "^1.3.1", 844 | "ext-dom": "*", 845 | "ext-json": "*", 846 | "ext-libxml": "*", 847 | "ext-mbstring": "*", 848 | "ext-xml": "*", 849 | "ext-xmlwriter": "*", 850 | "myclabs/deep-copy": "^1.10.1", 851 | "phar-io/manifest": "^2.0.3", 852 | "phar-io/version": "^3.0.2", 853 | "php": ">=7.3", 854 | "phpunit/php-code-coverage": "^9.2.13", 855 | "phpunit/php-file-iterator": "^3.0.5", 856 | "phpunit/php-invoker": "^3.1.1", 857 | "phpunit/php-text-template": "^2.0.3", 858 | "phpunit/php-timer": "^5.0.2", 859 | "sebastian/cli-parser": "^1.0.1", 860 | "sebastian/code-unit": "^1.0.6", 861 | "sebastian/comparator": "^4.0.8", 862 | "sebastian/diff": "^4.0.3", 863 | "sebastian/environment": "^5.1.3", 864 | "sebastian/exporter": "^4.0.5", 865 | "sebastian/global-state": "^5.0.1", 866 | "sebastian/object-enumerator": "^4.0.3", 867 | "sebastian/resource-operations": "^3.0.3", 868 | "sebastian/type": "^3.2", 869 | "sebastian/version": "^3.0.2" 870 | }, 871 | "suggest": { 872 | "ext-soap": "*", 873 | "ext-xdebug": "*" 874 | }, 875 | "bin": [ 876 | "phpunit" 877 | ], 878 | "type": "library", 879 | "extra": { 880 | "branch-alias": { 881 | "dev-master": "9.5-dev" 882 | } 883 | }, 884 | "autoload": { 885 | "files": [ 886 | "src/Framework/Assert/Functions.php" 887 | ], 888 | "classmap": [ 889 | "src/" 890 | ] 891 | }, 892 | "notification-url": "https://packagist.org/downloads/", 893 | "license": [ 894 | "BSD-3-Clause" 895 | ], 896 | "authors": [ 897 | { 898 | "name": "Sebastian Bergmann", 899 | "email": "sebastian@phpunit.de", 900 | "role": "lead" 901 | } 902 | ], 903 | "description": "The PHP Unit Testing framework.", 904 | "homepage": "https://phpunit.de/", 905 | "keywords": [ 906 | "phpunit", 907 | "testing", 908 | "xunit" 909 | ], 910 | "support": { 911 | "issues": "https://github.com/sebastianbergmann/phpunit/issues", 912 | "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.25" 913 | }, 914 | "funding": [ 915 | { 916 | "url": "https://phpunit.de/sponsors.html", 917 | "type": "custom" 918 | }, 919 | { 920 | "url": "https://github.com/sebastianbergmann", 921 | "type": "github" 922 | }, 923 | { 924 | "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", 925 | "type": "tidelift" 926 | } 927 | ], 928 | "time": "2022-09-25T03:44:45+00:00" 929 | }, 930 | { 931 | "name": "sebastian/cli-parser", 932 | "version": "1.0.1", 933 | "source": { 934 | "type": "git", 935 | "url": "https://github.com/sebastianbergmann/cli-parser.git", 936 | "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" 937 | }, 938 | "dist": { 939 | "type": "zip", 940 | "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", 941 | "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", 942 | "shasum": "" 943 | }, 944 | "require": { 945 | "php": ">=7.3" 946 | }, 947 | "require-dev": { 948 | "phpunit/phpunit": "^9.3" 949 | }, 950 | "type": "library", 951 | "extra": { 952 | "branch-alias": { 953 | "dev-master": "1.0-dev" 954 | } 955 | }, 956 | "autoload": { 957 | "classmap": [ 958 | "src/" 959 | ] 960 | }, 961 | "notification-url": "https://packagist.org/downloads/", 962 | "license": [ 963 | "BSD-3-Clause" 964 | ], 965 | "authors": [ 966 | { 967 | "name": "Sebastian Bergmann", 968 | "email": "sebastian@phpunit.de", 969 | "role": "lead" 970 | } 971 | ], 972 | "description": "Library for parsing CLI options", 973 | "homepage": "https://github.com/sebastianbergmann/cli-parser", 974 | "support": { 975 | "issues": "https://github.com/sebastianbergmann/cli-parser/issues", 976 | "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" 977 | }, 978 | "funding": [ 979 | { 980 | "url": "https://github.com/sebastianbergmann", 981 | "type": "github" 982 | } 983 | ], 984 | "time": "2020-09-28T06:08:49+00:00" 985 | }, 986 | { 987 | "name": "sebastian/code-unit", 988 | "version": "1.0.8", 989 | "source": { 990 | "type": "git", 991 | "url": "https://github.com/sebastianbergmann/code-unit.git", 992 | "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" 993 | }, 994 | "dist": { 995 | "type": "zip", 996 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", 997 | "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", 998 | "shasum": "" 999 | }, 1000 | "require": { 1001 | "php": ">=7.3" 1002 | }, 1003 | "require-dev": { 1004 | "phpunit/phpunit": "^9.3" 1005 | }, 1006 | "type": "library", 1007 | "extra": { 1008 | "branch-alias": { 1009 | "dev-master": "1.0-dev" 1010 | } 1011 | }, 1012 | "autoload": { 1013 | "classmap": [ 1014 | "src/" 1015 | ] 1016 | }, 1017 | "notification-url": "https://packagist.org/downloads/", 1018 | "license": [ 1019 | "BSD-3-Clause" 1020 | ], 1021 | "authors": [ 1022 | { 1023 | "name": "Sebastian Bergmann", 1024 | "email": "sebastian@phpunit.de", 1025 | "role": "lead" 1026 | } 1027 | ], 1028 | "description": "Collection of value objects that represent the PHP code units", 1029 | "homepage": "https://github.com/sebastianbergmann/code-unit", 1030 | "support": { 1031 | "issues": "https://github.com/sebastianbergmann/code-unit/issues", 1032 | "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" 1033 | }, 1034 | "funding": [ 1035 | { 1036 | "url": "https://github.com/sebastianbergmann", 1037 | "type": "github" 1038 | } 1039 | ], 1040 | "time": "2020-10-26T13:08:54+00:00" 1041 | }, 1042 | { 1043 | "name": "sebastian/code-unit-reverse-lookup", 1044 | "version": "2.0.3", 1045 | "source": { 1046 | "type": "git", 1047 | "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", 1048 | "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" 1049 | }, 1050 | "dist": { 1051 | "type": "zip", 1052 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", 1053 | "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", 1054 | "shasum": "" 1055 | }, 1056 | "require": { 1057 | "php": ">=7.3" 1058 | }, 1059 | "require-dev": { 1060 | "phpunit/phpunit": "^9.3" 1061 | }, 1062 | "type": "library", 1063 | "extra": { 1064 | "branch-alias": { 1065 | "dev-master": "2.0-dev" 1066 | } 1067 | }, 1068 | "autoload": { 1069 | "classmap": [ 1070 | "src/" 1071 | ] 1072 | }, 1073 | "notification-url": "https://packagist.org/downloads/", 1074 | "license": [ 1075 | "BSD-3-Clause" 1076 | ], 1077 | "authors": [ 1078 | { 1079 | "name": "Sebastian Bergmann", 1080 | "email": "sebastian@phpunit.de" 1081 | } 1082 | ], 1083 | "description": "Looks up which function or method a line of code belongs to", 1084 | "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", 1085 | "support": { 1086 | "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", 1087 | "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" 1088 | }, 1089 | "funding": [ 1090 | { 1091 | "url": "https://github.com/sebastianbergmann", 1092 | "type": "github" 1093 | } 1094 | ], 1095 | "time": "2020-09-28T05:30:19+00:00" 1096 | }, 1097 | { 1098 | "name": "sebastian/comparator", 1099 | "version": "4.0.8", 1100 | "source": { 1101 | "type": "git", 1102 | "url": "https://github.com/sebastianbergmann/comparator.git", 1103 | "reference": "fa0f136dd2334583309d32b62544682ee972b51a" 1104 | }, 1105 | "dist": { 1106 | "type": "zip", 1107 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", 1108 | "reference": "fa0f136dd2334583309d32b62544682ee972b51a", 1109 | "shasum": "" 1110 | }, 1111 | "require": { 1112 | "php": ">=7.3", 1113 | "sebastian/diff": "^4.0", 1114 | "sebastian/exporter": "^4.0" 1115 | }, 1116 | "require-dev": { 1117 | "phpunit/phpunit": "^9.3" 1118 | }, 1119 | "type": "library", 1120 | "extra": { 1121 | "branch-alias": { 1122 | "dev-master": "4.0-dev" 1123 | } 1124 | }, 1125 | "autoload": { 1126 | "classmap": [ 1127 | "src/" 1128 | ] 1129 | }, 1130 | "notification-url": "https://packagist.org/downloads/", 1131 | "license": [ 1132 | "BSD-3-Clause" 1133 | ], 1134 | "authors": [ 1135 | { 1136 | "name": "Sebastian Bergmann", 1137 | "email": "sebastian@phpunit.de" 1138 | }, 1139 | { 1140 | "name": "Jeff Welch", 1141 | "email": "whatthejeff@gmail.com" 1142 | }, 1143 | { 1144 | "name": "Volker Dusch", 1145 | "email": "github@wallbash.com" 1146 | }, 1147 | { 1148 | "name": "Bernhard Schussek", 1149 | "email": "bschussek@2bepublished.at" 1150 | } 1151 | ], 1152 | "description": "Provides the functionality to compare PHP values for equality", 1153 | "homepage": "https://github.com/sebastianbergmann/comparator", 1154 | "keywords": [ 1155 | "comparator", 1156 | "compare", 1157 | "equality" 1158 | ], 1159 | "support": { 1160 | "issues": "https://github.com/sebastianbergmann/comparator/issues", 1161 | "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" 1162 | }, 1163 | "funding": [ 1164 | { 1165 | "url": "https://github.com/sebastianbergmann", 1166 | "type": "github" 1167 | } 1168 | ], 1169 | "time": "2022-09-14T12:41:17+00:00" 1170 | }, 1171 | { 1172 | "name": "sebastian/complexity", 1173 | "version": "2.0.2", 1174 | "source": { 1175 | "type": "git", 1176 | "url": "https://github.com/sebastianbergmann/complexity.git", 1177 | "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" 1178 | }, 1179 | "dist": { 1180 | "type": "zip", 1181 | "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", 1182 | "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", 1183 | "shasum": "" 1184 | }, 1185 | "require": { 1186 | "nikic/php-parser": "^4.7", 1187 | "php": ">=7.3" 1188 | }, 1189 | "require-dev": { 1190 | "phpunit/phpunit": "^9.3" 1191 | }, 1192 | "type": "library", 1193 | "extra": { 1194 | "branch-alias": { 1195 | "dev-master": "2.0-dev" 1196 | } 1197 | }, 1198 | "autoload": { 1199 | "classmap": [ 1200 | "src/" 1201 | ] 1202 | }, 1203 | "notification-url": "https://packagist.org/downloads/", 1204 | "license": [ 1205 | "BSD-3-Clause" 1206 | ], 1207 | "authors": [ 1208 | { 1209 | "name": "Sebastian Bergmann", 1210 | "email": "sebastian@phpunit.de", 1211 | "role": "lead" 1212 | } 1213 | ], 1214 | "description": "Library for calculating the complexity of PHP code units", 1215 | "homepage": "https://github.com/sebastianbergmann/complexity", 1216 | "support": { 1217 | "issues": "https://github.com/sebastianbergmann/complexity/issues", 1218 | "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" 1219 | }, 1220 | "funding": [ 1221 | { 1222 | "url": "https://github.com/sebastianbergmann", 1223 | "type": "github" 1224 | } 1225 | ], 1226 | "time": "2020-10-26T15:52:27+00:00" 1227 | }, 1228 | { 1229 | "name": "sebastian/diff", 1230 | "version": "4.0.4", 1231 | "source": { 1232 | "type": "git", 1233 | "url": "https://github.com/sebastianbergmann/diff.git", 1234 | "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" 1235 | }, 1236 | "dist": { 1237 | "type": "zip", 1238 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", 1239 | "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", 1240 | "shasum": "" 1241 | }, 1242 | "require": { 1243 | "php": ">=7.3" 1244 | }, 1245 | "require-dev": { 1246 | "phpunit/phpunit": "^9.3", 1247 | "symfony/process": "^4.2 || ^5" 1248 | }, 1249 | "type": "library", 1250 | "extra": { 1251 | "branch-alias": { 1252 | "dev-master": "4.0-dev" 1253 | } 1254 | }, 1255 | "autoload": { 1256 | "classmap": [ 1257 | "src/" 1258 | ] 1259 | }, 1260 | "notification-url": "https://packagist.org/downloads/", 1261 | "license": [ 1262 | "BSD-3-Clause" 1263 | ], 1264 | "authors": [ 1265 | { 1266 | "name": "Sebastian Bergmann", 1267 | "email": "sebastian@phpunit.de" 1268 | }, 1269 | { 1270 | "name": "Kore Nordmann", 1271 | "email": "mail@kore-nordmann.de" 1272 | } 1273 | ], 1274 | "description": "Diff implementation", 1275 | "homepage": "https://github.com/sebastianbergmann/diff", 1276 | "keywords": [ 1277 | "diff", 1278 | "udiff", 1279 | "unidiff", 1280 | "unified diff" 1281 | ], 1282 | "support": { 1283 | "issues": "https://github.com/sebastianbergmann/diff/issues", 1284 | "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" 1285 | }, 1286 | "funding": [ 1287 | { 1288 | "url": "https://github.com/sebastianbergmann", 1289 | "type": "github" 1290 | } 1291 | ], 1292 | "time": "2020-10-26T13:10:38+00:00" 1293 | }, 1294 | { 1295 | "name": "sebastian/environment", 1296 | "version": "5.1.4", 1297 | "source": { 1298 | "type": "git", 1299 | "url": "https://github.com/sebastianbergmann/environment.git", 1300 | "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" 1301 | }, 1302 | "dist": { 1303 | "type": "zip", 1304 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", 1305 | "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", 1306 | "shasum": "" 1307 | }, 1308 | "require": { 1309 | "php": ">=7.3" 1310 | }, 1311 | "require-dev": { 1312 | "phpunit/phpunit": "^9.3" 1313 | }, 1314 | "suggest": { 1315 | "ext-posix": "*" 1316 | }, 1317 | "type": "library", 1318 | "extra": { 1319 | "branch-alias": { 1320 | "dev-master": "5.1-dev" 1321 | } 1322 | }, 1323 | "autoload": { 1324 | "classmap": [ 1325 | "src/" 1326 | ] 1327 | }, 1328 | "notification-url": "https://packagist.org/downloads/", 1329 | "license": [ 1330 | "BSD-3-Clause" 1331 | ], 1332 | "authors": [ 1333 | { 1334 | "name": "Sebastian Bergmann", 1335 | "email": "sebastian@phpunit.de" 1336 | } 1337 | ], 1338 | "description": "Provides functionality to handle HHVM/PHP environments", 1339 | "homepage": "http://www.github.com/sebastianbergmann/environment", 1340 | "keywords": [ 1341 | "Xdebug", 1342 | "environment", 1343 | "hhvm" 1344 | ], 1345 | "support": { 1346 | "issues": "https://github.com/sebastianbergmann/environment/issues", 1347 | "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" 1348 | }, 1349 | "funding": [ 1350 | { 1351 | "url": "https://github.com/sebastianbergmann", 1352 | "type": "github" 1353 | } 1354 | ], 1355 | "time": "2022-04-03T09:37:03+00:00" 1356 | }, 1357 | { 1358 | "name": "sebastian/exporter", 1359 | "version": "4.0.5", 1360 | "source": { 1361 | "type": "git", 1362 | "url": "https://github.com/sebastianbergmann/exporter.git", 1363 | "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" 1364 | }, 1365 | "dist": { 1366 | "type": "zip", 1367 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", 1368 | "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", 1369 | "shasum": "" 1370 | }, 1371 | "require": { 1372 | "php": ">=7.3", 1373 | "sebastian/recursion-context": "^4.0" 1374 | }, 1375 | "require-dev": { 1376 | "ext-mbstring": "*", 1377 | "phpunit/phpunit": "^9.3" 1378 | }, 1379 | "type": "library", 1380 | "extra": { 1381 | "branch-alias": { 1382 | "dev-master": "4.0-dev" 1383 | } 1384 | }, 1385 | "autoload": { 1386 | "classmap": [ 1387 | "src/" 1388 | ] 1389 | }, 1390 | "notification-url": "https://packagist.org/downloads/", 1391 | "license": [ 1392 | "BSD-3-Clause" 1393 | ], 1394 | "authors": [ 1395 | { 1396 | "name": "Sebastian Bergmann", 1397 | "email": "sebastian@phpunit.de" 1398 | }, 1399 | { 1400 | "name": "Jeff Welch", 1401 | "email": "whatthejeff@gmail.com" 1402 | }, 1403 | { 1404 | "name": "Volker Dusch", 1405 | "email": "github@wallbash.com" 1406 | }, 1407 | { 1408 | "name": "Adam Harvey", 1409 | "email": "aharvey@php.net" 1410 | }, 1411 | { 1412 | "name": "Bernhard Schussek", 1413 | "email": "bschussek@gmail.com" 1414 | } 1415 | ], 1416 | "description": "Provides the functionality to export PHP variables for visualization", 1417 | "homepage": "https://www.github.com/sebastianbergmann/exporter", 1418 | "keywords": [ 1419 | "export", 1420 | "exporter" 1421 | ], 1422 | "support": { 1423 | "issues": "https://github.com/sebastianbergmann/exporter/issues", 1424 | "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" 1425 | }, 1426 | "funding": [ 1427 | { 1428 | "url": "https://github.com/sebastianbergmann", 1429 | "type": "github" 1430 | } 1431 | ], 1432 | "time": "2022-09-14T06:03:37+00:00" 1433 | }, 1434 | { 1435 | "name": "sebastian/global-state", 1436 | "version": "5.0.5", 1437 | "source": { 1438 | "type": "git", 1439 | "url": "https://github.com/sebastianbergmann/global-state.git", 1440 | "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" 1441 | }, 1442 | "dist": { 1443 | "type": "zip", 1444 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", 1445 | "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", 1446 | "shasum": "" 1447 | }, 1448 | "require": { 1449 | "php": ">=7.3", 1450 | "sebastian/object-reflector": "^2.0", 1451 | "sebastian/recursion-context": "^4.0" 1452 | }, 1453 | "require-dev": { 1454 | "ext-dom": "*", 1455 | "phpunit/phpunit": "^9.3" 1456 | }, 1457 | "suggest": { 1458 | "ext-uopz": "*" 1459 | }, 1460 | "type": "library", 1461 | "extra": { 1462 | "branch-alias": { 1463 | "dev-master": "5.0-dev" 1464 | } 1465 | }, 1466 | "autoload": { 1467 | "classmap": [ 1468 | "src/" 1469 | ] 1470 | }, 1471 | "notification-url": "https://packagist.org/downloads/", 1472 | "license": [ 1473 | "BSD-3-Clause" 1474 | ], 1475 | "authors": [ 1476 | { 1477 | "name": "Sebastian Bergmann", 1478 | "email": "sebastian@phpunit.de" 1479 | } 1480 | ], 1481 | "description": "Snapshotting of global state", 1482 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1483 | "keywords": [ 1484 | "global state" 1485 | ], 1486 | "support": { 1487 | "issues": "https://github.com/sebastianbergmann/global-state/issues", 1488 | "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" 1489 | }, 1490 | "funding": [ 1491 | { 1492 | "url": "https://github.com/sebastianbergmann", 1493 | "type": "github" 1494 | } 1495 | ], 1496 | "time": "2022-02-14T08:28:10+00:00" 1497 | }, 1498 | { 1499 | "name": "sebastian/lines-of-code", 1500 | "version": "1.0.3", 1501 | "source": { 1502 | "type": "git", 1503 | "url": "https://github.com/sebastianbergmann/lines-of-code.git", 1504 | "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" 1505 | }, 1506 | "dist": { 1507 | "type": "zip", 1508 | "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", 1509 | "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", 1510 | "shasum": "" 1511 | }, 1512 | "require": { 1513 | "nikic/php-parser": "^4.6", 1514 | "php": ">=7.3" 1515 | }, 1516 | "require-dev": { 1517 | "phpunit/phpunit": "^9.3" 1518 | }, 1519 | "type": "library", 1520 | "extra": { 1521 | "branch-alias": { 1522 | "dev-master": "1.0-dev" 1523 | } 1524 | }, 1525 | "autoload": { 1526 | "classmap": [ 1527 | "src/" 1528 | ] 1529 | }, 1530 | "notification-url": "https://packagist.org/downloads/", 1531 | "license": [ 1532 | "BSD-3-Clause" 1533 | ], 1534 | "authors": [ 1535 | { 1536 | "name": "Sebastian Bergmann", 1537 | "email": "sebastian@phpunit.de", 1538 | "role": "lead" 1539 | } 1540 | ], 1541 | "description": "Library for counting the lines of code in PHP source code", 1542 | "homepage": "https://github.com/sebastianbergmann/lines-of-code", 1543 | "support": { 1544 | "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", 1545 | "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" 1546 | }, 1547 | "funding": [ 1548 | { 1549 | "url": "https://github.com/sebastianbergmann", 1550 | "type": "github" 1551 | } 1552 | ], 1553 | "time": "2020-11-28T06:42:11+00:00" 1554 | }, 1555 | { 1556 | "name": "sebastian/object-enumerator", 1557 | "version": "4.0.4", 1558 | "source": { 1559 | "type": "git", 1560 | "url": "https://github.com/sebastianbergmann/object-enumerator.git", 1561 | "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" 1562 | }, 1563 | "dist": { 1564 | "type": "zip", 1565 | "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", 1566 | "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", 1567 | "shasum": "" 1568 | }, 1569 | "require": { 1570 | "php": ">=7.3", 1571 | "sebastian/object-reflector": "^2.0", 1572 | "sebastian/recursion-context": "^4.0" 1573 | }, 1574 | "require-dev": { 1575 | "phpunit/phpunit": "^9.3" 1576 | }, 1577 | "type": "library", 1578 | "extra": { 1579 | "branch-alias": { 1580 | "dev-master": "4.0-dev" 1581 | } 1582 | }, 1583 | "autoload": { 1584 | "classmap": [ 1585 | "src/" 1586 | ] 1587 | }, 1588 | "notification-url": "https://packagist.org/downloads/", 1589 | "license": [ 1590 | "BSD-3-Clause" 1591 | ], 1592 | "authors": [ 1593 | { 1594 | "name": "Sebastian Bergmann", 1595 | "email": "sebastian@phpunit.de" 1596 | } 1597 | ], 1598 | "description": "Traverses array structures and object graphs to enumerate all referenced objects", 1599 | "homepage": "https://github.com/sebastianbergmann/object-enumerator/", 1600 | "support": { 1601 | "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", 1602 | "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" 1603 | }, 1604 | "funding": [ 1605 | { 1606 | "url": "https://github.com/sebastianbergmann", 1607 | "type": "github" 1608 | } 1609 | ], 1610 | "time": "2020-10-26T13:12:34+00:00" 1611 | }, 1612 | { 1613 | "name": "sebastian/object-reflector", 1614 | "version": "2.0.4", 1615 | "source": { 1616 | "type": "git", 1617 | "url": "https://github.com/sebastianbergmann/object-reflector.git", 1618 | "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" 1619 | }, 1620 | "dist": { 1621 | "type": "zip", 1622 | "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", 1623 | "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", 1624 | "shasum": "" 1625 | }, 1626 | "require": { 1627 | "php": ">=7.3" 1628 | }, 1629 | "require-dev": { 1630 | "phpunit/phpunit": "^9.3" 1631 | }, 1632 | "type": "library", 1633 | "extra": { 1634 | "branch-alias": { 1635 | "dev-master": "2.0-dev" 1636 | } 1637 | }, 1638 | "autoload": { 1639 | "classmap": [ 1640 | "src/" 1641 | ] 1642 | }, 1643 | "notification-url": "https://packagist.org/downloads/", 1644 | "license": [ 1645 | "BSD-3-Clause" 1646 | ], 1647 | "authors": [ 1648 | { 1649 | "name": "Sebastian Bergmann", 1650 | "email": "sebastian@phpunit.de" 1651 | } 1652 | ], 1653 | "description": "Allows reflection of object attributes, including inherited and non-public ones", 1654 | "homepage": "https://github.com/sebastianbergmann/object-reflector/", 1655 | "support": { 1656 | "issues": "https://github.com/sebastianbergmann/object-reflector/issues", 1657 | "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" 1658 | }, 1659 | "funding": [ 1660 | { 1661 | "url": "https://github.com/sebastianbergmann", 1662 | "type": "github" 1663 | } 1664 | ], 1665 | "time": "2020-10-26T13:14:26+00:00" 1666 | }, 1667 | { 1668 | "name": "sebastian/recursion-context", 1669 | "version": "4.0.4", 1670 | "source": { 1671 | "type": "git", 1672 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1673 | "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" 1674 | }, 1675 | "dist": { 1676 | "type": "zip", 1677 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", 1678 | "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", 1679 | "shasum": "" 1680 | }, 1681 | "require": { 1682 | "php": ">=7.3" 1683 | }, 1684 | "require-dev": { 1685 | "phpunit/phpunit": "^9.3" 1686 | }, 1687 | "type": "library", 1688 | "extra": { 1689 | "branch-alias": { 1690 | "dev-master": "4.0-dev" 1691 | } 1692 | }, 1693 | "autoload": { 1694 | "classmap": [ 1695 | "src/" 1696 | ] 1697 | }, 1698 | "notification-url": "https://packagist.org/downloads/", 1699 | "license": [ 1700 | "BSD-3-Clause" 1701 | ], 1702 | "authors": [ 1703 | { 1704 | "name": "Sebastian Bergmann", 1705 | "email": "sebastian@phpunit.de" 1706 | }, 1707 | { 1708 | "name": "Jeff Welch", 1709 | "email": "whatthejeff@gmail.com" 1710 | }, 1711 | { 1712 | "name": "Adam Harvey", 1713 | "email": "aharvey@php.net" 1714 | } 1715 | ], 1716 | "description": "Provides functionality to recursively process PHP variables", 1717 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1718 | "support": { 1719 | "issues": "https://github.com/sebastianbergmann/recursion-context/issues", 1720 | "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" 1721 | }, 1722 | "funding": [ 1723 | { 1724 | "url": "https://github.com/sebastianbergmann", 1725 | "type": "github" 1726 | } 1727 | ], 1728 | "time": "2020-10-26T13:17:30+00:00" 1729 | }, 1730 | { 1731 | "name": "sebastian/resource-operations", 1732 | "version": "3.0.3", 1733 | "source": { 1734 | "type": "git", 1735 | "url": "https://github.com/sebastianbergmann/resource-operations.git", 1736 | "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" 1737 | }, 1738 | "dist": { 1739 | "type": "zip", 1740 | "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", 1741 | "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", 1742 | "shasum": "" 1743 | }, 1744 | "require": { 1745 | "php": ">=7.3" 1746 | }, 1747 | "require-dev": { 1748 | "phpunit/phpunit": "^9.0" 1749 | }, 1750 | "type": "library", 1751 | "extra": { 1752 | "branch-alias": { 1753 | "dev-master": "3.0-dev" 1754 | } 1755 | }, 1756 | "autoload": { 1757 | "classmap": [ 1758 | "src/" 1759 | ] 1760 | }, 1761 | "notification-url": "https://packagist.org/downloads/", 1762 | "license": [ 1763 | "BSD-3-Clause" 1764 | ], 1765 | "authors": [ 1766 | { 1767 | "name": "Sebastian Bergmann", 1768 | "email": "sebastian@phpunit.de" 1769 | } 1770 | ], 1771 | "description": "Provides a list of PHP built-in functions that operate on resources", 1772 | "homepage": "https://www.github.com/sebastianbergmann/resource-operations", 1773 | "support": { 1774 | "issues": "https://github.com/sebastianbergmann/resource-operations/issues", 1775 | "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" 1776 | }, 1777 | "funding": [ 1778 | { 1779 | "url": "https://github.com/sebastianbergmann", 1780 | "type": "github" 1781 | } 1782 | ], 1783 | "time": "2020-09-28T06:45:17+00:00" 1784 | }, 1785 | { 1786 | "name": "sebastian/type", 1787 | "version": "3.2.0", 1788 | "source": { 1789 | "type": "git", 1790 | "url": "https://github.com/sebastianbergmann/type.git", 1791 | "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" 1792 | }, 1793 | "dist": { 1794 | "type": "zip", 1795 | "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", 1796 | "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", 1797 | "shasum": "" 1798 | }, 1799 | "require": { 1800 | "php": ">=7.3" 1801 | }, 1802 | "require-dev": { 1803 | "phpunit/phpunit": "^9.5" 1804 | }, 1805 | "type": "library", 1806 | "extra": { 1807 | "branch-alias": { 1808 | "dev-master": "3.2-dev" 1809 | } 1810 | }, 1811 | "autoload": { 1812 | "classmap": [ 1813 | "src/" 1814 | ] 1815 | }, 1816 | "notification-url": "https://packagist.org/downloads/", 1817 | "license": [ 1818 | "BSD-3-Clause" 1819 | ], 1820 | "authors": [ 1821 | { 1822 | "name": "Sebastian Bergmann", 1823 | "email": "sebastian@phpunit.de", 1824 | "role": "lead" 1825 | } 1826 | ], 1827 | "description": "Collection of value objects that represent the types of the PHP type system", 1828 | "homepage": "https://github.com/sebastianbergmann/type", 1829 | "support": { 1830 | "issues": "https://github.com/sebastianbergmann/type/issues", 1831 | "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" 1832 | }, 1833 | "funding": [ 1834 | { 1835 | "url": "https://github.com/sebastianbergmann", 1836 | "type": "github" 1837 | } 1838 | ], 1839 | "time": "2022-09-12T14:47:03+00:00" 1840 | }, 1841 | { 1842 | "name": "sebastian/version", 1843 | "version": "3.0.2", 1844 | "source": { 1845 | "type": "git", 1846 | "url": "https://github.com/sebastianbergmann/version.git", 1847 | "reference": "c6c1022351a901512170118436c764e473f6de8c" 1848 | }, 1849 | "dist": { 1850 | "type": "zip", 1851 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", 1852 | "reference": "c6c1022351a901512170118436c764e473f6de8c", 1853 | "shasum": "" 1854 | }, 1855 | "require": { 1856 | "php": ">=7.3" 1857 | }, 1858 | "type": "library", 1859 | "extra": { 1860 | "branch-alias": { 1861 | "dev-master": "3.0-dev" 1862 | } 1863 | }, 1864 | "autoload": { 1865 | "classmap": [ 1866 | "src/" 1867 | ] 1868 | }, 1869 | "notification-url": "https://packagist.org/downloads/", 1870 | "license": [ 1871 | "BSD-3-Clause" 1872 | ], 1873 | "authors": [ 1874 | { 1875 | "name": "Sebastian Bergmann", 1876 | "email": "sebastian@phpunit.de", 1877 | "role": "lead" 1878 | } 1879 | ], 1880 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1881 | "homepage": "https://github.com/sebastianbergmann/version", 1882 | "support": { 1883 | "issues": "https://github.com/sebastianbergmann/version/issues", 1884 | "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" 1885 | }, 1886 | "funding": [ 1887 | { 1888 | "url": "https://github.com/sebastianbergmann", 1889 | "type": "github" 1890 | } 1891 | ], 1892 | "time": "2020-09-28T06:39:44+00:00" 1893 | }, 1894 | { 1895 | "name": "theseer/tokenizer", 1896 | "version": "1.2.1", 1897 | "source": { 1898 | "type": "git", 1899 | "url": "https://github.com/theseer/tokenizer.git", 1900 | "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" 1901 | }, 1902 | "dist": { 1903 | "type": "zip", 1904 | "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", 1905 | "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", 1906 | "shasum": "" 1907 | }, 1908 | "require": { 1909 | "ext-dom": "*", 1910 | "ext-tokenizer": "*", 1911 | "ext-xmlwriter": "*", 1912 | "php": "^7.2 || ^8.0" 1913 | }, 1914 | "type": "library", 1915 | "autoload": { 1916 | "classmap": [ 1917 | "src/" 1918 | ] 1919 | }, 1920 | "notification-url": "https://packagist.org/downloads/", 1921 | "license": [ 1922 | "BSD-3-Clause" 1923 | ], 1924 | "authors": [ 1925 | { 1926 | "name": "Arne Blankerts", 1927 | "email": "arne@blankerts.de", 1928 | "role": "Developer" 1929 | } 1930 | ], 1931 | "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", 1932 | "support": { 1933 | "issues": "https://github.com/theseer/tokenizer/issues", 1934 | "source": "https://github.com/theseer/tokenizer/tree/1.2.1" 1935 | }, 1936 | "funding": [ 1937 | { 1938 | "url": "https://github.com/theseer", 1939 | "type": "github" 1940 | } 1941 | ], 1942 | "time": "2021-07-28T10:34:58+00:00" 1943 | }, 1944 | { 1945 | "name": "yoast/phpunit-polyfills", 1946 | "version": "1.0.3", 1947 | "source": { 1948 | "type": "git", 1949 | "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", 1950 | "reference": "5ea3536428944955f969bc764bbe09738e151ada" 1951 | }, 1952 | "dist": { 1953 | "type": "zip", 1954 | "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/5ea3536428944955f969bc764bbe09738e151ada", 1955 | "reference": "5ea3536428944955f969bc764bbe09738e151ada", 1956 | "shasum": "" 1957 | }, 1958 | "require": { 1959 | "php": ">=5.4", 1960 | "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0" 1961 | }, 1962 | "require-dev": { 1963 | "yoast/yoastcs": "^2.2.0" 1964 | }, 1965 | "type": "library", 1966 | "extra": { 1967 | "branch-alias": { 1968 | "dev-main": "1.x-dev", 1969 | "dev-develop": "1.x-dev" 1970 | } 1971 | }, 1972 | "autoload": { 1973 | "files": [ 1974 | "phpunitpolyfills-autoload.php" 1975 | ] 1976 | }, 1977 | "notification-url": "https://packagist.org/downloads/", 1978 | "license": [ 1979 | "BSD-3-Clause" 1980 | ], 1981 | "authors": [ 1982 | { 1983 | "name": "Team Yoast", 1984 | "email": "support@yoast.com", 1985 | "homepage": "https://yoast.com" 1986 | }, 1987 | { 1988 | "name": "Contributors", 1989 | "homepage": "https://github.com/Yoast/PHPUnit-Polyfills/graphs/contributors" 1990 | } 1991 | ], 1992 | "description": "Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests", 1993 | "homepage": "https://github.com/Yoast/PHPUnit-Polyfills", 1994 | "keywords": [ 1995 | "phpunit", 1996 | "polyfill", 1997 | "testing" 1998 | ], 1999 | "support": { 2000 | "issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues", 2001 | "source": "https://github.com/Yoast/PHPUnit-Polyfills" 2002 | }, 2003 | "time": "2021-11-23T01:37:03+00:00" 2004 | } 2005 | ], 2006 | "aliases": [], 2007 | "minimum-stability": "stable", 2008 | "stability-flags": [], 2009 | "prefer-stable": false, 2010 | "prefer-lowest": false, 2011 | "platform": { 2012 | "php": ">5.6.0" 2013 | }, 2014 | "platform-dev": [], 2015 | "plugin-api-version": "2.3.0" 2016 | } 2017 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | tests/ 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/IndieAuth/Client.php: -------------------------------------------------------------------------------- 1 | getArray(); 46 | } 47 | 48 | $_SESSION['indieauth_issuer'] = $response; 49 | } 50 | 51 | if(!$authorizationEndpoint) { 52 | $authorizationEndpoint = static::discoverAuthorizationEndpoint($url); 53 | } 54 | 55 | if(!$authorizationEndpoint) { 56 | return self::_errorResponse('missing_authorization_endpoint', 'Could not find your authorization endpoint'); 57 | } 58 | 59 | $scopes = self::parseNonProfileScopes($scope); 60 | if(count($scopes)) { 61 | $tokenEndpoint = static::discoverTokenEndpoint($url); 62 | 63 | if(!$tokenEndpoint) { 64 | return self::_errorResponse('missing_token_endpoint', 'Could not find your token endpoint. The token endpoint is required when requesting non-profile scopes'); 65 | } 66 | } 67 | 68 | $state = self::generateStateParameter(); 69 | $codeVerifier = self::generatePKCECodeVerifier(); 70 | 71 | $_SESSION['indieauth_state'] = $state; 72 | $_SESSION['indieauth_code_verifier'] = $codeVerifier; 73 | $_SESSION['indieauth_authorization_endpoint'] = $authorizationEndpoint; 74 | if(isset($tokenEndpoint)) 75 | $_SESSION['indieauth_token_endpoint'] = $tokenEndpoint; 76 | 77 | $authorizationURL = self::buildAuthorizationURL($authorizationEndpoint, [ 78 | 'me' => $url, 79 | 'redirect_uri' => self::$redirectURL, 80 | 'client_id' => self::$clientID, 81 | 'state' => $state, 82 | 'code_verifier' => $codeVerifier, 83 | 'scope' => $scope, 84 | ]); 85 | 86 | return [$authorizationURL, false]; 87 | } 88 | 89 | public static function complete($params) { 90 | $requiredSessionKeys = ['indieauth_entered_url', 'indieauth_state', 'indieauth_authorization_endpoint']; 91 | foreach($requiredSessionKeys as $key) { 92 | if(!isset($_SESSION[$key])) { 93 | return self::_errorResponse('invalid_session', 94 | 'The session was missing data. Ensure that you are initializing the session before using this library'); 95 | } 96 | } 97 | 98 | if(isset($params['error'])) { 99 | return self::_errorResponse($params['error'], isset($params['error_description']) ? $params['error_description'] : ''); 100 | } 101 | 102 | if(!isset($params['code'])) { 103 | return self::_errorResponse('invalid_response', 104 | 'The response from the authorization server did not return an authorization code or error information'); 105 | } 106 | 107 | $response = self::validateStateMatch($params, $_SESSION['indieauth_state']); 108 | if ($response instanceof ErrorResponse) { 109 | return $response->getArray(); 110 | } 111 | 112 | if (isset($_SESSION['indieauth_issuer'])) { 113 | $response = self::validateIssuerMatch($params, $_SESSION['indieauth_issuer']); 114 | if ($response instanceof ErrorResponse) { 115 | return $response->getArray(); 116 | } 117 | } 118 | 119 | if(isset($_SESSION['indieauth_token_endpoint'])) { 120 | $data = self::exchangeAuthorizationCode($_SESSION['indieauth_token_endpoint'], [ 121 | 'code' => $params['code'], 122 | 'redirect_uri' => self::$redirectURL, 123 | 'client_id' => self::$clientID, 124 | 'code_verifier' => $_SESSION['indieauth_code_verifier'], 125 | ]); 126 | } else { 127 | $data = self::exchangeAuthorizationCode($_SESSION['indieauth_authorization_endpoint'], [ 128 | 'code' => $params['code'], 129 | 'redirect_uri' => self::$redirectURL, 130 | 'client_id' => self::$clientID, 131 | 'code_verifier' => $_SESSION['indieauth_code_verifier'], 132 | ]); 133 | } 134 | 135 | if(!isset($data['response']['me'])) { 136 | $error = 'indieauth_error'; 137 | if(!empty($data['response_details']['error'])) 138 | $error = $data['response_details']['error']; 139 | elseif(!empty($data['response']['error'])) 140 | $error = $data['response']['error']; 141 | 142 | $error_description = 'The authorization server did not return a valid response'; 143 | if(!empty($data['response_details']['error_description'])) 144 | $error_description = $data['response_details']['error_description']; 145 | elseif(!empty($data['response']['error_description'])) 146 | $error_description = $data['response']['error_description']; 147 | 148 | return self::_errorResponse($error, $error_description, $data); 149 | } 150 | 151 | // If the returned "me" is not the same as the entered "me", check that the authorization endpoint linked to 152 | // by the returned URL is the same as the one used 153 | if($_SESSION['indieauth_entered_url'] != $data['response']['me']) { 154 | // Discover and populate metadata if the returned "me" has a metadata endpoint 155 | $metadataEndpoint = self::discoverMetadataEndpoint($data['response']['me']); 156 | 157 | // Go find the authorization endpoint that the returned "me" URL declares 158 | $authorizationEndpoint = static::discoverAuthorizationEndpoint($data['response']['me']); 159 | 160 | if($authorizationEndpoint != $_SESSION['indieauth_authorization_endpoint']) { 161 | return self::_errorResponse('invalid_authorization_endpoint', 162 | 'The authorization server of the returned profile URL did not match the initial authorization server', $data); 163 | } 164 | } 165 | 166 | $data['me'] = self::normalizeMeURL($data['response']['me']); 167 | 168 | self::_clearSessionData(); 169 | 170 | return [$data, false]; 171 | } 172 | 173 | /** 174 | * Wrapper to create an ErrorResponse and return the array 175 | * @return array 176 | */ 177 | private static function _errorResponse($error_code, $description, $debug = null) { 178 | self::_clearSessionData(); 179 | $error = new ErrorResponse($error_code, $description, $debug); 180 | return $error->getArray(); 181 | } 182 | 183 | private static function _clearSessionData() { 184 | unset($_SESSION['indieauth_entered_url']); 185 | unset($_SESSION['indieauth_state']); 186 | unset($_SESSION['indieauth_code_verifier']); 187 | unset($_SESSION['indieauth_authorization_endpoint']); 188 | unset($_SESSION['indieauth_token_endpoint']); 189 | unset($_SESSION['indieauth_issuer']); 190 | } 191 | 192 | public static function setUpHTTP() { 193 | // Unfortunately I've seen a bunch of websites return different content when the user agent is set to something like curl or other server-side libraries, so we have to pretend to be a browser to successfully get the real HTML 194 | if(!isset(self::$http)) { 195 | self::$http = new \p3k\HTTP(); 196 | self::$http->set_user_agent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36 indieauth-client/' . self::VERSION); 197 | self::$http->_timeout = 10; 198 | // You can customize the user agent for your application by calling 199 | // IndieAuth\Client::$http->set_user_agent('Your User Agent String'); 200 | } 201 | } 202 | 203 | private static function _urlIsValid($url) { 204 | $url = parse_url($url); 205 | 206 | if($url == false 207 | || !array_key_exists('scheme', $url) 208 | || !in_array($url['scheme'], array('http','https')) 209 | || !array_key_exists('host', $url) 210 | ) { 211 | // Invalid url 212 | return false; 213 | } 214 | 215 | return true; 216 | } 217 | 218 | /** 219 | * @see https://indieauth.spec.indieweb.org/#indieauth-server-metadata 220 | */ 221 | private static function _isIssuerValid($issuer, $metadata_endpoint) { 222 | $issuer = self::normalizeMeURL($issuer); 223 | if (!$issuer) { 224 | return false; 225 | } 226 | 227 | $parts = parse_url($issuer); 228 | 229 | if (!array_key_exists('scheme', $parts) || $parts['scheme'] != 'https') { 230 | return false; 231 | } 232 | 233 | if (array_key_exists('query', $parts) || array_key_exists('fragment', $parts)) { 234 | return false; 235 | } 236 | 237 | $metadata_endpoint = self::normalizeMeURL($metadata_endpoint); 238 | 239 | if (strpos($metadata_endpoint, $issuer) !== 0) { 240 | return false; 241 | } 242 | 243 | return true; 244 | } 245 | 246 | private static function _fetchHead($url) { 247 | self::setUpHTTP(); 248 | 249 | if(array_key_exists($url, self::$_headers)) { 250 | return self::$_headers[$url]; 251 | } else { 252 | $headers = self::$http->head($url); 253 | self::$_headers[$url] = $headers['header']; 254 | return self::$_headers[$url]; 255 | } 256 | } 257 | 258 | private static function _fetchBody($url) { 259 | self::setUpHTTP(); 260 | 261 | if(array_key_exists($url, self::$_body)) { 262 | return self::$_body[$url]; 263 | } else { 264 | $response = self::$http->get($url); 265 | self::$_body[$url] = $response['body']; 266 | return self::$_body[$url]; 267 | } 268 | } 269 | 270 | private static function _fetchMetadata($url) { 271 | self::setUpHTTP(); 272 | 273 | if(array_key_exists($url, self::$_metadata_body)) { 274 | return self::$_metadata_body[$url]; 275 | } else { 276 | $response = self::$http->get($url); 277 | self::setMetadata($url, $response['body']); 278 | return self::$_metadata_body[$url]; 279 | } 280 | } 281 | 282 | private static function resetMetadata() { 283 | self::$_metadata_body = array(); 284 | self::$_metadata = null; 285 | } 286 | 287 | /** 288 | * Set metadata body 289 | * $body is expected to be JSON and will attempt 290 | * to decode to array in self::$_metadata 291 | */ 292 | public static function setMetadata($url, $body) { 293 | self::resetMetadata(); 294 | 295 | self::$_metadata_body[$url] = $body; 296 | $metadata_array = json_decode($body, true); 297 | if (!is_null($metadata_array)) { 298 | self::$_metadata = $metadata_array; 299 | } 300 | } 301 | 302 | public static function getMetadata() { 303 | return self::$_metadata; 304 | } 305 | 306 | private static function _discoverEndpoint($url, $name) { 307 | if(!self::_urlIsValid($url)) { 308 | return null; 309 | } 310 | 311 | // First check the parsed metadata for the endpoint 312 | if ($endpoint = self::_discoverFromMetadata($name)) { 313 | return $endpoint; 314 | } 315 | 316 | // If not found, check the HTTP headers for the endpoint 317 | $headerString = self::_fetchHead($url); 318 | 319 | if($endpoint = self::_extractEndpointFromHeaders($headerString, $url, $name)) { 320 | return $endpoint; 321 | } 322 | 323 | // If not found, check the body for a rel value 324 | $html = self::_fetchBody($url); 325 | 326 | return self::_extractEndpointFromHTML($html, $url, $name); 327 | } 328 | 329 | private static function _discoverFromMetadata($name) { 330 | if (!self::$_metadata) { 331 | return null; 332 | } 333 | 334 | if (array_key_exists($name, self::$_metadata)) { 335 | return self::$_metadata[$name]; 336 | } 337 | 338 | return null; 339 | } 340 | 341 | private static function _extractEndpointFromHeaders($headerString, $url, $name) { 342 | $headers = \IndieWeb\http_rels($headerString); 343 | 344 | if(isset($headers[$name][0])) { 345 | return \Mf2\resolveUrl($url, $headers[$name][0]); 346 | } 347 | 348 | return false; 349 | } 350 | 351 | private static function _extractEndpointFromHTML($html, $url, $name) { 352 | if(self::$_parsedHash != ($h=md5($html))) { 353 | $parser = new \Mf2\Parser($html); 354 | $parser->enableAlternates = true; 355 | self::$_parsed = $parser->parse(); 356 | self::$_parsedHash = $h; 357 | } 358 | 359 | if(isset(self::$_parsed['rels'][$name][0])) { 360 | return \Mf2\resolveUrl($url, self::$_parsed['rels'][$name][0]); 361 | } 362 | 363 | return false; 364 | } 365 | 366 | public static function discoverMetadataEndpoint($url) { 367 | if ($endpoint = self::_discoverEndpoint($url, 'indieauth-metadata')) { 368 | self::_fetchMetadata($endpoint); 369 | } 370 | 371 | return $endpoint; 372 | } 373 | 374 | /** 375 | * @param string $metadataEndpoint 376 | * @return IndieAuth\ErrorResponse if error, string of `issuer` if valid 377 | */ 378 | public static function discoverIssuer($metadataEndpoint) { 379 | $issuer = self::_discoverFromMetadata('issuer'); 380 | if (!$issuer) { 381 | return new ErrorResponse('invalid_issuer', 'No issuer found in metadata endpoint'); 382 | } 383 | 384 | if (!(self::_isIssuerValid($issuer, $metadataEndpoint))) { 385 | return new ErrorResponse('invalid_issuer', 'Issuer in metadata endpoint is not valid'); 386 | } 387 | 388 | return $issuer; 389 | } 390 | 391 | public static function discoverAuthorizationEndpoint($url) { 392 | return self::_discoverEndpoint($url, 'authorization_endpoint'); 393 | } 394 | 395 | public static function discoverTokenEndpoint($url) { 396 | return self::_discoverEndpoint($url, 'token_endpoint'); 397 | } 398 | 399 | public static function discoverRevocationEndpoint($url) { 400 | return self::_discoverEndpoint($url, 'revocation_endpoint'); 401 | } 402 | 403 | public static function discoverIntrospectionEndpoint($url) { 404 | return self::_discoverEndpoint($url, 'introspection_endpoint'); 405 | } 406 | 407 | public static function discoverUserinfoEndpoint($url) { 408 | return self::_discoverEndpoint($url, 'userinfo_endpoint'); 409 | } 410 | 411 | public static function discoverMicropubEndpoint($url) { 412 | return self::_discoverEndpoint($url, 'micropub'); 413 | } 414 | 415 | public static function discoverMicrosubEndpoint($url) { 416 | return self::_discoverEndpoint($url, 'microsub'); 417 | } 418 | 419 | // Build the authorization URL for the given url and endpoint 420 | public static function buildAuthorizationURL($authorizationEndpoint, $params) { 421 | $required = ['me', 'redirect_uri', 'client_id', 'state']; 422 | foreach($required as $r) { 423 | if(!isset($params[$r])) { 424 | throw new \Exception('Missing parameter to buildAuthorizationURL: '.$r); 425 | } 426 | } 427 | 428 | $url = parse_url($authorizationEndpoint); 429 | 430 | $request = array(); 431 | if(array_key_exists('query', $url)) { 432 | parse_str($url['query'], $request); 433 | } 434 | 435 | $request['response_type'] = 'code'; 436 | $request['me'] = $params['me']; 437 | $request['redirect_uri'] = $params['redirect_uri']; 438 | $request['client_id'] = $params['client_id']; 439 | $request['state'] = $params['state']; 440 | if(!empty($params['scope'])) { 441 | $request['scope'] = $params['scope']; 442 | } 443 | if(isset($params['code_verifier'])) { 444 | $request['code_challenge'] = self::generatePKCECodeChallenge($params['code_verifier']); 445 | $request['code_challenge_method'] = 'S256'; 446 | } 447 | 448 | $url['query'] = http_build_query($request); 449 | 450 | return self::build_url($url); 451 | } 452 | 453 | // Input: Any URL or string like "aaronparecki.com" 454 | // Output: Normlized URL (default to http if no scheme, default "/" path) 455 | // or return false if not a valid IndieAuth URL (has a fragment) 456 | public static function normalizeMeURL($url) { 457 | $me = parse_url($url); 458 | 459 | if(array_key_exists('path', $me) && $me['path'] == '') 460 | return false; 461 | 462 | // parse_url returns just "path" for naked domains, so 463 | // move that into the "host" instead 464 | if(count($me) == 1 && array_key_exists('path', $me)) { 465 | if(preg_match('/([^\/]+)(\/.+)/', $me['path'], $match)) { 466 | $me['host'] = $match[1]; 467 | $me['path'] = $match[2]; 468 | } else { 469 | $me['host'] = $me['path']; 470 | unset($me['path']); 471 | } 472 | } 473 | 474 | if(!array_key_exists('scheme', $me)) 475 | $me['scheme'] = 'http'; 476 | 477 | if(!array_key_exists('path', $me)) 478 | $me['path'] = '/'; 479 | 480 | // Invalid scheme 481 | if(!in_array($me['scheme'], array('http','https'))) 482 | return false; 483 | 484 | // fragment not allowed 485 | if(array_key_exists('fragment', $me)) 486 | return false; 487 | 488 | return self::build_url($me); 489 | } 490 | 491 | public static function build_url($parsed_url) { 492 | $scheme = isset($parsed_url['scheme']) ? strtolower($parsed_url['scheme']) . '://' : ''; 493 | $host = isset($parsed_url['host']) ? strtolower($parsed_url['host']) : ''; 494 | $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; 495 | $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; 496 | $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; 497 | $pass = ($user || $pass) ? "$pass@" : ''; 498 | $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; 499 | $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; 500 | $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; 501 | return "$scheme$user$pass$host$port$path$query$fragment"; 502 | } 503 | 504 | public static function parseNonProfileScopes($scope) { 505 | $scopes = explode(' ', $scope); 506 | return array_filter(array_diff($scopes, ['profile','email'])); 507 | } 508 | 509 | /** 510 | * @param array $params 511 | * @param string $expected_state 512 | * @return IndieAuth\ErrorResponse if error, void (null) if valid 513 | */ 514 | public static function validateStateMatch($params, $expected_state = '') { 515 | if (!isset($params['state'])) { 516 | return new ErrorResponse('missing_state', 'The authorization server did not return the state parameter'); 517 | } 518 | 519 | if ($params['state'] !== $expected_state) { 520 | return new ErrorResponse('invalid_state', 'The authorization server returned an invalid state parameter'); 521 | } 522 | } 523 | 524 | /** 525 | * @param array $params 526 | * @param string $expected_issuer 527 | * @return IndieAuth\ErrorResponse if error, void (null) if valid 528 | */ 529 | public static function validateIssuerMatch($params, $expected_issuer = '') { 530 | if (!$expected_issuer) { 531 | return; 532 | } 533 | 534 | if (!isset($params['iss'])) { 535 | return new ErrorResponse('missing_iss', 'The authorization server did not return the iss parameter'); 536 | } 537 | 538 | if ($params['iss'] !== $expected_issuer) { 539 | return new ErrorResponse('invalid_iss', 'The authorization server returned an invalid iss parameter'); 540 | } 541 | } 542 | 543 | public static function exchangeAuthorizationCode($endpoint, $params) { 544 | $required = ['code', 'redirect_uri', 'client_id']; 545 | foreach($required as $r) { 546 | if(!isset($params[$r])) { 547 | throw new \Exception('Missing parameter to exchangeAuthorizationCode: '.$r); 548 | } 549 | } 550 | 551 | self::setUpHTTP(); 552 | 553 | $request = [ 554 | 'grant_type' => 'authorization_code', 555 | 'code' => $params['code'], 556 | 'redirect_uri' => $params['redirect_uri'], 557 | 'client_id' => $params['client_id'], 558 | ]; 559 | if(isset($params['code_verifier'])) { 560 | $request['code_verifier'] = $params['code_verifier']; 561 | } 562 | 563 | $response = self::$http->post($endpoint, http_build_query($request), [ 564 | 'Accept: application/json, application/x-www-form-urlencoded;q=0.8' 565 | ]); 566 | 567 | $data = json_decode($response['body'], true); 568 | if(!$data) { 569 | // Parse as form-encoded for legacy server support 570 | $data = array(); 571 | parse_str($response['body'], $data); 572 | } 573 | 574 | return [ 575 | 'response' => $data, 576 | 'raw_response' => $response['body'], 577 | 'response_code' => $response['code'], 578 | 'response_details' => $response, 579 | ]; 580 | } 581 | 582 | public static function representativeHCard($url) { 583 | $html = self::_fetchBody($url); 584 | $parsed = \Mf2\parse($html, $url); 585 | return \Mf2\HCard\representative($parsed, $url); 586 | } 587 | 588 | // Support legacy PHP random string generation methods 589 | private static function generateRandomString($numBytes) { 590 | if(function_exists('random_bytes')) { 591 | $bytes = random_bytes($numBytes); 592 | } elseif(function_exists('openssl_random_pseudo_bytes')){ 593 | $bytes = openssl_random_pseudo_bytes($numBytes); 594 | } else { 595 | $bytes = ''; 596 | for($i=0, $bytes=''; $i < $numBytes; $i++) { 597 | $bytes .= chr(mt_rand(0, 255)); 598 | } 599 | } 600 | return bin2hex($bytes); 601 | } 602 | 603 | // Optional helper method to generate a state parameter. You can just as easily do this yourself some other way. 604 | public static function generateStateParameter() { 605 | return self::generateRandomString(self:: $random_byte_count); 606 | } 607 | 608 | /** PKCE Helpers **/ 609 | 610 | public static function generatePKCECodeVerifier() { 611 | return self::generateRandomString(32); 612 | } 613 | 614 | private static function generatePKCECodeChallenge($plaintext) { 615 | return self::base64_urlencode(hash('sha256', $plaintext, true)); 616 | } 617 | 618 | private static function base64_urlencode($string) { 619 | return rtrim(strtr(base64_encode($string), '+/', '-_'), '='); 620 | } 621 | 622 | } 623 | 624 | -------------------------------------------------------------------------------- /src/IndieAuth/ErrorResponse.php: -------------------------------------------------------------------------------- 1 | code = $code; 14 | $this->description = $description; 15 | $this->debug = $debug; 16 | } 17 | 18 | /** 19 | * @return array 20 | */ 21 | public function getArray() 22 | { 23 | $response = [ 24 | 'error' => $this->code, 25 | 'error_description' => $this->description, 26 | ]; 27 | 28 | if ($this->debug) { 29 | $response['debug'] = $this->debug; 30 | } 31 | 32 | return [false, $response]; 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /tests/ClientTest.php: -------------------------------------------------------------------------------- 1 | getArray(); 22 | 23 | $this->assertIsArray($result); 24 | $this->assertCount(2, $result); 25 | 26 | if (isset($result[1])) { 27 | $error = $result[1]; 28 | $this->assertIsArray($error); 29 | $this->assertCount(3, $error); 30 | 31 | $this->assertArrayHasKey('error', $error); 32 | $this->assertArrayHasKey('error_description', $error); 33 | $this->assertArrayHasKey('debug', $error); 34 | 35 | $this->assertEquals('missing_state', $error['error']); 36 | $this->assertEquals('The state is missing', $error['error_description']); 37 | $this->assertEquals('debug information', $error['debug']); 38 | } 39 | } 40 | 41 | public function testValidateState() 42 | { 43 | $expected_state = 'example_state'; 44 | $params = ['state' => $expected_state]; 45 | $response = Client::validateStateMatch($params, $expected_state); 46 | $this->assertNull($response); 47 | } 48 | 49 | public function testValidateStateCase() 50 | { 51 | $params = ['state' => 'example_state']; 52 | $response = Client::validateStateMatch($params, 'Example_State'); 53 | $this->assertInstanceOf(ErrorResponse::class, $response); 54 | } 55 | 56 | public function testValidateStateMissing() 57 | { 58 | $params = []; 59 | $response = Client::validateStateMatch($params, 'state'); 60 | $this->assertInstanceOf(ErrorResponse::class, $response); 61 | } 62 | 63 | public function testValidateStateMismatch() 64 | { 65 | $params = ['state' => 'example_state']; 66 | $response = Client::validateStateMatch($params, 'unexpected_state'); 67 | $this->assertInstanceOf(ErrorResponse::class, $response); 68 | } 69 | 70 | public function testValidateIssuer() 71 | { 72 | $expected_issuer = 'https://issuer.example.com/'; 73 | $params = ['iss' => $expected_issuer]; 74 | $response = Client::validateIssuerMatch($params, $expected_issuer); 75 | $this->assertNull($response); 76 | } 77 | 78 | public function testValidateIssuerMissing() 79 | { 80 | $expected_issuer = 'https://issuer.example.com/'; 81 | $params = []; 82 | $response = Client::validateIssuerMatch($params, $expected_issuer); 83 | $this->assertInstanceOf(ErrorResponse::class, $response); 84 | } 85 | 86 | public function testValidateIssuerMismatch() 87 | { 88 | $params = ['iss' => 'https://issuer.example.com/']; 89 | $response = Client::validateIssuerMatch($params, 'https://example.org/'); 90 | $this->assertInstanceOf(ErrorResponse::class, $response); 91 | } 92 | 93 | } 94 | 95 | -------------------------------------------------------------------------------- /tests/DiscoveryTest.php: -------------------------------------------------------------------------------- 1 |

Hello World

'; 7 | $result = $this->_invokeStaticMethod(IndieAuth\Client::class, 8 | '_extractEndpointFromHTML', [$html, 'https://example.com/foo', 'micropub']); 9 | $this->assertEquals('https://example.com/micropub', $result); 10 | } 11 | 12 | public function testExtractRelativeEndpointFromHTML() { 13 | $html = '

Hello World

'; 14 | $result = $this->_invokeStaticMethod(IndieAuth\Client::class, 15 | '_extractEndpointFromHTML', [$html, 'https://example.com/foo/', 'micropub']); 16 | $this->assertEquals('https://example.com/foo/micropub', $result); 17 | } 18 | 19 | public function testExtractEmptyStringEndpointFromHTML() { 20 | $html = '

Hello World

'; 21 | $result = $this->_invokeStaticMethod(IndieAuth\Client::class, 22 | '_extractEndpointFromHTML', [$html, 'https://example.com/micropub', 'micropub']); 23 | $this->assertEquals('https://example.com/micropub', $result); 24 | } 25 | 26 | public function testExtractEndpointFromHeaders() { 27 | $headers = 'HTTP/1.1 200 Ok 28 | Content-Type: text/html; charset=UTF-8 29 | Cache-Control: no-cache 30 | Link: ; rel="hub" 31 | Link: ; rel="authorization_endpoint" 32 | Link: ; rel="micropub" 33 | Link: ; rel="token_endpoint"'; 34 | $result = $this->_invokeStaticMethod(IndieAuth\Client::class, 35 | '_extractEndpointFromHeaders', [$headers, 'https://example.com/foo', 'micropub']); 36 | $this->assertEquals('https://example.com/micropub', $result); 37 | } 38 | 39 | public function testExtractRelativeEndpointFromHeaders() { 40 | $headers = 'HTTP/1.1 200 Ok 41 | Content-Type: text/html; charset=UTF-8 42 | Cache-Control: no-cache 43 | Link: ; rel="hub" 44 | Link: ; rel="authorization_endpoint" 45 | Link: ; rel="micropub" 46 | Link: ; rel="token_endpoint"'; 47 | $result = $this->_invokeStaticMethod(IndieAuth\Client::class, 48 | '_extractEndpointFromHeaders', [$headers, 'https://example.com/foo/', 'micropub']); 49 | $this->assertEquals('https://example.com/foo/micropub', $result); 50 | } 51 | 52 | public function testExtractEmptyStringEndpointFromHeaders() { 53 | $headers = 'HTTP/1.1 200 Ok 54 | Content-Type: text/html; charset=UTF-8 55 | Cache-Control: no-cache 56 | Link: ; rel="hub" 57 | Link: <>; rel="authorization_endpoint" 58 | Link: <>; rel="micropub" 59 | Link: <>; rel="token_endpoint"'; 60 | $result = $this->_invokeStaticMethod(IndieAuth\Client::class, 61 | '_extractEndpointFromHeaders', [$headers, 'https://example.com/micropub', 'micropub']); 62 | $this->assertEquals('https://example.com/micropub', $result); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /tests/MetadataTest.php: -------------------------------------------------------------------------------- 1 | default_metadata); 12 | $metadata = Client::getMetadata(); 13 | 14 | $this->assertIsArray($metadata); 15 | $this->assertArrayHasKey('issuer', $metadata); 16 | $this->assertArrayHasKey('authorization_endpoint', $metadata); 17 | $this->assertArrayHasKey('token_endpoint', $metadata); 18 | $this->assertArrayHasKey('revocation_endpoint', $metadata); 19 | $this->assertArrayHasKey('introspection_endpoint', $metadata); 20 | } 21 | 22 | public function testSetMetadataInvalid() { 23 | # malfored JSON 24 | Client::setMetadata('https://example.com/', '{"issuer":"https://example.com/'); 25 | $metadata = Client::getMetadata(); 26 | $this->assertNull($metadata); 27 | 28 | # other content like HTML 29 | Client::setMetadata('https://example.com/', '

invalid metdata

'); 30 | $metadata = Client::getMetadata(); 31 | $this->assertNull($metadata); 32 | } 33 | 34 | public function testDiscoverFromMetadata() { 35 | Client::setMetadata('https://example.com/', $this->default_metadata); 36 | 37 | $result = $this->_invokeStaticMethod( 38 | Client::class, 39 | '_discoverFromMetadata', 40 | ['issuer'] 41 | ); 42 | 43 | $this->assertEquals('https://example.com/', $result); 44 | 45 | $result = $this->_invokeStaticMethod( 46 | Client::class, 47 | '_discoverFromMetadata', 48 | ['authorization_endpoint'] 49 | ); 50 | 51 | $this->assertEquals($result, 'https://example.com/authorization-endpoint'); 52 | 53 | $result = $this->_invokeStaticMethod( 54 | Client::class, 55 | '_discoverFromMetadata', 56 | ['token_endpoint'] 57 | ); 58 | 59 | $this->assertEquals('https://example.com/token-endpoint', $result); 60 | 61 | $result = $this->_invokeStaticMethod( 62 | Client::class, 63 | '_discoverFromMetadata', 64 | ['revocation_endpoint'] 65 | ); 66 | 67 | $this->assertEquals('https://example.com/revocation-endpoint', $result); 68 | 69 | $result = $this->_invokeStaticMethod( 70 | Client::class, 71 | '_discoverFromMetadata', 72 | ['introspection_endpoint'] 73 | ); 74 | 75 | $this->assertEquals('https://example.com/introspection-endpoint', $result); 76 | 77 | $result = $this->_invokeStaticMethod( 78 | Client::class, 79 | '_discoverFromMetadata', 80 | ['userinfo_endpoint'] 81 | ); 82 | 83 | $this->assertEquals('https://example.com/userinfo-endpoint', $result); 84 | } 85 | 86 | public function testIsIssuerValid() { 87 | # scheme must be https 88 | $result = $this->_invokeStaticMethod( 89 | Client::class, 90 | '_isIssuerValid', 91 | ['http://example.com/', 'https://example.com/indieauth-metadata-endpoint'] 92 | ); 93 | 94 | $this->assertFalse($result); 95 | 96 | # no query string allowed 97 | $result = $this->_invokeStaticMethod( 98 | Client::class, 99 | '_isIssuerValid', 100 | ['https://example.com/?foo=bar', 'https://example.com/indieauth-metadata-endpoint'] 101 | ); 102 | 103 | $this->assertFalse($result); 104 | 105 | # no fragment allowed 106 | $result = $this->_invokeStaticMethod( 107 | Client::class, 108 | '_isIssuerValid', 109 | ['https://example.com/#issuer', 'https://example.com/indieauth-metadata-endpoint'] 110 | ); 111 | 112 | $this->assertFalse($result); 113 | 114 | # issuer must be prefix of metadata endpoint 115 | $result = $this->_invokeStaticMethod( 116 | Client::class, 117 | '_isIssuerValid', 118 | ['https://example.com/foo', 'https://example.com/indieauth-metadata-endpoint'] 119 | ); 120 | 121 | $this->assertFalse($result); 122 | 123 | # valid issuer 124 | $result = $this->_invokeStaticMethod( 125 | Client::class, 126 | '_isIssuerValid', 127 | ['https://example.com/', 'https://example.com/indieauth-metadata-endpoint'] 128 | ); 129 | 130 | $this->assertTrue($result); 131 | } 132 | 133 | public function testDiscoverIssuer() 134 | { 135 | Client::setMetadata('https://example.com/', $this->default_metadata); 136 | 137 | $result = $this->_invokeStaticMethod( 138 | Client::class, 139 | 'discoverIssuer', 140 | ['https://example.com/indieauth-metadata-endpoint'] 141 | ); 142 | 143 | $this->assertEquals('https://example.com/', $result); 144 | } 145 | 146 | /** 147 | * `issuer` must be provided in indieauth-metadata 148 | */ 149 | public function testDiscoverIssuerMissing() 150 | { 151 | Client::setMetadata('https://example.com/', '{"authorization_endpoint":"https://example.com/authorization-endpoint"}'); 152 | $metadata_endpoint = 'https://example.com/indieauth-metadata-endpoint'; 153 | 154 | $result = $this->_invokeStaticMethod( 155 | Client::class, 156 | 'discoverIssuer', 157 | [$metadata_endpoint] 158 | ); 159 | $this->assertInstanceOf(ErrorResponse::class, $result); 160 | } 161 | 162 | /** 163 | * `issuer` must be a prefix of the metadata endpoint 164 | */ 165 | public function testDiscoverIssuerNotAPrefix() 166 | { 167 | Client::setMetadata('https://example.org/', $this->default_metadata); 168 | $metadata_endpoint = 'https://example.org/indieauth-metadata-endpoint'; 169 | 170 | $result = $this->_invokeStaticMethod( 171 | Client::class, 172 | 'discoverIssuer', 173 | [$metadata_endpoint] 174 | ); 175 | $this->assertInstanceOf(ErrorResponse::class, $result); 176 | } 177 | 178 | public function testDiscoverRevocationEndpoint() { 179 | Client::setMetadata('https://example.com/', $this->default_metadata); 180 | 181 | $result = $this->_invokeStaticMethod( 182 | Client::class, 183 | 'discoverRevocationEndpoint', 184 | ['https://example.com/'] 185 | ); 186 | 187 | $this->assertEquals('https://example.com/revocation-endpoint', $result); 188 | } 189 | 190 | public function testDiscoverIntrospectionEndpoint() { 191 | Client::setMetadata('https://example.com/', $this->default_metadata); 192 | 193 | $result = $this->_invokeStaticMethod( 194 | Client::class, 195 | 'discoverIntrospectionEndpoint', 196 | ['https://example.com/'] 197 | ); 198 | 199 | $this->assertEquals('https://example.com/introspection-endpoint', $result); 200 | } 201 | 202 | public function testDiscoverUserinfoEndpoint() { 203 | Client::setMetadata('https://example.com/', $this->default_metadata); 204 | 205 | $result = $this->_invokeStaticMethod( 206 | Client::class, 207 | 'discoverUserinfoEndpoint', 208 | ['https://example.com/'] 209 | ); 210 | 211 | $this->assertEquals('https://example.com/userinfo-endpoint', $result); 212 | } 213 | 214 | } 215 | -------------------------------------------------------------------------------- /tests/NormalizeTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('http://aaronpk.com/', $normalized); 9 | } 10 | 11 | public function testNoSchemeWithPath() { 12 | $url = 'aaronpk.com/me'; 13 | $normalized = IndieAuth\Client::normalizeMeURL($url); 14 | $this->assertEquals('http://aaronpk.com/me', $normalized); 15 | } 16 | 17 | public function testNoSlash() { 18 | $url = 'https://aaronpk.com'; 19 | $normalized = IndieAuth\Client::normalizeMeURL($url); 20 | $this->assertEquals('https://aaronpk.com/', $normalized); 21 | } 22 | 23 | public function testRejectsInvalidScheme() { 24 | $url = 'mailto:me@example.com'; 25 | $normalized = IndieAuth\Client::normalizeMeURL($url); 26 | $this->assertEquals(false, $normalized); 27 | } 28 | 29 | public function testAllowsQueryString() { 30 | $url = 'https://aaronpk.com?foo'; 31 | $normalized = IndieAuth\Client::normalizeMeURL($url); 32 | $this->assertEquals('https://aaronpk.com/?foo', $normalized); 33 | } 34 | 35 | public function testRejectsFragment() { 36 | $url = 'https://aaronpk.com/#me'; 37 | $normalized = IndieAuth\Client::normalizeMeURL($url); 38 | $this->assertEquals(false, $normalized); 39 | } 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /tests/ScopeTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(is_array($scopes)); 8 | $this->assertContains('create', $scopes); 9 | $this->assertContains('update', $scopes); 10 | $this->assertNotContains('profile', $scopes); 11 | $this->assertNotContains('email', $scopes); 12 | } 13 | 14 | public function testWorksWithEmptyScope() { 15 | $scopes = IndieAuth\Client::parseNonProfileScopes(''); 16 | $this->assertTrue(is_array($scopes)); 17 | $this->assertNotContains('profile', $scopes); 18 | $this->assertNotContains('email', $scopes); 19 | } 20 | 21 | public function testAcceptsFalseInput() { 22 | $scopes = IndieAuth\Client::parseNonProfileScopes(false); 23 | $this->assertTrue(is_array($scopes)); 24 | $this->assertNotContains('profile', $scopes); 25 | $this->assertNotContains('email', $scopes); 26 | } 27 | 28 | public function testExcludesOneScope() { 29 | $scopes = IndieAuth\Client::parseNonProfileScopes('profile'); 30 | $this->assertTrue(is_array($scopes)); 31 | $this->assertNotContains('profile', $scopes); 32 | } 33 | 34 | public function testIncludesOneScope() { 35 | $scopes = IndieAuth\Client::parseNonProfileScopes('create'); 36 | $this->assertTrue(is_array($scopes)); 37 | $this->assertContains('create', $scopes); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | getMethod($methodName); 12 | $method->setAccessible(true); 13 | return $method->invokeArgs($object, $params); 14 | } 15 | 16 | protected function _invokeStaticMethod($class, $methodName, $params=[]) { 17 | $reflection = new \ReflectionClass($class); 18 | $method = $reflection->getMethod($methodName); 19 | $method->setAccessible(true); 20 | return $method->invokeArgs(null, $params); 21 | } 22 | 23 | } 24 | --------------------------------------------------------------------------------