File tree 4 files changed +51
-1
lines changed
4 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 29
29
"@types/express" : " ^4.17.8" ,
30
30
"@types/jest" : " ^26.0.15" ,
31
31
"@types/node" : " ^14.14.5" ,
32
+ "@types/oauth" : " ^0.9.1" ,
32
33
"@types/sinon" : " ^9.0.8" ,
33
34
"@typescript-eslint/eslint-plugin" : " ^4.6.0" ,
34
35
"@typescript-eslint/parser" : " ^4.6.0" ,
44
45
},
45
46
"dependencies" : {
46
47
"atlassian-jwt" : " ^1.0.3" ,
47
- "axios" : " ^0.21.0"
48
+ "axios" : " ^0.21.0" ,
49
+ "oauth" : " ^0.9.15" ,
50
+ "qs" : " ^6.9.4"
48
51
}
49
52
}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export namespace Config {
17
17
jwt ?: Authentication . JWT ;
18
18
accessToken ?: Authentication . AccessToken ;
19
19
basic ?: Authentication . Basic ;
20
+ oauth1 ?: Authentication . OAuth1 ;
20
21
}
21
22
22
23
export interface Middlewares {
@@ -42,6 +43,13 @@ export namespace Config {
42
43
password ?: string ;
43
44
} ;
44
45
46
+ export type OAuth1 = {
47
+ consumerKey : string ;
48
+ consumerSecret : string ;
49
+ accessToken : string ;
50
+ tokenSecret : string ;
51
+ } ;
52
+
45
53
export type AccessToken = string ;
46
54
}
47
55
}
Original file line number Diff line number Diff line change 1
1
import { AxiosRequestConfig } from 'axios' ;
2
2
import * as jwt from 'atlassian-jwt' ;
3
3
import * as url from 'url' ;
4
+ import { OAuth } from 'oauth' ;
5
+ import * as qs from 'qs' ;
4
6
import { Config } from '../config' ;
5
7
6
8
export const getAuthentication = (
@@ -30,6 +32,26 @@ export const getAuthentication = (
30
32
return `JWT ${ jwtToken } ` ;
31
33
}
32
34
35
+ if ( config . authentication ?. oauth1 ) {
36
+ const oauthUrl = `${ config . host } /plugins/servlet/oauth/` ;
37
+ const oauth = new OAuth (
38
+ `${ oauthUrl } request-token` ,
39
+ `${ oauthUrl } access-token` ,
40
+ config . authentication . oauth1 . consumerKey ,
41
+ config . authentication . oauth1 . consumerSecret ,
42
+ '1.0' ,
43
+ null ,
44
+ 'RSA-SHA1' ,
45
+ ) ;
46
+
47
+ return oauth . authHeader (
48
+ `${ config . host + request . url ! } ?${ qs . stringify ( request . params ) } ` ,
49
+ config . authentication . oauth1 . accessToken ,
50
+ config . authentication . oauth1 . tokenSecret ,
51
+ request . method ! ,
52
+ ) ;
53
+ }
54
+
33
55
if ( config . authentication ?. accessToken ) {
34
56
return `Bearer ${ config . authentication . accessToken } ` ;
35
57
}
Original file line number Diff line number Diff line change 667
667
resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz"
668
668
integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==
669
669
670
+ " @types/oauth@^0.9.1 " :
671
+ version "0.9.1"
672
+ resolved "https://registry.yarnpkg.com/@types/oauth/-/oauth-0.9.1.tgz#e17221e7f7936b0459ae7d006255dff61adca305"
673
+ integrity sha512-a1iY62/a3yhZ7qH7cNUsxoI3U/0Fe9+RnuFrpTKr+0WVOzbKlSLojShCKe20aOD1Sppv+i8Zlq0pLDuTJnwS4A==
674
+ dependencies :
675
+ " @types/node" " *"
676
+
670
677
" @types/prettier@^2.0.0 " :
671
678
version "2.1.1"
672
679
resolved "https://registry.npmjs.org/@types/prettier/-/prettier-2.1.1.tgz"
@@ -3460,6 +3467,11 @@ oauth-sign@~0.9.0:
3460
3467
resolved "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz"
3461
3468
integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==
3462
3469
3470
+ oauth@^0.9.15 :
3471
+ version "0.9.15"
3472
+ resolved "https://registry.yarnpkg.com/oauth/-/oauth-0.9.15.tgz#bd1fefaf686c96b75475aed5196412ff60cfb9c1"
3473
+ integrity sha1-vR/vr2hslrdUda7VGWQS/2DPucE=
3474
+
3463
3475
object-copy@^0.1.0 :
3464
3476
version "0.1.0"
3465
3477
resolved "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz"
@@ -3783,6 +3795,11 @@ punycode@^2.1.0, punycode@^2.1.1:
3783
3795
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz"
3784
3796
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
3785
3797
3798
+ qs@^6.9.4 :
3799
+ version "6.9.4"
3800
+ resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.4.tgz#9090b290d1f91728d3c22e54843ca44aea5ab687"
3801
+ integrity sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==
3802
+
3786
3803
qs@~6.5.2 :
3787
3804
version "6.5.2"
3788
3805
resolved "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz"
You can’t perform that action at this time.
0 commit comments