@asseteragmbh/wallet-connector 0.2.3 → 0.2.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 +105 -4
- package/dist/{chunk-RAR3QQGK.js → chunk-2OK3FPAS.js} +91 -13
- package/dist/chunk-2OK3FPAS.js.map +1 -0
- package/dist/{chunk-CPSTYPVT.js → chunk-4YVGTYYE.js} +3 -3
- package/dist/{chunk-CPSTYPVT.js.map → chunk-4YVGTYYE.js.map} +1 -1
- package/dist/{chunk-ZEOGKINA.js → chunk-Z7QSH4N2.js} +7 -3
- package/dist/chunk-Z7QSH4N2.js.map +1 -0
- package/dist/index.cjs +171 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -6
- package/dist/index.d.ts +64 -6
- package/dist/index.js +80 -18
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs +6 -0
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +40 -3
- package/dist/protocol.d.ts +40 -3
- package/dist/protocol.js +1 -1
- package/dist/{provider-CfVvuYbQ.d.cts → provider-BjOez2Q4.d.cts} +33 -5
- package/dist/{provider-BNMvsJst.d.ts → provider-CsnGDnXj.d.ts} +33 -5
- package/dist/rainbowkit.cjs +88 -10
- package/dist/rainbowkit.cjs.map +1 -1
- package/dist/rainbowkit.js +3 -3
- package/dist/wagmi.cjs +88 -10
- package/dist/wagmi.cjs.map +1 -1
- package/dist/wagmi.d.cts +1 -1
- package/dist/wagmi.d.ts +1 -1
- package/dist/wagmi.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-RAR3QQGK.js.map +0 -1
- package/dist/chunk-ZEOGKINA.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SignInHint, WalletAccountName, WalletSecurityStatus } from './protocol.js';
|
|
2
|
-
export { AccountsMessage, CONNECT_PATH, DisconnectMessage, EventMessage, MANAGE_PATH, MESSAGE_PREFIX, ONBOARD_PATH, OnboardCancelledMessage, OnboardedMessage, PROTOCOL_VERSION, PartnerToWalletMessage, ReadyMessage, RequestMessage, ResponseMessage, RpcError, RpcErrorCode, SIGN_IN_HINTS, SUPPORTED_METHODS, SecurityMessage, SupportedMethod, WalletProtection, WalletToPartnerMessage, connectUrl, isAccountsMessage, isCaip2EvmChain, isDisconnectMessage, isEventMessage, isOnboardCancelledMessage, isOnboardedMessage, isReadyMessage, isRequestMessage, isResponseMessage, isSecurityMessage, isSignInHint, isSupportedMethod, manageUrl, onboardUrl } from './protocol.js';
|
|
3
|
-
export { A as AsseteraWalletProvider, a as AsseteraWalletProviderOptions, P as
|
|
2
|
+
export { AccountsMessage, CONNECT_PATH, DisconnectMessage, EventMessage, HOLD_MAX_MS, HoldMessage, MANAGE_PATH, MESSAGE_PREFIX, ONBOARD_PATH, OnboardCancelledMessage, OnboardedMessage, PROTOCOL_VERSION, PartnerToWalletMessage, ReadyMessage, RequestMessage, ResponseMessage, RpcError, RpcErrorCode, SIGN_IN_HINTS, SUPPORTED_METHODS, SecurityMessage, SupportedMethod, WalletProtection, WalletToPartnerMessage, connectUrl, isAccountsMessage, isCaip2EvmChain, isDisconnectMessage, isEventMessage, isHoldMessage, isOnboardCancelledMessage, isOnboardedMessage, isReadyMessage, isRequestMessage, isResponseMessage, isSecurityMessage, isSignInHint, isSupportedMethod, manageUrl, onboardUrl } from './protocol.js';
|
|
3
|
+
export { A as AsseteraWalletProvider, a as AsseteraWalletProviderOptions, P as PopupHold, b as PreparedSigning, c as ProviderEvent, d as ProviderListener, e as ProviderRpcError, R as RequestArguments, f as createAsseteraWalletProvider } from './provider-CsnGDnXj.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Onboarding opener for the Assetera Wallet: the partner side of the `/onboard` wizard (AO-1274).
|
|
@@ -8,7 +8,9 @@ export { A as AsseteraWalletProvider, a as AsseteraWalletProviderOptions, P as P
|
|
|
8
8
|
* A tied-agent bank site shows a "Create an Assetera wallet" button. On the click, this module opens the wallet
|
|
9
9
|
* pop-up in onboarding mode synchronously (so the browser treats it as part of the click) and waits for the
|
|
10
10
|
* wizard to post the new wallet address back. While the pop-up is open the partner page shows a dimming
|
|
11
|
-
* overlay; the overlay is plain DOM (no React, no CSS files) so any partner can drop this in.
|
|
11
|
+
* overlay; the overlay is plain DOM (no React, no CSS files) so any partner can drop this in. A host can give
|
|
12
|
+
* the overlay its colours and radii (`OverlayTheme`), render its own dialog (`overlay: false` plus
|
|
13
|
+
* `onControls`), or do both.
|
|
12
14
|
*
|
|
13
15
|
* The wallet's `/onboard` page is the pop-up side and speaks the same protocol in `./protocol`, but it uses the
|
|
14
16
|
* message types and the `ONBOARD_PATH` from there, so the two sides cannot drift apart.
|
|
@@ -54,6 +56,52 @@ interface OverlayLabels {
|
|
|
54
56
|
cancel?: string;
|
|
55
57
|
blocked?: string;
|
|
56
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Colours, radii and font of the dimming overlay, all optional. A key left out keeps the value of the base
|
|
61
|
+
* palette picked by {@link OverlayTheme.scheme} (`"light"` unless the host asks for `"dark"`).
|
|
62
|
+
*
|
|
63
|
+
* Every value is applied to its own CSS property with `style.setProperty`, so a value can never smuggle in a
|
|
64
|
+
* second declaration. A value the browser cannot parse is dropped and the rest of the overlay stays as it is.
|
|
65
|
+
*/
|
|
66
|
+
interface OverlayTheme {
|
|
67
|
+
/** Base palette the other keys override. Default `"light"`, which is today's look, unchanged. */
|
|
68
|
+
scheme?: "light" | "dark";
|
|
69
|
+
/** The dimming layer behind the card, a CSS colour. */
|
|
70
|
+
backdrop?: string;
|
|
71
|
+
/** The card background, a CSS colour. */
|
|
72
|
+
surface?: string;
|
|
73
|
+
/** The title colour, a CSS colour. */
|
|
74
|
+
text?: string;
|
|
75
|
+
/** The body text and the Cancel button, a CSS colour. */
|
|
76
|
+
mutedText?: string;
|
|
77
|
+
/** The "show the wallet window" button background, a CSS colour. */
|
|
78
|
+
primary?: string;
|
|
79
|
+
/** The "show the wallet window" button text, a CSS colour. */
|
|
80
|
+
primaryText?: string;
|
|
81
|
+
/** The card border, CSS `border` shorthand. Default `"none"`. */
|
|
82
|
+
border?: string;
|
|
83
|
+
/** The card corner radius, e.g. `"36px"`. */
|
|
84
|
+
radius?: string;
|
|
85
|
+
/** The button corner radius, e.g. `"9999px"`. */
|
|
86
|
+
buttonRadius?: string;
|
|
87
|
+
/** The overlay font, CSS `font-family`. */
|
|
88
|
+
fontFamily?: string;
|
|
89
|
+
}
|
|
90
|
+
/** The text of the overlay plus its optional theme. A plain {@link OverlayLabels} object still works. */
|
|
91
|
+
interface OverlayOptions extends OverlayLabels {
|
|
92
|
+
theme?: OverlayTheme;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Headless handles for the open onboarding run, handed to {@link OnboardingOptions.onControls} right after the
|
|
96
|
+
* pop-up opened. They let a host with `overlay: false` render its own dialog. Both are safe no-ops after the
|
|
97
|
+
* run finished.
|
|
98
|
+
*/
|
|
99
|
+
interface OnboardingControls {
|
|
100
|
+
/** Bring the wallet pop-up to the front. */
|
|
101
|
+
focus(): void;
|
|
102
|
+
/** Like the overlay's Cancel button: rejects with `cancelled` before the address arrived, else `close()`. */
|
|
103
|
+
cancel(): void;
|
|
104
|
+
}
|
|
57
105
|
/** Options for {@link openAsseteraOnboarding}. */
|
|
58
106
|
interface OnboardingOptions {
|
|
59
107
|
/** Base URL of the wallet origin, e.g. `https://wallet.wallet-staging.assetera.com`. */
|
|
@@ -64,8 +112,13 @@ interface OnboardingOptions {
|
|
|
64
112
|
locale?: string;
|
|
65
113
|
/** `window.open` feature string. Defaults to a centred `"popup,width=440,height=760,left=…,top=…"`. */
|
|
66
114
|
popupFeatures?: string;
|
|
67
|
-
/** `true` (default) shows the dimming overlay, `false` hides it, an object overrides its text. */
|
|
68
|
-
overlay?: boolean |
|
|
115
|
+
/** `true` (default) shows the dimming overlay, `false` hides it, an object overrides its text and theme. */
|
|
116
|
+
overlay?: boolean | OverlayOptions;
|
|
117
|
+
/**
|
|
118
|
+
* Called once, synchronously, right after the pop-up opened, whether or not the overlay is shown. Lets a host
|
|
119
|
+
* with `overlay: false` drive the run from its own dialog.
|
|
120
|
+
*/
|
|
121
|
+
onControls?: (controls: OnboardingControls) => void;
|
|
69
122
|
/** Only used in the overlay text, e.g. `"Musterbank"`. */
|
|
70
123
|
partnerName?: string;
|
|
71
124
|
/** Ask for one more wallet even when the client already has one ("Create another Assetera Wallet"). */
|
|
@@ -91,6 +144,11 @@ interface OnboardingOptions {
|
|
|
91
144
|
* After it resolved, the overlay stays until `close()`; closing the pop-up by hand also removes it. After it
|
|
92
145
|
* reported the address the pop-up may send `accounts` messages; `onAccounts` receives each list and
|
|
93
146
|
* `lastAccounts()` returns the last one.
|
|
147
|
+
*
|
|
148
|
+
* `overlay` accepts `true` (default), `false`, or an {@link OverlayOptions} object with the overlay text and an
|
|
149
|
+
* {@link OverlayTheme}. With `overlay: false` a host can render its own dialog: {@link OnboardingOptions.onControls}
|
|
150
|
+
* is called once, synchronously, right after the pop-up opened, and its `focus()` and `cancel()` behave like the
|
|
151
|
+
* overlay buttons.
|
|
94
152
|
*/
|
|
95
153
|
declare function openAsseteraOnboarding(options: OnboardingOptions): Promise<OnboardingResult>;
|
|
96
154
|
|
|
@@ -152,4 +210,4 @@ interface WalletManager {
|
|
|
152
210
|
*/
|
|
153
211
|
declare function openAsseteraWalletManager(options: WalletManagerOptions): WalletManager;
|
|
154
212
|
|
|
155
|
-
export { ManagerError, type ManagerErrorCode, OnboardingError, type OnboardingErrorCode, type OnboardingOptions, type OnboardingResult, type OverlayLabels, SignInHint, WalletAccountName, type WalletManager, type WalletManagerOptions, WalletSecurityStatus, openAsseteraOnboarding, openAsseteraWalletManager };
|
|
213
|
+
export { ManagerError, type ManagerErrorCode, type OnboardingControls, OnboardingError, type OnboardingErrorCode, type OnboardingOptions, type OnboardingResult, type OverlayLabels, type OverlayOptions, type OverlayTheme, SignInHint, WalletAccountName, type WalletManager, type WalletManagerOptions, WalletSecurityStatus, openAsseteraOnboarding, openAsseteraWalletManager };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ProviderRpcError, createAsseteraWalletProvider } from './chunk-
|
|
2
|
-
import { isCaip2EvmChain, onboardUrl, manageUrl, isOnboardedMessage, isOnboardCancelledMessage, isSecurityMessage, isAccountsMessage, isResponseMessage, RpcErrorCode, PROTOCOL_VERSION, MESSAGE_PREFIX } from './chunk-
|
|
3
|
-
export { CONNECT_PATH, MANAGE_PATH, MESSAGE_PREFIX, ONBOARD_PATH, PROTOCOL_VERSION, RpcErrorCode, SIGN_IN_HINTS, SUPPORTED_METHODS, connectUrl, isAccountsMessage, isCaip2EvmChain, isDisconnectMessage, isEventMessage, isOnboardCancelledMessage, isOnboardedMessage, isReadyMessage, isRequestMessage, isResponseMessage, isSecurityMessage, isSignInHint, isSupportedMethod, manageUrl, onboardUrl } from './chunk-
|
|
1
|
+
export { ProviderRpcError, createAsseteraWalletProvider } from './chunk-2OK3FPAS.js';
|
|
2
|
+
import { isCaip2EvmChain, onboardUrl, manageUrl, isOnboardedMessage, isOnboardCancelledMessage, isSecurityMessage, isAccountsMessage, isResponseMessage, RpcErrorCode, PROTOCOL_VERSION, MESSAGE_PREFIX } from './chunk-Z7QSH4N2.js';
|
|
3
|
+
export { CONNECT_PATH, HOLD_MAX_MS, MANAGE_PATH, MESSAGE_PREFIX, ONBOARD_PATH, PROTOCOL_VERSION, RpcErrorCode, SIGN_IN_HINTS, SUPPORTED_METHODS, connectUrl, isAccountsMessage, isCaip2EvmChain, isDisconnectMessage, isEventMessage, isHoldMessage, isOnboardCancelledMessage, isOnboardedMessage, isReadyMessage, isRequestMessage, isResponseMessage, isSecurityMessage, isSignInHint, isSupportedMethod, manageUrl, onboardUrl } from './chunk-Z7QSH4N2.js';
|
|
4
4
|
|
|
5
5
|
// src/popup.ts
|
|
6
6
|
var POPUP_WIDTH = 440;
|
|
@@ -34,6 +34,48 @@ var DEFAULT_LABELS = {
|
|
|
34
34
|
cancel: "Cancel",
|
|
35
35
|
blocked: "Your browser blocked the Assetera Wallet window. Allow pop-ups for this site and try again."
|
|
36
36
|
};
|
|
37
|
+
var LIGHT_THEME = {
|
|
38
|
+
scheme: "light",
|
|
39
|
+
backdrop: "rgba(15,20,30,0.6)",
|
|
40
|
+
surface: "#ffffff",
|
|
41
|
+
text: "#101828",
|
|
42
|
+
mutedText: "#475467",
|
|
43
|
+
primary: "#101828",
|
|
44
|
+
primaryText: "#ffffff",
|
|
45
|
+
border: "none",
|
|
46
|
+
radius: "16px",
|
|
47
|
+
buttonRadius: "10px",
|
|
48
|
+
fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"
|
|
49
|
+
};
|
|
50
|
+
var DARK_THEME = {
|
|
51
|
+
scheme: "dark",
|
|
52
|
+
backdrop: "rgba(8,10,14,0.72)",
|
|
53
|
+
surface: "#1b1d24",
|
|
54
|
+
text: "#f7f8fa",
|
|
55
|
+
mutedText: "#9aa2b1",
|
|
56
|
+
primary: "#ffffff",
|
|
57
|
+
primaryText: "#101828",
|
|
58
|
+
border: "1px solid rgba(255,255,255,0.14)",
|
|
59
|
+
radius: "16px",
|
|
60
|
+
buttonRadius: "10px",
|
|
61
|
+
fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"
|
|
62
|
+
};
|
|
63
|
+
function resolveTheme(theme) {
|
|
64
|
+
const base = theme?.scheme === "dark" ? DARK_THEME : LIGHT_THEME;
|
|
65
|
+
return {
|
|
66
|
+
scheme: base.scheme,
|
|
67
|
+
backdrop: theme?.backdrop ?? base.backdrop,
|
|
68
|
+
surface: theme?.surface ?? base.surface,
|
|
69
|
+
text: theme?.text ?? base.text,
|
|
70
|
+
mutedText: theme?.mutedText ?? base.mutedText,
|
|
71
|
+
primary: theme?.primary ?? base.primary,
|
|
72
|
+
primaryText: theme?.primaryText ?? base.primaryText,
|
|
73
|
+
border: theme?.border ?? base.border,
|
|
74
|
+
radius: theme?.radius ?? base.radius,
|
|
75
|
+
buttonRadius: theme?.buttonRadius ?? base.buttonRadius,
|
|
76
|
+
fontFamily: theme?.fontFamily ?? base.fontFamily
|
|
77
|
+
};
|
|
78
|
+
}
|
|
37
79
|
function resolveLabels(options) {
|
|
38
80
|
const overrides = typeof options.overlay === "object" && options.overlay !== null ? options.overlay : {};
|
|
39
81
|
const partnerName = options.partnerName;
|
|
@@ -46,6 +88,10 @@ function resolveLabels(options) {
|
|
|
46
88
|
blocked: overrides.blocked ?? DEFAULT_LABELS.blocked
|
|
47
89
|
};
|
|
48
90
|
}
|
|
91
|
+
function resolveThemeOption(options) {
|
|
92
|
+
const overlay = typeof options.overlay === "object" && options.overlay !== null ? options.overlay : {};
|
|
93
|
+
return resolveTheme(overlay.theme);
|
|
94
|
+
}
|
|
49
95
|
function cancelCode(reason) {
|
|
50
96
|
if (reason === "user") return "cancelled";
|
|
51
97
|
if (reason === "refused") return "refused";
|
|
@@ -59,7 +105,7 @@ function cancelMessage(reason) {
|
|
|
59
105
|
function copyAccountNames(accounts) {
|
|
60
106
|
return accounts.map((account) => ({ address: account.address, name: account.name }));
|
|
61
107
|
}
|
|
62
|
-
function showOverlay(win, labels, handlers) {
|
|
108
|
+
function showOverlay(win, labels, theme, handlers) {
|
|
63
109
|
const doc = win.document;
|
|
64
110
|
const root = doc.createElement("div");
|
|
65
111
|
root.setAttribute("role", "dialog");
|
|
@@ -73,40 +119,43 @@ function showOverlay(win, labels, handlers) {
|
|
|
73
119
|
"justify-content: center",
|
|
74
120
|
"padding: 24px",
|
|
75
121
|
"box-sizing: border-box",
|
|
76
|
-
|
|
77
|
-
`z-index: ${OVERLAY_Z_INDEX}`,
|
|
78
|
-
"font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"
|
|
122
|
+
`z-index: ${OVERLAY_Z_INDEX}`
|
|
79
123
|
].join("; ");
|
|
124
|
+
root.style.setProperty("background-color", theme.backdrop);
|
|
125
|
+
root.style.setProperty("font-family", theme.fontFamily);
|
|
80
126
|
const card = doc.createElement("div");
|
|
81
127
|
card.style.cssText = [
|
|
82
128
|
"box-sizing: border-box",
|
|
83
129
|
"width: 100%",
|
|
84
130
|
"max-width: 420px",
|
|
85
|
-
"border-radius: 16px",
|
|
86
131
|
"padding: 24px",
|
|
87
|
-
"background: #ffffff",
|
|
88
|
-
"color: #101828",
|
|
89
132
|
"box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35)"
|
|
90
133
|
].join("; ");
|
|
134
|
+
card.style.setProperty("background-color", theme.surface);
|
|
135
|
+
card.style.setProperty("color", theme.text);
|
|
136
|
+
card.style.setProperty("border", theme.border);
|
|
137
|
+
card.style.setProperty("border-radius", theme.radius);
|
|
91
138
|
const title = doc.createElement("h2");
|
|
92
139
|
title.textContent = labels.title;
|
|
93
140
|
title.style.cssText = "margin: 0 0 10px; font-size: 18px; line-height: 1.3; font-weight: 600;";
|
|
141
|
+
title.style.setProperty("color", theme.text);
|
|
94
142
|
const body = doc.createElement("p");
|
|
95
143
|
body.textContent = labels.body;
|
|
96
|
-
body.style.cssText = "margin: 0 0 20px; font-size: 14px; line-height: 1.5;
|
|
144
|
+
body.style.cssText = "margin: 0 0 20px; font-size: 14px; line-height: 1.5;";
|
|
145
|
+
body.style.setProperty("color", theme.mutedText);
|
|
97
146
|
const focus = doc.createElement("button");
|
|
98
147
|
focus.type = "button";
|
|
99
148
|
focus.textContent = labels.focus;
|
|
100
149
|
focus.style.cssText = [
|
|
101
150
|
"padding: 10px 16px",
|
|
102
151
|
"border: 0",
|
|
103
|
-
"border-radius: 10px",
|
|
104
|
-
"background: #101828",
|
|
105
|
-
"color: #ffffff",
|
|
106
152
|
"font: inherit",
|
|
107
153
|
"font-weight: 600",
|
|
108
154
|
"cursor: pointer"
|
|
109
155
|
].join("; ");
|
|
156
|
+
focus.style.setProperty("background-color", theme.primary);
|
|
157
|
+
focus.style.setProperty("color", theme.primaryText);
|
|
158
|
+
focus.style.setProperty("border-radius", theme.buttonRadius);
|
|
110
159
|
focus.addEventListener("click", handlers.onFocus);
|
|
111
160
|
const cancel = doc.createElement("button");
|
|
112
161
|
cancel.type = "button";
|
|
@@ -116,10 +165,11 @@ function showOverlay(win, labels, handlers) {
|
|
|
116
165
|
"border: 0",
|
|
117
166
|
"border-radius: 10px",
|
|
118
167
|
"background: transparent",
|
|
119
|
-
"color: #475467",
|
|
120
168
|
"font: inherit",
|
|
121
169
|
"cursor: pointer"
|
|
122
170
|
].join("; ");
|
|
171
|
+
cancel.style.setProperty("color", theme.mutedText);
|
|
172
|
+
cancel.style.setProperty("border-radius", theme.buttonRadius);
|
|
123
173
|
cancel.addEventListener("click", handlers.onCancel);
|
|
124
174
|
const actions = doc.createElement("div");
|
|
125
175
|
actions.style.cssText = "display: flex; gap: 8px; align-items: center;";
|
|
@@ -154,6 +204,7 @@ function openAsseteraOnboarding(options) {
|
|
|
154
204
|
);
|
|
155
205
|
}
|
|
156
206
|
const labels = resolveLabels(options);
|
|
207
|
+
const theme = resolveThemeOption(options);
|
|
157
208
|
const overlayEnabled = options.overlay !== false;
|
|
158
209
|
const popup = targetWindow.open(
|
|
159
210
|
onboardUrl(options.walletUrl, targetWindow.location.origin, {
|
|
@@ -208,6 +259,16 @@ function openAsseteraOnboarding(options) {
|
|
|
208
259
|
activePopup.close();
|
|
209
260
|
fail(new OnboardingError("cancelled", "The user cancelled the Assetera Wallet onboarding."));
|
|
210
261
|
}
|
|
262
|
+
const controls = {
|
|
263
|
+
focus() {
|
|
264
|
+
if (finished) return;
|
|
265
|
+
activePopup.focus();
|
|
266
|
+
},
|
|
267
|
+
cancel() {
|
|
268
|
+
if (finished) return;
|
|
269
|
+
cancel();
|
|
270
|
+
}
|
|
271
|
+
};
|
|
211
272
|
function signMessage(message) {
|
|
212
273
|
if (finished || activePopup.closed) {
|
|
213
274
|
return Promise.reject(new OnboardingError("closed", "The Assetera Wallet window was closed."));
|
|
@@ -286,11 +347,12 @@ function openAsseteraOnboarding(options) {
|
|
|
286
347
|
);
|
|
287
348
|
}, CLOSE_POLL_MS);
|
|
288
349
|
if (overlayEnabled) {
|
|
289
|
-
overlay = showOverlay(targetWindow, labels, {
|
|
290
|
-
onFocus: () =>
|
|
291
|
-
onCancel: cancel
|
|
350
|
+
overlay = showOverlay(targetWindow, labels, theme, {
|
|
351
|
+
onFocus: () => controls.focus(),
|
|
352
|
+
onCancel: () => controls.cancel()
|
|
292
353
|
});
|
|
293
354
|
}
|
|
355
|
+
options.onControls?.(controls);
|
|
294
356
|
});
|
|
295
357
|
}
|
|
296
358
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/popup.ts","../src/onboarding.ts","../src/manage.ts"],"names":["POPUP_NAME","CLOSE_POLL_MS","copyAccountNames"],"mappings":";;;;;AAMO,IAAM,WAAA,GAAc,GAAA;AAGpB,IAAM,YAAA,GAAe,GAAA;AAMrB,SAAS,qBAAqB,GAAA,EAAqB;AACxD,EAAA,MAAM,UAAU,MAAA,CAAO,QAAA,CAAS,IAAI,OAAO,CAAA,GAAI,IAAI,OAAA,GAAU,CAAA;AAC7D,EAAA,MAAM,UAAU,MAAA,CAAO,QAAA,CAAS,IAAI,OAAO,CAAA,GAAI,IAAI,OAAA,GAAU,CAAA;AAC7D,EAAA,MAAM,aAAa,MAAA,CAAO,QAAA,CAAS,IAAI,UAAU,CAAA,GAAI,IAAI,UAAA,GAAa,WAAA;AACtE,EAAA,MAAM,cAAc,MAAA,CAAO,QAAA,CAAS,IAAI,WAAW,CAAA,GAAI,IAAI,WAAA,GAAc,YAAA;AACzE,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,IAAA,CAAK,MAAM,OAAA,GAAA,CAAW,UAAA,GAAa,WAAA,IAAe,CAAC,CAAC,CAAA;AAC7E,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,IAAA,CAAK,MAAM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AAA,YAAA,GAAeA,iBAAAA,CAAiB,KAAK,IAAI,CAAA;AACzC,MAAA,OAAA,CAAQ,UAAA,GAAaA,iBAAAA,CAAiB,YAAY,CAAC,CAAA;AAAA,IACrD;AAAA,EACF;AAEA,EAAA,YAAA,CAAa,gBAAA,CAAiB,WAAW,SAAS,CAAA;AAClD,EAAA,UAAA,GAAa,YAAY,MAAM;AAC7B,IAAA,IAAI,WAAA,CAAY,QAAQ,OAAA,EAAQ;AAAA,EAClC,GAAGD,cAAa,CAAA;AAEhB,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAc,MAAM,YAAA;AAAA,IACpB,cAAc,MAAO,YAAA,KAAiB,MAAA,GAAY,MAAA,GAAYC,kBAAiB,YAAY;AAAA,GAC7F;AACF","file":"index.js","sourcesContent":["/**\n * Small helpers shared by the pop-up openers in this package. They are internal and are not part of the public\n * API through `index.ts`.\n */\n\n/** Default width, in pixels, of the onboarding and manage pop-ups. */\nexport const POPUP_WIDTH = 440;\n\n/** Default height, in pixels, of the onboarding and manage pop-ups. */\nexport const POPUP_HEIGHT = 760;\n\n/**\n * Build the centred `window.open` feature string for a pop-up of the default size. `win` is the opener window:\n * the pop-up is centred over it, and safe defaults are used when the browser does not expose the geometry.\n */\nexport function defaultPopupFeatures(win: Window): string {\n const screenX = Number.isFinite(win.screenX) ? win.screenX : 0;\n const screenY = Number.isFinite(win.screenY) ? win.screenY : 0;\n const outerWidth = Number.isFinite(win.outerWidth) ? win.outerWidth : POPUP_WIDTH;\n const outerHeight = Number.isFinite(win.outerHeight) ? win.outerHeight : POPUP_HEIGHT;\n const left = Math.max(0, Math.round(screenX + (outerWidth - POPUP_WIDTH) / 2));\n const top = Math.max(0, Math.round(screenY + (outerHeight - POPUP_HEIGHT) / 2));\n return `popup,width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${left},top=${top}`;\n}\n","/**\n * Onboarding opener for the Assetera Wallet: the partner side of the `/onboard` wizard (AO-1274).\n *\n * A tied-agent bank site shows a \"Create an Assetera wallet\" button. On the click, this module opens the wallet\n * pop-up in onboarding mode synchronously (so the browser treats it as part of the click) and waits for the\n * wizard to post the new wallet address back. While the pop-up is open the partner page shows a dimming\n * overlay; the overlay is plain DOM (no React, no CSS files) so any partner can drop this in.\n *\n * The wallet's `/onboard` page is the pop-up side and speaks the same protocol in `./protocol`, but it uses the\n * message types and the `ONBOARD_PATH` from there, so the two sides cannot drift apart.\n */\nimport {\n MESSAGE_PREFIX,\n PROTOCOL_VERSION,\n RpcErrorCode,\n isAccountsMessage,\n isCaip2EvmChain,\n isOnboardCancelledMessage,\n isOnboardedMessage,\n isResponseMessage,\n onboardUrl,\n type OnboardCancelledMessage,\n type RequestMessage,\n type SignInHint,\n type WalletAccountName,\n} from \"./protocol\";\nimport { defaultPopupFeatures } from \"./popup\";\n\n/** Why {@link openAsseteraOnboarding} rejected. */\nexport type OnboardingErrorCode =\n \"popup_blocked\" | \"closed\" | \"cancelled\" | \"refused\" | \"failed\" | \"invalid_options\";\n\n/** Error thrown (well, rejected) by {@link openAsseteraOnboarding}. `code` is stable and safe to branch on. */\nexport class OnboardingError extends Error {\n readonly code: OnboardingErrorCode;\n\n constructor(code: OnboardingErrorCode, message: string) {\n super(message);\n this.name = \"OnboardingError\";\n this.code = code;\n }\n}\n\n/**\n * The client's Assetera Wallet, with the pop-up still open.\n *\n * The wallet is NOT registered with any compliance service. A regulated partner registers it itself, like any\n * other wallet: fetch a challenge for `address`, pass it to `signMessage`, send the signature to its compliance\n * service, then call `close()`. Always call `close()`: it closes the pop-up and removes the overlay.\n */\nexport interface OnboardingResult {\n address: `0x${string}`;\n chain: string;\n /** `true` when the wallet was created in this run, `false` when the client's existing wallet was returned. */\n created: boolean;\n /**\n * Ask the client to sign `message` (EIP-191 `personal_sign`) with this wallet in the open pop-up. Rejects with\n * `OnboardingError(\"cancelled\")` when the client declines, `\"closed\"` when the pop-up is gone, else `\"failed\"`.\n */\n signMessage: (message: string) => Promise<`0x${string}`>;\n /** Close the pop-up and remove the overlay. Safe to call more than once. */\n close: () => void;\n /**\n * The last account names the pop-up sent after it reported the address, or `undefined` when none arrived yet.\n * The returned list is a copy.\n */\n lastAccounts: () => WalletAccountName[] | undefined;\n}\n\n/** Text of the dimming overlay, all optional. Any key left out keeps its English default. */\nexport interface OverlayLabels {\n title?: string;\n body?: string;\n focus?: string;\n cancel?: string;\n blocked?: string;\n}\n\n/** Options for {@link openAsseteraOnboarding}. */\nexport interface OnboardingOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.wallet-staging.assetera.com`. */\n walletUrl: string;\n /** CAIP-2 chain id the new wallet should be created on, e.g. `eip155:80002`. An invalid value rejects with `invalid_options`. */\n chain: string;\n /** Wizard language passed as `lang`, e.g. `\"en\"` or `\"de\"`. */\n locale?: string;\n /** `window.open` feature string. Defaults to a centred `\"popup,width=440,height=760,left=…,top=…\"`. */\n popupFeatures?: string;\n /** `true` (default) shows the dimming overlay, `false` hides it, an object overrides its text. */\n overlay?: boolean | OverlayLabels;\n /** Only used in the overlay text, e.g. `\"Musterbank\"`. */\n partnerName?: string;\n /** Ask for one more wallet even when the client already has one (\"Create another Assetera Wallet\"). */\n addWallet?: boolean;\n /** Sign-in hint passed as `signIn`, e.g. `\"assetera-marketplace\"`. Only a hint; the wallet may ignore it. */\n signIn?: SignInHint;\n /** Called for every `accounts` message the pop-up sends after it reported the address. */\n onAccounts?: (accounts: WalletAccountName[]) => void;\n /** Injectable `window` for tests; defaults to `globalThis.window`. */\n window?: Window;\n}\n\nconst POPUP_NAME = \"assetera-wallet-onboarding\";\nconst CLOSE_POLL_MS = 500;\nconst OVERLAY_Z_INDEX = 2147483000;\n\nconst DEFAULT_LABELS: Required<OverlayLabels> = {\n title: \"Continue in the Assetera Wallet window\",\n body: \"A secure Assetera Wallet window is open. Follow the steps there. This page continues by itself when you are done.\",\n focus: \"Show the wallet window\",\n cancel: \"Cancel\",\n blocked: \"Your browser blocked the Assetera Wallet window. Allow pop-ups for this site and try again.\",\n};\n\ninterface OverlayHandlers {\n onFocus: () => void;\n onCancel: () => void;\n}\n\nfunction resolveLabels(options: OnboardingOptions): Required<OverlayLabels> {\n const overrides: OverlayLabels =\n typeof options.overlay === \"object\" && options.overlay !== null ? options.overlay : {};\n const partnerName = options.partnerName;\n const defaultBody = partnerName\n ? `A secure Assetera Wallet window is open for ${partnerName}. Follow the steps there. This page continues by itself when you are done.`\n : DEFAULT_LABELS.body;\n return {\n title: overrides.title ?? DEFAULT_LABELS.title,\n body: overrides.body ?? defaultBody,\n focus: overrides.focus ?? DEFAULT_LABELS.focus,\n cancel: overrides.cancel ?? DEFAULT_LABELS.cancel,\n blocked: overrides.blocked ?? DEFAULT_LABELS.blocked,\n };\n}\n\nfunction cancelCode(reason: OnboardCancelledMessage[\"reason\"]): OnboardingErrorCode {\n if (reason === \"user\") return \"cancelled\";\n if (reason === \"refused\") return \"refused\";\n return \"failed\";\n}\n\nfunction cancelMessage(reason: OnboardCancelledMessage[\"reason\"]): string {\n if (reason === \"user\") return \"The user cancelled the Assetera Wallet onboarding.\";\n if (reason === \"refused\") return \"The Assetera Wallet refused the onboarding.\";\n return \"The Assetera Wallet onboarding failed.\";\n}\n\n/** A copy of a list of named accounts, so callers never get the opener's own list. */\nfunction copyAccountNames(accounts: readonly WalletAccountName[]): WalletAccountName[] {\n return accounts.map((account) => ({ address: account.address, name: account.name }));\n}\n\n/**\n * Build the dimming overlay. Text is inserted with `textContent` only and every style is inline, so the\n * overlay cannot pick up partner CSS and cannot be scripted through an injected string.\n */\nfunction showOverlay(win: Window, labels: Required<OverlayLabels>, handlers: OverlayHandlers): HTMLElement {\n const doc = win.document;\n const root = doc.createElement(\"div\");\n root.setAttribute(\"role\", \"dialog\");\n root.setAttribute(\"aria-modal\", \"true\");\n root.setAttribute(\"data-assetera-onboarding-overlay\", \"\");\n root.style.cssText = [\n \"position: fixed\",\n \"inset: 0\",\n \"display: flex\",\n \"align-items: center\",\n \"justify-content: center\",\n \"padding: 24px\",\n \"box-sizing: border-box\",\n \"background: rgba(15,20,30,0.6)\",\n `z-index: ${OVERLAY_Z_INDEX}`,\n \"font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n ].join(\"; \");\n\n const card = doc.createElement(\"div\");\n card.style.cssText = [\n \"box-sizing: border-box\",\n \"width: 100%\",\n \"max-width: 420px\",\n \"border-radius: 16px\",\n \"padding: 24px\",\n \"background: #ffffff\",\n \"color: #101828\",\n \"box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35)\",\n ].join(\"; \");\n\n const title = doc.createElement(\"h2\");\n title.textContent = labels.title;\n title.style.cssText = \"margin: 0 0 10px; font-size: 18px; line-height: 1.3; font-weight: 600;\";\n\n const body = doc.createElement(\"p\");\n body.textContent = labels.body;\n body.style.cssText = \"margin: 0 0 20px; font-size: 14px; line-height: 1.5; color: #475467;\";\n\n const focus = doc.createElement(\"button\");\n focus.type = \"button\";\n focus.textContent = labels.focus;\n focus.style.cssText = [\n \"padding: 10px 16px\",\n \"border: 0\",\n \"border-radius: 10px\",\n \"background: #101828\",\n \"color: #ffffff\",\n \"font: inherit\",\n \"font-weight: 600\",\n \"cursor: pointer\",\n ].join(\"; \");\n focus.addEventListener(\"click\", handlers.onFocus);\n\n const cancel = doc.createElement(\"button\");\n cancel.type = \"button\";\n cancel.textContent = labels.cancel;\n cancel.style.cssText = [\n \"padding: 10px 16px\",\n \"border: 0\",\n \"border-radius: 10px\",\n \"background: transparent\",\n \"color: #475467\",\n \"font: inherit\",\n \"cursor: pointer\",\n ].join(\"; \");\n cancel.addEventListener(\"click\", handlers.onCancel);\n\n const actions = doc.createElement(\"div\");\n actions.style.cssText = \"display: flex; gap: 8px; align-items: center;\";\n actions.append(focus, cancel);\n\n card.append(title, body, actions);\n root.append(card);\n doc.body.append(root);\n return root;\n}\n\n/**\n * Open the Assetera Wallet onboarding wizard in a pop-up and resolve with the client's wallet, the pop-up still\n * open so the partner can ask for the ownership signature (see {@link OnboardingResult}).\n *\n * Call this from a user click (a button handler). `window.open` runs synchronously inside the call, before any\n * `await`, so the browser allows it; if the browser blocks the pop-up the promise rejects with\n * `OnboardingError(\"popup_blocked\")` and no overlay is shown.\n *\n * The promise rejects with `OnboardingError` and one of these codes: `invalid_options` (bad chain or wallet\n * URL), `popup_blocked`, `closed` (the pop-up was closed first), `cancelled` (the user cancelled in the wizard\n * or in the overlay), `refused` (the wallet refused the onboarding) or `failed` (anything else in the wallet).\n * After it resolved, the overlay stays until `close()`; closing the pop-up by hand also removes it. After it\n * reported the address the pop-up may send `accounts` messages; `onAccounts` receives each list and\n * `lastAccounts()` returns the last one.\n */\nexport function openAsseteraOnboarding(options: OnboardingOptions): Promise<OnboardingResult> {\n const requestedWindow = options.window ?? (typeof window === \"undefined\" ? undefined : window);\n if (!requestedWindow) {\n return Promise.reject(\n new OnboardingError(\"invalid_options\", \"The Assetera Wallet onboarding can only run in a browser.\"),\n );\n }\n // A non-optional alias so TypeScript keeps the narrowed type inside the callbacks below.\n const targetWindow: Window = requestedWindow;\n if (!isCaip2EvmChain(options.chain)) {\n return Promise.reject(\n new OnboardingError(\n \"invalid_options\",\n `\"${options.chain}\" is not a CAIP-2 EVM chain id (for example \"eip155:80002\").`,\n ),\n );\n }\n let walletOrigin: string;\n try {\n walletOrigin = new URL(options.walletUrl).origin;\n } catch {\n return Promise.reject(\n new OnboardingError(\"invalid_options\", `\"${options.walletUrl}\" is not a valid wallet URL.`),\n );\n }\n\n const labels = resolveLabels(options);\n const overlayEnabled = options.overlay !== false;\n\n // MUST stay synchronous, before the first await, so the pop-up runs inside the caller's user activation.\n const popup = targetWindow.open(\n onboardUrl(options.walletUrl, targetWindow.location.origin, {\n chain: options.chain,\n ...(options.locale === undefined ? {} : { locale: options.locale }),\n ...(options.addWallet ? { add: true } : {}),\n ...(options.signIn === undefined ? {} : { signIn: options.signIn }),\n }),\n POPUP_NAME,\n options.popupFeatures ?? defaultPopupFeatures(targetWindow),\n );\n\n if (!popup) {\n // Nothing was opened, so there is nothing to wait for and no overlay: the partner page stays usable.\n return Promise.reject(new OnboardingError(\"popup_blocked\", labels.blocked));\n }\n // A non-optional alias so TypeScript keeps the narrowed type inside the callbacks below.\n const activePopup: Window = popup;\n\n return new Promise<OnboardingResult>((resolve, reject) => {\n // Phase 1 waits for `onboarded`; phase 2 (after it) keeps the pop-up for signature requests until `close()`.\n let onboarded = false;\n let finished = false;\n let closeTimer: ReturnType<typeof setInterval> | null = null;\n let overlay: HTMLElement | null = null;\n const pending = new Map<\n string,\n { resolve: (signature: `0x${string}`) => void; reject: (error: OnboardingError) => void }\n >();\n\n function cleanup(): void {\n finished = true;\n targetWindow.removeEventListener(\"message\", onMessage);\n if (closeTimer !== null) {\n clearInterval(closeTimer);\n closeTimer = null;\n }\n overlay?.remove();\n overlay = null;\n }\n\n function failPending(error: OnboardingError): void {\n for (const entry of pending.values()) entry.reject(error);\n pending.clear();\n }\n\n function close(): void {\n if (finished) return;\n failPending(new OnboardingError(\"closed\", \"The Assetera Wallet window was closed.\"));\n cleanup();\n if (!activePopup.closed) activePopup.close();\n }\n\n function fail(error: OnboardingError): void {\n if (onboarded || finished) return;\n cleanup();\n reject(error);\n }\n\n function cancel(): void {\n if (onboarded) {\n close();\n return;\n }\n activePopup.close();\n fail(new OnboardingError(\"cancelled\", \"The user cancelled the Assetera Wallet onboarding.\"));\n }\n\n function signMessage(message: string): Promise<`0x${string}`> {\n if (finished || activePopup.closed) {\n return Promise.reject(new OnboardingError(\"closed\", \"The Assetera Wallet window was closed.\"));\n }\n const id = globalThis.crypto.randomUUID();\n const request: RequestMessage = {\n type: `${MESSAGE_PREFIX}request`,\n v: PROTOCOL_VERSION,\n id,\n method: \"personal_sign\",\n params: [message, address as `0x${string}`],\n };\n return new Promise((resolveSign, rejectSign) => {\n pending.set(id, { resolve: resolveSign, reject: rejectSign });\n activePopup.focus();\n activePopup.postMessage(request, walletOrigin);\n });\n }\n\n // Set with `onboarded`; `signMessage` is only handed out after that.\n let address: `0x${string}` | undefined;\n /** The last account names the pop-up sent after `onboarded`; kept until `close()`. */\n let lastAccountNameList: WalletAccountName[] | undefined;\n\n function onMessage(event: MessageEvent): void {\n // Trust rule: accept only the wallet origin AND the exact pop-up we opened. Ignore everything else.\n if (event.origin !== walletOrigin) return;\n if ((event.source as unknown) !== activePopup) return;\n const data: unknown = event.data;\n if (!onboarded) {\n if (isOnboardedMessage(data)) {\n onboarded = true;\n address = data.address;\n resolve({\n address: data.address,\n chain: data.chain,\n created: data.created ?? true,\n signMessage,\n close,\n lastAccounts: () =>\n lastAccountNameList === undefined ? undefined : copyAccountNames(lastAccountNameList),\n });\n return;\n }\n if (isOnboardCancelledMessage(data)) {\n fail(new OnboardingError(cancelCode(data.reason), data.message ?? cancelMessage(data.reason)));\n }\n return;\n }\n if (isAccountsMessage(data)) {\n lastAccountNameList = copyAccountNames(data.data);\n options.onAccounts?.(copyAccountNames(lastAccountNameList));\n return;\n }\n if (isResponseMessage(data)) {\n const entry = pending.get(data.id);\n if (!entry) return;\n pending.delete(data.id);\n if (\"error\" in data) {\n entry.reject(\n new OnboardingError(\n data.error.code === RpcErrorCode.UserRejected ? \"cancelled\" : \"failed\",\n data.error.message,\n ),\n );\n } else if (typeof data.result === \"string\" && /^0x[0-9a-fA-F]+$/.test(data.result)) {\n entry.resolve(data.result as `0x${string}`);\n } else {\n entry.reject(new OnboardingError(\"failed\", \"The Assetera Wallet returned no signature.\"));\n }\n }\n }\n\n targetWindow.addEventListener(\"message\", onMessage);\n closeTimer = setInterval(() => {\n if (!activePopup.closed) return;\n if (onboarded) {\n close();\n return;\n }\n fail(\n new OnboardingError(\"closed\", \"The Assetera Wallet window was closed before onboarding finished.\"),\n );\n }, CLOSE_POLL_MS);\n\n if (overlayEnabled) {\n overlay = showOverlay(targetWindow, labels, {\n onFocus: () => activePopup.focus(),\n onCancel: cancel,\n });\n }\n });\n}\n","/**\n * Manage-wallet opener for the Assetera Wallet: the partner side of the `/manage` pop-up (AO-1436).\n *\n * A partner page shows a \"Manage wallet\" button. On the click this module opens the wallet pop-up on the manage\n * route synchronously (so the browser treats it as part of the click). The client sees the wallet accounts and\n * the wallet security (passkeys, authenticator app, recovery codes) and can change them. The pop-up never\n * answers `request` messages; it posts `security` and `accounts` messages while it is open.\n */\nimport {\n isAccountsMessage,\n isSecurityMessage,\n manageUrl,\n type SignInHint,\n type WalletAccountName,\n type WalletSecurityStatus,\n} from \"./protocol\";\nimport { defaultPopupFeatures } from \"./popup\";\n\n/** Why {@link openAsseteraWalletManager} threw. */\nexport type ManagerErrorCode = \"popup_blocked\" | \"invalid_options\";\n\n/** Error thrown by {@link openAsseteraWalletManager}. `code` is stable and safe to branch on. */\nexport class ManagerError extends Error {\n readonly code: ManagerErrorCode;\n\n constructor(code: ManagerErrorCode, message: string) {\n super(message);\n this.name = \"ManagerError\";\n this.code = code;\n }\n}\n\n/** Options for {@link openAsseteraWalletManager}. */\nexport interface WalletManagerOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.wallet-staging.assetera.com`. */\n walletUrl: string;\n /** Sign-in hint passed as `signIn`, e.g. `\"assetera-marketplace\"`. Only a hint; the wallet may ignore it. */\n signIn?: SignInHint;\n /** Language passed as `lang`, e.g. `\"en\"` or `\"de\"`. */\n locale?: string;\n /** `window.open` feature string. Defaults to a centred `\"popup,width=440,height=760,left=…,top=…\"`. */\n popupFeatures?: string;\n /** Called for every `security` message from the pop-up. */\n onSecurity?: (status: WalletSecurityStatus) => void;\n /** Called for every `accounts` message from the pop-up. */\n onAccounts?: (accounts: WalletAccountName[]) => void;\n /** Injectable `window` for tests; defaults to `globalThis.window`. */\n window?: Window;\n}\n\n/** The open manage pop-up, controlled by the partner. */\nexport interface WalletManager {\n /** Close the pop-up and remove the listener and the close timer. Safe to call more than once. */\n close: () => void;\n /** Resolves when the pop-up is closed, by the partner or by the client. */\n closed: Promise<void>;\n /** The last security status the pop-up sent, or `undefined` when none arrived yet. */\n lastSecurity: () => WalletSecurityStatus | undefined;\n /** The last account names the pop-up sent, or `undefined` when none arrived yet. */\n lastAccounts: () => WalletAccountName[] | undefined;\n}\n\nconst POPUP_NAME = \"assetera-wallet-manage\";\nconst CLOSE_POLL_MS = 500;\n\n/**\n * Open the manage-wallet pop-up for the Assetera Wallet and return a handle to it.\n *\n * Call this from a user click (a button handler). `window.open` runs synchronously inside the call, before any\n * `await`, so the browser allows it; when the browser blocks the pop-up this throws `ManagerError` with code\n * `popup_blocked`.\n *\n * The pop-up checks the `origin` query parameter against the wallet's partner list, posts `ready` to\n * `window.opener` and then posts `security` and `accounts` messages. Messages are accepted only when they come\n * from the wallet origin AND from the pop-up that was opened here. The pop-up does not answer `request`\n * messages.\n */\nexport function openAsseteraWalletManager(options: WalletManagerOptions): WalletManager {\n const requestedWindow = options.window ?? (typeof window === \"undefined\" ? undefined : window);\n if (!requestedWindow) {\n throw new ManagerError(\"invalid_options\", \"The Assetera Wallet manager can only run in a browser.\");\n }\n // A non-optional alias so TypeScript keeps the narrowed type inside the callbacks below.\n const targetWindow: Window = requestedWindow;\n let walletOrigin: string;\n try {\n walletOrigin = new URL(options.walletUrl).origin;\n } catch {\n throw new ManagerError(\"invalid_options\", `\"${options.walletUrl}\" is not a valid wallet URL.`);\n }\n\n // MUST stay synchronous, before any await, so the pop-up runs inside the caller's user activation.\n const popup = targetWindow.open(\n manageUrl(options.walletUrl, targetWindow.location.origin, {\n ...(options.locale === undefined ? {} : { locale: options.locale }),\n ...(options.signIn === undefined ? {} : { signIn: options.signIn }),\n }),\n POPUP_NAME,\n options.popupFeatures ?? defaultPopupFeatures(targetWindow),\n );\n\n if (!popup) {\n throw new ManagerError(\n \"popup_blocked\",\n \"Your browser blocked the Assetera Wallet window. Allow pop-ups for this site and try again.\",\n );\n }\n // A non-optional alias so TypeScript keeps the narrowed type inside the callbacks below.\n const activePopup: Window = popup;\n\n let finished = false;\n let lastSecurity: WalletSecurityStatus | undefined;\n let lastAccounts: WalletAccountName[] | undefined;\n let closeTimer: ReturnType<typeof setInterval> | null = null;\n let resolveClosed!: () => void;\n const closed = new Promise<void>((resolve) => {\n resolveClosed = resolve;\n });\n\n function cleanup(): void {\n if (finished) return;\n finished = true;\n targetWindow.removeEventListener(\"message\", onMessage);\n if (closeTimer !== null) {\n clearInterval(closeTimer);\n closeTimer = null;\n }\n resolveClosed();\n }\n\n function close(): void {\n cleanup();\n if (!activePopup.closed) activePopup.close();\n }\n\n /** A copy of a list of named accounts, so callers never get the manager's own list. */\n function copyAccountNames(accounts: readonly WalletAccountName[]): WalletAccountName[] {\n return accounts.map((account) => ({ address: account.address, name: account.name }));\n }\n\n function onMessage(event: MessageEvent): void {\n // Trust rule: accept only the wallet origin AND the exact pop-up we opened. Ignore everything else.\n if (event.origin !== walletOrigin) return;\n if ((event.source as unknown) !== activePopup) return;\n const data: unknown = event.data;\n if (isSecurityMessage(data)) {\n const status: WalletSecurityStatus = {\n protection: data.data.protection,\n passkeys: data.data.passkeys,\n authenticatorApps: data.data.authenticatorApps,\n };\n lastSecurity = status;\n options.onSecurity?.(status);\n return;\n }\n if (isAccountsMessage(data)) {\n lastAccounts = copyAccountNames(data.data);\n options.onAccounts?.(copyAccountNames(lastAccounts));\n }\n }\n\n targetWindow.addEventListener(\"message\", onMessage);\n closeTimer = setInterval(() => {\n if (activePopup.closed) cleanup();\n }, CLOSE_POLL_MS);\n\n return {\n close,\n closed,\n lastSecurity: () => lastSecurity,\n lastAccounts: () => (lastAccounts === undefined ? undefined : copyAccountNames(lastAccounts)),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/popup.ts","../src/onboarding.ts","../src/manage.ts"],"names":["POPUP_NAME","CLOSE_POLL_MS","copyAccountNames"],"mappings":";;;;;AAMO,IAAM,WAAA,GAAc,GAAA;AAGpB,IAAM,YAAA,GAAe,GAAA;AAMrB,SAAS,qBAAqB,GAAA,EAAqB;AACxD,EAAA,MAAM,UAAU,MAAA,CAAO,QAAA,CAAS,IAAI,OAAO,CAAA,GAAI,IAAI,OAAA,GAA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AA;AACzC,MAAA,OAAA,CAAQ,UAAA,GAAaA,iBAAAA,CAAiB,YAAY,CAAC,CAAA;AAAA,IACrD;AAAA,EACF;AAEA,EAAA,YAAA,CAAa,gBAAA,CAAiB,WAAW,SAAS,CAAA;AAClD,EAAA,UAAA,GAAa,YAAY,MAAM;AAC7B,IAAA,IAAI,WAAA,CAAY,QAAQ,OAAA,EAAQ;AAAA,EAClC,GAAGD,cAAa,CAAA;AAEhB,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAc,MAAM,YAAA;AAAA,IACpB,cAAc,MAAO,YAAA,KAAiB,MAAA,GAAY,MAAA,GAAYC,kBAAiB,YAAY;AAAA,GAC7F;AACF","file":"index.js","sourcesContent":["/**\n * Small helpers shared by the pop-up openers in this package. They are internal and are not part of the public\n * API through `index.ts`.\n */\n\n/** Default width, in pixels, of the onboarding and manage pop-ups. */\nexport const POPUP_WIDTH = 440;\n\n/** Default height, in pixels, of the onboarding and manage pop-ups. */\nexport const POPUP_HEIGHT = 760;\n\n/**\n * Build the centred `window.open` feature string for a pop-up of the default size. `win` is the opener window:\n * the pop-up is centred over it, and safe defaults are used when the browser does not expose the geometry.\n */\nexport function defaultPopupFeatures(win: Window): string {\n const screenX = Number.isFinite(win.screenX) ? win.screenX : 0;\n const screenY = Number.isFinite(win.screenY) ? win.screenY : 0;\n const outerWidth = Number.isFinite(win.outerWidth) ? win.outerWidth : POPUP_WIDTH;\n const outerHeight = Number.isFinite(win.outerHeight) ? win.outerHeight : POPUP_HEIGHT;\n const left = Math.max(0, Math.round(screenX + (outerWidth - POPUP_WIDTH) / 2));\n const top = Math.max(0, Math.round(screenY + (outerHeight - POPUP_HEIGHT) / 2));\n return `popup,width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${left},top=${top}`;\n}\n","/**\n * Onboarding opener for the Assetera Wallet: the partner side of the `/onboard` wizard (AO-1274).\n *\n * A tied-agent bank site shows a \"Create an Assetera wallet\" button. On the click, this module opens the wallet\n * pop-up in onboarding mode synchronously (so the browser treats it as part of the click) and waits for the\n * wizard to post the new wallet address back. While the pop-up is open the partner page shows a dimming\n * overlay; the overlay is plain DOM (no React, no CSS files) so any partner can drop this in. A host can give\n * the overlay its colours and radii (`OverlayTheme`), render its own dialog (`overlay: false` plus\n * `onControls`), or do both.\n *\n * The wallet's `/onboard` page is the pop-up side and speaks the same protocol in `./protocol`, but it uses the\n * message types and the `ONBOARD_PATH` from there, so the two sides cannot drift apart.\n */\nimport {\n MESSAGE_PREFIX,\n PROTOCOL_VERSION,\n RpcErrorCode,\n isAccountsMessage,\n isCaip2EvmChain,\n isOnboardCancelledMessage,\n isOnboardedMessage,\n isResponseMessage,\n onboardUrl,\n type OnboardCancelledMessage,\n type RequestMessage,\n type SignInHint,\n type WalletAccountName,\n} from \"./protocol\";\nimport { defaultPopupFeatures } from \"./popup\";\n\n/** Why {@link openAsseteraOnboarding} rejected. */\nexport type OnboardingErrorCode =\n \"popup_blocked\" | \"closed\" | \"cancelled\" | \"refused\" | \"failed\" | \"invalid_options\";\n\n/** Error thrown (well, rejected) by {@link openAsseteraOnboarding}. `code` is stable and safe to branch on. */\nexport class OnboardingError extends Error {\n readonly code: OnboardingErrorCode;\n\n constructor(code: OnboardingErrorCode, message: string) {\n super(message);\n this.name = \"OnboardingError\";\n this.code = code;\n }\n}\n\n/**\n * The client's Assetera Wallet, with the pop-up still open.\n *\n * The wallet is NOT registered with any compliance service. A regulated partner registers it itself, like any\n * other wallet: fetch a challenge for `address`, pass it to `signMessage`, send the signature to its compliance\n * service, then call `close()`. Always call `close()`: it closes the pop-up and removes the overlay.\n */\nexport interface OnboardingResult {\n address: `0x${string}`;\n chain: string;\n /** `true` when the wallet was created in this run, `false` when the client's existing wallet was returned. */\n created: boolean;\n /**\n * Ask the client to sign `message` (EIP-191 `personal_sign`) with this wallet in the open pop-up. Rejects with\n * `OnboardingError(\"cancelled\")` when the client declines, `\"closed\"` when the pop-up is gone, else `\"failed\"`.\n */\n signMessage: (message: string) => Promise<`0x${string}`>;\n /** Close the pop-up and remove the overlay. Safe to call more than once. */\n close: () => void;\n /**\n * The last account names the pop-up sent after it reported the address, or `undefined` when none arrived yet.\n * The returned list is a copy.\n */\n lastAccounts: () => WalletAccountName[] | undefined;\n}\n\n/** Text of the dimming overlay, all optional. Any key left out keeps its English default. */\nexport interface OverlayLabels {\n title?: string;\n body?: string;\n focus?: string;\n cancel?: string;\n blocked?: string;\n}\n\n/**\n * Colours, radii and font of the dimming overlay, all optional. A key left out keeps the value of the base\n * palette picked by {@link OverlayTheme.scheme} (`\"light\"` unless the host asks for `\"dark\"`).\n *\n * Every value is applied to its own CSS property with `style.setProperty`, so a value can never smuggle in a\n * second declaration. A value the browser cannot parse is dropped and the rest of the overlay stays as it is.\n */\nexport interface OverlayTheme {\n /** Base palette the other keys override. Default `\"light\"`, which is today's look, unchanged. */\n scheme?: \"light\" | \"dark\";\n /** The dimming layer behind the card, a CSS colour. */\n backdrop?: string;\n /** The card background, a CSS colour. */\n surface?: string;\n /** The title colour, a CSS colour. */\n text?: string;\n /** The body text and the Cancel button, a CSS colour. */\n mutedText?: string;\n /** The \"show the wallet window\" button background, a CSS colour. */\n primary?: string;\n /** The \"show the wallet window\" button text, a CSS colour. */\n primaryText?: string;\n /** The card border, CSS `border` shorthand. Default `\"none\"`. */\n border?: string;\n /** The card corner radius, e.g. `\"36px\"`. */\n radius?: string;\n /** The button corner radius, e.g. `\"9999px\"`. */\n buttonRadius?: string;\n /** The overlay font, CSS `font-family`. */\n fontFamily?: string;\n}\n\n/** The text of the overlay plus its optional theme. A plain {@link OverlayLabels} object still works. */\nexport interface OverlayOptions extends OverlayLabels {\n theme?: OverlayTheme;\n}\n\n/**\n * Headless handles for the open onboarding run, handed to {@link OnboardingOptions.onControls} right after the\n * pop-up opened. They let a host with `overlay: false` render its own dialog. Both are safe no-ops after the\n * run finished.\n */\nexport interface OnboardingControls {\n /** Bring the wallet pop-up to the front. */\n focus(): void;\n /** Like the overlay's Cancel button: rejects with `cancelled` before the address arrived, else `close()`. */\n cancel(): void;\n}\n\n/** Options for {@link openAsseteraOnboarding}. */\nexport interface OnboardingOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.wallet-staging.assetera.com`. */\n walletUrl: string;\n /** CAIP-2 chain id the new wallet should be created on, e.g. `eip155:80002`. An invalid value rejects with `invalid_options`. */\n chain: string;\n /** Wizard language passed as `lang`, e.g. `\"en\"` or `\"de\"`. */\n locale?: string;\n /** `window.open` feature string. Defaults to a centred `\"popup,width=440,height=760,left=…,top=…\"`. */\n popupFeatures?: string;\n /** `true` (default) shows the dimming overlay, `false` hides it, an object overrides its text and theme. */\n overlay?: boolean | OverlayOptions;\n /**\n * Called once, synchronously, right after the pop-up opened, whether or not the overlay is shown. Lets a host\n * with `overlay: false` drive the run from its own dialog.\n */\n onControls?: (controls: OnboardingControls) => void;\n /** Only used in the overlay text, e.g. `\"Musterbank\"`. */\n partnerName?: string;\n /** Ask for one more wallet even when the client already has one (\"Create another Assetera Wallet\"). */\n addWallet?: boolean;\n /** Sign-in hint passed as `signIn`, e.g. `\"assetera-marketplace\"`. Only a hint; the wallet may ignore it. */\n signIn?: SignInHint;\n /** Called for every `accounts` message the pop-up sends after it reported the address. */\n onAccounts?: (accounts: WalletAccountName[]) => void;\n /** Injectable `window` for tests; defaults to `globalThis.window`. */\n window?: Window;\n}\n\nconst POPUP_NAME = \"assetera-wallet-onboarding\";\nconst CLOSE_POLL_MS = 500;\nconst OVERLAY_Z_INDEX = 2147483000;\n\nconst DEFAULT_LABELS: Required<OverlayLabels> = {\n title: \"Continue in the Assetera Wallet window\",\n body: \"A secure Assetera Wallet window is open. Follow the steps there. This page continues by itself when you are done.\",\n focus: \"Show the wallet window\",\n cancel: \"Cancel\",\n blocked: \"Your browser blocked the Assetera Wallet window. Allow pop-ups for this site and try again.\",\n};\n\ninterface OverlayHandlers {\n onFocus: () => void;\n onCancel: () => void;\n}\n\n/** Every theme key resolved, so the overlay builder always has a value to set. */\ntype ResolvedOverlayTheme = Required<OverlayTheme>;\n\n/** Today's look, so an existing host without a theme sees no change at all. */\nconst LIGHT_THEME: ResolvedOverlayTheme = {\n scheme: \"light\",\n backdrop: \"rgba(15,20,30,0.6)\",\n surface: \"#ffffff\",\n text: \"#101828\",\n mutedText: \"#475467\",\n primary: \"#101828\",\n primaryText: \"#ffffff\",\n border: \"none\",\n radius: \"16px\",\n buttonRadius: \"10px\",\n fontFamily: \"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n};\n\n/** A neutral dark card for a dark host page. Text and buttons keep WCAG AA contrast on `surface`. */\nconst DARK_THEME: ResolvedOverlayTheme = {\n scheme: \"dark\",\n backdrop: \"rgba(8,10,14,0.72)\",\n surface: \"#1b1d24\",\n text: \"#f7f8fa\",\n mutedText: \"#9aa2b1\",\n primary: \"#ffffff\",\n primaryText: \"#101828\",\n border: \"1px solid rgba(255,255,255,0.14)\",\n radius: \"16px\",\n buttonRadius: \"10px\",\n fontFamily: \"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n};\n\n/**\n * Pick the base palette by `scheme` (default `\"light\"`) and let every key the host gave us win over it. Keys the\n * host left out keep the preset value, so `{ scheme: \"dark\", primary: \"#7b61ff\" }` only changes the button.\n */\nfunction resolveTheme(theme: OverlayTheme | undefined): ResolvedOverlayTheme {\n const base = theme?.scheme === \"dark\" ? DARK_THEME : LIGHT_THEME;\n return {\n scheme: base.scheme,\n backdrop: theme?.backdrop ?? base.backdrop,\n surface: theme?.surface ?? base.surface,\n text: theme?.text ?? base.text,\n mutedText: theme?.mutedText ?? base.mutedText,\n primary: theme?.primary ?? base.primary,\n primaryText: theme?.primaryText ?? base.primaryText,\n border: theme?.border ?? base.border,\n radius: theme?.radius ?? base.radius,\n buttonRadius: theme?.buttonRadius ?? base.buttonRadius,\n fontFamily: theme?.fontFamily ?? base.fontFamily,\n };\n}\n\nfunction resolveLabels(options: OnboardingOptions): Required<OverlayLabels> {\n const overrides: OverlayLabels =\n typeof options.overlay === \"object\" && options.overlay !== null ? options.overlay : {};\n const partnerName = options.partnerName;\n const defaultBody = partnerName\n ? `A secure Assetera Wallet window is open for ${partnerName}. Follow the steps there. This page continues by itself when you are done.`\n : DEFAULT_LABELS.body;\n return {\n title: overrides.title ?? DEFAULT_LABELS.title,\n body: overrides.body ?? defaultBody,\n focus: overrides.focus ?? DEFAULT_LABELS.focus,\n cancel: overrides.cancel ?? DEFAULT_LABELS.cancel,\n blocked: overrides.blocked ?? DEFAULT_LABELS.blocked,\n };\n}\n\nfunction resolveThemeOption(options: OnboardingOptions): ResolvedOverlayTheme {\n const overlay: OverlayOptions =\n typeof options.overlay === \"object\" && options.overlay !== null ? options.overlay : {};\n return resolveTheme(overlay.theme);\n}\n\nfunction cancelCode(reason: OnboardCancelledMessage[\"reason\"]): OnboardingErrorCode {\n if (reason === \"user\") return \"cancelled\";\n if (reason === \"refused\") return \"refused\";\n return \"failed\";\n}\n\nfunction cancelMessage(reason: OnboardCancelledMessage[\"reason\"]): string {\n if (reason === \"user\") return \"The user cancelled the Assetera Wallet onboarding.\";\n if (reason === \"refused\") return \"The Assetera Wallet refused the onboarding.\";\n return \"The Assetera Wallet onboarding failed.\";\n}\n\n/** A copy of a list of named accounts, so callers never get the opener's own list. */\nfunction copyAccountNames(accounts: readonly WalletAccountName[]): WalletAccountName[] {\n return accounts.map((account) => ({ address: account.address, name: account.name }));\n}\n\n/**\n * Build the dimming overlay. Text is inserted with `textContent` only. The layout, the z-index and the shadow\n * are fixed inline; every colour, radius and font the host may set goes through `style.setProperty` on its own\n * property, so a host value can never add a second declaration and an unparseable value is simply dropped.\n */\nfunction showOverlay(\n win: Window,\n labels: Required<OverlayLabels>,\n theme: ResolvedOverlayTheme,\n handlers: OverlayHandlers,\n): HTMLElement {\n const doc = win.document;\n const root = doc.createElement(\"div\");\n root.setAttribute(\"role\", \"dialog\");\n root.setAttribute(\"aria-modal\", \"true\");\n root.setAttribute(\"data-assetera-onboarding-overlay\", \"\");\n root.style.cssText = [\n \"position: fixed\",\n \"inset: 0\",\n \"display: flex\",\n \"align-items: center\",\n \"justify-content: center\",\n \"padding: 24px\",\n \"box-sizing: border-box\",\n `z-index: ${OVERLAY_Z_INDEX}`,\n ].join(\"; \");\n root.style.setProperty(\"background-color\", theme.backdrop);\n root.style.setProperty(\"font-family\", theme.fontFamily);\n\n const card = doc.createElement(\"div\");\n card.style.cssText = [\n \"box-sizing: border-box\",\n \"width: 100%\",\n \"max-width: 420px\",\n \"padding: 24px\",\n \"box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35)\",\n ].join(\"; \");\n card.style.setProperty(\"background-color\", theme.surface);\n card.style.setProperty(\"color\", theme.text);\n card.style.setProperty(\"border\", theme.border);\n card.style.setProperty(\"border-radius\", theme.radius);\n\n const title = doc.createElement(\"h2\");\n title.textContent = labels.title;\n title.style.cssText = \"margin: 0 0 10px; font-size: 18px; line-height: 1.3; font-weight: 600;\";\n title.style.setProperty(\"color\", theme.text);\n\n const body = doc.createElement(\"p\");\n body.textContent = labels.body;\n body.style.cssText = \"margin: 0 0 20px; font-size: 14px; line-height: 1.5;\";\n body.style.setProperty(\"color\", theme.mutedText);\n\n const focus = doc.createElement(\"button\");\n focus.type = \"button\";\n focus.textContent = labels.focus;\n focus.style.cssText = [\n \"padding: 10px 16px\",\n \"border: 0\",\n \"font: inherit\",\n \"font-weight: 600\",\n \"cursor: pointer\",\n ].join(\"; \");\n focus.style.setProperty(\"background-color\", theme.primary);\n focus.style.setProperty(\"color\", theme.primaryText);\n focus.style.setProperty(\"border-radius\", theme.buttonRadius);\n focus.addEventListener(\"click\", handlers.onFocus);\n\n const cancel = doc.createElement(\"button\");\n cancel.type = \"button\";\n cancel.textContent = labels.cancel;\n cancel.style.cssText = [\n \"padding: 10px 16px\",\n \"border: 0\",\n \"border-radius: 10px\",\n \"background: transparent\",\n \"font: inherit\",\n \"cursor: pointer\",\n ].join(\"; \");\n cancel.style.setProperty(\"color\", theme.mutedText);\n cancel.style.setProperty(\"border-radius\", theme.buttonRadius);\n cancel.addEventListener(\"click\", handlers.onCancel);\n\n const actions = doc.createElement(\"div\");\n actions.style.cssText = \"display: flex; gap: 8px; align-items: center;\";\n actions.append(focus, cancel);\n\n card.append(title, body, actions);\n root.append(card);\n doc.body.append(root);\n return root;\n}\n\n/**\n * Open the Assetera Wallet onboarding wizard in a pop-up and resolve with the client's wallet, the pop-up still\n * open so the partner can ask for the ownership signature (see {@link OnboardingResult}).\n *\n * Call this from a user click (a button handler). `window.open` runs synchronously inside the call, before any\n * `await`, so the browser allows it; if the browser blocks the pop-up the promise rejects with\n * `OnboardingError(\"popup_blocked\")` and no overlay is shown.\n *\n * The promise rejects with `OnboardingError` and one of these codes: `invalid_options` (bad chain or wallet\n * URL), `popup_blocked`, `closed` (the pop-up was closed first), `cancelled` (the user cancelled in the wizard\n * or in the overlay), `refused` (the wallet refused the onboarding) or `failed` (anything else in the wallet).\n * After it resolved, the overlay stays until `close()`; closing the pop-up by hand also removes it. After it\n * reported the address the pop-up may send `accounts` messages; `onAccounts` receives each list and\n * `lastAccounts()` returns the last one.\n *\n * `overlay` accepts `true` (default), `false`, or an {@link OverlayOptions} object with the overlay text and an\n * {@link OverlayTheme}. With `overlay: false` a host can render its own dialog: {@link OnboardingOptions.onControls}\n * is called once, synchronously, right after the pop-up opened, and its `focus()` and `cancel()` behave like the\n * overlay buttons.\n */\nexport function openAsseteraOnboarding(options: OnboardingOptions): Promise<OnboardingResult> {\n const requestedWindow = options.window ?? (typeof window === \"undefined\" ? undefined : window);\n if (!requestedWindow) {\n return Promise.reject(\n new OnboardingError(\"invalid_options\", \"The Assetera Wallet onboarding can only run in a browser.\"),\n );\n }\n // A non-optional alias so TypeScript keeps the narrowed type inside the callbacks below.\n const targetWindow: Window = requestedWindow;\n if (!isCaip2EvmChain(options.chain)) {\n return Promise.reject(\n new OnboardingError(\n \"invalid_options\",\n `\"${options.chain}\" is not a CAIP-2 EVM chain id (for example \"eip155:80002\").`,\n ),\n );\n }\n let walletOrigin: string;\n try {\n walletOrigin = new URL(options.walletUrl).origin;\n } catch {\n return Promise.reject(\n new OnboardingError(\"invalid_options\", `\"${options.walletUrl}\" is not a valid wallet URL.`),\n );\n }\n\n const labels = resolveLabels(options);\n const theme = resolveThemeOption(options);\n const overlayEnabled = options.overlay !== false;\n\n // MUST stay synchronous, before the first await, so the pop-up runs inside the caller's user activation.\n const popup = targetWindow.open(\n onboardUrl(options.walletUrl, targetWindow.location.origin, {\n chain: options.chain,\n ...(options.locale === undefined ? {} : { locale: options.locale }),\n ...(options.addWallet ? { add: true } : {}),\n ...(options.signIn === undefined ? {} : { signIn: options.signIn }),\n }),\n POPUP_NAME,\n options.popupFeatures ?? defaultPopupFeatures(targetWindow),\n );\n\n if (!popup) {\n // Nothing was opened, so there is nothing to wait for and no overlay: the partner page stays usable.\n return Promise.reject(new OnboardingError(\"popup_blocked\", labels.blocked));\n }\n // A non-optional alias so TypeScript keeps the narrowed type inside the callbacks below.\n const activePopup: Window = popup;\n\n return new Promise<OnboardingResult>((resolve, reject) => {\n // Phase 1 waits for `onboarded`; phase 2 (after it) keeps the pop-up for signature requests until `close()`.\n let onboarded = false;\n let finished = false;\n let closeTimer: ReturnType<typeof setInterval> | null = null;\n let overlay: HTMLElement | null = null;\n const pending = new Map<\n string,\n { resolve: (signature: `0x${string}`) => void; reject: (error: OnboardingError) => void }\n >();\n\n function cleanup(): void {\n finished = true;\n targetWindow.removeEventListener(\"message\", onMessage);\n if (closeTimer !== null) {\n clearInterval(closeTimer);\n closeTimer = null;\n }\n overlay?.remove();\n overlay = null;\n }\n\n function failPending(error: OnboardingError): void {\n for (const entry of pending.values()) entry.reject(error);\n pending.clear();\n }\n\n function close(): void {\n if (finished) return;\n failPending(new OnboardingError(\"closed\", \"The Assetera Wallet window was closed.\"));\n cleanup();\n if (!activePopup.closed) activePopup.close();\n }\n\n function fail(error: OnboardingError): void {\n if (onboarded || finished) return;\n cleanup();\n reject(error);\n }\n\n function cancel(): void {\n if (onboarded) {\n close();\n return;\n }\n activePopup.close();\n fail(new OnboardingError(\"cancelled\", \"The user cancelled the Assetera Wallet onboarding.\"));\n }\n\n // Handed to `onControls` and used by the overlay buttons. Both stay no-ops once the run finished.\n const controls: OnboardingControls = {\n focus(): void {\n if (finished) return;\n activePopup.focus();\n },\n cancel(): void {\n if (finished) return;\n cancel();\n },\n };\n\n function signMessage(message: string): Promise<`0x${string}`> {\n if (finished || activePopup.closed) {\n return Promise.reject(new OnboardingError(\"closed\", \"The Assetera Wallet window was closed.\"));\n }\n const id = globalThis.crypto.randomUUID();\n const request: RequestMessage = {\n type: `${MESSAGE_PREFIX}request`,\n v: PROTOCOL_VERSION,\n id,\n method: \"personal_sign\",\n params: [message, address as `0x${string}`],\n };\n return new Promise((resolveSign, rejectSign) => {\n pending.set(id, { resolve: resolveSign, reject: rejectSign });\n activePopup.focus();\n activePopup.postMessage(request, walletOrigin);\n });\n }\n\n // Set with `onboarded`; `signMessage` is only handed out after that.\n let address: `0x${string}` | undefined;\n /** The last account names the pop-up sent after `onboarded`; kept until `close()`. */\n let lastAccountNameList: WalletAccountName[] | undefined;\n\n function onMessage(event: MessageEvent): void {\n // Trust rule: accept only the wallet origin AND the exact pop-up we opened. Ignore everything else.\n if (event.origin !== walletOrigin) return;\n if ((event.source as unknown) !== activePopup) return;\n const data: unknown = event.data;\n if (!onboarded) {\n if (isOnboardedMessage(data)) {\n onboarded = true;\n address = data.address;\n resolve({\n address: data.address,\n chain: data.chain,\n created: data.created ?? true,\n signMessage,\n close,\n lastAccounts: () =>\n lastAccountNameList === undefined ? undefined : copyAccountNames(lastAccountNameList),\n });\n return;\n }\n if (isOnboardCancelledMessage(data)) {\n fail(new OnboardingError(cancelCode(data.reason), data.message ?? cancelMessage(data.reason)));\n }\n return;\n }\n if (isAccountsMessage(data)) {\n lastAccountNameList = copyAccountNames(data.data);\n options.onAccounts?.(copyAccountNames(lastAccountNameList));\n return;\n }\n if (isResponseMessage(data)) {\n const entry = pending.get(data.id);\n if (!entry) return;\n pending.delete(data.id);\n if (\"error\" in data) {\n entry.reject(\n new OnboardingError(\n data.error.code === RpcErrorCode.UserRejected ? \"cancelled\" : \"failed\",\n data.error.message,\n ),\n );\n } else if (typeof data.result === \"string\" && /^0x[0-9a-fA-F]+$/.test(data.result)) {\n entry.resolve(data.result as `0x${string}`);\n } else {\n entry.reject(new OnboardingError(\"failed\", \"The Assetera Wallet returned no signature.\"));\n }\n }\n }\n\n targetWindow.addEventListener(\"message\", onMessage);\n closeTimer = setInterval(() => {\n if (!activePopup.closed) return;\n if (onboarded) {\n close();\n return;\n }\n fail(\n new OnboardingError(\"closed\", \"The Assetera Wallet window was closed before onboarding finished.\"),\n );\n }, CLOSE_POLL_MS);\n\n if (overlayEnabled) {\n overlay = showOverlay(targetWindow, labels, theme, {\n onFocus: () => controls.focus(),\n onCancel: () => controls.cancel(),\n });\n }\n // After the overlay, so a host that renders its own dialog already sees it (or knows there is none). The\n // call is synchronous, like the `window.open` above: the promise settles only in a later tick.\n options.onControls?.(controls);\n });\n}\n","/**\n * Manage-wallet opener for the Assetera Wallet: the partner side of the `/manage` pop-up (AO-1436).\n *\n * A partner page shows a \"Manage wallet\" button. On the click this module opens the wallet pop-up on the manage\n * route synchronously (so the browser treats it as part of the click). The client sees the wallet accounts and\n * the wallet security (passkeys, authenticator app, recovery codes) and can change them. The pop-up never\n * answers `request` messages; it posts `security` and `accounts` messages while it is open.\n */\nimport {\n isAccountsMessage,\n isSecurityMessage,\n manageUrl,\n type SignInHint,\n type WalletAccountName,\n type WalletSecurityStatus,\n} from \"./protocol\";\nimport { defaultPopupFeatures } from \"./popup\";\n\n/** Why {@link openAsseteraWalletManager} threw. */\nexport type ManagerErrorCode = \"popup_blocked\" | \"invalid_options\";\n\n/** Error thrown by {@link openAsseteraWalletManager}. `code` is stable and safe to branch on. */\nexport class ManagerError extends Error {\n readonly code: ManagerErrorCode;\n\n constructor(code: ManagerErrorCode, message: string) {\n super(message);\n this.name = \"ManagerError\";\n this.code = code;\n }\n}\n\n/** Options for {@link openAsseteraWalletManager}. */\nexport interface WalletManagerOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.wallet-staging.assetera.com`. */\n walletUrl: string;\n /** Sign-in hint passed as `signIn`, e.g. `\"assetera-marketplace\"`. Only a hint; the wallet may ignore it. */\n signIn?: SignInHint;\n /** Language passed as `lang`, e.g. `\"en\"` or `\"de\"`. */\n locale?: string;\n /** `window.open` feature string. Defaults to a centred `\"popup,width=440,height=760,left=…,top=…\"`. */\n popupFeatures?: string;\n /** Called for every `security` message from the pop-up. */\n onSecurity?: (status: WalletSecurityStatus) => void;\n /** Called for every `accounts` message from the pop-up. */\n onAccounts?: (accounts: WalletAccountName[]) => void;\n /** Injectable `window` for tests; defaults to `globalThis.window`. */\n window?: Window;\n}\n\n/** The open manage pop-up, controlled by the partner. */\nexport interface WalletManager {\n /** Close the pop-up and remove the listener and the close timer. Safe to call more than once. */\n close: () => void;\n /** Resolves when the pop-up is closed, by the partner or by the client. */\n closed: Promise<void>;\n /** The last security status the pop-up sent, or `undefined` when none arrived yet. */\n lastSecurity: () => WalletSecurityStatus | undefined;\n /** The last account names the pop-up sent, or `undefined` when none arrived yet. */\n lastAccounts: () => WalletAccountName[] | undefined;\n}\n\nconst POPUP_NAME = \"assetera-wallet-manage\";\nconst CLOSE_POLL_MS = 500;\n\n/**\n * Open the manage-wallet pop-up for the Assetera Wallet and return a handle to it.\n *\n * Call this from a user click (a button handler). `window.open` runs synchronously inside the call, before any\n * `await`, so the browser allows it; when the browser blocks the pop-up this throws `ManagerError` with code\n * `popup_blocked`.\n *\n * The pop-up checks the `origin` query parameter against the wallet's partner list, posts `ready` to\n * `window.opener` and then posts `security` and `accounts` messages. Messages are accepted only when they come\n * from the wallet origin AND from the pop-up that was opened here. The pop-up does not answer `request`\n * messages.\n */\nexport function openAsseteraWalletManager(options: WalletManagerOptions): WalletManager {\n const requestedWindow = options.window ?? (typeof window === \"undefined\" ? undefined : window);\n if (!requestedWindow) {\n throw new ManagerError(\"invalid_options\", \"The Assetera Wallet manager can only run in a browser.\");\n }\n // A non-optional alias so TypeScript keeps the narrowed type inside the callbacks below.\n const targetWindow: Window = requestedWindow;\n let walletOrigin: string;\n try {\n walletOrigin = new URL(options.walletUrl).origin;\n } catch {\n throw new ManagerError(\"invalid_options\", `\"${options.walletUrl}\" is not a valid wallet URL.`);\n }\n\n // MUST stay synchronous, before any await, so the pop-up runs inside the caller's user activation.\n const popup = targetWindow.open(\n manageUrl(options.walletUrl, targetWindow.location.origin, {\n ...(options.locale === undefined ? {} : { locale: options.locale }),\n ...(options.signIn === undefined ? {} : { signIn: options.signIn }),\n }),\n POPUP_NAME,\n options.popupFeatures ?? defaultPopupFeatures(targetWindow),\n );\n\n if (!popup) {\n throw new ManagerError(\n \"popup_blocked\",\n \"Your browser blocked the Assetera Wallet window. Allow pop-ups for this site and try again.\",\n );\n }\n // A non-optional alias so TypeScript keeps the narrowed type inside the callbacks below.\n const activePopup: Window = popup;\n\n let finished = false;\n let lastSecurity: WalletSecurityStatus | undefined;\n let lastAccounts: WalletAccountName[] | undefined;\n let closeTimer: ReturnType<typeof setInterval> | null = null;\n let resolveClosed!: () => void;\n const closed = new Promise<void>((resolve) => {\n resolveClosed = resolve;\n });\n\n function cleanup(): void {\n if (finished) return;\n finished = true;\n targetWindow.removeEventListener(\"message\", onMessage);\n if (closeTimer !== null) {\n clearInterval(closeTimer);\n closeTimer = null;\n }\n resolveClosed();\n }\n\n function close(): void {\n cleanup();\n if (!activePopup.closed) activePopup.close();\n }\n\n /** A copy of a list of named accounts, so callers never get the manager's own list. */\n function copyAccountNames(accounts: readonly WalletAccountName[]): WalletAccountName[] {\n return accounts.map((account) => ({ address: account.address, name: account.name }));\n }\n\n function onMessage(event: MessageEvent): void {\n // Trust rule: accept only the wallet origin AND the exact pop-up we opened. Ignore everything else.\n if (event.origin !== walletOrigin) return;\n if ((event.source as unknown) !== activePopup) return;\n const data: unknown = event.data;\n if (isSecurityMessage(data)) {\n const status: WalletSecurityStatus = {\n protection: data.data.protection,\n passkeys: data.data.passkeys,\n authenticatorApps: data.data.authenticatorApps,\n };\n lastSecurity = status;\n options.onSecurity?.(status);\n return;\n }\n if (isAccountsMessage(data)) {\n lastAccounts = copyAccountNames(data.data);\n options.onAccounts?.(copyAccountNames(lastAccounts));\n }\n }\n\n targetWindow.addEventListener(\"message\", onMessage);\n closeTimer = setInterval(() => {\n if (activePopup.closed) cleanup();\n }, CLOSE_POLL_MS);\n\n return {\n close,\n closed,\n lastSecurity: () => lastSecurity,\n lastAccounts: () => (lastAccounts === undefined ? undefined : copyAccountNames(lastAccounts)),\n };\n}\n"]}
|
package/dist/protocol.cjs
CHANGED
|
@@ -10,6 +10,7 @@ function isSignInHint(value) {
|
|
|
10
10
|
return SIGN_IN_HINTS.includes(value);
|
|
11
11
|
}
|
|
12
12
|
var MESSAGE_PREFIX = "assetera-wallet:";
|
|
13
|
+
var HOLD_MAX_MS = 3e5;
|
|
13
14
|
var SUPPORTED_METHODS = [
|
|
14
15
|
"eth_requestAccounts",
|
|
15
16
|
"eth_accounts",
|
|
@@ -95,6 +96,9 @@ function isRequestMessage(value) {
|
|
|
95
96
|
function isDisconnectMessage(value) {
|
|
96
97
|
return hasType(value, "disconnect");
|
|
97
98
|
}
|
|
99
|
+
function isHoldMessage(value) {
|
|
100
|
+
return hasType(value, "hold") && typeof value.hold === "boolean";
|
|
101
|
+
}
|
|
98
102
|
var EVM_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
99
103
|
function isOnboardedMessage(value) {
|
|
100
104
|
return hasType(value, "onboarded") && typeof value.address === "string" && EVM_ADDRESS_RE.test(value.address) && typeof value.chain === "string" && // `created` is new; an older wallet sent `status` instead and always created or reused a wallet.
|
|
@@ -133,6 +137,7 @@ function manageUrl(walletUrl, partnerOrigin, options = {}) {
|
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
exports.CONNECT_PATH = CONNECT_PATH;
|
|
140
|
+
exports.HOLD_MAX_MS = HOLD_MAX_MS;
|
|
136
141
|
exports.MANAGE_PATH = MANAGE_PATH;
|
|
137
142
|
exports.MESSAGE_PREFIX = MESSAGE_PREFIX;
|
|
138
143
|
exports.ONBOARD_PATH = ONBOARD_PATH;
|
|
@@ -145,6 +150,7 @@ exports.isAccountsMessage = isAccountsMessage;
|
|
|
145
150
|
exports.isCaip2EvmChain = isCaip2EvmChain;
|
|
146
151
|
exports.isDisconnectMessage = isDisconnectMessage;
|
|
147
152
|
exports.isEventMessage = isEventMessage;
|
|
153
|
+
exports.isHoldMessage = isHoldMessage;
|
|
148
154
|
exports.isOnboardCancelledMessage = isOnboardCancelledMessage;
|
|
149
155
|
exports.isOnboardedMessage = isOnboardedMessage;
|
|
150
156
|
exports.isReadyMessage = isReadyMessage;
|