react-native-mosquito-transport 0.0.31 → 0.0.32
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/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -283,6 +283,11 @@ interface DocumentError extends ErrorResponse {
|
|
|
283
283
|
|
|
284
284
|
interface FetchHttpConfig {
|
|
285
285
|
retrieval?: GetConfig['retrieval'];
|
|
286
|
+
/**
|
|
287
|
+
* disable sending authentication token along with this request
|
|
288
|
+
*
|
|
289
|
+
* Defaults to true when either `rawApproach` is true or the request url is absolute otherwise false
|
|
290
|
+
*/
|
|
286
291
|
disableAuth?: boolean;
|
|
287
292
|
enableMinimizer?: boolean;
|
|
288
293
|
rawApproach?: boolean;
|
|
@@ -315,7 +320,7 @@ interface WriteConfig {
|
|
|
315
320
|
delivery?: Delievery;
|
|
316
321
|
}
|
|
317
322
|
|
|
318
|
-
type Retrieval = 'sticky' | 'sticky-no-await' | 'sticky-reload' | 'default' | 'cache-no-await' | 'no-cache-no-await' | 'no-cache-await';
|
|
323
|
+
type Retrieval = 'sticky' | 'sticky-no-await' | 'sticky-reload' | 'default' | 'cache-no-await' | 'no-cache-no-await' | 'no-cache-await' | 'cache-await';
|
|
319
324
|
|
|
320
325
|
interface GetConfig {
|
|
321
326
|
excludeFields?: string | string[];
|
|
@@ -48,7 +48,7 @@ export const mfetch = async (input = '', init, config) => {
|
|
|
48
48
|
const { retrieval = RETRIEVAL.DEFAULT, enableMinimizer, rawApproach } = method || {};
|
|
49
49
|
const isLink = Validator.LINK(input);
|
|
50
50
|
const isBaseUrl = isLink || rawApproach;
|
|
51
|
-
const disableAuth = method?.disableAuth
|
|
51
|
+
const disableAuth = method?.disableAuth === undefined ? isBaseUrl : method?.disableAuth;
|
|
52
52
|
const hasBody = body !== undefined;
|
|
53
53
|
const shouldCache = (retrieval !== RETRIEVAL.DEFAULT || (config.disableCache === undefined ? !hasBody : !disableCache)) &&
|
|
54
54
|
![RETRIEVAL.NO_CACHE_NO_AWAIT, RETRIEVAL.NO_CACHE_AWAIT].includes(retrieval);
|
|
@@ -135,7 +135,7 @@ export const mfetch = async (input = '', init, config) => {
|
|
|
135
135
|
if (!disableAuth && await getReachableServer(projectUrl))
|
|
136
136
|
await awaitRefreshToken(projectUrl);
|
|
137
137
|
|
|
138
|
-
const mtoken = Scoped.AuthJWTToken[projectUrl];
|
|
138
|
+
const mtoken = disableAuth ? undefined : Scoped.AuthJWTToken[projectUrl];
|
|
139
139
|
const initType = rawHeader['content-type'];
|
|
140
140
|
const encodeBody = initType === undefined && hasBody && !isBaseUrl;
|
|
141
141
|
|
|
@@ -157,13 +157,13 @@ export const mfetch = async (input = '', init, config) => {
|
|
|
157
157
|
} : encodeBody
|
|
158
158
|
? { 'content-type': 'request/buffer', 'entity-encoded': '1' }
|
|
159
159
|
: {},
|
|
160
|
-
...(
|
|
160
|
+
...(!mtoken || uglified) ? {} : { mtoken }
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
const { ok, type, status, statusText, redirected, url, headers, size } = f;
|
|
164
164
|
const simple = headers.get('simple_error');
|
|
165
165
|
|
|
166
|
-
if (!
|
|
166
|
+
if (!isLink && simple) throw { simpleError: JSON.parse(simple) };
|
|
167
167
|
|
|
168
168
|
const base64 = uglified ?
|
|
169
169
|
Buffer.from(await deserializeE2E(await f.arrayBuffer(), serverE2E_PublicKey, privateKey)).toString('base64') :
|