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