@paywithglide/glide-react 0.0.31 → 0.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { GlideWidgetTheme } from './theme.ts';
2
- import { CAIP2 } from '@paywithglide/glide-js';
2
+ import { CAIP2, Session } from '@paywithglide/glide-js';
3
3
  export type Hex = `0x${string}`;
4
4
  export type EVMTransaction = {
5
5
  chainId: number;
@@ -110,7 +110,7 @@ export type GlideDepositOptions = {
110
110
  walletProvider?: GlideDepositWalletProvider;
111
111
  localStorageProvider?: GlideLocalStorageProvider;
112
112
  onOpen?: () => void;
113
- onSuccess?: (hash: Hex) => void;
113
+ onSuccess?: (fulfillmentTxHash: Hex, session: Session) => void;
114
114
  onClose?: () => void;
115
115
  onSetMode?: (mode: "deposit" | "withdraw") => void;
116
116
  autoCloseOnSuccess?: boolean;
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 E = (s, t, e) => _(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { useMemo as k } from "react";
3
+ var k = (s, t, e) => _(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { useMemo as U } 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,7 +9,7 @@ function R(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 S = {
12
+ let E = {
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
  };
@@ -19,13 +19,13 @@ class x extends Error {
19
19
  const i = (() => {
20
20
  var n;
21
21
  return e.cause instanceof x ? e.cause.details : (n = e.cause) != null && n.message ? e.cause.message : e.details;
22
- })(), r = e.cause instanceof x && e.cause.docsPath || e.docsPath, o = (a = S.getDocsUrl) == null ? void 0 : a.call(S, { ...e, docsPath: r }), c = [
22
+ })(), r = e.cause instanceof x && e.cause.docsPath || e.docsPath, o = (a = E.getDocsUrl) == null ? void 0 : a.call(E, { ...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
- ...S.version ? [`Version: ${S.version}`] : []
28
+ ...E.version ? [`Version: ${E.version}`] : []
29
29
  ].join(`
30
30
  `);
31
31
  super(c, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
@@ -72,7 +72,7 @@ class F extends x {
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 z(s, { dir: t, size: e = 32 } = {}) {
75
+ function A(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 } = {}) {
@@ -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 }), z(e, { size: t.size })) : e;
129
+ return typeof t.size == "number" ? (V(e, { size: t.size }), A(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 }), z(i, { dir: "right", size: t.size })) : i;
136
+ return typeof t.size == "number" ? (V(i, { size: t.size }), A(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 ? z(a, { size: i }) : a;
154
+ return i ? A(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 U {
161
+ class z {
162
162
  constructor(t) {
163
- E(this, "opts");
164
- E(this, "open", () => {
163
+ k(this, "opts");
164
+ k(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 U {
172
172
  this.openUrl(`${this.baseUrl}${this.opts.app}?init=true&embed=true`), this.initialize();
173
173
  }
174
174
  });
175
- E(this, "iframeEventHandler", async (t) => {
176
- var i, r, o, c, a, n, h, u, m, f, g, y, l, w, d, b, v, I, P, $, A, M, T, D, C, G, j, B, W, H, L, O;
175
+ k(this, "iframeEventHandler", async (t) => {
176
+ var i, r, o, c, a, n, h, u, m, f, g, y, l, w, d, b, v, I, P, S, $, M, T, D, C, G, j, B, W, H, L, O;
177
177
  const e = t.data;
178
178
  switch (e.type) {
179
179
  case "sendInit": {
@@ -249,7 +249,7 @@ class U {
249
249
  break;
250
250
  }
251
251
  case "success":
252
- (w = (l = this.opts) == null ? void 0 : l.onSuccess) == null || w.call(l, e.hash);
252
+ (w = (l = this.opts) == null ? void 0 : l.onSuccess) == null || w.call(l, e.hash, e.session);
253
253
  break;
254
254
  case "close":
255
255
  this.removeIframe(), this.destroy(), (b = (d = this.opts) == null ? void 0 : d.onClose) == null || b.call(d);
@@ -263,7 +263,7 @@ class U {
263
263
  try {
264
264
  await this.opts.walletProvider.switchChainAsync({
265
265
  chainId: e.chainId
266
- }), ($ = (P = this.iframe) == null ? void 0 : P.contentWindow) == null || $.postMessage(
266
+ }), (S = (P = this.iframe) == null ? void 0 : P.contentWindow) == null || S.postMessage(
267
267
  {
268
268
  type: "didSwitchChain",
269
269
  success: !0,
@@ -272,7 +272,7 @@ class U {
272
272
  this.baseUrl
273
273
  );
274
274
  } catch (p) {
275
- (M = (A = this.iframe) == null ? void 0 : A.contentWindow) == null || M.postMessage(
275
+ (M = ($ = this.iframe) == null ? void 0 : $.contentWindow) == null || M.postMessage(
276
276
  {
277
277
  type: "didSwitchChain",
278
278
  success: !1,
@@ -404,19 +404,20 @@ const ue = ({
404
404
  excludeCurrencyTiers: n,
405
405
  excludeFundingSources: h,
406
406
  mode: u,
407
- sessionMetadata: m,
408
- theme: f,
409
- walletProvider: g,
410
- localStorageProvider: y,
411
- onOpen: l,
412
- onSuccess: w,
413
- onClose: d,
414
- autoCloseOnSuccess: b,
415
- popupsBlocked: v,
416
- baseUrl: I,
417
- debug: P
407
+ sessionId: m,
408
+ sessionMetadata: f,
409
+ theme: g,
410
+ walletProvider: y,
411
+ localStorageProvider: l,
412
+ onOpen: w,
413
+ onSuccess: d,
414
+ onClose: b,
415
+ autoCloseOnSuccess: v,
416
+ popupsBlocked: I,
417
+ baseUrl: P,
418
+ debug: S
418
419
  }) => {
419
- const $ = k(() => new U({
420
+ const $ = U(() => new z({
420
421
  app: s,
421
422
  recipient: t,
422
423
  chainId: e,
@@ -428,17 +429,18 @@ const ue = ({
428
429
  excludeCurrencyTiers: n,
429
430
  excludeFundingSources: h,
430
431
  mode: u,
431
- sessionMetadata: m,
432
- theme: f,
433
- walletProvider: g,
434
- localStorageProvider: y,
435
- onOpen: l,
436
- onSuccess: w,
437
- onClose: d,
438
- autoCloseOnSuccess: b,
439
- popupsBlocked: v,
440
- baseUrl: I,
441
- debug: P
432
+ sessionId: m,
433
+ sessionMetadata: f,
434
+ theme: g,
435
+ walletProvider: y,
436
+ localStorageProvider: l,
437
+ onOpen: w,
438
+ onSuccess: d,
439
+ onClose: b,
440
+ autoCloseOnSuccess: v,
441
+ popupsBlocked: I,
442
+ baseUrl: P,
443
+ debug: S
442
444
  }), [
443
445
  s,
444
446
  t,
@@ -461,7 +463,8 @@ const ue = ({
461
463
  b,
462
464
  v,
463
465
  I,
464
- P
466
+ P,
467
+ S
465
468
  ]);
466
469
  return {
467
470
  openGlideDeposit: $.open,
@@ -488,7 +491,7 @@ const ue = ({
488
491
  baseUrl: w,
489
492
  debug: d
490
493
  }) => {
491
- const b = k(() => new U({
494
+ const b = U(() => new z({
492
495
  app: s,
493
496
  preferGaslessPayment: t,
494
497
  excludeChainIds: e,
@@ -553,7 +556,7 @@ const ue = ({
553
556
  baseUrl: w,
554
557
  debug: d
555
558
  }) => {
556
- const b = k(() => new U({
559
+ const b = U(() => new z({
557
560
  app: s,
558
561
  evm: t,
559
562
  approval: e,
@@ -617,7 +620,7 @@ const ue = ({
617
620
  autoCloseOnSuccess: l,
618
621
  baseUrl: w
619
622
  }) => {
620
- const d = k(() => new U({
623
+ const d = U(() => new z({
621
624
  app: s,
622
625
  recipient: t,
623
626
  chainId: e,
@@ -693,7 +696,7 @@ const ue = ({
693
696
  })
694
697
  });
695
698
  export {
696
- U as GlideDeposit,
699
+ z as GlideDeposit,
697
700
  ye as browserLocalStorageProvider,
698
701
  ge as useGlideBuy,
699
702
  fe as useGlideCall,
@@ -1,6 +1,6 @@
1
1
  import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider, Hex } from './GlideDeposit.ts';
2
2
  import { GlideWidgetTheme } from './theme.ts';
3
- import { CAIP2 } from '@paywithglide/glide-js';
3
+ import { CAIP2, Session } from '@paywithglide/glide-js';
4
4
  interface UseGlideBuyProps {
5
5
  app: string;
6
6
  recipient?: string;
@@ -15,7 +15,7 @@ interface UseGlideBuyProps {
15
15
  walletProvider?: GlideDepositWalletProvider;
16
16
  localStorageProvider?: GlideLocalStorageProvider;
17
17
  onOpen?: () => void;
18
- onSuccess?: (hash: Hex) => void;
18
+ onSuccess?: (hash: Hex, session: Session) => void;
19
19
  onClose?: () => void;
20
20
  autoCloseOnSuccess?: boolean;
21
21
  baseUrl?: string;
@@ -1,6 +1,6 @@
1
1
  import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider, Hex } from './GlideDeposit.ts';
2
2
  import { GlideWidgetTheme } from './theme.ts';
3
- import { CAIP2 } from '@paywithglide/glide-js';
3
+ import { CAIP2, Session } from '@paywithglide/glide-js';
4
4
  interface UseGlideCallProps {
5
5
  app: string;
6
6
  evm: {
@@ -22,7 +22,7 @@ interface UseGlideCallProps {
22
22
  walletProvider?: GlideDepositWalletProvider;
23
23
  localStorageProvider?: GlideLocalStorageProvider;
24
24
  onOpen?: () => void;
25
- onSuccess?: (hash: Hex) => void;
25
+ onSuccess?: (hash: Hex, session: Session) => void;
26
26
  onClose?: () => void;
27
27
  autoCloseOnSuccess?: boolean;
28
28
  popupsBlocked?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider } from './GlideDeposit.ts';
2
2
  import { GlideWidgetTheme } from './theme.ts';
3
- import { CAIP2 } from '@paywithglide/glide-js';
3
+ import { CAIP2, Hex, Session } from '@paywithglide/glide-js';
4
4
  interface UseGlideDepositProps {
5
5
  app: string;
6
6
  recipient?: string;
@@ -13,19 +13,20 @@ interface UseGlideDepositProps {
13
13
  excludeCurrencyTiers?: ("tier1" | "tier2" | "tier3")[];
14
14
  excludeFundingSources?: FundingSource[];
15
15
  mode?: "deposit" | "withdraw";
16
+ sessionId?: string;
16
17
  sessionMetadata?: string;
17
18
  theme?: GlideWidgetTheme;
18
19
  walletProvider?: GlideDepositWalletProvider;
19
20
  localStorageProvider?: GlideLocalStorageProvider;
20
21
  onOpen?: () => void;
21
- onSuccess?: (hash: string) => void;
22
+ onSuccess?: (hash: Hex, session: Session) => void;
22
23
  onClose?: () => void;
23
24
  autoCloseOnSuccess?: boolean;
24
25
  popupsBlocked?: boolean;
25
26
  baseUrl?: string;
26
27
  debug?: boolean;
27
28
  }
28
- export declare const useGlideDeposit: ({ app, recipient, chainId, currencyId, amount, gasRefuelAmountPerChain, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
29
+ export declare const useGlideDeposit: ({ app, recipient, chainId, currencyId, amount, gasRefuelAmountPerChain, preferGaslessPayment, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, mode, sessionId, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
29
30
  openGlideDeposit: () => void;
30
31
  externalUrl: string;
31
32
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
@@ -1,6 +1,6 @@
1
1
  import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider } from './GlideDeposit.ts';
2
2
  import { GlideWidgetTheme } from './theme.ts';
3
- import { CAIP2 } from '@paywithglide/glide-js';
3
+ import { CAIP2, Hex, Session } from '@paywithglide/glide-js';
4
4
  type UseGlidePayProps = {
5
5
  app: string;
6
6
  amount?: string;
@@ -14,7 +14,7 @@ type UseGlidePayProps = {
14
14
  walletProvider?: GlideDepositWalletProvider;
15
15
  localStorageProvider?: GlideLocalStorageProvider;
16
16
  onOpen?: () => void;
17
- onSuccess?: (hash: string) => void;
17
+ onSuccess?: (hash: Hex, session: Session) => void;
18
18
  onClose?: () => void;
19
19
  autoCloseOnSuccess?: boolean;
20
20
  popupsBlocked?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithglide/glide-react",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"