Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit c93f372

Browse files
Add support for user credentials/jwt
1 parent c38acc7 commit c93f372

27 files changed

+3960
-2835
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
env.sh
44
.nyc_output
55
coverage
6+
.tern-port

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ Wrapper library for Topcoder Submission API
1414

1515
```javascript
1616
const submissionApi = require('topcoder-submission-api-wrapper')
17-
const submissionApiClient = submissionApi(_.pick(config,
17+
const submissionApiM2MClient = submissionApi(_.pick(config,
1818
['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME',
1919
'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'SUBMISSION_API_URL',
2020
'AUTH0_PROXY_SERVER_URL']))
2121
```
2222

23-
**Configuration / Environment variables:**
24-
23+
**M2M Authentication Configuration:**
2524
- AUTH0_URL - the auth0 url
2625
- AUTH0_AUDIENCE - the auth0 audience
2726
- TOKEN_CACHE_TIME - (optional) the token cache time
@@ -33,6 +32,29 @@ Wrapper library for Topcoder Submission API
3332
- PER_PAGE - the page size
3433
- MAX_PAGE_SIZE - the max number of page size
3534

35+
```javascript
36+
const submissionApiUserCredentialsClient = submissionApi(_.pick(config,
37+
['USERNAME', 'PASSWORD', 'TC_AUTHN_URL', 'TC_AUTHZ_URL', 'TC_CLIENT_ID',
38+
'TC_CLIENT_V2CONNECTION', 'SUBMISSION_API_URL']))
39+
```
40+
41+
**User Credentials Authentication Configuration:**
42+
- USERNAME - Topcoder handle
43+
- PASSWORD - Topcoder password
44+
- TC_AUTHN_URL - OAUTH2 token URL, e.g. `https://topcoder.auth0.com/oauth/ro` or for dev `https://topcoder-dev.auth0.com/oauth/ro`
45+
- TC_AUTHZ_URL - Topcoder API token URL, e.g. `https://api.topcoder.com/v3/authorizations` or for dev `https://api.topcoder-dev.com/v3/authorizations`
46+
- TC_CLIENT_ID - OAUTH2 Client ID, e.g. `6ZwZEUo2ZK4c50aLPpgupeg5v2Ffxp9P` or for dev `JFDo7HMkf0q2CkVFHojy3zHWafziprhT`
47+
- TC_CLIENT_V2CONNECTION - The OAUTH2 Client data source, e.g. `TC-User-Database`
48+
- SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. `https://api.topcoder.com/v5` or for dev `https://api.topcoder-dev.com/v5`
49+
50+
```javascript
51+
const submissionJwtMethodArgClient = submissionApi(_.pick(config,
52+
['SUBMISSION_API_URL']))
53+
```
54+
55+
**JWT Method Argument Authentication Configuration:**
56+
- SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. `https://api.topcoder.com/v5` or for dev `https://api.topcoder-dev.com/v5`
57+
3658
3. Every function in this wrapper will return a promise, Handling promises is at the caller end. Call the functions with appropriate arguments
3759

3860
E.g.
@@ -126,6 +148,13 @@ Following environment variables need to be set up before running the tests
126148
- TEST_AUTH0_CLIENT_ID
127149
- TEST_AUTH0_CLIENT_SECRET
128150
- TEST_SUBMISSION_API_URL
151+
- TEST_JWT
152+
- TEST_USERNAME
153+
- TEST_PASSWORD
154+
- TEST_TC_AUTHN_URL
155+
- TEST_TC_AUTHZ_URL
156+
- TEST_TC_CLIENT_ID
157+
- TEST_TC_CLIENT_V2CONNECTION
129158
```
130159

131160
Refer to Step # 2 in [this section](#how-to-use-this-wrapper) to learn more about the configuration variables.

Verification.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88

99
## Test Coverage Report
1010

11-
226 passing (5m)
11+
668 passing
1212

13-
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
14-
--------------------------------------------|----------|----------|----------|----------|-------------------
15-
All files | 99.42 | 90 | 100 | 99.42 |
16-
topcoder-submission-api-wrapper | 100 | 100 | 100 | 100 |
17-
index.js | 100 | 100 | 100 | 100 |
18-
topcoder-submission-api-wrapper/src | 100 | 100 | 100 | 100 |
19-
ReviewSummationsApi.js | 100 | 100 | 100 | 100 |
20-
ReviewTypesApi.js | 100 | 100 | 100 | 100 |
21-
ReviewsApi.js | 100 | 100 | 100 | 100 |
22-
SubmissionsApi.js | 100 | 100 | 100 | 100 |
23-
topcoder-submission-api-wrapper/src/common | 97.56 | 88.89 | 100 | 97.56 |
24-
helper.js | 97.56 | 88.89 | 100 | 97.56 | 63
13+
14+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
15+
--------------------------------------------|----------|----------|----------|----------|-------------------|
16+
All files | 99.5 | 95.52 | 100 | 99.5 | |
17+
topcoder-submission-api-wrapper | 100 | 100 | 100 | 100 | |
18+
index.js | 100 | 100 | 100 | 100 | |
19+
topcoder-submission-api-wrapper/src | 100 | 100 | 100 | 100 | |
20+
ReviewSummationsApi.js | 100 | 100 | 100 | 100 | |
21+
ReviewTypesApi.js | 100 | 100 | 100 | 100 | |
22+
ReviewsApi.js | 100 | 100 | 100 | 100 | |
23+
SubmissionsApi.js | 100 | 100 | 100 | 100 | |
24+
topcoder-submission-api-wrapper/src/common | 98.25 | 88 | 100 | 98.25 | |
25+
constants.js | 100 | 100 | 100 | 100 | |
26+
helper.js | 98.21 | 88 | 100 | 98.21 | 134 |

0 commit comments

Comments
 (0)