@pybara/pybara-js 0.9.0 → 0.10.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/README.md CHANGED
@@ -13,7 +13,7 @@ npm install @pybara/pybara-js
13
13
  No bundler? The IIFE build exposes `window.Pybara` — the same calls as the module:
14
14
 
15
15
  ```html
16
- <script src="https://cdn.jsdelivr.net/npm/@pybara/pybara-js@0.9/dist/pybara-js.iife.js"></script>
16
+ <script src="https://cdn.jsdelivr.net/npm/@pybara/pybara-js@0.10/dist/pybara-js.iife.js"></script>
17
17
  <script>
18
18
  const pybara = Pybara.checkout({ siteUrl, siteName, recipientPrincipal, currency: 'EUR' });
19
19
  pybara.buttons({ createPayment: () => ({ amount: '25' }) }).render('#pybara-button');
@@ -97,6 +97,28 @@ await pybara.open({ amount: '25', frequency: 'monthly', durationMonths: 12 });
97
97
  // omit durationMonths for an open-ended subscription
98
98
  ```
99
99
 
100
+ ## A Donate button with no amount
101
+
102
+ A tip jar, or a "Donate" button with no amount next to it: open the checkout without one, and it asks the donor how much, before the wallet.
103
+
104
+ ```ts
105
+ const pybara = Pybara.checkout({ siteUrl, siteName, recipientPrincipal, currency: 'USD' });
106
+ donateButton.addEventListener('click', () => pybara.open({}));
107
+ ```
108
+
109
+ With suggested amounts, shown as buttons beside the amount field:
110
+
111
+ ```ts
112
+ donateButton.addEventListener('click', () => pybara.open({ suggestedAmounts: ['5', '10', '25'] }));
113
+ ```
114
+
115
+ **Built with AI? Ask the site owner first,** rather than guessing:
116
+ - **Which amounts to suggest, if any:** up to four, in the site's currency. Without them, the donor types the amount; the checkout has no presets of its own.
117
+ - **Which currency the donations are in,** if the site doesn't say: it is required, set once in `Pybara.checkout()`, or on each `open()` on a multi-currency site. Never guess it from the visitor.
118
+ - **Whether to offer monthly giving,** and how: a second "Give monthly" button calling `open({ frequency: 'monthly' })`, or `frequency` on the existing one. Without `frequency`, donations are one-time.
119
+
120
+ Below the minimum, the checkout shows it in the donor's currency.
121
+
100
122
  ## Reference
101
123
 
102
124
  ### `Pybara.checkout(config)` → `PybaraCheckout`
@@ -122,7 +144,8 @@ await pybara.open({ amount: '25', frequency: 'monthly', durationMonths: 12 });
122
144
 
123
145
  | Field | Type | Description |
124
146
  |---|---|---|
125
- | `amount` | `string` \| `number` | Decimal string in the currency's major units: `'12.34'`, `'1000'` (JPY) |
147
+ | `amount` | `string` \| `number` | Decimal string in the currency's major units: `'12.34'`, `'1000'` (JPY). Omit it and the donor chooses ([A Donate button with no amount](#a-donate-button-with-no-amount)) |
148
+ | `suggestedAmounts` | `(string \| number)[]` | Without `amount`: up to four amounts offered as buttons beside the amount field |
126
149
  | `currency` | `string` | ISO 4217 — required here unless set in `Pybara.checkout()`; a multi-currency site passes it on every call |
127
150
  | `frequency` | `'weekly' \| 'monthly' \| 'yearly'` | Omit for one-time |
128
151
  | `durationMonths` | `3 \| 6 \| 12 \| 24` | Omit for unlimited |
@@ -185,7 +208,7 @@ If pybara.io can't be reached, the checkout doesn't spin forever: after 15 secon
185
208
 
186
209
  Today `checkout()` runs the **donation** flow (the `siteUrl` resolves a registered recipient; the frame collects donor details, optional anonymity, tax-receipt flag). Merchant payments ride the same surface when they land — the site's registry record decides the flow, the API doesn't change.
187
210
 
188
- If you want the whole donation *form* — presets, amount selector, frequency picker, styled button — that's [`@pybara/donate-widget`](https://github.com/pybara/pybara-widget), a product built on the same machinery.
211
+ If you want the whole donation *form* — presets, amount selector, frequency picker, styled button — that's [`@pybara/donate-widget`](https://docs.pybara.com/donate-widget/overview/), a product built on the same machinery.
189
212
 
190
213
  ## Internal entry points
191
214
 
@@ -10,7 +10,8 @@
10
10
  "recipientPrincipal": {
11
11
  "type": "string",
12
12
  "minLength": 1,
13
- "description": "Recipient's wallet principal — the same one the site's _pybara-payto DNS record lists. The registry does not serve it; the integrator passes it."
13
+ "not": { "enum": ["2vxsx-fae", "aaaaa-aa"] },
14
+ "description": "Recipient's wallet principal — the same one the site's _pybara-payto DNS record lists. The registry does not serve it; the integrator passes it. Never the anonymous principal (2vxsx-fae) or the management canister (aaaaa-aa): both are refused."
14
15
  },
15
16
  "siteUrl": {
16
17
  "type": "string",
@@ -93,7 +94,6 @@
93
94
  "description": "One payment attempt — the params of a single open() call.",
94
95
  "type": "object",
95
96
  "additionalProperties": false,
96
- "required": ["amount"],
97
97
  "properties": {
98
98
  "amount": {
99
99
  "oneOf": [
@@ -101,7 +101,19 @@
101
101
  { "type": "number", "exclusiveMinimum": 0 }
102
102
  ],
103
103
  "examples": ["12.34", "1000", "5"],
104
- "description": "The amount in the currency's major units, as a decimal string ('12.34' for €12.34, '1000' for ¥1,000); a number is accepted and turned into its decimal text. The checkout reads it with the currency's ISO 4217 minor units and refuses more decimals than the currency holds ('12.345' EUR, '1000.5' JPY), so the page never needs to know them. No minimum is checked here: the checkout shows its own, in the payer's currency."
104
+ "description": "The amount in the currency's major units, as a decimal string ('12.34' for €12.34, '1000' for ¥1,000); a number is accepted and turned into its decimal text. The checkout reads it with the currency's ISO 4217 minor units and refuses more decimals than the currency holds ('12.345' EUR, '1000.5' JPY), so the page never needs to know them. No minimum is checked here: the checkout shows its own, in the payer's currency. Omit it for a 'Donate' button with no amount: the checkout then asks the donor how much."
105
+ },
106
+ "suggestedAmounts": {
107
+ "type": "array",
108
+ "maxItems": 4,
109
+ "items": {
110
+ "oneOf": [
111
+ { "type": "string", "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$" },
112
+ { "type": "number", "exclusiveMinimum": 0 }
113
+ ]
114
+ },
115
+ "examples": [["5", "10", "25"]],
116
+ "description": "Without amount: up to four amounts the checkout offers the donor as buttons beside an amount field, in the currency's major units. Without them, the donor types the amount. Ask the site owner which amounts to suggest, if any, rather than inventing them."
105
117
  },
106
118
  "currency": {
107
119
  "type": "string",
@@ -1 +1 @@
1
- {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,UAAU,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,IAAI,IAAI;YAIC,IAAI;IA8ClB,OAAO,CAAC,iBAAiB;IAyDzB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAqCnB,6FAA6F;IAC7F,OAAO,CAAC,gBAAgB;CAOzB"}
@@ -82,8 +82,11 @@ export interface PaymentData {
82
82
  */
83
83
  export interface Checkout {
84
84
  v: 1;
85
- /** A decimal string in the currency's major units: "12.34" is €12.34, "1000" is ¥1,000. The frame reads it with the currency's ISO 4217 minor units. */
86
- amount: string;
85
+ /**
86
+ * A decimal string in the currency's major units: "12.34" is €12.34, "1000" is ¥1,000. The frame reads it with the currency's ISO 4217 minor units.
87
+ * A donation may omit it: the checkout then asks the donor how much, with `donation.suggestedAmounts` as its buttons. An order never may.
88
+ */
89
+ amount?: string;
87
90
  /** ISO 4217, uppercase. */
88
91
  currency: string;
89
92
  site: {
@@ -125,6 +128,8 @@ export interface Checkout {
125
128
  message?: string;
126
129
  isAnonymous?: boolean;
127
130
  wantsTaxReceipt?: boolean;
131
+ /** Without `amount`: up to four amounts the checkout's amount step offers as buttons, decimal strings in the checkout's currency. */
132
+ suggestedAmounts?: string[];
128
133
  };
129
134
  /** A merchant payment's part (context 'payment'): the order. Informational amounts are decimal text or numbers, any decimals; only `id` and each item's `name` and `quantity` are required. */
130
135
  order?: {
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/modal/modal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,MAAM,WAAW,SAAS;IACtB,sJAAsJ;IACtJ,WAAW,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,IAAI,EAAE,MAAM,CAAC;IACb,+JAA+J;IAC/J,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAChC,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAC;IAClB,6HAA6H;IAC7H,OAAO,EAAE,SAAS,GAAG,UAAU,CAAC;IAChC,2JAA2J;IAC3J,eAAe,CA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C7B,OAAO,CAAC,aAAa,CAAgD;IACrE,OAAO,CAAC,eAAe,CAA6C;IACpE,kKAAkK;IAClK,OAAO,CAAC,QAAQ,CAAQ;IACxB,+EAA+E;IAC/E,OAAO,CAAC,YAAY,CAAS;IAC7B,8EAA8E;IAC9E,OAAO,CAAC,kBAAkB,CAA4B;IACtD,2FAA2F;IAC3F,OAAO,CAAC,eAAe,CAA4B;IACnD,2HAA2H;IAC3H,OAAO,CAAC,SAAS,CAA8C;IAC/D,mDAAmD;IACnD,OAAO,CAAC,cAAc,CAA4B;IAClD,0FAA0F;IAC1F,OAAO,CAAC,eAAe,CAAyB;gBAEpC,MAAM,EAAE,mBAAmB;IAMvC,wGAAwG;IACxG,OAAO,CAAC,YAAY;IAgJpB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,cAAc;IAOtB,0LAA0L;IAC1L,OAAO,CAAC,cAAc;IAStB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAqCzB,uGAAuG;IACvG,OAAO,CAAC,SAAS;IAajB,mIAAmI;IACnI,OAAO,CAAC,gBAAgB;IAKxB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAKlC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAevB;;;OAGG;IACH,IAAI,IAAI,IAAI;IASZ,uIAAuI;IACvI,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAW7B;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IA2C1C;;;OAGG;IACH,KAAK,IAAI,IAAI;CAwChB"}
@@ -65,4 +65,4 @@ ic-request`);var ei=new TextEncoder().encode(`\vic-response`);new TextEncoder().
65
65
  text-align: center;
66
66
  font-family: system-ui, sans-serif;
67
67
  user-select: text;
68
- `,n.textContent=e,t.appendChild(n),t.addEventListener(`click`,e=>{e.target===t&&(t.remove(),Qu(),this.config.onClose?.())}),document.body.appendChild(t),this.overlay=t}close(){this.handleMessage&&=(window.removeEventListener(`message`,this.handleMessage),null),this.handleEscapeKey&&=(document.removeEventListener(`keydown`,this.handleEscapeKey),null),Qu();let e=this.overlay,t=this.iframe;this.overlay=null,this.iframe=null,this.spinner=null,this.iframeLoaded=!1,this.pendingPaymentData=null,this.lastPaymentData=null,this.pendingPrecheck=null,this.closable=!0,this.clearLoadTimer(),this.unavailableBox=null,e&&(e.style.display===`none`||$u()?e.remove():(e.style.pointerEvents=`none`,t?.animate([{transform:`scale(1)`,opacity:1},{transform:`scale(0.95)`,opacity:0}],{duration:Hu.PANEL_CLOSE_MS,easing:`ease-out`,fill:`forwards`}),e.animate([{opacity:1},{opacity:0}],{duration:Hu.OVERLAY_FADE_OUT_MS,delay:Hu.OVERLAY_FADE_OUT_DELAY_MS,easing:`ease-out`,fill:`forwards`}).finished.then(()=>e.remove(),()=>e.remove())))}},ad={widget:`donate-widget`,recurring:`donate-widget-recurring`};function od(e,t){let n=e=>{let t=/^(\d+)-(\d+)$/.exec(e);return t?[Number(t[1]),Number(t[2])]:null},r=n(e),i=n(t);return!r||!i?!1:r[0]>i[0]||r[0]===i[0]&&r[1]>=i[1]}async function sd(e){let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status} from ${e}`);return await t.json()}async function cd(e,t,n){let r=i[e],a=`https://${r.admin_core}.raw.icp0.io/widget-config`,o=`https://${r.admin_regs}.raw.icp0.io/widget-terms?site_url=${encodeURIComponent(t)}&principal=${encodeURIComponent(n)}`,s,c;try{[s,c]=await Promise.all([sd(a),sd(o)])}catch(e){return{show:!1,cause:`unreadable`,reason:`could not read the widget's configuration (${e instanceof Error?e.message:String(e)})`}}let l=s.kill_switch?.plugins??{};return l[ad.widget]?.enabled===!0?!c.signed||!c.version?{show:!1,cause:`terms`,reason:`${t} has not accepted the widget's terms in Pybara Wallet (Manage › Sites › Add a site without a plugin)`}:od(c.version,`1-0`)?{show:!0,recurring:l[ad.recurring]?.enabled===!0}:{show:!1,cause:`terms`,reason:`this widget version requires terms 1-0, and ${t} accepted ${c.version}: accept the new terms in Pybara Wallet (Manage › Sites)`}:{show:!1,cause:`switched-off`,reason:`the widget is switched off by Pybara for now`}}var $=class extends Error{constructor(e,t){super(t),this.name=`PybaraError`,this.code=e}};function ld(e){let t=typeof e?.height==`number`&&Number.isFinite(e.height)?Math.round(e.height):45;return Math.min(55,Math.max(25,t))}function ud(e,t){return typeof e?.borderRadius==`number`&&Number.isFinite(e.borderRadius)&&e.borderRadius>=0?`${e.borderRadius}px`:e?.shape===`sharp`?`0`:e?.shape===`rect`?`4px`:`${t/2}px`}function dd(e){let t=typeof e==`string`?document.querySelector(e):e;if(!t)throw new $(`INVALID_CONFIG`,`render(): no element matches ${JSON.stringify(e)}`);return t}function fd(e,t){let n=dd(e),r=new URL(t.walletUrl).origin,i=ld(t.style),a=document.createElement(`div`);a.style.cssText=`position:relative;width:100%;height:${i}px;`;let o=document.createElement(`div`);o.setAttribute(`aria-hidden`,`true`),o.style.cssText=`position:absolute;inset:0;border-radius:${ud(t.style,i)};background:rgba(128,128,128,0.16);`;let s=document.createElement(`iframe`);s.src=`${r}/button`,s.title=`Pybara`,s.style.cssText=`position:absolute;inset:0;width:100%;height:100%;border:0;opacity:0;color-scheme:normal;background:transparent;`,a.append(o,s),n.appendChild(a);let c=!1,l=null,u=e=>{s.contentWindow?.postMessage(e,r)},d=()=>u({type:`pybara_button_idle`,v:1}),f=e=>{l=e,c&&u({type:`pybara_button_availability`,v:1,status:e.status}),t.onStateChange?.(e)},p=setTimeout(()=>{if(c)return;o.remove(),t.hideWhenUnavailable===!0&&(a.style.height=`0px`);let e=`Pybara: the button (${r}/button) did not load within ${Uu/1e3} seconds; pybara.io may be unreachable from this browser.`;console.warn(e),t.onStateChange?.({status:`unavailable`,reason:`BUTTON_UNAVAILABLE`,detail:e})},Uu);s.addEventListener(`load`,()=>{u({type:`pybara_button_init`,v:1,style:t.style??{},hideWhenUnavailable:t.hideWhenUnavailable===!0,locale:t.locale,busy:!0})},{once:!0});let m=e=>{if(e.origin!==r||e.source!==s.contentWindow)return;let n=e.data;n?.type===`pybara_button_ready`||n?.type===`pybara_button_resize`?(typeof n.height==`number`&&(a.style.height=`${n.height}px`),c||(c=!0,clearTimeout(p),s.style.opacity=`1`,o.remove(),l&&u({type:`pybara_button_availability`,v:1,status:l.status}))):n?.type===`pybara_button_click`&&(async()=>{try{await t.onClick()}catch{d()}})()};window.addEventListener(`message`,m);let h=t.subscribeAvailability(f);return{idle:d,destroy(){clearTimeout(p),window.removeEventListener(`message`,m),h(),a.remove()}}}function pd(e,t){if(typeof t?.createPayment!=`function`)throw new $(`INVALID_CONFIG`,`buttons(): "createPayment" is required, a function returning the payment from the form, e.g. () => ({ amount: form.amount.value, currency: "EUR" })`);let n=[],r=()=>{for(let e of n)e.idle()};async function i(){try{let n=await t.createPayment();await e.open({...n,onSuccess:t.onSuccess,onError:e=>{r(),t.onError?.(e)},onClose:()=>{r(),t.onClose?.()}})||r()}catch(e){r(),t.onError?.(e instanceof Error?e:Error(String(e)))}}function a(r){let a=n.length===0;n.push(fd(r,{walletUrl:e.walletUrl,style:t.style,hideWhenUnavailable:t.hideWhenUnavailable,locale:e.locale,subscribeAvailability:e.subscribeAvailability,onClick:i,onStateChange:a?t.onStateChange:void 0}))}return{render:a,destroy(){for(let e of n.splice(0))e.destroy()}}}var md=/^(0|[1-9]\d*)(\.\d+)?$/,hd=/^[a-z0-9-]{1,64}$/,gd=class{constructor(e){this.adminClient=null,this.modal=null,this.gateOutcome=null,this.isOpen=!1,this.completedPayment=!1,this.activePayment=null,this.lastPrecheck={},this.availabilityListeners=new Set,this.latestAvailability=null,this.config=yd(e),this.config.onAvailability&&this.availabilityListeners.add(this.config.onAvailability),this.ready=this.init(),this.config.onAvailability&&this.precheck()}buttons(e){return pd({walletUrl:r[this.config.staging?`staging`:`prod`],locale:this.config.locale,open:async e=>(await this.open(e),this.activePayment===e),subscribeAvailability:e=>(this.availabilityListeners.add(e),this.latestAvailability?e(this.latestAvailability):!this.config.onAvailability&&this.availabilityListeners.size===1&&this.precheck(this.lastPrecheck),()=>{this.availabilityListeners.delete(e)})},e)}emitAvailability(e){this.latestAvailability=e;for(let t of this.availabilityListeners)t(e)}precheck(e={}){let t=typeof e.amount==`number`&&Number.isFinite(e.amount)?String(e.amount):e.amount;this.lastPrecheck={amount:typeof t==`string`?t:void 0,currency:e.currency??this.config.currency},this.sendPrecheck()}async sendPrecheck(){if(this.availabilityListeners.size===0)return;await this.ready;let e=this.gateOutcome;if(e&&!e.show){let t=e.cause===`unreadable`?{status:`retry-later`,reason:`GATE_UNREADABLE`,detail:`Pybara: ${e.reason}; the checkout tries again at the click.`}:e.cause===`switched-off`?{status:`unavailable`,reason:`SWITCHED_OFF`,detail:`Pybara: ${e.reason}.`}:{status:`unavailable`,reason:`SITE_NOT_READY`,detail:`Pybara: ${e.reason}; the site owner does this, not the page. https://docs.pybara.com/pybara-js/setup/`};t.detail&&console.warn(t.detail),this.emitAvailability(t)}else this.modal?.precheck({beneficiary:this.config.recipientPrincipal,siteUrl:this.config.siteUrl,...this.lastPrecheck})}get gate(){return this.gateOutcome}async open(e){if(await this.ready,this.gateOutcome&&!this.gateOutcome.show)throw new $(`GATE_REFUSED`,this.gateOutcome.reason??`This site cannot accept Pybara payments yet.`);let t=_d(e.amount);if(t===null)throw new $(`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)}`);let n=e.currency??this.config.currency;if(!n)throw new $(`INVALID_CONFIG`,`open(): "currency" is required — pass it to open(), or set it once in Pybara.checkout()`);if(!/^[A-Z]{3}$/.test(n))throw new $(`INVALID_CONFIG`,`open(): "currency" must be an uppercase ISO 4217 code, e.g. "EUR" — got ${JSON.stringify(n)}`);if(e.durationMonths!=null&&!e.frequency)throw new $(`INVALID_CONFIG`,`open(): "durationMonths" needs a "frequency"`);let r=e.frequency?{frequency:e.frequency,...e.durationMonths==null?{}:{durationMonths:e.durationMonths}}:void 0;if(r&&this.gateOutcome&&this.gateOutcome.show&&!this.gateOutcome.recurring)throw new $(`GATE_REFUSED`,`Recurring payments are temporarily unavailable.`);if(this.isOpen)return;this.isOpen=!0;let i=!1;try{await this.adminClient?.getRecipientDataWithCache(this.config.siteUrl)}catch(e){this.config.debug&&console.warn(`🧩 pybara-js: recipient access validation failed:`,e),i=!0}this.modal||this.initCheckoutModal();let a=this.modal;if(!a)throw this.isOpen=!1,new $(`CHECKOUT_FAILED`,`The checkout modal could not be initialised.`);if(i)this.isOpen=!1,a.renderTerminalState(`This recipient is currently unable to accept donations.`),this.initCheckoutModal();else{this.activePayment=e;try{a.show({modalData:{beneficiary:this.config.recipientPrincipal,salt:bd(),reference:this.config.siteName},recurring:r,checkout:this.checkoutFor(e,t,n)})}catch(e){throw this.isOpen=!1,this.activePayment=null,xd(e)}}}close(){this.modal?.close()}async init(){let e=this.config.staging?`staging`:`prod`,t=this.config.debug;t&&console.log(`🧩 pybara-js: initializing checkout…`),this.preconnectWallet(e),this.initCheckoutModal();let n=new Bu({adminCoreCanisterId:i[e].admin_core,debug:t});this.adminClient=n;let r=(async()=>{try{await n.init(),await n.getPybaraAdminConfig(),t&&console.log(`🧩 pybara-js: admin client ready`),n.getRecipientDataWithCache(this.config.siteUrl).catch(e=>{t&&console.warn(`🧩 pybara-js: recipient prewarm failed:`,e)})}catch(e){t&&console.error(`🧩 pybara-js: admin client init failed:`,e)}})(),a=(async()=>{this.config.pluginVersion||(this.gateOutcome=await cd(e,this.config.siteUrl,this.config.recipientPrincipal),!this.gateOutcome.show&&t&&console.warn(`🧩 pybara-js: gate refused —`,this.gateOutcome.reason))})();await Promise.all([r,a])}initCheckoutModal(){let e=this.config.staging?`staging`:`prod`,t=this.config,n=this;this.modal=new id({walletUrl:r[e],context:`donation`,thankYouMessage:t.thankYouMessage,locale:t.locale,onAvailability:e=>n.emitAvailability(e),onSuccess:e=>{n.completedPayment=!0;let r=n.activePayment,i=r?.frequency!=null,a={blockIndex:e.blockIndex,reference:e.reference,token:e.token,recurring:i,frequency:r?.frequency,durationMonths:i?r?.durationMonths??void 0:void 0,isUnlimited:i&&r?.durationMonths==null,payerPrincipal:e.payerPrincipal,recipientPrincipal:t.recipientPrincipal};r?.onSuccess?.(a)},onError:e=>{n.isOpen=!1;let t=n.activePayment;n.activePayment=null,t?.onError?.(xd(e)),n.modal=null,n.initCheckoutModal()},onClose:()=>{n.isOpen=!1;let e=n.activePayment;n.activePayment=null,e?.onClose?.(),n.completedPayment&&t.thankYouRedirectUrl?window.location.href=t.thankYouRedirectUrl:(n.completedPayment=!1,n.modal=null,n.initCheckoutModal())}}),this.availabilityListeners.size>0&&this.modal&&Object.keys(this.lastPrecheck).length>0&&this.sendPrecheck()}checkoutFor(e,t,n){let r=this.config;return{v:1,amount:t,currency:n,site:{url:r.siteUrl,name:r.siteName,country:r.siteCountry},platform:r.platform??`pybara-js`,pluginVersion:r.pluginVersion,siteTerms:{version:r.recipientTosVersion,acceptedAt:r.recipientTosAcceptedAt},notify:{email:r.notifyEmail,enabled:r.notifyDonations},donation:{donor:{email:e.donorEmail,firstName:e.donorFirstName,lastName:e.donorLastName,company:e.donorCompany,country:e.donorCountry,address:{line1:e.donorAddressLine1,line2:e.donorAddressLine2,city:e.donorAddressCity,state:e.donorAddressState,postalCode:e.donorAddressPostalCode,country:e.donorAddressCountry},tos:{version:e.donorTosVersion,acceptedAt:e.donorTosAcceptedAt}},message:e.donorMessage,isAnonymous:e.donorIsAnonymous,wantsTaxReceipt:e.wantsTaxReceipt}}}preconnectWallet(e){let t=document.createElement(`link`);t.rel=`preconnect`,t.href=new URL(r[e]).origin,t.crossOrigin=`anonymous`,document.head.appendChild(t)}};function _d(e){let t=typeof e==`number`&&Number.isFinite(e)?String(e):e;return typeof t!=`string`||!md.test(t)||!/[1-9]/.test(t)?null:t}function vd(e){let t=e.trim();if(!t)return null;let n;try{n=new URL(t.includes(`://`)?t:`https://${t}`)}catch{return null}return n.protocol!==`https:`&&n.protocol!==`http:`?null:n.origin+n.pathname.replace(/\/+$/,``)}function yd(e){if(!e.recipientPrincipal)throw new $(`INVALID_CONFIG`,`Pybara.checkout: "recipientPrincipal" is required`);if(!e.siteUrl)throw new $(`INVALID_CONFIG`,`Pybara.checkout: "siteUrl" is required`);let t=vd(e.siteUrl);if(!t)throw new $(`INVALID_CONFIG`,`Pybara.checkout: "siteUrl" is not a valid http(s) URL: ${e.siteUrl}`);if(!e.siteName)throw new $(`INVALID_CONFIG`,`Pybara.checkout: "siteName" is required`);if(e.currency!=null&&!/^[A-Z]{3}$/.test(e.currency))throw new $(`INVALID_CONFIG`,`Pybara.checkout: "currency" must be an uppercase ISO 4217 code, e.g. "EUR" — got ${JSON.stringify(e.currency)}`);if(e.platform!=null&&!hd.test(e.platform))throw new $(`INVALID_CONFIG`,`Pybara.checkout: "platform" must be a lowercase slug (a-z, 0-9, -), at most 64 characters`);return{...e,siteUrl:t,staging:e.staging??!1,debug:e.debug??!1}}function bd(){let e=crypto.getRandomValues(new Uint8Array(16));return btoa(String.fromCharCode(...e))}function xd(e){return e instanceof Error?e:Error(String(e))}function Sd(e){return new gd(e)}return e.Pybara={checkout:Sd},e.PybaraCheckout=gd,e.PybaraError=$,e.checkout=Sd,e})({});
68
+ `,n.textContent=e,t.appendChild(n),t.addEventListener(`click`,e=>{e.target===t&&(t.remove(),Qu(),this.config.onClose?.())}),document.body.appendChild(t),this.overlay=t}close(){this.handleMessage&&=(window.removeEventListener(`message`,this.handleMessage),null),this.handleEscapeKey&&=(document.removeEventListener(`keydown`,this.handleEscapeKey),null),Qu();let e=this.overlay,t=this.iframe;this.overlay=null,this.iframe=null,this.spinner=null,this.iframeLoaded=!1,this.pendingPaymentData=null,this.lastPaymentData=null,this.pendingPrecheck=null,this.closable=!0,this.clearLoadTimer(),this.unavailableBox=null,e&&(e.style.display===`none`||$u()?e.remove():(e.style.pointerEvents=`none`,t?.animate([{transform:`scale(1)`,opacity:1},{transform:`scale(0.95)`,opacity:0}],{duration:Hu.PANEL_CLOSE_MS,easing:`ease-out`,fill:`forwards`}),e.animate([{opacity:1},{opacity:0}],{duration:Hu.OVERLAY_FADE_OUT_MS,delay:Hu.OVERLAY_FADE_OUT_DELAY_MS,easing:`ease-out`,fill:`forwards`}).finished.then(()=>e.remove(),()=>e.remove())))}},ad={widget:`donate-widget`,recurring:`donate-widget-recurring`};function od(e,t){let n=e=>{let t=/^(\d+)-(\d+)$/.exec(e);return t?[Number(t[1]),Number(t[2])]:null},r=n(e),i=n(t);return!r||!i?!1:r[0]>i[0]||r[0]===i[0]&&r[1]>=i[1]}async function sd(e){let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status} from ${e}`);return await t.json()}async function cd(e,t,n){let r=i[e],a=`https://${r.admin_core}.raw.icp0.io/widget-config`,o=`https://${r.admin_regs}.raw.icp0.io/widget-terms?site_url=${encodeURIComponent(t)}&principal=${encodeURIComponent(n)}`,s,c;try{[s,c]=await Promise.all([sd(a),sd(o)])}catch(e){return{show:!1,cause:`unreadable`,reason:`could not read the widget's configuration (${e instanceof Error?e.message:String(e)})`}}let l=s.kill_switch?.plugins??{};return l[ad.widget]?.enabled===!0?!c.signed||!c.version?{show:!1,cause:`terms`,reason:`${t} has not accepted the widget's terms in Pybara Wallet (Manage › Sites › Add a site without a plugin)`}:od(c.version,`1-0`)?{show:!0,recurring:l[ad.recurring]?.enabled===!0}:{show:!1,cause:`terms`,reason:`this widget version requires terms 1-0, and ${t} accepted ${c.version}: accept the new terms in Pybara Wallet (Manage › Sites)`}:{show:!1,cause:`switched-off`,reason:`the widget is switched off by Pybara for now`}}var $=class extends Error{constructor(e,t){super(t),this.name=`PybaraError`,this.code=e}};function ld(e){let t=typeof e?.height==`number`&&Number.isFinite(e.height)?Math.round(e.height):45;return Math.min(55,Math.max(25,t))}function ud(e,t){return typeof e?.borderRadius==`number`&&Number.isFinite(e.borderRadius)&&e.borderRadius>=0?`${e.borderRadius}px`:e?.shape===`sharp`?`0`:e?.shape===`rect`?`4px`:`${t/2}px`}function dd(e){let t=typeof e==`string`?document.querySelector(e):e;if(!t)throw new $(`INVALID_CONFIG`,`render(): no element matches ${JSON.stringify(e)}`);return t}function fd(e,t){let n=dd(e),r=new URL(t.walletUrl).origin,i=ld(t.style),a=document.createElement(`div`);a.style.cssText=`position:relative;width:100%;height:${i}px;`;let o=document.createElement(`div`);o.setAttribute(`aria-hidden`,`true`),o.style.cssText=`position:absolute;inset:0;border-radius:${ud(t.style,i)};background:rgba(128,128,128,0.16);`;let s=document.createElement(`iframe`);s.src=`${r}/button`,s.title=`Pybara`,s.style.cssText=`position:absolute;inset:0;width:100%;height:100%;border:0;opacity:0;color-scheme:normal;background:transparent;`,a.append(o,s),n.appendChild(a);let c=!1,l=null,u=e=>{s.contentWindow?.postMessage(e,r)},d=()=>u({type:`pybara_button_idle`,v:1}),f=e=>{l=e,c&&u({type:`pybara_button_availability`,v:1,status:e.status}),t.onStateChange?.(e)},p=setTimeout(()=>{if(c)return;o.remove(),t.hideWhenUnavailable===!0&&(a.style.height=`0px`);let e=`Pybara: the button (${r}/button) did not load within ${Uu/1e3} seconds; pybara.io may be unreachable from this browser.`;console.warn(e),t.onStateChange?.({status:`unavailable`,reason:`BUTTON_UNAVAILABLE`,detail:e})},Uu);s.addEventListener(`load`,()=>{u({type:`pybara_button_init`,v:1,style:t.style??{},hideWhenUnavailable:t.hideWhenUnavailable===!0,locale:t.locale,busy:!0})},{once:!0});let m=e=>{if(e.origin!==r||e.source!==s.contentWindow)return;let n=e.data;n?.type===`pybara_button_ready`||n?.type===`pybara_button_resize`?(typeof n.height==`number`&&(a.style.height=`${n.height}px`),c||(c=!0,clearTimeout(p),s.style.opacity=`1`,o.remove(),l&&u({type:`pybara_button_availability`,v:1,status:l.status}))):n?.type===`pybara_button_click`&&(async()=>{try{await t.onClick()}catch{d()}})()};window.addEventListener(`message`,m);let h=t.subscribeAvailability(f);return{idle:d,destroy(){clearTimeout(p),window.removeEventListener(`message`,m),h(),a.remove()}}}function pd(e,t){if(typeof t?.createPayment!=`function`)throw new $(`INVALID_CONFIG`,`buttons(): "createPayment" is required, a function returning the payment from the form, e.g. () => ({ amount: form.amount.value, currency: "EUR" })`);let n=[],r=()=>{for(let e of n)e.idle()};async function i(){try{let n=await t.createPayment();await e.open({...n,onSuccess:t.onSuccess,onError:e=>{r(),t.onError?.(e)},onClose:()=>{r(),t.onClose?.()}})||r()}catch(e){r(),t.onError?.(e instanceof Error?e:Error(String(e)))}}function a(r){let a=n.length===0;n.push(fd(r,{walletUrl:e.walletUrl,style:t.style,hideWhenUnavailable:t.hideWhenUnavailable,locale:e.locale,subscribeAvailability:e.subscribeAvailability,onClick:i,onStateChange:a?t.onStateChange:void 0}))}return{render:a,destroy(){for(let e of n.splice(0))e.destroy()}}}var md=/^(0|[1-9]\d*)(\.\d+)?$/,hd=/^[a-z0-9-]{1,64}$/,gd=class{constructor(e){this.adminClient=null,this.modal=null,this.gateOutcome=null,this.isOpen=!1,this.completedPayment=!1,this.activePayment=null,this.lastPrecheck={},this.availabilityListeners=new Set,this.latestAvailability=null,this.config=yd(e),this.config.onAvailability&&this.availabilityListeners.add(this.config.onAvailability),this.ready=this.init(),this.config.onAvailability&&this.precheck()}buttons(e){return pd({walletUrl:r[this.config.staging?`staging`:`prod`],locale:this.config.locale,open:async e=>(await this.open(e),this.activePayment===e),subscribeAvailability:e=>(this.availabilityListeners.add(e),this.latestAvailability?e(this.latestAvailability):!this.config.onAvailability&&this.availabilityListeners.size===1&&this.precheck(this.lastPrecheck),()=>{this.availabilityListeners.delete(e)})},e)}emitAvailability(e){this.latestAvailability=e;for(let t of this.availabilityListeners)t(e)}precheck(e={}){let t=typeof e.amount==`number`&&Number.isFinite(e.amount)?String(e.amount):e.amount;this.lastPrecheck={amount:typeof t==`string`?t:void 0,currency:e.currency??this.config.currency},this.sendPrecheck()}async sendPrecheck(){if(this.availabilityListeners.size===0)return;await this.ready;let e=this.gateOutcome;if(e&&!e.show){let t=e.cause===`unreadable`?{status:`retry-later`,reason:`GATE_UNREADABLE`,detail:`Pybara: ${e.reason}; the checkout tries again at the click.`}:e.cause===`switched-off`?{status:`unavailable`,reason:`SWITCHED_OFF`,detail:`Pybara: ${e.reason}.`}:{status:`unavailable`,reason:`SITE_NOT_READY`,detail:`Pybara: ${e.reason}; the site owner does this, not the page. https://docs.pybara.com/pybara-js/setup/`};t.detail&&console.warn(t.detail),this.emitAvailability(t)}else this.modal?.precheck({beneficiary:this.config.recipientPrincipal,siteUrl:this.config.siteUrl,...this.lastPrecheck})}get gate(){return this.gateOutcome}async open(e){if(await this.ready,this.gateOutcome&&!this.gateOutcome.show)throw new $(`GATE_REFUSED`,this.gateOutcome.reason??`This site cannot accept Pybara payments yet.`);let t=e.amount==null||e.amount===``?void 0:_d(e.amount);if(t===null)throw new $(`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)}; omit it to let the donor choose`);let n=e.suggestedAmounts?.map(e=>{let t=_d(e);if(t===null)throw new $(`INVALID_CONFIG`,`open(): every "suggestedAmounts" entry must be a decimal string in the currency's major units, e.g. "10", or a positive number — got ${JSON.stringify(e)}`);return t});if(n&&n.length>4)throw new $(`INVALID_CONFIG`,`open(): "suggestedAmounts" holds at most 4 amounts — got ${n.length}`);let r=e.currency??this.config.currency;if(!r)throw new $(`INVALID_CONFIG`,`open(): "currency" is required — pass it to open(), or set it once in Pybara.checkout()`);if(!/^[A-Z]{3}$/.test(r))throw new $(`INVALID_CONFIG`,`open(): "currency" must be an uppercase ISO 4217 code, e.g. "EUR" — got ${JSON.stringify(r)}`);if(e.durationMonths!=null&&!e.frequency)throw new $(`INVALID_CONFIG`,`open(): "durationMonths" needs a "frequency"`);let i=e.frequency?{frequency:e.frequency,...e.durationMonths==null?{}:{durationMonths:e.durationMonths}}:void 0;if(i&&this.gateOutcome&&this.gateOutcome.show&&!this.gateOutcome.recurring)throw new $(`GATE_REFUSED`,`Recurring payments are temporarily unavailable.`);if(this.isOpen)return;this.isOpen=!0;let a=!1;try{await this.adminClient?.getRecipientDataWithCache(this.config.siteUrl)}catch(e){this.config.debug&&console.warn(`🧩 pybara-js: recipient access validation failed:`,e),a=!0}this.modal||this.initCheckoutModal();let o=this.modal;if(!o)throw this.isOpen=!1,new $(`CHECKOUT_FAILED`,`The checkout modal could not be initialised.`);if(a)this.isOpen=!1,o.renderTerminalState(`This recipient is currently unable to accept donations.`),this.initCheckoutModal();else{this.activePayment=e;try{o.show({modalData:{beneficiary:this.config.recipientPrincipal,salt:bd(),reference:this.config.siteName},recurring:i,checkout:this.checkoutFor(e,t,r,n)})}catch(e){throw this.isOpen=!1,this.activePayment=null,xd(e)}}}close(){this.modal?.close()}async init(){let e=this.config.staging?`staging`:`prod`,t=this.config.debug;t&&console.log(`🧩 pybara-js: initializing checkout…`),this.preconnectWallet(e),this.initCheckoutModal();let n=new Bu({adminCoreCanisterId:i[e].admin_core,debug:t});this.adminClient=n;let r=(async()=>{try{await n.init(),await n.getPybaraAdminConfig(),t&&console.log(`🧩 pybara-js: admin client ready`),n.getRecipientDataWithCache(this.config.siteUrl).catch(e=>{t&&console.warn(`🧩 pybara-js: recipient prewarm failed:`,e)})}catch(e){t&&console.error(`🧩 pybara-js: admin client init failed:`,e)}})(),a=(async()=>{this.config.pluginVersion||(this.gateOutcome=await cd(e,this.config.siteUrl,this.config.recipientPrincipal),!this.gateOutcome.show&&t&&console.warn(`🧩 pybara-js: gate refused —`,this.gateOutcome.reason))})();await Promise.all([r,a])}initCheckoutModal(){let e=this.config.staging?`staging`:`prod`,t=this.config,n=this;this.modal=new id({walletUrl:r[e],context:`donation`,thankYouMessage:t.thankYouMessage,locale:t.locale,onAvailability:e=>n.emitAvailability(e),onSuccess:e=>{n.completedPayment=!0;let r=n.activePayment,i=r?.frequency!=null,a={blockIndex:e.blockIndex,reference:e.reference,token:e.token,recurring:i,frequency:r?.frequency,durationMonths:i?r?.durationMonths??void 0:void 0,isUnlimited:i&&r?.durationMonths==null,payerPrincipal:e.payerPrincipal,recipientPrincipal:t.recipientPrincipal};r?.onSuccess?.(a)},onError:e=>{n.isOpen=!1;let t=n.activePayment;n.activePayment=null,t?.onError?.(xd(e)),n.modal=null,n.initCheckoutModal()},onClose:()=>{n.isOpen=!1;let e=n.activePayment;n.activePayment=null,e?.onClose?.(),n.completedPayment&&t.thankYouRedirectUrl?window.location.href=t.thankYouRedirectUrl:(n.completedPayment=!1,n.modal=null,n.initCheckoutModal())}}),this.availabilityListeners.size>0&&this.modal&&Object.keys(this.lastPrecheck).length>0&&this.sendPrecheck()}checkoutFor(e,t,n,r){let i=this.config;return{v:1,amount:t,currency:n,site:{url:i.siteUrl,name:i.siteName,country:i.siteCountry},platform:i.platform??`pybara-js`,pluginVersion:i.pluginVersion,siteTerms:{version:i.recipientTosVersion,acceptedAt:i.recipientTosAcceptedAt},notify:{email:i.notifyEmail,enabled:i.notifyDonations},donation:{donor:{email:e.donorEmail,firstName:e.donorFirstName,lastName:e.donorLastName,company:e.donorCompany,country:e.donorCountry,address:{line1:e.donorAddressLine1,line2:e.donorAddressLine2,city:e.donorAddressCity,state:e.donorAddressState,postalCode:e.donorAddressPostalCode,country:e.donorAddressCountry},tos:{version:e.donorTosVersion,acceptedAt:e.donorTosAcceptedAt}},message:e.donorMessage,isAnonymous:e.donorIsAnonymous,wantsTaxReceipt:e.wantsTaxReceipt,...t===void 0&&r?.length?{suggestedAmounts:r}:{}}}}preconnectWallet(e){let t=document.createElement(`link`);t.rel=`preconnect`,t.href=new URL(r[e]).origin,t.crossOrigin=`anonymous`,document.head.appendChild(t)}};function _d(e){let t=typeof e==`number`&&Number.isFinite(e)?String(e):e;return typeof t!=`string`||!md.test(t)||!/[1-9]/.test(t)?null:t}function vd(e){let t=e.trim();if(!t)return null;let n;try{n=new URL(t.includes(`://`)?t:`https://${t}`)}catch{return null}return n.protocol!==`https:`&&n.protocol!==`http:`?null:n.origin+n.pathname.replace(/\/+$/,``)}function yd(e){if(!e.recipientPrincipal)throw new $(`INVALID_CONFIG`,`Pybara.checkout: "recipientPrincipal" is required`);let t=e.recipientPrincipal.trim().toLowerCase();if(t===`2vxsx-fae`||t===`aaaaa-aa`)throw new $(`INVALID_CONFIG`,`Pybara.checkout: "recipientPrincipal" ${t} cannot receive payments (${t===`2vxsx-fae`?`the anonymous principal: anyone can move what it holds`:`the management canister`}); use the wallet principal the site's _pybara-payto DNS record lists`);if(!e.siteUrl)throw new $(`INVALID_CONFIG`,`Pybara.checkout: "siteUrl" is required`);let n=vd(e.siteUrl);if(!n)throw new $(`INVALID_CONFIG`,`Pybara.checkout: "siteUrl" is not a valid http(s) URL: ${e.siteUrl}`);if(!e.siteName)throw new $(`INVALID_CONFIG`,`Pybara.checkout: "siteName" is required`);if(e.currency!=null&&!/^[A-Z]{3}$/.test(e.currency))throw new $(`INVALID_CONFIG`,`Pybara.checkout: "currency" must be an uppercase ISO 4217 code, e.g. "EUR" — got ${JSON.stringify(e.currency)}`);if(e.platform!=null&&!hd.test(e.platform))throw new $(`INVALID_CONFIG`,`Pybara.checkout: "platform" must be a lowercase slug (a-z, 0-9, -), at most 64 characters`);return{...e,siteUrl:n,staging:e.staging??!1,debug:e.debug??!1}}function bd(){let e=crypto.getRandomValues(new Uint8Array(16));return btoa(String.fromCharCode(...e))}function xd(e){return e instanceof Error?e:Error(String(e))}function Sd(e){return new gd(e)}return e.Pybara={checkout:Sd},e.PybaraCheckout=gd,e.PybaraError=$,e.checkout=Sd,e})({});
package/dist/pybara-js.js CHANGED
@@ -104,40 +104,46 @@ var u = /^(0|[1-9]\d*)(\.\d+)?$/, d = /^[a-z0-9-]{1,64}$/, f = class {
104
104
  }
105
105
  async open(e) {
106
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)}`);
109
- let n = e.currency ?? this.config.currency;
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)}`);
107
+ let t = e.amount == null || e.amount === "" ? void 0 : 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)}; omit it to let the donor choose`);
109
+ let n = e.suggestedAmounts?.map((e) => {
110
+ let t = p(e);
111
+ if (t === null) throw new i("INVALID_CONFIG", `open(): every "suggestedAmounts" entry must be a decimal string in the currency's major units, e.g. "10", or a positive number — got ${JSON.stringify(e)}`);
112
+ return t;
113
+ });
114
+ if (n && n.length > 4) throw new i("INVALID_CONFIG", `open(): "suggestedAmounts" holds at most 4 amounts — got ${n.length}`);
115
+ let r = e.currency ?? this.config.currency;
116
+ if (!r) throw new i("INVALID_CONFIG", "open(): \"currency\" is required — pass it to open(), or set it once in Pybara.checkout()");
117
+ if (!/^[A-Z]{3}$/.test(r)) throw new i("INVALID_CONFIG", `open(): "currency" must be an uppercase ISO 4217 code, e.g. "EUR" — got ${JSON.stringify(r)}`);
112
118
  if (e.durationMonths != null && !e.frequency) throw new i("INVALID_CONFIG", "open(): \"durationMonths\" needs a \"frequency\"");
113
- let r = e.frequency ? {
119
+ let a = e.frequency ? {
114
120
  frequency: e.frequency,
115
121
  ...e.durationMonths == null ? {} : { durationMonths: e.durationMonths }
116
122
  } : void 0;
117
- if (r && this.gateOutcome && this.gateOutcome.show && !this.gateOutcome.recurring) throw new i("GATE_REFUSED", "Recurring payments are temporarily unavailable.");
123
+ if (a && this.gateOutcome && this.gateOutcome.show && !this.gateOutcome.recurring) throw new i("GATE_REFUSED", "Recurring payments are temporarily unavailable.");
118
124
  if (this.isOpen) return;
119
125
  this.isOpen = !0;
120
- let a = !1;
126
+ let o = !1;
121
127
  try {
122
128
  await this.adminClient?.getRecipientDataWithCache(this.config.siteUrl);
123
129
  } catch (e) {
124
- this.config.debug && console.warn("🧩 pybara-js: recipient access validation failed:", e), a = !0;
130
+ this.config.debug && console.warn("🧩 pybara-js: recipient access validation failed:", e), o = !0;
125
131
  }
126
132
  this.modal || 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();
133
+ let s = this.modal;
134
+ if (!s) throw this.isOpen = !1, new i("CHECKOUT_FAILED", "The checkout modal could not be initialised.");
135
+ if (o) this.isOpen = !1, s.renderTerminalState("This recipient is currently unable to accept donations."), this.initCheckoutModal();
130
136
  else {
131
137
  this.activePayment = e;
132
138
  try {
133
- o.show({
139
+ s.show({
134
140
  modalData: {
135
141
  beneficiary: this.config.recipientPrincipal,
136
142
  salt: g(),
137
143
  reference: this.config.siteName
138
144
  },
139
- recurring: r,
140
- checkout: this.checkoutFor(e, t, n)
145
+ recurring: a,
146
+ checkout: this.checkoutFor(e, t, r, n)
141
147
  });
142
148
  } catch (e) {
143
149
  throw this.isOpen = !1, this.activePayment = null, _(e);
@@ -203,26 +209,26 @@ var u = /^(0|[1-9]\d*)(\.\d+)?$/, d = /^[a-z0-9-]{1,64}$/, f = class {
203
209
  }
204
210
  }), this.availabilityListeners.size > 0 && this.modal && Object.keys(this.lastPrecheck).length > 0 && this.sendPrecheck();
205
211
  }
206
- checkoutFor(e, t, n) {
207
- let r = this.config;
212
+ checkoutFor(e, t, n, r) {
213
+ let i = this.config;
208
214
  return {
209
215
  v: 1,
210
216
  amount: t,
211
217
  currency: n,
212
218
  site: {
213
- url: r.siteUrl,
214
- name: r.siteName,
215
- country: r.siteCountry
219
+ url: i.siteUrl,
220
+ name: i.siteName,
221
+ country: i.siteCountry
216
222
  },
217
- platform: r.platform ?? "pybara-js",
218
- pluginVersion: r.pluginVersion,
223
+ platform: i.platform ?? "pybara-js",
224
+ pluginVersion: i.pluginVersion,
219
225
  siteTerms: {
220
- version: r.recipientTosVersion,
221
- acceptedAt: r.recipientTosAcceptedAt
226
+ version: i.recipientTosVersion,
227
+ acceptedAt: i.recipientTosAcceptedAt
222
228
  },
223
229
  notify: {
224
- email: r.notifyEmail,
225
- enabled: r.notifyDonations
230
+ email: i.notifyEmail,
231
+ enabled: i.notifyDonations
226
232
  },
227
233
  donation: {
228
234
  donor: {
@@ -246,7 +252,8 @@ var u = /^(0|[1-9]\d*)(\.\d+)?$/, d = /^[a-z0-9-]{1,64}$/, f = class {
246
252
  },
247
253
  message: e.donorMessage,
248
254
  isAnonymous: e.donorIsAnonymous,
249
- wantsTaxReceipt: e.wantsTaxReceipt
255
+ wantsTaxReceipt: e.wantsTaxReceipt,
256
+ ...t === void 0 && r?.length ? { suggestedAmounts: r } : {}
250
257
  }
251
258
  };
252
259
  }
@@ -272,15 +279,17 @@ function m(e) {
272
279
  }
273
280
  function h(e) {
274
281
  if (!e.recipientPrincipal) throw new i("INVALID_CONFIG", "Pybara.checkout: \"recipientPrincipal\" is required");
282
+ let t = e.recipientPrincipal.trim().toLowerCase();
283
+ if (t === "2vxsx-fae" || t === "aaaaa-aa") throw new i("INVALID_CONFIG", `Pybara.checkout: "recipientPrincipal" ${t} cannot receive payments (${t === "2vxsx-fae" ? "the anonymous principal: anyone can move what it holds" : "the management canister"}); use the wallet principal the site's _pybara-payto DNS record lists`);
275
284
  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}`);
285
+ let n = m(e.siteUrl);
286
+ if (!n) throw new i("INVALID_CONFIG", `Pybara.checkout: "siteUrl" is not a valid http(s) URL: ${e.siteUrl}`);
278
287
  if (!e.siteName) throw new i("INVALID_CONFIG", "Pybara.checkout: \"siteName\" is required");
279
288
  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
289
  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");
281
290
  return {
282
291
  ...e,
283
- siteUrl: t,
292
+ siteUrl: n,
284
293
  staging: e.staging ?? !1,
285
294
  debug: e.debug ?? !1
286
295
  };
package/dist/types.d.ts CHANGED
@@ -49,8 +49,14 @@ export interface PaymentParams {
49
49
  * The amount in the currency's major units, as a decimal string — "12.34" for €12.34, "1000" for ¥1,000 — as PayPal's API takes it.
50
50
  * A number is accepted and turned into its decimal text (12.34 → "12.34").
51
51
  * The checkout reads it with the currency's ISO 4217 minor units, and refuses more decimals than the currency holds ("12.345" EUR, "1000.5" JPY), so the page never needs to know them.
52
+ * Omit it for a "Donate" button with no amount: the checkout then asks the donor how much, with `suggestedAmounts` as its buttons.
52
53
  */
53
- amount: string | number;
54
+ amount?: string | number;
55
+ /**
56
+ * Without `amount`: up to four amounts the checkout offers the donor as buttons, beside an amount field, in the currency's major units (decimal strings or numbers, as `amount`).
57
+ * Without them, the donor types the amount. Ask the site owner which amounts to suggest, if any, rather than inventing them.
58
+ */
59
+ suggestedAmounts?: (string | number)[];
54
60
  /** The currency charged (ISO 4217, e.g. 'EUR') — the checkout config's when absent; one of the two is required. A multi-currency site passes it on every call. */
55
61
  currency?: string;
56
62
  /** Recurring frequency — omit for a one-time payment. */
@@ -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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oE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,wHAAwH;IACxH,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8DAA8D;IAC9D,WAAW,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,wFAAwF;IACxF,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,cAAc,GACd,qBAAqB,GACrB,iBAAiB,CAAC;AAEtB,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;gBAEnB,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;CAKnD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pybara/pybara-js",
3
- "version": "0.9.0",
3
+ "version": "0.10.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",
@@ -60,9 +60,5 @@
60
60
  "typescript": "7.0.2",
61
61
  "vite": "8.3.3",
62
62
  "vite-plugin-dts": "^5.1.2"
63
- },
64
- "repository": {
65
- "type": "git",
66
- "url": "git+https://github.com/pybara/pybara-js.git"
67
63
  }
68
64
  }