Skip to content

Commit 5875cd1

Browse files
authored
Merge pull request #17 from topcoder-platform/dev
bringing master up to parity w/ dev
2 parents 175750c + 8822cb9 commit 5875cd1

File tree

13 files changed

+1265
-22
lines changed

13 files changed

+1265
-22
lines changed

.github/workflows/main.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: 12
15+
registry-url: https://registry.npmjs.org/
16+
- run: yarn install
17+
- run: npm publish --access public
18+
env:
19+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "tc-auth-lib",
2+
"name": "@topcoder-platform/tc-auth-lib",
33
"version": "1.0.0",
44
"description": "Topcoder Authentication lib ",
55
"main": "index.js",

src/connector-wrapper.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let url = ''
77
let mock = false
88
let token = ''
99

10-
function configureConnector({connectorUrl, frameId, mockMode, mockToken}) {
10+
export function configureConnector({connectorUrl, frameId, mockMode, mockToken}) {
1111
if (mockMode) {
1212
mock = true
1313
token = mockToken
@@ -65,7 +65,7 @@ const proxyCall = function() {
6565
}
6666
}
6767

68-
function getFreshToken() {
68+
export function getFreshToken() {
6969
if (mock) {
7070
if (token) {
7171
return Promise.resolve(token)
@@ -78,8 +78,5 @@ function getFreshToken() {
7878
.then( data => data.token )
7979
}
8080

81-
module.exports = {
82-
getFreshToken,
83-
configureConnector
84-
}
81+
8582

src/iframe.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function createFrame(id, src) {
1+
export function createFrame(id, src) {
22
const iframe = document.createElement('iframe')
33

44
iframe.id = id
@@ -11,6 +11,3 @@ function createFrame(id, src) {
1111

1212
return iframe
1313
}
14-
module.exports = {
15-
createFrame
16-
}

src/token.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const fromPairs = require('lodash/fromPairs')
1+
const _ = require('lodash')
22

33

4-
function getToken(key) {
4+
export function getToken(key) {
55
return readCookie(key)
66
}
77

88

9-
function decodeToken(token) {
9+
export function decodeToken(token) {
1010
const parts = token.split('.')
1111

1212
if (parts.length !== 3) {
@@ -36,7 +36,7 @@ function decodeToken(token) {
3636
return t
3737
}
3838

39-
function isTokenExpired(token, offsetSeconds = 0) {
39+
export function isTokenExpired(token, offsetSeconds = 0) {
4040
const d = getTokenExpirationDate(token)
4141

4242
if (d === null) {
@@ -82,16 +82,10 @@ function getTokenExpirationDate(token) {
8282
}
8383

8484
function parseCookie(cookie) {
85-
return fromPairs(cookie.split(';').map((pair) => pair.split('=').map((part) => part.trim())))
85+
return _.fromPairs(cookie.split(';').map((pair) => pair.split('=').map((part) => part.trim())))
8686
}
8787

8888
function readCookie(name) {
8989
return parseCookie(document.cookie)[name]
9090
}
9191

92-
93-
module.exports = {
94-
isTokenExpired,
95-
decodeToken,
96-
getToken
97-
}

0 commit comments

Comments
 (0)