hcloud-sdk 0.0.7 → 0.0.10
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 +2 -0
- package/index.d.ts +1 -1
- package/lib/base.d.ts +0 -2
- package/lib/base.js +0 -2
- package/lib/dto/IDP.d.ts +0 -4
- package/lib/hcloud.d.ts +4 -3
- package/lib/hcloud.js +6 -0
- package/lib/service/High5.d.ts +1 -1
- package/lib/service/IDP.d.ts +3 -3
- package/lib/service/IDP.js +5 -11
- package/package.json +18 -11
- package/lib/Axios.d.ts +0 -5
- package/lib/Axios.js +0 -23
- package/lib/common.d.ts +0 -9
- package/lib/common.js +0 -11
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
CHANGED
package/lib/base.js
CHANGED
package/lib/dto/IDP.d.ts
CHANGED
package/lib/hcloud.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import base, { Options } from
|
|
2
|
-
import IDPService from
|
|
3
|
-
import High5Service from
|
|
1
|
+
import base, { Options } from "./base";
|
|
2
|
+
import IDPService from "./service/IDP";
|
|
3
|
+
import High5Service from "./service/High5";
|
|
4
4
|
export default class hcloud extends base {
|
|
5
5
|
IDP: IDPService;
|
|
6
6
|
High5: High5Service;
|
|
7
7
|
constructor(opts: Options);
|
|
8
|
+
setAuthToken(token: string): void;
|
|
8
9
|
}
|
package/lib/hcloud.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const base_1 = require("./base");
|
|
4
4
|
const IDP_1 = require("./service/IDP");
|
|
5
5
|
const High5_1 = require("./service/High5");
|
|
6
|
+
const axios_1 = require("axios");
|
|
6
7
|
// tslint:disable-next-line
|
|
7
8
|
class hcloud extends base_1.default {
|
|
8
9
|
constructor(opts) {
|
|
@@ -10,5 +11,10 @@ class hcloud extends base_1.default {
|
|
|
10
11
|
this.IDP = new IDP_1.default(this.opts);
|
|
11
12
|
this.High5 = new High5_1.default(this.opts);
|
|
12
13
|
}
|
|
14
|
+
setAuthToken(token) {
|
|
15
|
+
axios_1.default.defaults.headers.common = {
|
|
16
|
+
Authorization: token,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
13
19
|
}
|
|
14
20
|
exports.default = hcloud;
|
package/lib/service/High5.d.ts
CHANGED
package/lib/service/IDP.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import base from
|
|
2
|
-
import { Token, User } from
|
|
1
|
+
import base from "../base";
|
|
2
|
+
import { Token, User } from "../dto/IDP";
|
|
3
3
|
export default class IDP extends base {
|
|
4
4
|
/**
|
|
5
5
|
* Authorize validates a token
|
|
6
6
|
* @param token
|
|
7
7
|
* @returns User object
|
|
8
8
|
*/
|
|
9
|
-
authorize: (
|
|
9
|
+
authorize: () => Promise<User>;
|
|
10
10
|
/**
|
|
11
11
|
* Register against the identity provider
|
|
12
12
|
* @param name
|
package/lib/service/IDP.js
CHANGED
|
@@ -19,10 +19,8 @@ class IDP extends base_1.default {
|
|
|
19
19
|
* @param token
|
|
20
20
|
* @returns User object
|
|
21
21
|
*/
|
|
22
|
-
this.authorize = (
|
|
23
|
-
const resp = yield axios_1.default
|
|
24
|
-
.post(this.getEndpoint('/v1/authenticate'), {}, { headers: { Authorization: token } })
|
|
25
|
-
.catch((err) => {
|
|
22
|
+
this.authorize = () => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const resp = yield axios_1.default.post(this.getEndpoint("/v1/authorize"), {}, {}).catch((err) => {
|
|
26
24
|
throw err;
|
|
27
25
|
});
|
|
28
26
|
return resp.data;
|
|
@@ -36,7 +34,7 @@ class IDP extends base_1.default {
|
|
|
36
34
|
*/
|
|
37
35
|
this.register = (name, email, password) => __awaiter(this, void 0, void 0, function* () {
|
|
38
36
|
const resp = yield axios_1.default
|
|
39
|
-
.post(this.getEndpoint(
|
|
37
|
+
.post(this.getEndpoint("/v1/registration"), { name: name, email: email, password: password })
|
|
40
38
|
.catch((err) => {
|
|
41
39
|
throw err;
|
|
42
40
|
});
|
|
@@ -49,9 +47,7 @@ class IDP extends base_1.default {
|
|
|
49
47
|
* @returns Bearer Token
|
|
50
48
|
*/
|
|
51
49
|
this.authenticate = (email, password) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const resp = yield axios_1.default
|
|
53
|
-
.post(this.getEndpoint('/v1/authorize'), { email: email, password: password })
|
|
54
|
-
.catch((err) => {
|
|
50
|
+
const resp = yield axios_1.default.post(this.getEndpoint("/v1/authenticate"), { email: email, password: password }).catch((err) => {
|
|
55
51
|
throw err;
|
|
56
52
|
});
|
|
57
53
|
// tslint-disable: no-string-literal
|
|
@@ -65,9 +61,7 @@ class IDP extends base_1.default {
|
|
|
65
61
|
* @returns User object
|
|
66
62
|
*/
|
|
67
63
|
this.authenticateReturnUser = (email, password) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const resp = yield axios_1.default
|
|
69
|
-
.post(this.getEndpoint('/v1/authorize'), { email: email, password: password })
|
|
70
|
-
.catch((err) => {
|
|
64
|
+
const resp = yield axios_1.default.post(this.getEndpoint("/v1/authenticate"), { email: email, password: password }).catch((err) => {
|
|
71
65
|
throw err;
|
|
72
66
|
});
|
|
73
67
|
return resp.data;
|
package/package.json
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hcloud-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
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
|
},
|
|
@@ -38,6 +32,19 @@
|
|
|
38
32
|
"uuid": "^8.3.2"
|
|
39
33
|
},
|
|
40
34
|
"dependencies": {
|
|
41
|
-
"axios": "^0.27.2"
|
|
42
|
-
|
|
43
|
-
|
|
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/lib/Axios.d.ts
DELETED
package/lib/Axios.js
DELETED
|
@@ -1,23 +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
|
-
this.post = (url, body) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
return axios_1.default.post(url, body, {});
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.default = AxiosService;
|
package/lib/common.d.ts
DELETED
package/lib/common.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Axios_1 = require("./Axios");
|
|
4
|
-
// tslint:disable-next-line
|
|
5
|
-
class common {
|
|
6
|
-
constructor(opts) {
|
|
7
|
-
this.opts = opts;
|
|
8
|
-
this.axios = new Axios_1.default();
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = common;
|