@paywithglide/glide-react 0.0.31 → 0.0.33

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,17 +1,17 @@
1
- var Z = Object.defineProperty;
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";
5
- function ee(s, { strict: t = !0 } = {}) {
1
+ var _ = Object.defineProperty;
2
+ var ee = (s, t, e) => t in s ? _(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var k = (s, t, e) => ee(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { useMemo as U } from "react";
5
+ function te(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
  }
8
- function R(s) {
9
- return ee(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
8
+ function N(s) {
9
+ return te(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
10
10
  }
11
- const N = "2.21.51";
12
- let S = {
11
+ const K = "2.21.51";
12
+ let E = {
13
13
  getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
14
- version: `viem@${N}`
14
+ version: `viem@${K}`
15
15
  };
16
16
  class x extends Error {
17
17
  constructor(t, e = {}) {
@@ -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", {
@@ -58,40 +58,40 @@ class x extends Error {
58
58
  configurable: !0,
59
59
  writable: !0,
60
60
  value: "BaseError"
61
- }), this.details = i, this.docsPath = r, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version = N;
61
+ }), this.details = i, this.docsPath = r, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version = K;
62
62
  }
63
63
  walk(t) {
64
- return K(this, t);
64
+ return F(this, t);
65
65
  }
66
66
  }
67
- function K(s, t) {
68
- return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? K(s.cause, t) : t ? null : s;
67
+ function F(s, t) {
68
+ return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? F(s.cause, t) : t ? null : s;
69
69
  }
70
- class F extends x {
70
+ class V extends x {
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 z(s, { dir: t, size: e = 32 } = {}) {
76
- return typeof s == "string" ? te(s, { dir: t, size: e }) : se(s, { dir: t, size: e });
75
+ function A(s, { dir: t, size: e = 32 } = {}) {
76
+ return typeof s == "string" ? se(s, { dir: t, size: e }) : ie(s, { dir: t, size: e });
77
77
  }
78
- function te(s, { dir: t, size: e = 32 } = {}) {
78
+ function se(s, { dir: t, size: e = 32 } = {}) {
79
79
  if (e === null)
80
80
  return s;
81
81
  const i = s.replace("0x", "");
82
82
  if (i.length > e * 2)
83
- throw new F({
83
+ throw new V({
84
84
  size: Math.ceil(i.length / 2),
85
85
  targetSize: e,
86
86
  type: "hex"
87
87
  });
88
88
  return `0x${i[t === "right" ? "padEnd" : "padStart"](e * 2, "0")}`;
89
89
  }
90
- function se(s, { dir: t, size: e = 32 } = {}) {
90
+ function ie(s, { dir: t, size: e = 32 } = {}) {
91
91
  if (e === null)
92
92
  return s;
93
93
  if (s.length > e)
94
- throw new F({
94
+ throw new V({
95
95
  size: s.length,
96
96
  targetSize: e,
97
97
  type: "bytes"
@@ -103,46 +103,46 @@ function se(s, { dir: t, size: e = 32 } = {}) {
103
103
  }
104
104
  return i;
105
105
  }
106
- class ie extends x {
106
+ class re extends x {
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 x {
111
+ class oe extends x {
112
112
  constructor({ givenSize: t, maxSize: e }) {
113
113
  super(`Size cannot exceed ${e} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
114
114
  }
115
115
  }
116
- function V(s, { size: t }) {
117
- if (R(s) > t)
118
- throw new re({
119
- givenSize: R(s),
116
+ function q(s, { size: t }) {
117
+ if (N(s) > t)
118
+ throw new oe({
119
+ givenSize: N(s),
120
120
  maxSize: t
121
121
  });
122
122
  }
123
- const oe = /* @__PURE__ */ Array.from({ length: 256 }, (s, t) => t.toString(16).padStart(2, "0"));
124
- function ne(s, t = {}) {
125
- return typeof s == "number" || typeof s == "bigint" ? ce(s, t) : typeof s == "string" ? le(s, t) : typeof s == "boolean" ? ae(s, t) : q(s, t);
126
- }
123
+ const ne = /* @__PURE__ */ Array.from({ length: 256 }, (s, t) => t.toString(16).padStart(2, "0"));
127
124
  function ae(s, t = {}) {
125
+ return typeof s == "number" || typeof s == "bigint" ? de(s, t) : typeof s == "string" ? pe(s, t) : typeof s == "boolean" ? ce(s, t) : J(s, t);
126
+ }
127
+ function ce(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" ? (q(e, { size: t.size }), A(e, { size: t.size })) : e;
130
130
  }
131
- function q(s, t = {}) {
131
+ function J(s, t = {}) {
132
132
  let e = "";
133
133
  for (let r = 0; r < s.length; r++)
134
- e += oe[s[r]];
134
+ e += ne[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" ? (q(i, { size: t.size }), A(i, { dir: "right", size: t.size })) : i;
137
137
  }
138
- function ce(s, t = {}) {
138
+ function de(s, t = {}) {
139
139
  const { signed: e, size: i } = t, r = BigInt(s);
140
140
  let o;
141
141
  i ? e ? o = (1n << BigInt(i) * 8n - 1n) - 1n : o = 2n ** (BigInt(i) * 8n) - 1n : typeof s == "number" && (o = BigInt(Number.MAX_SAFE_INTEGER));
142
142
  const c = typeof o == "bigint" && e ? -o - 1n : 0;
143
143
  if (o && r > o || r < c) {
144
144
  const n = typeof s == "bigint" ? "n" : "";
145
- throw new ie({
145
+ throw new re({
146
146
  max: o ? `${o}${n}` : void 0,
147
147
  min: `${c}${n}`,
148
148
  signed: e,
@@ -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
- const de = /* @__PURE__ */ new TextEncoder();
157
- function le(s, t = {}) {
158
- const e = de.encode(s);
159
- return q(e, t);
156
+ const le = /* @__PURE__ */ new TextEncoder();
157
+ function pe(s, t = {}) {
158
+ const e = le.encode(s);
159
+ return J(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,21 +172,21 @@ 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, u, m, f, g, y, w, b, d, l, p, I, v, P, S, $, M, T, D, C, G, j, B, W, H, O, L, R;
177
177
  const e = t.data;
178
178
  switch (e.type) {
179
179
  case "sendInit": {
180
- const p = this.opts.recipient, J = (i = this.opts.walletProvider) == null ? void 0 : i.address, X = (r = this.opts.walletProvider) == null ? void 0 : r.availableChainIds, Q = (o = this.opts.walletProvider) == null ? void 0 : o.currentChainId, Y = this.opts.preferGaslessPayment || !!((c = this.opts.walletProvider) != null && c.signTypedDataAsync);
181
- (n = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || n.postMessage(
180
+ const h = this.opts.recipient, X = (i = this.opts.walletProvider) == null ? void 0 : i.address, Q = (r = this.opts.walletProvider) == null ? void 0 : r.availableChainIds, Y = (o = this.opts.walletProvider) == null ? void 0 : o.currentChainId, Z = this.opts.preferGaslessPayment || !!((c = this.opts.walletProvider) != null && c.signTypedDataAsync);
181
+ (u = (a = this.iframe) == null ? void 0 : a.contentWindow) == null || u.postMessage(
182
182
  {
183
183
  type: "initialize",
184
184
  sessionId: this.opts.sessionId,
185
- recipient: p,
186
- connectedWalletAddress: J,
187
- availableChainIds: X,
188
- currentChainId: Q,
189
- preferGaslessPayment: Y,
185
+ recipient: h,
186
+ connectedWalletAddress: X,
187
+ availableChainIds: Q,
188
+ currentChainId: Y,
189
+ preferGaslessPayment: Z,
190
190
  excludeChainIds: this.opts.excludeChainIds,
191
191
  excludeCurrencyTiers: this.opts.excludeCurrencyTiers,
192
192
  excludeFundingSources: this.opts.excludeFundingSources,
@@ -198,24 +198,31 @@ class U {
198
198
  tokenApproval: this.opts.approval,
199
199
  sessionMetadata: this.opts.sessionMetadata,
200
200
  autoCloseOnSuccess: this.opts.autoCloseOnSuccess,
201
- theme: this.opts.theme,
201
+ theme: {
202
+ ...this.opts.theme || {},
203
+ colorScheme: ((n = this.opts.theme) == null ? void 0 : n.colorScheme) || getComputedStyle(document.documentElement).colorScheme || ""
204
+ },
202
205
  didProvideLocalStorage: !!this.opts.localStorageProvider,
203
206
  debug: this.opts.debug,
204
207
  popupsBlocked: this.opts.popupsBlocked,
205
208
  gasRefuelAmountPerChain: this.opts.gasRefuelAmountPerChain
206
209
  },
207
210
  new URL(this.baseUrl).origin
208
- ), this.iframe.style.opacity = "1", (u = (h = this.opts).onOpen) == null || u.call(h);
211
+ );
212
+ break;
213
+ }
214
+ case "didOpen": {
215
+ this.iframe.style.opacity = "1", (f = (m = this.opts).onOpen) == null || f.call(m);
209
216
  break;
210
217
  }
211
218
  case "localStorage.getKeys": {
212
219
  if (!this.opts.localStorageProvider)
213
220
  throw new Error("localStorageProvider is not set");
214
- const p = await this.opts.localStorageProvider.getKeys();
215
- (f = (m = this.iframe) == null ? void 0 : m.contentWindow) == null || f.postMessage(
221
+ const h = await this.opts.localStorageProvider.getKeys();
222
+ (y = (g = this.iframe) == null ? void 0 : g.contentWindow) == null || y.postMessage(
216
223
  {
217
224
  type: "localStorage.didGetKeys",
218
- keys: p
225
+ keys: h
219
226
  },
220
227
  this.baseUrl
221
228
  );
@@ -237,25 +244,25 @@ class U {
237
244
  case "localStorage.getItem": {
238
245
  if (!this.opts.localStorageProvider)
239
246
  throw new Error("localStorageProvider is not set");
240
- const p = await this.opts.localStorageProvider.getItem(e.key);
241
- (y = (g = this.iframe) == null ? void 0 : g.contentWindow) == null || y.postMessage(
247
+ const h = await this.opts.localStorageProvider.getItem(e.key);
248
+ (b = (w = this.iframe) == null ? void 0 : w.contentWindow) == null || b.postMessage(
242
249
  {
243
250
  type: "localStorage.didGetItem",
244
251
  key: e.key,
245
- value: p
252
+ value: h
246
253
  },
247
254
  this.baseUrl
248
255
  );
249
256
  break;
250
257
  }
251
258
  case "success":
252
- (w = (l = this.opts) == null ? void 0 : l.onSuccess) == null || w.call(l, e.hash);
259
+ (l = (d = this.opts) == null ? void 0 : d.onSuccess) == null || l.call(d, e.hash, e.session);
253
260
  break;
254
261
  case "close":
255
- this.removeIframe(), this.destroy(), (b = (d = this.opts) == null ? void 0 : d.onClose) == null || b.call(d);
262
+ this.removeIframe(), this.destroy(), (I = (p = this.opts) == null ? void 0 : p.onClose) == null || I.call(p);
256
263
  break;
257
264
  case "setMode":
258
- (I = (v = this.opts) == null ? void 0 : v.onSetMode) == null || I.call(v, e.mode);
265
+ (P = (v = this.opts) == null ? void 0 : v.onSetMode) == null || P.call(v, e.mode);
259
266
  break;
260
267
  case "switchChain":
261
268
  if (!this.opts.walletProvider)
@@ -263,7 +270,7 @@ class U {
263
270
  try {
264
271
  await this.opts.walletProvider.switchChainAsync({
265
272
  chainId: e.chainId
266
- }), ($ = (P = this.iframe) == null ? void 0 : P.contentWindow) == null || $.postMessage(
273
+ }), ($ = (S = this.iframe) == null ? void 0 : S.contentWindow) == null || $.postMessage(
267
274
  {
268
275
  type: "didSwitchChain",
269
276
  success: !0,
@@ -271,12 +278,12 @@ class U {
271
278
  },
272
279
  this.baseUrl
273
280
  );
274
- } catch (p) {
275
- (M = (A = this.iframe) == null ? void 0 : A.contentWindow) == null || M.postMessage(
281
+ } catch (h) {
282
+ (T = (M = this.iframe) == null ? void 0 : M.contentWindow) == null || T.postMessage(
276
283
  {
277
284
  type: "didSwitchChain",
278
285
  success: !1,
279
- error: p
286
+ error: h
280
287
  },
281
288
  this.baseUrl
282
289
  );
@@ -287,23 +294,23 @@ class U {
287
294
  if (!this.opts.walletProvider)
288
295
  throw new Error("walletProvider is not set");
289
296
  try {
290
- const p = await this.opts.walletProvider.sendTransactionAsync(
297
+ const h = await this.opts.walletProvider.sendTransactionAsync(
291
298
  e.tx
292
299
  );
293
- (D = (T = this.iframe) == null ? void 0 : T.contentWindow) == null || D.postMessage(
300
+ (C = (D = this.iframe) == null ? void 0 : D.contentWindow) == null || C.postMessage(
294
301
  {
295
302
  type: "didSendTransaction",
296
303
  success: !0,
297
- txHash: p
304
+ txHash: h
298
305
  },
299
306
  this.baseUrl
300
307
  );
301
- } catch (p) {
302
- (G = (C = this.iframe) == null ? void 0 : C.contentWindow) == null || G.postMessage(
308
+ } catch (h) {
309
+ (j = (G = this.iframe) == null ? void 0 : G.contentWindow) == null || j.postMessage(
303
310
  {
304
311
  type: "didSendTransaction",
305
312
  success: !1,
306
- error: p
313
+ error: h
307
314
  },
308
315
  this.baseUrl
309
316
  );
@@ -315,7 +322,7 @@ class U {
315
322
  if (!this.opts.walletProvider)
316
323
  throw new Error("walletProvider is not set");
317
324
  if (!this.opts.walletProvider.signTypedDataAsync) {
318
- (B = (j = this.iframe) == null ? void 0 : j.contentWindow) == null || B.postMessage(
325
+ (W = (B = this.iframe) == null ? void 0 : B.contentWindow) == null || W.postMessage(
319
326
  {
320
327
  type: "didSignTypedData",
321
328
  success: !1,
@@ -326,23 +333,23 @@ class U {
326
333
  return;
327
334
  }
328
335
  try {
329
- const p = await this.opts.walletProvider.signTypedDataAsync(
336
+ const h = await this.opts.walletProvider.signTypedDataAsync(
330
337
  e.data
331
338
  );
332
- (H = (W = this.iframe) == null ? void 0 : W.contentWindow) == null || H.postMessage(
339
+ (O = (H = this.iframe) == null ? void 0 : H.contentWindow) == null || O.postMessage(
333
340
  {
334
341
  type: "didSignTypedData",
335
342
  success: !0,
336
- signature: p
343
+ signature: h
337
344
  },
338
345
  this.baseUrl
339
346
  );
340
- } catch (p) {
341
- (O = (L = this.iframe) == null ? void 0 : L.contentWindow) == null || O.postMessage(
347
+ } catch (h) {
348
+ (R = (L = this.iframe) == null ? void 0 : L.contentWindow) == null || R.postMessage(
342
349
  {
343
350
  type: "didSignTypedData",
344
351
  success: !1,
345
- error: p
352
+ error: h
346
353
  },
347
354
  this.baseUrl
348
355
  );
@@ -355,7 +362,7 @@ class U {
355
362
  }
356
363
  get externalUrl() {
357
364
  var t, e, i;
358
- 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.chainId ? `&chainId=${this.opts.chainId}` : ""}${this.opts.currencyId ? `&currencyId=${this.opts.currencyId}` : ""}${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(
365
+ 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.chainId ? `&chainId=${this.opts.chainId}` : ""}${this.opts.currencyId ? `&currencyId=${this.opts.currencyId}` : ""}${this.opts.evm ? `&evm.chainId=${this.opts.evm.chainId}&evm.to=${this.opts.evm.to}&evm.data=${this.opts.evm.data || "0x0"}&evm.value=${ae(
359
366
  this.opts.evm.value || 0n
360
367
  )}` : ""}${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" : ""}${this.opts.gasRefuelAmountPerChain ? `&gasRefuelAmountPerChain=${encodeURIComponent(JSON.stringify(this.opts.gasRefuelAmountPerChain))}` : ""}`;
361
368
  }
@@ -392,7 +399,7 @@ class U {
392
399
  t && (t.remove(), document.body.classList.remove("glide-deposit-open"));
393
400
  }
394
401
  }
395
- const ue = ({
402
+ const me = ({
396
403
  app: s,
397
404
  recipient: t,
398
405
  chainId: e,
@@ -402,21 +409,22 @@ const ue = ({
402
409
  preferGaslessPayment: c,
403
410
  excludeChainIds: a,
404
411
  excludeCurrencyTiers: n,
405
- excludeFundingSources: h,
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,
412
+ excludeFundingSources: u,
413
+ mode: m,
414
+ sessionId: f,
415
+ sessionMetadata: g,
416
+ theme: y,
417
+ walletProvider: w,
418
+ localStorageProvider: b,
419
+ onOpen: d,
420
+ onSuccess: l,
421
+ onClose: p,
422
+ autoCloseOnSuccess: I,
415
423
  popupsBlocked: v,
416
- baseUrl: I,
417
- debug: P
424
+ baseUrl: P,
425
+ debug: S
418
426
  }) => {
419
- const $ = k(() => new U({
427
+ const $ = U(() => new z({
420
428
  app: s,
421
429
  recipient: t,
422
430
  chainId: e,
@@ -426,19 +434,20 @@ const ue = ({
426
434
  preferGaslessPayment: c,
427
435
  excludeChainIds: a,
428
436
  excludeCurrencyTiers: n,
429
- excludeFundingSources: h,
430
- 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,
437
+ excludeFundingSources: u,
438
+ mode: m,
439
+ sessionId: f,
440
+ sessionMetadata: g,
441
+ theme: y,
442
+ walletProvider: w,
443
+ localStorageProvider: b,
444
+ onOpen: d,
445
+ onSuccess: l,
446
+ onClose: p,
447
+ autoCloseOnSuccess: I,
439
448
  popupsBlocked: v,
440
- baseUrl: I,
441
- debug: P
449
+ baseUrl: P,
450
+ debug: S
442
451
  }), [
443
452
  s,
444
453
  t,
@@ -449,26 +458,27 @@ const ue = ({
449
458
  c,
450
459
  a,
451
460
  n,
452
- h,
453
461
  u,
454
462
  m,
455
463
  f,
456
464
  g,
457
465
  y,
458
- l,
459
466
  w,
460
- d,
461
467
  b,
462
- v,
468
+ d,
469
+ l,
470
+ p,
463
471
  I,
464
- P
472
+ v,
473
+ P,
474
+ S
465
475
  ]);
466
476
  return {
467
477
  openGlideDeposit: $.open,
468
478
  externalUrl: $.externalUrl,
469
479
  opts: $.opts
470
480
  };
471
- }, me = ({
481
+ }, fe = ({
472
482
  app: s,
473
483
  preferGaslessPayment: t,
474
484
  excludeChainIds: e,
@@ -478,17 +488,17 @@ const ue = ({
478
488
  sessionId: c,
479
489
  sessionMetadata: a,
480
490
  theme: n,
481
- walletProvider: h,
482
- localStorageProvider: u,
483
- onOpen: m,
484
- onSuccess: f,
485
- onClose: g,
486
- autoCloseOnSuccess: y,
487
- popupsBlocked: l,
488
- baseUrl: w,
489
- debug: d
491
+ walletProvider: u,
492
+ localStorageProvider: m,
493
+ onOpen: f,
494
+ onSuccess: g,
495
+ onClose: y,
496
+ autoCloseOnSuccess: w,
497
+ popupsBlocked: b,
498
+ baseUrl: d,
499
+ debug: l
490
500
  }) => {
491
- const b = k(() => new U({
501
+ const p = U(() => new z({
492
502
  app: s,
493
503
  preferGaslessPayment: t,
494
504
  excludeChainIds: e,
@@ -499,15 +509,15 @@ const ue = ({
499
509
  amount: o,
500
510
  sessionMetadata: a,
501
511
  theme: n,
502
- walletProvider: h,
503
- localStorageProvider: u,
504
- onOpen: m,
505
- onSuccess: f,
506
- onClose: g,
507
- autoCloseOnSuccess: y,
508
- popupsBlocked: l,
509
- baseUrl: w,
510
- debug: d
512
+ walletProvider: u,
513
+ localStorageProvider: m,
514
+ onOpen: f,
515
+ onSuccess: g,
516
+ onClose: y,
517
+ autoCloseOnSuccess: w,
518
+ popupsBlocked: b,
519
+ baseUrl: d,
520
+ debug: l
511
521
  }), [
512
522
  s,
513
523
  t,
@@ -518,22 +528,22 @@ const ue = ({
518
528
  o,
519
529
  a,
520
530
  n,
521
- h,
522
531
  u,
523
532
  m,
524
533
  f,
525
534
  g,
526
535
  y,
527
- l,
528
536
  w,
529
- d
537
+ b,
538
+ d,
539
+ l
530
540
  ]);
531
541
  return {
532
- openGlidePay: b.open,
533
- externalUrl: b.externalUrl,
534
- opts: b.opts
542
+ openGlidePay: p.open,
543
+ externalUrl: p.externalUrl,
544
+ opts: p.opts
535
545
  };
536
- }, fe = ({
546
+ }, ge = ({
537
547
  app: s,
538
548
  evm: t,
539
549
  approval: e,
@@ -543,17 +553,17 @@ const ue = ({
543
553
  excludeFundingSources: c,
544
554
  sessionMetadata: a,
545
555
  theme: n,
546
- walletProvider: h,
547
- localStorageProvider: u,
548
- onOpen: m,
549
- onSuccess: f,
550
- onClose: g,
551
- autoCloseOnSuccess: y,
552
- popupsBlocked: l,
553
- baseUrl: w,
554
- debug: d
556
+ walletProvider: u,
557
+ localStorageProvider: m,
558
+ onOpen: f,
559
+ onSuccess: g,
560
+ onClose: y,
561
+ autoCloseOnSuccess: w,
562
+ popupsBlocked: b,
563
+ baseUrl: d,
564
+ debug: l
555
565
  }) => {
556
- const b = k(() => new U({
566
+ const p = U(() => new z({
557
567
  app: s,
558
568
  evm: t,
559
569
  approval: e,
@@ -564,15 +574,15 @@ const ue = ({
564
574
  sessionMetadata: a,
565
575
  mode: "call",
566
576
  theme: n,
567
- walletProvider: h,
568
- localStorageProvider: u,
569
- onOpen: m,
570
- onSuccess: f,
571
- onClose: g,
572
- autoCloseOnSuccess: y,
573
- popupsBlocked: l,
574
- baseUrl: w,
575
- debug: d
577
+ walletProvider: u,
578
+ localStorageProvider: m,
579
+ onOpen: f,
580
+ onSuccess: g,
581
+ onClose: y,
582
+ autoCloseOnSuccess: w,
583
+ popupsBlocked: b,
584
+ baseUrl: d,
585
+ debug: l
576
586
  }), [
577
587
  s,
578
588
  t,
@@ -583,22 +593,22 @@ const ue = ({
583
593
  c,
584
594
  a,
585
595
  n,
586
- h,
587
596
  u,
588
597
  m,
589
598
  f,
590
599
  g,
591
600
  y,
592
- l,
593
601
  w,
594
- d
602
+ b,
603
+ d,
604
+ l
595
605
  ]);
596
606
  return {
597
- openGlideCall: b.open,
598
- externalUrl: b.externalUrl,
599
- opts: b.opts
607
+ openGlideCall: p.open,
608
+ externalUrl: p.externalUrl,
609
+ opts: p.opts
600
610
  };
601
- }, ge = ({
611
+ }, ye = ({
602
612
  app: s,
603
613
  recipient: t,
604
614
  chainId: e,
@@ -608,16 +618,16 @@ const ue = ({
608
618
  excludeCurrencyTiers: c,
609
619
  excludeFundingSources: a,
610
620
  sessionMetadata: n,
611
- theme: h,
612
- walletProvider: u,
613
- localStorageProvider: m,
614
- onOpen: f,
615
- onSuccess: g,
616
- onClose: y,
617
- autoCloseOnSuccess: l,
618
- baseUrl: w
621
+ theme: u,
622
+ walletProvider: m,
623
+ localStorageProvider: f,
624
+ onOpen: g,
625
+ onSuccess: y,
626
+ onClose: w,
627
+ autoCloseOnSuccess: b,
628
+ baseUrl: d
619
629
  }) => {
620
- const d = k(() => new U({
630
+ const l = U(() => new z({
621
631
  app: s,
622
632
  recipient: t,
623
633
  chainId: e,
@@ -628,14 +638,14 @@ const ue = ({
628
638
  excludeFundingSources: a,
629
639
  sessionMetadata: n,
630
640
  mode: "buy",
631
- theme: h,
632
- walletProvider: u,
633
- localStorageProvider: m,
634
- onOpen: f,
635
- onSuccess: g,
636
- onClose: y,
637
- autoCloseOnSuccess: l,
638
- baseUrl: w
641
+ theme: u,
642
+ walletProvider: m,
643
+ localStorageProvider: f,
644
+ onOpen: g,
645
+ onSuccess: y,
646
+ onClose: w,
647
+ autoCloseOnSuccess: b,
648
+ baseUrl: d
639
649
  }), [
640
650
  s,
641
651
  t,
@@ -646,21 +656,21 @@ const ue = ({
646
656
  c,
647
657
  a,
648
658
  n,
649
- h,
650
659
  u,
651
660
  m,
652
661
  f,
653
662
  g,
654
663
  y,
655
- l,
656
- w
664
+ w,
665
+ b,
666
+ d
657
667
  ]);
658
668
  return {
659
- openGlideBuy: d.open,
660
- externalUrl: d.externalUrl,
661
- opts: d.opts
669
+ openGlideBuy: l.open,
670
+ externalUrl: l.externalUrl,
671
+ opts: l.opts
662
672
  };
663
- }, ye = Object.freeze({
673
+ }, we = Object.freeze({
664
674
  getItem: (s) => new Promise((t, e) => {
665
675
  try {
666
676
  const i = localStorage.getItem(s);
@@ -693,10 +703,10 @@ const ue = ({
693
703
  })
694
704
  });
695
705
  export {
696
- U as GlideDeposit,
697
- ye as browserLocalStorageProvider,
698
- ge as useGlideBuy,
699
- fe as useGlideCall,
700
- ue as useGlideDeposit,
701
- me as useGlidePay
706
+ z as GlideDeposit,
707
+ we as browserLocalStorageProvider,
708
+ ye as useGlideBuy,
709
+ ge as useGlideCall,
710
+ me as useGlideDeposit,
711
+ fe as useGlidePay
702
712
  };
package/dist/theme.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type GlideWidgetTheme = {
2
+ colorScheme?: string;
2
3
  fontSrcCss?: string;
3
4
  fontFamily?: string;
4
5
  modalBorderWidth?: 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 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.33",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"