@pybara/pybara-js 0.7.0 → 0.9.0

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/pybara-js.js CHANGED
@@ -1,26 +1,27 @@
1
1
  /* Pybara.js - pybara.com */
2
2
  import { n as e, r as t, t as n } from "./admin-B1pVP25-.js";
3
- import { t as r } from "./modal-CvQ7qr5d.js";
4
- var i = {
3
+ import { t as r } from "./modal-CXTyI_BA.js";
4
+ import { r as i, t as a } from "./button-BEOTKYpw.js";
5
+ var o = {
5
6
  widget: "donate-widget",
6
7
  recurring: "donate-widget-recurring"
7
8
  };
8
- function a(e, t) {
9
+ function s(e, t) {
9
10
  let n = (e) => {
10
11
  let t = /^(\d+)-(\d+)$/.exec(e);
11
12
  return t ? [Number(t[1]), Number(t[2])] : null;
12
13
  }, r = n(e), i = n(t);
13
14
  return !r || !i ? !1 : r[0] > i[0] || r[0] === i[0] && r[1] >= i[1];
14
15
  }
15
- async function o(e) {
16
+ async function c(e) {
16
17
  let t = await fetch(e);
17
18
  if (!t.ok) throw Error(`HTTP ${t.status} from ${e}`);
18
19
  return await t.json();
19
20
  }
20
- async function s(t, n, r) {
21
- let s = e[t], c = `https://${s.admin_core}.raw.icp0.io/widget-config`, l = `https://${s.admin_regs}.raw.icp0.io/widget-terms?site_url=${encodeURIComponent(n)}&principal=${encodeURIComponent(r)}`, u, d;
21
+ async function l(t, n, r) {
22
+ let i = e[t], a = `https://${i.admin_core}.raw.icp0.io/widget-config`, l = `https://${i.admin_regs}.raw.icp0.io/widget-terms?site_url=${encodeURIComponent(n)}&principal=${encodeURIComponent(r)}`, u, d;
22
23
  try {
23
- [u, d] = await Promise.all([o(c), o(l)]);
24
+ [u, d] = await Promise.all([c(a), c(l)]);
24
25
  } catch (e) {
25
26
  return {
26
27
  show: !1,
@@ -29,13 +30,13 @@ async function s(t, n, r) {
29
30
  };
30
31
  }
31
32
  let f = u.kill_switch?.plugins ?? {};
32
- return f[i.widget]?.enabled === !0 ? !d.signed || !d.version ? {
33
+ return f[o.widget]?.enabled === !0 ? !d.signed || !d.version ? {
33
34
  show: !1,
34
35
  cause: "terms",
35
36
  reason: `${n} has not accepted the widget's terms in Pybara Wallet (Manage › Sites › Add a site without a plugin)`
36
- } : a(d.version, "1-0") ? {
37
+ } : s(d.version, "1-0") ? {
37
38
  show: !0,
38
- recurring: f[i.recurring]?.enabled === !0
39
+ recurring: f[o.recurring]?.enabled === !0
39
40
  } : {
40
41
  show: !1,
41
42
  cause: "terms",
@@ -47,100 +48,16 @@ async function s(t, n, r) {
47
48
  };
48
49
  }
49
50
  //#endregion
50
- //#region src/types.ts
51
- var c = class extends Error {
52
- constructor(e, t) {
53
- super(t), this.name = "PybaraError", this.code = e;
54
- }
55
- };
56
- //#endregion
57
- //#region src/buttons.ts
58
- function l(e) {
59
- let t = typeof e?.height == "number" && Number.isFinite(e.height) ? Math.round(e.height) : 45;
60
- return Math.min(55, Math.max(25, t));
61
- }
62
- function u(e, t) {
63
- return e?.shape === "sharp" ? "0" : e?.shape === "rect" ? "4px" : `${t / 2}px`;
64
- }
65
- function d(e) {
66
- let t = typeof e == "string" ? document.querySelector(e) : e;
67
- if (!t) throw new c("INVALID_CONFIG", `buttons().render(): no element matches ${JSON.stringify(e)}`);
68
- return t;
69
- }
70
- function f(e, t) {
71
- if (typeof t?.createPayment != "function") throw new c("INVALID_CONFIG", "buttons(): \"createPayment\" is required, a function returning the payment from the form, e.g. () => ({ amount: form.amount.value, currency: \"EUR\" })");
72
- let n = new URL(e.walletUrl).origin, r = [], i = null;
73
- async function a() {
74
- try {
75
- let n = await t.createPayment();
76
- await e.open({
77
- ...n,
78
- onSuccess: t.onSuccess,
79
- onError: t.onError,
80
- onClose: t.onClose
81
- });
82
- } catch (e) {
83
- t.onError?.(e instanceof Error ? e : Error(String(e)));
84
- }
85
- }
86
- function o(o) {
87
- let s = d(o), c = l(t.style), f = document.createElement("div");
88
- f.style.cssText = `position:relative;width:100%;height:${c}px;`;
89
- let p = document.createElement("div");
90
- p.setAttribute("aria-hidden", "true"), p.style.cssText = `position:absolute;inset:0;border-radius:${u(t.style, c)};background:rgba(128,128,128,0.16);`;
91
- let m = document.createElement("iframe");
92
- m.src = `${n}/button`, m.title = "Pybara", m.style.cssText = "position:absolute;inset:0;width:100%;height:100%;border:0;opacity:0;color-scheme:normal;background:transparent;", f.append(p, m), s.appendChild(f);
93
- let h = !1, g = null, _ = {};
94
- i ??= _;
95
- let v = (e) => {
96
- m.contentWindow?.postMessage(e, n);
97
- }, y = (e) => {
98
- g = e, h && v({
99
- type: "pybara_button_availability",
100
- v: 1,
101
- status: e.status
102
- }), i ??= _, i === _ && t.onStateChange?.(e);
103
- };
104
- m.addEventListener("load", () => {
105
- v({
106
- type: "pybara_button_init",
107
- v: 1,
108
- style: t.style ?? {},
109
- hideWhenUnavailable: t.hideWhenUnavailable === !0
110
- });
111
- }, { once: !0 });
112
- let b = (e) => {
113
- if (e.origin !== n || e.source !== m.contentWindow) return;
114
- let t = e.data;
115
- t?.type === "pybara_button_ready" || t?.type === "pybara_button_resize" ? (typeof t.height == "number" && (f.style.height = `${t.height}px`), h || (h = !0, m.style.opacity = "1", p.remove(), g && v({
116
- type: "pybara_button_availability",
117
- v: 1,
118
- status: g.status
119
- }))) : t?.type === "pybara_button_click" && a();
120
- };
121
- window.addEventListener("message", b);
122
- let x = e.subscribeAvailability(y);
123
- r.push(() => {
124
- window.removeEventListener("message", b), x(), i === _ && (i = null), f.remove();
125
- });
126
- }
127
- return {
128
- render: o,
129
- destroy() {
130
- for (let e of r.splice(0)) e();
131
- }
132
- };
133
- }
134
- //#endregion
135
51
  //#region src/checkout.ts
136
- var p = /^(0|[1-9]\d*)(\.\d+)?$/, m = /^[a-z0-9-]{1,64}$/, h = class {
52
+ var u = /^(0|[1-9]\d*)(\.\d+)?$/, d = /^[a-z0-9-]{1,64}$/, f = class {
137
53
  constructor(e) {
138
- this.adminClient = null, this.modal = null, this.gateOutcome = null, this.isOpen = !1, this.completedPayment = !1, this.activePayment = null, this.lastPrecheck = {}, this.availabilityListeners = /* @__PURE__ */ new Set(), this.latestAvailability = null, this.config = v(e), this.config.onAvailability && this.availabilityListeners.add(this.config.onAvailability), this.ready = this.init(), this.config.onAvailability && this.precheck();
54
+ this.adminClient = null, this.modal = null, this.gateOutcome = null, this.isOpen = !1, this.completedPayment = !1, this.activePayment = null, this.lastPrecheck = {}, this.availabilityListeners = /* @__PURE__ */ new Set(), this.latestAvailability = null, this.config = h(e), this.config.onAvailability && this.availabilityListeners.add(this.config.onAvailability), this.ready = this.init(), this.config.onAvailability && this.precheck();
139
55
  }
140
56
  buttons(e) {
141
- return f({
57
+ return a({
142
58
  walletUrl: t[this.config.staging ? "staging" : "prod"],
143
- open: (e) => this.open(e),
59
+ locale: this.config.locale,
60
+ open: async (e) => (await this.open(e), this.activePayment === e),
144
61
  subscribeAvailability: (e) => (this.availabilityListeners.add(e), this.latestAvailability ? e(this.latestAvailability) : !this.config.onAvailability && this.availabilityListeners.size === 1 && this.precheck(this.lastPrecheck), () => {
145
62
  this.availabilityListeners.delete(e);
146
63
  })
@@ -186,44 +103,44 @@ var p = /^(0|[1-9]\d*)(\.\d+)?$/, m = /^[a-z0-9-]{1,64}$/, h = class {
186
103
  return this.gateOutcome;
187
104
  }
188
105
  async open(e) {
189
- if (await this.ready, this.gateOutcome && !this.gateOutcome.show) throw new c("GATE_REFUSED", this.gateOutcome.reason ?? "This site cannot accept Pybara payments yet.");
190
- let t = g(e.amount);
191
- if (t === null) throw new c("INVALID_CONFIG", `open(): "amount" must be a decimal string in the currency's major units, e.g. "12.34", or a positive number — got ${JSON.stringify(e.amount)}`);
106
+ if (await this.ready, this.gateOutcome && !this.gateOutcome.show) throw new i("GATE_REFUSED", this.gateOutcome.reason ?? "This site cannot accept Pybara payments yet.");
107
+ let t = p(e.amount);
108
+ if (t === null) throw new i("INVALID_CONFIG", `open(): "amount" must be a decimal string in the currency's major units, e.g. "12.34", or a positive number — got ${JSON.stringify(e.amount)}`);
192
109
  let n = e.currency ?? this.config.currency;
193
- if (!n) throw new c("INVALID_CONFIG", "open(): \"currency\" is required — pass it to open(), or set it once in Pybara.checkout()");
194
- if (!/^[A-Z]{3}$/.test(n)) throw new c("INVALID_CONFIG", `open(): "currency" must be an uppercase ISO 4217 code, e.g. "EUR" — got ${JSON.stringify(n)}`);
195
- if (e.durationMonths != null && !e.frequency) throw new c("INVALID_CONFIG", "open(): \"durationMonths\" needs a \"frequency\"");
110
+ if (!n) throw new i("INVALID_CONFIG", "open(): \"currency\" is required — pass it to open(), or set it once in Pybara.checkout()");
111
+ if (!/^[A-Z]{3}$/.test(n)) throw new i("INVALID_CONFIG", `open(): "currency" must be an uppercase ISO 4217 code, e.g. "EUR" — got ${JSON.stringify(n)}`);
112
+ if (e.durationMonths != null && !e.frequency) throw new i("INVALID_CONFIG", "open(): \"durationMonths\" needs a \"frequency\"");
196
113
  let r = e.frequency ? {
197
114
  frequency: e.frequency,
198
115
  ...e.durationMonths == null ? {} : { durationMonths: e.durationMonths }
199
116
  } : void 0;
200
- if (r && this.gateOutcome && this.gateOutcome.show && !this.gateOutcome.recurring) throw new c("GATE_REFUSED", "Recurring payments are temporarily unavailable.");
117
+ if (r && this.gateOutcome && this.gateOutcome.show && !this.gateOutcome.recurring) throw new i("GATE_REFUSED", "Recurring payments are temporarily unavailable.");
201
118
  if (this.isOpen) return;
202
119
  this.isOpen = !0;
203
- let i = !1;
120
+ let a = !1;
204
121
  try {
205
122
  await this.adminClient?.getRecipientDataWithCache(this.config.siteUrl);
206
123
  } catch (e) {
207
- this.config.debug && console.warn("🧩 pybara-js: recipient access validation failed:", e), i = !0;
124
+ this.config.debug && console.warn("🧩 pybara-js: recipient access validation failed:", e), a = !0;
208
125
  }
209
126
  this.modal || this.initCheckoutModal();
210
- let a = this.modal;
211
- if (!a) throw this.isOpen = !1, new c("CHECKOUT_FAILED", "The checkout modal could not be initialised.");
212
- if (i) this.isOpen = !1, a.renderTerminalState("This recipient is currently unable to accept donations."), this.initCheckoutModal();
127
+ let o = this.modal;
128
+ if (!o) throw this.isOpen = !1, new i("CHECKOUT_FAILED", "The checkout modal could not be initialised.");
129
+ if (a) this.isOpen = !1, o.renderTerminalState("This recipient is currently unable to accept donations."), this.initCheckoutModal();
213
130
  else {
214
131
  this.activePayment = e;
215
132
  try {
216
- a.show({
133
+ o.show({
217
134
  modalData: {
218
135
  beneficiary: this.config.recipientPrincipal,
219
- salt: y(),
136
+ salt: g(),
220
137
  reference: this.config.siteName
221
138
  },
222
139
  recurring: r,
223
140
  checkout: this.checkoutFor(e, t, n)
224
141
  });
225
142
  } catch (e) {
226
- throw this.isOpen = !1, this.activePayment = null, b(e);
143
+ throw this.isOpen = !1, this.activePayment = null, _(e);
227
144
  }
228
145
  }
229
146
  }
@@ -247,7 +164,7 @@ var p = /^(0|[1-9]\d*)(\.\d+)?$/, m = /^[a-z0-9-]{1,64}$/, h = class {
247
164
  r && console.error("🧩 pybara-js: admin client init failed:", e);
248
165
  }
249
166
  })(), o = (async () => {
250
- this.config.pluginVersion || (this.gateOutcome = await s(t, this.config.siteUrl, this.config.recipientPrincipal), !this.gateOutcome.show && r && console.warn("🧩 pybara-js: gate refused —", this.gateOutcome.reason));
167
+ this.config.pluginVersion || (this.gateOutcome = await l(t, this.config.siteUrl, this.config.recipientPrincipal), !this.gateOutcome.show && r && console.warn("🧩 pybara-js: gate refused —", this.gateOutcome.reason));
251
168
  })();
252
169
  await Promise.all([a, o]);
253
170
  }
@@ -277,7 +194,7 @@ var p = /^(0|[1-9]\d*)(\.\d+)?$/, m = /^[a-z0-9-]{1,64}$/, h = class {
277
194
  onError: (e) => {
278
195
  i.isOpen = !1;
279
196
  let t = i.activePayment;
280
- i.activePayment = null, t?.onError?.(b(e)), i.modal = null, i.initCheckoutModal();
197
+ i.activePayment = null, t?.onError?.(_(e)), i.modal = null, i.initCheckoutModal();
281
198
  },
282
199
  onClose: () => {
283
200
  i.isOpen = !1;
@@ -338,11 +255,11 @@ var p = /^(0|[1-9]\d*)(\.\d+)?$/, m = /^[a-z0-9-]{1,64}$/, h = class {
338
255
  n.rel = "preconnect", n.href = new URL(t[e]).origin, n.crossOrigin = "anonymous", document.head.appendChild(n);
339
256
  }
340
257
  };
341
- function g(e) {
258
+ function p(e) {
342
259
  let t = typeof e == "number" && Number.isFinite(e) ? String(e) : e;
343
- return typeof t != "string" || !p.test(t) || !/[1-9]/.test(t) ? null : t;
260
+ return typeof t != "string" || !u.test(t) || !/[1-9]/.test(t) ? null : t;
344
261
  }
345
- function _(e) {
262
+ function m(e) {
346
263
  let t = e.trim();
347
264
  if (!t) return null;
348
265
  let n;
@@ -353,14 +270,14 @@ function _(e) {
353
270
  }
354
271
  return n.protocol !== "https:" && n.protocol !== "http:" ? null : n.origin + n.pathname.replace(/\/+$/, "");
355
272
  }
356
- function v(e) {
357
- if (!e.recipientPrincipal) throw new c("INVALID_CONFIG", "Pybara.checkout: \"recipientPrincipal\" is required");
358
- if (!e.siteUrl) throw new c("INVALID_CONFIG", "Pybara.checkout: \"siteUrl\" is required");
359
- let t = _(e.siteUrl);
360
- if (!t) throw new c("INVALID_CONFIG", `Pybara.checkout: "siteUrl" is not a valid http(s) URL: ${e.siteUrl}`);
361
- if (!e.siteName) throw new c("INVALID_CONFIG", "Pybara.checkout: \"siteName\" is required");
362
- if (e.currency != null && !/^[A-Z]{3}$/.test(e.currency)) throw new c("INVALID_CONFIG", `Pybara.checkout: "currency" must be an uppercase ISO 4217 code, e.g. "EUR" — got ${JSON.stringify(e.currency)}`);
363
- if (e.platform != null && !m.test(e.platform)) throw new c("INVALID_CONFIG", "Pybara.checkout: \"platform\" must be a lowercase slug (a-z, 0-9, -), at most 64 characters");
273
+ function h(e) {
274
+ if (!e.recipientPrincipal) throw new i("INVALID_CONFIG", "Pybara.checkout: \"recipientPrincipal\" is required");
275
+ if (!e.siteUrl) throw new i("INVALID_CONFIG", "Pybara.checkout: \"siteUrl\" is required");
276
+ let t = m(e.siteUrl);
277
+ if (!t) throw new i("INVALID_CONFIG", `Pybara.checkout: "siteUrl" is not a valid http(s) URL: ${e.siteUrl}`);
278
+ if (!e.siteName) throw new i("INVALID_CONFIG", "Pybara.checkout: \"siteName\" is required");
279
+ if (e.currency != null && !/^[A-Z]{3}$/.test(e.currency)) throw new i("INVALID_CONFIG", `Pybara.checkout: "currency" must be an uppercase ISO 4217 code, e.g. "EUR" — got ${JSON.stringify(e.currency)}`);
280
+ if (e.platform != null && !d.test(e.platform)) throw new i("INVALID_CONFIG", "Pybara.checkout: \"platform\" must be a lowercase slug (a-z, 0-9, -), at most 64 characters");
364
281
  return {
365
282
  ...e,
366
283
  siteUrl: t,
@@ -368,18 +285,18 @@ function v(e) {
368
285
  debug: e.debug ?? !1
369
286
  };
370
287
  }
371
- function y() {
288
+ function g() {
372
289
  let e = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
373
290
  return btoa(String.fromCharCode(...e));
374
291
  }
375
- function b(e) {
292
+ function _(e) {
376
293
  return e instanceof Error ? e : Error(String(e));
377
294
  }
378
295
  //#endregion
379
296
  //#region src/index.ts
380
- function x(e) {
381
- return new h(e);
297
+ function v(e) {
298
+ return new f(e);
382
299
  }
383
- var S = { checkout: x };
300
+ var y = { checkout: v };
384
301
  //#endregion
385
- export { S as Pybara, h as PybaraCheckout, c as PybaraError, x as checkout };
302
+ export { y as Pybara, f as PybaraCheckout, i as PybaraError, v as checkout };
package/dist/types.d.ts CHANGED
@@ -88,17 +88,19 @@ export interface PaymentParams {
88
88
  }
89
89
  /** The payment a button's createPayment() returns: open()'s params, without the callbacks, which buttons() takes itself. */
90
90
  export type ButtonPayment = Omit<PaymentParams, 'onSuccess' | 'onError' | 'onClose'>;
91
+ /**
92
+ * The served button's style, passed to it as given and read by it: `color` 'brand' | 'black' | 'white' (PayPal's names; its 'gold', 'blue' and 'silver' read as 'brand'), `shape` 'pill' | 'rect' | 'sharp', `height` 25–55 px (PayPal's range, default 45), and `borderRadius` in pixels, 0 or more, which overrides the shape's corners, as PayPal's.
93
+ * Copy a PayPal button's style and the two match. A value the button doesn't know falls back to its default.
94
+ */
95
+ export interface ButtonStyle {
96
+ color?: string;
97
+ shape?: string;
98
+ height?: number;
99
+ borderRadius?: number;
100
+ }
91
101
  /** Options for checkout.buttons(): a "Pybara" button, served by Pybara, that opens this checkout on click. */
92
102
  export interface ButtonsOptions {
93
- /**
94
- * Passed to the button as given, and read by it: `color` 'brand' | 'black' | 'white' (PayPal's names; its 'gold', 'blue' and 'silver' read as 'brand'), `shape` 'pill' | 'rect' | 'sharp', `height` 25–55 px (PayPal's range, default 45).
95
- * Copy a PayPal button's style and the two match. A value the button doesn't know falls back to its default.
96
- */
97
- style?: {
98
- color?: string;
99
- shape?: string;
100
- height?: number;
101
- };
103
+ style?: ButtonStyle;
102
104
  /** Collapse the button to no height when Pybara is unavailable on this page; by default its slot stays, empty, so the layout never moves. */
103
105
  hideWhenUnavailable?: boolean;
104
106
  /** Called on the payer's click: the payment from the form's current values, as open() takes it (amount, currency, frequency, donor fields). */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,8IAA8I;AAC9I,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEtE,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,uKAAuK;IACvK,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gIAAgI;IAChI,OAAO,EAAE,MAAM,CAAC;IAChB,iHAAiH;IACjH,QAAQ,EAAE,MAAM,CAAC;IACjB,uLAAuL;IACvL,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yJAAyJ;IACzJ,MAAM,CAAC,EAAE,MAAM,CAAC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-1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pybara/pybara-js",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Accept crypto payments and donations with Pybara on any page — a callable checkout, in the stripe-js / paypal-js convention.",
5
5
  "keywords": [
6
6
  "pybara",
@@ -32,6 +32,10 @@
32
32
  "types": "./dist/modal/index.d.ts",
33
33
  "import": "./dist/modal/index.js"
34
34
  },
35
+ "./button": {
36
+ "types": "./dist/button/index.d.ts",
37
+ "import": "./dist/button/index.js"
38
+ },
35
39
  "./dist/pybara-js.iife.js": "./dist/pybara-js.iife.js",
36
40
  "./package.json": "./package.json"
37
41
  },
@@ -43,7 +47,7 @@
43
47
  "build": "vite build && vite build -c vite.config.iife.ts",
44
48
  "prepare": "npm run build",
45
49
  "type-check": "tsc --noEmit",
46
- "prepublishOnly": "npm run type-check && npm run build",
50
+ "prepublishOnly": "npm run type-check && node scripts/check-readme-version.mjs && npm run build",
47
51
  "release:tag": "git tag v$npm_package_version && git push origin v$npm_package_version",
48
52
  "demo": "node demo/load-env.mjs && (sleep 1 && open http://localhost:5678 &) && npx serve demo -l 5678",
49
53
  "dev": "vite --open /demo/"
package/dist/buttons.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { Availability } from './modal/modal';
2
- import { ButtonsOptions, PaymentParams, PybaraButtons } from './types';
3
- /** What the loader needs from its checkout: the frame's origin, open(), and the availability answers. */
4
- export interface ButtonsHost {
5
- walletUrl: string;
6
- open(payment: PaymentParams): Promise<void>;
7
- /** Subscribes to every availability answer, first with the latest one if there is one; returns the unsubscribe. */
8
- subscribeAvailability(listener: (availability: Availability) => void): () => void;
9
- }
10
- export declare function createButtons(host: ButtonsHost, options: ButtonsOptions): PybaraButtons;
11
- //# sourceMappingURL=buttons.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buttons.d.ts","sourceRoot":"","sources":["../src/buttons.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAe,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAEnG,yGAAyG;AACzG,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,mHAAmH;IACnH,qBAAqB,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACnF;AAoBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,aAAa,CAqFvF"}
@@ -1,209 +0,0 @@
1
- /* Pybara.js - pybara.com */
2
- //#region src/modal/config.ts
3
- var e = {
4
- Z_INDEX: 999999,
5
- BACKGROUND: "rgba(0, 0, 0, 0.7)"
6
- }, t = {
7
- OVERLAY_FADE_IN_MS: 200,
8
- PANEL_OPEN_MS: 300,
9
- PANEL_CLOSE_MS: 200,
10
- OVERLAY_FADE_OUT_DELAY_MS: 50,
11
- OVERLAY_FADE_OUT_MS: 150
12
- }, n = 0, r = 0, i = 0;
13
- function a(e) {
14
- e.preventDefault();
15
- }
16
- function o(e) {
17
- e.preventDefault();
18
- }
19
- function s(e) {
20
- e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || [
21
- "ArrowUp",
22
- "ArrowDown",
23
- "PageUp",
24
- "PageDown",
25
- "Home",
26
- "End",
27
- " "
28
- ].includes(e.key) && e.preventDefault();
29
- }
30
- function c() {
31
- window.scrollTo(r, i);
32
- }
33
- function l() {
34
- n === 0 && (r = window.scrollX, i = window.scrollY, window.addEventListener("wheel", a, { passive: !1 }), window.addEventListener("touchmove", o, { passive: !1 }), window.addEventListener("keydown", s), window.addEventListener("scroll", c)), n += 1;
35
- }
36
- function u() {
37
- n !== 0 && (--n, n === 0 && (window.removeEventListener("wheel", a), window.removeEventListener("touchmove", o), window.removeEventListener("keydown", s), window.removeEventListener("scroll", c)));
38
- }
39
- //#endregion
40
- //#region src/modal/modal.ts
41
- function d() {
42
- return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
43
- }
44
- var f = [
45
- "DESTINATION_REFUSED",
46
- "INVALID_BENEFICIARY",
47
- "INVALID_CHECKOUT",
48
- "NO_WALLET_AVAILABLE",
49
- "RATE_UNAVAILABLE",
50
- "SITE_MISMATCH"
51
- ];
52
- function p(e) {
53
- return f.includes(e) ? e : "UNKNOWN";
54
- }
55
- var m = class extends Error {
56
- constructor(e, t) {
57
- super(t), this.name = "EmbeddedError", this.code = e, Object.setPrototypeOf(this, new.target.prototype);
58
- }
59
- };
60
- function h(e) {
61
- return typeof e == "object" && !!e && typeof e.type == "string" && e.type.startsWith("pybara_embedded_");
62
- }
63
- var g = class {
64
- constructor(e) {
65
- this.overlay = null, this.iframe = null, this.spinner = null, this.handleMessage = null, this.handleEscapeKey = null, this.closable = !0, this.iframeLoaded = !1, this.pendingPaymentData = null, this.pendingPrecheck = null, this.config = e, this.walletOrigin = new URL(e.walletUrl).origin, this.createIframe();
66
- }
67
- createIframe() {
68
- let n = document.createElement("div");
69
- n.className = "pybara-checkout-overlay", n.style.cssText = `
70
- position: fixed;
71
- top: 0;
72
- left: 0;
73
- right: 0;
74
- bottom: 0;
75
- background: ${e.BACKGROUND};
76
- z-index: ${e.Z_INDEX};
77
- display: none;
78
- align-items: center;
79
- justify-content: center;
80
- overscroll-behavior: none;
81
- user-select: none;
82
- `;
83
- let r = document.createElement("iframe");
84
- r.src = `${this.config.walletUrl}/pay?mode=embedded`, r.title = "Pybara Wallet", r.style.cssText = "\n width: 100%;\n max-width: 500px;\n height: 0;\n max-height: 90vh;\n border: none;\n border-radius: 20px;\n box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);\n overscroll-behavior: none;\n ";
85
- let i = document.createElement("div");
86
- i.setAttribute("aria-hidden", "true"), i.style.cssText = "\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n ", i.innerHTML = "\n <svg viewBox=\"0 0 50 50\" width=\"50\" height=\"50\">\n <circle cx=\"25\" cy=\"25\" r=\"20\" fill=\"none\" stroke=\"white\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-dasharray=\"80\" stroke-dashoffset=\"20\"/>\n </svg>\n ", i.querySelector("svg")?.animate([{ transform: "rotate(0deg)" }, { transform: "rotate(360deg)" }], {
87
- duration: 1e3,
88
- iterations: Infinity
89
- }), r.addEventListener("load", () => {
90
- this.iframeLoaded = !0, this.pendingPrecheck &&= (this.sendPrecheck(this.pendingPrecheck), null), this.pendingPaymentData &&= (this.sendInitMessage(this.pendingPaymentData), null);
91
- }, { once: !0 }), this.handleMessage = (e) => {
92
- if (e.origin === this.walletOrigin && e.source === r.contentWindow && h(e.data)) switch (e.data.type) {
93
- case "pybara_embedded_result":
94
- this.config.onSuccess?.({
95
- blockIndex: e.data.blockIndex,
96
- reference: e.data.reference,
97
- payerPrincipal: e.data.payerPrincipal,
98
- token: e.data.token
99
- });
100
- break;
101
- case "pybara_embedded_error":
102
- this.close(), this.config.onError?.(new m(p(e.data.code), e.data.message));
103
- break;
104
- case "pybara_embedded_closed":
105
- this.close(), this.config.onClose?.();
106
- break;
107
- case "pybara_embedded_resize":
108
- r.style.height !== `${e.data.height}px` && (r.style.height = `${e.data.height}px`), this.spinner && (this.spinner.remove(), this.spinner = null, d() || r.animate([{
109
- transform: "translateY(20px)",
110
- opacity: 0
111
- }, {
112
- transform: "none",
113
- opacity: 1
114
- }], {
115
- duration: t.PANEL_OPEN_MS,
116
- easing: "ease"
117
- }));
118
- break;
119
- case "pybara_embedded_closable":
120
- this.closable = e.data.closable;
121
- break;
122
- case "pybara_embedded_availability": {
123
- let { type: t, v: n, ...r } = e.data;
124
- r.status !== "available" && r.detail && console.warn(r.detail), this.config.onAvailability?.(r);
125
- break;
126
- }
127
- }
128
- }, window.addEventListener("message", this.handleMessage), this.handleEscapeKey = (e) => {
129
- e.key === "Escape" && this.closable && (this.close(), this.config.onClose?.());
130
- }, document.addEventListener("keydown", this.handleEscapeKey), n.appendChild(i), n.appendChild(r), document.body.appendChild(n), this.overlay = n, this.iframe = r, this.spinner = i;
131
- }
132
- precheck(e) {
133
- this.iframeLoaded ? this.sendPrecheck(e) : this.pendingPrecheck = e;
134
- }
135
- sendPrecheck(e) {
136
- this.iframe?.contentWindow?.postMessage({
137
- type: "pybara_embedded_precheck",
138
- v: 1,
139
- context: this.config.context,
140
- ...e
141
- }, this.walletOrigin);
142
- }
143
- sendInitMessage(e) {
144
- let t = {
145
- type: "pybara_embedded_init",
146
- beneficiary: e.modalData.beneficiary,
147
- salt: e.modalData.salt,
148
- reference: e.modalData.reference,
149
- context: this.config.context,
150
- ...e.recurring ? { recurring: e.recurring } : {},
151
- checkout: e.checkout,
152
- ...this.config.thankYouMessage ? { thankYouMessage: this.config.thankYouMessage } : {},
153
- ...this.config.locale ? { locale: this.config.locale } : {}
154
- };
155
- this.iframe?.contentWindow?.postMessage(t, this.walletOrigin);
156
- }
157
- open() {
158
- this.overlay && this.overlay.style.display !== "flex" && (l(), this.overlay.style.display = "flex", d() || this.overlay.animate([{ opacity: 0 }, { opacity: 1 }], {
159
- duration: t.OVERLAY_FADE_IN_MS,
160
- easing: "ease"
161
- }));
162
- }
163
- show(e) {
164
- this.open(), this.iframeLoaded ? this.sendInitMessage(e) : this.pendingPaymentData = e;
165
- }
166
- renderTerminalState(t) {
167
- this.close(), l();
168
- let n = document.createElement("div");
169
- n.className = "pybara-checkout-overlay", n.style.cssText = `
170
- position: fixed;
171
- top: 0;
172
- left: 0;
173
- right: 0;
174
- bottom: 0;
175
- background: ${e.BACKGROUND};
176
- z-index: ${e.Z_INDEX};
177
- display: flex;
178
- align-items: center;
179
- justify-content: center;
180
- user-select: none;
181
- `;
182
- let r = document.createElement("div");
183
- r.style.cssText = "\n background: #fff;\n border-radius: 12px;\n color: #666;\n padding: 2rem;\n line-height: 1.4;\n max-width: 360px;\n text-align: center;\n font-family: system-ui, sans-serif;\n user-select: text;\n ", r.textContent = t, n.appendChild(r), n.addEventListener("click", (e) => {
184
- e.target === n && (n.remove(), u(), this.config.onClose?.());
185
- }), document.body.appendChild(n), this.overlay = n;
186
- }
187
- close() {
188
- this.handleMessage &&= (window.removeEventListener("message", this.handleMessage), null), this.handleEscapeKey &&= (document.removeEventListener("keydown", this.handleEscapeKey), null), u();
189
- let e = this.overlay, n = this.iframe;
190
- this.overlay = null, this.iframe = null, this.spinner = null, this.iframeLoaded = !1, this.pendingPaymentData = null, this.pendingPrecheck = null, this.closable = !0, e && (e.style.display === "none" || d() ? e.remove() : (e.style.pointerEvents = "none", n?.animate([{
191
- transform: "scale(1)",
192
- opacity: 1
193
- }, {
194
- transform: "scale(0.95)",
195
- opacity: 0
196
- }], {
197
- duration: t.PANEL_CLOSE_MS,
198
- easing: "ease-out",
199
- fill: "forwards"
200
- }), e.animate([{ opacity: 1 }, { opacity: 0 }], {
201
- duration: t.OVERLAY_FADE_OUT_MS,
202
- delay: t.OVERLAY_FADE_OUT_DELAY_MS,
203
- easing: "ease-out",
204
- fill: "forwards"
205
- }).finished.then(() => e.remove(), () => e.remove())));
206
- }
207
- };
208
- //#endregion
209
- export { m as n, g as t };