authscape 1.0.240 → 1.0.243
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/index.js +105 -36
- package/package.json +1 -1
- package/src/services/apiService.js +16 -5
- package/src/services/authService.js +21 -0
package/index.js
CHANGED
|
@@ -2934,7 +2934,10 @@ var apiService = function apiService() {
|
|
|
2934
2934
|
}(),
|
|
2935
2935
|
DownloadFile: function () {
|
|
2936
2936
|
var _DownloadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(url, fileName, completed) {
|
|
2937
|
-
var
|
|
2937
|
+
var method,
|
|
2938
|
+
data,
|
|
2939
|
+
mimeType,
|
|
2940
|
+
passData,
|
|
2938
2941
|
defaultOptions,
|
|
2939
2942
|
options,
|
|
2940
2943
|
response,
|
|
@@ -2942,20 +2945,40 @@ var apiService = function apiService() {
|
|
|
2942
2945
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
2943
2946
|
while (1) switch (_context9.prev = _context9.next) {
|
|
2944
2947
|
case 0:
|
|
2945
|
-
|
|
2946
|
-
|
|
2948
|
+
method = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : "get";
|
|
2949
|
+
data = _args9.length > 4 && _args9[4] !== undefined ? _args9[4] : {};
|
|
2950
|
+
mimeType = _args9.length > 5 && _args9[5] !== undefined ? _args9[5] : "application/octet-stream";
|
|
2951
|
+
passData = _args9.length > 6 && _args9[6] !== undefined ? _args9[6] : false;
|
|
2952
|
+
_context9.prev = 4;
|
|
2947
2953
|
//let defaultOptions = await setupDefaultOptions();
|
|
2948
2954
|
defaultOptions = {};
|
|
2949
2955
|
options = {
|
|
2950
2956
|
responseType: "blob"
|
|
2951
2957
|
};
|
|
2952
|
-
|
|
2958
|
+
response = null;
|
|
2959
|
+
if (!(method == "get")) {
|
|
2960
|
+
_context9.next = 14;
|
|
2961
|
+
break;
|
|
2962
|
+
}
|
|
2963
|
+
_context9.next = 11;
|
|
2953
2964
|
return instance.get(url, _objectSpread(_objectSpread({}, defaultOptions), options));
|
|
2954
|
-
case
|
|
2965
|
+
case 11:
|
|
2955
2966
|
response = _context9.sent;
|
|
2956
|
-
|
|
2967
|
+
_context9.next = 18;
|
|
2968
|
+
break;
|
|
2969
|
+
case 14:
|
|
2970
|
+
if (!(method == "post")) {
|
|
2971
|
+
_context9.next = 18;
|
|
2972
|
+
break;
|
|
2973
|
+
}
|
|
2974
|
+
_context9.next = 17;
|
|
2975
|
+
return instance.post(url, data, _objectSpread(_objectSpread({}, defaultOptions), options));
|
|
2976
|
+
case 17:
|
|
2977
|
+
response = _context9.sent;
|
|
2978
|
+
case 18:
|
|
2979
|
+
if (response != null && response.status === 200) {
|
|
2957
2980
|
if (!passData) {
|
|
2958
|
-
(0, _jsFileDownload["default"])(response.data, fileName);
|
|
2981
|
+
(0, _jsFileDownload["default"])(response.data, fileName, mimeType);
|
|
2959
2982
|
if (completed !== undefined) {
|
|
2960
2983
|
completed();
|
|
2961
2984
|
}
|
|
@@ -2963,20 +2986,20 @@ var apiService = function apiService() {
|
|
|
2963
2986
|
completed(response.data);
|
|
2964
2987
|
}
|
|
2965
2988
|
}
|
|
2966
|
-
_context9.next =
|
|
2989
|
+
_context9.next = 25;
|
|
2967
2990
|
break;
|
|
2968
|
-
case
|
|
2969
|
-
_context9.prev =
|
|
2970
|
-
_context9.t0 = _context9["catch"](
|
|
2991
|
+
case 21:
|
|
2992
|
+
_context9.prev = 21;
|
|
2993
|
+
_context9.t0 = _context9["catch"](4);
|
|
2971
2994
|
console.error(_context9.t0);
|
|
2972
2995
|
if (completed !== undefined) {
|
|
2973
2996
|
completed();
|
|
2974
2997
|
}
|
|
2975
|
-
case
|
|
2998
|
+
case 25:
|
|
2976
2999
|
case "end":
|
|
2977
3000
|
return _context9.stop();
|
|
2978
3001
|
}
|
|
2979
|
-
}, _callee9, null, [[
|
|
3002
|
+
}, _callee9, null, [[4, 21]]);
|
|
2980
3003
|
}));
|
|
2981
3004
|
function DownloadFile(_x10, _x11, _x12) {
|
|
2982
3005
|
return _DownloadFile.apply(this, arguments);
|
|
@@ -3122,8 +3145,54 @@ var authService = function authService() {
|
|
|
3122
3145
|
}
|
|
3123
3146
|
return challenge_from_verifier;
|
|
3124
3147
|
}(),
|
|
3148
|
+
inviteUsers: function () {
|
|
3149
|
+
var _inviteUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(inviteRequests) {
|
|
3150
|
+
var response;
|
|
3151
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3152
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
3153
|
+
case 0:
|
|
3154
|
+
_context2.next = 2;
|
|
3155
|
+
return apiService().post(process.env.authorityUri + "/Invite/InviteUsers", inviteRequests);
|
|
3156
|
+
case 2:
|
|
3157
|
+
response = _context2.sent;
|
|
3158
|
+
return _context2.abrupt("return", response);
|
|
3159
|
+
case 4:
|
|
3160
|
+
case "end":
|
|
3161
|
+
return _context2.stop();
|
|
3162
|
+
}
|
|
3163
|
+
}, _callee2);
|
|
3164
|
+
}));
|
|
3165
|
+
function inviteUsers(_x2) {
|
|
3166
|
+
return _inviteUsers.apply(this, arguments);
|
|
3167
|
+
}
|
|
3168
|
+
return inviteUsers;
|
|
3169
|
+
}(),
|
|
3170
|
+
inviteUser: function () {
|
|
3171
|
+
var _inviteUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(inviteRequest) {
|
|
3172
|
+
var inviteRequests, response;
|
|
3173
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
3174
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
3175
|
+
case 0:
|
|
3176
|
+
inviteRequests = [];
|
|
3177
|
+
inviteRequests.push(inviteRequest);
|
|
3178
|
+
_context3.next = 4;
|
|
3179
|
+
return apiService().post(process.env.authorityUri + "/Invite/InviteUsers", inviteRequests);
|
|
3180
|
+
case 4:
|
|
3181
|
+
response = _context3.sent;
|
|
3182
|
+
return _context3.abrupt("return", response);
|
|
3183
|
+
case 6:
|
|
3184
|
+
case "end":
|
|
3185
|
+
return _context3.stop();
|
|
3186
|
+
}
|
|
3187
|
+
}, _callee3);
|
|
3188
|
+
}));
|
|
3189
|
+
function inviteUser(_x3) {
|
|
3190
|
+
return _inviteUser.apply(this, arguments);
|
|
3191
|
+
}
|
|
3192
|
+
return inviteUser;
|
|
3193
|
+
}(),
|
|
3125
3194
|
login: function () {
|
|
3126
|
-
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3195
|
+
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
3127
3196
|
var redirectUserUri,
|
|
3128
3197
|
dnsRecord,
|
|
3129
3198
|
deviceId,
|
|
@@ -3132,22 +3201,22 @@ var authService = function authService() {
|
|
|
3132
3201
|
challenge,
|
|
3133
3202
|
redirectUri,
|
|
3134
3203
|
loginUri,
|
|
3135
|
-
|
|
3136
|
-
return _regeneratorRuntime().wrap(function
|
|
3137
|
-
while (1) switch (
|
|
3204
|
+
_args4 = arguments;
|
|
3205
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
3206
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
3138
3207
|
case 0:
|
|
3139
|
-
redirectUserUri =
|
|
3140
|
-
dnsRecord =
|
|
3141
|
-
deviceId =
|
|
3208
|
+
redirectUserUri = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : null;
|
|
3209
|
+
dnsRecord = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : null;
|
|
3210
|
+
deviceId = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : null;
|
|
3142
3211
|
state = "1234";
|
|
3143
3212
|
if (redirectUserUri != null) {
|
|
3144
3213
|
localStorage.setItem("redirectUri", redirectUserUri);
|
|
3145
3214
|
}
|
|
3146
3215
|
verifier = authService().generateRandomString();
|
|
3147
|
-
|
|
3216
|
+
_context4.next = 8;
|
|
3148
3217
|
return authService().challenge_from_verifier(verifier);
|
|
3149
3218
|
case 8:
|
|
3150
|
-
challenge =
|
|
3219
|
+
challenge = _context4.sent;
|
|
3151
3220
|
window.localStorage.setItem("verifier", verifier);
|
|
3152
3221
|
redirectUri = window.location.origin + "/signin-oidc";
|
|
3153
3222
|
loginUri = process.env.authorityUri + "/connect/authorize?response_type=code&state=" + state + "&client_id=" + process.env.client_id + "&scope=email%20openid%20offline_access%20profile%20api1&redirect_uri=" + redirectUri + "&code_challenge=" + challenge + "&code_challenge_method=S256";
|
|
@@ -3158,9 +3227,9 @@ var authService = function authService() {
|
|
|
3158
3227
|
window.location.href = loginUri;
|
|
3159
3228
|
case 14:
|
|
3160
3229
|
case "end":
|
|
3161
|
-
return
|
|
3230
|
+
return _context4.stop();
|
|
3162
3231
|
}
|
|
3163
|
-
},
|
|
3232
|
+
}, _callee4);
|
|
3164
3233
|
}));
|
|
3165
3234
|
function login() {
|
|
3166
3235
|
return _login.apply(this, arguments);
|
|
@@ -3181,16 +3250,16 @@ var authService = function authService() {
|
|
|
3181
3250
|
window.location.href = url;
|
|
3182
3251
|
},
|
|
3183
3252
|
manageAccount: function () {
|
|
3184
|
-
var _manageAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3185
|
-
return _regeneratorRuntime().wrap(function
|
|
3186
|
-
while (1) switch (
|
|
3253
|
+
var _manageAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
3254
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
3255
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
3187
3256
|
case 0:
|
|
3188
3257
|
window.location.href = process.env.authorityUri + "/Identity/Account/Manage";
|
|
3189
3258
|
case 1:
|
|
3190
3259
|
case "end":
|
|
3191
|
-
return
|
|
3260
|
+
return _context5.stop();
|
|
3192
3261
|
}
|
|
3193
|
-
},
|
|
3262
|
+
}, _callee5);
|
|
3194
3263
|
}));
|
|
3195
3264
|
function manageAccount() {
|
|
3196
3265
|
return _manageAccount.apply(this, arguments);
|
|
@@ -3198,15 +3267,15 @@ var authService = function authService() {
|
|
|
3198
3267
|
return manageAccount;
|
|
3199
3268
|
}(),
|
|
3200
3269
|
logout: function () {
|
|
3201
|
-
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3270
|
+
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
3202
3271
|
var redirectUri,
|
|
3203
3272
|
domainHost,
|
|
3204
3273
|
AuthUri,
|
|
3205
|
-
|
|
3206
|
-
return _regeneratorRuntime().wrap(function
|
|
3207
|
-
while (1) switch (
|
|
3274
|
+
_args6 = arguments;
|
|
3275
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
3276
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
3208
3277
|
case 0:
|
|
3209
|
-
redirectUri =
|
|
3278
|
+
redirectUri = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : null;
|
|
3210
3279
|
domainHost = window.location.hostname.split('.').slice(-2).join('.');
|
|
3211
3280
|
AuthUri = process.env.authorityUri;
|
|
3212
3281
|
(0, _nookies.destroyCookie)({}, "access_token", {
|
|
@@ -3233,9 +3302,9 @@ var authService = function authService() {
|
|
|
3233
3302
|
}, 500);
|
|
3234
3303
|
case 7:
|
|
3235
3304
|
case "end":
|
|
3236
|
-
return
|
|
3305
|
+
return _context6.stop();
|
|
3237
3306
|
}
|
|
3238
|
-
},
|
|
3307
|
+
}, _callee6);
|
|
3239
3308
|
}));
|
|
3240
3309
|
function logout() {
|
|
3241
3310
|
return _logout.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -229,19 +229,29 @@ export const apiService = (ctx = null) => {
|
|
|
229
229
|
}
|
|
230
230
|
return null;
|
|
231
231
|
},
|
|
232
|
-
DownloadFile: async (url, fileName, completed, passData = false) => {
|
|
233
|
-
|
|
232
|
+
DownloadFile : async (url, fileName, completed, method = "get", data = {}, mimeType = "application/octet-stream", passData = false) => {
|
|
233
|
+
|
|
234
234
|
try
|
|
235
235
|
{
|
|
236
236
|
//let defaultOptions = await setupDefaultOptions();
|
|
237
237
|
let defaultOptions = {};
|
|
238
238
|
let options = { responseType: "blob" };
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
|
|
240
|
+
let response = null;
|
|
241
|
+
if (method == "get")
|
|
242
|
+
{
|
|
243
|
+
response = await instance.get(url, { ...defaultOptions, ...options });
|
|
244
|
+
}
|
|
245
|
+
else if (method == "post")
|
|
246
|
+
{
|
|
247
|
+
response = await instance.post(url, data, { ...defaultOptions, ...options });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (response != null && response.status === 200) {
|
|
241
251
|
|
|
242
252
|
if (!passData)
|
|
243
253
|
{
|
|
244
|
-
fileDownload(response.data, fileName);
|
|
254
|
+
fileDownload(response.data, fileName, mimeType);
|
|
245
255
|
if (completed !== undefined) {
|
|
246
256
|
completed();
|
|
247
257
|
}
|
|
@@ -259,6 +269,7 @@ export const apiService = (ctx = null) => {
|
|
|
259
269
|
completed();
|
|
260
270
|
}
|
|
261
271
|
}
|
|
272
|
+
|
|
262
273
|
}
|
|
263
274
|
}
|
|
264
275
|
}
|
|
@@ -35,6 +35,27 @@ export const authService = () => {
|
|
|
35
35
|
let base64encoded = authService().base64urlencode(hashed);
|
|
36
36
|
return base64encoded;
|
|
37
37
|
},
|
|
38
|
+
inviteUsers: async (inviteRequests) => {
|
|
39
|
+
|
|
40
|
+
let response = await apiService().post(
|
|
41
|
+
process.env.authorityUri + "/Invite/InviteUsers",
|
|
42
|
+
inviteRequests
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return response;
|
|
46
|
+
},
|
|
47
|
+
inviteUser: async (inviteRequest) => {
|
|
48
|
+
|
|
49
|
+
let inviteRequests = [];
|
|
50
|
+
inviteRequests.push(inviteRequest);
|
|
51
|
+
|
|
52
|
+
let response = await apiService().post(
|
|
53
|
+
process.env.authorityUri + "/Invite/InviteUsers",
|
|
54
|
+
inviteRequests
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return response;
|
|
58
|
+
},
|
|
38
59
|
login: async (redirectUserUri = null, dnsRecord = null, deviceId = null) => {
|
|
39
60
|
|
|
40
61
|
let state = "1234";
|