Compare commits

...

30 commits

Author SHA1 Message Date
semantic-release-bot
6c1e4c3c80 chore(release): 1.6.0 [skip ci] 2021-06-13 21:07:17 +00:00
Luke Bennett
39dad3a037
feat: release 2021-06-13 22:06:28 +01:00
Luke Bennett
a9ed375f88
Merge branch 'stable' of github-me.com:LukeeeeBennett/ccash-client-js into stable 2021-06-13 22:06:13 +01:00
Luke Bennett
6fd7a91422
fix: correct password as body calls 2021-06-13 22:05:58 +01:00
semantic-release-bot
4e60a56373 chore(release): 1.5.0 [skip ci] 2021-06-13 20:34:07 +00:00
Luke Bennett
27a77d8b30
Merge branch 'stable' of github-me.com:LukeeeeBennett/ccash-client-js into stable 2021-06-13 21:33:12 +01:00
Luke Bennett
a26b61aeec
fix: remove log transactionCount 2021-06-13 21:32:19 +01:00
Luke Bennett
dbe1008850
feat: add ping 2021-06-13 21:28:07 +01:00
Luke Bennett
0a1d35812d
feat: remove WrongAdminPassword exception 2021-06-13 21:26:53 +01:00
semantic-release-bot
cf6eabc4f5 chore(release): 1.4.0 [skip ci] 2021-06-13 03:50:36 +00:00
Luke Bennett
2663b24220
feat: release 2021-06-13 04:50:00 +01:00
Luke Bennett
5bd08201d7
fix: types 2021-06-13 04:49:56 +01:00
Luke Bennett
957481b42d
Merge branch 'stable' of github-me.com:LukeeeeBennett/ccash-client-js into stable 2021-06-13 04:48:15 +01:00
Luke Bennett
a443b6bba1
feat: release 2021-06-13 04:48:09 +01:00
Luke Bennett
80ca0b6800
fix: add password in body to adminAddUser 2021-06-13 04:47:27 +01:00
semantic-release-bot
139a7f6ebb chore(release): 1.3.0 [skip ci] 2021-06-13 03:21:06 +00:00
Luke Bennett
aa57f32701
feat: release 2021-06-13 04:20:30 +01:00
Luke Bennett
203f4a6cf1
ci: remove missing needs 2021-06-13 04:20:24 +01:00
Luke Bennett
4498e04e31
feat: release 2021-06-13 04:18:42 +01:00
Luke Bennett
e157f943ae
Merge branch 'stable' of github-me.com:LukeeeeBennett/ccash-client-js into stable 2021-06-13 04:18:39 +01:00
Luke Bennett
d653d73606
feat: release 2021-06-13 04:18:35 +01:00
Luke Bennett
5f0248b63c
ci: drop build step 2021-06-13 04:18:32 +01:00
semantic-release-bot
11958fbf3c chore(release): 1.2.0 [skip ci] 2021-06-13 03:16:24 +00:00
Luke Bennett
72698f3260
feat: release 2021-06-13 04:13:49 +01:00
Luke Bennett
411e2dc429
ci: remove release notes from release commit 2021-06-13 04:13:32 +01:00
Luke Bennett
9bc7437dae
feat: release 2021-06-13 04:10:43 +01:00
Luke Bennett
f7aed94aa0
docs: add CHANGELOG.md 2021-06-13 04:10:37 +01:00
Luke Bennett
4ae0dde4eb
feat: release 2021-06-13 04:03:41 +01:00
Luke Bennett
41fcfdc8f0
ci: add token envs 2021-06-13 04:00:49 +01:00
Luke Bennett
abb5aee53e
ci: fix release.config plugins array 2021-06-13 03:47:30 +01:00
9 changed files with 948 additions and 915 deletions

View file

@ -4,22 +4,8 @@ on:
branches: branches:
- stable - stable
jobs: jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '15.x'
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- run: yarn --no-progress
- run: yarn build
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
@ -32,4 +18,8 @@ jobs:
path: '**/node_modules' path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- run: yarn --no-progress - run: yarn --no-progress
- run: yarn build
- run: yarn release - run: yarn release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

58
CHANGELOG.md Normal file
View file

@ -0,0 +1,58 @@
# CHANGELOG
# [1.6.0](https://github.com/LukeeeeBennett/ccash-client-js/compare/v1.5.0...v1.6.0) (2021-06-13)
### Bug Fixes
* correct password as body calls ([6fd7a91](https://github.com/LukeeeeBennett/ccash-client-js/commit/6fd7a91422c74f5b0c2bea951db160e3d6bb4dfc))
### Features
* release ([39dad3a](https://github.com/LukeeeeBennett/ccash-client-js/commit/39dad3a037c6151915288401f68ecdad2b2ac0f4))
# [1.5.0](https://github.com/LukeeeeBennett/ccash-client-js/compare/v1.4.0...v1.5.0) (2021-06-13)
### Bug Fixes
* remove log transactionCount ([a26b61a](https://github.com/LukeeeeBennett/ccash-client-js/commit/a26b61aeecda844dc2e9e043aeeacad71d813dd7))
### Features
* add ping ([dbe1008](https://github.com/LukeeeeBennett/ccash-client-js/commit/dbe1008850d68ee871b153fbca1c410d668601e9))
* remove WrongAdminPassword exception ([0a1d358](https://github.com/LukeeeeBennett/ccash-client-js/commit/0a1d35812d31032e114fbfb983e39f4a3cc7775a))
# [1.4.0](https://github.com/LukeeeeBennett/ccash-client-js/compare/v1.3.0...v1.4.0) (2021-06-13)
### Bug Fixes
* add password in body to adminAddUser ([80ca0b6](https://github.com/LukeeeeBennett/ccash-client-js/commit/80ca0b6800725b6e814a3a07974da796caa03c6a))
* types ([5bd0820](https://github.com/LukeeeeBennett/ccash-client-js/commit/5bd08201d75acb83574ac35e9c0317e835713746))
### Features
* release ([2663b24](https://github.com/LukeeeeBennett/ccash-client-js/commit/2663b2422057c0ebe5d054aee0d1793973b6bbb4))
* release ([a443b6b](https://github.com/LukeeeeBennett/ccash-client-js/commit/a443b6bba10c5d512b92d02bdd0dc80a29519e19))
# [1.3.0](https://github.com/LukeeeeBennett/ccash-client-js/compare/v1.2.0...v1.3.0) (2021-06-13)
### Features
* release ([aa57f32](https://github.com/LukeeeeBennett/ccash-client-js/commit/aa57f32701c0d4add0a131a487b44a2ca5be4977))
* release ([4498e04](https://github.com/LukeeeeBennett/ccash-client-js/commit/4498e04e3177251ca4ba8cd046742d4868420255))
* release ([d653d73](https://github.com/LukeeeeBennett/ccash-client-js/commit/d653d736064c8733c9959ad788f8a4c0d53f7b81))
# [1.2.0](https://github.com/LukeeeeBennett/ccash-client-js/compare/v1.1.0...v1.2.0) (2021-06-13)
### Features
* release ([72698f3](https://github.com/LukeeeeBennett/ccash-client-js/commit/72698f326081bcc4b16138f5d344418bdb2b12f4))
* release ([9bc7437](https://github.com/LukeeeeBennett/ccash-client-js/commit/9bc7437daefc9c7d9378c40ee5a1d2a6d3740c5e))
* release ([4ae0dde](https://github.com/LukeeeeBennett/ccash-client-js/commit/4ae0dde4eb22cb839c9c3e342fcc66ec06368516))

View file

@ -1,8 +1,8 @@
{ {
"name": "ccash-client-js", "name": "ccash-client-js",
"version": "0.0.0", "version": "1.6.0",
"description": "JS HTTP client for CCash", "description": "JS HTTP client for CCash",
"main": "./dist/cjs", "main": "./dist",
"publishConfig": { "publishConfig": {
"registry": "https://registry.npmjs.org/" "registry": "https://registry.npmjs.org/"
}, },

View file

@ -1,7 +1,7 @@
module.exports = { module.exports = {
branches: ['stable'], branches: ['stable'],
plugins: { plugins: [
commitAnalyzer: [ [
'@semantic-release/commit-analyzer', '@semantic-release/commit-analyzer',
{ {
releaseRules: [ releaseRules: [
@ -11,21 +11,22 @@ module.exports = {
], ],
}, },
], ],
releaseNotes: '@semantic-release/release-notes-generator', '@semantic-release/release-notes-generator',
changelog: [ [
'@semantic-release/changelog', '@semantic-release/changelog',
{ {
changelogFile: 'CHANGELOG.md', changelogFile: 'CHANGELOG.md',
changelogTitle: '# CHANGELOG', changelogTitle: '# CHANGELOG',
}, },
], ],
github: '@semantic-release/github', '@semantic-release/github',
npm: '@semantic-release/npm', '@semantic-release/npm',
git: [ [
'@semantic-release/git', '@semantic-release/git',
{ {
assets: ['CHANGELOG.md', 'package.json'], assets: ['CHANGELOG.md', 'package.json'],
message: 'chore(release): ${nextRelease.version} [skip ci]',
}, },
], ],
}, ],
}; };

View file

@ -24,12 +24,6 @@ export class InvalidRequestException extends Exception {
} }
} }
export class WrongAdminPasswordException extends Exception {
constructor() {
super('wrong admin password');
}
}
export class NameTooLongException extends Exception { export class NameTooLongException extends Exception {
constructor() { constructor() {
super('name too long'); super('name too long');
@ -52,7 +46,6 @@ export enum ErrorCodes {
UserNotFound = -1, UserNotFound = -1,
WrongPassword = -2, WrongPassword = -2,
InvalidRequest = -3, InvalidRequest = -3,
WrongAdminPassword = -4,
NameTooLong = -5, NameTooLong = -5,
UserAlreadyExists = -6, UserAlreadyExists = -6,
InsufficientFunds = -7, InsufficientFunds = -7,
@ -62,7 +55,6 @@ export const ExceptionMap = {
[ErrorCodes.UserNotFound]: UserNotFoundException, [ErrorCodes.UserNotFound]: UserNotFoundException,
[ErrorCodes.WrongPassword]: WrongPasswordException, [ErrorCodes.WrongPassword]: WrongPasswordException,
[ErrorCodes.InvalidRequest]: InvalidRequestException, [ErrorCodes.InvalidRequest]: InvalidRequestException,
[ErrorCodes.WrongAdminPassword]: WrongAdminPasswordException,
[ErrorCodes.NameTooLong]: NameTooLongException, [ErrorCodes.NameTooLong]: NameTooLongException,
[ErrorCodes.UserAlreadyExists]: UserAlreadyExistsException, [ErrorCodes.UserAlreadyExists]: UserAlreadyExistsException,
[ErrorCodes.InsufficientFunds]: InsufficientFundsException, [ErrorCodes.InsufficientFunds]: InsufficientFundsException,

View file

@ -7,8 +7,7 @@ import {
ErrorCodes, ErrorCodes,
} from './CCashClient.exceptions'; } from './CCashClient.exceptions';
export class CCashClient implements Partial<ICCashClient> { export class CCashClient implements ICCashClient {
/** TODO: not partial **/
http: AxiosInstance; http: AxiosInstance;
constructor(baseURL: string | undefined = process.env.CCASH_API_BASE_URL) { constructor(baseURL: string | undefined = process.env.CCASH_API_BASE_URL) {
@ -27,15 +26,10 @@ export class CCashClient implements Partial<ICCashClient> {
.then((response) => this.handleError(response) || response.data.value); .then((response) => this.handleError(response) || response.data.value);
} }
log( log(user: string, pass: string): Promise<number[]> {
user: string,
pass: string,
transactionCount: number = 10
): Promise<number[]> {
return this.http return this.http
.get(`/${user}/bal`, { .get(`/${user}/bal`, {
headers: { Password: pass }, headers: { Password: pass },
params: { n: transactionCount },
}) })
.then((response) => this.handleError(response) || response.data.value); .then((response) => this.handleError(response) || response.data.value);
} }
@ -62,18 +56,14 @@ export class CCashClient implements Partial<ICCashClient> {
changePassword(user: string, pass: string, newPass: string): Promise<User> { changePassword(user: string, pass: string, newPass: string): Promise<User> {
return this.http return this.http
.patch( .patch(`/${user}/pass/change`, newPass, { headers: { Password: pass } })
`/${user}/pass/change`,
{ password: newPass },
{ headers: { Password: pass } }
)
.then( .then(
(response) => (response) =>
this.handleError(response) || this.serialize(User, { user }) this.handleError(response) || this.serialize(User, { user })
); );
} }
setBal(user: string, pass: string, amount: number): Promise<number> { setBalance(user: string, pass: string, amount: number): Promise<number> {
return this.http return this.http
.patch(`/admin/${user}/bal`, undefined, { .patch(`/admin/${user}/bal`, undefined, {
headers: { Password: pass }, headers: { Password: pass },
@ -86,6 +76,10 @@ export class CCashClient implements Partial<ICCashClient> {
return this.http.get('/help').then((response) => response.data); return this.http.get('/help').then((response) => response.data);
} }
ping(): Promise<boolean> {
return this.http.get('/ping').then((response) => response.data || false);
}
close(pass: string): Promise<boolean> { close(pass: string): Promise<boolean> {
return this.http return this.http
.post('/close', undefined, { headers: { Password: pass } }) .post('/close', undefined, { headers: { Password: pass } })
@ -120,10 +114,11 @@ export class CCashClient implements Partial<ICCashClient> {
adminAddUser( adminAddUser(
user: string, user: string,
pass: string, pass: string,
initialPass: string,
initialBalance: number initialBalance: number
): Promise<User> { ): Promise<User> {
return this.http return this.http
.post(`/user/${user}`, undefined, { .post(`/user/${user}`, initialPass, {
headers: { Password: pass }, headers: { Password: pass },
params: { init_bal: initialBalance }, params: { init_bal: initialBalance },
}) })

View file

@ -5,7 +5,7 @@ export { User };
export interface ICCashClient { export interface ICCashClient {
// Usage // Usage
balance(user: string): Promise<number>; balance(user: string): Promise<number>;
log(user: string, pass: string, transactionCount?: number): Promise<number[]>; log(user: string, pass: string): Promise<number[]>;
sendFunds( sendFunds(
user: string, user: string,
pass: string, pass: string,
@ -16,10 +16,11 @@ export interface ICCashClient {
// Meta usage // Meta usage
changePassword(user: string, pass: string, newPass: string): Promise<User>; changePassword(user: string, pass: string, newPass: string): Promise<User>;
setBal(user: string, pass: string, amount: number): Promise<number>; setBalance(user: string, pass: string, amount: number): Promise<number>;
// System usage // System usage
help(): Promise<string>; help(): Promise<string>;
ping(): Promise<boolean>;
close(pass: string): Promise<boolean>; close(pass: string): Promise<boolean>;
contains(user: string): Promise<boolean>; contains(user: string): Promise<boolean>;
adminVerifyPass(pass: string): Promise<boolean>; adminVerifyPass(pass: string): Promise<boolean>;
@ -29,6 +30,7 @@ export interface ICCashClient {
adminAddUser( adminAddUser(
user: string, user: string,
pass: string, pass: string,
initialPass: string,
initialBalance: number initialBalance: number
): Promise<User>; ): Promise<User>;
deleteUser(user: string, pass: string): Promise<User>; deleteUser(user: string, pass: string): Promise<User>;

View file

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/cjs", "outDir": "./dist",
"target": "es2015", "target": "es2015",
"module": "commonjs", "module": "commonjs",
"declaration": true, "declaration": true,

1725
yarn.lock

File diff suppressed because it is too large Load diff