mirror of
https://github.com/Expand-sys/ccash-client-js
synced 2026-03-22 12:27:09 +11:00
Compare commits
No commits in common. "stable" and "v1.2.0" have entirely different histories.
7 changed files with 42 additions and 66 deletions
15
.github/workflows/publish.yaml
vendored
15
.github/workflows/publish.yaml
vendored
|
|
@ -4,8 +4,22 @@ on:
|
|||
branches:
|
||||
- stable
|
||||
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:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
|
|
@ -18,7 +32,6 @@ jobs:
|
|||
path: '**/node_modules'
|
||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
||||
- run: yarn --no-progress
|
||||
- run: yarn build
|
||||
- run: yarn release
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
|
|
|||
48
CHANGELOG.md
48
CHANGELOG.md
|
|
@ -1,53 +1,5 @@
|
|||
# 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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "ccash-client-js",
|
||||
"version": "1.6.0",
|
||||
"version": "1.2.0",
|
||||
"description": "JS HTTP client for CCash",
|
||||
"main": "./dist",
|
||||
"main": "./dist/cjs",
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ export class InvalidRequestException extends Exception {
|
|||
}
|
||||
}
|
||||
|
||||
export class WrongAdminPasswordException extends Exception {
|
||||
constructor() {
|
||||
super('wrong admin password');
|
||||
}
|
||||
}
|
||||
|
||||
export class NameTooLongException extends Exception {
|
||||
constructor() {
|
||||
super('name too long');
|
||||
|
|
@ -46,6 +52,7 @@ export enum ErrorCodes {
|
|||
UserNotFound = -1,
|
||||
WrongPassword = -2,
|
||||
InvalidRequest = -3,
|
||||
WrongAdminPassword = -4,
|
||||
NameTooLong = -5,
|
||||
UserAlreadyExists = -6,
|
||||
InsufficientFunds = -7,
|
||||
|
|
@ -55,6 +62,7 @@ export const ExceptionMap = {
|
|||
[ErrorCodes.UserNotFound]: UserNotFoundException,
|
||||
[ErrorCodes.WrongPassword]: WrongPasswordException,
|
||||
[ErrorCodes.InvalidRequest]: InvalidRequestException,
|
||||
[ErrorCodes.WrongAdminPassword]: WrongAdminPasswordException,
|
||||
[ErrorCodes.NameTooLong]: NameTooLongException,
|
||||
[ErrorCodes.UserAlreadyExists]: UserAlreadyExistsException,
|
||||
[ErrorCodes.InsufficientFunds]: InsufficientFundsException,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ import {
|
|||
ErrorCodes,
|
||||
} from './CCashClient.exceptions';
|
||||
|
||||
export class CCashClient implements ICCashClient {
|
||||
export class CCashClient implements Partial<ICCashClient> {
|
||||
/** TODO: not partial **/
|
||||
http: AxiosInstance;
|
||||
|
||||
constructor(baseURL: string | undefined = process.env.CCASH_API_BASE_URL) {
|
||||
|
|
@ -26,10 +27,15 @@ export class CCashClient implements ICCashClient {
|
|||
.then((response) => this.handleError(response) || response.data.value);
|
||||
}
|
||||
|
||||
log(user: string, pass: string): Promise<number[]> {
|
||||
log(
|
||||
user: string,
|
||||
pass: string,
|
||||
transactionCount: number = 10
|
||||
): Promise<number[]> {
|
||||
return this.http
|
||||
.get(`/${user}/bal`, {
|
||||
headers: { Password: pass },
|
||||
params: { n: transactionCount },
|
||||
})
|
||||
.then((response) => this.handleError(response) || response.data.value);
|
||||
}
|
||||
|
|
@ -56,14 +62,18 @@ export class CCashClient implements ICCashClient {
|
|||
|
||||
changePassword(user: string, pass: string, newPass: string): Promise<User> {
|
||||
return this.http
|
||||
.patch(`/${user}/pass/change`, newPass, { headers: { Password: pass } })
|
||||
.patch(
|
||||
`/${user}/pass/change`,
|
||||
{ password: newPass },
|
||||
{ headers: { Password: pass } }
|
||||
)
|
||||
.then(
|
||||
(response) =>
|
||||
this.handleError(response) || this.serialize(User, { user })
|
||||
);
|
||||
}
|
||||
|
||||
setBalance(user: string, pass: string, amount: number): Promise<number> {
|
||||
setBal(user: string, pass: string, amount: number): Promise<number> {
|
||||
return this.http
|
||||
.patch(`/admin/${user}/bal`, undefined, {
|
||||
headers: { Password: pass },
|
||||
|
|
@ -76,10 +86,6 @@ export class CCashClient implements ICCashClient {
|
|||
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> {
|
||||
return this.http
|
||||
.post('/close', undefined, { headers: { Password: pass } })
|
||||
|
|
@ -114,11 +120,10 @@ export class CCashClient implements ICCashClient {
|
|||
adminAddUser(
|
||||
user: string,
|
||||
pass: string,
|
||||
initialPass: string,
|
||||
initialBalance: number
|
||||
): Promise<User> {
|
||||
return this.http
|
||||
.post(`/user/${user}`, initialPass, {
|
||||
.post(`/user/${user}`, undefined, {
|
||||
headers: { Password: pass },
|
||||
params: { init_bal: initialBalance },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export { User };
|
|||
export interface ICCashClient {
|
||||
// Usage
|
||||
balance(user: string): Promise<number>;
|
||||
log(user: string, pass: string): Promise<number[]>;
|
||||
log(user: string, pass: string, transactionCount?: number): Promise<number[]>;
|
||||
sendFunds(
|
||||
user: string,
|
||||
pass: string,
|
||||
|
|
@ -16,11 +16,10 @@ export interface ICCashClient {
|
|||
|
||||
// Meta usage
|
||||
changePassword(user: string, pass: string, newPass: string): Promise<User>;
|
||||
setBalance(user: string, pass: string, amount: number): Promise<number>;
|
||||
setBal(user: string, pass: string, amount: number): Promise<number>;
|
||||
|
||||
// System usage
|
||||
help(): Promise<string>;
|
||||
ping(): Promise<boolean>;
|
||||
close(pass: string): Promise<boolean>;
|
||||
contains(user: string): Promise<boolean>;
|
||||
adminVerifyPass(pass: string): Promise<boolean>;
|
||||
|
|
@ -30,7 +29,6 @@ export interface ICCashClient {
|
|||
adminAddUser(
|
||||
user: string,
|
||||
pass: string,
|
||||
initialPass: string,
|
||||
initialBalance: number
|
||||
): Promise<User>;
|
||||
deleteUser(user: string, pass: string): Promise<User>;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"outDir": "./dist/cjs",
|
||||
"target": "es2015",
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue