@paywithglide/glide-react 0.0.23 → 0.0.25

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.
@@ -113,7 +113,9 @@ export type GlideDepositOptions = {
113
113
  autoCloseOnSuccess?: boolean;
114
114
  container?: HTMLElement;
115
115
  theme?: GlideWidgetTheme;
116
+ popupsBlocked?: boolean;
116
117
  baseUrl?: string;
118
+ debug?: boolean;
117
119
  };
118
120
  export declare class GlideDeposit {
119
121
  opts: GlideDepositOptions;
@@ -1,6 +1,6 @@
1
- export declare const browserLocalStorageProvider: {
1
+ export declare const browserLocalStorageProvider: Readonly<{
2
2
  getItem: (key: string) => Promise<string | null>;
3
3
  setItem: (key: string, value: string) => Promise<void>;
4
4
  removeItem: (key: string) => Promise<void>;
5
5
  getKeys: () => Promise<string[]>;
6
- };
6
+ }>;
package/dist/glide.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var Z = Object.defineProperty;
2
2
  var _ = (s, t, e) => t in s ? Z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var x = (s, t, e) => _(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { useMemo as I } from "react";
3
+ var I = (s, t, e) => _(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { useMemo as P } from "react";
5
5
  function ee(s, { strict: t = !0 } = {}) {
6
6
  return !s || typeof s != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(s) : s.startsWith("0x");
7
7
  }
@@ -9,23 +9,23 @@ function K(s) {
9
9
  return ee(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
10
10
  }
11
11
  const N = "2.21.51";
12
- let b = {
12
+ let $ = {
13
13
  getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
14
14
  version: `viem@${N}`
15
15
  };
16
- class w extends Error {
16
+ class v extends Error {
17
17
  constructor(t, e = {}) {
18
18
  var a;
19
19
  const i = (() => {
20
20
  var n;
21
- return e.cause instanceof w ? e.cause.details : (n = e.cause) != null && n.message ? e.cause.message : e.details;
22
- })(), r = e.cause instanceof w && e.cause.docsPath || e.docsPath, o = (a = b.getDocsUrl) == null ? void 0 : a.call(b, { ...e, docsPath: r }), c = [
21
+ return e.cause instanceof v ? e.cause.details : (n = e.cause) != null && n.message ? e.cause.message : e.details;
22
+ })(), r = e.cause instanceof v && e.cause.docsPath || e.docsPath, o = (a = $.getDocsUrl) == null ? void 0 : a.call($, { ...e, docsPath: r }), c = [
23
23
  t || "An error occurred.",
24
24
  "",
25
25
  ...e.metaMessages ? [...e.metaMessages, ""] : [],
26
26
  ...o ? [`Docs: ${o}`] : [],
27
27
  ...i ? [`Details: ${i}`] : [],
28
- ...b.version ? [`Version: ${b.version}`] : []
28
+ ...$.version ? [`Version: ${$.version}`] : []
29
29
  ].join(`
30
30
  `);
31
31
  super(c, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
@@ -67,12 +67,12 @@ class w extends Error {
67
67
  function R(s, t) {
68
68
  return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? R(s.cause, t) : t ? null : s;
69
69
  }
70
- class F extends w {
70
+ class F extends v {
71
71
  constructor({ size: t, targetSize: e, type: i }) {
72
72
  super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${t}) exceeds padding size (${e}).`, { name: "SizeExceedsPaddingSizeError" });
73
73
  }
74
74
  }
75
- function S(s, { dir: t, size: e = 32 } = {}) {
75
+ function E(s, { dir: t, size: e = 32 } = {}) {
76
76
  return typeof s == "string" ? te(s, { dir: t, size: e }) : se(s, { dir: t, size: e });
77
77
  }
78
78
  function te(s, { dir: t, size: e = 32 } = {}) {
@@ -103,12 +103,12 @@ function se(s, { dir: t, size: e = 32 } = {}) {
103
103
  }
104
104
  return i;
105
105
  }
106
- class ie extends w {
106
+ class ie extends v {
107
107
  constructor({ max: t, min: e, signed: i, size: r, value: o }) {
108
108
  super(`Number "${o}" is not in safe ${r ? `${r * 8}-bit ${i ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${e} to ${t})` : `(above ${e})`}`, { name: "IntegerOutOfRangeError" });
109
109
  }
110
110
  }
111
- class re extends w {
111
+ class re extends v {
112
112
  constructor({ givenSize: t, maxSize: e }) {
113
113
  super(`Size cannot exceed ${e} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
114
114
  }
@@ -126,14 +126,14 @@ function ne(s, t = {}) {
126
126
  }
127
127
  function ae(s, t = {}) {
128
128
  const e = `0x${Number(s)}`;
129
- return typeof t.size == "number" ? (V(e, { size: t.size }), S(e, { size: t.size })) : e;
129
+ return typeof t.size == "number" ? (V(e, { size: t.size }), E(e, { size: t.size })) : e;
130
130
  }
131
131
  function q(s, t = {}) {
132
132
  let e = "";
133
133
  for (let r = 0; r < s.length; r++)
134
134
  e += oe[s[r]];
135
135
  const i = `0x${e}`;
136
- return typeof t.size == "number" ? (V(i, { size: t.size }), S(i, { dir: "right", size: t.size })) : i;
136
+ return typeof t.size == "number" ? (V(i, { size: t.size }), E(i, { dir: "right", size: t.size })) : i;
137
137
  }
138
138
  function ce(s, t = {}) {
139
139
  const { signed: e, size: i } = t, r = BigInt(s);
@@ -151,17 +151,17 @@ function ce(s, t = {}) {
151
151
  });
152
152
  }
153
153
  const a = `0x${(e && r < 0 ? (1n << BigInt(i * 8)) + BigInt(r) : r).toString(16)}`;
154
- return i ? S(a, { size: i }) : a;
154
+ return i ? E(a, { size: i }) : a;
155
155
  }
156
156
  const de = /* @__PURE__ */ new TextEncoder();
157
157
  function le(s, t = {}) {
158
158
  const e = de.encode(s);
159
159
  return q(e, t);
160
160
  }
161
- class P {
161
+ class S {
162
162
  constructor(t) {
163
- x(this, "opts");
164
- x(this, "open", () => {
163
+ I(this, "opts");
164
+ I(this, "open", () => {
165
165
  if (!(!this.opts.container && document.body.classList.contains("glide-deposit-open"))) {
166
166
  if (this.opts.container || document.body.classList.add("glide-deposit-open"), (this.opts.mode === "deposit" || this.opts.mode === "buy") && !this.opts.recipient)
167
167
  throw new Error("recipient is required for deposit/buy mode");
@@ -172,8 +172,8 @@ class P {
172
172
  this.openUrl(`${this.baseUrl}${this.opts.app}?init=true&embed=true`), this.initialize();
173
173
  }
174
174
  });
175
- x(this, "iframeEventHandler", async (t) => {
176
- var i, r, o, c, a, n, p, h, u, m, f, g, d, y, v, E, $, k, U, z, M, T, D, A, G, j, C, W, B, H, L, O;
175
+ I(this, "iframeEventHandler", async (t) => {
176
+ var i, r, o, c, a, n, p, h, u, m, f, g, d, b, w, y, x, k, U, z, M, T, D, A, G, j, B, C, W, H, L, O;
177
177
  const e = t.data;
178
178
  switch (e.type) {
179
179
  case "sendInit": {
@@ -197,7 +197,9 @@ class P {
197
197
  sessionMetadata: this.opts.sessionMetadata,
198
198
  autoCloseOnSuccess: this.opts.autoCloseOnSuccess,
199
199
  theme: this.opts.theme,
200
- didProvideLocalStorage: !!this.opts.localStorageProvider
200
+ didProvideLocalStorage: !!this.opts.localStorageProvider,
201
+ debug: this.opts.debug,
202
+ popupsBlocked: this.opts.popupsBlocked
201
203
  },
202
204
  new URL(this.baseUrl).origin
203
205
  ), this.iframe.style.opacity = "1", (h = (p = this.opts).onOpen) == null || h.call(p);
@@ -244,13 +246,13 @@ class P {
244
246
  break;
245
247
  }
246
248
  case "success":
247
- (y = (d = this.opts) == null ? void 0 : d.onSuccess) == null || y.call(d, e.hash);
249
+ (b = (d = this.opts) == null ? void 0 : d.onSuccess) == null || b.call(d, e.hash);
248
250
  break;
249
251
  case "close":
250
- this.removeIframe(), this.destroy(), (E = (v = this.opts) == null ? void 0 : v.onClose) == null || E.call(v);
252
+ this.removeIframe(), this.destroy(), (y = (w = this.opts) == null ? void 0 : w.onClose) == null || y.call(w);
251
253
  break;
252
254
  case "setMode":
253
- (k = ($ = this.opts) == null ? void 0 : $.onSetMode) == null || k.call($, e.mode);
255
+ (k = (x = this.opts) == null ? void 0 : x.onSetMode) == null || k.call(x, e.mode);
254
256
  break;
255
257
  case "switchChain":
256
258
  if (!this.opts.walletProvider)
@@ -310,7 +312,7 @@ class P {
310
312
  if (!this.opts.walletProvider)
311
313
  throw new Error("walletProvider is not set");
312
314
  if (!this.opts.walletProvider.signTypedDataAsync) {
313
- (W = (C = this.iframe) == null ? void 0 : C.contentWindow) == null || W.postMessage(
315
+ (C = (B = this.iframe) == null ? void 0 : B.contentWindow) == null || C.postMessage(
314
316
  {
315
317
  type: "didSignTypedData",
316
318
  success: !1,
@@ -324,7 +326,7 @@ class P {
324
326
  const l = await this.opts.walletProvider.signTypedDataAsync(
325
327
  e.data
326
328
  );
327
- (H = (B = this.iframe) == null ? void 0 : B.contentWindow) == null || H.postMessage(
329
+ (H = (W = this.iframe) == null ? void 0 : W.contentWindow) == null || H.postMessage(
328
330
  {
329
331
  type: "didSignTypedData",
330
332
  success: !0,
@@ -352,7 +354,7 @@ class P {
352
354
  var t, e, i;
353
355
  return `${this.baseUrl}${this.opts.app}?${this.opts.recipient ? `&recipient=${this.opts.recipient}` : ""}${this.opts.preferGaslessPayment ? "&preferGaslessPayment=true" : ""}${this.opts.mode ? `&mode=${this.opts.mode}` : ""}${this.opts.amount ? `&amount=${this.opts.amount}` : ""}${this.opts.evm ? `&evm.chainId=${this.opts.evm.chainId}&evm.to=${this.opts.evm.to}&evm.data=${this.opts.evm.data || "0x0"}&evm.value=${ne(
354
356
  this.opts.evm.value || 0n
355
- )}` : ""}${this.opts.approval ? `&approval.token=${this.opts.approval.token}&approval.amount=${this.opts.approval.amount}` : ""}${this.opts.sessionMetadata ? `&metadata=${this.opts.sessionMetadata}` : ""}${this.opts.autoCloseOnSuccess ? "&autoCloseOnSuccess=true" : ""}${this.opts.sessionId ? `&sessionId=${this.opts.sessionId}` : ""}${(t = this.opts.excludeChainIds) != null && t.length ? `&excludeChainIds=${this.opts.excludeChainIds.join(",")}` : ""}${(e = this.opts.excludeCurrencyTiers) != null && e.length ? `&excludeCurrencyTiers=${this.opts.excludeCurrencyTiers.join(",")}` : ""}${(i = this.opts.excludeFundingSources) != null && i.length ? `&excludeFundingSources=${this.opts.excludeFundingSources.join(",")}` : ""}`;
357
+ )}` : ""}${this.opts.approval ? `&approval.token=${this.opts.approval.token}&approval.amount=${this.opts.approval.amount}` : ""}${this.opts.sessionMetadata ? `&metadata=${this.opts.sessionMetadata}` : ""}${this.opts.autoCloseOnSuccess ? "&autoCloseOnSuccess=true" : ""}${this.opts.sessionId ? `&sessionId=${this.opts.sessionId}` : ""}${(t = this.opts.excludeChainIds) != null && t.length ? `&excludeChainIds=${this.opts.excludeChainIds.join(",")}` : ""}${(e = this.opts.excludeCurrencyTiers) != null && e.length ? `&excludeCurrencyTiers=${this.opts.excludeCurrencyTiers.join(",")}` : ""}${(i = this.opts.excludeFundingSources) != null && i.length ? `&excludeFundingSources=${this.opts.excludeFundingSources.join(",")}` : ""}${this.opts.debug ? "debug=true" : ""}${this.opts.popupsBlocked ? "popupsBlocked=true" : ""}`;
356
358
  }
357
359
  initialize() {
358
360
  window.addEventListener("message", this.iframeEventHandler);
@@ -403,9 +405,11 @@ const ue = ({
403
405
  onSuccess: m,
404
406
  onClose: f,
405
407
  autoCloseOnSuccess: g,
406
- baseUrl: d
408
+ popupsBlocked: d,
409
+ baseUrl: b,
410
+ debug: w
407
411
  }) => {
408
- const y = I(() => new P({
412
+ const y = P(() => new S({
409
413
  app: s,
410
414
  recipient: t,
411
415
  preferGaslessPayment: e,
@@ -421,7 +425,9 @@ const ue = ({
421
425
  onSuccess: m,
422
426
  onClose: f,
423
427
  autoCloseOnSuccess: g,
424
- baseUrl: d
428
+ popupsBlocked: d,
429
+ baseUrl: b,
430
+ debug: w
425
431
  }), [
426
432
  s,
427
433
  t,
@@ -438,7 +444,9 @@ const ue = ({
438
444
  m,
439
445
  f,
440
446
  g,
441
- d
447
+ d,
448
+ b,
449
+ w
442
450
  ]);
443
451
  return {
444
452
  openGlideDeposit: y.open,
@@ -461,9 +469,11 @@ const ue = ({
461
469
  onSuccess: m,
462
470
  onClose: f,
463
471
  autoCloseOnSuccess: g,
464
- baseUrl: d
472
+ popupsBlocked: d,
473
+ baseUrl: b,
474
+ debug: w
465
475
  }) => {
466
- const y = I(() => new P({
476
+ const y = P(() => new S({
467
477
  app: s,
468
478
  preferGaslessPayment: t,
469
479
  excludeChainIds: e,
@@ -480,7 +490,9 @@ const ue = ({
480
490
  onSuccess: m,
481
491
  onClose: f,
482
492
  autoCloseOnSuccess: g,
483
- baseUrl: d
493
+ popupsBlocked: d,
494
+ baseUrl: b,
495
+ debug: w
484
496
  }), [
485
497
  s,
486
498
  t,
@@ -497,7 +509,9 @@ const ue = ({
497
509
  m,
498
510
  f,
499
511
  g,
500
- d
512
+ d,
513
+ b,
514
+ w
501
515
  ]);
502
516
  return {
503
517
  openGlidePay: y.open,
@@ -520,9 +534,11 @@ const ue = ({
520
534
  onSuccess: m,
521
535
  onClose: f,
522
536
  autoCloseOnSuccess: g,
523
- baseUrl: d
537
+ popupsBlocked: d,
538
+ baseUrl: b,
539
+ debug: w
524
540
  }) => {
525
- const y = I(() => new P({
541
+ const y = P(() => new S({
526
542
  app: s,
527
543
  evm: t,
528
544
  approval: e,
@@ -539,7 +555,9 @@ const ue = ({
539
555
  onSuccess: m,
540
556
  onClose: f,
541
557
  autoCloseOnSuccess: g,
542
- baseUrl: d
558
+ popupsBlocked: d,
559
+ baseUrl: b,
560
+ debug: w
543
561
  }), [
544
562
  s,
545
563
  t,
@@ -556,7 +574,9 @@ const ue = ({
556
574
  m,
557
575
  f,
558
576
  g,
559
- d
577
+ d,
578
+ b,
579
+ w
560
580
  ]);
561
581
  return {
562
582
  openGlideCall: y.open,
@@ -580,7 +600,7 @@ const ue = ({
580
600
  autoCloseOnSuccess: f,
581
601
  baseUrl: g
582
602
  }) => {
583
- const d = I(() => new P({
603
+ const d = P(() => new S({
584
604
  app: s,
585
605
  recipient: t,
586
606
  preferGaslessPayment: e,
@@ -619,7 +639,7 @@ const ue = ({
619
639
  externalUrl: d.externalUrl,
620
640
  opts: d.opts
621
641
  };
622
- }, ye = {
642
+ }, ye = Object.freeze({
623
643
  getItem: (s) => new Promise((t, e) => {
624
644
  try {
625
645
  const i = localStorage.getItem(s);
@@ -650,9 +670,9 @@ const ue = ({
650
670
  t(e);
651
671
  }
652
672
  })
653
- };
673
+ });
654
674
  export {
655
- P as GlideDeposit,
675
+ S as GlideDeposit,
656
676
  ye as browserLocalStorageProvider,
657
677
  ge as useGlideBuy,
658
678
  fe as useGlideCall,
@@ -25,9 +25,11 @@ interface UseGlideCallProps {
25
25
  onSuccess?: (hash: Hex) => void;
26
26
  onClose?: () => void;
27
27
  autoCloseOnSuccess?: boolean;
28
+ popupsBlocked?: boolean;
28
29
  baseUrl?: string;
30
+ debug?: boolean;
29
31
  }
30
- export declare const useGlideCall: ({ app, evm, approval, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, baseUrl, }: UseGlideCallProps) => {
32
+ export declare const useGlideCall: ({ app, evm, approval, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideCallProps) => {
31
33
  openGlideCall: () => void;
32
34
  externalUrl: string;
33
35
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
@@ -17,9 +17,11 @@ interface UseGlideDepositProps {
17
17
  onSuccess?: (hash: string) => void;
18
18
  onClose?: () => void;
19
19
  autoCloseOnSuccess?: boolean;
20
+ popupsBlocked?: boolean;
20
21
  baseUrl?: string;
22
+ debug?: boolean;
21
23
  }
22
- export declare const useGlideDeposit: ({ app, recipient, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, baseUrl, }: UseGlideDepositProps) => {
24
+ export declare const useGlideDeposit: ({ app, recipient, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
23
25
  openGlideDeposit: () => void;
24
26
  externalUrl: string;
25
27
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
@@ -17,9 +17,11 @@ type UseGlidePayProps = {
17
17
  onSuccess?: (hash: string) => void;
18
18
  onClose?: () => void;
19
19
  autoCloseOnSuccess?: boolean;
20
+ popupsBlocked?: boolean;
20
21
  baseUrl?: string;
22
+ debug?: boolean;
21
23
  };
22
- export declare const useGlidePay: ({ app, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, amount, sessionId, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, baseUrl, }: UseGlidePayProps) => {
24
+ export declare const useGlidePay: ({ app, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, amount, sessionId, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlidePayProps) => {
23
25
  openGlidePay: () => void;
24
26
  externalUrl: string;
25
27
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithglide/glide-react",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"