-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating the project tests and dependencies. Adding a deployment to C…
…odeArtifact.
- Loading branch information
Showing
8 changed files
with
6,169 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
tests: | ||
runs-on: [self-hosted, Linux, AWS] | ||
timeout-minutes: 5 | ||
steps: | ||
- name: Checkout code | ||
uses: Brightspace/third-party-actions@actions/checkout | ||
|
||
- name: Setup node | ||
uses: Brightspace/third-party-actions@actions/setup-node | ||
with: | ||
node-version-file: .nvmrc | ||
cache: npm | ||
|
||
- name: Add CodeArtifact npm registry | ||
uses: Brightspace/codeartifact-actions/npm/add-registry@main | ||
with: | ||
auth-token: ${{secrets.CODEARTIFACT_AUTH_TOKEN}} | ||
|
||
- name: Install node modules | ||
run: npm ci | ||
|
||
- name: Lint and license check | ||
run: | | ||
npm run lint | ||
npm run test:license | ||
- name: Run Tests | ||
run: npm run test | ||
release: | ||
runs-on: [ self-hosted, Linux, AWS ] | ||
timeout-minutes: 10 | ||
if: github.ref == 'refs/heads/master' | ||
needs: tests | ||
steps: | ||
- name: Checkout code | ||
uses: Brightspace/third-party-actions@actions/checkout | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Setup node | ||
uses: Brightspace/third-party-actions@actions/setup-node | ||
with: | ||
node-version-file: .nvmrc | ||
cache: npm | ||
|
||
- name: Add CodeArtifact npm registry | ||
uses: Brightspace/codeartifact-actions/npm/add-registry@main | ||
with: | ||
auth-token: ${{secrets.CODEARTIFACT_AUTH_TOKEN}} | ||
|
||
- name: Install node modules | ||
run: npm ci | ||
|
||
- name: Lint, License Check and Generate Types | ||
run: | | ||
npm run lint | ||
npm run test:license | ||
- name: Get CodeArtifact Authorization Token | ||
uses: Brightspace/codeartifact-actions/get-authorization-token@main | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} | ||
|
||
- name: Semantic Release | ||
uses: BrightspaceUI/actions/semantic-release@main | ||
with: | ||
DEFAULT_BRANCH: master | ||
GITHUB_TOKEN: ${{ secrets.D2L_GITHUB_TOKEN }} | ||
NPM: true | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,76 @@ | ||
'use strict'; | ||
|
||
const oauthSignature = require('oauth-signature'); | ||
const CryptoJS = require('crypto-js'); | ||
const sha1 = require('crypto-js/sha1'); | ||
const url = require('url'); | ||
const uuid = require('uuid'); | ||
|
||
module.exports = function(request) { | ||
request.sign = function(creds) { | ||
this.toSign = true; | ||
this.consumerKey = creds.consumerKey; | ||
this.consumerSecret = creds.consumerSecret; | ||
return this; | ||
}; | ||
|
||
request.hashBody = function() { | ||
this.toHashBody = true; | ||
return this; | ||
}; | ||
|
||
request.signOAuth = function() { | ||
const oauthHeader = { | ||
oauth_version: '1.0', | ||
oauth_nonce: uuid.v4(), | ||
oauth_timestamp: Math.floor(Date.now() / 1000), | ||
oauth_consumer_key: this.consumerKey, | ||
oauth_signature_method: 'HMAC-SHA1' | ||
}; | ||
|
||
if (this.toHashBody) { | ||
const stringifiedBody = (typeof this._data !== 'string') ? | ||
JSON.stringify(this._data) : this._data; | ||
|
||
oauthHeader.oauth_body_hash = sha1(stringifiedBody).toString(CryptoJS.enc.Base64); | ||
} | ||
|
||
const oauthParams = {}; | ||
const queryParams = url.parse(this.url, true).query; | ||
for (const attrname of Object.keys(queryParams)) { | ||
oauthParams[attrname] = queryParams[attrname]; | ||
} | ||
for (const attrname of Object.keys(oauthHeader)) { | ||
oauthParams[attrname] = oauthHeader[attrname]; | ||
} | ||
|
||
oauthHeader.oauth_signature = oauthSignature.generate( | ||
this.method, | ||
this.url, | ||
oauthParams, | ||
this.consumerSecret, | ||
'', | ||
{ | ||
encodeSignature: false | ||
}); | ||
|
||
const headerArray = []; | ||
for (const key of Object.keys(oauthHeader)) { | ||
headerArray.push(`${key}="${encodeURIComponent(oauthHeader[key])}"`); | ||
} | ||
|
||
this.set('Authorization', `OAuth ${headerArray.join(',')}`); | ||
}; | ||
|
||
const oldEnd = request.end; | ||
|
||
request.end = function() { | ||
this.end = oldEnd; | ||
|
||
if (this.toSign) { | ||
this.signOAuth(); | ||
} | ||
|
||
return this.end.apply(this, arguments); | ||
}; | ||
}; | ||
'use strict'; | ||
|
||
const oauthSignature = require('oauth-signature'); | ||
const CryptoJS = require('crypto-js'); | ||
const sha1 = require('crypto-js/sha1'); | ||
const url = require('url'); | ||
const uuid = require('uuid'); | ||
|
||
module.exports = function(request) { | ||
request.sign = function(creds) { | ||
this.toSign = true; | ||
this.consumerKey = creds.consumerKey; | ||
this.consumerSecret = creds.consumerSecret; | ||
return this; | ||
}; | ||
|
||
request.hashBody = function() { | ||
this.toHashBody = true; | ||
return this; | ||
}; | ||
|
||
request.signOAuth = function() { | ||
const oauthHeader = { | ||
oauth_version: '1.0', | ||
oauth_nonce: uuid.v4(), | ||
oauth_timestamp: Math.floor(Date.now() / 1000), | ||
oauth_consumer_key: this.consumerKey, | ||
oauth_signature_method: 'HMAC-SHA1' | ||
}; | ||
|
||
if (this.toHashBody) { | ||
const stringifiedBody = (typeof this._data !== 'string') ? | ||
JSON.stringify(this._data) : this._data; | ||
|
||
oauthHeader.oauth_body_hash = sha1(stringifiedBody).toString(CryptoJS.enc.Base64); | ||
} | ||
|
||
const oauthParams = {}; | ||
const queryParams = url.parse(this.url, true).query; | ||
for (const attrname of Object.keys(queryParams)) { | ||
oauthParams[attrname] = queryParams[attrname]; | ||
} | ||
for (const attrname of Object.keys(oauthHeader)) { | ||
oauthParams[attrname] = oauthHeader[attrname]; | ||
} | ||
|
||
oauthHeader.oauth_signature = oauthSignature.generate( | ||
this.method, | ||
this.url, | ||
oauthParams, | ||
this.consumerSecret, | ||
'', | ||
{ | ||
encodeSignature: false | ||
}); | ||
|
||
const headerArray = []; | ||
for (const key of Object.keys(oauthHeader)) { | ||
headerArray.push(`${key}="${encodeURIComponent(oauthHeader[key])}"`); | ||
} | ||
|
||
this.set('Authorization', `OAuth ${headerArray.join(',')}`); | ||
}; | ||
|
||
const oldEnd = request.end; | ||
|
||
request.end = function() { | ||
this.end = oldEnd; | ||
|
||
if (this.toSign) { | ||
this.signOAuth(); | ||
} | ||
|
||
return this.end.apply(this, arguments); | ||
}; | ||
}; |
Oops, something went wrong.