@magic-sdk/react-native-expo 30.4.1-canary.913.16658556087.0 → 30.4.1

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 CHANGED
@@ -1,1487 +1,2 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
-
34
- // node_modules/regenerator-runtime/runtime.js
35
- var require_runtime = __commonJS({
36
- "node_modules/regenerator-runtime/runtime.js"(exports2, module2) {
37
- "use strict";
38
- var runtime = function(exports3) {
39
- "use strict";
40
- var Op = Object.prototype;
41
- var hasOwn = Op.hasOwnProperty;
42
- var undefined2;
43
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
44
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
45
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
46
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
47
- function define(obj, key, value) {
48
- Object.defineProperty(obj, key, {
49
- value,
50
- enumerable: true,
51
- configurable: true,
52
- writable: true
53
- });
54
- return obj[key];
55
- }
56
- try {
57
- define({}, "");
58
- } catch (err) {
59
- define = function(obj, key, value) {
60
- return obj[key] = value;
61
- };
62
- }
63
- function wrap(innerFn, outerFn, self, tryLocsList) {
64
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
65
- var generator = Object.create(protoGenerator.prototype);
66
- var context = new Context(tryLocsList || []);
67
- generator._invoke = makeInvokeMethod(innerFn, self, context);
68
- return generator;
69
- }
70
- exports3.wrap = wrap;
71
- function tryCatch(fn, obj, arg) {
72
- try {
73
- return { type: "normal", arg: fn.call(obj, arg) };
74
- } catch (err) {
75
- return { type: "throw", arg: err };
76
- }
77
- }
78
- var GenStateSuspendedStart = "suspendedStart";
79
- var GenStateSuspendedYield = "suspendedYield";
80
- var GenStateExecuting = "executing";
81
- var GenStateCompleted = "completed";
82
- var ContinueSentinel = {};
83
- function Generator() {
84
- }
85
- function GeneratorFunction() {
86
- }
87
- function GeneratorFunctionPrototype() {
88
- }
89
- var IteratorPrototype = {};
90
- define(IteratorPrototype, iteratorSymbol, function() {
91
- return this;
92
- });
93
- var getProto = Object.getPrototypeOf;
94
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
95
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
96
- IteratorPrototype = NativeIteratorPrototype;
97
- }
98
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
99
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
100
- define(Gp, "constructor", GeneratorFunctionPrototype);
101
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
102
- GeneratorFunction.displayName = define(
103
- GeneratorFunctionPrototype,
104
- toStringTagSymbol,
105
- "GeneratorFunction"
106
- );
107
- function defineIteratorMethods(prototype) {
108
- ["next", "throw", "return"].forEach(function(method) {
109
- define(prototype, method, function(arg) {
110
- return this._invoke(method, arg);
111
- });
112
- });
113
- }
114
- exports3.isGeneratorFunction = function(genFun) {
115
- var ctor = typeof genFun === "function" && genFun.constructor;
116
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
117
- // do is to check its .name property.
118
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
119
- };
120
- exports3.mark = function(genFun) {
121
- if (Object.setPrototypeOf) {
122
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
123
- } else {
124
- genFun.__proto__ = GeneratorFunctionPrototype;
125
- define(genFun, toStringTagSymbol, "GeneratorFunction");
126
- }
127
- genFun.prototype = Object.create(Gp);
128
- return genFun;
129
- };
130
- exports3.awrap = function(arg) {
131
- return { __await: arg };
132
- };
133
- function AsyncIterator(generator, PromiseImpl) {
134
- function invoke(method, arg, resolve, reject) {
135
- var record = tryCatch(generator[method], generator, arg);
136
- if (record.type === "throw") {
137
- reject(record.arg);
138
- } else {
139
- var result = record.arg;
140
- var value = result.value;
141
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
142
- return PromiseImpl.resolve(value.__await).then(function(value2) {
143
- invoke("next", value2, resolve, reject);
144
- }, function(err) {
145
- invoke("throw", err, resolve, reject);
146
- });
147
- }
148
- return PromiseImpl.resolve(value).then(function(unwrapped) {
149
- result.value = unwrapped;
150
- resolve(result);
151
- }, function(error) {
152
- return invoke("throw", error, resolve, reject);
153
- });
154
- }
155
- }
156
- var previousPromise;
157
- function enqueue(method, arg) {
158
- function callInvokeWithMethodAndArg() {
159
- return new PromiseImpl(function(resolve, reject) {
160
- invoke(method, arg, resolve, reject);
161
- });
162
- }
163
- return previousPromise = // If enqueue has been called before, then we want to wait until
164
- // all previous Promises have been resolved before calling invoke,
165
- // so that results are always delivered in the correct order. If
166
- // enqueue has not been called before, then it is important to
167
- // call invoke immediately, without waiting on a callback to fire,
168
- // so that the async generator function has the opportunity to do
169
- // any necessary setup in a predictable way. This predictability
170
- // is why the Promise constructor synchronously invokes its
171
- // executor callback, and why async functions synchronously
172
- // execute code before the first await. Since we implement simple
173
- // async functions in terms of async generators, it is especially
174
- // important to get this right, even though it requires care.
175
- previousPromise ? previousPromise.then(
176
- callInvokeWithMethodAndArg,
177
- // Avoid propagating failures to Promises returned by later
178
- // invocations of the iterator.
179
- callInvokeWithMethodAndArg
180
- ) : callInvokeWithMethodAndArg();
181
- }
182
- this._invoke = enqueue;
183
- }
184
- defineIteratorMethods(AsyncIterator.prototype);
185
- define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
186
- return this;
187
- });
188
- exports3.AsyncIterator = AsyncIterator;
189
- exports3.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
190
- if (PromiseImpl === void 0) PromiseImpl = Promise;
191
- var iter = new AsyncIterator(
192
- wrap(innerFn, outerFn, self, tryLocsList),
193
- PromiseImpl
194
- );
195
- return exports3.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
196
- return result.done ? result.value : iter.next();
197
- });
198
- };
199
- function makeInvokeMethod(innerFn, self, context) {
200
- var state = GenStateSuspendedStart;
201
- return function invoke(method, arg) {
202
- if (state === GenStateExecuting) {
203
- throw new Error("Generator is already running");
204
- }
205
- if (state === GenStateCompleted) {
206
- if (method === "throw") {
207
- throw arg;
208
- }
209
- return doneResult();
210
- }
211
- context.method = method;
212
- context.arg = arg;
213
- while (true) {
214
- var delegate = context.delegate;
215
- if (delegate) {
216
- var delegateResult = maybeInvokeDelegate(delegate, context);
217
- if (delegateResult) {
218
- if (delegateResult === ContinueSentinel) continue;
219
- return delegateResult;
220
- }
221
- }
222
- if (context.method === "next") {
223
- context.sent = context._sent = context.arg;
224
- } else if (context.method === "throw") {
225
- if (state === GenStateSuspendedStart) {
226
- state = GenStateCompleted;
227
- throw context.arg;
228
- }
229
- context.dispatchException(context.arg);
230
- } else if (context.method === "return") {
231
- context.abrupt("return", context.arg);
232
- }
233
- state = GenStateExecuting;
234
- var record = tryCatch(innerFn, self, context);
235
- if (record.type === "normal") {
236
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
237
- if (record.arg === ContinueSentinel) {
238
- continue;
239
- }
240
- return {
241
- value: record.arg,
242
- done: context.done
243
- };
244
- } else if (record.type === "throw") {
245
- state = GenStateCompleted;
246
- context.method = "throw";
247
- context.arg = record.arg;
248
- }
249
- }
250
- };
251
- }
252
- function maybeInvokeDelegate(delegate, context) {
253
- var method = delegate.iterator[context.method];
254
- if (method === undefined2) {
255
- context.delegate = null;
256
- if (context.method === "throw") {
257
- if (delegate.iterator["return"]) {
258
- context.method = "return";
259
- context.arg = undefined2;
260
- maybeInvokeDelegate(delegate, context);
261
- if (context.method === "throw") {
262
- return ContinueSentinel;
263
- }
264
- }
265
- context.method = "throw";
266
- context.arg = new TypeError(
267
- "The iterator does not provide a 'throw' method"
268
- );
269
- }
270
- return ContinueSentinel;
271
- }
272
- var record = tryCatch(method, delegate.iterator, context.arg);
273
- if (record.type === "throw") {
274
- context.method = "throw";
275
- context.arg = record.arg;
276
- context.delegate = null;
277
- return ContinueSentinel;
278
- }
279
- var info = record.arg;
280
- if (!info) {
281
- context.method = "throw";
282
- context.arg = new TypeError("iterator result is not an object");
283
- context.delegate = null;
284
- return ContinueSentinel;
285
- }
286
- if (info.done) {
287
- context[delegate.resultName] = info.value;
288
- context.next = delegate.nextLoc;
289
- if (context.method !== "return") {
290
- context.method = "next";
291
- context.arg = undefined2;
292
- }
293
- } else {
294
- return info;
295
- }
296
- context.delegate = null;
297
- return ContinueSentinel;
298
- }
299
- defineIteratorMethods(Gp);
300
- define(Gp, toStringTagSymbol, "Generator");
301
- define(Gp, iteratorSymbol, function() {
302
- return this;
303
- });
304
- define(Gp, "toString", function() {
305
- return "[object Generator]";
306
- });
307
- function pushTryEntry(locs) {
308
- var entry = { tryLoc: locs[0] };
309
- if (1 in locs) {
310
- entry.catchLoc = locs[1];
311
- }
312
- if (2 in locs) {
313
- entry.finallyLoc = locs[2];
314
- entry.afterLoc = locs[3];
315
- }
316
- this.tryEntries.push(entry);
317
- }
318
- function resetTryEntry(entry) {
319
- var record = entry.completion || {};
320
- record.type = "normal";
321
- delete record.arg;
322
- entry.completion = record;
323
- }
324
- function Context(tryLocsList) {
325
- this.tryEntries = [{ tryLoc: "root" }];
326
- tryLocsList.forEach(pushTryEntry, this);
327
- this.reset(true);
328
- }
329
- exports3.keys = function(object) {
330
- var keys = [];
331
- for (var key in object) {
332
- keys.push(key);
333
- }
334
- keys.reverse();
335
- return function next() {
336
- while (keys.length) {
337
- var key2 = keys.pop();
338
- if (key2 in object) {
339
- next.value = key2;
340
- next.done = false;
341
- return next;
342
- }
343
- }
344
- next.done = true;
345
- return next;
346
- };
347
- };
348
- function values(iterable) {
349
- if (iterable) {
350
- var iteratorMethod = iterable[iteratorSymbol];
351
- if (iteratorMethod) {
352
- return iteratorMethod.call(iterable);
353
- }
354
- if (typeof iterable.next === "function") {
355
- return iterable;
356
- }
357
- if (!isNaN(iterable.length)) {
358
- var i = -1, next = function next2() {
359
- while (++i < iterable.length) {
360
- if (hasOwn.call(iterable, i)) {
361
- next2.value = iterable[i];
362
- next2.done = false;
363
- return next2;
364
- }
365
- }
366
- next2.value = undefined2;
367
- next2.done = true;
368
- return next2;
369
- };
370
- return next.next = next;
371
- }
372
- }
373
- return { next: doneResult };
374
- }
375
- exports3.values = values;
376
- function doneResult() {
377
- return { value: undefined2, done: true };
378
- }
379
- Context.prototype = {
380
- constructor: Context,
381
- reset: function(skipTempReset) {
382
- this.prev = 0;
383
- this.next = 0;
384
- this.sent = this._sent = undefined2;
385
- this.done = false;
386
- this.delegate = null;
387
- this.method = "next";
388
- this.arg = undefined2;
389
- this.tryEntries.forEach(resetTryEntry);
390
- if (!skipTempReset) {
391
- for (var name in this) {
392
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
393
- this[name] = undefined2;
394
- }
395
- }
396
- }
397
- },
398
- stop: function() {
399
- this.done = true;
400
- var rootEntry = this.tryEntries[0];
401
- var rootRecord = rootEntry.completion;
402
- if (rootRecord.type === "throw") {
403
- throw rootRecord.arg;
404
- }
405
- return this.rval;
406
- },
407
- dispatchException: function(exception) {
408
- if (this.done) {
409
- throw exception;
410
- }
411
- var context = this;
412
- function handle(loc, caught) {
413
- record.type = "throw";
414
- record.arg = exception;
415
- context.next = loc;
416
- if (caught) {
417
- context.method = "next";
418
- context.arg = undefined2;
419
- }
420
- return !!caught;
421
- }
422
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
423
- var entry = this.tryEntries[i];
424
- var record = entry.completion;
425
- if (entry.tryLoc === "root") {
426
- return handle("end");
427
- }
428
- if (entry.tryLoc <= this.prev) {
429
- var hasCatch = hasOwn.call(entry, "catchLoc");
430
- var hasFinally = hasOwn.call(entry, "finallyLoc");
431
- if (hasCatch && hasFinally) {
432
- if (this.prev < entry.catchLoc) {
433
- return handle(entry.catchLoc, true);
434
- } else if (this.prev < entry.finallyLoc) {
435
- return handle(entry.finallyLoc);
436
- }
437
- } else if (hasCatch) {
438
- if (this.prev < entry.catchLoc) {
439
- return handle(entry.catchLoc, true);
440
- }
441
- } else if (hasFinally) {
442
- if (this.prev < entry.finallyLoc) {
443
- return handle(entry.finallyLoc);
444
- }
445
- } else {
446
- throw new Error("try statement without catch or finally");
447
- }
448
- }
449
- }
450
- },
451
- abrupt: function(type, arg) {
452
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
453
- var entry = this.tryEntries[i];
454
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
455
- var finallyEntry = entry;
456
- break;
457
- }
458
- }
459
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
460
- finallyEntry = null;
461
- }
462
- var record = finallyEntry ? finallyEntry.completion : {};
463
- record.type = type;
464
- record.arg = arg;
465
- if (finallyEntry) {
466
- this.method = "next";
467
- this.next = finallyEntry.finallyLoc;
468
- return ContinueSentinel;
469
- }
470
- return this.complete(record);
471
- },
472
- complete: function(record, afterLoc) {
473
- if (record.type === "throw") {
474
- throw record.arg;
475
- }
476
- if (record.type === "break" || record.type === "continue") {
477
- this.next = record.arg;
478
- } else if (record.type === "return") {
479
- this.rval = this.arg = record.arg;
480
- this.method = "return";
481
- this.next = "end";
482
- } else if (record.type === "normal" && afterLoc) {
483
- this.next = afterLoc;
484
- }
485
- return ContinueSentinel;
486
- },
487
- finish: function(finallyLoc) {
488
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
489
- var entry = this.tryEntries[i];
490
- if (entry.finallyLoc === finallyLoc) {
491
- this.complete(entry.completion, entry.afterLoc);
492
- resetTryEntry(entry);
493
- return ContinueSentinel;
494
- }
495
- }
496
- },
497
- "catch": function(tryLoc) {
498
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
499
- var entry = this.tryEntries[i];
500
- if (entry.tryLoc === tryLoc) {
501
- var record = entry.completion;
502
- if (record.type === "throw") {
503
- var thrown = record.arg;
504
- resetTryEntry(entry);
505
- }
506
- return thrown;
507
- }
508
- }
509
- throw new Error("illegal catch attempt");
510
- },
511
- delegateYield: function(iterable, resultName, nextLoc) {
512
- this.delegate = {
513
- iterator: values(iterable),
514
- resultName,
515
- nextLoc
516
- };
517
- if (this.method === "next") {
518
- this.arg = undefined2;
519
- }
520
- return ContinueSentinel;
521
- }
522
- };
523
- return exports3;
524
- }(
525
- // If this script is executing as a CommonJS module, use module.exports
526
- // as the regeneratorRuntime namespace. Otherwise create a new empty
527
- // object. Either way, the resulting object will be used to initialize
528
- // the regeneratorRuntime variable at the top of this file.
529
- typeof module2 === "object" ? module2.exports : {}
530
- );
531
- try {
532
- regeneratorRuntime = runtime;
533
- } catch (accidentalStrictMode) {
534
- if (typeof globalThis === "object") {
535
- globalThis.regeneratorRuntime = runtime;
536
- } else {
537
- Function("r", "regeneratorRuntime = r")(runtime);
538
- }
539
- }
540
- }
541
- });
542
-
543
- // ../../../node_modules/localforage-driver-memory/_driver.js
544
- var require_driver = __commonJS({
545
- "../../../node_modules/localforage-driver-memory/_driver.js"(exports2) {
546
- "use strict";
547
- Object.defineProperty(exports2, "__esModule", { value: true });
548
- exports2._driver = "localforage-driver-memory";
549
- }
550
- });
551
-
552
- // ../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/serialiser/createBlob.js
553
- var require_createBlob = __commonJS({
554
- "../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/serialiser/createBlob.js"(exports2) {
555
- "use strict";
556
- Object.defineProperty(exports2, "__esModule", { value: true });
557
- function createBlob(parts, properties) {
558
- parts = parts || [];
559
- properties = properties || {};
560
- try {
561
- return new Blob(parts, properties);
562
- } catch (e) {
563
- if (e.name !== "TypeError") {
564
- throw e;
565
- }
566
- var Builder = typeof BlobBuilder !== "undefined" ? BlobBuilder : typeof MSBlobBuilder !== "undefined" ? MSBlobBuilder : typeof MozBlobBuilder !== "undefined" ? MozBlobBuilder : WebKitBlobBuilder;
567
- var builder = new Builder();
568
- for (var i = 0; i < parts.length; i += 1) {
569
- builder.append(parts[i]);
570
- }
571
- return builder.getBlob(properties.type);
572
- }
573
- }
574
- exports2.createBlob = createBlob;
575
- }
576
- });
577
-
578
- // ../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/serialiser/index.js
579
- var require_serialiser = __commonJS({
580
- "../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/serialiser/index.js"(exports2) {
581
- "use strict";
582
- Object.defineProperty(exports2, "__esModule", { value: true });
583
- var createBlob_1 = require_createBlob();
584
- var BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;
585
- var SERIALIZED_MARKER_LENGTH = "__lfsc__:".length;
586
- var TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + "arbf".length;
587
- var toString = Object.prototype.toString;
588
- function stringToBuffer(serializedString) {
589
- var bufferLength = serializedString.length * 0.75;
590
- var len = serializedString.length;
591
- if (serializedString[serializedString.length - 1] === "=") {
592
- bufferLength--;
593
- if (serializedString[serializedString.length - 2] === "=") {
594
- bufferLength--;
595
- }
596
- }
597
- var buffer = new ArrayBuffer(bufferLength);
598
- var bytes = new Uint8Array(buffer);
599
- for (var i = 0, p = 0; i < len; i += 4) {
600
- var encoded1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(serializedString[i]);
601
- var encoded2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(serializedString[i + 1]);
602
- var encoded3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(serializedString[i + 2]);
603
- var encoded4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(serializedString[i + 3]);
604
- bytes[p++] = encoded1 << 2 | encoded2 >> 4;
605
- bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
606
- bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
607
- }
608
- return buffer;
609
- }
610
- exports2.stringToBuffer = stringToBuffer;
611
- function bufferToString(buffer) {
612
- var bytes = new Uint8Array(buffer);
613
- var base64String = "";
614
- for (var i = 0; i < bytes.length; i += 3) {
615
- base64String += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[bytes[i] >> 2];
616
- base64String += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
617
- base64String += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
618
- base64String += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[bytes[i + 2] & 63];
619
- }
620
- if (bytes.length % 3 === 2) {
621
- base64String = base64String.substring(0, base64String.length - 1) + "=";
622
- } else if (bytes.length % 3 === 1) {
623
- base64String = base64String.substring(0, base64String.length - 2) + "==";
624
- }
625
- return base64String;
626
- }
627
- exports2.bufferToString = bufferToString;
628
- function serialize(value, callback) {
629
- var valueType = "";
630
- if (value) {
631
- valueType = toString.call(value);
632
- }
633
- if (value && (valueType === "[object ArrayBuffer]" || value.buffer && toString.call(value.buffer) === "[object ArrayBuffer]")) {
634
- var buffer = void 0;
635
- var marker = "__lfsc__:";
636
- if (value instanceof ArrayBuffer) {
637
- buffer = value;
638
- marker += "arbf";
639
- } else {
640
- buffer = value.buffer;
641
- if (valueType === "[object Int8Array]") {
642
- marker += "si08";
643
- } else if (valueType === "[object Uint8Array]") {
644
- marker += "ui08";
645
- } else if (valueType === "[object Uint8ClampedArray]") {
646
- marker += "uic8";
647
- } else if (valueType === "[object Int16Array]") {
648
- marker += "si16";
649
- } else if (valueType === "[object Uint16Array]") {
650
- marker += "ur16";
651
- } else if (valueType === "[object Int32Array]") {
652
- marker += "si32";
653
- } else if (valueType === "[object Uint32Array]") {
654
- marker += "ui32";
655
- } else if (valueType === "[object Float32Array]") {
656
- marker += "fl32";
657
- } else if (valueType === "[object Float64Array]") {
658
- marker += "fl64";
659
- } else {
660
- callback(new Error("Failed to get type for BinaryArray"));
661
- }
662
- }
663
- callback(marker + bufferToString(buffer));
664
- } else if (valueType === "[object Blob]") {
665
- var fileReader = new FileReader();
666
- fileReader.onload = function() {
667
- var str = "~~local_forage_type~" + value.type + "~" + bufferToString(this.result);
668
- callback("__lfsc__:blob" + str);
669
- };
670
- fileReader.readAsArrayBuffer(value);
671
- } else {
672
- try {
673
- callback(JSON.stringify(value));
674
- } catch (e) {
675
- console.error("Couldn't convert value into a JSON string: ", value);
676
- callback(null, e);
677
- }
678
- }
679
- }
680
- exports2.serialize = serialize;
681
- function deserialize(value) {
682
- if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== "__lfsc__:") {
683
- return JSON.parse(value);
684
- }
685
- var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);
686
- var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);
687
- var blobType;
688
- if (type === "blob" && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {
689
- var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);
690
- blobType = matcher[1];
691
- serializedString = serializedString.substring(matcher[0].length);
692
- }
693
- var buffer = stringToBuffer(serializedString);
694
- switch (type) {
695
- case "arbf":
696
- return buffer;
697
- case "blob":
698
- return createBlob_1.createBlob([buffer], { type: blobType });
699
- case "si08":
700
- return new Int8Array(buffer);
701
- case "ui08":
702
- return new Uint8Array(buffer);
703
- case "uic8":
704
- return new Uint8ClampedArray(buffer);
705
- case "si16":
706
- return new Int16Array(buffer);
707
- case "ur16":
708
- return new Uint16Array(buffer);
709
- case "si32":
710
- return new Int32Array(buffer);
711
- case "ui32":
712
- return new Uint32Array(buffer);
713
- case "fl32":
714
- return new Float32Array(buffer);
715
- case "fl64":
716
- return new Float64Array(buffer);
717
- default:
718
- throw new Error("Unkown type: " + type);
719
- }
720
- }
721
- exports2.deserialize = deserialize;
722
- }
723
- });
724
-
725
- // ../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/clone.js
726
- var require_clone = __commonJS({
727
- "../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/clone.js"(exports2) {
728
- "use strict";
729
- var __values = exports2 && exports2.__values || function(o) {
730
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
731
- if (m) return m.call(o);
732
- return {
733
- next: function() {
734
- if (o && i >= o.length) o = void 0;
735
- return { value: o && o[i++], done: !o };
736
- }
737
- };
738
- };
739
- Object.defineProperty(exports2, "__esModule", { value: true });
740
- function clone(obj) {
741
- var e_1, _a;
742
- if (obj === null || typeof obj !== "object" || "isActiveClone" in obj) {
743
- return obj;
744
- }
745
- var temp = obj instanceof Date ? new Date(obj) : obj.constructor();
746
- try {
747
- for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
748
- var key = _c.value;
749
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
750
- obj["isActiveClone"] = null;
751
- temp[key] = clone(obj[key]);
752
- delete obj["isActiveClone"];
753
- }
754
- }
755
- } catch (e_1_1) {
756
- e_1 = { error: e_1_1 };
757
- } finally {
758
- try {
759
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
760
- } finally {
761
- if (e_1) throw e_1.error;
762
- }
763
- }
764
- return temp;
765
- }
766
- exports2.clone = clone;
767
- }
768
- });
769
-
770
- // ../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/getKeyPrefix.js
771
- var require_getKeyPrefix = __commonJS({
772
- "../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/getKeyPrefix.js"(exports2) {
773
- "use strict";
774
- Object.defineProperty(exports2, "__esModule", { value: true });
775
- function getKeyPrefix(options, defaultConfig) {
776
- return (options.name || defaultConfig.name) + "/" + (options.storeName || defaultConfig.storeName) + "/";
777
- }
778
- exports2.getKeyPrefix = getKeyPrefix;
779
- }
780
- });
781
-
782
- // ../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/executeCallback.js
783
- var require_executeCallback = __commonJS({
784
- "../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/executeCallback.js"(exports2) {
785
- "use strict";
786
- Object.defineProperty(exports2, "__esModule", { value: true });
787
- function executeCallback(promise, callback) {
788
- if (callback) {
789
- promise.then(function(result) {
790
- callback(null, result);
791
- }, function(error) {
792
- callback(error);
793
- });
794
- }
795
- }
796
- exports2.executeCallback = executeCallback;
797
- }
798
- });
799
-
800
- // ../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/getCallback.js
801
- var require_getCallback = __commonJS({
802
- "../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/getCallback.js"(exports2) {
803
- "use strict";
804
- Object.defineProperty(exports2, "__esModule", { value: true });
805
- function getCallback() {
806
- var _args = [];
807
- for (var _i = 0; _i < arguments.length; _i++) {
808
- _args[_i] = arguments[_i];
809
- }
810
- if (arguments.length && typeof arguments[arguments.length - 1] === "function") {
811
- return arguments[arguments.length - 1];
812
- }
813
- }
814
- exports2.getCallback = getCallback;
815
- }
816
- });
817
-
818
- // ../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/dropInstanceCommon.js
819
- var require_dropInstanceCommon = __commonJS({
820
- "../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/dropInstanceCommon.js"(exports2) {
821
- "use strict";
822
- Object.defineProperty(exports2, "__esModule", { value: true });
823
- var getCallback_1 = require_getCallback();
824
- var getKeyPrefix_1 = require_getKeyPrefix();
825
- function dropInstanceCommon(options, callback) {
826
- var _this = this;
827
- callback = getCallback_1.getCallback.apply(this, arguments);
828
- options = typeof options !== "function" && options || {};
829
- if (!options.name) {
830
- var currentConfig = this.config();
831
- options.name = options.name || currentConfig.name;
832
- options.storeName = options.storeName || currentConfig.storeName;
833
- }
834
- var promise;
835
- if (!options.name) {
836
- promise = Promise.reject("Invalid arguments");
837
- } else {
838
- promise = new Promise(function(resolve) {
839
- if (!options.storeName) {
840
- resolve(options.name + "/");
841
- } else {
842
- resolve(getKeyPrefix_1.getKeyPrefix(options, _this._defaultConfig));
843
- }
844
- });
845
- }
846
- return { promise, callback };
847
- }
848
- exports2.dropInstanceCommon = dropInstanceCommon;
849
- }
850
- });
851
-
852
- // ../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/normaliseKey.js
853
- var require_normaliseKey = __commonJS({
854
- "../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/normaliseKey.js"(exports2) {
855
- "use strict";
856
- Object.defineProperty(exports2, "__esModule", { value: true });
857
- function normaliseKey(key) {
858
- if (typeof key !== "string") {
859
- console.warn(key + " used as a key, but it is not a string.");
860
- key = String(key);
861
- }
862
- return key;
863
- }
864
- exports2.normaliseKey = normaliseKey;
865
- }
866
- });
867
-
868
- // ../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/index.js
869
- var require_localforage_driver_commons = __commonJS({
870
- "../../../node_modules/localforage-driver-memory/node_modules/localforage-driver-commons/index.js"(exports2) {
871
- "use strict";
872
- Object.defineProperty(exports2, "__esModule", { value: true });
873
- var serialiser_1 = require_serialiser();
874
- var clone_1 = require_clone();
875
- exports2.clone = clone_1.clone;
876
- var getKeyPrefix_1 = require_getKeyPrefix();
877
- exports2.getKeyPrefix = getKeyPrefix_1.getKeyPrefix;
878
- var executeCallback_1 = require_executeCallback();
879
- exports2.executeCallback = executeCallback_1.executeCallback;
880
- var getCallback_1 = require_getCallback();
881
- exports2.getCallback = getCallback_1.getCallback;
882
- var dropInstanceCommon_1 = require_dropInstanceCommon();
883
- exports2.dropInstanceCommon = dropInstanceCommon_1.dropInstanceCommon;
884
- var normaliseKey_1 = require_normaliseKey();
885
- exports2.normaliseKey = normaliseKey_1.normaliseKey;
886
- exports2.serialiser = {
887
- bufferToString: serialiser_1.bufferToString,
888
- deserialize: serialiser_1.deserialize,
889
- serialize: serialiser_1.serialize,
890
- stringToBuffer: serialiser_1.stringToBuffer
891
- };
892
- }
893
- });
894
-
895
- // ../../../node_modules/localforage-driver-memory/Store.js
896
- var require_Store = __commonJS({
897
- "../../../node_modules/localforage-driver-memory/Store.js"(exports2) {
898
- "use strict";
899
- Object.defineProperty(exports2, "__esModule", { value: true });
900
- var stores = {};
901
- var Store = (
902
- /** @class */
903
- function() {
904
- function Store2(kp) {
905
- this.kp = kp;
906
- this.data = {};
907
- }
908
- Store2.resolve = function(kp) {
909
- if (!stores[kp]) {
910
- stores[kp] = new Store2(kp);
911
- }
912
- return stores[kp];
913
- };
914
- Store2.prototype.clear = function() {
915
- this.data = {};
916
- };
917
- Store2.prototype.drop = function() {
918
- this.clear();
919
- delete stores[this.kp];
920
- };
921
- Store2.prototype.get = function(key) {
922
- return this.data[key];
923
- };
924
- Store2.prototype.key = function(idx) {
925
- return this.keys()[idx];
926
- };
927
- Store2.prototype.keys = function() {
928
- return Object.keys(this.data);
929
- };
930
- Store2.prototype.rm = function(k) {
931
- delete this.data[k];
932
- };
933
- Store2.prototype.set = function(k, v) {
934
- this.data[k] = v;
935
- };
936
- return Store2;
937
- }()
938
- );
939
- exports2.Store = Store;
940
- }
941
- });
942
-
943
- // ../../../node_modules/localforage-driver-memory/_initStorage.js
944
- var require_initStorage = __commonJS({
945
- "../../../node_modules/localforage-driver-memory/_initStorage.js"(exports2) {
946
- "use strict";
947
- Object.defineProperty(exports2, "__esModule", { value: true });
948
- var localforage_driver_commons_1 = require_localforage_driver_commons();
949
- var Store_1 = require_Store();
950
- function _initStorage(options) {
951
- var opts = options ? localforage_driver_commons_1.clone(options) : {};
952
- var kp = localforage_driver_commons_1.getKeyPrefix(opts, this._defaultConfig);
953
- var store = Store_1.Store.resolve(kp);
954
- this._dbInfo = opts;
955
- this._dbInfo.serializer = localforage_driver_commons_1.serialiser;
956
- this._dbInfo.keyPrefix = kp;
957
- this._dbInfo.mStore = store;
958
- return Promise.resolve();
959
- }
960
- exports2._initStorage = _initStorage;
961
- }
962
- });
963
-
964
- // ../../../node_modules/localforage-driver-memory/clear.js
965
- var require_clear = __commonJS({
966
- "../../../node_modules/localforage-driver-memory/clear.js"(exports2) {
967
- "use strict";
968
- Object.defineProperty(exports2, "__esModule", { value: true });
969
- var localforage_driver_commons_1 = require_localforage_driver_commons();
970
- function clear(callback) {
971
- var _this = this;
972
- var promise = this.ready().then(function() {
973
- _this._dbInfo.mStore.clear();
974
- });
975
- localforage_driver_commons_1.executeCallback(promise, callback);
976
- return promise;
977
- }
978
- exports2.clear = clear;
979
- }
980
- });
981
-
982
- // ../../../node_modules/localforage-driver-memory/dropInstance.js
983
- var require_dropInstance = __commonJS({
984
- "../../../node_modules/localforage-driver-memory/dropInstance.js"(exports2) {
985
- "use strict";
986
- Object.defineProperty(exports2, "__esModule", { value: true });
987
- var localforage_driver_commons_1 = require_localforage_driver_commons();
988
- var Store_1 = require_Store();
989
- function dropInstance(_options, _cb) {
990
- var _a = localforage_driver_commons_1.dropInstanceCommon.apply(this, arguments), promise = _a.promise, callback = _a.callback;
991
- var outPromise = promise.then(function(keyPrefix) {
992
- Store_1.Store.resolve(keyPrefix).drop();
993
- });
994
- localforage_driver_commons_1.executeCallback(outPromise, callback);
995
- return promise;
996
- }
997
- exports2.dropInstance = dropInstance;
998
- }
999
- });
1000
-
1001
- // ../../../node_modules/localforage-driver-memory/getItem.js
1002
- var require_getItem = __commonJS({
1003
- "../../../node_modules/localforage-driver-memory/getItem.js"(exports2) {
1004
- "use strict";
1005
- Object.defineProperty(exports2, "__esModule", { value: true });
1006
- var localforage_driver_commons_1 = require_localforage_driver_commons();
1007
- function getItem(key$, callback) {
1008
- var _this = this;
1009
- key$ = localforage_driver_commons_1.normaliseKey(key$);
1010
- var promise = this.ready().then(function() {
1011
- var result = _this._dbInfo.mStore.get(key$);
1012
- return result == null ? null : _this._dbInfo.serializer.deserialize(result);
1013
- });
1014
- localforage_driver_commons_1.executeCallback(promise, callback);
1015
- return promise;
1016
- }
1017
- exports2.getItem = getItem;
1018
- }
1019
- });
1020
-
1021
- // ../../../node_modules/localforage-driver-memory/iterate.js
1022
- var require_iterate = __commonJS({
1023
- "../../../node_modules/localforage-driver-memory/iterate.js"(exports2) {
1024
- "use strict";
1025
- Object.defineProperty(exports2, "__esModule", { value: true });
1026
- var localforage_driver_commons_1 = require_localforage_driver_commons();
1027
- function iterate(iterator, callback) {
1028
- var _this = this;
1029
- var promise = this.ready().then(function() {
1030
- var store = _this._dbInfo.mStore;
1031
- var keys = store.keys();
1032
- for (var i = 0; i < keys.length; i++) {
1033
- var value = store.get(keys[i]);
1034
- if (value) {
1035
- value = _this._dbInfo.serializer.deserialize(value);
1036
- }
1037
- value = iterator(value, keys[i], i + 1);
1038
- if (value !== void 0) {
1039
- return value;
1040
- }
1041
- }
1042
- });
1043
- localforage_driver_commons_1.executeCallback(promise, callback);
1044
- return promise;
1045
- }
1046
- exports2.iterate = iterate;
1047
- }
1048
- });
1049
-
1050
- // ../../../node_modules/localforage-driver-memory/key.js
1051
- var require_key = __commonJS({
1052
- "../../../node_modules/localforage-driver-memory/key.js"(exports2) {
1053
- "use strict";
1054
- Object.defineProperty(exports2, "__esModule", { value: true });
1055
- var localforage_driver_commons_1 = require_localforage_driver_commons();
1056
- function key(idx, callback) {
1057
- var _this = this;
1058
- var promise = this.ready().then(function() {
1059
- var result;
1060
- try {
1061
- result = _this._dbInfo.mStore.key(idx);
1062
- if (result === void 0) {
1063
- result = null;
1064
- }
1065
- } catch (_a) {
1066
- result = null;
1067
- }
1068
- return result;
1069
- });
1070
- localforage_driver_commons_1.executeCallback(promise, callback);
1071
- return promise;
1072
- }
1073
- exports2.key = key;
1074
- }
1075
- });
1076
-
1077
- // ../../../node_modules/localforage-driver-memory/keys.js
1078
- var require_keys = __commonJS({
1079
- "../../../node_modules/localforage-driver-memory/keys.js"(exports2) {
1080
- "use strict";
1081
- Object.defineProperty(exports2, "__esModule", { value: true });
1082
- var localforage_driver_commons_1 = require_localforage_driver_commons();
1083
- function keys(callback) {
1084
- var _this = this;
1085
- var promise = this.ready().then(function() {
1086
- return _this._dbInfo.mStore.keys();
1087
- });
1088
- localforage_driver_commons_1.executeCallback(promise, callback);
1089
- return promise;
1090
- }
1091
- exports2.keys = keys;
1092
- }
1093
- });
1094
-
1095
- // ../../../node_modules/localforage-driver-memory/length.js
1096
- var require_length = __commonJS({
1097
- "../../../node_modules/localforage-driver-memory/length.js"(exports2) {
1098
- "use strict";
1099
- Object.defineProperty(exports2, "__esModule", { value: true });
1100
- var localforage_driver_commons_1 = require_localforage_driver_commons();
1101
- function length(callback) {
1102
- var promise = this.keys().then(function(keys$) {
1103
- return keys$.length;
1104
- });
1105
- localforage_driver_commons_1.executeCallback(promise, callback);
1106
- return promise;
1107
- }
1108
- exports2.length = length;
1109
- }
1110
- });
1111
-
1112
- // ../../../node_modules/localforage-driver-memory/removeItem.js
1113
- var require_removeItem = __commonJS({
1114
- "../../../node_modules/localforage-driver-memory/removeItem.js"(exports2) {
1115
- "use strict";
1116
- Object.defineProperty(exports2, "__esModule", { value: true });
1117
- var localforage_driver_commons_1 = require_localforage_driver_commons();
1118
- function removeItem(key$, callback) {
1119
- var _this = this;
1120
- key$ = localforage_driver_commons_1.normaliseKey(key$);
1121
- var promise = this.ready().then(function() {
1122
- _this._dbInfo.mStore.rm(key$);
1123
- });
1124
- localforage_driver_commons_1.executeCallback(promise, callback);
1125
- return promise;
1126
- }
1127
- exports2.removeItem = removeItem;
1128
- }
1129
- });
1130
-
1131
- // ../../../node_modules/localforage-driver-memory/setItem.js
1132
- var require_setItem = __commonJS({
1133
- "../../../node_modules/localforage-driver-memory/setItem.js"(exports2) {
1134
- "use strict";
1135
- Object.defineProperty(exports2, "__esModule", { value: true });
1136
- var localforage_driver_commons_1 = require_localforage_driver_commons();
1137
- function setItem(key$, value, callback) {
1138
- var _this = this;
1139
- key$ = localforage_driver_commons_1.normaliseKey(key$);
1140
- var promise = this.ready().then(function() {
1141
- if (value === void 0) {
1142
- value = null;
1143
- }
1144
- var originalValue = value;
1145
- return new Promise(function(resolve, reject) {
1146
- _this._dbInfo.serializer.serialize(value, function(value$, error) {
1147
- if (error) {
1148
- reject(error);
1149
- } else {
1150
- try {
1151
- _this._dbInfo.mStore.set(key$, value$);
1152
- resolve(originalValue);
1153
- } catch (e) {
1154
- reject(e);
1155
- }
1156
- }
1157
- });
1158
- });
1159
- });
1160
- localforage_driver_commons_1.executeCallback(promise, callback);
1161
- return promise;
1162
- }
1163
- exports2.setItem = setItem;
1164
- }
1165
- });
1166
-
1167
- // ../../../node_modules/localforage-driver-memory/index.js
1168
- var require_localforage_driver_memory = __commonJS({
1169
- "../../../node_modules/localforage-driver-memory/index.js"(exports2) {
1170
- "use strict";
1171
- Object.defineProperty(exports2, "__esModule", { value: true });
1172
- exports2._support = true;
1173
- var _driver_1 = require_driver();
1174
- exports2._driver = _driver_1._driver;
1175
- var _initStorage_1 = require_initStorage();
1176
- exports2._initStorage = _initStorage_1._initStorage;
1177
- var clear_1 = require_clear();
1178
- exports2.clear = clear_1.clear;
1179
- var dropInstance_1 = require_dropInstance();
1180
- exports2.dropInstance = dropInstance_1.dropInstance;
1181
- var getItem_1 = require_getItem();
1182
- exports2.getItem = getItem_1.getItem;
1183
- var iterate_1 = require_iterate();
1184
- exports2.iterate = iterate_1.iterate;
1185
- var key_1 = require_key();
1186
- exports2.key = key_1.key;
1187
- var keys_1 = require_keys();
1188
- exports2.keys = keys_1.keys;
1189
- var length_1 = require_length();
1190
- exports2.length = length_1.length;
1191
- var removeItem_1 = require_removeItem();
1192
- exports2.removeItem = removeItem_1.removeItem;
1193
- var setItem_1 = require_setItem();
1194
- exports2.setItem = setItem_1.setItem;
1195
- }
1196
- });
1197
-
1198
- // src/index.ts
1199
- var index_exports = {};
1200
- __export(index_exports, {
1201
- Magic: () => Magic,
1202
- useInternetConnection: () => useInternetConnection
1203
- });
1204
- module.exports = __toCommonJS(index_exports);
1205
- var import_runtime = __toESM(require_runtime());
1206
- var import_provider3 = require("@magic-sdk/provider");
1207
- var processPolyfill = __toESM(require("process"));
1208
- var import_localforage = __toESM(require("localforage"));
1209
- var import_whatwg_url = require("whatwg-url");
1210
- var import_buffer = require("buffer");
1211
- var _ = __toESM(require("lodash"));
1212
- var Application = __toESM(require("expo-application"));
1213
- var import_localforage_asyncstorage_driver = require("@aveq-research/localforage-asyncstorage-driver");
1214
- var memoryDriver = __toESM(require_localforage_driver_memory());
1215
-
1216
- // src/react-native-webview-controller.tsx
1217
- var import_react2 = __toESM(require("react"));
1218
- var import_react_native = require("react-native");
1219
- var import_react_native_webview = require("react-native-webview");
1220
- var import_react_native_safe_area_context = require("react-native-safe-area-context");
1221
- var import_provider = require("@magic-sdk/provider");
1222
- var import_lodash = require("lodash");
1223
- var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
1224
- var import_react_native_event_listeners = require("react-native-event-listeners");
1225
-
1226
- // src/hooks.ts
1227
- var import_react = require("react");
1228
- var import_netinfo = __toESM(require("@react-native-community/netinfo"));
1229
- var useInternetConnection = () => {
1230
- const [isConnected, setIsConnected] = (0, import_react.useState)(true);
1231
- (0, import_react.useEffect)(() => {
1232
- const handleConnectionChange = (connectionInfo) => {
1233
- setIsConnected(!!connectionInfo.isConnected);
1234
- };
1235
- return import_netinfo.default.addEventListener(handleConnectionChange);
1236
- }, []);
1237
- return isConnected;
1238
- };
1239
-
1240
- // src/react-native-webview-controller.tsx
1241
- var MAGIC_PAYLOAD_FLAG_TYPED_ARRAY = "MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";
1242
- var OPEN_IN_DEVICE_BROWSER = "open_in_device_browser";
1243
- var DEFAULT_BACKGROUND_COLOR = "#FFFFFF";
1244
- var MSG_POSTED_AFTER_INACTIVITY_EVENT = "msg_posted_after_inactivity_event";
1245
- var LAST_MESSAGE_TIME = "lastMessageTime";
1246
- function createWebViewStyles() {
1247
- return import_react_native.StyleSheet.create({
1248
- "magic-webview": {
1249
- flex: 1,
1250
- backgroundColor: "transparent"
1251
- },
1252
- "webview-container": {
1253
- flex: 1,
1254
- width: "100%",
1255
- backgroundColor: "transparent",
1256
- position: "absolute",
1257
- top: 0,
1258
- left: 0,
1259
- right: 0,
1260
- bottom: 0
1261
- },
1262
- show: {
1263
- zIndex: 1e4,
1264
- elevation: 1e4
1265
- },
1266
- hide: {
1267
- zIndex: -1e4,
1268
- elevation: 0
1269
- }
1270
- });
1271
- }
1272
- var ReactNativeWebViewController = class extends import_provider.ViewController {
1273
- webView;
1274
- container;
1275
- styles;
1276
- init() {
1277
- this.webView = null;
1278
- this.container = null;
1279
- this.styles = createWebViewStyles();
1280
- }
1281
- /**
1282
- * Renders a React Native `<WebView>` with built-in message handling to and
1283
- * from the Magic `<iframe>` context.
1284
- */
1285
- // Validating this logic requires lots of React-specific boilerplate. We will
1286
- // revisit this method for unit testing in the future. For now, manual testing
1287
- // is sufficient (this logic is stable right now and not expected to change in
1288
- // the foreseeable future).
1289
- /* istanbul ignore next */
1290
- Relayer = (backgroundColor) => {
1291
- const [show, setShow] = (0, import_react2.useState)(false);
1292
- const [mountOverlay, setMountOverlay] = (0, import_react2.useState)(true);
1293
- const isConnected = useInternetConnection();
1294
- (0, import_react2.useEffect)(() => {
1295
- this.isConnectedToInternet = isConnected;
1296
- }, [isConnected]);
1297
- (0, import_react2.useEffect)(() => {
1298
- import_async_storage.default.setItem(LAST_MESSAGE_TIME, "");
1299
- return () => {
1300
- this.isReadyForRequest = false;
1301
- };
1302
- }, []);
1303
- (0, import_react2.useEffect)(() => {
1304
- import_react_native_event_listeners.EventRegister.addEventListener(MSG_POSTED_AFTER_INACTIVITY_EVENT, async (message) => {
1305
- this.isReadyForRequest = false;
1306
- setMountOverlay(false);
1307
- this.post(message.msgType, message.payload);
1308
- await import_async_storage.default.setItem(LAST_MESSAGE_TIME, (/* @__PURE__ */ new Date()).toISOString());
1309
- });
1310
- }, []);
1311
- (0, import_react2.useEffect)(() => {
1312
- if (!mountOverlay) {
1313
- setTimeout(() => setMountOverlay(true), 10);
1314
- }
1315
- }, [mountOverlay]);
1316
- const webViewRef = (0, import_react2.useCallback)((webView) => {
1317
- this.webView = webView;
1318
- }, []);
1319
- const containerRef = (0, import_react2.useCallback)((view) => {
1320
- this.container = {
1321
- ...view,
1322
- showOverlay,
1323
- hideOverlay
1324
- };
1325
- }, []);
1326
- const showOverlay = (0, import_react2.useCallback)(() => {
1327
- setShow(true);
1328
- }, []);
1329
- const hideOverlay = (0, import_react2.useCallback)(() => {
1330
- setShow(false);
1331
- }, []);
1332
- const containerStyles = (0, import_react2.useMemo)(() => {
1333
- return [
1334
- this.styles["webview-container"],
1335
- show ? {
1336
- ...this.styles.show,
1337
- backgroundColor: backgroundColor ?? DEFAULT_BACKGROUND_COLOR
1338
- } : this.styles.hide
1339
- ];
1340
- }, [show]);
1341
- const handleWebViewMessage = (0, import_react2.useCallback)((event) => {
1342
- this.handleReactNativeWebViewMessage(event);
1343
- }, []);
1344
- if (!mountOverlay) {
1345
- return null;
1346
- }
1347
- return /* @__PURE__ */ import_react2.default.createElement(import_react_native_safe_area_context.SafeAreaView, { ref: containerRef, style: containerStyles }, /* @__PURE__ */ import_react2.default.createElement(
1348
- import_react_native_webview.WebView,
1349
- {
1350
- ref: webViewRef,
1351
- source: { uri: `${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}` },
1352
- onMessage: handleWebViewMessage,
1353
- style: this.styles["magic-webview"],
1354
- autoManageStatusBarEnabled: false,
1355
- webviewDebuggingEnabled: true,
1356
- onShouldStartLoadWithRequest: (event) => {
1357
- const queryParams = new URLSearchParams(event.url.split("?")[1]);
1358
- const openInDeviceBrowser = queryParams.get(OPEN_IN_DEVICE_BROWSER);
1359
- if (openInDeviceBrowser) {
1360
- import_react_native.Linking.openURL(event.url);
1361
- return false;
1362
- }
1363
- return true;
1364
- }
1365
- }
1366
- ));
1367
- };
1368
- /**
1369
- * Route incoming messages from a React Native `<WebView>`.
1370
- */
1371
- handleReactNativeWebViewMessage(event) {
1372
- if (event.nativeEvent && typeof event.nativeEvent.data === "string" && /* Backward compatible */
1373
- (event.nativeEvent.url === `${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}` || event.nativeEvent.url === `${this.endpoint}/send/?params=${this.parameters}`)) {
1374
- const data = JSON.parse(event.nativeEvent.data, (key, value) => {
1375
- try {
1376
- if (value && typeof value === "object" && value.flag && value.flag === MAGIC_PAYLOAD_FLAG_TYPED_ARRAY) {
1377
- return new global[value.constructor](value.data.split(","));
1378
- }
1379
- } catch (e) {
1380
- }
1381
- return value;
1382
- });
1383
- if (data && data.msgType && this.messageHandlers.size) {
1384
- data.response = data.response ?? {};
1385
- const magicEvent = { data };
1386
- for (const handler of this.messageHandlers.values()) {
1387
- handler(magicEvent);
1388
- }
1389
- }
1390
- }
1391
- }
1392
- async msgPostedAfterInactivity() {
1393
- const lastPostTimestamp = await import_async_storage.default.getItem(LAST_MESSAGE_TIME);
1394
- if (lastPostTimestamp) {
1395
- const lastPostDate = new Date(lastPostTimestamp).getTime();
1396
- const now = (/* @__PURE__ */ new Date()).getTime();
1397
- const fiveMinutes = 5 * 60 * 1e3;
1398
- return now - lastPostDate > fiveMinutes;
1399
- }
1400
- return false;
1401
- }
1402
- hideOverlay() {
1403
- if (this.container) this.container.hideOverlay();
1404
- }
1405
- showOverlay() {
1406
- if (this.container) this.container.showOverlay();
1407
- }
1408
- async _post(data) {
1409
- if (await this.msgPostedAfterInactivity()) {
1410
- import_react_native_event_listeners.EventRegister.emit(MSG_POSTED_AFTER_INACTIVITY_EVENT, data);
1411
- return;
1412
- }
1413
- if (this.webView && this.webView.postMessage) {
1414
- this.webView.postMessage(
1415
- JSON.stringify(data, (key, value) => {
1416
- if ((0, import_lodash.isTypedArray)(value)) {
1417
- return {
1418
- constructor: value.constructor.name,
1419
- data: value.toString(),
1420
- flag: MAGIC_PAYLOAD_FLAG_TYPED_ARRAY
1421
- };
1422
- }
1423
- return value;
1424
- }),
1425
- this.endpoint
1426
- );
1427
- import_async_storage.default.setItem(LAST_MESSAGE_TIME, (/* @__PURE__ */ new Date()).toISOString());
1428
- } else {
1429
- throw (0, import_provider.createModalNotReadyError)();
1430
- }
1431
- }
1432
- // Todo - implement these methods
1433
- /* istanbul ignore next */
1434
- checkRelayerExistsInDOM() {
1435
- return Promise.resolve(true);
1436
- }
1437
- /* istanbul ignore next */
1438
- reloadRelayer() {
1439
- return Promise.resolve(void 0);
1440
- }
1441
- };
1442
-
1443
- // src/react-native-sdk-base.ts
1444
- var import_provider2 = require("@magic-sdk/provider");
1445
- var SDKBaseReactNative = class extends import_provider2.SDKBase {
1446
- get Relayer() {
1447
- return this.overlay.Relayer;
1448
- }
1449
- };
1450
-
1451
- // src/index.ts
1452
- __reExport(index_exports, require("@magic-sdk/commons"), module.exports);
1453
- global.process = _.merge(global.process, processPolyfill);
1454
- global.process.browser = false;
1455
- global.Buffer = import_buffer.Buffer;
1456
- global.URL = import_whatwg_url.URL;
1457
- global.URLSearchParams = import_whatwg_url.URLSearchParams;
1458
- global.btoa = (str) => import_buffer.Buffer.from(str, "binary").toString("base64");
1459
- global.atob = (b64Encoded) => import_buffer.Buffer.from(b64Encoded, "base64").toString("binary");
1460
- var Magic = (0, import_provider3.createSDK)(SDKBaseReactNative, {
1461
- platform: "react-native",
1462
- sdkName: "@magic-sdk/react-native-expo",
1463
- version: "30.4.0",
1464
- bundleId: Application.applicationId,
1465
- defaultEndpoint: "https://box.magic.link/",
1466
- ViewController: ReactNativeWebViewController,
1467
- configureStorage: (
1468
- /* istanbul ignore next */
1469
- async () => {
1470
- const lf = import_localforage.default.createInstance({
1471
- name: "MagicAuthLocalStorageDB",
1472
- storeName: "MagicAuthLocalStorage"
1473
- });
1474
- const driver = (0, import_localforage_asyncstorage_driver.driverWithoutSerialization)();
1475
- await Promise.all([lf.defineDriver(driver), lf.defineDriver(memoryDriver)]);
1476
- await lf.setDriver([driver._driver, memoryDriver._driver]);
1477
- return lf;
1478
- }
1479
- )
1480
- });
1481
- // Annotate the CommonJS export names for ESM import in node:
1482
- 0 && (module.exports = {
1483
- Magic,
1484
- useInternetConnection,
1485
- ...require("@magic-sdk/commons")
1486
- });
1
+ "use strict";var Mr=Object.create;var F=Object.defineProperty;var Lr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var Tr=Object.getPrototypeOf,kr=Object.prototype.hasOwnProperty;var d=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Br=(e,r)=>{for(var t in r)F(e,t,{get:r[t],enumerable:!0})},U=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Rr(r))!kr.call(e,a)&&a!==t&&F(e,a,{get:()=>r[a],enumerable:!(i=Lr(r,a))||i.enumerable});return e},v=(e,r,t)=>(U(e,r,"default"),t&&U(t,r,"default")),M=(e,r,t)=>(t=e!=null?Mr(Tr(e)):{},U(r||!e||!e.__esModule?F(t,"default",{value:e,enumerable:!0}):t,e)),Nr=e=>U(F({},"__esModule",{value:!0}),e);var Ve=d((Nt,fe)=>{"use strict";var ce=function(e){"use strict";var r=Object.prototype,t=r.hasOwnProperty,i,a=typeof Symbol=="function"?Symbol:{},u=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",m=a.toStringTag||"@@toStringTag";function y(o,n,s){return Object.defineProperty(o,n,{value:s,enumerable:!0,configurable:!0,writable:!0}),o[n]}try{y({},"")}catch{y=function(n,s,c){return n[s]=c}}function A(o,n,s,c){var l=n&&n.prototype instanceof ne?n:ne,p=Object.create(l.prototype),b=new se(c||[]);return p._invoke=Ar(o,s,b),p}e.wrap=A;function C(o,n,s){try{return{type:"normal",arg:o.call(n,s)}}catch(c){return{type:"throw",arg:c}}}var x="suspendedStart",te="suspendedYield",_="executing",N="completed",E={};function ne(){}function G(){}function R(){}var oe={};y(oe,u,function(){return this});var ie=Object.getPrototypeOf,V=ie&&ie(ie(ue([])));V&&V!==r&&t.call(V,u)&&(oe=V);var k=R.prototype=ne.prototype=Object.create(oe);G.prototype=R,y(k,"constructor",R),y(R,"constructor",G),G.displayName=y(R,m,"GeneratorFunction");function De(o){["next","throw","return"].forEach(function(n){y(o,n,function(s){return this._invoke(n,s)})})}e.isGeneratorFunction=function(o){var n=typeof o=="function"&&o.constructor;return n?n===G||(n.displayName||n.name)==="GeneratorFunction":!1},e.mark=function(o){return Object.setPrototypeOf?Object.setPrototypeOf(o,R):(o.__proto__=R,y(o,m,"GeneratorFunction")),o.prototype=Object.create(k),o},e.awrap=function(o){return{__await:o}};function K(o,n){function s(p,b,w,O){var I=C(o[p],o,b);if(I.type==="throw")O(I.arg);else{var le=I.arg,q=le.value;return q&&typeof q=="object"&&t.call(q,"__await")?n.resolve(q.__await).then(function(T){s("next",T,w,O)},function(T){s("throw",T,w,O)}):n.resolve(q).then(function(T){le.value=T,w(le)},function(T){return s("throw",T,w,O)})}}var c;function l(p,b){function w(){return new n(function(O,I){s(p,b,O,I)})}return c=c?c.then(w,w):w()}this._invoke=l}De(K.prototype),y(K.prototype,f,function(){return this}),e.AsyncIterator=K,e.async=function(o,n,s,c,l){l===void 0&&(l=Promise);var p=new K(A(o,n,s,c),l);return e.isGeneratorFunction(n)?p:p.next().then(function(b){return b.done?b.value:p.next()})};function Ar(o,n,s){var c=x;return function(p,b){if(c===_)throw new Error("Generator is already running");if(c===N){if(p==="throw")throw b;return Ge()}for(s.method=p,s.arg=b;;){var w=s.delegate;if(w){var O=xe(w,s);if(O){if(O===E)continue;return O}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(c===x)throw c=N,s.arg;s.dispatchException(s.arg)}else s.method==="return"&&s.abrupt("return",s.arg);c=_;var I=C(o,n,s);if(I.type==="normal"){if(c=s.done?N:te,I.arg===E)continue;return{value:I.arg,done:s.done}}else I.type==="throw"&&(c=N,s.method="throw",s.arg=I.arg)}}}function xe(o,n){var s=o.iterator[n.method];if(s===i){if(n.delegate=null,n.method==="throw"){if(o.iterator.return&&(n.method="return",n.arg=i,xe(o,n),n.method==="throw"))return E;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return E}var c=C(s,o.iterator,n.arg);if(c.type==="throw")return n.method="throw",n.arg=c.arg,n.delegate=null,E;var l=c.arg;if(!l)return n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,E;if(l.done)n[o.resultName]=l.value,n.next=o.nextLoc,n.method!=="return"&&(n.method="next",n.arg=i);else return l;return n.delegate=null,E}De(k),y(k,m,"Generator"),y(k,u,function(){return this}),y(k,"toString",function(){return"[object Generator]"});function Cr(o){var n={tryLoc:o[0]};1 in o&&(n.catchLoc=o[1]),2 in o&&(n.finallyLoc=o[2],n.afterLoc=o[3]),this.tryEntries.push(n)}function ae(o){var n=o.completion||{};n.type="normal",delete n.arg,o.completion=n}function se(o){this.tryEntries=[{tryLoc:"root"}],o.forEach(Cr,this),this.reset(!0)}e.keys=function(o){var n=[];for(var s in o)n.push(s);return n.reverse(),function c(){for(;n.length;){var l=n.pop();if(l in o)return c.value=l,c.done=!1,c}return c.done=!0,c}};function ue(o){if(o){var n=o[u];if(n)return n.call(o);if(typeof o.next=="function")return o;if(!isNaN(o.length)){var s=-1,c=function l(){for(;++s<o.length;)if(t.call(o,s))return l.value=o[s],l.done=!1,l;return l.value=i,l.done=!0,l};return c.next=c}}return{next:Ge}}e.values=ue;function Ge(){return{value:i,done:!0}}return se.prototype={constructor:se,reset:function(o){if(this.prev=0,this.next=0,this.sent=this._sent=i,this.done=!1,this.delegate=null,this.method="next",this.arg=i,this.tryEntries.forEach(ae),!o)for(var n in this)n.charAt(0)==="t"&&t.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=i)},stop:function(){this.done=!0;var o=this.tryEntries[0],n=o.completion;if(n.type==="throw")throw n.arg;return this.rval},dispatchException:function(o){if(this.done)throw o;var n=this;function s(O,I){return p.type="throw",p.arg=o,n.next=O,I&&(n.method="next",n.arg=i),!!I}for(var c=this.tryEntries.length-1;c>=0;--c){var l=this.tryEntries[c],p=l.completion;if(l.tryLoc==="root")return s("end");if(l.tryLoc<=this.prev){var b=t.call(l,"catchLoc"),w=t.call(l,"finallyLoc");if(b&&w){if(this.prev<l.catchLoc)return s(l.catchLoc,!0);if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else if(b){if(this.prev<l.catchLoc)return s(l.catchLoc,!0)}else if(w){if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(o,n){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.tryLoc<=this.prev&&t.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var l=c;break}}l&&(o==="break"||o==="continue")&&l.tryLoc<=n&&n<=l.finallyLoc&&(l=null);var p=l?l.completion:{};return p.type=o,p.arg=n,l?(this.method="next",this.next=l.finallyLoc,E):this.complete(p)},complete:function(o,n){if(o.type==="throw")throw o.arg;return o.type==="break"||o.type==="continue"?this.next=o.arg:o.type==="return"?(this.rval=this.arg=o.arg,this.method="return",this.next="end"):o.type==="normal"&&n&&(this.next=n),E},finish:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.finallyLoc===o)return this.complete(s.completion,s.afterLoc),ae(s),E}},catch:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.tryLoc===o){var c=s.completion;if(c.type==="throw"){var l=c.arg;ae(s)}return l}}throw new Error("illegal catch attempt")},delegateYield:function(o,n,s){return this.delegate={iterator:ue(o),resultName:n,nextLoc:s},this.method==="next"&&(this.arg=i),E}},e}(typeof fe=="object"?fe.exports:{});try{regeneratorRuntime=ce}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=ce:Function("r","regeneratorRuntime = r")(ce)}});var Ke=d(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he._driver="localforage-driver-memory"});var Ue=d(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});function qr(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(u){if(u.name!=="TypeError")throw u;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,i=new t,a=0;a<e.length;a+=1)i.append(e[a]);return i.getBlob(r.type)}}ve.createBlob=qr});var Je=d(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});var jr=Ue(),Fe=/^~~local_forage_type~([^~]+)~/,de=9,We=de+4,ze=Object.prototype.toString;function Ye(e){var r=e.length*.75,t=e.length;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);for(var i=new ArrayBuffer(r),a=new Uint8Array(i),u=0,f=0;u<t;u+=4){var m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u]),y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+1]),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+2]),C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+3]);a[f++]=m<<2|y>>4,a[f++]=(y&15)<<4|A>>2,a[f++]=(A&3)<<6|C&63}return i}B.stringToBuffer=Ye;function me(e){for(var r=new Uint8Array(e),t="",i=0;i<r.length;i+=3)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i]>>2],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i]&3)<<4|r[i+1]>>4],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i+1]&15)<<2|r[i+2]>>6],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}B.bufferToString=me;function Dr(e,r){var t="";if(e&&(t=ze.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&ze.call(e.buffer)==="[object ArrayBuffer]")){var i=void 0,a="__lfsc__:";e instanceof ArrayBuffer?(i=e,a+="arbf"):(i=e.buffer,t==="[object Int8Array]"?a+="si08":t==="[object Uint8Array]"?a+="ui08":t==="[object Uint8ClampedArray]"?a+="uic8":t==="[object Int16Array]"?a+="si16":t==="[object Uint16Array]"?a+="ur16":t==="[object Int32Array]"?a+="si32":t==="[object Uint32Array]"?a+="ui32":t==="[object Float32Array]"?a+="fl32":t==="[object Float64Array]"?a+="fl64":r(new Error("Failed to get type for BinaryArray"))),r(a+me(i))}else if(t==="[object Blob]"){var u=new FileReader;u.onload=function(){var f="~~local_forage_type~"+e.type+"~"+me(this.result);r("__lfsc__:blob"+f)},u.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),r(null,f)}}B.serialize=Dr;function xr(e){if(e.substring(0,de)!=="__lfsc__:")return JSON.parse(e);var r=e.substring(We),t=e.substring(de,We),i;if(t==="blob"&&Fe.test(r)){var a=r.match(Fe);i=a[1],r=r.substring(a[0].length)}var u=Ye(r);switch(t){case"arbf":return u;case"blob":return jr.createBlob([u],{type:i});case"si08":return new Int8Array(u);case"ui08":return new Uint8Array(u);case"uic8":return new Uint8ClampedArray(u);case"si16":return new Int16Array(u);case"ur16":return new Uint16Array(u);case"si32":return new Int32Array(u);case"ui32":return new Uint32Array(u);case"fl32":return new Float32Array(u);case"fl64":return new Float64Array(u);default:throw new Error("Unkown type: "+t)}}B.deserialize=xr});var Xe=d(j=>{"use strict";var Gr=j&&j.__values||function(e){var r=typeof Symbol=="function"&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}};Object.defineProperty(j,"__esModule",{value:!0});function He(e){var r,t;if(e===null||typeof e!="object"||"isActiveClone"in e)return e;var i=e instanceof Date?new Date(e):e.constructor();try{for(var a=Gr(Object.keys(e)),u=a.next();!u.done;u=a.next()){var f=u.value;Object.prototype.hasOwnProperty.call(e,f)&&(e.isActiveClone=null,i[f]=He(e[f]),delete e.isActiveClone)}}catch(m){r={error:m}}finally{try{u&&!u.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}return i}j.clone=He});var ye=d(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});function Vr(e,r){return(e.name||r.name)+"/"+(e.storeName||r.storeName)+"/"}pe.getKeyPrefix=Vr});var Ze=d(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});function Kr(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}ge.executeCallback=Kr});var be=d(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});function Ur(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}_e.getCallback=Ur});var Qe=d(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});var Fr=be(),Wr=ye();function zr(e,r){var t=this;if(r=Fr.getCallback.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var i=this.config();e.name=e.name||i.name,e.storeName=e.storeName||i.storeName}var a;return e.name?a=new Promise(function(u){e.storeName?u(Wr.getKeyPrefix(e,t._defaultConfig)):u(e.name+"/")}):a=Promise.reject("Invalid arguments"),{promise:a,callback:r}}we.dropInstanceCommon=zr});var $e=d(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});function Yr(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}Ie.normaliseKey=Yr});var P=d(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});var W=Je(),Jr=Xe();L.clone=Jr.clone;var Hr=ye();L.getKeyPrefix=Hr.getKeyPrefix;var Xr=Ze();L.executeCallback=Xr.executeCallback;var Zr=be();L.getCallback=Zr.getCallback;var Qr=Qe();L.dropInstanceCommon=Qr.dropInstanceCommon;var $r=$e();L.normaliseKey=$r.normaliseKey;L.serialiser={bufferToString:W.bufferToString,deserialize:W.deserialize,serialize:W.serialize,stringToBuffer:W.stringToBuffer}});var Ee=d(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});var z={},et=function(){function e(r){this.kp=r,this.data={}}return e.resolve=function(r){return z[r]||(z[r]=new e(r)),z[r]},e.prototype.clear=function(){this.data={}},e.prototype.drop=function(){this.clear(),delete z[this.kp]},e.prototype.get=function(r){return this.data[r]},e.prototype.key=function(r){return this.keys()[r]},e.prototype.keys=function(){return Object.keys(this.data)},e.prototype.rm=function(r){delete this.data[r]},e.prototype.set=function(r,t){this.data[r]=t},e}();Se.Store=et});var er=d(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});var Oe=P(),rt=Ee();function tt(e){var r=e?Oe.clone(e):{},t=Oe.getKeyPrefix(r,this._defaultConfig),i=rt.Store.resolve(t);return this._dbInfo=r,this._dbInfo.serializer=Oe.serialiser,this._dbInfo.keyPrefix=t,this._dbInfo.mStore=i,Promise.resolve()}Pe._initStorage=tt});var rr=d(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});var nt=P();function ot(e){var r=this,t=this.ready().then(function(){r._dbInfo.mStore.clear()});return nt.executeCallback(t,e),t}Ae.clear=ot});var nr=d(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});var tr=P(),it=Ee();function at(e,r){var t=tr.dropInstanceCommon.apply(this,arguments),i=t.promise,a=t.callback,u=i.then(function(f){it.Store.resolve(f).drop()});return tr.executeCallback(u,a),i}Ce.dropInstance=at});var ir=d(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});var or=P();function st(e,r){var t=this;e=or.normaliseKey(e);var i=this.ready().then(function(){var a=t._dbInfo.mStore.get(e);return a==null?null:t._dbInfo.serializer.deserialize(a)});return or.executeCallback(i,r),i}Me.getItem=st});var ar=d(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var ut=P();function lt(e,r){var t=this,i=this.ready().then(function(){for(var a=t._dbInfo.mStore,u=a.keys(),f=0;f<u.length;f++){var m=a.get(u[f]);if(m&&(m=t._dbInfo.serializer.deserialize(m)),m=e(m,u[f],f+1),m!==void 0)return m}});return ut.executeCallback(i,r),i}Le.iterate=lt});var sr=d(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});var ct=P();function ft(e,r){var t=this,i=this.ready().then(function(){var a;try{a=t._dbInfo.mStore.key(e),a===void 0&&(a=null)}catch{a=null}return a});return ct.executeCallback(i,r),i}Re.key=ft});var ur=d(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});var ht=P();function vt(e){var r=this,t=this.ready().then(function(){return r._dbInfo.mStore.keys()});return ht.executeCallback(t,e),t}Te.keys=vt});var lr=d(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});var dt=P();function mt(e){var r=this.keys().then(function(t){return t.length});return dt.executeCallback(r,e),r}ke.length=mt});var fr=d(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});var cr=P();function pt(e,r){var t=this;e=cr.normaliseKey(e);var i=this.ready().then(function(){t._dbInfo.mStore.rm(e)});return cr.executeCallback(i,r),i}Be.removeItem=pt});var vr=d(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});var hr=P();function yt(e,r,t){var i=this;e=hr.normaliseKey(e);var a=this.ready().then(function(){r===void 0&&(r=null);var u=r;return new Promise(function(f,m){i._dbInfo.serializer.serialize(r,function(y,A){if(A)m(A);else try{i._dbInfo.mStore.set(e,y),f(u)}catch(C){m(C)}})})});return hr.executeCallback(a,t),a}Ne.setItem=yt});var dr=d(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S._support=!0;var gt=Ke();S._driver=gt._driver;var _t=er();S._initStorage=_t._initStorage;var bt=rr();S.clear=bt.clear;var wt=nr();S.dropInstance=wt.dropInstance;var It=ir();S.getItem=It.getItem;var St=ar();S.iterate=St.iterate;var Et=sr();S.key=Et.key;var Ot=ur();S.keys=Ot.keys;var Pt=lr();S.length=Pt.length;var At=fr();S.removeItem=At.removeItem;var Ct=vr();S.setItem=Ct.setItem});var h={};Br(h,{Magic:()=>kt,useInternetConnection:()=>J});module.exports=Nr(h);var fn=M(Ve()),Ir=require("@magic-sdk/provider"),Tt=M(require("process")),Sr=M(require("localforage")),ee=require("whatwg-url"),re=require("buffer"),Er=M(require("lodash")),Or=M(require("expo-application")),Pr=require("@aveq-research/localforage-asyncstorage-driver"),je=M(dr());var g=M(require("react")),Z=require("react-native"),gr=require("react-native-webview"),_r=require("react-native-safe-area-context"),Q=require("@magic-sdk/provider"),br=require("lodash"),D=M(require("@react-native-async-storage/async-storage")),qe=require("react-native-event-listeners");var Y=require("react"),mr=M(require("@react-native-community/netinfo")),J=()=>{let[e,r]=(0,Y.useState)(!0);return(0,Y.useEffect)(()=>{let t=i=>{r(!!i.isConnected)};return mr.default.addEventListener(t)},[]),e};var pr="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Mt="open_in_device_browser",Lt="#FFFFFF",yr="msg_posted_after_inactivity_event",H="lastMessageTime";function Rt(){return Z.StyleSheet.create({"magic-webview":{flex:1,backgroundColor:"transparent"},"webview-container":{flex:1,width:"100%",backgroundColor:"transparent",position:"absolute",top:0,left:0,right:0,bottom:0},show:{zIndex:1e4,elevation:1e4},hide:{zIndex:-1e4,elevation:0}})}var X=class extends Q.ViewController{webView;container;styles;init(){this.webView=null,this.container=null,this.styles=Rt()}Relayer=r=>{let[t,i]=(0,g.useState)(!1),[a,u]=(0,g.useState)(!0),f=J();(0,g.useEffect)(()=>{this.isConnectedToInternet=f},[f]),(0,g.useEffect)(()=>(D.default.setItem(H,""),()=>{this.isReadyForRequest=!1}),[]),(0,g.useEffect)(()=>{qe.EventRegister.addEventListener(yr,async _=>{this.isReadyForRequest=!1,u(!1),this.post(_.msgType,_.payload),await D.default.setItem(H,new Date().toISOString())})},[]),(0,g.useEffect)(()=>{a||setTimeout(()=>u(!0),10)},[a]);let m=(0,g.useCallback)(_=>{this.webView=_},[]),y=(0,g.useCallback)(_=>{this.container={..._,showOverlay:A,hideOverlay:C}},[]),A=(0,g.useCallback)(()=>{i(!0)},[]),C=(0,g.useCallback)(()=>{i(!1)},[]),x=(0,g.useMemo)(()=>[this.styles["webview-container"],t?{...this.styles.show,backgroundColor:r??Lt}:this.styles.hide],[t]),te=(0,g.useCallback)(_=>{this.handleReactNativeWebViewMessage(_)},[]);return a?g.default.createElement(_r.SafeAreaView,{ref:y,style:x},g.default.createElement(gr.WebView,{ref:m,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:te,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1,webviewDebuggingEnabled:!0,onShouldStartLoadWithRequest:_=>new URLSearchParams(_.url.split("?")[1]).get(Mt)?(Z.Linking.openURL(_.url),!1):!0})):null};handleReactNativeWebViewMessage(r){if(r.nativeEvent&&typeof r.nativeEvent.data=="string"&&(r.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||r.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let t=JSON.parse(r.nativeEvent.data,(i,a)=>{try{if(a&&typeof a=="object"&&a.flag&&a.flag===pr)return new global[a.constructor](a.data.split(","))}catch{}return a});if(t&&t.msgType&&this.messageHandlers.size){t.response=t.response??{};let i={data:t};for(let a of this.messageHandlers.values())a(i)}}}async msgPostedAfterInactivity(){let r=await D.default.getItem(H);if(r){let t=new Date(r).getTime(),i=new Date().getTime(),a=5*60*1e3;return i-t>a}return!1}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}async _post(r){if(await this.msgPostedAfterInactivity()){qe.EventRegister.emit(yr,r);return}if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(r,(t,i)=>(0,br.isTypedArray)(i)?{constructor:i.constructor.name,data:i.toString(),flag:pr}:i),this.endpoint),D.default.setItem(H,new Date().toISOString());else throw(0,Q.createModalNotReadyError)()}checkRelayerExistsInDOM(){return Promise.resolve(!0)}reloadRelayer(){return Promise.resolve(void 0)}};var wr=require("@magic-sdk/provider"),$=class extends wr.SDKBase{get Relayer(){return this.overlay.Relayer}};v(h,require("@magic-sdk/commons"),module.exports);global.process=Er.merge(global.process,Tt);global.process.browser=!1;global.Buffer=re.Buffer;global.URL=ee.URL;global.URLSearchParams=ee.URLSearchParams;global.btoa=e=>re.Buffer.from(e,"binary").toString("base64");global.atob=e=>re.Buffer.from(e,"base64").toString("binary");var kt=(0,Ir.createSDK)($,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"30.4.1",bundleId:Or.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:X,configureStorage:async()=>{let e=Sr.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),r=(0,Pr.driverWithoutSerialization)();return await Promise.all([e.defineDriver(r),e.defineDriver(je)]),await e.setDriver([r._driver,je._driver]),e}});0&&(module.exports={Magic,useInternetConnection,...require("@magic-sdk/commons")});
1487
2
  //# sourceMappingURL=index.js.map