@facto-to/connect 0.0.1-beta.1 → 0.0.1-beta.5
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 +128 -20
- package/dist/browser/index.cjs +5 -6
- package/dist/browser/index.d.cts +1 -31
- package/dist/browser/index.d.ts +1 -31
- package/dist/browser/index.js +4 -5
- package/dist/index.d-DE9GmLfU.d.cts +114 -0
- package/dist/index.d-DE9GmLfU.d.ts +114 -0
- package/dist/react/index.cjs +0 -1
- package/dist/react/index.js +0 -1
- package/dist/server/index.cjs +1 -2
- package/dist/server/index.d.cts +33 -227
- package/dist/server/index.d.ts +33 -227
- package/dist/server/index.js +1 -2
- package/dist/testing/index.cjs +1 -2
- package/dist/testing/index.d.cts +1 -12
- package/dist/testing/index.d.ts +1 -12
- package/dist/testing/index.js +1 -2
- package/package.json +51 -17
- package/dist/browser/index.cjs.map +0 -1
- package/dist/browser/index.js.map +0 -1
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.js.map +0 -1
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/testing/index.cjs.map +0 -1
- package/dist/testing/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,19 +8,39 @@ Facto Connect SDK lets partners bind their users to Facto accounts and payment r
|
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
The workspace version **0.0.1-beta.5** is a prepared candidate, not a publication
|
|
12
|
+
receipt. Install only a tarball delivered with its source revision and digest.
|
|
13
|
+
Its ESM `.d.ts` and CommonJS `.d.cts` declarations include the existing public
|
|
14
|
+
type dependencies; consumers do not install the private engine-wire package or
|
|
15
|
+
need `skipLibCheck` to hide a missing dependency.
|
|
16
|
+
|
|
17
|
+
When upgrading from beta.4, server-built Hosted Connect URLs require a
|
|
18
|
+
per-request `merchantOrigin`. Refresh exhaustive decline-reason handling and
|
|
19
|
+
payment-readiness types against the delivered declarations. The existing
|
|
20
|
+
server error wrapper remains `FACTO_ENGINE_REQUEST_FAILED` with the original
|
|
21
|
+
HTTP `status` and raw `details`: a 403 `permission_denied` and a 409 `conflict`
|
|
22
|
+
remain distinguishable and are not automatically retried. Request deadlines
|
|
23
|
+
and caller cancellation cover the response body as well as response headers.
|
|
24
|
+
These behaviors are checked with offline responses; they do not establish
|
|
25
|
+
Production eligibility or authorize a funds operation.
|
|
26
|
+
|
|
27
|
+
`@facto-to/connect` is published to npm with **restricted access**. If your npm
|
|
28
|
+
account is authorized on the `@facto-to` organization:
|
|
16
29
|
|
|
17
30
|
```sh
|
|
18
|
-
npm install
|
|
31
|
+
npm install @facto-to/connect
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Otherwise the registry answers 404 and you install the tarball Facto ships with
|
|
35
|
+
your credentials instead — it is self-contained (its `@facto-to/*` runtime
|
|
36
|
+
dependencies are bundled into `dist/`), so the one file is the whole install:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm install --ignore-scripts ./facto-to-connect-<version>.tgz
|
|
19
40
|
```
|
|
20
41
|
|
|
21
42
|
Verify the tarball's SHA-256 against the digest Facto provides before
|
|
22
|
-
installing.
|
|
23
|
-
the supported path.
|
|
43
|
+
installing.
|
|
24
44
|
|
|
25
45
|
## Browser
|
|
26
46
|
|
|
@@ -67,12 +87,16 @@ const facto = createFactoConnectServer({
|
|
|
67
87
|
appId: process.env.FACTO_APP_ID!,
|
|
68
88
|
clientId: process.env.FACTO_CLIENT_ID!,
|
|
69
89
|
clientSecret: process.env.FACTO_CLIENT_SECRET!,
|
|
70
|
-
environment: 'sandbox',
|
|
71
90
|
})
|
|
72
91
|
|
|
73
92
|
const linked = await facto.exchangeUserLinkCode({ code, state, nonce })
|
|
74
93
|
```
|
|
75
94
|
|
|
95
|
+
Credentials and endpoints are one decision, not three. The client id Facto issued
|
|
96
|
+
you already names its environment, so the SDK reads it and resolves both the API
|
|
97
|
+
base URL and the Hosted Connect origin from it — there is nothing else to
|
|
98
|
+
configure and no URL to paste.
|
|
99
|
+
|
|
76
100
|
The server entrypoint wraps:
|
|
77
101
|
|
|
78
102
|
- `POST /api/merchant/user-links/exchange`
|
|
@@ -86,29 +110,91 @@ The public GA operation names mirror the OpenAPI contract:
|
|
|
86
110
|
`getAuthorizationSession`, `getPaymentAuthorization`, `createMerchantPayment`, and
|
|
87
111
|
`getMerchantPayment`. The pre-GA names remain as deprecated source-compatible aliases.
|
|
88
112
|
|
|
89
|
-
|
|
113
|
+
### Hosted Connect URLs
|
|
114
|
+
|
|
115
|
+
`buildHostedConnectUrl` and `facto.createHostedConnectUrl` take a required
|
|
116
|
+
`merchantOrigin`: the origin of the browsing context that will open the
|
|
117
|
+
returned URL. **Breaking change** — this used to be implicit, resolved by the
|
|
118
|
+
Hosted Connect page from `document.referrer` alone, which `rel="noreferrer"`
|
|
119
|
+
links, a `Referrer-Policy: no-referrer` deployment, or a privacy-mode browser
|
|
120
|
+
all erase silently. The parameter is required so a
|
|
121
|
+
missing value fails your build instead of a shopper's session.
|
|
122
|
+
|
|
123
|
+
Pass the origin of *this specific request's* browsing context — never a
|
|
124
|
+
single static value pinned in server config, since one server can serve
|
|
125
|
+
several merchant origins (custom domains, preview deployments, staging
|
|
126
|
+
mirrors) that would otherwise all get stamped with whichever origin happened
|
|
127
|
+
to be configured last:
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
// Express-style handler: derive merchantOrigin from the request that is
|
|
131
|
+
// actually asking, not from an environment variable.
|
|
132
|
+
app.get('/facto/connect-url', (req, res) => {
|
|
133
|
+
const merchantOrigin = req.get('origin') ?? new URL(req.get('referer')!).origin
|
|
134
|
+
const url = facto.createHostedConnectUrl({ state, nonce, merchantOrigin })
|
|
135
|
+
res.json({ url })
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`merchantOrigin` must be a bare `http(s)` origin — no path, query, fragment,
|
|
140
|
+
or credentials — and is written verbatim into the URL's `external_origin`
|
|
141
|
+
parameter. A value that fails that shape throws
|
|
142
|
+
`merchantOrigin must be an absolute http(s) origin`; omitting it throws
|
|
143
|
+
`merchantOrigin is required and has no implicit default`. Both are
|
|
144
|
+
`FactoConnectServerError` with code `FACTO_CONFIG_INVALID`.
|
|
145
|
+
|
|
146
|
+
This is the hosted (server-built) URL only. The browser popup leg
|
|
147
|
+
(`createFactoConnect`/`FactoConnectTransportOptions.origin`) already sets its
|
|
148
|
+
own `external_origin` from `window.location.origin` (or an explicit `origin`
|
|
149
|
+
override) and is unchanged by this release — see CHANGELOG for how the two
|
|
150
|
+
legs relate when they disagree.
|
|
151
|
+
|
|
152
|
+
### Environment
|
|
153
|
+
|
|
154
|
+
`environment` is optional and accepts `sandbox`, `dev`, or `production`. Per ADR-0077
|
|
90
155
|
(“sandbox naming, dev interface”), `sandbox` is the documented public name for the test
|
|
91
156
|
environment and `dev` is the infrastructure name for the same environment: both resolve the
|
|
92
157
|
same published dev endpoints (`https://dev-api.facto.to`, hosted Connect
|
|
93
|
-
`https://dev.facto.to`) and the `/api/dev/*` route family.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
158
|
+
`https://dev.facto.to`) and the `/api/dev/*` route family.
|
|
159
|
+
|
|
160
|
+
> **Real-money warning (ADR-0078):** Sandbox is a product name, not a testnet.
|
|
161
|
+
> The environment behind `sandbox`/`dev` settles on mainnet chains with real
|
|
162
|
+
> value — a succeeded payment, refund, or faucet transfer moves real USDC. The
|
|
163
|
+
> only zero-money path is the offline fixture transport
|
|
164
|
+
> (`@facto-to/connect/testing`), which never performs network I/O.
|
|
165
|
+
|
|
166
|
+
Omit it and the environment is derived from `clientId`, in this order:
|
|
167
|
+
|
|
168
|
+
1. the explicit `environment` value, when you pass one;
|
|
169
|
+
2. the client id's keyspace — `dev_mcid_`/`dev_pspid_`/`dev_cpid_` resolve dev, bare
|
|
170
|
+
`mcid_`/`pspid_`/`cpid_` resolve production;
|
|
171
|
+
3. an `apiBaseUrl` or `hostedConnectUrl` you pointed at a published Facto endpoint.
|
|
172
|
+
|
|
173
|
+
That is evidence, never a default. A client id carrying no published keyspace — internal
|
|
174
|
+
(`lab_`, `staging_`, `test_`), legacy (`sandbox_`), or unrecognized — derives nothing and
|
|
175
|
+
throws at construction. The historical silent fallback — Production endpoints over the
|
|
176
|
+
legacy `/api/external/*` routes — was removed before first publish, so a wrong environment
|
|
177
|
+
still fails loudly at construction instead of sending credentialed traffic to the wrong
|
|
178
|
+
deployment at runtime. An explicit `environment` that contradicts the credential is also
|
|
179
|
+
rejected there rather than silently preferring one of the two. Exact published origins are
|
|
180
|
+
matched fail-closed, and selector/origin or API/Hosted environment conflicts are rejected
|
|
181
|
+
before any credential-bearing request.
|
|
182
|
+
|
|
183
|
+
`factoConnectEnvironmentFromClientId(clientId)` is exported if you need the same reading
|
|
184
|
+
outside the client — for a config banner or a startup assertion, say. It returns `'dev'`,
|
|
185
|
+
`'production'`, or `undefined`. All operations, including the deprecated pre-GA aliases, use only the canonical
|
|
100
186
|
`/api/connect` and `/api/merchant` families; the legacy `/api/external` aliases are gone. The
|
|
101
187
|
published dev URL is a target endpoint and does not imply that a named dev deployment is
|
|
102
188
|
currently available.
|
|
103
189
|
|
|
104
190
|
`staging` and the former `custom` selector are retired. Local, private, and staging
|
|
105
|
-
deployments
|
|
106
|
-
|
|
191
|
+
deployments pass explicit `apiBaseUrl` and `hostedConnectUrl` overrides, which take
|
|
192
|
+
precedence over the published endpoint tables. A dev credential still names the environment
|
|
193
|
+
for the dev-only capability gates, so `environment` stays optional here too:
|
|
107
194
|
|
|
108
195
|
```ts
|
|
109
196
|
createFactoConnectServer({
|
|
110
197
|
...credentials,
|
|
111
|
-
environment: 'sandbox',
|
|
112
198
|
apiBaseUrl: 'http://127.0.0.1:8080',
|
|
113
199
|
hostedConnectUrl: 'http://127.0.0.1:5173',
|
|
114
200
|
})
|
|
@@ -193,6 +279,28 @@ an `Idempotency-Key`, honoring `Retry-After`; it never retries other POST calls.
|
|
|
193
279
|
and fixtures; callers must read the capability response rather than assuming a dev
|
|
194
280
|
endpoint, faucet, simulation, or money loop is deployed or verified.
|
|
195
281
|
|
|
282
|
+
## Link-code mint refusal errors
|
|
283
|
+
|
|
284
|
+
The two refusals below originate on the engine's link-code minting surface and
|
|
285
|
+
need different recovery actions. Their uppercase tokens are prefixes of the
|
|
286
|
+
engine's `error.message`, not SDK error codes. The identity refusal requires a
|
|
287
|
+
forced link reference, as used by the sandbox persona flow; the ordinary Hosted
|
|
288
|
+
Connect flow does not supply that reference.
|
|
289
|
+
|
|
290
|
+
| Message prefix | Engine `error.code` | HTTP | Meaning and recovery |
|
|
291
|
+
| --- | --- | --- | --- |
|
|
292
|
+
| `FACTO_LINK_IDENTITY_MISMATCH` | `conflict` | 409 | The forced link reference on a mint request differs from this user's active grant for the app. Unlink the existing association before reclaiming it. |
|
|
293
|
+
| `FACTO_LINK_MISMATCH` | `permission_denied` | 403 | The mint request's origin is not registered for the app. Register the intended origin; changing the shopper's identity does not fix this refusal. |
|
|
294
|
+
|
|
295
|
+
For non-success HTTP responses, `FactoConnectServerError.code` remains
|
|
296
|
+
`FACTO_ENGINE_REQUEST_FAILED`. Its `status` preserves the HTTP status and its
|
|
297
|
+
`details` preserves the engine error envelope, including `error.code` and
|
|
298
|
+
`error.message`. Both refusals are non-retryable: distinguish their status and
|
|
299
|
+
message prefix instead of treating every link refusal as an origin mismatch.
|
|
300
|
+
The SDK preserves these fields if a server returns such an envelope. This is
|
|
301
|
+
not a claim that the merchant link-code exchange endpoint produces either
|
|
302
|
+
minting refusal, or that the SDK exposes the minting surface.
|
|
303
|
+
|
|
196
304
|
## Offline Fixtures
|
|
197
305
|
|
|
198
306
|
The testing entrypoint provides an in-memory transport that never performs network I/O:
|
package/dist/browser/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var E=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var e1=Object.getOwnPropertyNames;var t1=Object.prototype.hasOwnProperty;var o1=(e,t)=>{for(var n in t)E(e,n,{get:t[n],enumerable:!0})},n1=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of e1(t))!t1.call(e,a)&&a!==n&&E(e,a,{get:()=>t[a],enumerable:!(s=J(t,a))||s.enumerable});return e};var s1=e=>n1(E({},"__esModule",{value:!0}),e);var N1={};o1(N1,{FACTO_LINK_CLOSE_REQUESTED:()=>P,FACTO_LINK_CONNECTED:()=>_,FACTO_LINK_FAILED:()=>O,FACTO_LINK_READY:()=>T,FactoConnect:()=>Z1,FactoConnectError:()=>m,createFactoConnect:()=>A,createFactoConnectTransport:()=>R,createFactoExpressCheckout:()=>X,default:()=>B1});module.exports=s1(N1);var D=`<svg xmlns:xodm="http://www.corel.com/coreldraw/odm/2003" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 2500 2500" style="enable-background:new 0 0 2500 2500;" xml:space="preserve"><div xmlns="" id="in-page-channel-node-id" data-channel-name="in_page_channel_fxgOrU"/>
|
|
2
2
|
<style type="text/css">
|
|
3
3
|
.st0{fill:none;}
|
|
4
4
|
.st1{fill:#213147;}
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
transform="translate(70 66)"
|
|
118
118
|
/>
|
|
119
119
|
</svg>
|
|
120
|
-
`,f1='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill-opacity=".5" d="M17.82 14.342v4.672h1.275c.172 0 .312-.14.312-.311v-4.05a.31.31 0 0 0-.312-.312zm0-9.356v4.673h1.275c.172 0 .312-.14.312-.312v-4.05a.31.31 0 0 0-.312-.311z"/><path fill-opacity=".3" d="M20.209 4.986v4.673h.477c.172 0 .311-.14.311-.312v-4.05a.31.31 0 0 0-.311-.311zm.002 9.356v4.672h.477c.172 0 .312-.14.312-.311v-4.05a.31.31 0 0 0-.312-.312z"/><path d="M12.026 9.67h-4.03a.31.31 0 0 0-.31.307v4.002c0 .17.138.308.31.308h4.03a.31.31 0 0 0 .31-.308V9.977a.31.31 0 0 0-.31-.308M7.361 4.986h-4.05A.31.31 0 0 0 3 5.297v4.05c0 .172.14.312.312.312h4.05c.171 0 .31-.14.31-.312v-4.05a.31.31 0 0 0-.31-.311m9.343 0h-4.05a.31.31 0 0 0-.311.311v4.05c0 .172.14.312.311.312h4.05c.172 0 .312-.14.312-.312v-4.05a.31.31 0 0 0-.312-.311M7.361 14.33h-4.05a.31.31 0 0 0-.311.313v4.05c0 .171.14.31.312.31h4.05a.31.31 0 0 0 .31-.31v-4.05a.31.31 0 0 0-.31-.312m9.343-.001h-4.05a.31.31 0 0 0-.311.313v4.05c0 .171.14.31.311.31h4.05a.31.31 0 0 0 .312-.31v-4.05a.31.31 0 0 0-.312-.312"/></svg>',$=[{chainId:1,name:"Ethereum",gasSymbol:"ETH",explorerUrl:"https://etherscan.io",logo:r1,logoTheme:"normal",testnet:!1},{chainId:56,name:"BNB",gasSymbol:"BNB",explorerUrl:"https://bscscan.com",logo:a1,logoTheme:"normal",testnet:!1},{chainId:137,name:"Polygon",gasSymbol:"POL",explorerUrl:"https://polygonscan.com",logo:d1,logoTheme:"normal",testnet:!1},{chainId:143,name:"Monad",gasSymbol:"MON",explorerUrl:"https://monadscan.com",logo:c1,logoTheme:"normal",testnet:!1},{chainId:196,name:"X Layer",gasSymbol:"OKB",explorerUrl:"https://www.oklink.com/x-layer/evm",logo:f1,logoTheme:"invertOnDark",testnet:!1},{chainId:988,name:"Stable Mainnet",gasSymbol:"USDT0",explorerUrl:"https://stablescan.xyz",logo:u1,logoTheme:"invertOnLight",testnet:!1},{chainId:1329,name:"Sei",gasSymbol:"SEI",explorerUrl:"https://seiscan.io",logo:C1,logoTheme:"normal",testnet:!1},{chainId:4217,name:"Tempo",gasSymbol:"TMPO",explorerUrl:"https://explore.tempo.xyz",logo:V,logoTheme:"normal",testnet:!1},{chainId:4326,name:"MegaETH",gasSymbol:"ETH",explorerUrl:"https://mega.etherscan.io",logo:i1,logoTheme:"normal",testnet:!1},{chainId:8453,name:"Base",gasSymbol:"ETH",explorerUrl:"https://basescan.org",logo:z,logoTheme:"normal",testnet:!1},{chainId:9745,name:"Plasma",gasSymbol:"XPL",explorerUrl:"https://plasmascan.to",logo:l1,logoTheme:"normal",testnet:!1},{chainId:42161,name:"Arbitrum",gasSymbol:"ETH",explorerUrl:"https://arbiscan.io",logo:D,logoTheme:"normal",testnet:!1},{chainId:42431,name:"Tempo Moderato",gasSymbol:"SEI",explorerUrl:"https://explore.tempo.xyz",logo:V,logoTheme:"normal",testnet:!0},{chainId:46630,name:"Robinhood Testnet",gasSymbol:"ETH",explorerUrl:"https://explorer.testnet.chain.robinhood.com",logo:p1,logoTheme:"normal",testnet:!0},{chainId:84532,name:"Base Sepolia",gasSymbol:"ETH",explorerUrl:"https://sepolia.basescan.org",logo:z,logoTheme:"normal",testnet:!0},{chainId:421614,name:"Arbitrum Sepolia",gasSymbol:"ETH",explorerUrl:"https://sepolia.arbiscan.io",logo:D,logoTheme:"normal",testnet:!0}],
|
|
120
|
+
`,f1='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill-opacity=".5" d="M17.82 14.342v4.672h1.275c.172 0 .312-.14.312-.311v-4.05a.31.31 0 0 0-.312-.312zm0-9.356v4.673h1.275c.172 0 .312-.14.312-.312v-4.05a.31.31 0 0 0-.312-.311z"/><path fill-opacity=".3" d="M20.209 4.986v4.673h.477c.172 0 .311-.14.311-.312v-4.05a.31.31 0 0 0-.311-.311zm.002 9.356v4.672h.477c.172 0 .312-.14.312-.311v-4.05a.31.31 0 0 0-.312-.312z"/><path d="M12.026 9.67h-4.03a.31.31 0 0 0-.31.307v4.002c0 .17.138.308.31.308h4.03a.31.31 0 0 0 .31-.308V9.977a.31.31 0 0 0-.31-.308M7.361 4.986h-4.05A.31.31 0 0 0 3 5.297v4.05c0 .172.14.312.312.312h4.05c.171 0 .31-.14.31-.312v-4.05a.31.31 0 0 0-.31-.311m9.343 0h-4.05a.31.31 0 0 0-.311.311v4.05c0 .172.14.312.311.312h4.05c.172 0 .312-.14.312-.312v-4.05a.31.31 0 0 0-.312-.311M7.361 14.33h-4.05a.31.31 0 0 0-.311.313v4.05c0 .171.14.31.312.31h4.05a.31.31 0 0 0 .31-.31v-4.05a.31.31 0 0 0-.31-.312m9.343-.001h-4.05a.31.31 0 0 0-.311.313v4.05c0 .171.14.31.311.31h4.05a.31.31 0 0 0 .312-.31v-4.05a.31.31 0 0 0-.312-.312"/></svg>',$=[{chainId:1,name:"Ethereum",gasSymbol:"ETH",explorerUrl:"https://etherscan.io",logo:r1,logoTheme:"normal",testnet:!1},{chainId:56,name:"BNB",gasSymbol:"BNB",explorerUrl:"https://bscscan.com",logo:a1,logoTheme:"normal",testnet:!1},{chainId:137,name:"Polygon",gasSymbol:"POL",explorerUrl:"https://polygonscan.com",logo:d1,logoTheme:"normal",testnet:!1},{chainId:143,name:"Monad",gasSymbol:"MON",explorerUrl:"https://monadscan.com",logo:c1,logoTheme:"normal",testnet:!1},{chainId:196,name:"X Layer",gasSymbol:"OKB",explorerUrl:"https://www.oklink.com/x-layer/evm",logo:f1,logoTheme:"invertOnDark",testnet:!1},{chainId:988,name:"Stable Mainnet",gasSymbol:"USDT0",explorerUrl:"https://stablescan.xyz",logo:u1,logoTheme:"invertOnLight",testnet:!1},{chainId:1329,name:"Sei",gasSymbol:"SEI",explorerUrl:"https://seiscan.io",logo:C1,logoTheme:"normal",testnet:!1},{chainId:4217,name:"Tempo",gasSymbol:"TMPO",explorerUrl:"https://explore.tempo.xyz",logo:V,logoTheme:"normal",testnet:!1},{chainId:4326,name:"MegaETH",gasSymbol:"ETH",explorerUrl:"https://mega.etherscan.io",logo:i1,logoTheme:"normal",testnet:!1},{chainId:8453,name:"Base",gasSymbol:"ETH",explorerUrl:"https://basescan.org",logo:z,logoTheme:"normal",testnet:!1},{chainId:9745,name:"Plasma",gasSymbol:"XPL",explorerUrl:"https://plasmascan.to",logo:l1,logoTheme:"normal",testnet:!1},{chainId:42161,name:"Arbitrum",gasSymbol:"ETH",explorerUrl:"https://arbiscan.io",logo:D,logoTheme:"normal",testnet:!1},{chainId:42431,name:"Tempo Moderato",gasSymbol:"SEI",explorerUrl:"https://explore.tempo.xyz",logo:V,logoTheme:"normal",testnet:!0},{chainId:46630,name:"Robinhood Testnet",gasSymbol:"ETH",explorerUrl:"https://explorer.testnet.chain.robinhood.com",logo:p1,logoTheme:"normal",testnet:!0},{chainId:84532,name:"Base Sepolia",gasSymbol:"ETH",explorerUrl:"https://sepolia.basescan.org",logo:z,logoTheme:"normal",testnet:!0},{chainId:421614,name:"Arbitrum Sepolia",gasSymbol:"ETH",explorerUrl:"https://sepolia.arbiscan.io",logo:D,logoTheme:"normal",testnet:!0}],k=Object.fromEntries($.map(e=>[e.chainId,e])),g1=`<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
121
121
|
<!-- PLACEHOLDER \u2014 not final artwork. See src/assets/chains/README.md. -->
|
|
122
122
|
<circle cx="50" cy="50" r="47" fill="#E5E7EB" stroke="#9CA3AF" stroke-width="2" stroke-dasharray="6 5"/>
|
|
123
123
|
<text x="50" y="58" font-family="ui-sans-serif, system-ui, sans-serif" font-size="30" font-weight="600" fill="#6B7280" text-anchor="middle">AV3</text>
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
<circle cx="50" cy="50" r="47" fill="#E5E7EB" stroke="#9CA3AF" stroke-width="2" stroke-dasharray="6 5"/>
|
|
138
138
|
<text x="50" y="58" font-family="ui-sans-serif, system-ui, sans-serif" font-size="30" font-weight="600" fill="#6B7280" text-anchor="middle">MB</text>
|
|
139
139
|
</svg>
|
|
140
|
-
`,K=[{id:"aave-v3",name:"AAVE V3",logo:g1,logoTheme:"normal"},{id:"compound-v2",name:"Compound V2",logo:m1,logoTheme:"normal"},{id:"morpho",name:"Morpho Blue",logo:x1,logoTheme:"normal"},{id:"dolomite",name:"Dolomite",logo:h1,logoTheme:"normal"}],
|
|
140
|
+
`,K=[{id:"aave-v3",name:"AAVE V3",logo:g1,logoTheme:"normal"},{id:"compound-v2",name:"Compound V2",logo:m1,logoTheme:"normal"},{id:"morpho",name:"Morpho Blue",logo:x1,logoTheme:"normal"},{id:"dolomite",name:"Dolomite",logo:h1,logoTheme:"normal"}],S=Object.fromEntries(K.map(e=>[e.id,e]));var j=!1;function X(e){let t=y1(e.container);k1();let n=e,s=I(void 0).setup,a={kind:"idle",message:""},c=!1,u=W("facto-express-root"),d=document.createElement("button");d.type="button",d.className="facto-express-button",d.addEventListener("click",()=>{r()});let p=document.createElement("span"),L=document.createElement("strong");d.append(p,L);let C=document.createElement("p");C.className="facto-express-inline-status",C.setAttribute("role","status"),C.setAttribute("aria-live","polite"),u.append(d,C),t.replaceChildren(u);let o=W("facto-express-overlay");o.setAttribute("aria-hidden","true"),o.innerHTML=L1(),document.body.append(o);let f=w(o,"[data-facto-close]"),g=w(o,"[data-facto-change]"),l=w(o,"[data-facto-pay]"),v=w(o,"[data-facto-result]");f.addEventListener("click",F),g.addEventListener("click",()=>{y()}),l.addEventListener("click",()=>{q()}),document.addEventListener("keydown",U),Z(),b();async function r(){if(!c){h({kind:"checking",message:"Checking saved Facto setup..."});try{let i=I(await n.getPaymentSetup());if(i.setup?.ready){s=i.setup,H();return}await y()}catch(i){h({kind:"error",message:M(i,"Facto checkout could not start.")})}}}async function y(){if(!c){h({kind:"setup",message:"Opening Facto secure checkout..."});try{let i=I(await n.startPaymentSetup());if(!i.setup?.ready){h({kind:"setup",message:i.state?.message??"Finish Facto setup"});return}s=i.setup,H()}catch(i){h({kind:"error",message:M(i,"Facto setup could not be completed.")})}}}async function q(){if(!(c||!s?.ready)){h({kind:"paying",message:"Submitting Facto payment..."}),l.disabled=!0;try{let i=await n.submitPayment(s);h({kind:"success",message:i?.message??"Payment authorized with Facto."})}catch(i){h({kind:"error",message:M(i,"Facto payment failed.")})}finally{l.disabled=!1}}}function H(){b(),o.dataset.open="true",o.setAttribute("aria-hidden","false"),h({kind:"ready",message:""}),l.focus()}function F(){o.dataset.open="false",o.setAttribute("aria-hidden","true"),d.focus()}function G(i){n={...n,...i},Z(),b()}function Q(){c=!0,document.removeEventListener("keydown",U),o.remove(),u.remove()}function U(i){i.key==="Escape"&&o.dataset.open==="true"&&F()}function h(i){a=i,n.onStatusChange?.(a),B()}function Z(){let i=n.buttonLabel??"Pay with",N=n.brandLabel??"Facto";p.textContent=i,L.textContent=N,d.setAttribute("aria-label",`${i} ${N}`)}function b(){let i=s;x(o,"[data-facto-brand]",n.brandLabel??"Facto"),x(o,"[data-facto-route]",i?.routeLabel??"Connect Facto to pay"),x(o,"[data-facto-address]",i?E1(i.walletAddress):""),x(o,"[data-facto-order-label]",n.order.label),x(o,"[data-facto-order-amount]",n.order.amountLabel),x(o,"[data-facto-shipping]",n.order.shippingLabel??"Included"),x(o,"[data-facto-total]",n.order.amountLabel),x(o,"[data-facto-pay-label]",`Pay ${n.order.amountLabel} with ${n.brandLabel??"Facto"}`),x(o,"[data-facto-env]",`Sandbox target: ${n.environmentLabel??"local"}`),B()}function B(){C.textContent=a.message,C.dataset.kind=a.kind,v.textContent=a.kind==="ready"?"":a.message,v.dataset.kind=a.kind}return{open:r,close:F,update:G,destroy:Q}}function L1(){return`
|
|
141
141
|
<section class="facto-express-sheet" role="dialog" aria-modal="true" aria-labelledby="facto-express-title">
|
|
142
142
|
<div class="facto-express-close-row">
|
|
143
143
|
<button type="button" class="facto-express-secondary" data-facto-close>Close</button>
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
<p class="facto-express-result" role="status" aria-live="polite" data-facto-result></p>
|
|
185
185
|
</div>
|
|
186
186
|
</section>
|
|
187
|
-
`}function y1(e){if(typeof e!="string")return e;let t=document.querySelector(e);if(t instanceof HTMLElement)return t;throw new Error(`Facto checkout container was not found: ${e}`)}function
|
|
187
|
+
`}function y1(e){if(typeof e!="string")return e;let t=document.querySelector(e);if(t instanceof HTMLElement)return t;throw new Error(`Facto checkout container was not found: ${e}`)}function I(e){return e?v1(e)?{setup:null,state:e}:"pipelineReady"in e?e.pipelineReady?e.factoServerWalletAddress?{setup:{walletAddress:e.factoServerWalletAddress,routeLabel:w1(e.pipeline),ready:!0},state:null}:{setup:null,state:null}:{setup:null,state:{buttonLabel:"Pay with Facto",setupStatus:"finish_facto_setup",message:"Finish Facto setup. We'll resume checkout here.",paymentReady:!1,mandateReady:!1,blockingReason:"payment_path_required"}}:e.ready?{setup:e,state:null}:{setup:null,state:null}:{setup:null,state:null}}function v1(e){return"setupStatus"in e&&"paymentReady"in e&&"mandateReady"in e}function w1(e){return e?[F1(e.chainId),b1(e.protocolId),e.assetSymbol].filter(Boolean).join(" \xB7 "):"Facto payment route"}function F1(e){return k[e]?.name??`Chain ${e}`}function b1(e){return S[e]?.name??e}function E1(e){return e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}function W(e){let t=document.createElement("div");return t.className=e,t}function w(e,t){let n=e.querySelector(t);if(!n)throw new Error(`Facto checkout element missing: ${t}`);return n}function x(e,t,n){w(e,t).textContent=n}function M(e,t){return e instanceof Error?e.message:t}function k1(){if(j)return;j=!0;let e=document.createElement("style");e.dataset.factoExpressCheckout="true",e.textContent=`
|
|
188
188
|
.facto-express-root { width: 100%; }
|
|
189
189
|
.facto-express-button {
|
|
190
190
|
width: min(352px, 100%);
|
|
@@ -375,5 +375,4 @@
|
|
|
375
375
|
.facto-express-body { padding: 16px; }
|
|
376
376
|
.facto-express-button { width: 100%; }
|
|
377
377
|
}
|
|
378
|
-
`,document.head.append(e)}var
|
|
379
|
-
//# sourceMappingURL=index.cjs.map
|
|
378
|
+
`,document.head.append(e)}var _="facto.externalLink.connected",T="facto.externalLink.ready",O="facto.externalLink.failed",P="facto.externalLink.closeRequested",m=class extends Error{code;retryable;status;details;constructor(t,n,s){super(n),this.name="FactoConnectError",this.code=t,this.retryable=s.retryable,this.status=s.status,this.details=s.details}},S1=460,I1=720;function Y(){let e=S1,t=I1,n=window.screenLeft??window.screenX??0,s=window.screenTop??window.screenY??0,a=window.outerWidth||e,c=window.outerHeight||t,u=Math.max(0,n+(a-e)/2),d=Math.max(0,s+(c-t)/2);return{width:e,height:t,left:Math.round(u),top:Math.round(d)}}function M1(){let{width:e,height:t,left:n,top:s}=Y();return["popup=yes",`width=${e}`,`height=${t}`,`innerWidth=${e}`,`innerHeight=${t}`,`left=${n}`,`top=${s}`,"resizable=yes","scrollbars=yes","toolbar=no","menubar=no","location=no","status=no"].join(",")}function _1(e){return`facto-connect-${e.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,36)||"session"}`}function T1(e){let{width:t,height:n,left:s,top:a}=Y();try{typeof e.resizeTo=="function"&&e.resizeTo(t,n),typeof e.moveTo=="function"&&e.moveTo(s,a),typeof e.focus=="function"&&e.focus()}catch{}}function O1(e,t){let n=new URL(e);return!n.searchParams.has("external_origin")&&!n.searchParams.has("origin")&&n.searchParams.set("external_origin",t),n.toString()}function P1(e){if(typeof e!="object"||e===null)return null;let t=e,n=t.type,s=t.state;if(typeof n!="string"||typeof s!="string"||n!==_&&n!==T&&n!==O&&n!==P)return null;let a={type:n,state:s};return typeof t.code=="string"&&(a.code=t.code),typeof t.reason=="string"&&(a.reason=t.reason),a}function R(e){let t=new URL(e.connectUrl).origin,n=e.origin??window.location.origin,s=null,a=!1,c=!1,u=!1,d=!1,p=null,L=g=>{if(a||g.origin!==t||s&&g.source&&g.source!==s)return;let l=P1(g.data);if(!(!l||l.state!==e.state))switch(l.type){case _:typeof l.code=="string"&&e.onConnected?.({code:l.code,state:l.state,kind:"connected"});break;case T:typeof l.code=="string"&&e.onReady?.({code:l.code,state:l.state,kind:"ready"});break;case O:e.onFailed?.({state:l.state,reason:l.reason});break;case P:o();break}};function C(){c&&(window.removeEventListener("message",L),c=!1),p&&(clearInterval(p),p=null)}function o(){a||(a=!0,C(),s&&!s.closed&&s.close(),s=null,u&&e.onClose?.())}function f(){if(a||c)return;let g=O1(e.connectUrl,n);if(s=window.open(g,e.windowName??_1(e.state),e.windowFeatures??M1()),!s||s.closed){e.onFailed?.({state:e.state,reason:"popup_blocked"});return}e.windowFeatures||T1(s),window.addEventListener("message",L),c=!0,u=!0,d=!1,p=setInterval(()=>{if(s){if(!s.closed){d=!0;return}d&&o()}},500)}return{open:f,close:o}}function R1(e){return{...e.appId===void 0?{}:{appId:e.appId},...e.userLinkRef===void 0?{}:{userLinkRef:e.userLinkRef},...e.grantStatus===void 0?{}:{grantStatus:e.grantStatus},pipelineReady:e.pipelineReady,...e.scopes===void 0?{}:{scopes:e.scopes}}}function A1(e){let t=null,n=()=>{t?.close(),t=null},s=c=>{e.telemetry?.track(c)};return{connect:c=>(s({type:"connect_started",appId:e.appId}),new Promise((u,d)=>{let p=!1,L=!1,C=null,o=null,f=r=>{p||(p=!0,C&&clearTimeout(C),n(),c.onError?.(r),d(r))},g=r=>{p||(p=!0,C&&clearTimeout(C),c.onError?.(r),d(r))},l=r=>{p||(p=!0,C&&clearTimeout(C),n(),u(r))},v=async r=>{if(!(p||L||!o)){L=!0,r.kind==="connected"&&c.onConnected?.(r),r.kind==="ready"&&c.onReady?.(r),s({type:"code_received",appId:e.appId,sessionId:o.sessionId,state:o.state,details:{kind:r.kind}}),s({type:"link_complete_started",appId:e.appId,sessionId:o.sessionId,state:o.state});try{let y=await c.completeLink({sessionId:o.sessionId,state:o.state,nonce:o.nonce,code:r.code});s({type:"link_complete_succeeded",appId:e.appId,sessionId:o.sessionId,state:o.state}),l(R1(y))}catch(y){s({type:"link_complete_failed",appId:e.appId,sessionId:o.sessionId,state:o.state}),g(new m("LINK_COMPLETE_FAILED","Facto link completion failed",{retryable:!0,details:y}))}}};(async()=>{try{s({type:"link_session_requested",appId:e.appId}),o=H1(await c.fetchLinkSession()),s({type:"link_session_received",appId:e.appId,sessionId:o.sessionId,state:o.state})}catch(r){f(new m("INVALID_LINK_SESSION","Unable to create Facto link session",{retryable:!0,details:r}));return}if(new Date(o.expiresAt).getTime()<=Date.now()){f(new m("LINK_SESSION_EXPIRED","Facto link session expired",{retryable:!0,details:{expiresAt:o.expiresAt}}));return}C=setTimeout(()=>{c.onExit?.({reason:"timeout",state:o?.state}),s({type:"connect_timeout",appId:e.appId,sessionId:o?.sessionId,state:o?.state}),f(new m("TIMEOUT","Facto Connect timed out",{retryable:!0}))},e.timeoutMs??3e5),t=R({connectUrl:o.connectUrl,state:o.state,windowName:e.popupName,windowFeatures:e.popupFeatures,onReady:r=>{v(r)},onConnected:r=>{v(r)},onFailed:r=>{if(r.reason==="popup_blocked"){s({type:"popup_blocked",appId:e.appId,state:r.state}),f(new m("POPUP_BLOCKED","Facto Connect popup was blocked",{retryable:!0}));return}f(new m("CONNECT_APP_FAILED","Facto Connect failed",{retryable:!0,details:r}))},onClose:()=>{p||(c.onExit?.({reason:"user_exit",state:o?.state}),s({type:"journey_exit",appId:e.appId,sessionId:o?.sessionId,state:o?.state}),f(new m("USER_EXIT","Facto Connect was closed before completion",{retryable:!0})))}}),t.open(),s({type:"popup_opened",appId:e.appId,sessionId:o.sessionId,state:o.state})})()})),close:n}}function H1(e){let t=e.connectUrl??e.iframeUrl;if(!t||typeof t!="string")throw new Error("Facto link session is missing connectUrl");if(!e.state||typeof e.state!="string")throw new Error("Facto link session is missing state");if(!e.expiresAt||Number.isNaN(new Date(e.expiresAt).getTime()))throw new Error("Facto link session is missing a valid expiresAt");return{...e,connectUrl:t}}function U1(e){return"connectUrl"in e&&"state"in e}function A(e){return U1(e)?R(e):A1(e)}var Z1={create:A},B1=A;
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExchangeLinkCodeResponse } from '
|
|
1
|
+
import { E as ExchangeLinkCodeResponse } from '../index.d-DE9GmLfU.cjs';
|
|
2
2
|
|
|
3
3
|
interface FactoExpressCheckoutOrder {
|
|
4
4
|
label: string;
|
|
@@ -61,17 +61,6 @@ interface FactoExpressCheckoutHandle {
|
|
|
61
61
|
}
|
|
62
62
|
declare function createFactoExpressCheckout(options: FactoExpressCheckoutOptions): FactoExpressCheckoutHandle;
|
|
63
63
|
|
|
64
|
-
/**
|
|
65
|
-
* @facto-to/connect
|
|
66
|
-
*
|
|
67
|
-
* Browser SDK for merchant pages to launch the Facto-owned Connect Journey.
|
|
68
|
-
* The public client hides popup and postMessage details behind
|
|
69
|
-
* connect({ fetchLinkSession, completeLink }).
|
|
70
|
-
*
|
|
71
|
-
* The low-level popup transport remains exported for the current internal demo
|
|
72
|
-
* and tests, but partner documentation should use the high-level client.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
64
|
declare const FACTO_LINK_CONNECTED = "facto.externalLink.connected";
|
|
76
65
|
declare const FACTO_LINK_READY = "facto.externalLink.ready";
|
|
77
66
|
declare const FACTO_LINK_FAILED = "facto.externalLink.failed";
|
|
@@ -150,31 +139,12 @@ interface FactoLinkCompleteInput {
|
|
|
150
139
|
nonce?: string;
|
|
151
140
|
code: string;
|
|
152
141
|
}
|
|
153
|
-
/**
|
|
154
|
-
* What the merchant's `completeLink` callback hands back: their own backend's
|
|
155
|
-
* relay of the engine `ExchangeLinkCodeResponse`.
|
|
156
|
-
*
|
|
157
|
-
* Pre-GA engine deployments and older merchant backends relay partial bodies,
|
|
158
|
-
* so every wire field except `pipelineReady` is tolerated as absent. Whatever
|
|
159
|
-
* arrives here, `connect()` only ever resolves `FactoConnectResult`.
|
|
160
|
-
*/
|
|
161
142
|
type FactoLinkCompleteResponse = Partial<ExchangeLinkCodeResponse> & Pick<ExchangeLinkCodeResponse, 'pipelineReady'> & {
|
|
162
|
-
/** Legacy marker kept for source compatibility; not part of the wire. */
|
|
163
143
|
linked?: true;
|
|
164
|
-
/** Route summary consumed by the legacy express-checkout callback. */
|
|
165
144
|
pipeline?: FactoPipelineSummary | null;
|
|
166
145
|
};
|
|
167
|
-
/**
|
|
168
|
-
* Merchant-safe result of `createFactoConnect(...).connect(...)`.
|
|
169
|
-
*
|
|
170
|
-
* Exactly the wire-derived subset a browser caller is allowed to see. The
|
|
171
|
-
* legacy identity fields `factoUserId`, `factoServerWalletAddress`, and
|
|
172
|
-
* `cardRef` are server-side only and are stripped before this resolves — do not
|
|
173
|
-
* widen this type to reintroduce them.
|
|
174
|
-
*/
|
|
175
146
|
type FactoConnectResult = Pick<ExchangeLinkCodeResponse, 'pipelineReady'> & Partial<Pick<ExchangeLinkCodeResponse, 'appId' | 'userLinkRef' | 'grantStatus' | 'scopes'>>;
|
|
176
147
|
interface FactoPipelineSummary {
|
|
177
|
-
selectedPipelineId: string;
|
|
178
148
|
chainId: number;
|
|
179
149
|
protocolId: string;
|
|
180
150
|
assetSymbol?: string;
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExchangeLinkCodeResponse } from '
|
|
1
|
+
import { E as ExchangeLinkCodeResponse } from '../index.d-DE9GmLfU.js';
|
|
2
2
|
|
|
3
3
|
interface FactoExpressCheckoutOrder {
|
|
4
4
|
label: string;
|
|
@@ -61,17 +61,6 @@ interface FactoExpressCheckoutHandle {
|
|
|
61
61
|
}
|
|
62
62
|
declare function createFactoExpressCheckout(options: FactoExpressCheckoutOptions): FactoExpressCheckoutHandle;
|
|
63
63
|
|
|
64
|
-
/**
|
|
65
|
-
* @facto-to/connect
|
|
66
|
-
*
|
|
67
|
-
* Browser SDK for merchant pages to launch the Facto-owned Connect Journey.
|
|
68
|
-
* The public client hides popup and postMessage details behind
|
|
69
|
-
* connect({ fetchLinkSession, completeLink }).
|
|
70
|
-
*
|
|
71
|
-
* The low-level popup transport remains exported for the current internal demo
|
|
72
|
-
* and tests, but partner documentation should use the high-level client.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
64
|
declare const FACTO_LINK_CONNECTED = "facto.externalLink.connected";
|
|
76
65
|
declare const FACTO_LINK_READY = "facto.externalLink.ready";
|
|
77
66
|
declare const FACTO_LINK_FAILED = "facto.externalLink.failed";
|
|
@@ -150,31 +139,12 @@ interface FactoLinkCompleteInput {
|
|
|
150
139
|
nonce?: string;
|
|
151
140
|
code: string;
|
|
152
141
|
}
|
|
153
|
-
/**
|
|
154
|
-
* What the merchant's `completeLink` callback hands back: their own backend's
|
|
155
|
-
* relay of the engine `ExchangeLinkCodeResponse`.
|
|
156
|
-
*
|
|
157
|
-
* Pre-GA engine deployments and older merchant backends relay partial bodies,
|
|
158
|
-
* so every wire field except `pipelineReady` is tolerated as absent. Whatever
|
|
159
|
-
* arrives here, `connect()` only ever resolves `FactoConnectResult`.
|
|
160
|
-
*/
|
|
161
142
|
type FactoLinkCompleteResponse = Partial<ExchangeLinkCodeResponse> & Pick<ExchangeLinkCodeResponse, 'pipelineReady'> & {
|
|
162
|
-
/** Legacy marker kept for source compatibility; not part of the wire. */
|
|
163
143
|
linked?: true;
|
|
164
|
-
/** Route summary consumed by the legacy express-checkout callback. */
|
|
165
144
|
pipeline?: FactoPipelineSummary | null;
|
|
166
145
|
};
|
|
167
|
-
/**
|
|
168
|
-
* Merchant-safe result of `createFactoConnect(...).connect(...)`.
|
|
169
|
-
*
|
|
170
|
-
* Exactly the wire-derived subset a browser caller is allowed to see. The
|
|
171
|
-
* legacy identity fields `factoUserId`, `factoServerWalletAddress`, and
|
|
172
|
-
* `cardRef` are server-side only and are stripped before this resolves — do not
|
|
173
|
-
* widen this type to reintroduce them.
|
|
174
|
-
*/
|
|
175
146
|
type FactoConnectResult = Pick<ExchangeLinkCodeResponse, 'pipelineReady'> & Partial<Pick<ExchangeLinkCodeResponse, 'appId' | 'userLinkRef' | 'grantStatus' | 'scopes'>>;
|
|
176
147
|
interface FactoPipelineSummary {
|
|
177
|
-
selectedPipelineId: string;
|
|
178
148
|
chainId: number;
|
|
179
149
|
protocolId: string;
|
|
180
150
|
assetSymbol?: string;
|
package/dist/browser/index.js
CHANGED
|
@@ -117,7 +117,7 @@ var R=`<svg xmlns:xodm="http://www.corel.com/coreldraw/odm/2003" xmlns="http://w
|
|
|
117
117
|
transform="translate(70 66)"
|
|
118
118
|
/>
|
|
119
119
|
</svg>
|
|
120
|
-
`,r1='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill-opacity=".5" d="M17.82 14.342v4.672h1.275c.172 0 .312-.14.312-.311v-4.05a.31.31 0 0 0-.312-.312zm0-9.356v4.673h1.275c.172 0 .312-.14.312-.312v-4.05a.31.31 0 0 0-.312-.311z"/><path fill-opacity=".3" d="M20.209 4.986v4.673h.477c.172 0 .311-.14.311-.312v-4.05a.31.31 0 0 0-.311-.311zm.002 9.356v4.672h.477c.172 0 .312-.14.312-.311v-4.05a.31.31 0 0 0-.312-.312z"/><path d="M12.026 9.67h-4.03a.31.31 0 0 0-.31.307v4.002c0 .17.138.308.31.308h4.03a.31.31 0 0 0 .31-.308V9.977a.31.31 0 0 0-.31-.308M7.361 4.986h-4.05A.31.31 0 0 0 3 5.297v4.05c0 .172.14.312.312.312h4.05c.171 0 .31-.14.31-.312v-4.05a.31.31 0 0 0-.31-.311m9.343 0h-4.05a.31.31 0 0 0-.311.311v4.05c0 .172.14.312.311.312h4.05c.172 0 .312-.14.312-.312v-4.05a.31.31 0 0 0-.312-.311M7.361 14.33h-4.05a.31.31 0 0 0-.311.313v4.05c0 .171.14.31.312.31h4.05a.31.31 0 0 0 .31-.31v-4.05a.31.31 0 0 0-.31-.312m9.343-.001h-4.05a.31.31 0 0 0-.311.313v4.05c0 .171.14.31.311.31h4.05a.31.31 0 0 0 .312-.31v-4.05a.31.31 0 0 0-.312-.312"/></svg>',U=[{chainId:1,name:"Ethereum",gasSymbol:"ETH",explorerUrl:"https://etherscan.io",logo:Q,logoTheme:"normal",testnet:!1},{chainId:56,name:"BNB",gasSymbol:"BNB",explorerUrl:"https://bscscan.com",logo:G,logoTheme:"normal",testnet:!1},{chainId:137,name:"Polygon",gasSymbol:"POL",explorerUrl:"https://polygonscan.com",logo:o1,logoTheme:"normal",testnet:!1},{chainId:143,name:"Monad",gasSymbol:"MON",explorerUrl:"https://monadscan.com",logo:e1,logoTheme:"normal",testnet:!1},{chainId:196,name:"X Layer",gasSymbol:"OKB",explorerUrl:"https://www.oklink.com/x-layer/evm",logo:r1,logoTheme:"invertOnDark",testnet:!1},{chainId:988,name:"Stable Mainnet",gasSymbol:"USDT0",explorerUrl:"https://stablescan.xyz",logo:a1,logoTheme:"invertOnLight",testnet:!1},{chainId:1329,name:"Sei",gasSymbol:"SEI",explorerUrl:"https://seiscan.io",logo:s1,logoTheme:"normal",testnet:!1},{chainId:4217,name:"Tempo",gasSymbol:"TMPO",explorerUrl:"https://explore.tempo.xyz",logo:H,logoTheme:"normal",testnet:!1},{chainId:4326,name:"MegaETH",gasSymbol:"ETH",explorerUrl:"https://mega.etherscan.io",logo:J,logoTheme:"normal",testnet:!1},{chainId:8453,name:"Base",gasSymbol:"ETH",explorerUrl:"https://basescan.org",logo:A,logoTheme:"normal",testnet:!1},{chainId:9745,name:"Plasma",gasSymbol:"XPL",explorerUrl:"https://plasmascan.to",logo:t1,logoTheme:"normal",testnet:!1},{chainId:42161,name:"Arbitrum",gasSymbol:"ETH",explorerUrl:"https://arbiscan.io",logo:R,logoTheme:"normal",testnet:!1},{chainId:42431,name:"Tempo Moderato",gasSymbol:"SEI",explorerUrl:"https://explore.tempo.xyz",logo:H,logoTheme:"normal",testnet:!0},{chainId:46630,name:"Robinhood Testnet",gasSymbol:"ETH",explorerUrl:"https://explorer.testnet.chain.robinhood.com",logo:n1,logoTheme:"normal",testnet:!0},{chainId:84532,name:"Base Sepolia",gasSymbol:"ETH",explorerUrl:"https://sepolia.basescan.org",logo:A,logoTheme:"normal",testnet:!0},{chainId:421614,name:"Arbitrum Sepolia",gasSymbol:"ETH",explorerUrl:"https://sepolia.arbiscan.io",logo:R,logoTheme:"normal",testnet:!0}],
|
|
120
|
+
`,r1='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill-opacity=".5" d="M17.82 14.342v4.672h1.275c.172 0 .312-.14.312-.311v-4.05a.31.31 0 0 0-.312-.312zm0-9.356v4.673h1.275c.172 0 .312-.14.312-.312v-4.05a.31.31 0 0 0-.312-.311z"/><path fill-opacity=".3" d="M20.209 4.986v4.673h.477c.172 0 .311-.14.311-.312v-4.05a.31.31 0 0 0-.311-.311zm.002 9.356v4.672h.477c.172 0 .312-.14.312-.311v-4.05a.31.31 0 0 0-.312-.312z"/><path d="M12.026 9.67h-4.03a.31.31 0 0 0-.31.307v4.002c0 .17.138.308.31.308h4.03a.31.31 0 0 0 .31-.308V9.977a.31.31 0 0 0-.31-.308M7.361 4.986h-4.05A.31.31 0 0 0 3 5.297v4.05c0 .172.14.312.312.312h4.05c.171 0 .31-.14.31-.312v-4.05a.31.31 0 0 0-.31-.311m9.343 0h-4.05a.31.31 0 0 0-.311.311v4.05c0 .172.14.312.311.312h4.05c.172 0 .312-.14.312-.312v-4.05a.31.31 0 0 0-.312-.311M7.361 14.33h-4.05a.31.31 0 0 0-.311.313v4.05c0 .171.14.31.312.31h4.05a.31.31 0 0 0 .31-.31v-4.05a.31.31 0 0 0-.31-.312m9.343-.001h-4.05a.31.31 0 0 0-.311.313v4.05c0 .171.14.31.311.31h4.05a.31.31 0 0 0 .312-.31v-4.05a.31.31 0 0 0-.312-.312"/></svg>',U=[{chainId:1,name:"Ethereum",gasSymbol:"ETH",explorerUrl:"https://etherscan.io",logo:Q,logoTheme:"normal",testnet:!1},{chainId:56,name:"BNB",gasSymbol:"BNB",explorerUrl:"https://bscscan.com",logo:G,logoTheme:"normal",testnet:!1},{chainId:137,name:"Polygon",gasSymbol:"POL",explorerUrl:"https://polygonscan.com",logo:o1,logoTheme:"normal",testnet:!1},{chainId:143,name:"Monad",gasSymbol:"MON",explorerUrl:"https://monadscan.com",logo:e1,logoTheme:"normal",testnet:!1},{chainId:196,name:"X Layer",gasSymbol:"OKB",explorerUrl:"https://www.oklink.com/x-layer/evm",logo:r1,logoTheme:"invertOnDark",testnet:!1},{chainId:988,name:"Stable Mainnet",gasSymbol:"USDT0",explorerUrl:"https://stablescan.xyz",logo:a1,logoTheme:"invertOnLight",testnet:!1},{chainId:1329,name:"Sei",gasSymbol:"SEI",explorerUrl:"https://seiscan.io",logo:s1,logoTheme:"normal",testnet:!1},{chainId:4217,name:"Tempo",gasSymbol:"TMPO",explorerUrl:"https://explore.tempo.xyz",logo:H,logoTheme:"normal",testnet:!1},{chainId:4326,name:"MegaETH",gasSymbol:"ETH",explorerUrl:"https://mega.etherscan.io",logo:J,logoTheme:"normal",testnet:!1},{chainId:8453,name:"Base",gasSymbol:"ETH",explorerUrl:"https://basescan.org",logo:A,logoTheme:"normal",testnet:!1},{chainId:9745,name:"Plasma",gasSymbol:"XPL",explorerUrl:"https://plasmascan.to",logo:t1,logoTheme:"normal",testnet:!1},{chainId:42161,name:"Arbitrum",gasSymbol:"ETH",explorerUrl:"https://arbiscan.io",logo:R,logoTheme:"normal",testnet:!1},{chainId:42431,name:"Tempo Moderato",gasSymbol:"SEI",explorerUrl:"https://explore.tempo.xyz",logo:H,logoTheme:"normal",testnet:!0},{chainId:46630,name:"Robinhood Testnet",gasSymbol:"ETH",explorerUrl:"https://explorer.testnet.chain.robinhood.com",logo:n1,logoTheme:"normal",testnet:!0},{chainId:84532,name:"Base Sepolia",gasSymbol:"ETH",explorerUrl:"https://sepolia.basescan.org",logo:A,logoTheme:"normal",testnet:!0},{chainId:421614,name:"Arbitrum Sepolia",gasSymbol:"ETH",explorerUrl:"https://sepolia.arbiscan.io",logo:R,logoTheme:"normal",testnet:!0}],E=Object.fromEntries(U.map(e=>[e.chainId,e])),i1=`<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
121
121
|
<!-- PLACEHOLDER \u2014 not final artwork. See src/assets/chains/README.md. -->
|
|
122
122
|
<circle cx="50" cy="50" r="47" fill="#E5E7EB" stroke="#9CA3AF" stroke-width="2" stroke-dasharray="6 5"/>
|
|
123
123
|
<text x="50" y="58" font-family="ui-sans-serif, system-ui, sans-serif" font-size="30" font-weight="600" fill="#6B7280" text-anchor="middle">AV3</text>
|
|
@@ -137,7 +137,7 @@ var R=`<svg xmlns:xodm="http://www.corel.com/coreldraw/odm/2003" xmlns="http://w
|
|
|
137
137
|
<circle cx="50" cy="50" r="47" fill="#E5E7EB" stroke="#9CA3AF" stroke-width="2" stroke-dasharray="6 5"/>
|
|
138
138
|
<text x="50" y="58" font-family="ui-sans-serif, system-ui, sans-serif" font-size="30" font-weight="600" fill="#6B7280" text-anchor="middle">MB</text>
|
|
139
139
|
</svg>
|
|
140
|
-
`,Z=[{id:"aave-v3",name:"AAVE V3",logo:i1,logoTheme:"normal"},{id:"compound-v2",name:"Compound V2",logo:c1,logoTheme:"normal"},{id:"morpho",name:"Morpho Blue",logo:d1,logoTheme:"normal"},{id:"dolomite",name:"Dolomite",logo:l1,logoTheme:"normal"}],
|
|
140
|
+
`,Z=[{id:"aave-v3",name:"AAVE V3",logo:i1,logoTheme:"normal"},{id:"compound-v2",name:"Compound V2",logo:c1,logoTheme:"normal"},{id:"morpho",name:"Morpho Blue",logo:d1,logoTheme:"normal"},{id:"dolomite",name:"Dolomite",logo:l1,logoTheme:"normal"}],k=Object.fromEntries(Z.map(e=>[e.id,e]));var B=!1;function p1(e){let n=u1(e.container);L1();let o=e,s=S(void 0).setup,c={kind:"idle",message:""},i=!1,u=N("facto-express-root"),d=document.createElement("button");d.type="button",d.className="facto-express-button",d.addEventListener("click",()=>{a()});let p=document.createElement("span"),L=document.createElement("strong");d.append(p,L);let C=document.createElement("p");C.className="facto-express-inline-status",C.setAttribute("role","status"),C.setAttribute("aria-live","polite"),u.append(d,C),n.replaceChildren(u);let t=N("facto-express-overlay");t.setAttribute("aria-hidden","true"),t.innerHTML=C1(),document.body.append(t);let f=w(t,"[data-facto-close]"),g=w(t,"[data-facto-change]"),l=w(t,"[data-facto-pay]"),v=w(t,"[data-facto-result]");f.addEventListener("click",F),g.addEventListener("click",()=>{y()}),l.addEventListener("click",()=>{X()}),document.addEventListener("keydown",_),T(),b();async function a(){if(!i){m({kind:"checking",message:"Checking saved Facto setup..."});try{let r=S(await o.getPaymentSetup());if(r.setup?.ready){s=r.setup,M();return}await y()}catch(r){m({kind:"error",message:I(r,"Facto checkout could not start.")})}}}async function y(){if(!i){m({kind:"setup",message:"Opening Facto secure checkout..."});try{let r=S(await o.startPaymentSetup());if(!r.setup?.ready){m({kind:"setup",message:r.state?.message??"Finish Facto setup"});return}s=r.setup,M()}catch(r){m({kind:"error",message:I(r,"Facto setup could not be completed.")})}}}async function X(){if(!(i||!s?.ready)){m({kind:"paying",message:"Submitting Facto payment..."}),l.disabled=!0;try{let r=await o.submitPayment(s);m({kind:"success",message:r?.message??"Payment authorized with Facto."})}catch(r){m({kind:"error",message:I(r,"Facto payment failed.")})}finally{l.disabled=!1}}}function M(){b(),t.dataset.open="true",t.setAttribute("aria-hidden","false"),m({kind:"ready",message:""}),l.focus()}function F(){t.dataset.open="false",t.setAttribute("aria-hidden","true"),d.focus()}function Y(r){o={...o,...r},T(),b()}function q(){i=!0,document.removeEventListener("keydown",_),t.remove(),u.remove()}function _(r){r.key==="Escape"&&t.dataset.open==="true"&&F()}function m(r){c=r,o.onStatusChange?.(c),O()}function T(){let r=o.buttonLabel??"Pay with",P=o.brandLabel??"Facto";p.textContent=r,L.textContent=P,d.setAttribute("aria-label",`${r} ${P}`)}function b(){let r=s;h(t,"[data-facto-brand]",o.brandLabel??"Facto"),h(t,"[data-facto-route]",r?.routeLabel??"Connect Facto to pay"),h(t,"[data-facto-address]",r?x1(r.walletAddress):""),h(t,"[data-facto-order-label]",o.order.label),h(t,"[data-facto-order-amount]",o.order.amountLabel),h(t,"[data-facto-shipping]",o.order.shippingLabel??"Included"),h(t,"[data-facto-total]",o.order.amountLabel),h(t,"[data-facto-pay-label]",`Pay ${o.order.amountLabel} with ${o.brandLabel??"Facto"}`),h(t,"[data-facto-env]",`Sandbox target: ${o.environmentLabel??"local"}`),O()}function O(){C.textContent=c.message,C.dataset.kind=c.kind,v.textContent=c.kind==="ready"?"":c.message,v.dataset.kind=c.kind}return{open:a,close:F,update:Y,destroy:q}}function C1(){return`
|
|
141
141
|
<section class="facto-express-sheet" role="dialog" aria-modal="true" aria-labelledby="facto-express-title">
|
|
142
142
|
<div class="facto-express-close-row">
|
|
143
143
|
<button type="button" class="facto-express-secondary" data-facto-close>Close</button>
|
|
@@ -184,7 +184,7 @@ var R=`<svg xmlns:xodm="http://www.corel.com/coreldraw/odm/2003" xmlns="http://w
|
|
|
184
184
|
<p class="facto-express-result" role="status" aria-live="polite" data-facto-result></p>
|
|
185
185
|
</div>
|
|
186
186
|
</section>
|
|
187
|
-
`}function u1(e){if(typeof e!="string")return e;let
|
|
187
|
+
`}function u1(e){if(typeof e!="string")return e;let n=document.querySelector(e);if(n instanceof HTMLElement)return n;throw new Error(`Facto checkout container was not found: ${e}`)}function S(e){return e?f1(e)?{setup:null,state:e}:"pipelineReady"in e?e.pipelineReady?e.factoServerWalletAddress?{setup:{walletAddress:e.factoServerWalletAddress,routeLabel:g1(e.pipeline),ready:!0},state:null}:{setup:null,state:null}:{setup:null,state:{buttonLabel:"Pay with Facto",setupStatus:"finish_facto_setup",message:"Finish Facto setup. We'll resume checkout here.",paymentReady:!1,mandateReady:!1,blockingReason:"payment_path_required"}}:e.ready?{setup:e,state:null}:{setup:null,state:null}:{setup:null,state:null}}function f1(e){return"setupStatus"in e&&"paymentReady"in e&&"mandateReady"in e}function g1(e){return e?[m1(e.chainId),h1(e.protocolId),e.assetSymbol].filter(Boolean).join(" \xB7 "):"Facto payment route"}function m1(e){return E[e]?.name??`Chain ${e}`}function h1(e){return k[e]?.name??e}function x1(e){return e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}function N(e){let n=document.createElement("div");return n.className=e,n}function w(e,n){let o=e.querySelector(n);if(!o)throw new Error(`Facto checkout element missing: ${n}`);return o}function h(e,n,o){w(e,n).textContent=o}function I(e,n){return e instanceof Error?e.message:n}function L1(){if(B)return;B=!0;let e=document.createElement("style");e.dataset.factoExpressCheckout="true",e.textContent=`
|
|
188
188
|
.facto-express-root { width: 100%; }
|
|
189
189
|
.facto-express-button {
|
|
190
190
|
width: min(352px, 100%);
|
|
@@ -375,5 +375,4 @@ var R=`<svg xmlns:xodm="http://www.corel.com/coreldraw/odm/2003" xmlns="http://w
|
|
|
375
375
|
.facto-express-body { padding: 16px; }
|
|
376
376
|
.facto-express-button { width: 100%; }
|
|
377
377
|
}
|
|
378
|
-
`,document.head.append(e)}var D="facto.externalLink.connected",z="facto.externalLink.ready",V="facto.externalLink.failed",$="facto.externalLink.closeRequested",x=class extends Error{code;retryable;status;details;constructor(o,
|
|
379
|
-
//# sourceMappingURL=index.js.map
|
|
378
|
+
`,document.head.append(e)}var D="facto.externalLink.connected",z="facto.externalLink.ready",V="facto.externalLink.failed",$="facto.externalLink.closeRequested",x=class extends Error{code;retryable;status;details;constructor(n,o,s){super(o),this.name="FactoConnectError",this.code=n,this.retryable=s.retryable,this.status=s.status,this.details=s.details}},y1=460,v1=720;function K(){let e=y1,n=v1,o=window.screenLeft??window.screenX??0,s=window.screenTop??window.screenY??0,c=window.outerWidth||e,i=window.outerHeight||n,u=Math.max(0,o+(c-e)/2),d=Math.max(0,s+(i-n)/2);return{width:e,height:n,left:Math.round(u),top:Math.round(d)}}function w1(){let{width:e,height:n,left:o,top:s}=K();return["popup=yes",`width=${e}`,`height=${n}`,`innerWidth=${e}`,`innerHeight=${n}`,`left=${o}`,`top=${s}`,"resizable=yes","scrollbars=yes","toolbar=no","menubar=no","location=no","status=no"].join(",")}function F1(e){return`facto-connect-${e.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,36)||"session"}`}function b1(e){let{width:n,height:o,left:s,top:c}=K();try{typeof e.resizeTo=="function"&&e.resizeTo(n,o),typeof e.moveTo=="function"&&e.moveTo(s,c),typeof e.focus=="function"&&e.focus()}catch{}}function E1(e,n){let o=new URL(e);return!o.searchParams.has("external_origin")&&!o.searchParams.has("origin")&&o.searchParams.set("external_origin",n),o.toString()}function k1(e){if(typeof e!="object"||e===null)return null;let n=e,o=n.type,s=n.state;if(typeof o!="string"||typeof s!="string"||o!==D&&o!==z&&o!==V&&o!==$)return null;let c={type:o,state:s};return typeof n.code=="string"&&(c.code=n.code),typeof n.reason=="string"&&(c.reason=n.reason),c}function j(e){let n=new URL(e.connectUrl).origin,o=e.origin??window.location.origin,s=null,c=!1,i=!1,u=!1,d=!1,p=null,L=g=>{if(c||g.origin!==n||s&&g.source&&g.source!==s)return;let l=k1(g.data);if(!(!l||l.state!==e.state))switch(l.type){case D:typeof l.code=="string"&&e.onConnected?.({code:l.code,state:l.state,kind:"connected"});break;case z:typeof l.code=="string"&&e.onReady?.({code:l.code,state:l.state,kind:"ready"});break;case V:e.onFailed?.({state:l.state,reason:l.reason});break;case $:t();break}};function C(){i&&(window.removeEventListener("message",L),i=!1),p&&(clearInterval(p),p=null)}function t(){c||(c=!0,C(),s&&!s.closed&&s.close(),s=null,u&&e.onClose?.())}function f(){if(c||i)return;let g=E1(e.connectUrl,o);if(s=window.open(g,e.windowName??F1(e.state),e.windowFeatures??w1()),!s||s.closed){e.onFailed?.({state:e.state,reason:"popup_blocked"});return}e.windowFeatures||b1(s),window.addEventListener("message",L),i=!0,u=!0,d=!1,p=setInterval(()=>{if(s){if(!s.closed){d=!0;return}d&&t()}},500)}return{open:f,close:t}}function S1(e){return{...e.appId===void 0?{}:{appId:e.appId},...e.userLinkRef===void 0?{}:{userLinkRef:e.userLinkRef},...e.grantStatus===void 0?{}:{grantStatus:e.grantStatus},pipelineReady:e.pipelineReady,...e.scopes===void 0?{}:{scopes:e.scopes}}}function I1(e){let n=null,o=()=>{n?.close(),n=null},s=i=>{e.telemetry?.track(i)};return{connect:i=>(s({type:"connect_started",appId:e.appId}),new Promise((u,d)=>{let p=!1,L=!1,C=null,t=null,f=a=>{p||(p=!0,C&&clearTimeout(C),o(),i.onError?.(a),d(a))},g=a=>{p||(p=!0,C&&clearTimeout(C),i.onError?.(a),d(a))},l=a=>{p||(p=!0,C&&clearTimeout(C),o(),u(a))},v=async a=>{if(!(p||L||!t)){L=!0,a.kind==="connected"&&i.onConnected?.(a),a.kind==="ready"&&i.onReady?.(a),s({type:"code_received",appId:e.appId,sessionId:t.sessionId,state:t.state,details:{kind:a.kind}}),s({type:"link_complete_started",appId:e.appId,sessionId:t.sessionId,state:t.state});try{let y=await i.completeLink({sessionId:t.sessionId,state:t.state,nonce:t.nonce,code:a.code});s({type:"link_complete_succeeded",appId:e.appId,sessionId:t.sessionId,state:t.state}),l(S1(y))}catch(y){s({type:"link_complete_failed",appId:e.appId,sessionId:t.sessionId,state:t.state}),g(new x("LINK_COMPLETE_FAILED","Facto link completion failed",{retryable:!0,details:y}))}}};(async()=>{try{s({type:"link_session_requested",appId:e.appId}),t=M1(await i.fetchLinkSession()),s({type:"link_session_received",appId:e.appId,sessionId:t.sessionId,state:t.state})}catch(a){f(new x("INVALID_LINK_SESSION","Unable to create Facto link session",{retryable:!0,details:a}));return}if(new Date(t.expiresAt).getTime()<=Date.now()){f(new x("LINK_SESSION_EXPIRED","Facto link session expired",{retryable:!0,details:{expiresAt:t.expiresAt}}));return}C=setTimeout(()=>{i.onExit?.({reason:"timeout",state:t?.state}),s({type:"connect_timeout",appId:e.appId,sessionId:t?.sessionId,state:t?.state}),f(new x("TIMEOUT","Facto Connect timed out",{retryable:!0}))},e.timeoutMs??3e5),n=j({connectUrl:t.connectUrl,state:t.state,windowName:e.popupName,windowFeatures:e.popupFeatures,onReady:a=>{v(a)},onConnected:a=>{v(a)},onFailed:a=>{if(a.reason==="popup_blocked"){s({type:"popup_blocked",appId:e.appId,state:a.state}),f(new x("POPUP_BLOCKED","Facto Connect popup was blocked",{retryable:!0}));return}f(new x("CONNECT_APP_FAILED","Facto Connect failed",{retryable:!0,details:a}))},onClose:()=>{p||(i.onExit?.({reason:"user_exit",state:t?.state}),s({type:"journey_exit",appId:e.appId,sessionId:t?.sessionId,state:t?.state}),f(new x("USER_EXIT","Facto Connect was closed before completion",{retryable:!0})))}}),n.open(),s({type:"popup_opened",appId:e.appId,sessionId:t.sessionId,state:t.state})})()})),close:o}}function M1(e){let n=e.connectUrl??e.iframeUrl;if(!n||typeof n!="string")throw new Error("Facto link session is missing connectUrl");if(!e.state||typeof e.state!="string")throw new Error("Facto link session is missing state");if(!e.expiresAt||Number.isNaN(new Date(e.expiresAt).getTime()))throw new Error("Facto link session is missing a valid expiresAt");return{...e,connectUrl:n}}function _1(e){return"connectUrl"in e&&"state"in e}function W(e){return _1(e)?j(e):I1(e)}var H1={create:W},U1=W;export{$ as FACTO_LINK_CLOSE_REQUESTED,D as FACTO_LINK_CONNECTED,V as FACTO_LINK_FAILED,z as FACTO_LINK_READY,H1 as FactoConnect,x as FactoConnectError,W as createFactoConnect,j as createFactoConnectTransport,p1 as createFactoExpressCheckout,U1 as default};
|