Compare commits
73 Commits
f956ba16c6
...
master
Author | SHA1 | Date | |
---|---|---|---|
73a2631867 | |||
c0811f0f08 | |||
fb75ebb1cc | |||
15b4ddb407 | |||
d05eaec7c7 | |||
b54068954c | |||
3d93b0cd9a | |||
d503b8c6fa | |||
2f24ad6da5 | |||
b18030e6d2 | |||
986aab33a4 | |||
79ac44cb52 | |||
7502e10c94 | |||
5ec975739d | |||
ea3644b835 | |||
09cbd6d93c | |||
d62d68dd83 | |||
aa67a690cc | |||
7b671cba0a | |||
f6f5243775 | |||
8c06a0003e | |||
81ccb2d119 | |||
8c0eadae97 | |||
5ad538232e | |||
1ee5ede443 | |||
4690fda999 | |||
960814a96b | |||
4399d3c951 | |||
b105efa6ed | |||
e9d38463f8 | |||
93ef222dd1 | |||
3856b168b0 | |||
9e9b1a57de | |||
983dfaff58 | |||
67ffb62c30 | |||
45f3337527 | |||
7e6886d8ff | |||
d994749ea7 | |||
df7e098fc7 | |||
514d630e4c | |||
928d8036a4 | |||
ebf5208d82 | |||
4f1cb8dd17 | |||
20ede219b3 | |||
40a204309f | |||
9b2d97b9bb | |||
22633f0b1b | |||
fe6d23d5d3 | |||
45299c49db | |||
ae277f5bf9 | |||
14d2978278 | |||
77df83a01a | |||
0c78c811bd | |||
8972983080 | |||
deef29da3b | |||
626ca64a96 | |||
ebdac85909 | |||
9f7567434c | |||
15a1a6e83d | |||
17a4c8f1ba | |||
14f30a1b96 | |||
943e7f879e | |||
4ac1b48f6c | |||
9329374b9c | |||
e1311dfd31 | |||
1f7c9c2d56 | |||
5ea750462a | |||
c7f3ffa742 | |||
ae3cbf168e | |||
0cd67742c2 | |||
67e8acef5a | |||
92934a2b92 | |||
c116058565 |
14
.drone.yml
Normal file
14
.drone.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: setup
|
||||||
|
image: registry:5000/node-build
|
||||||
|
commands:
|
||||||
|
- yarn
|
||||||
|
- curl https://git.scode.ovh/Timo/standard/raw/branch/master/ci.js > ci.js
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
image: registry:5000/node-build
|
||||||
|
commands:
|
||||||
|
- node ci.js
|
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.d.ts
|
25
.eslintrc.js
25
.eslintrc.js
@ -1,17 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||||
|
* This file is part of auth-client-helper which is released under MIT.
|
||||||
|
* See file 'LICENSE' for full license details.
|
||||||
|
* Created by Timo Hocker <timo@scode.ovh>, May 2020
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
env: {
|
env: {
|
||||||
commonjs: true,
|
commonjs: true,
|
||||||
es6: true,
|
es6: true,
|
||||||
node: true
|
node: true
|
||||||
},
|
},
|
||||||
extends: [
|
extends: [ '@sapphirecode' ],
|
||||||
'@scode'
|
|
||||||
],
|
|
||||||
globals: {
|
globals: {
|
||||||
Atomics: 'readonly',
|
Atomics: 'readonly',
|
||||||
SharedArrayBuffer: 'readonly'
|
SharedArrayBuffer: 'readonly'
|
||||||
},
|
},
|
||||||
parserOptions: {
|
parserOptions: { ecmaVersion: 2018 }
|
||||||
ecmaVersion: 2018
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,6 @@
|
|||||||
/node_modules/
|
/node_modules/
|
||||||
/dist/
|
/dist/
|
||||||
/.nyc_output/
|
/.nyc_output/
|
||||||
/coverage/
|
/coverage/
|
||||||
|
# stryker temp files
|
||||||
|
.stryker-tmp
|
||||||
|
8
.liconfig.json
Normal file
8
.liconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"has_license": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"author": "Timo Hocker",
|
||||||
|
"company": "Sapphirecode",
|
||||||
|
"email": "timo@scode.ovh",
|
||||||
|
"software": "auth-client-helper"
|
||||||
|
}
|
11
CHANGELOG.md
Normal file
11
CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 1.1.0
|
||||||
|
|
||||||
|
- package updates
|
||||||
|
- documentation improvements
|
||||||
|
- better testing
|
||||||
|
|
||||||
|
## 1.0.0
|
||||||
|
|
||||||
|
initial release
|
23
Jenkinsfile
vendored
23
Jenkinsfile
vendored
@ -1,23 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
environment {
|
|
||||||
VERSION = VersionNumber([
|
|
||||||
versionNumberString:
|
|
||||||
'${BUILDS_ALL_TIME}',
|
|
||||||
versionPrefix: '1.0.',
|
|
||||||
worstResultForIncrement: 'SUCCESS'
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
stages {
|
|
||||||
stage('Building') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
currentBuild.displayName = env.VERSION
|
|
||||||
}
|
|
||||||
sh 'yarn ci ${VERSION}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
7
LICENSE
Normal file
7
LICENSE
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
MIT License Copyright (c) <year> <author>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
README.md
16
README.md
@ -1,15 +1,3 @@
|
|||||||
# Auth Client Helper
|
# @sapphirecode/auth-client-helper
|
||||||
|
|
||||||
a module to make logging in to servers using the auth-server-helper easier
|
Package deprecated due to the current auth-server-helper allowing users to define their own endpoints and not forcing a specific procedure anymore.
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
const client = require('@scode/auth-client-helper');
|
|
||||||
|
|
||||||
// if using in the browser, will send a request to the current host
|
|
||||||
const session_id = client.login('user','passw');
|
|
||||||
|
|
||||||
// specify a host manually
|
|
||||||
const session_id = client.login('user','passw','https://example.com');
|
|
||||||
```
|
|
||||||
|
6
index.js
6
index.js
@ -2,7 +2,7 @@
|
|||||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||||
* This file is part of auth-client-helper which is released under MIT.
|
* This file is part of auth-client-helper which is released under MIT.
|
||||||
* See file 'LICENSE' for full license details.
|
* See file 'LICENSE' for full license details.
|
||||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
* Created by Timo Hocker <timo@scode.ovh>, May 2020
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* eslint-disable no-magic-numbers */
|
/* eslint-disable no-magic-numbers */
|
||||||
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const crypto = require ('@scode/crypto-helper');
|
const crypto = require ('@sapphirecode/crypto-helper');
|
||||||
const consts = require ('@scode/consts');
|
const consts = require ('@sapphirecode/consts');
|
||||||
const fetch = require ('node-fetch');
|
const fetch = require ('node-fetch');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
14
jasmine.json
Normal file
14
jasmine.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"spec_dir": "test",
|
||||||
|
"spec_files": [
|
||||||
|
"spec/*.js",
|
||||||
|
"spec/*.ts"
|
||||||
|
],
|
||||||
|
"helpers": [
|
||||||
|
"helpers/*.js",
|
||||||
|
"helpers/*.ts"
|
||||||
|
],
|
||||||
|
"stopSpecOnExpectationFailure": false,
|
||||||
|
"random": false
|
||||||
|
}
|
26
jenkins.js
26
jenkins.js
@ -1,26 +0,0 @@
|
|||||||
/* eslint-disable no-process-exit */
|
|
||||||
/* eslint-disable no-console */
|
|
||||||
/* eslint-disable no-sync */
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const fs = require ('fs');
|
|
||||||
const child_process = require ('child_process');
|
|
||||||
|
|
||||||
const pkg = JSON.parse (fs.readFileSync ('package.json', 'utf-8'));
|
|
||||||
[
|
|
||||||
,, pkg.version
|
|
||||||
] = process.argv;
|
|
||||||
fs.writeFileSync ('package.json', JSON.stringify (pkg, null, 2));
|
|
||||||
|
|
||||||
child_process.execSync ('yarn lint', { stdio: 'inherit' });
|
|
||||||
if (typeof pkg.scripts !== 'undefined' && typeof pkg.scripts.test === 'string')
|
|
||||||
child_process.execSync ('yarn test', { stdio: 'inherit' });
|
|
||||||
|
|
||||||
child_process.exec ('git log -1 | grep \'\\[no publish\\]\'')
|
|
||||||
.addListener ('exit', (code) => {
|
|
||||||
if (code === 0) {
|
|
||||||
console.log ('build not marked for deployment');
|
|
||||||
process.exit (0);
|
|
||||||
}
|
|
||||||
else { child_process.execSync ('yarn publish'); }
|
|
||||||
});
|
|
48
package.json
48
package.json
@ -1,23 +1,45 @@
|
|||||||
{
|
{
|
||||||
"name": "@scode/auth-client-helper",
|
"name": "@sapphirecode/auth-client-helper",
|
||||||
"version": "1.0.0",
|
"version": "1.1.3",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Timo Hocker <t-hocker@web.de>",
|
"author": {
|
||||||
|
"name": "Timo Hocker",
|
||||||
|
"email": "timo@scode.ovh"
|
||||||
|
},
|
||||||
|
"bugs": "https://redmine.scode.ovh/projects/auth-client-helper",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"description": "client helper to authenticate on servers using the auth-server-helper",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.scode.ovh:timo/auth-client-helper.git"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scode/eslint-config": "^1.2.26",
|
"@sapphirecode/eslint-config": "^2.1.4",
|
||||||
"ava": "^3.5.0",
|
"@stryker-mutator/core": "^4.0.0",
|
||||||
"eslint": "^6.8.0",
|
"@types/jasmine": "^3.5.14",
|
||||||
"nyc": "^15.0.0"
|
"eslint": "^7.0.0",
|
||||||
|
"jasmine": "^3.6.1",
|
||||||
|
"nyc": "^15.0.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint .",
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
|
||||||
"test": "nyc ava",
|
"test": "nyc jasmine --config=\"jasmine.json\"",
|
||||||
"ci": "yarn && node jenkins.js"
|
"mutate": "stryker run",
|
||||||
|
"compile": "tsc --allowJs --declaration --emitDeclarationOnly index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@scode/consts": "^1.0.3",
|
"@sapphirecode/consts": "^1.1.18",
|
||||||
"@scode/crypto-helper": "^1.1.9",
|
"@sapphirecode/crypto-helper": "^1.1.44",
|
||||||
|
"@stryker-mutator/jasmine-runner": "^4.0.0",
|
||||||
"node-fetch": "^2.6.0"
|
"node-fetch": "^2.6.0"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"LICENSE",
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"authentication",
|
||||||
|
"helper",
|
||||||
|
"auth-server-helper"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
23
stryker.conf.js
Normal file
23
stryker.conf.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||||
|
* This file is part of auth-client-helper which is released under MIT.
|
||||||
|
* See file 'LICENSE' for full license details.
|
||||||
|
* Created by Timo Hocker <timo@scode.ovh>, May 2020
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('@stryker-mutator/api/core').StrykerOptions}
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
packageManager: 'yarn',
|
||||||
|
reporters: [
|
||||||
|
'clear-text',
|
||||||
|
'progress'
|
||||||
|
],
|
||||||
|
testRunner: 'jasmine',
|
||||||
|
jasmineConfigFile: 'jasmine.json',
|
||||||
|
coverageAnalysis: 'perTest',
|
||||||
|
mutate: [ 'index.js' ]
|
||||||
|
};
|
@ -1,50 +0,0 @@
|
|||||||
// @ts-nocheck
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const test = require ('ava');
|
|
||||||
const http = require ('http');
|
|
||||||
const client = require ('../index');
|
|
||||||
const consts = require ('@scode/consts');
|
|
||||||
|
|
||||||
|
|
||||||
test.before (() => {
|
|
||||||
http.createServer ((req, res) => {
|
|
||||||
let str = '';
|
|
||||||
if (req.headers.user)
|
|
||||||
str += req.headers.user;
|
|
||||||
if (req.headers.key)
|
|
||||||
str += req.headers.key;
|
|
||||||
res.writeHead (
|
|
||||||
req.headers.user === 'fail'
|
|
||||||
// eslint-disable-next-line max-len
|
|
||||||
|| req.headers.key === '73192367f6dde83a7e3c0bb412dff8e1b7dfbdb5e5010f00057f317b8eab68e8e448528303142c1455dfe72e062bb2e48f07441b38c7b65329ba7e5acbea6126'
|
|
||||||
? consts.http.status_forbidden
|
|
||||||
: consts.http.status_ok
|
|
||||||
);
|
|
||||||
res.end (str);
|
|
||||||
})
|
|
||||||
// eslint-disable-next-line no-magic-numbers
|
|
||||||
.listen (3000);
|
|
||||||
});
|
|
||||||
|
|
||||||
test ('send request', async (t) => {
|
|
||||||
const session = await client.login ('foo', 'bar', 'http://localhost:3000');
|
|
||||||
|
|
||||||
t.is (
|
|
||||||
session,
|
|
||||||
// eslint-disable-next-line max-len
|
|
||||||
'foo39082c11afda7a927fe4e23c5ba81b64186c33f7e58adf492be5a5c64ddc9db459e0778d573000a5ebaeeae902b6c8641198406b58bf9c53ce48ecdef73a33d1'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test ('fail salt', async (t) => {
|
|
||||||
await t.throwsAsync (
|
|
||||||
client.login ('fail', 'bar', 'http://localhost:3000')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test ('fail password', async (t) => {
|
|
||||||
await t.throwsAsync (
|
|
||||||
client.login ('foo', 'fail', 'http://localhost:3000')
|
|
||||||
);
|
|
||||||
});
|
|
62
test/spec/index.js
Normal file
62
test/spec/index.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||||
|
* This file is part of auth-client-helper which is released under MIT.
|
||||||
|
* See file 'LICENSE' for full license details.
|
||||||
|
* Created by Timo Hocker <timo@scode.ovh>, May 2020
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable no-undef */
|
||||||
|
// @ts-nocheck
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const http = require ('http');
|
||||||
|
const client = require ('../../index');
|
||||||
|
const consts = require ('@sapphirecode/consts');
|
||||||
|
|
||||||
|
describe ('client helper', () => {
|
||||||
|
beforeAll (() => {
|
||||||
|
http.createServer ((req, res) => {
|
||||||
|
let str = '';
|
||||||
|
if (req.headers.user)
|
||||||
|
str += req.headers.user;
|
||||||
|
if (req.headers.key)
|
||||||
|
str += req.headers.key;
|
||||||
|
res.writeHead (
|
||||||
|
req.headers.user === 'fail'
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
|| req.headers.key === '73192367f6dde83a7e3c0bb412dff8e1b7dfbdb5e5010f00057f317b8eab68e8e448528303142c1455dfe72e062bb2e48f07441b38c7b65329ba7e5acbea6126'
|
||||||
|
? consts.http.status_forbidden
|
||||||
|
: consts.http.status_ok
|
||||||
|
);
|
||||||
|
res.end (str);
|
||||||
|
})
|
||||||
|
// eslint-disable-next-line no-magic-numbers
|
||||||
|
.listen (3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it ('should send request', async () => {
|
||||||
|
const session = await client.login ('foo', 'bar', 'http://localhost:3000');
|
||||||
|
|
||||||
|
expect (
|
||||||
|
session
|
||||||
|
)
|
||||||
|
.toEqual (
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
'foo39082c11afda7a927fe4e23c5ba81b64186c33f7e58adf492be5a5c64ddc9db459e0778d573000a5ebaeeae902b6c8641198406b58bf9c53ce48ecdef73a33d1'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it ('should fail salt', async () => {
|
||||||
|
await expectAsync (
|
||||||
|
client.login ('fail', 'bar', 'http://localhost:3000')
|
||||||
|
)
|
||||||
|
.toBeRejectedWithError ('user or password invalid');
|
||||||
|
});
|
||||||
|
|
||||||
|
it ('should fail password', async () => {
|
||||||
|
await expectAsync (
|
||||||
|
client.login ('foo', 'fail', 'http://localhost:3000')
|
||||||
|
)
|
||||||
|
.toBeRejectedWithError ('user or password invalid');
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue
Block a user