@gen3/core 0.10.59 → 0.10.61
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/dist/cjs/index.js +3 -55
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +3 -55
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -100,59 +100,7 @@ const FILE_DELIMITERS = {
|
|
|
100
100
|
headers,
|
|
101
101
|
body
|
|
102
102
|
});
|
|
103
|
-
}; /*
|
|
104
|
-
interface DownloadFromFenceParameters {
|
|
105
|
-
guid: string;
|
|
106
|
-
method?: 'GET' | 'POST';
|
|
107
|
-
onStart?: () => void; // function to call when the download starts
|
|
108
|
-
onDone?: (blob: Blob) => void; // function to call when the download is done
|
|
109
|
-
onError?: (error: Error) => void; // function to call when the download fails
|
|
110
|
-
onAbort?: () => void; // function to call when the download is aborted
|
|
111
|
-
signal?: AbortSignal; // AbortSignal to use for the request
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
export const fetchFencePresignedURL = async ({
|
|
116
|
-
guid,
|
|
117
|
-
method = 'GET',
|
|
118
|
-
onAbort = () => null,
|
|
119
|
-
signal = undefined,
|
|
120
|
-
}: DownloadFromFenceParameters) => {
|
|
121
|
-
const csrfToken = selectCSRFToken(coreStore.getState());
|
|
122
|
-
|
|
123
|
-
const headers = new Headers();
|
|
124
|
-
headers.set('Content-Type', 'application/json');
|
|
125
|
-
if (csrfToken) headers.set('X-CSRF-Token', csrfToken);
|
|
126
|
-
let accessToken = undefined;
|
|
127
|
-
if (process.env.NODE_ENV === 'development') {
|
|
128
|
-
// NOTE: This cookie can only be accessed from the client side
|
|
129
|
-
// in development mode. Otherwise, the cookie is set as httpOnly
|
|
130
|
-
accessToken = getCookie('credentials_token');
|
|
131
|
-
}
|
|
132
|
-
if (csrfToken) headers.set('X-CSRF-Token', csrfToken);
|
|
133
|
-
if (accessToken) headers.set('Authorization', `Bearer ${accessToken}`);
|
|
134
|
-
const url = prepareUrl(`${GEN3_FENCE_API}/user/download/${guid}`);
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
const response = await fetch(url.toString(), {
|
|
138
|
-
method: method,
|
|
139
|
-
headers: headers,
|
|
140
|
-
...(signal ? { signal: signal } : {}),
|
|
141
|
-
} as RequestInit);
|
|
142
|
-
|
|
143
|
-
const jsonData = await response.json();
|
|
144
|
-
// convert the data to the specified format and return a Blob
|
|
145
|
-
return jsonData;
|
|
146
|
-
} catch (error: any) {
|
|
147
|
-
// Abort is handle as an exception
|
|
148
|
-
if (error.name == 'AbortError') {
|
|
149
|
-
// handle abort()
|
|
150
|
-
onAbort?.();
|
|
151
|
-
}
|
|
152
|
-
throw new Error(error);
|
|
153
|
-
}
|
|
154
103
|
};
|
|
155
|
-
*/
|
|
156
104
|
|
|
157
105
|
const userAuthApi = react.createApi({
|
|
158
106
|
reducerPath: 'userAuthApi',
|
|
@@ -2391,7 +2339,6 @@ const HTTPErrorMessages = {
|
|
|
2391
2339
|
510: 'Not Extended',
|
|
2392
2340
|
511: 'Network Authentication Required'
|
|
2393
2341
|
};
|
|
2394
|
-
const prepareDownloadUrl = (apiUrl, guid)=>new URL(`${apiUrl}/data/download/${guid}`);
|
|
2395
2342
|
class HTTPError extends Error {
|
|
2396
2343
|
constructor(status, message, responseData){
|
|
2397
2344
|
super(message), this.status = status, this.responseData = responseData;
|
|
@@ -2410,9 +2357,10 @@ const fetchFencePresignedURL = async ({ guid, method = 'GET', onAbort = ()=>null
|
|
|
2410
2357
|
}
|
|
2411
2358
|
if (csrfToken) headers.set('X-CSRF-Token', csrfToken);
|
|
2412
2359
|
if (accessToken) headers.set('Authorization', `Bearer ${accessToken}`);
|
|
2413
|
-
const url = prepareDownloadUrl(`${GEN3_FENCE_API}/user`, guid);
|
|
2360
|
+
// const url = prepareDownloadUrl(`${GEN3_FENCE_API}/user`, guid);
|
|
2361
|
+
const url = `${GEN3_FENCE_API}/user/download/${guid}`;
|
|
2414
2362
|
try {
|
|
2415
|
-
const response = await fetch(url
|
|
2363
|
+
const response = await fetch(url, {
|
|
2416
2364
|
method: method,
|
|
2417
2365
|
headers: headers,
|
|
2418
2366
|
...signal ? {
|