docs: add README and LICENSE
This commit is contained in:
Родитель
5eacd37cd3
Коммит
b8028131d1
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Contributors to the Electron project
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,55 @@
|
|||
# @electron/github-app-auth
|
||||
|
||||
> Gets an auth token for a repo via a GitHub app installation
|
||||
|
||||
[![CircleCI](https://circleci.com/gh/electron/github-app-auth.svg?style=svg)](https://circleci.com/gh/electron/github-app-auth)
|
||||
|
||||
## Usage
|
||||
|
||||
### Generating Credentials
|
||||
|
||||
In order to simply credential management `@electron/github-app-auth` contains
|
||||
a CLI tool to generate a "credential bundle" that contains the requisite
|
||||
information to generate tokens. You need both a private key for your
|
||||
application and the application ID.
|
||||
|
||||
```bash
|
||||
npx @electron/github-app-auth --creds=my-private.key.pem --app-id=12345
|
||||
```
|
||||
|
||||
This command will output a base64 encoded blob which you should store in your
|
||||
services secret storage (normally accessed via an environment variable). Below
|
||||
we will use `MY_GITHUB_APP_CREDS` as the environment variable.
|
||||
|
||||
### With `@octokit/rest`
|
||||
|
||||
```typescript
|
||||
import { appCredentialsFromString, getAuthOptionsForRepo } from '@electron/github-app-auth';
|
||||
import { Octokit } from '@octokit/rest';
|
||||
|
||||
const creds = appCredentialsFromString(process.env.MY_GITHUB_APP_CREDS);
|
||||
const authOpts = await getAuthOptionsForRepo({
|
||||
owner: 'electron',
|
||||
name: 'electron'
|
||||
}, creds)
|
||||
const octo = new Octokit({
|
||||
...authOpts,
|
||||
});
|
||||
|
||||
// octo is now a valid octokit instance
|
||||
```
|
||||
|
||||
### With raw tokens
|
||||
|
||||
```typescript
|
||||
import { appCredentialsFromString, getTokenForRepo } from '@electron/github-app-auth';
|
||||
import { Octokit } from '@octokit/rest';
|
||||
|
||||
const creds = appCredentialsFromString(process.env.MY_GITHUB_APP_CREDS);
|
||||
const token = await getTokenForRepo({
|
||||
owner: 'electron',
|
||||
name: 'electron'
|
||||
}, creds)
|
||||
|
||||
// token is now a valid github auth token
|
||||
```
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "tsc",
|
||||
"test": "exit 0"
|
||||
"test": "yarn tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@continuous-auth/semantic-release-npm": "^2.0.0",
|
||||
|
|
Загрузка…
Ссылка в новой задаче