hcloud-sdk 0.0.6 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -1
- package/index.d.ts +1 -1
- package/lib/base.d.ts +7 -0
- package/lib/base.js +8 -0
- package/lib/dto/IDP.d.ts +13 -0
- package/lib/dto/IDP.js +2 -0
- package/lib/hcloud.d.ts +7 -9
- package/lib/hcloud.js +12 -5
- package/lib/service/High5.d.ts +4 -0
- package/lib/service/High5.js +9 -0
- package/lib/service/IDP.d.ts +33 -0
- package/lib/service/IDP.js +74 -0
- package/package.json +21 -12
- package/hcloud-sdk-0.0.5.tgz +0 -0
- package/lib/Axios.d.ts +0 -4
- package/lib/Axios.js +0 -20
- package/lib/IDP.d.ts +0 -4
- package/lib/IDP.js +0 -22
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 MoovIT Software Products GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import hcloud from
|
|
1
|
+
import hcloud from "./lib/hcloud";
|
|
2
2
|
export default hcloud;
|
package/lib/base.d.ts
ADDED
package/lib/base.js
ADDED
package/lib/dto/IDP.d.ts
ADDED
package/lib/dto/IDP.js
ADDED
package/lib/hcloud.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export default class hcloud {
|
|
7
|
-
protected opts: options;
|
|
8
|
-
protected axios: AxiosService;
|
|
1
|
+
import base, { Options } from "./base";
|
|
2
|
+
import IDPService from "./service/IDP";
|
|
3
|
+
import High5Service from "./service/High5";
|
|
4
|
+
export default class hcloud extends base {
|
|
9
5
|
IDP: IDPService;
|
|
10
|
-
|
|
6
|
+
High5: High5Service;
|
|
7
|
+
constructor(opts: Options);
|
|
8
|
+
setAuthToken(token: string): void;
|
|
11
9
|
}
|
package/lib/hcloud.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const base_1 = require("./base");
|
|
4
|
+
const IDP_1 = require("./service/IDP");
|
|
5
|
+
const High5_1 = require("./service/High5");
|
|
6
|
+
const axios_1 = require("axios");
|
|
5
7
|
// tslint:disable-next-line
|
|
6
|
-
class hcloud {
|
|
8
|
+
class hcloud extends base_1.default {
|
|
7
9
|
constructor(opts) {
|
|
8
|
-
|
|
9
|
-
this.axios = new Axios_1.default();
|
|
10
|
+
super(opts);
|
|
10
11
|
this.IDP = new IDP_1.default(this.opts);
|
|
12
|
+
this.High5 = new High5_1.default(this.opts);
|
|
13
|
+
}
|
|
14
|
+
setAuthToken(token) {
|
|
15
|
+
axios_1.default.defaults.headers.common = {
|
|
16
|
+
Authorization: token,
|
|
17
|
+
};
|
|
11
18
|
}
|
|
12
19
|
}
|
|
13
20
|
exports.default = hcloud;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base_1 = require("../base");
|
|
4
|
+
class High5 extends base_1.default {
|
|
5
|
+
getEndpoint(endpoint) {
|
|
6
|
+
return `${this.opts.api}/api/high5${endpoint}`;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.default = High5;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import base from "../base";
|
|
2
|
+
import { Token, User } from "../dto/IDP";
|
|
3
|
+
export default class IDP extends base {
|
|
4
|
+
/**
|
|
5
|
+
* Authorize validates a token
|
|
6
|
+
* @param token
|
|
7
|
+
* @returns User object
|
|
8
|
+
*/
|
|
9
|
+
authorize: () => Promise<User>;
|
|
10
|
+
/**
|
|
11
|
+
* Register against the identity provider
|
|
12
|
+
* @param name
|
|
13
|
+
* @param email
|
|
14
|
+
* @param password
|
|
15
|
+
* @returns Bearer Token
|
|
16
|
+
*/
|
|
17
|
+
register: (name: string, email: string, password: string) => Promise<User>;
|
|
18
|
+
/**
|
|
19
|
+
* Authenticate against the identity provider with a given email and password.
|
|
20
|
+
* @param email
|
|
21
|
+
* @param password
|
|
22
|
+
* @returns Bearer Token
|
|
23
|
+
*/
|
|
24
|
+
authenticate: (email: string, password: string) => Promise<Token>;
|
|
25
|
+
/**
|
|
26
|
+
* authenticateReturnUser against the identity provider with a given email and password.
|
|
27
|
+
* @param email
|
|
28
|
+
* @param password
|
|
29
|
+
* @returns User object
|
|
30
|
+
*/
|
|
31
|
+
authenticateReturnUser: (email: string, password: string) => Promise<User>;
|
|
32
|
+
private getEndpoint;
|
|
33
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const base_1 = require("../base");
|
|
13
|
+
const axios_1 = require("axios");
|
|
14
|
+
class IDP extends base_1.default {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
/**
|
|
18
|
+
* Authorize validates a token
|
|
19
|
+
* @param token
|
|
20
|
+
* @returns User object
|
|
21
|
+
*/
|
|
22
|
+
this.authorize = () => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const resp = yield axios_1.default.post(this.getEndpoint("/v1/authenticate"), {}, {}).catch((err) => {
|
|
24
|
+
throw err;
|
|
25
|
+
});
|
|
26
|
+
return resp.data;
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Register against the identity provider
|
|
30
|
+
* @param name
|
|
31
|
+
* @param email
|
|
32
|
+
* @param password
|
|
33
|
+
* @returns Bearer Token
|
|
34
|
+
*/
|
|
35
|
+
this.register = (name, email, password) => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const resp = yield axios_1.default
|
|
37
|
+
.post(this.getEndpoint("/v1/registration"), { name: name, email: email, password: password })
|
|
38
|
+
.catch((err) => {
|
|
39
|
+
throw err;
|
|
40
|
+
});
|
|
41
|
+
return resp.data;
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Authenticate against the identity provider with a given email and password.
|
|
45
|
+
* @param email
|
|
46
|
+
* @param password
|
|
47
|
+
* @returns Bearer Token
|
|
48
|
+
*/
|
|
49
|
+
this.authenticate = (email, password) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const resp = yield axios_1.default.post(this.getEndpoint("/v1/authorize"), { email: email, password: password }).catch((err) => {
|
|
51
|
+
throw err;
|
|
52
|
+
});
|
|
53
|
+
// tslint-disable: no-string-literal
|
|
54
|
+
const token = { token: resp.headers.authorization };
|
|
55
|
+
return token;
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* authenticateReturnUser against the identity provider with a given email and password.
|
|
59
|
+
* @param email
|
|
60
|
+
* @param password
|
|
61
|
+
* @returns User object
|
|
62
|
+
*/
|
|
63
|
+
this.authenticateReturnUser = (email, password) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const resp = yield axios_1.default.post(this.getEndpoint("/v1/authorize"), { email: email, password: password }).catch((err) => {
|
|
65
|
+
throw err;
|
|
66
|
+
});
|
|
67
|
+
return resp.data;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
getEndpoint(endpoint) {
|
|
71
|
+
return `${this.opts.api}/api/account${endpoint}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.default = IDP;
|
package/package.json
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hcloud-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "hcloud platform sdk",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "mocha -r ts-node/register test/**/*.test.ts",
|
|
9
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
10
|
-
"lint": "tslint -p tsconfig.json",
|
|
11
|
-
"build": "tsc"
|
|
12
|
-
},
|
|
13
7
|
"repository": {
|
|
14
8
|
"type": "git",
|
|
15
9
|
"url": "git+https://github.com/moovit-sp-gmbh/hcloud-sdk-js.git"
|
|
@@ -18,7 +12,7 @@
|
|
|
18
12
|
"hcloud",
|
|
19
13
|
"sdk"
|
|
20
14
|
],
|
|
21
|
-
"license": "
|
|
15
|
+
"license": "MIT",
|
|
22
16
|
"bugs": {
|
|
23
17
|
"url": "https://github.com/moovit-sp-gmbh/hcloud-sdk-js/issues"
|
|
24
18
|
},
|
|
@@ -27,15 +21,30 @@
|
|
|
27
21
|
"devDependencies": {
|
|
28
22
|
"@types/chai": "^4.3.1",
|
|
29
23
|
"@types/mocha": "^9.1.1",
|
|
24
|
+
"@types/uuid": "^8.3.4",
|
|
30
25
|
"chai": "^4.3.6",
|
|
31
26
|
"mocha": "^10.0.0",
|
|
32
27
|
"prettier": "^2.6.2",
|
|
33
28
|
"ts-node": "^10.8.0",
|
|
34
29
|
"tslint": "^6.1.3",
|
|
35
30
|
"tslint-config-prettier": "^1.18.0",
|
|
36
|
-
"typescript": "^4.7.2"
|
|
31
|
+
"typescript": "^4.7.2",
|
|
32
|
+
"uuid": "^8.3.2"
|
|
37
33
|
},
|
|
38
34
|
"dependencies": {
|
|
39
|
-
"axios": "^0.27.2"
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
"axios": "^0.27.2",
|
|
36
|
+
"dayjs": "^1.11.3",
|
|
37
|
+
"vuepress": "^1.9.7",
|
|
38
|
+
"vuepress-theme-default-prefers-color-scheme": "^2.0.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"test": "mocha -r ts-node/register tests/**/*.test.ts",
|
|
42
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.test.ts\"",
|
|
43
|
+
"lint": "tslint -p tsconfig.json",
|
|
44
|
+
"doc:build": "vuepress build _docs/src",
|
|
45
|
+
"doc:dev": "vuepress dev _docs/src",
|
|
46
|
+
"doc:export": "vuepress export _docs/src",
|
|
47
|
+
"build": "tsc"
|
|
48
|
+
},
|
|
49
|
+
"readme": "# hcloud-sdk\n[](https://opensource.org/licenses/MIT)\n[](https://www.npmjs.com/package/hcloud-sdk)\n"
|
|
50
|
+
}
|
package/hcloud-sdk-0.0.5.tgz
DELETED
|
Binary file
|
package/lib/Axios.d.ts
DELETED
package/lib/Axios.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const axios_1 = require("axios");
|
|
13
|
-
class AxiosService {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.get = (url) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
return axios_1.default.get(url);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.default = AxiosService;
|
package/lib/IDP.d.ts
DELETED
package/lib/IDP.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const hcloud_1 = require("./hcloud");
|
|
13
|
-
class IDPService extends hcloud_1.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.authenticate = () => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
// const resp = await this.axios.get('https://google.com');
|
|
18
|
-
return this.opts.api;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.default = IDPService;
|