@edgeiq/edgeiq-api-js 1.0.0 → 1.0.1
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/README.md +2 -21
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.js +52 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/core/handleResponseError.js +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,33 +42,14 @@ $ npm test
|
|
|
42
42
|
|
|
43
43
|
## Publishing:
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
So before publishing run:
|
|
47
|
-
```
|
|
48
|
-
$ npm login --registry=https://npm.fury.io/edgeiq/
|
|
49
|
-
```
|
|
50
|
-
Use your gemfuty credentials.
|
|
51
|
-
Once this is done, run:
|
|
45
|
+
Run:
|
|
52
46
|
```
|
|
53
47
|
$ npm publish
|
|
54
48
|
```
|
|
55
49
|
|
|
56
|
-
And the package will be uploaded.
|
|
57
|
-
To make sure it has been uploaded correctly, go to: `https://manage.fury.io/dashboard/edgeiq` and look for the package.
|
|
58
|
-
|
|
59
50
|
## How to use it
|
|
60
|
-
1. Add `.npmrc` in the consuming project and add this line:
|
|
61
|
-
`@edgeiq:registry=https://npm-proxy.fury.io/edgeiq/`
|
|
62
|
-
|
|
63
|
-
2. Login via npm CLI with Gemfury credentials.
|
|
64
|
-
`npm login --registry https://npm-proxy.fury.io/edgeiq/`
|
|
65
|
-
|
|
66
|
-
This will add or edit the users global .npmrc file located in their home directory with this line:
|
|
67
|
-
|
|
68
|
-
`# ~/.npmrc`
|
|
69
|
-
`//npm-proxy.fury.io/organization/:_authToken=${SECRET_TOKEN}`
|
|
70
51
|
|
|
71
|
-
|
|
52
|
+
Install the dependency via the command line.
|
|
72
53
|
`npm install --save @edgeiq/edgeiq-api-js`
|
|
73
54
|
# OR
|
|
74
55
|
`yarn add @edgeiq/edgeiq-api-js`
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ import { EIQLoginUser, User } from '../users/models';
|
|
|
2
2
|
declare const Authentication: {
|
|
3
3
|
login: (user: string, password: string) => Promise<EIQLoginUser>;
|
|
4
4
|
me: () => Promise<User>;
|
|
5
|
+
passwordResetRequest: (email: string, url: string, subject: string, greeting: string) => Promise<boolean>;
|
|
6
|
+
passwordReset: (token: string, password: string, password_confirmation: string) => Promise<boolean>;
|
|
5
7
|
};
|
|
6
8
|
export { Authentication };
|
package/dist/auth/index.js
CHANGED
|
@@ -91,5 +91,57 @@ var Authentication = {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
}); },
|
|
94
|
+
passwordResetRequest: function (email, url, subject, greeting) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
+
var axios, error_3;
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
switch (_a.label) {
|
|
98
|
+
case 0:
|
|
99
|
+
_a.trys.push([0, 2, , 3]);
|
|
100
|
+
__1.EdgeIQAPI.logAction("Requesting to reset password for user with email: " + email);
|
|
101
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
102
|
+
return [4, axios.post(constants_1.Endpoints.passwordResetRequest, JSON.stringify({
|
|
103
|
+
email: email,
|
|
104
|
+
url: url,
|
|
105
|
+
subject: subject,
|
|
106
|
+
greeting: greeting,
|
|
107
|
+
}))];
|
|
108
|
+
case 1:
|
|
109
|
+
_a.sent();
|
|
110
|
+
return [2, true];
|
|
111
|
+
case 2:
|
|
112
|
+
error_3 = _a.sent();
|
|
113
|
+
if ((0, helpers_1.isApiError)(error_3)) {
|
|
114
|
+
throw error_3;
|
|
115
|
+
}
|
|
116
|
+
throw error_3;
|
|
117
|
+
case 3: return [2];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}); },
|
|
121
|
+
passwordReset: function (token, password, password_confirmation) { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
+
var axios, error_4;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
_a.trys.push([0, 2, , 3]);
|
|
127
|
+
__1.EdgeIQAPI.logAction("Resetting password");
|
|
128
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
129
|
+
return [4, axios.post(constants_1.Endpoints.passwordReset + "/" + token, JSON.stringify({
|
|
130
|
+
password: password,
|
|
131
|
+
password_confirmation: password_confirmation,
|
|
132
|
+
}))];
|
|
133
|
+
case 1:
|
|
134
|
+
_a.sent();
|
|
135
|
+
return [2, true];
|
|
136
|
+
case 2:
|
|
137
|
+
error_4 = _a.sent();
|
|
138
|
+
if ((0, helpers_1.isApiError)(error_4)) {
|
|
139
|
+
throw error_4;
|
|
140
|
+
}
|
|
141
|
+
throw error_4;
|
|
142
|
+
case 3: return [2];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); },
|
|
94
146
|
};
|
|
95
147
|
exports.Authentication = Authentication;
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -99,6 +99,7 @@ exports.Endpoints = {
|
|
|
99
99
|
me: 'me',
|
|
100
100
|
login: exports.BaseEndpoints.auth + "/authenticate",
|
|
101
101
|
apiTokenReset: exports.BaseEndpoints.auth + "/api_token_reset",
|
|
102
|
+
passwordResetRequest: exports.BaseEndpoints.auth + "/password_reset_request",
|
|
102
103
|
passwordReset: exports.BaseEndpoints.auth + "/password_reset",
|
|
103
104
|
bulkResponse: "" + exports.BaseEndpoints.bulkResponse,
|
|
104
105
|
command: "" + exports.BaseEndpoints.command,
|
|
@@ -8,13 +8,15 @@ var handleResponseError = function (error) {
|
|
|
8
8
|
}
|
|
9
9
|
var status = error.response.status;
|
|
10
10
|
var url = error.response.request.path;
|
|
11
|
-
if ((status === 401 || status === 404) &&
|
|
11
|
+
if ((status === 401 || status === 404) &&
|
|
12
|
+
url &&
|
|
13
|
+
url.indexOf(constants_1.Endpoints.login) >= 0) {
|
|
12
14
|
return handleCredentials(error);
|
|
13
15
|
}
|
|
14
|
-
if (status === 401 && url.indexOf(constants_1.Endpoints.apiTokenReset) >= 0) {
|
|
16
|
+
if (status === 401 && url && url.indexOf(constants_1.Endpoints.apiTokenReset) >= 0) {
|
|
15
17
|
return handleCredentials(error);
|
|
16
18
|
}
|
|
17
|
-
if (status === 400 && url.indexOf(constants_1.Endpoints.passwordReset) >= 0) {
|
|
19
|
+
if (status === 400 && url && url.indexOf(constants_1.Endpoints.passwordReset) >= 0) {
|
|
18
20
|
return handlePasswordReset(error);
|
|
19
21
|
}
|
|
20
22
|
if (status === 401) {
|