mirror of
https://github.com/Expand-sys/ccash-client-js
synced 2026-03-22 12:27:09 +11:00
Compare commits
9 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c1e4c3c80 | ||
|
|
39dad3a037 | ||
|
|
a9ed375f88 | ||
|
|
6fd7a91422 | ||
|
|
4e60a56373 | ||
|
|
27a77d8b30 | ||
|
|
a26b61aeec | ||
|
|
dbe1008850 | ||
|
|
0a1d35812d |
5 changed files with 38 additions and 29 deletions
25
CHANGELOG.md
25
CHANGELOG.md
|
|
@ -1,5 +1,30 @@
|
||||||
# CHANGELOG
|
# 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)
|
# [1.4.0](https://github.com/LukeeeeBennett/ccash-client-js/compare/v1.3.0...v1.4.0) (2021-06-13)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ccash-client-js",
|
"name": "ccash-client-js",
|
||||||
"version": "1.4.0",
|
"version": "1.6.0",
|
||||||
"description": "JS HTTP client for CCash",
|
"description": "JS HTTP client for CCash",
|
||||||
"main": "./dist",
|
"main": "./dist",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -26,15 +26,10 @@ export class CCashClient implements 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);
|
||||||
}
|
}
|
||||||
|
|
@ -61,11 +56,7 @@ export class CCashClient implements 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 })
|
||||||
|
|
@ -85,6 +76,10 @@ export class CCashClient implements 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 } })
|
||||||
|
|
@ -123,14 +118,10 @@ export class CCashClient implements ICCashClient {
|
||||||
initialBalance: number
|
initialBalance: number
|
||||||
): Promise<User> {
|
): Promise<User> {
|
||||||
return this.http
|
return this.http
|
||||||
.post(
|
.post(`/user/${user}`, initialPass, {
|
||||||
`/user/${user}`,
|
headers: { Password: pass },
|
||||||
{ password: initialPass },
|
params: { init_bal: initialBalance },
|
||||||
{
|
})
|
||||||
headers: { Password: pass },
|
|
||||||
params: { init_bal: initialBalance },
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(
|
.then(
|
||||||
(response) =>
|
(response) =>
|
||||||
this.handleError(response) || this.serialize(User, { user })
|
this.handleError(response) || this.serialize(User, { user })
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
@ -20,6 +20,7 @@ export interface ICCashClient {
|
||||||
|
|
||||||
// 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>;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue