@gen3/core 0.10.59 → 0.10.60
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/esm/index.js
CHANGED
|
@@ -80,59 +80,7 @@ const FILE_DELIMITERS = {
|
|
|
80
80
|
headers,
|
|
81
81
|
body
|
|
82
82
|
});
|
|
83
|
-
}; /*
|
|
84
|
-
interface DownloadFromFenceParameters {
|
|
85
|
-
guid: string;
|
|
86
|
-
method?: 'GET' | 'POST';
|
|
87
|
-
onStart?: () => void; // function to call when the download starts
|
|
88
|
-
onDone?: (blob: Blob) => void; // function to call when the download is done
|
|
89
|
-
onError?: (error: Error) => void; // function to call when the download fails
|
|
90
|
-
onAbort?: () => void; // function to call when the download is aborted
|
|
91
|
-
signal?: AbortSignal; // AbortSignal to use for the request
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
export const fetchFencePresignedURL = async ({
|
|
96
|
-
guid,
|
|
97
|
-
method = 'GET',
|
|
98
|
-
onAbort = () => null,
|
|
99
|
-
signal = undefined,
|
|
100
|
-
}: DownloadFromFenceParameters) => {
|
|
101
|
-
const csrfToken = selectCSRFToken(coreStore.getState());
|
|
102
|
-
|
|
103
|
-
const headers = new Headers();
|
|
104
|
-
headers.set('Content-Type', 'application/json');
|
|
105
|
-
if (csrfToken) headers.set('X-CSRF-Token', csrfToken);
|
|
106
|
-
let accessToken = undefined;
|
|
107
|
-
if (process.env.NODE_ENV === 'development') {
|
|
108
|
-
// NOTE: This cookie can only be accessed from the client side
|
|
109
|
-
// in development mode. Otherwise, the cookie is set as httpOnly
|
|
110
|
-
accessToken = getCookie('credentials_token');
|
|
111
|
-
}
|
|
112
|
-
if (csrfToken) headers.set('X-CSRF-Token', csrfToken);
|
|
113
|
-
if (accessToken) headers.set('Authorization', `Bearer ${accessToken}`);
|
|
114
|
-
const url = prepareUrl(`${GEN3_FENCE_API}/user/download/${guid}`);
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
const response = await fetch(url.toString(), {
|
|
118
|
-
method: method,
|
|
119
|
-
headers: headers,
|
|
120
|
-
...(signal ? { signal: signal } : {}),
|
|
121
|
-
} as RequestInit);
|
|
122
|
-
|
|
123
|
-
const jsonData = await response.json();
|
|
124
|
-
// convert the data to the specified format and return a Blob
|
|
125
|
-
return jsonData;
|
|
126
|
-
} catch (error: any) {
|
|
127
|
-
// Abort is handle as an exception
|
|
128
|
-
if (error.name == 'AbortError') {
|
|
129
|
-
// handle abort()
|
|
130
|
-
onAbort?.();
|
|
131
|
-
}
|
|
132
|
-
throw new Error(error);
|
|
133
|
-
}
|
|
134
83
|
};
|
|
135
|
-
*/
|
|
136
84
|
|
|
137
85
|
const userAuthApi = createApi({
|
|
138
86
|
reducerPath: 'userAuthApi',
|
|
@@ -2371,7 +2319,6 @@ const HTTPErrorMessages = {
|
|
|
2371
2319
|
510: 'Not Extended',
|
|
2372
2320
|
511: 'Network Authentication Required'
|
|
2373
2321
|
};
|
|
2374
|
-
const prepareDownloadUrl = (apiUrl, guid)=>new URL(`${apiUrl}/data/download/${guid}`);
|
|
2375
2322
|
class HTTPError extends Error {
|
|
2376
2323
|
constructor(status, message, responseData){
|
|
2377
2324
|
super(message), this.status = status, this.responseData = responseData;
|
|
@@ -2390,9 +2337,10 @@ const fetchFencePresignedURL = async ({ guid, method = 'GET', onAbort = ()=>null
|
|
|
2390
2337
|
}
|
|
2391
2338
|
if (csrfToken) headers.set('X-CSRF-Token', csrfToken);
|
|
2392
2339
|
if (accessToken) headers.set('Authorization', `Bearer ${accessToken}`);
|
|
2393
|
-
const url = prepareDownloadUrl(`${GEN3_FENCE_API}/user`, guid);
|
|
2340
|
+
// const url = prepareDownloadUrl(`${GEN3_FENCE_API}/user`, guid);
|
|
2341
|
+
const url = `${GEN3_FENCE_API}/user/download/${guid}`;
|
|
2394
2342
|
try {
|
|
2395
|
-
const response = await fetch(url
|
|
2343
|
+
const response = await fetch(url, {
|
|
2396
2344
|
method: method,
|
|
2397
2345
|
headers: headers,
|
|
2398
2346
|
...signal ? {
|