Skip to content

Commit c912b0c

Browse files
author
Artem Shteltser
committed
Clear changes
1 parent 1371418 commit c912b0c

File tree

10 files changed

+7787
-40816
lines changed

10 files changed

+7787
-40816
lines changed

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ docs
33
lib
44

55
# Dependency directories
6-
node_modules
7-
src/authentication/**/*
6+
node_modules

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ via **yarn**:
2828
$ yarn add bitbucket
2929
```
3030

31+
## Authentication
32+
33+
Bitbucket supports different authentication strategies:
34+
35+
- OAuth 2
36+
- App passwords
37+
- Basic auth
38+
39+
### Basic auth
40+
41+
```javascript
42+
const { Bitbucket } = require('bitbucket')
43+
44+
const bitbucket = new Bitbucket({
45+
auth: '',
46+
})
47+
```
48+
3149
## Usage
3250

3351
### Browser

package-lock.json

Lines changed: 0 additions & 28593 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
"rest"
1111
],
1212
"homepage": "https://github.com/MunifTanjim/node-bitbucket#readme",
13-
"bugs": {
14-
"url": "https://github.com/MunifTanjim/node-bitbucket/issues"
15-
},
13+
"bugs": "https://github.com/MunifTanjim/node-bitbucket/issues",
1614
"license": "MIT",
1715
"author": "MunifTanjim (https://muniftanjim.com)",
1816
"files": [
@@ -24,17 +22,14 @@
2422
"unpkg": "lib/index.umd.js",
2523
"jsdelivr": "lib/index.umd.js",
2624
"types": "lib/index.d.ts",
27-
"repository": {
28-
"type": "git",
29-
"url": "git+https://github.com/MunifTanjim/node-bitbucket.git"
30-
},
25+
"repository": "github:MunifTanjim/node-bitbucket",
3126
"scripts": {
32-
"build": "npm-run-all -s build:core",
27+
"build": "npm-run-all -s build:core build:plugins",
3328
"prebuild:core": "rimraf lib/*.js lib/*.js.map",
3429
"build:core": "bili",
3530
"prebuild:plugins": "rimraf lib/plugins/*.js lib/plugins/*.js.map",
3631
"build:plugins": "npm-run-all -s build:plugin:*",
37-
"build:plugin:authenticate": "PLUGIN=authenticate bili",
32+
"build:plugin:authenticate": "cross-env PLUGIN=auth bili",
3833
"predocs:build": "mkdirp docs && rimraf docs/*",
3934
"docs:build": "npm run generate:api-docs",
4035
"postdocs:build": "apidoc -i docs -o docs",
@@ -54,7 +49,6 @@
5449
"validate:types:index": "tsc --noEmit lib/index.d.ts",
5550
"validate:types:minimal": "tsc --noEmit lib/minimal.d.ts",
5651
"validate:types:plugin:authenticate": "tsc --noEmit lib/plugins/authenticate.d.ts",
57-
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json}\"",
5852
"test": "jest"
5953
},
6054
"dependencies": {
@@ -77,14 +71,15 @@
7771
"apidoc": "0.17.5",
7872
"bili": "^4.10.0",
7973
"clean-deep": "^3.3.0",
74+
"cross-env": "^7.0.3",
8075
"deep-sort-object": "^1.0.2",
8176
"eslint": "^6.8.0",
8277
"eslint-config-prettier": "^6.10.0",
8378
"eslint-config-standard-with-typescript": "^15.0.1",
8479
"eslint-plugin-import": "^2.20.1",
8580
"eslint-plugin-jest": "^23.8.2",
8681
"eslint-plugin-node": "^11.0.0",
87-
"eslint-plugin-prettier": "^3.3.1",
82+
"eslint-plugin-prettier": "^3.1.2",
8883
"eslint-plugin-promise": "^4.2.1",
8984
"eslint-plugin-standard": "^4.0.1",
9085
"husky": "^4.2.5",
@@ -95,15 +90,12 @@
9590
"mkdirp": "^1.0.4",
9691
"mustache": "^4.0.1",
9792
"npm-run-all": "^4.1.5",
98-
"prettier": "^2.2.1",
93+
"prettier": "^2.0.5",
9994
"pretty-quick": "^2.0.1",
10095
"rimraf": "^3.0.2",
10196
"rollup-plugin-typescript2": "^0.27.1",
10297
"ts-jest": "^26.0.0",
10398
"ts-node": "^8.10.1",
10499
"typescript": "^3.8.3"
105-
},
106-
"directories": {
107-
"test": "test"
108100
}
109101
}

src/plugins/auth/basicAuth/auth.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import btoa from 'btoa-lite'
33
type AuthOptions = import('./types').AuthOptions
44
type Authentication = import('./types').Authentication
55

6-
// eslint-disable-next-line @typescript-eslint/require-await
76
export function auth(authState: AuthOptions): Authentication {
87
if (authState.type === 'token') {
98
return {

src/plugins/auth/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ const routes = getOAuthRoutes(oAuth2Spec)
1010
function authenticatePlugin(client: APIClient, clientOptions: Options): void {
1111
client.registerEndpoints({ oauth: routes.getToken })
1212

13+
// (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance
14+
// is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered.
15+
// (2) If only `options.auth` is set, use the default token authentication strategy.
16+
// (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance.
17+
1318
if (!clientOptions.auth) return
1419
switch (clientOptions.authStrategy) {
1520
case 'OAuth':

test/index.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)