@near-mobile/connector 0.0.3 → 0.0.4
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/chunk-2P3A4VVY.js +37 -0
- package/dist/chunk-CC4VKGDC.mjs +37 -0
- package/dist/chunk-MLBWBY57.js +2577 -0
- package/dist/chunk-YAMG4CQQ.mjs +2577 -0
- package/dist/config.js +1 -1
- package/dist/config.mjs +1 -1
- package/dist/connector.js +3 -3
- package/dist/connector.mjs +2 -2
- package/dist/index.js +3 -3
- package/dist/index.mjs +2 -2
- package/dist/main.js +3 -3
- package/dist/main.mjs +2 -2
- package/dist/strategies/qr-code/index.js +1 -1
- package/dist/strategies/qr-code/index.mjs +1 -1
- package/dist/strategies/qr-code/qr-code.config.js +1 -1
- package/dist/strategies/qr-code/qr-code.config.mjs +1 -1
- package/dist/strategies/qr-code/qr-code.js +1 -1
- package/dist/strategies/qr-code/qr-code.mjs +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +1 -1
- package/package.json +17 -12
- package/dist/chunk-7P6ASYW6.mjs +0 -9
- package/dist/chunk-APKMGRUO.mjs +0 -506
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-ZZJKEHX6.js +0 -506
package/dist/chunk-APKMGRUO.mjs
DELETED
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
nearMobileConnectorConfig
|
|
3
|
-
} from "./chunk-OWBUUQRE.mjs";
|
|
4
|
-
import {
|
|
5
|
-
__export
|
|
6
|
-
} from "./chunk-7P6ASYW6.mjs";
|
|
7
|
-
|
|
8
|
-
// src/connector.ts
|
|
9
|
-
var connector_exports = {};
|
|
10
|
-
__export(connector_exports, {
|
|
11
|
-
createRequest: () => createRequest,
|
|
12
|
-
getRequest: () => getRequest,
|
|
13
|
-
pollResponse: () => pollResponse
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// ../../shared/connector/src/core/ApiError.ts
|
|
17
|
-
var ApiError = class extends Error {
|
|
18
|
-
url;
|
|
19
|
-
status;
|
|
20
|
-
statusText;
|
|
21
|
-
body;
|
|
22
|
-
request;
|
|
23
|
-
constructor(request2, response, message) {
|
|
24
|
-
super(message);
|
|
25
|
-
this.name = "ApiError";
|
|
26
|
-
this.url = response.url;
|
|
27
|
-
this.status = response.status;
|
|
28
|
-
this.statusText = response.statusText;
|
|
29
|
-
this.body = response.body;
|
|
30
|
-
this.request = request2;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// ../../shared/connector/src/core/CancelablePromise.ts
|
|
35
|
-
var CancelError = class extends Error {
|
|
36
|
-
constructor(message) {
|
|
37
|
-
super(message);
|
|
38
|
-
this.name = "CancelError";
|
|
39
|
-
}
|
|
40
|
-
get isCancelled() {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var CancelablePromise = class {
|
|
45
|
-
#isResolved;
|
|
46
|
-
#isRejected;
|
|
47
|
-
#isCancelled;
|
|
48
|
-
#cancelHandlers;
|
|
49
|
-
#promise;
|
|
50
|
-
#resolve;
|
|
51
|
-
#reject;
|
|
52
|
-
constructor(executor) {
|
|
53
|
-
this.#isResolved = false;
|
|
54
|
-
this.#isRejected = false;
|
|
55
|
-
this.#isCancelled = false;
|
|
56
|
-
this.#cancelHandlers = [];
|
|
57
|
-
this.#promise = new Promise((resolve2, reject) => {
|
|
58
|
-
this.#resolve = resolve2;
|
|
59
|
-
this.#reject = reject;
|
|
60
|
-
const onResolve = (value) => {
|
|
61
|
-
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this.#isResolved = true;
|
|
65
|
-
if (this.#resolve) this.#resolve(value);
|
|
66
|
-
};
|
|
67
|
-
const onReject = (reason) => {
|
|
68
|
-
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
this.#isRejected = true;
|
|
72
|
-
if (this.#reject) this.#reject(reason);
|
|
73
|
-
};
|
|
74
|
-
const onCancel = (cancelHandler) => {
|
|
75
|
-
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.#cancelHandlers.push(cancelHandler);
|
|
79
|
-
};
|
|
80
|
-
Object.defineProperty(onCancel, "isResolved", {
|
|
81
|
-
get: () => this.#isResolved
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(onCancel, "isRejected", {
|
|
84
|
-
get: () => this.#isRejected
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(onCancel, "isCancelled", {
|
|
87
|
-
get: () => this.#isCancelled
|
|
88
|
-
});
|
|
89
|
-
return executor(onResolve, onReject, onCancel);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
get [Symbol.toStringTag]() {
|
|
93
|
-
return "Cancellable Promise";
|
|
94
|
-
}
|
|
95
|
-
then(onFulfilled, onRejected) {
|
|
96
|
-
return this.#promise.then(onFulfilled, onRejected);
|
|
97
|
-
}
|
|
98
|
-
catch(onRejected) {
|
|
99
|
-
return this.#promise.catch(onRejected);
|
|
100
|
-
}
|
|
101
|
-
finally(onFinally) {
|
|
102
|
-
return this.#promise.finally(onFinally);
|
|
103
|
-
}
|
|
104
|
-
cancel() {
|
|
105
|
-
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
this.#isCancelled = true;
|
|
109
|
-
if (this.#cancelHandlers.length) {
|
|
110
|
-
try {
|
|
111
|
-
for (const cancelHandler of this.#cancelHandlers) {
|
|
112
|
-
cancelHandler();
|
|
113
|
-
}
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.warn("Cancellation threw an error", error);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
this.#cancelHandlers.length = 0;
|
|
120
|
-
if (this.#reject) this.#reject(new CancelError("Request aborted"));
|
|
121
|
-
}
|
|
122
|
-
get isCancelled() {
|
|
123
|
-
return this.#isCancelled;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
// ../../shared/connector/src/core/OpenAPI.ts
|
|
128
|
-
var OpenAPI = {
|
|
129
|
-
BASE: "",
|
|
130
|
-
VERSION: "0.0.1",
|
|
131
|
-
WITH_CREDENTIALS: false,
|
|
132
|
-
CREDENTIALS: "include",
|
|
133
|
-
TOKEN: void 0,
|
|
134
|
-
USERNAME: void 0,
|
|
135
|
-
PASSWORD: void 0,
|
|
136
|
-
HEADERS: void 0,
|
|
137
|
-
ENCODE_PATH: void 0
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// ../../shared/connector/src/core/request.ts
|
|
141
|
-
var isDefined = (value) => {
|
|
142
|
-
return value !== void 0 && value !== null;
|
|
143
|
-
};
|
|
144
|
-
var isString = (value) => {
|
|
145
|
-
return typeof value === "string";
|
|
146
|
-
};
|
|
147
|
-
var isStringWithValue = (value) => {
|
|
148
|
-
return isString(value) && value !== "";
|
|
149
|
-
};
|
|
150
|
-
var isBlob = (value) => {
|
|
151
|
-
return typeof value === "object" && typeof value.type === "string" && typeof value.stream === "function" && typeof value.arrayBuffer === "function" && typeof value.constructor === "function" && typeof value.constructor.name === "string" && /^(Blob|File)$/.test(value.constructor.name) && /^(Blob|File)$/.test(value[Symbol.toStringTag]);
|
|
152
|
-
};
|
|
153
|
-
var isFormData = (value) => {
|
|
154
|
-
return value instanceof FormData;
|
|
155
|
-
};
|
|
156
|
-
var base64 = (str) => {
|
|
157
|
-
try {
|
|
158
|
-
return btoa(str);
|
|
159
|
-
} catch (err) {
|
|
160
|
-
return Buffer.from(str).toString("base64");
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
var getQueryString = (params) => {
|
|
164
|
-
const qs = [];
|
|
165
|
-
const append = (key, value) => {
|
|
166
|
-
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
167
|
-
};
|
|
168
|
-
const process = (key, value) => {
|
|
169
|
-
if (isDefined(value)) {
|
|
170
|
-
if (Array.isArray(value)) {
|
|
171
|
-
value.forEach((v) => {
|
|
172
|
-
process(key, v);
|
|
173
|
-
});
|
|
174
|
-
} else if (typeof value === "object") {
|
|
175
|
-
Object.entries(value).forEach(([k, v]) => {
|
|
176
|
-
process(`${key}[${k}]`, v);
|
|
177
|
-
});
|
|
178
|
-
} else {
|
|
179
|
-
append(key, value);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
184
|
-
process(key, value);
|
|
185
|
-
});
|
|
186
|
-
if (qs.length > 0) {
|
|
187
|
-
return `?${qs.join("&")}`;
|
|
188
|
-
}
|
|
189
|
-
return "";
|
|
190
|
-
};
|
|
191
|
-
var getUrl = (config, options) => {
|
|
192
|
-
const encoder = config.ENCODE_PATH || encodeURI;
|
|
193
|
-
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
194
|
-
if (options.path?.hasOwnProperty(group)) {
|
|
195
|
-
return encoder(String(options.path[group]));
|
|
196
|
-
}
|
|
197
|
-
return substring;
|
|
198
|
-
});
|
|
199
|
-
const url = `${config.BASE}${path}`;
|
|
200
|
-
if (options.query) {
|
|
201
|
-
return `${url}${getQueryString(options.query)}`;
|
|
202
|
-
}
|
|
203
|
-
return url;
|
|
204
|
-
};
|
|
205
|
-
var getFormData = (options) => {
|
|
206
|
-
if (options.formData) {
|
|
207
|
-
const formData = new FormData();
|
|
208
|
-
const process = (key, value) => {
|
|
209
|
-
if (isString(value) || isBlob(value)) {
|
|
210
|
-
formData.append(key, value);
|
|
211
|
-
} else {
|
|
212
|
-
formData.append(key, JSON.stringify(value));
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
|
|
216
|
-
if (Array.isArray(value)) {
|
|
217
|
-
value.forEach((v) => process(key, v));
|
|
218
|
-
} else {
|
|
219
|
-
process(key, value);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
return formData;
|
|
223
|
-
}
|
|
224
|
-
return void 0;
|
|
225
|
-
};
|
|
226
|
-
var resolve = async (options, resolver) => {
|
|
227
|
-
if (typeof resolver === "function") {
|
|
228
|
-
return resolver(options);
|
|
229
|
-
}
|
|
230
|
-
return resolver;
|
|
231
|
-
};
|
|
232
|
-
var getHeaders = async (config, options) => {
|
|
233
|
-
const [token, username, password, additionalHeaders] = await Promise.all([
|
|
234
|
-
resolve(options, config.TOKEN),
|
|
235
|
-
resolve(options, config.USERNAME),
|
|
236
|
-
resolve(options, config.PASSWORD),
|
|
237
|
-
resolve(options, config.HEADERS)
|
|
238
|
-
]);
|
|
239
|
-
const headers = Object.entries({
|
|
240
|
-
Accept: "application/json",
|
|
241
|
-
...additionalHeaders,
|
|
242
|
-
...options.headers
|
|
243
|
-
}).filter(([_, value]) => isDefined(value)).reduce((headers2, [key, value]) => ({
|
|
244
|
-
...headers2,
|
|
245
|
-
[key]: String(value)
|
|
246
|
-
}), {});
|
|
247
|
-
if (isStringWithValue(token)) {
|
|
248
|
-
headers["Authorization"] = `Bearer ${token}`;
|
|
249
|
-
}
|
|
250
|
-
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
251
|
-
const credentials = base64(`${username}:${password}`);
|
|
252
|
-
headers["Authorization"] = `Basic ${credentials}`;
|
|
253
|
-
}
|
|
254
|
-
if (options.body !== void 0) {
|
|
255
|
-
if (options.mediaType) {
|
|
256
|
-
headers["Content-Type"] = options.mediaType;
|
|
257
|
-
} else if (isBlob(options.body)) {
|
|
258
|
-
headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
259
|
-
} else if (isString(options.body)) {
|
|
260
|
-
headers["Content-Type"] = "text/plain";
|
|
261
|
-
} else if (!isFormData(options.body)) {
|
|
262
|
-
headers["Content-Type"] = "application/json";
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return new Headers(headers);
|
|
266
|
-
};
|
|
267
|
-
var getRequestBody = (options) => {
|
|
268
|
-
if (options.body !== void 0) {
|
|
269
|
-
if (options.mediaType?.includes("/json")) {
|
|
270
|
-
return JSON.stringify(options.body);
|
|
271
|
-
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
272
|
-
return options.body;
|
|
273
|
-
} else {
|
|
274
|
-
return JSON.stringify(options.body);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return void 0;
|
|
278
|
-
};
|
|
279
|
-
var sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
280
|
-
const controller = new AbortController();
|
|
281
|
-
const request2 = {
|
|
282
|
-
headers,
|
|
283
|
-
body: body ?? formData,
|
|
284
|
-
method: options.method,
|
|
285
|
-
signal: controller.signal
|
|
286
|
-
};
|
|
287
|
-
if (config.WITH_CREDENTIALS) {
|
|
288
|
-
request2.credentials = config.CREDENTIALS;
|
|
289
|
-
}
|
|
290
|
-
onCancel(() => controller.abort());
|
|
291
|
-
return await fetch(url, request2);
|
|
292
|
-
};
|
|
293
|
-
var getResponseHeader = (response, responseHeader) => {
|
|
294
|
-
if (responseHeader) {
|
|
295
|
-
const content = response.headers.get(responseHeader);
|
|
296
|
-
if (isString(content)) {
|
|
297
|
-
return content;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return void 0;
|
|
301
|
-
};
|
|
302
|
-
var getResponseBody = async (response) => {
|
|
303
|
-
if (response.status !== 204) {
|
|
304
|
-
try {
|
|
305
|
-
const contentType = response.headers.get("Content-Type");
|
|
306
|
-
if (contentType) {
|
|
307
|
-
const jsonTypes = ["application/json", "application/problem+json"];
|
|
308
|
-
const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
|
|
309
|
-
if (isJSON) {
|
|
310
|
-
return await response.json();
|
|
311
|
-
} else {
|
|
312
|
-
return await response.text();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
} catch (error) {
|
|
316
|
-
console.error(error);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return void 0;
|
|
320
|
-
};
|
|
321
|
-
var catchErrorCodes = (options, result) => {
|
|
322
|
-
const errors = {
|
|
323
|
-
400: "Bad Request",
|
|
324
|
-
401: "Unauthorized",
|
|
325
|
-
403: "Forbidden",
|
|
326
|
-
404: "Not Found",
|
|
327
|
-
500: "Internal Server Error",
|
|
328
|
-
502: "Bad Gateway",
|
|
329
|
-
503: "Service Unavailable",
|
|
330
|
-
...options.errors
|
|
331
|
-
};
|
|
332
|
-
const error = errors[result.status];
|
|
333
|
-
if (error) {
|
|
334
|
-
throw new ApiError(options, result, error);
|
|
335
|
-
}
|
|
336
|
-
if (!result.ok) {
|
|
337
|
-
const errorStatus = result.status ?? "unknown";
|
|
338
|
-
const errorStatusText = result.statusText ?? "unknown";
|
|
339
|
-
const errorBody = (() => {
|
|
340
|
-
try {
|
|
341
|
-
return JSON.stringify(result.body, null, 2);
|
|
342
|
-
} catch (e) {
|
|
343
|
-
return void 0;
|
|
344
|
-
}
|
|
345
|
-
})();
|
|
346
|
-
throw new ApiError(
|
|
347
|
-
options,
|
|
348
|
-
result,
|
|
349
|
-
`Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
var request = (config, options) => {
|
|
354
|
-
return new CancelablePromise(async (resolve2, reject, onCancel) => {
|
|
355
|
-
try {
|
|
356
|
-
const url = getUrl(config, options);
|
|
357
|
-
const formData = getFormData(options);
|
|
358
|
-
const body = getRequestBody(options);
|
|
359
|
-
const headers = await getHeaders(config, options);
|
|
360
|
-
if (!onCancel.isCancelled) {
|
|
361
|
-
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
362
|
-
const responseBody = await getResponseBody(response);
|
|
363
|
-
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
364
|
-
const result = {
|
|
365
|
-
url,
|
|
366
|
-
ok: response.ok,
|
|
367
|
-
status: response.status,
|
|
368
|
-
statusText: response.statusText,
|
|
369
|
-
body: responseHeader ?? responseBody
|
|
370
|
-
};
|
|
371
|
-
catchErrorCodes(options, result);
|
|
372
|
-
resolve2(result.body);
|
|
373
|
-
}
|
|
374
|
-
} catch (error) {
|
|
375
|
-
reject(error);
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
// ../../shared/connector/src/services/RequestApi.ts
|
|
381
|
-
var RequestApi = class {
|
|
382
|
-
/**
|
|
383
|
-
* @param requestBody
|
|
384
|
-
* @returns ConnectorRequestDto
|
|
385
|
-
* @throws ApiError
|
|
386
|
-
*/
|
|
387
|
-
static createRequest(requestBody) {
|
|
388
|
-
return request(OpenAPI, {
|
|
389
|
-
method: "POST",
|
|
390
|
-
url: "/connector/request",
|
|
391
|
-
body: requestBody,
|
|
392
|
-
mediaType: "application/json"
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* @param id
|
|
397
|
-
* @returns ConnectorRequestDto
|
|
398
|
-
* @throws ApiError
|
|
399
|
-
*/
|
|
400
|
-
static getRequest(id) {
|
|
401
|
-
return request(OpenAPI, {
|
|
402
|
-
method: "GET",
|
|
403
|
-
url: "/connector/request/{id}",
|
|
404
|
-
path: {
|
|
405
|
-
"id": id
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* @param id
|
|
411
|
-
* @param requestBody
|
|
412
|
-
* @returns any
|
|
413
|
-
* @throws ApiError
|
|
414
|
-
*/
|
|
415
|
-
static createResponse(id, requestBody) {
|
|
416
|
-
return request(OpenAPI, {
|
|
417
|
-
method: "PUT",
|
|
418
|
-
url: "/connector/request/{id}/response",
|
|
419
|
-
path: {
|
|
420
|
-
"id": id
|
|
421
|
-
},
|
|
422
|
-
body: requestBody,
|
|
423
|
-
mediaType: "application/json"
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
// ../../shared/utils/src/timeout-promise.ts
|
|
429
|
-
var TimeoutPromiseError = class extends Error {
|
|
430
|
-
constructor() {
|
|
431
|
-
super("Promise timeout");
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
async function timeoutPromise(promise, ms) {
|
|
435
|
-
let timeout;
|
|
436
|
-
const rejectedPromise = new Promise((_, reject) => {
|
|
437
|
-
timeout = setTimeout(() => {
|
|
438
|
-
reject(new TimeoutPromiseError());
|
|
439
|
-
}, ms);
|
|
440
|
-
});
|
|
441
|
-
const res = await Promise.race([promise, rejectedPromise]);
|
|
442
|
-
clearTimeout(timeout);
|
|
443
|
-
return res;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// ../../shared/utils/src/polling/polling.ts
|
|
447
|
-
function polling(fn, condition, options = {}) {
|
|
448
|
-
let timeout;
|
|
449
|
-
let abort = false;
|
|
450
|
-
const polling2 = async () => {
|
|
451
|
-
const { delay = 1e3, maxIterations, timeout: timeoutMs } = options;
|
|
452
|
-
let i = 0;
|
|
453
|
-
let promiseDidTimeout = false;
|
|
454
|
-
let res;
|
|
455
|
-
async function resolveFn() {
|
|
456
|
-
promiseDidTimeout = false;
|
|
457
|
-
try {
|
|
458
|
-
return await (timeoutMs !== void 0 ? timeoutPromise(fn(), timeoutMs) : fn());
|
|
459
|
-
} catch (e) {
|
|
460
|
-
if (e instanceof TimeoutPromiseError) promiseDidTimeout = true;
|
|
461
|
-
else throw e;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
res = await resolveFn();
|
|
465
|
-
while (!abort && (promiseDidTimeout || condition(res))) {
|
|
466
|
-
if (i === maxIterations) throw new Error("Polling executed the maximum number iterations");
|
|
467
|
-
await new Promise((resolve2) => {
|
|
468
|
-
timeout = setTimeout(async () => {
|
|
469
|
-
i++;
|
|
470
|
-
res = await resolveFn();
|
|
471
|
-
resolve2();
|
|
472
|
-
}, delay);
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
return res;
|
|
476
|
-
};
|
|
477
|
-
const result = polling2();
|
|
478
|
-
result.abort = () => {
|
|
479
|
-
abort = true;
|
|
480
|
-
clearTimeout(timeout);
|
|
481
|
-
};
|
|
482
|
-
return result;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// src/connector.ts
|
|
486
|
-
OpenAPI.BASE = nearMobileConnectorConfig.apiUrl;
|
|
487
|
-
var createRequest = RequestApi.createRequest;
|
|
488
|
-
var getRequest = RequestApi.getRequest;
|
|
489
|
-
function pollResponse(id, options = {}) {
|
|
490
|
-
const mergedOptions = {
|
|
491
|
-
...nearMobileConnectorConfig.responsePolling,
|
|
492
|
-
...options
|
|
493
|
-
};
|
|
494
|
-
return polling(
|
|
495
|
-
async () => getRequest(id),
|
|
496
|
-
(request2) => request2.status === "pending",
|
|
497
|
-
mergedOptions
|
|
498
|
-
);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
export {
|
|
502
|
-
createRequest,
|
|
503
|
-
getRequest,
|
|
504
|
-
pollResponse,
|
|
505
|
-
connector_exports
|
|
506
|
-
};
|
package/dist/chunk-MLKGABMK.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.__export = __export;
|