@ultraos/wallet-sdk 0.6.0 → 0.6.1
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/CHANGELOG.md +23 -3
- package/LICENSE +165 -0
- package/README.md +2 -2
- package/dist/index.mjs +33 -14
- package/dist/index.mjs.map +2 -2
- package/package.json +4 -2
- package/src/index.d.ts +2 -2
- package/src/lib/common/client-error.d.ts +1 -1
- package/src/lib/common/client-messenger.d.ts +3 -2
- package/src/lib/common/client-messenger.d.ts.map +1 -1
- package/src/lib/common/client-messenger.js +24 -12
- package/src/lib/common/client-messenger.js.map +1 -1
- package/src/lib/common/window-manager.d.ts +3 -2
- package/src/lib/common/window-manager.d.ts.map +1 -1
- package/src/lib/common/window-manager.js.map +1 -1
- package/src/lib/config/ultra-wallet-sdk.config.d.ts +2 -1
- package/src/lib/config/ultra-wallet-sdk.config.d.ts.map +1 -1
- package/src/lib/config/ultra-wallet-sdk.config.js +2 -1
- package/src/lib/config/ultra-wallet-sdk.config.js.map +1 -1
- package/src/lib/interfaces/error-enum.d.ts +1 -0
- package/src/lib/interfaces/error-enum.d.ts.map +1 -1
- package/src/lib/interfaces/error-enum.js +2 -0
- package/src/lib/interfaces/error-enum.js.map +1 -1
- package/src/lib/interfaces/index.d.ts +7 -7
- package/src/lib/interfaces/wallet-provider-response.interface.d.ts +4 -0
- package/src/lib/interfaces/wallet-provider-response.interface.d.ts.map +1 -1
- package/src/lib/interfaces/wallet-provider-response.interface.js.map +1 -1
- package/src/lib/interfaces/wallet-provider.interface.d.ts +4 -4
- package/src/lib/providers/extension-provider/extension.provider.d.ts +1 -1
- package/src/lib/providers/index.d.ts +2 -2
- package/src/lib/providers/web-provider/web.provider.d.ts +5 -1
- package/src/lib/providers/web-provider/web.provider.d.ts.map +1 -1
- package/src/lib/providers/web-provider/web.provider.js +9 -2
- package/src/lib/providers/web-provider/web.provider.js.map +1 -1
- package/src/lib/ultra-wallet-sdk.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@ultraos/wallet-sdk` are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.6.1
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- `environment: 'testnet'` with the Web Wallet provider now rejects immediately with the new
|
|
10
|
+
`SdkErrorCode.WEB_WALLET_UNAVAILABLE` (4302) instead of opening a popup to the decommissioned
|
|
11
|
+
`web-wallet.staging.ultra.io`. Testnet is supported through the browser extension; `getChainId()` still answers
|
|
12
|
+
locally.
|
|
13
|
+
- Web Wallet JSON-RPC errors (for example calling an extension-only method such as `getAccounts()` with the Web Wallet
|
|
14
|
+
provider) rejected with `undefined`. They now reject with the wallet's `{ status: 'error', code, message }`
|
|
15
|
+
(`UNKNOWN_ERROR` -32604 when the error has no code), and the SDK closes the popup so the next request is not left
|
|
16
|
+
waiting for a `ready` handshake that never comes.
|
|
17
|
+
- Type declarations use explicit `.js` specifiers, so they resolve under TypeScript `moduleResolution: node16/nodenext`
|
|
18
|
+
(previously every export was reported missing).
|
|
19
|
+
- The package now declares `"license": "LGPL-3.0-only"` and ships the `LICENSE` file.
|
|
20
|
+
- CI publishing (`release:wallet-sdk` → `nx-release-publish`) now publishes the packaged `dist/libs/wallet-sdk` (via the
|
|
21
|
+
new `wallet-sdk:package` target) instead of the raw library folder.
|
|
22
|
+
|
|
5
23
|
## 0.6.0
|
|
6
24
|
|
|
25
|
+
0.4.0 and 0.5.0 were never published to npm; their changes (below) first shipped in 0.6.0.
|
|
26
|
+
|
|
7
27
|
### Removed
|
|
8
28
|
|
|
9
29
|
- `purchaseItem()` and the `PurchaseItemType` / `PurchaseItemResult` types. Neither wallet serves it any more: the
|
|
@@ -18,9 +38,9 @@ All notable changes to `@ultraos/wallet-sdk` are documented in this file.
|
|
|
18
38
|
- Corrected the `ConnectResult.blockchainid` documentation: it is the connected account **name** (equal to
|
|
19
39
|
`selectedAccount.accountName`), not a network identifier.
|
|
20
40
|
- Declared the `nonce` / `signedNonce` fields every wallet already returns from `connect({ nonce })`.
|
|
21
|
-
- Marked the connect-time attestation surface (`ConnectAttestation`, `
|
|
22
|
-
`ConnectParams.requireAttestation`) `@experimental`: only the browser extension issues it
|
|
23
|
-
consumes it yet.
|
|
41
|
+
- Marked the connect-time attestation surface (`ConnectAttestation`, `AttestationPayload`, `SignableAccount`,
|
|
42
|
+
`ConnectResult.attestation`, `ConnectParams.requireAttestation`) `@experimental`: only the browser extension issues it
|
|
43
|
+
and no Ultra service consumes it yet.
|
|
24
44
|
- Published as a bundled ES module (`dist/index.mjs` + `exports` map), as in 0.3.2, now produced reproducibly by
|
|
25
45
|
`npm run build:wallet-sdk`.
|
|
26
46
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
CHANGED
|
@@ -7,8 +7,8 @@ browser extension or via a web fallback.
|
|
|
7
7
|
|
|
8
8
|
- Automatically detects and uses the Ultra Wallet Extension if available.
|
|
9
9
|
- Falls back to a Web Wallet if the extension is not installed.
|
|
10
|
-
- Connect, sign messages
|
|
11
|
-
- Environment support: `mainnet`, `testnet
|
|
10
|
+
- Connect, sign messages and sign transactions with a simple API.
|
|
11
|
+
- Environment support: `mainnet`, `testnet` (browser extension only), or a custom Web Wallet URL.
|
|
12
12
|
|
|
13
13
|
## 📦 Installation
|
|
14
14
|
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@ var SdkErrorCode;
|
|
|
4
4
|
SdkErrorCode2[SdkErrorCode2["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
|
|
5
5
|
SdkErrorCode2[SdkErrorCode2["WALLET_HANDSHAKE_TIMEOUT"] = 4300] = "WALLET_HANDSHAKE_TIMEOUT";
|
|
6
6
|
SdkErrorCode2[SdkErrorCode2["WALLET_WINDOW_UNAVAILABLE"] = 4301] = "WALLET_WINDOW_UNAVAILABLE";
|
|
7
|
+
SdkErrorCode2[SdkErrorCode2["WEB_WALLET_UNAVAILABLE"] = 4302] = "WEB_WALLET_UNAVAILABLE";
|
|
7
8
|
SdkErrorCode2[SdkErrorCode2["REQUESTED_RESOURCE_NOT_AVAILABLE"] = 32002] = "REQUESTED_RESOURCE_NOT_AVAILABLE";
|
|
8
9
|
SdkErrorCode2[SdkErrorCode2["UNKNOWN_ERROR"] = -32604] = "UNKNOWN_ERROR";
|
|
9
10
|
})(SdkErrorCode || (SdkErrorCode = {}));
|
|
@@ -11,6 +12,7 @@ var SDK_ERROR_MESSAGE = {
|
|
|
11
12
|
[SdkErrorCode.USER_REJECTED_REQUEST]: "The user rejected the request.",
|
|
12
13
|
[SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT]: "Timeout to connect with the web wallet.",
|
|
13
14
|
[SdkErrorCode.WALLET_WINDOW_UNAVAILABLE]: "Wallet window blocked by browser or failed to open.",
|
|
15
|
+
[SdkErrorCode.WEB_WALLET_UNAVAILABLE]: "The Ultra Web Wallet is not available on this network. Use the Ultra Wallet browser extension.",
|
|
14
16
|
[SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE]: "Requested resource not available.",
|
|
15
17
|
[SdkErrorCode.UNKNOWN_ERROR]: "Unknown error occurred."
|
|
16
18
|
};
|
|
@@ -29,7 +31,8 @@ var UltraWalletSdkConfig = Object.freeze({
|
|
|
29
31
|
height: 815,
|
|
30
32
|
walletUrls: {
|
|
31
33
|
mainnet: "https://web-wallet.ultra.io",
|
|
32
|
-
testnet
|
|
34
|
+
// The testnet Web Wallet (web-wallet.staging.ultra.io) was decommissioned; testnet is extension-only.
|
|
35
|
+
testnet: null
|
|
33
36
|
},
|
|
34
37
|
networkInfo: {
|
|
35
38
|
mainnet: {
|
|
@@ -280,6 +283,9 @@ var ClientMessenger = class {
|
|
|
280
283
|
});
|
|
281
284
|
}
|
|
282
285
|
async sendRequest(requestMethod, requestParams) {
|
|
286
|
+
if (!this.windowManager.walletUrl) {
|
|
287
|
+
throw this.createErrorResponse(SdkErrorCode.WEB_WALLET_UNAVAILABLE);
|
|
288
|
+
}
|
|
283
289
|
if (this.pendingRequest && !this.isWalletWindowClosed()) {
|
|
284
290
|
throw this.createErrorResponse(SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE);
|
|
285
291
|
}
|
|
@@ -340,18 +346,13 @@ var ClientMessenger = class {
|
|
|
340
346
|
try {
|
|
341
347
|
result = await this.rpcClient.request(requestMethod, requestParams);
|
|
342
348
|
} catch (error) {
|
|
343
|
-
|
|
344
|
-
throw
|
|
345
|
-
status: ResponseStatus.ERROR,
|
|
346
|
-
...clientError
|
|
347
|
-
};
|
|
348
|
-
} finally {
|
|
349
|
-
if (result?.status === ResponseStatus.SUCCESS) {
|
|
350
|
-
return result;
|
|
351
|
-
} else {
|
|
352
|
-
throw result;
|
|
353
|
-
}
|
|
349
|
+
walletWindow.close();
|
|
350
|
+
throw this.createRpcErrorResponse(error);
|
|
354
351
|
}
|
|
352
|
+
if (result?.status === ResponseStatus.SUCCESS) {
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
throw result;
|
|
355
356
|
});
|
|
356
357
|
}
|
|
357
358
|
async withWindowMonitoring(walletWindow, operation) {
|
|
@@ -377,6 +378,19 @@ var ClientMessenger = class {
|
|
|
377
378
|
const msg = event.data;
|
|
378
379
|
return msg?.jsonrpc === "2.0" && msg.method === "ready";
|
|
379
380
|
}
|
|
381
|
+
createRpcErrorResponse(error) {
|
|
382
|
+
const { code, message } = error ?? {};
|
|
383
|
+
if (typeof code === "number") {
|
|
384
|
+
return {
|
|
385
|
+
status: ResponseStatus.ERROR,
|
|
386
|
+
code,
|
|
387
|
+
message: typeof message === "string" ? message : "",
|
|
388
|
+
data: error.data
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const clientError = new ClientError(SdkErrorCode.UNKNOWN_ERROR);
|
|
392
|
+
return { status: ResponseStatus.ERROR, code: clientError.code, message: clientError.message, data: error };
|
|
393
|
+
}
|
|
380
394
|
createErrorResponse(errorCode) {
|
|
381
395
|
const { code, message } = new ClientError(errorCode);
|
|
382
396
|
return { status: ResponseStatus.ERROR, code, message, data: null };
|
|
@@ -472,9 +486,14 @@ var WebProvider = class {
|
|
|
472
486
|
}
|
|
473
487
|
dispose() {
|
|
474
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Built-in networks map to their configured Web Wallet URL (`null` when none is deployed);
|
|
491
|
+
* any other `environment` value is a custom Web Wallet URL.
|
|
492
|
+
*/
|
|
475
493
|
resolveWalletUrl() {
|
|
476
|
-
const
|
|
477
|
-
|
|
494
|
+
const environment = this.options?.environment || "mainnet";
|
|
495
|
+
const { walletUrls } = ultra_wallet_sdk_config_default;
|
|
496
|
+
return Object.prototype.hasOwnProperty.call(walletUrls, environment) ? walletUrls[environment] : environment;
|
|
478
497
|
}
|
|
479
498
|
};
|
|
480
499
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../libs/wallet-sdk/src/lib/interfaces/error-enum.ts", "../../../../libs/wallet-sdk/src/lib/interfaces/wallet-provider-response.interface.ts", "../../../../libs/wallet-sdk/src/lib/config/ultra-wallet-sdk.config.ts", "../../../../libs/wallet-sdk/src/lib/utils/chain-validator.ts", "../../../../libs/wallet-sdk/src/lib/providers/extension-provider/extension.provider.ts", "../../../../libs/wallet-sdk/src/lib/common/client-messenger.ts", "../../../../libs/wallet-sdk/src/lib/common/client-error.ts", "../../../../libs/wallet-sdk/src/lib/common/window-manager.ts", "../../../../libs/wallet-sdk/src/lib/providers/web-provider/web.provider.ts", "../../../../libs/wallet-sdk/src/lib/utils/detection.ts", "../../../../libs/wallet-sdk/src/lib/ultra-wallet-sdk.ts"],
|
|
4
|
-
"sourcesContent": ["export enum SdkErrorCode {\n USER_REJECTED_REQUEST = 4001,\n WALLET_HANDSHAKE_TIMEOUT = 4300,\n WALLET_WINDOW_UNAVAILABLE = 4301,\n REQUESTED_RESOURCE_NOT_AVAILABLE = 32002,\n UNKNOWN_ERROR = -32604,\n}\n\nexport const SDK_ERROR_MESSAGE: { [key in SdkErrorCode]: string } = {\n [SdkErrorCode.USER_REJECTED_REQUEST]: 'The user rejected the request.',\n [SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT]: 'Timeout to connect with the web wallet.',\n [SdkErrorCode.WALLET_WINDOW_UNAVAILABLE]: 'Wallet window blocked by browser or failed to open.',\n [SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE]: 'Requested resource not available.',\n [SdkErrorCode.UNKNOWN_ERROR]: 'Unknown error occurred.',\n};\n", "/**\n * A generic wrapper for all Ultra Wallet SDK responses.\n * Encapsulates the status, data payload, and optional error messaging or codes.\n *\n * @template T The type of the data payload contained in the response.\n */\nexport interface UltraResponse<T = any> {\n /**\n * The status of the response, e.g., success, fail, or error.\n */\n status: ResponseStatus;\n /**\n * The actual response data payload.\n */\n data: T;\n /**\n * Optional end-user-readable message, explaining what went wrong (if applicable).\n */\n message?: string;\n /**\n * Optional error or status code.\n */\n code?: number;\n}\n\n/**\n * Enumeration of possible response statuses returned by the Ultra Wallet SDK.\n */\nexport enum ResponseStatus {\n SUCCESS = 'success',\n FAIL = 'fail',\n ERROR = 'error',\n}\n\n/**\n * Represents the result of a disconnect request.\n * A boolean indicating whether the disconnection was successful.\n */\nexport type DisconnectResponse = boolean;\n\n/**\n * Represents a single permission entry associated with a blockchain account.\n */\nexport interface PermissionInfo {\n /**\n * The permission level name (e.g., \"active\", \"owner\").\n */\n name: string;\n /**\n * The public keys associated with this permission.\n */\n publicKeys: string[];\n}\n\n/**\n * Represents a blockchain account with its associated permissions.\n */\nexport interface AccountInfo {\n /**\n * The blockchain account name.\n */\n accountName: string;\n /**\n * The list of permissions associated with this account.\n */\n permissions: PermissionInfo[];\n}\n\n/**\n * Represents information about the connected blockchain network.\n */\nexport interface NetworkInfo {\n /**\n * The human-readable name of the network (e.g., \"mainnet\", \"testnet\").\n */\n name: string;\n /**\n * The unique chain identifier.\n */\n chainId: string;\n}\n\n/**\n * Extended network information including connection details.\n * Returned by getNetwork and getNetworks.\n */\nexport interface NetworkDetails {\n /**\n * The human-readable name of the network (e.g., \"mainnet\", \"testnet\").\n */\n name: string;\n /**\n * The unique chain identifier.\n */\n chainId: string;\n /**\n * The RPC node URL for the network.\n */\n nodeUrl: string;\n /**\n * Whether this is a user-defined custom network.\n */\n isCustom?: boolean;\n}\n\n/**\n * One account the wallet currently holds signing keys for, plus the permission\n * names whose keys it controls. Sourced from the same set the wallet exposes via\n * `ConnectResult.accounts` — never an FE-supplied (spoofable) list (RFC §2.1 / §5.6).\n */\nexport interface SignableAccount {\n /** The blockchain account name. */\n account: string;\n /** The permission names the wallet holds the signing key for (e.g. `active`). */\n permissions: string[];\n}\n\n/**\n * The signed payload of a connect-time identity attestation (RFC §2.1). The canonical\n * form — JSON with sorted keys, UTF-8 encoded, SHA-256 hashed — is what the wallet signs.\n */\nexport interface AttestationPayload {\n /** Attestation format version. */\n v: 1;\n /** The signing public key (e.g. `EOS...` / `UTR...`). */\n pubkey: string;\n /** The primary account name (the one signing). */\n account: string;\n /** The permission used to sign (e.g. `active`, `owner`). */\n permission: string;\n /** The dApp origin the attestation is bound to (e.g. `http://localhost:5172`). */\n origin: string;\n /** The chain identifier the attestation is scoped to. */\n chainId: string;\n /** Issued-at, unix seconds. */\n iat: number;\n /** Expiry, unix seconds. */\n exp: number;\n /** 32-byte random value, hex-encoded. */\n nonce: string;\n /**\n * The full set of accounts the wallet currently holds signing keys for, each with\n * the permission names it controls. Lets a backend reason about the user's real\n * account set without trusting an FE-supplied (spoofable) list. Omitted when the\n * wallet doesn't enumerate additional accounts — backends MUST fall back to the\n * primary `account` field on absence.\n */\n signableAccounts?: SignableAccount[];\n}\n\n/**\n * A connect-time identity attestation, optionally produced by the wallet when the\n * user approves a `connect()`. Rides the existing connect consent — no extra popup.\n *\n * Present only if the connected wallet vendor supports silent attestation; absent\n * otherwise. dApps treat absence as \"fall back to whatever auth this dApp uses\n * without attestation\". The SDK does not verify or transform this value — it is\n * passed through verbatim from the wallet. Verification is the consumer backend's\n * responsibility (see RFC §2.4 / §5).\n *\n * @see https://github.com/ultraio/ultra-tool-kit/blob/feature/ai-enhancement/docs/proposals/wallet-native-attestation.md\n *\n * @experimental Issued only by the browser-extension wallet and not yet consumed by any\n * Ultra service; the shape may change before it is stabilised.\n */\nexport interface ConnectAttestation {\n /** The signed identity payload. */\n payload: AttestationPayload;\n /** Signature over the canonical hash of `payload` (e.g. `SIG_K1_...`). */\n signature: string;\n}\n\n/**\n * Represents the result of a successful connection request, containing the user's account details.\n * Backward-compatible: legacy fields `blockchainid` and `publicKey` are preserved alongside\n * the new multi-account fields.\n */\nexport type ConnectResult = {\n /**\n * The connected (selected) account name, e.g. `aa1aa2aa3aa4` — not a chain id.\n * Equals `selectedAccount.accountName` when the wallet returns `selectedAccount`;\n * the Web Wallet returns only this legacy field.\n * @deprecated Use `selectedAccount.accountName` when present.\n */\n blockchainid: string;\n /**\n * The public key associated with the user's account.\n * @deprecated Use `selectedAccount.permissions[n].publicKeys` instead.\n */\n publicKey: string;\n /**\n * All accounts available in the connected wallet.\n */\n accounts?: AccountInfo[];\n /**\n * The currently selected account.\n */\n selectedAccount?: AccountInfo;\n /**\n * Information about the connected blockchain network.\n */\n network?: NetworkInfo;\n /**\n * The nonce passed to `connect({ nonce })`, echoed back. Present only when a nonce was sent.\n */\n nonce?: string;\n /**\n * The wallet's signature over `nonce` (same scheme as `signMessage`). Present only when a nonce was sent.\n */\n signedNonce?: string;\n /**\n * An optional connect-time identity attestation. Present only when the connected\n * wallet vendor supports silent attestation; `undefined` otherwise. Passed through\n * verbatim from the wallet — the SDK does not verify or transform it.\n * @experimental See {@link ConnectAttestation}.\n */\n attestation?: ConnectAttestation;\n};\n\n/**\n * Represents the result returned after signing a message with the Ultra Wallet.\n */\nexport interface SignMessageResult {\n signature: string;\n}\n\n/**\n * Represents the result returned after signing a blockchain transaction with the Ultra Wallet.\n */\nexport interface SignTransactionResult {\n /**\n * The hash of the signed blockchain transaction.\n */\n transactionHash?: string;\n /**\n * Authorizations that couldn't be signed because the wallet lacks the keys.\n * Format: [\"account@permission\", ...]\n * Absent or empty means all authorizations were signed.\n */\n unsignedAuth?: string[];\n processed?: {\n id: string;\n block_num: number;\n block_time: string; // ISO timestamp\n producer_block_id: string | null;\n receipt: {\n status: string;\n cpu_usage_us: number;\n net_usage_words: number;\n };\n elapsed: number;\n net_usage: number;\n scheduled: boolean;\n action_traces: ActionTrace[];\n account_ram_delta: any | null;\n except: any | null;\n error_code: number | null;\n };\n}\n\nexport interface ActionTrace {\n action_ordinal: number;\n creator_action_ordinal: number;\n closest_unnotified_ancestor_action_ordinal: number;\n receipt: {\n receiver: string;\n act_digest: string;\n global_sequence: number;\n recv_sequence: number;\n auth_sequence: [string, number][];\n code_sequence: number;\n abi_sequence: number;\n };\n receiver: string;\n act: {\n account: string;\n name: string;\n authorization: {\n actor: string;\n permission: string;\n }[];\n data: {\n from: string;\n to: string;\n quantity: string;\n memo: string;\n };\n hex_data: string;\n };\n context_free: boolean;\n elapsed: number;\n console: string;\n trx_id: string;\n block_num: number;\n block_time: string;\n producer_block_id: string | null;\n account_ram_deltas: any[];\n except: any | null;\n error_code: number | null;\n return_value_hex_data: string;\n inline_traces: ActionTrace[];\n}\n", "interface UltraWalletSdkConfig {\n width: number;\n height: number;\n walletUrls: {\n mainnet: string;\n testnet: string;\n };\n checkWindowInterval: number;\n handshakeTimeout: number;\n networkInfo: Record<\n 'mainnet' | 'testnet',\n {\n chainId: string;\n }\n >;\n}\n\nconst UltraWalletSdkConfig: UltraWalletSdkConfig = Object.freeze({\n width: 420,\n height: 815,\n walletUrls: {\n mainnet: 'https://web-wallet.ultra.io',\n testnet: 'https://web-wallet.staging.ultra.io',\n },\n networkInfo: {\n mainnet: {\n chainId: 'a9c481dfbc7d9506dc7e87e9a137c931b0a9303f64fd7a1d08b8230133920097',\n },\n testnet: {\n chainId: '7fc56be645bb76ab9d747b53089f132dcb7681db06f0852cfa03eaf6f7ac80e9',\n },\n },\n checkWindowInterval: 500,\n handshakeTimeout: 10_000,\n});\n\nexport default UltraWalletSdkConfig;\n", "import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\n\nexport function isValidChain(targetNetwork: string, walletChainId: string): boolean {\n const { chainId } = UltraWalletSdkConfig.networkInfo[targetNetwork] || {};\n return !chainId || chainId === walletChainId;\n}\n", "import {\n AccountInfo,\n AvailableAuth,\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n NetworkDetails,\n SignMessageResult,\n SignTransactionOptions,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n WalletEventType,\n} from '../../interfaces';\nimport { isValidChain } from '../../utils/chain-validator';\n\n/**\n * Internal extension-only API exposed by the wallet's content-script-injected\n * `window.ultra` proxy. Not part of the public `UltraWalletProvider`\n * interface — the SDK calls these to manage listener registration with the\n * extension's background service worker.\n */\ninterface ExtensionListenerAPI {\n addExtensionListener?(event: WalletEventType, listenerId: string): Promise<unknown> | unknown;\n removeExtensionListener?(event: WalletEventType, listenerId: string): Promise<unknown> | unknown;\n}\n\nconst HEARTBEAT_INTERVAL_MS = 2_000;\n\nexport class ExtensionProvider implements UltraWalletProvider {\n private readonly eventListeners = new Map<WalletEventType, Array<(data: any) => void>>();\n private readonly listenerIds = new Map<WalletEventType, string>();\n private heartbeatTimer: ReturnType<typeof setInterval> | null = null;\n private messageHandler: ((event: MessageEvent) => void) | null = null;\n\n /**\n * Access window.ultra typed as UltraWalletProvider.\n * At runtime, window.ultra is a Proxy that handles all SDK method calls.\n * We cast here rather than declaring a global Window augmentation to avoid\n * conflicting with the app-level window.d.ts which types window.ultra as IUltraInternalAPI.\n */\n private get walletProvider(): UltraWalletProvider & ExtensionListenerAPI {\n return (window as any).ultra as UltraWalletProvider & ExtensionListenerAPI;\n }\n\n constructor(private readonly options?: UltraWalletSdkOptions) {\n this.initWindowEventListener();\n }\n\n /**\n * Wire-format match: the BG's MessageType.EVENT serialises as the uppercase\n * string 'EVENT'. We uppercase the incoming type so a future SDK build that\n * emits lowercase (or any case variant) still dispatches. Payload shape:\n * `{ event, origin, data }`.\n */\n private initWindowEventListener(): void {\n if (typeof window === 'undefined') return;\n if (this.messageHandler) return;\n this.messageHandler = (event: MessageEvent) => {\n if (event.source !== window || !event.data) return;\n const msg = event.data;\n const msgType = typeof msg.type === 'string' ? msg.type.toUpperCase() : '';\n if (msgType !== 'EVENT' || !msg.payload) return;\n const eventName = msg.payload.event as WalletEventType;\n if (!eventName) return;\n const cbs = this.eventListeners.get(eventName);\n if (cbs) cbs.forEach((cb) => cb(msg.payload.data));\n };\n window.addEventListener('message', this.messageHandler);\n }\n\n async connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n const { data: chainId } = await this.walletProvider.getChainId();\n if (!isValidChain(this.options?.environment, chainId)) {\n throw new Error(\n `Wallet environment mismatch: expected \"${this.options?.environment}\" chain, but received \"${chainId}\". Please verify the SDK configuration and the connected network.`,\n );\n }\n const result = await this.walletProvider.connect(params);\n // After connect() succeeds, the origin is now trusted in the BG. Any\n // pre-connect on() calls registered listener-ids that the BG silently\n // dropped (untrusted-origin no-op). Clear and re-register so the heartbeat\n // observes the fresh state.\n if (result?.status === 'success') {\n this.listenerIds.clear();\n for (const event of this.eventListeners.keys()) {\n void this.registerListenerWithExtension(event);\n }\n }\n return result;\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return this.walletProvider.disconnect();\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return this.walletProvider.signMessage(message);\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n options?: SignTransactionOptions,\n ): Promise<UltraResponse<SignTransactionResult>> {\n return this.walletProvider.signTransaction(transaction, options);\n }\n\n getChainId(): Promise<UltraResponse<string>> {\n return this.walletProvider.getChainId();\n }\n\n getAccounts(): Promise<UltraResponse<AccountInfo[]>> {\n return this.walletProvider.getAccounts();\n }\n\n getSelectedAccount(): Promise<UltraResponse<AccountInfo>> {\n return this.walletProvider.getSelectedAccount();\n }\n\n getAvailableAuthorizations(): Promise<UltraResponse<AvailableAuth[]>> {\n return this.walletProvider.getAvailableAuthorizations();\n }\n\n on(event: WalletEventType, callback: (data: any) => void): void {\n this.initWindowEventListener();\n const cbs = this.eventListeners.get(event) ?? [];\n cbs.push(callback);\n this.eventListeners.set(event, cbs);\n // Idempotent re-register: every on() call refreshes the BG's record of\n // this listener-id. Defends against extension-reload wipe and the\n // pre-connect untrusted-origin no-op race.\n void this.registerListenerWithExtension(event);\n this.ensureHeartbeat();\n }\n\n off(event: WalletEventType, callback: (data: any) => void): void {\n const cbs = this.eventListeners.get(event);\n if (!cbs) return;\n const idx = cbs.indexOf(callback);\n if (idx >= 0) cbs.splice(idx, 1);\n if (cbs.length === 0) {\n this.eventListeners.delete(event);\n void this.deregisterListenerWithExtension(event);\n }\n }\n\n switchNetwork(chainId: string): Promise<UltraResponse<void>> {\n return this.walletProvider.switchNetwork(chainId);\n }\n\n getNetwork(): Promise<UltraResponse<NetworkDetails>> {\n return this.walletProvider.getNetwork();\n }\n\n getNetworks(): Promise<UltraResponse<NetworkDetails[]>> {\n return this.walletProvider.getNetworks();\n }\n\n /**\n * Detach the window message listener and clear timers + maps. Safe to call\n * multiple times. Does NOT deregister each listener on the BG — the BG\n * GCs on tab close (verified via the S5(b) dedup work + tab-close cleanup\n * in `EventsService.removeTabListeners`). Calling N RPCs at dispose-time\n * would slow the page-unload path for no benefit.\n */\n dispose(): void {\n if (this.heartbeatTimer != null) {\n clearInterval(this.heartbeatTimer);\n this.heartbeatTimer = null;\n }\n if (this.messageHandler && typeof window !== 'undefined') {\n window.removeEventListener('message', this.messageHandler);\n this.messageHandler = null;\n }\n this.eventListeners.clear();\n this.listenerIds.clear();\n }\n\n private async registerListenerWithExtension(event: WalletEventType): Promise<void> {\n if (!this.isExtensionAvailable()) return;\n const id = this.listenerIds.get(event) ?? this.generateListenerId();\n this.listenerIds.set(event, id);\n try {\n const result = this.walletProvider.addExtensionListener?.(event, id);\n if (result && typeof (result as Promise<unknown>).catch === 'function') {\n // Don't drop the id on rejection — heartbeat will retry.\n (result as Promise<unknown>).catch(() => undefined);\n }\n } catch {\n // Swallow: heartbeat retry will pick this up.\n }\n }\n\n private async deregisterListenerWithExtension(event: WalletEventType): Promise<void> {\n if (!this.isExtensionAvailable()) return;\n const id = this.listenerIds.get(event);\n if (!id) return;\n this.listenerIds.delete(event);\n try {\n const result = this.walletProvider.removeExtensionListener?.(event, id);\n if (result && typeof (result as Promise<unknown>).catch === 'function') {\n (result as Promise<unknown>).catch(() => undefined);\n }\n } catch {\n // Ignore — extension may have been removed.\n }\n }\n\n private ensureHeartbeat(): void {\n if (this.heartbeatTimer != null || typeof window === 'undefined') return;\n // Cadence matches the toolkit's prior workaround. Lower = BG storage-write\n // overhead; higher = wider post-reload event-drop window.\n this.heartbeatTimer = setInterval(() => this.heartbeatTick(), HEARTBEAT_INTERVAL_MS);\n }\n\n private heartbeatTick(): void {\n if (!this.isExtensionAvailable()) return;\n let hasAny = false;\n for (const cbs of this.eventListeners.values()) {\n if (cbs.length > 0) {\n hasAny = true;\n break;\n }\n }\n if (!hasAny) return;\n for (const event of this.eventListeners.keys()) {\n void this.registerListenerWithExtension(event);\n }\n }\n\n private isExtensionAvailable(): boolean {\n return typeof window !== 'undefined' && !!(window as any).ultra;\n }\n\n private generateListenerId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return Math.random().toString(36).slice(2) + Date.now().toString(36);\n }\n}\n", "import { JSONRPCClient } from 'json-rpc-2.0';\n\nimport UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\nimport { JsonRpcMessage, ResponseStatus, SdkErrorCode, UltraResponse } from '../interfaces';\n\nimport { ClientError } from './client-error';\nimport { WindowManager } from './window-manager';\n\nexport class ClientMessenger {\n private windowManager: WindowManager;\n private rpcClient: JSONRPCClient;\n private pendingRequest = false;\n\n constructor(windowManager: WindowManager) {\n this.windowManager = windowManager;\n this.initializeRpcClient();\n this.setupMessageListener();\n }\n\n private initializeRpcClient(): void {\n this.rpcClient = new JSONRPCClient((request) => {\n const walletWindow = this.windowManager.getWalletWindow();\n if (!walletWindow) {\n return Promise.reject(new ClientError(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE));\n }\n walletWindow.postMessage(request, this.windowManager.walletUrl);\n return Promise.resolve();\n });\n }\n\n private setupMessageListener(): void {\n window.addEventListener('message', (event) => {\n if (event.origin === this.windowManager.walletUrl && event.data?.jsonrpc === '2.0') {\n this.rpcClient.receive(event.data);\n }\n });\n }\n\n async sendRequest<T>(requestMethod: string, requestParams: Record<string, unknown>): Promise<UltraResponse<T>> {\n if (this.pendingRequest && !this.isWalletWindowClosed()) {\n throw this.createErrorResponse(SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE);\n }\n\n this.pendingRequest = true;\n\n try {\n this.windowManager.openOrReuseWallet();\n const walletWindow = this.ensureWalletWindow();\n\n return await this.executeRequest<T>(walletWindow, requestMethod, requestParams);\n } finally {\n this.pendingRequest = false;\n }\n }\n\n private isWalletWindowClosed(): boolean {\n return this.windowManager.getWalletWindow()?.closed === true;\n }\n\n private ensureWalletWindow(): Window {\n const walletWindow = this.windowManager.getWalletWindow();\n if (!walletWindow) {\n throw this.createErrorResponse(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE);\n }\n return walletWindow;\n }\n\n private async executeRequest<T>(\n walletWindow: Window,\n requestMethod: string,\n requestParams: Record<string, unknown>,\n ): Promise<UltraResponse<T>> {\n // Wait for wallet handshake first\n await this.waitForWalletReady(walletWindow);\n\n // Then execute the RPC request with window monitoring\n return this.processRpcRequest<T>(walletWindow, requestMethod, requestParams);\n }\n\n private async waitForWalletReady(walletWindow: Window): Promise<void> {\n return this.withWindowMonitoring(walletWindow, () => {\n return new Promise<void>((resolve, reject) => {\n let isResolved = false;\n let timeoutId: any;\n\n const cleanup = () => {\n if (isResolved) return;\n isResolved = true;\n clearTimeout(timeoutId);\n window.removeEventListener('message', handleWalletHandshake);\n };\n\n const handleWalletHandshake = (event: MessageEvent) => {\n if (!this.isValidReadyMessage(event)) return;\n cleanup();\n resolve();\n };\n\n const handleTimeout = () => {\n cleanup();\n walletWindow.close();\n reject(this.createErrorResponse(SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT));\n };\n\n window.addEventListener('message', handleWalletHandshake);\n timeoutId = setTimeout(handleTimeout, UltraWalletSdkConfig.handshakeTimeout);\n });\n });\n }\n\n private async processRpcRequest<T>(\n walletWindow: Window,\n requestMethod: string,\n requestParams: Record<string, unknown>,\n ): Promise<UltraResponse<T>> {\n return this.withWindowMonitoring(walletWindow, async () => {\n let result: UltraResponse<T>;\n\n try {\n result = await this.rpcClient.request(requestMethod, requestParams);\n } catch (error) {\n const clientError = new ClientError(SdkErrorCode.UNKNOWN_ERROR, error);\n throw {\n status: ResponseStatus.ERROR,\n ...clientError,\n };\n } finally {\n if (result?.status === ResponseStatus.SUCCESS) {\n return result;\n } else {\n throw result;\n }\n }\n });\n }\n\n private async withWindowMonitoring<T>(walletWindow: Window, operation: () => Promise<T>): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const intervalId = setInterval(() => {\n if (walletWindow.closed) {\n clearInterval(intervalId);\n reject(this.createErrorResponse(SdkErrorCode.USER_REJECTED_REQUEST));\n }\n }, UltraWalletSdkConfig.checkWindowInterval);\n\n operation()\n .then((result) => {\n clearInterval(intervalId);\n resolve(result);\n })\n .catch((error) => {\n clearInterval(intervalId);\n reject(error);\n });\n });\n }\n\n private isValidReadyMessage(event: MessageEvent): boolean {\n if (event.origin !== this.windowManager.walletUrl) return false;\n\n const msg: JsonRpcMessage = event.data;\n return msg?.jsonrpc === '2.0' && msg.method === 'ready';\n }\n\n private createErrorResponse(errorCode: SdkErrorCode): UltraResponse<never> {\n const { code, message } = new ClientError(errorCode);\n return { status: ResponseStatus.ERROR, code, message, data: null as never };\n }\n}\n", "import { SDK_ERROR_MESSAGE, SdkErrorCode } from '../interfaces';\n\nexport class ClientError extends Error {\n override message: string;\n\n constructor(\n public code: SdkErrorCode,\n public data?,\n ) {\n super();\n this.message = SDK_ERROR_MESSAGE[code];\n this.name = this.constructor.name;\n }\n}\n", "import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\n\nexport class WindowManager {\n private currentWindow: Window;\n private walletWindow: Window | null = null;\n public readonly walletUrl: string;\n\n constructor(walletUrl: string) {\n this.currentWindow = window;\n this.walletUrl = walletUrl;\n }\n\n openOrReuseWallet() {\n if (this.walletWindow == null || this.walletWindow.closed) {\n const height = UltraWalletSdkConfig.height;\n const width = UltraWalletSdkConfig.width;\n const top = this.currentWindow.top;\n const left = this.currentWindow.screenLeft + this.currentWindow.innerWidth - width;\n\n this.walletWindow = window.open(\n this.walletUrl,\n '_blank',\n `width=${width},height=${height},top=${top},left=${left},resizable=0`,\n );\n } else {\n this.walletWindow.focus();\n }\n }\n\n // Provides a reference to the wallet window\n getWalletWindow(): Window | null {\n return this.walletWindow;\n }\n}\n", "import { ClientMessenger } from '../../common/client-messenger';\nimport { WindowManager } from '../../common/window-manager';\nimport UltraWalletSdkConfig from '../../config/ultra-wallet-sdk.config';\nimport {\n AccountInfo,\n AvailableAuth,\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n NetworkDetails,\n ResponseStatus,\n SignMessageResult,\n SignTransactionOptions,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n WalletEventType,\n} from '../../interfaces';\n\nexport class WebProvider implements UltraWalletProvider {\n private readonly windowManager: WindowManager;\n private readonly clientMessenger: ClientMessenger;\n\n constructor(private readonly options?: UltraWalletSdkOptions) {\n this.windowManager = new WindowManager(this.resolveWalletUrl());\n this.clientMessenger = new ClientMessenger(this.windowManager);\n }\n\n connect(options?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n return this.clientMessenger.sendRequest<ConnectResult>('connect', { options });\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return this.clientMessenger.sendRequest<boolean>('disconnect', {});\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return this.clientMessenger.sendRequest<SignMessageResult>('signMessage', { message });\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n options?: SignTransactionOptions,\n ): Promise<UltraResponse<SignTransactionResult>> {\n return this.clientMessenger.sendRequest<SignTransactionResult>('signTransaction', { transaction, options });\n }\n\n async getChainId(): Promise<UltraResponse<string>> {\n const environment = this.options?.environment || 'mainnet';\n\n switch (environment) {\n case 'mainnet':\n const mainnetChainId = UltraWalletSdkConfig.networkInfo.mainnet.chainId;\n return {\n status: ResponseStatus.SUCCESS,\n data: mainnetChainId,\n };\n\n case 'testnet':\n const testnetChainId = UltraWalletSdkConfig.networkInfo.testnet.chainId;\n return {\n status: ResponseStatus.SUCCESS,\n data: testnetChainId,\n };\n\n default:\n return this.clientMessenger.sendRequest<string>('getChainId', {});\n }\n }\n\n getAccounts(): Promise<UltraResponse<AccountInfo[]>> {\n return this.clientMessenger.sendRequest<AccountInfo[]>('getAccounts', {});\n }\n\n getSelectedAccount(): Promise<UltraResponse<AccountInfo>> {\n return this.clientMessenger.sendRequest<AccountInfo>('getSelectedAccount', {});\n }\n\n getAvailableAuthorizations(): Promise<UltraResponse<AvailableAuth[]>> {\n return this.clientMessenger.sendRequest<AvailableAuth[]>('getAvailableAuthorizations', {});\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n on(_event: WalletEventType, _callback: (data: any) => void): void {\n // The Web Wallet provider communicates via postMessage through a popup window.\n // Long-lived event subscriptions are not supported in this transport model.\n // Consumers requiring real-time events should use the Extension provider.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n off(_event: WalletEventType, _callback: (data: any) => void): void {\n // Not supported in web provider — see on() above.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n switchNetwork(_chainId: string): Promise<UltraResponse<void>> {\n throw new Error('Not supported in web provider');\n }\n\n getNetwork(): Promise<UltraResponse<NetworkDetails>> {\n throw new Error('Not supported in web provider');\n }\n\n getNetworks(): Promise<UltraResponse<NetworkDetails[]>> {\n throw new Error('Not supported in web provider');\n }\n\n dispose(): void {\n // Web provider holds no long-lived timers/listeners — the popup-based\n // postMessage transport is request/response only.\n }\n\n private resolveWalletUrl(): string {\n const env = UltraWalletSdkConfig.walletUrls[this.options?.environment || 'mainnet'];\n return env || this.options.environment;\n }\n}\n", "export function isExtensionAvailable(): boolean {\n return typeof window !== 'undefined' && 'ultra' in window;\n}\n", "import {\n AccountInfo,\n AvailableAuth,\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n NetworkDetails,\n SignMessageResult,\n SignTransactionOptions,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n UltraWalletSdkProvider,\n WalletEventType,\n} from './interfaces';\nimport { ExtensionProvider, WebProvider } from './providers';\nimport { isExtensionAvailable } from './utils/detection';\n\n/**\n * UltraWalletClient acts as a Facade for interacting with the Ultra Wallet.\n * It provides a unified API regardless of the underlying provider implementation (Extension or Web).\n */\nexport class UltraWalletSDK {\n private provider: UltraWalletProvider;\n\n /**\n * Constructs an UltraWalletClient instance.\n * If the Ultra Wallet Extension is available (window.ultra), it will be used automatically.\n * If the Extension is not available, the Web Wallet provider will be initialized using the given network options.\n *\n * @param {UltraWalletSdkOptions} [options] - Configuration options for the Web Wallet fallback (environment or custom URL).\n */\n constructor(private readonly options?: UltraWalletSdkOptions) {\n this.provider = this.resolveWalletProvider();\n }\n\n connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n return this.provider.connect(params);\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return this.provider.disconnect();\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return this.provider.signMessage(message);\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n options?: SignTransactionOptions,\n ): Promise<UltraResponse<SignTransactionResult>> {\n return this.provider.signTransaction(transaction, options);\n }\n\n getChainId(): Promise<UltraResponse<string>> {\n return this.provider.getChainId();\n }\n\n getAccounts(): Promise<UltraResponse<AccountInfo[]>> {\n return this.provider.getAccounts();\n }\n\n getSelectedAccount(): Promise<UltraResponse<AccountInfo>> {\n return this.provider.getSelectedAccount();\n }\n\n getAvailableAuthorizations(): Promise<UltraResponse<AvailableAuth[]>> {\n return this.provider.getAvailableAuthorizations();\n }\n\n on(event: WalletEventType, callback: (data: any) => void): void {\n this.provider.on(event, callback);\n }\n\n off(event: WalletEventType, callback: (data: any) => void): void {\n this.provider.off(event, callback);\n }\n\n switchNetwork(chainId: string): Promise<UltraResponse<void>> {\n return this.provider.switchNetwork(chainId);\n }\n\n getNetwork(): Promise<UltraResponse<NetworkDetails>> {\n return this.provider.getNetwork();\n }\n\n getNetworks(): Promise<UltraResponse<NetworkDetails[]>> {\n return this.provider.getNetworks();\n }\n\n dispose(): void {\n this.provider.dispose();\n }\n\n private resolveWalletProvider(): UltraWalletProvider {\n const requestedProvider: UltraWalletSdkProvider | undefined = this.options?.provider;\n if (requestedProvider === 'extension') {\n return new ExtensionProvider(this.options);\n }\n if (requestedProvider === 'web') {\n return new WebProvider(this.options);\n }\n\n const extensionAvailable = isExtensionAvailable();\n return extensionAvailable ? new ExtensionProvider(this.options) : new WebProvider(this.options);\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,IAAY;CAAZ,SAAYA,eAAY;AACtB,EAAAA,cAAAA,cAAA,uBAAA,IAAA,IAAA,IAAA;AACA,EAAAA,cAAAA,cAAA,0BAAA,IAAA,IAAA,IAAA;AACA,EAAAA,cAAAA,cAAA,2BAAA,IAAA,IAAA,IAAA;AACA,EAAAA,cAAAA,cAAA,kCAAA,IAAA,KAAA,IAAA;AACA,EAAAA,cAAAA,cAAA,eAAA,IAAA,MAAA,IAAA;AACF,
|
|
4
|
+
"sourcesContent": ["export enum SdkErrorCode {\n USER_REJECTED_REQUEST = 4001,\n WALLET_HANDSHAKE_TIMEOUT = 4300,\n WALLET_WINDOW_UNAVAILABLE = 4301,\n WEB_WALLET_UNAVAILABLE = 4302,\n REQUESTED_RESOURCE_NOT_AVAILABLE = 32002,\n UNKNOWN_ERROR = -32604,\n}\n\nexport const SDK_ERROR_MESSAGE: { [key in SdkErrorCode]: string } = {\n [SdkErrorCode.USER_REJECTED_REQUEST]: 'The user rejected the request.',\n [SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT]: 'Timeout to connect with the web wallet.',\n [SdkErrorCode.WALLET_WINDOW_UNAVAILABLE]: 'Wallet window blocked by browser or failed to open.',\n [SdkErrorCode.WEB_WALLET_UNAVAILABLE]:\n 'The Ultra Web Wallet is not available on this network. Use the Ultra Wallet browser extension.',\n [SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE]: 'Requested resource not available.',\n [SdkErrorCode.UNKNOWN_ERROR]: 'Unknown error occurred.',\n};\n", "/**\n * A generic wrapper for all Ultra Wallet SDK responses.\n * Encapsulates the status, data payload, and optional error messaging or codes.\n *\n * @template T The type of the data payload contained in the response.\n */\nexport interface UltraResponse<T = any> {\n /**\n * The status of the response, e.g., success, fail, or error.\n */\n status: ResponseStatus;\n /**\n * The actual response data payload.\n */\n data: T;\n /**\n * Optional end-user-readable message, explaining what went wrong (if applicable).\n */\n message?: string;\n /**\n * Optional error or status code.\n */\n code?: number;\n}\n\n/**\n * Enumeration of possible response statuses returned by the Ultra Wallet SDK.\n */\nexport enum ResponseStatus {\n SUCCESS = 'success',\n FAIL = 'fail',\n ERROR = 'error',\n}\n\n/**\n * Represents the result of a disconnect request.\n * A boolean indicating whether the disconnection was successful.\n */\nexport type DisconnectResponse = boolean;\n\n/**\n * Represents a single permission entry associated with a blockchain account.\n */\nexport interface PermissionInfo {\n /**\n * The permission level name (e.g., \"active\", \"owner\").\n */\n name: string;\n /**\n * The public keys associated with this permission.\n */\n publicKeys: string[];\n}\n\n/**\n * Represents a blockchain account with its associated permissions.\n */\nexport interface AccountInfo {\n /**\n * The blockchain account name.\n */\n accountName: string;\n /**\n * The list of permissions associated with this account.\n */\n permissions: PermissionInfo[];\n}\n\n/**\n * Represents information about the connected blockchain network.\n */\nexport interface NetworkInfo {\n /**\n * The human-readable name of the network (e.g., \"mainnet\", \"testnet\").\n */\n name: string;\n /**\n * The unique chain identifier.\n */\n chainId: string;\n}\n\n/**\n * Extended network information including connection details.\n * Returned by getNetwork and getNetworks.\n */\nexport interface NetworkDetails {\n /**\n * The human-readable name of the network (e.g., \"mainnet\", \"testnet\").\n */\n name: string;\n /**\n * The unique chain identifier.\n */\n chainId: string;\n /**\n * The RPC node URL for the network.\n */\n nodeUrl: string;\n /**\n * Whether this is a user-defined custom network.\n */\n isCustom?: boolean;\n}\n\n/**\n * One account the wallet currently holds signing keys for, plus the permission\n * names whose keys it controls. Sourced from the same set the wallet exposes via\n * `ConnectResult.accounts` — never an FE-supplied (spoofable) list (RFC §2.1 / §5.6).\n *\n * @experimental See {@link ConnectAttestation}.\n */\nexport interface SignableAccount {\n /** The blockchain account name. */\n account: string;\n /** The permission names the wallet holds the signing key for (e.g. `active`). */\n permissions: string[];\n}\n\n/**\n * The signed payload of a connect-time identity attestation (RFC §2.1). The canonical\n * form — JSON with sorted keys, UTF-8 encoded, SHA-256 hashed — is what the wallet signs.\n *\n * @experimental See {@link ConnectAttestation}.\n */\nexport interface AttestationPayload {\n /** Attestation format version. */\n v: 1;\n /** The signing public key (e.g. `EOS...` / `UTR...`). */\n pubkey: string;\n /** The primary account name (the one signing). */\n account: string;\n /** The permission used to sign (e.g. `active`, `owner`). */\n permission: string;\n /** The dApp origin the attestation is bound to (e.g. `http://localhost:5172`). */\n origin: string;\n /** The chain identifier the attestation is scoped to. */\n chainId: string;\n /** Issued-at, unix seconds. */\n iat: number;\n /** Expiry, unix seconds. */\n exp: number;\n /** 32-byte random value, hex-encoded. */\n nonce: string;\n /**\n * The full set of accounts the wallet currently holds signing keys for, each with\n * the permission names it controls. Lets a backend reason about the user's real\n * account set without trusting an FE-supplied (spoofable) list. Omitted when the\n * wallet doesn't enumerate additional accounts — backends MUST fall back to the\n * primary `account` field on absence.\n */\n signableAccounts?: SignableAccount[];\n}\n\n/**\n * A connect-time identity attestation, optionally produced by the wallet when the\n * user approves a `connect()`. Rides the existing connect consent — no extra popup.\n *\n * Present only if the connected wallet vendor supports silent attestation; absent\n * otherwise. dApps treat absence as \"fall back to whatever auth this dApp uses\n * without attestation\". The SDK does not verify or transform this value — it is\n * passed through verbatim from the wallet. Verification is the consumer backend's\n * responsibility (see RFC §2.4 / §5).\n *\n * @see https://github.com/ultraio/ultra-tool-kit/blob/feature/ai-enhancement/docs/proposals/wallet-native-attestation.md\n *\n * @experimental Issued only by the browser-extension wallet and not yet consumed by any\n * Ultra service; the shape may change before it is stabilised.\n */\nexport interface ConnectAttestation {\n /** The signed identity payload. */\n payload: AttestationPayload;\n /** Signature over the canonical hash of `payload` (e.g. `SIG_K1_...`). */\n signature: string;\n}\n\n/**\n * Represents the result of a successful connection request, containing the user's account details.\n * Backward-compatible: legacy fields `blockchainid` and `publicKey` are preserved alongside\n * the new multi-account fields.\n */\nexport type ConnectResult = {\n /**\n * The connected (selected) account name, e.g. `aa1aa2aa3aa4` — not a chain id.\n * Equals `selectedAccount.accountName` when the wallet returns `selectedAccount`;\n * the Web Wallet returns only this legacy field.\n * @deprecated Use `selectedAccount.accountName` when present.\n */\n blockchainid: string;\n /**\n * The public key associated with the user's account.\n * @deprecated Use `selectedAccount.permissions[n].publicKeys` instead.\n */\n publicKey: string;\n /**\n * All accounts available in the connected wallet.\n */\n accounts?: AccountInfo[];\n /**\n * The currently selected account.\n */\n selectedAccount?: AccountInfo;\n /**\n * Information about the connected blockchain network.\n */\n network?: NetworkInfo;\n /**\n * The nonce passed to `connect({ nonce })`, echoed back. Present only when a nonce was sent.\n */\n nonce?: string;\n /**\n * The wallet's signature over `nonce` (same scheme as `signMessage`). Present only when a nonce was sent.\n */\n signedNonce?: string;\n /**\n * An optional connect-time identity attestation. Present only when the connected\n * wallet vendor supports silent attestation; `undefined` otherwise. Passed through\n * verbatim from the wallet — the SDK does not verify or transform it.\n * @experimental See {@link ConnectAttestation}.\n */\n attestation?: ConnectAttestation;\n};\n\n/**\n * Represents the result returned after signing a message with the Ultra Wallet.\n */\nexport interface SignMessageResult {\n signature: string;\n}\n\n/**\n * Represents the result returned after signing a blockchain transaction with the Ultra Wallet.\n */\nexport interface SignTransactionResult {\n /**\n * The hash of the signed blockchain transaction.\n */\n transactionHash?: string;\n /**\n * Authorizations that couldn't be signed because the wallet lacks the keys.\n * Format: [\"account@permission\", ...]\n * Absent or empty means all authorizations were signed.\n */\n unsignedAuth?: string[];\n processed?: {\n id: string;\n block_num: number;\n block_time: string; // ISO timestamp\n producer_block_id: string | null;\n receipt: {\n status: string;\n cpu_usage_us: number;\n net_usage_words: number;\n };\n elapsed: number;\n net_usage: number;\n scheduled: boolean;\n action_traces: ActionTrace[];\n account_ram_delta: any | null;\n except: any | null;\n error_code: number | null;\n };\n}\n\nexport interface ActionTrace {\n action_ordinal: number;\n creator_action_ordinal: number;\n closest_unnotified_ancestor_action_ordinal: number;\n receipt: {\n receiver: string;\n act_digest: string;\n global_sequence: number;\n recv_sequence: number;\n auth_sequence: [string, number][];\n code_sequence: number;\n abi_sequence: number;\n };\n receiver: string;\n act: {\n account: string;\n name: string;\n authorization: {\n actor: string;\n permission: string;\n }[];\n data: {\n from: string;\n to: string;\n quantity: string;\n memo: string;\n };\n hex_data: string;\n };\n context_free: boolean;\n elapsed: number;\n console: string;\n trx_id: string;\n block_num: number;\n block_time: string;\n producer_block_id: string | null;\n account_ram_deltas: any[];\n except: any | null;\n error_code: number | null;\n return_value_hex_data: string;\n inline_traces: ActionTrace[];\n}\n", "interface UltraWalletSdkConfig {\n width: number;\n height: number;\n /** Web Wallet URL per built-in network; `null` = no Web Wallet deployed for that network. */\n walletUrls: {\n mainnet: string;\n testnet: string | null;\n };\n checkWindowInterval: number;\n handshakeTimeout: number;\n networkInfo: Record<\n 'mainnet' | 'testnet',\n {\n chainId: string;\n }\n >;\n}\n\nconst UltraWalletSdkConfig: UltraWalletSdkConfig = Object.freeze({\n width: 420,\n height: 815,\n walletUrls: {\n mainnet: 'https://web-wallet.ultra.io',\n // The testnet Web Wallet (web-wallet.staging.ultra.io) was decommissioned; testnet is extension-only.\n testnet: null,\n },\n networkInfo: {\n mainnet: {\n chainId: 'a9c481dfbc7d9506dc7e87e9a137c931b0a9303f64fd7a1d08b8230133920097',\n },\n testnet: {\n chainId: '7fc56be645bb76ab9d747b53089f132dcb7681db06f0852cfa03eaf6f7ac80e9',\n },\n },\n checkWindowInterval: 500,\n handshakeTimeout: 10_000,\n});\n\nexport default UltraWalletSdkConfig;\n", "import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\n\nexport function isValidChain(targetNetwork: string, walletChainId: string): boolean {\n const { chainId } = UltraWalletSdkConfig.networkInfo[targetNetwork] || {};\n return !chainId || chainId === walletChainId;\n}\n", "import {\n AccountInfo,\n AvailableAuth,\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n NetworkDetails,\n SignMessageResult,\n SignTransactionOptions,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n WalletEventType,\n} from '../../interfaces';\nimport { isValidChain } from '../../utils/chain-validator';\n\n/**\n * Internal extension-only API exposed by the wallet's content-script-injected\n * `window.ultra` proxy. Not part of the public `UltraWalletProvider`\n * interface — the SDK calls these to manage listener registration with the\n * extension's background service worker.\n */\ninterface ExtensionListenerAPI {\n addExtensionListener?(event: WalletEventType, listenerId: string): Promise<unknown> | unknown;\n removeExtensionListener?(event: WalletEventType, listenerId: string): Promise<unknown> | unknown;\n}\n\nconst HEARTBEAT_INTERVAL_MS = 2_000;\n\nexport class ExtensionProvider implements UltraWalletProvider {\n private readonly eventListeners = new Map<WalletEventType, Array<(data: any) => void>>();\n private readonly listenerIds = new Map<WalletEventType, string>();\n private heartbeatTimer: ReturnType<typeof setInterval> | null = null;\n private messageHandler: ((event: MessageEvent) => void) | null = null;\n\n /**\n * Access window.ultra typed as UltraWalletProvider.\n * At runtime, window.ultra is a Proxy that handles all SDK method calls.\n * We cast here rather than declaring a global Window augmentation to avoid\n * conflicting with the app-level window.d.ts which types window.ultra as IUltraInternalAPI.\n */\n private get walletProvider(): UltraWalletProvider & ExtensionListenerAPI {\n return (window as any).ultra as UltraWalletProvider & ExtensionListenerAPI;\n }\n\n constructor(private readonly options?: UltraWalletSdkOptions) {\n this.initWindowEventListener();\n }\n\n /**\n * Wire-format match: the BG's MessageType.EVENT serialises as the uppercase\n * string 'EVENT'. We uppercase the incoming type so a future SDK build that\n * emits lowercase (or any case variant) still dispatches. Payload shape:\n * `{ event, origin, data }`.\n */\n private initWindowEventListener(): void {\n if (typeof window === 'undefined') return;\n if (this.messageHandler) return;\n this.messageHandler = (event: MessageEvent) => {\n if (event.source !== window || !event.data) return;\n const msg = event.data;\n const msgType = typeof msg.type === 'string' ? msg.type.toUpperCase() : '';\n if (msgType !== 'EVENT' || !msg.payload) return;\n const eventName = msg.payload.event as WalletEventType;\n if (!eventName) return;\n const cbs = this.eventListeners.get(eventName);\n if (cbs) cbs.forEach((cb) => cb(msg.payload.data));\n };\n window.addEventListener('message', this.messageHandler);\n }\n\n async connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n const { data: chainId } = await this.walletProvider.getChainId();\n if (!isValidChain(this.options?.environment, chainId)) {\n throw new Error(\n `Wallet environment mismatch: expected \"${this.options?.environment}\" chain, but received \"${chainId}\". Please verify the SDK configuration and the connected network.`,\n );\n }\n const result = await this.walletProvider.connect(params);\n // After connect() succeeds, the origin is now trusted in the BG. Any\n // pre-connect on() calls registered listener-ids that the BG silently\n // dropped (untrusted-origin no-op). Clear and re-register so the heartbeat\n // observes the fresh state.\n if (result?.status === 'success') {\n this.listenerIds.clear();\n for (const event of this.eventListeners.keys()) {\n void this.registerListenerWithExtension(event);\n }\n }\n return result;\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return this.walletProvider.disconnect();\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return this.walletProvider.signMessage(message);\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n options?: SignTransactionOptions,\n ): Promise<UltraResponse<SignTransactionResult>> {\n return this.walletProvider.signTransaction(transaction, options);\n }\n\n getChainId(): Promise<UltraResponse<string>> {\n return this.walletProvider.getChainId();\n }\n\n getAccounts(): Promise<UltraResponse<AccountInfo[]>> {\n return this.walletProvider.getAccounts();\n }\n\n getSelectedAccount(): Promise<UltraResponse<AccountInfo>> {\n return this.walletProvider.getSelectedAccount();\n }\n\n getAvailableAuthorizations(): Promise<UltraResponse<AvailableAuth[]>> {\n return this.walletProvider.getAvailableAuthorizations();\n }\n\n on(event: WalletEventType, callback: (data: any) => void): void {\n this.initWindowEventListener();\n const cbs = this.eventListeners.get(event) ?? [];\n cbs.push(callback);\n this.eventListeners.set(event, cbs);\n // Idempotent re-register: every on() call refreshes the BG's record of\n // this listener-id. Defends against extension-reload wipe and the\n // pre-connect untrusted-origin no-op race.\n void this.registerListenerWithExtension(event);\n this.ensureHeartbeat();\n }\n\n off(event: WalletEventType, callback: (data: any) => void): void {\n const cbs = this.eventListeners.get(event);\n if (!cbs) return;\n const idx = cbs.indexOf(callback);\n if (idx >= 0) cbs.splice(idx, 1);\n if (cbs.length === 0) {\n this.eventListeners.delete(event);\n void this.deregisterListenerWithExtension(event);\n }\n }\n\n switchNetwork(chainId: string): Promise<UltraResponse<void>> {\n return this.walletProvider.switchNetwork(chainId);\n }\n\n getNetwork(): Promise<UltraResponse<NetworkDetails>> {\n return this.walletProvider.getNetwork();\n }\n\n getNetworks(): Promise<UltraResponse<NetworkDetails[]>> {\n return this.walletProvider.getNetworks();\n }\n\n /**\n * Detach the window message listener and clear timers + maps. Safe to call\n * multiple times. Does NOT deregister each listener on the BG — the BG\n * GCs on tab close (verified via the S5(b) dedup work + tab-close cleanup\n * in `EventsService.removeTabListeners`). Calling N RPCs at dispose-time\n * would slow the page-unload path for no benefit.\n */\n dispose(): void {\n if (this.heartbeatTimer != null) {\n clearInterval(this.heartbeatTimer);\n this.heartbeatTimer = null;\n }\n if (this.messageHandler && typeof window !== 'undefined') {\n window.removeEventListener('message', this.messageHandler);\n this.messageHandler = null;\n }\n this.eventListeners.clear();\n this.listenerIds.clear();\n }\n\n private async registerListenerWithExtension(event: WalletEventType): Promise<void> {\n if (!this.isExtensionAvailable()) return;\n const id = this.listenerIds.get(event) ?? this.generateListenerId();\n this.listenerIds.set(event, id);\n try {\n const result = this.walletProvider.addExtensionListener?.(event, id);\n if (result && typeof (result as Promise<unknown>).catch === 'function') {\n // Don't drop the id on rejection — heartbeat will retry.\n (result as Promise<unknown>).catch(() => undefined);\n }\n } catch {\n // Swallow: heartbeat retry will pick this up.\n }\n }\n\n private async deregisterListenerWithExtension(event: WalletEventType): Promise<void> {\n if (!this.isExtensionAvailable()) return;\n const id = this.listenerIds.get(event);\n if (!id) return;\n this.listenerIds.delete(event);\n try {\n const result = this.walletProvider.removeExtensionListener?.(event, id);\n if (result && typeof (result as Promise<unknown>).catch === 'function') {\n (result as Promise<unknown>).catch(() => undefined);\n }\n } catch {\n // Ignore — extension may have been removed.\n }\n }\n\n private ensureHeartbeat(): void {\n if (this.heartbeatTimer != null || typeof window === 'undefined') return;\n // Cadence matches the toolkit's prior workaround. Lower = BG storage-write\n // overhead; higher = wider post-reload event-drop window.\n this.heartbeatTimer = setInterval(() => this.heartbeatTick(), HEARTBEAT_INTERVAL_MS);\n }\n\n private heartbeatTick(): void {\n if (!this.isExtensionAvailable()) return;\n let hasAny = false;\n for (const cbs of this.eventListeners.values()) {\n if (cbs.length > 0) {\n hasAny = true;\n break;\n }\n }\n if (!hasAny) return;\n for (const event of this.eventListeners.keys()) {\n void this.registerListenerWithExtension(event);\n }\n }\n\n private isExtensionAvailable(): boolean {\n return typeof window !== 'undefined' && !!(window as any).ultra;\n }\n\n private generateListenerId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return Math.random().toString(36).slice(2) + Date.now().toString(36);\n }\n}\n", "import { JSONRPCClient } from 'json-rpc-2.0';\n\nimport UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\nimport { JsonRpcMessage, ResponseStatus, SdkErrorCode, UltraResponse } from '../interfaces';\n\nimport { ClientError } from './client-error';\nimport { WindowManager } from './window-manager';\n\nexport class ClientMessenger {\n private windowManager: WindowManager;\n private rpcClient: JSONRPCClient;\n private pendingRequest = false;\n\n constructor(windowManager: WindowManager) {\n this.windowManager = windowManager;\n this.initializeRpcClient();\n this.setupMessageListener();\n }\n\n private initializeRpcClient(): void {\n this.rpcClient = new JSONRPCClient((request) => {\n const walletWindow = this.windowManager.getWalletWindow();\n if (!walletWindow) {\n return Promise.reject(new ClientError(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE));\n }\n walletWindow.postMessage(request, this.windowManager.walletUrl);\n return Promise.resolve();\n });\n }\n\n private setupMessageListener(): void {\n window.addEventListener('message', (event) => {\n if (event.origin === this.windowManager.walletUrl && event.data?.jsonrpc === '2.0') {\n this.rpcClient.receive(event.data);\n }\n });\n }\n\n async sendRequest<T>(requestMethod: string, requestParams: Record<string, unknown>): Promise<UltraResponse<T>> {\n if (!this.windowManager.walletUrl) {\n throw this.createErrorResponse(SdkErrorCode.WEB_WALLET_UNAVAILABLE);\n }\n\n if (this.pendingRequest && !this.isWalletWindowClosed()) {\n throw this.createErrorResponse(SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE);\n }\n\n this.pendingRequest = true;\n\n try {\n this.windowManager.openOrReuseWallet();\n const walletWindow = this.ensureWalletWindow();\n\n return await this.executeRequest<T>(walletWindow, requestMethod, requestParams);\n } finally {\n this.pendingRequest = false;\n }\n }\n\n private isWalletWindowClosed(): boolean {\n return this.windowManager.getWalletWindow()?.closed === true;\n }\n\n private ensureWalletWindow(): Window {\n const walletWindow = this.windowManager.getWalletWindow();\n if (!walletWindow) {\n throw this.createErrorResponse(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE);\n }\n return walletWindow;\n }\n\n private async executeRequest<T>(\n walletWindow: Window,\n requestMethod: string,\n requestParams: Record<string, unknown>,\n ): Promise<UltraResponse<T>> {\n // Wait for wallet handshake first\n await this.waitForWalletReady(walletWindow);\n\n // Then execute the RPC request with window monitoring\n return this.processRpcRequest<T>(walletWindow, requestMethod, requestParams);\n }\n\n private async waitForWalletReady(walletWindow: Window): Promise<void> {\n return this.withWindowMonitoring(walletWindow, () => {\n return new Promise<void>((resolve, reject) => {\n let isResolved = false;\n let timeoutId: any;\n\n const cleanup = () => {\n if (isResolved) return;\n isResolved = true;\n clearTimeout(timeoutId);\n window.removeEventListener('message', handleWalletHandshake);\n };\n\n const handleWalletHandshake = (event: MessageEvent) => {\n if (!this.isValidReadyMessage(event)) return;\n cleanup();\n resolve();\n };\n\n const handleTimeout = () => {\n cleanup();\n walletWindow.close();\n reject(this.createErrorResponse(SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT));\n };\n\n window.addEventListener('message', handleWalletHandshake);\n timeoutId = setTimeout(handleTimeout, UltraWalletSdkConfig.handshakeTimeout);\n });\n });\n }\n\n private async processRpcRequest<T>(\n walletWindow: Window,\n requestMethod: string,\n requestParams: Record<string, unknown>,\n ): Promise<UltraResponse<T>> {\n return this.withWindowMonitoring(walletWindow, async () => {\n let result: UltraResponse<T>;\n try {\n result = await this.rpcClient.request(requestMethod, requestParams);\n } catch (error) {\n // JSON-RPC-level failure (e.g. the Web Wallet does not implement the method). The wallet\n // has no request to show, so close the popup — left open it would never re-send `ready`\n // and the next request would time out — and surface the wallet's code/message.\n walletWindow.close();\n throw this.createRpcErrorResponse(error);\n }\n if (result?.status === ResponseStatus.SUCCESS) {\n return result;\n }\n throw result;\n });\n }\n\n private async withWindowMonitoring<T>(walletWindow: Window, operation: () => Promise<T>): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const intervalId = setInterval(() => {\n if (walletWindow.closed) {\n clearInterval(intervalId);\n reject(this.createErrorResponse(SdkErrorCode.USER_REJECTED_REQUEST));\n }\n }, UltraWalletSdkConfig.checkWindowInterval);\n\n operation()\n .then((result) => {\n clearInterval(intervalId);\n resolve(result);\n })\n .catch((error) => {\n clearInterval(intervalId);\n reject(error);\n });\n });\n }\n\n private isValidReadyMessage(event: MessageEvent): boolean {\n if (event.origin !== this.windowManager.walletUrl) return false;\n\n const msg: JsonRpcMessage = event.data;\n return msg?.jsonrpc === '2.0' && msg.method === 'ready';\n }\n\n private createRpcErrorResponse(error: unknown): UltraResponse<never> {\n const { code, message } = (error ?? {}) as { code?: unknown; message?: unknown };\n if (typeof code === 'number') {\n return {\n status: ResponseStatus.ERROR,\n code,\n message: typeof message === 'string' ? message : '',\n data: (error as { data?: never }).data,\n };\n }\n const clientError = new ClientError(SdkErrorCode.UNKNOWN_ERROR);\n return { status: ResponseStatus.ERROR, code: clientError.code, message: clientError.message, data: error as never };\n }\n\n private createErrorResponse(errorCode: SdkErrorCode): UltraResponse<never> {\n const { code, message } = new ClientError(errorCode);\n return { status: ResponseStatus.ERROR, code, message, data: null as never };\n }\n}\n", "import { SDK_ERROR_MESSAGE, SdkErrorCode } from '../interfaces';\n\nexport class ClientError extends Error {\n override message: string;\n\n constructor(\n public code: SdkErrorCode,\n public data?,\n ) {\n super();\n this.message = SDK_ERROR_MESSAGE[code];\n this.name = this.constructor.name;\n }\n}\n", "import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\n\nexport class WindowManager {\n private currentWindow: Window;\n private walletWindow: Window | null = null;\n /** `null` when no Web Wallet is deployed for the configured network. */\n public readonly walletUrl: string | null;\n\n constructor(walletUrl: string | null) {\n this.currentWindow = window;\n this.walletUrl = walletUrl;\n }\n\n openOrReuseWallet() {\n if (this.walletWindow == null || this.walletWindow.closed) {\n const height = UltraWalletSdkConfig.height;\n const width = UltraWalletSdkConfig.width;\n const top = this.currentWindow.top;\n const left = this.currentWindow.screenLeft + this.currentWindow.innerWidth - width;\n\n this.walletWindow = window.open(\n this.walletUrl,\n '_blank',\n `width=${width},height=${height},top=${top},left=${left},resizable=0`,\n );\n } else {\n this.walletWindow.focus();\n }\n }\n\n // Provides a reference to the wallet window\n getWalletWindow(): Window | null {\n return this.walletWindow;\n }\n}\n", "import { ClientMessenger } from '../../common/client-messenger';\nimport { WindowManager } from '../../common/window-manager';\nimport UltraWalletSdkConfig from '../../config/ultra-wallet-sdk.config';\nimport {\n AccountInfo,\n AvailableAuth,\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n NetworkDetails,\n ResponseStatus,\n SignMessageResult,\n SignTransactionOptions,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n WalletEventType,\n} from '../../interfaces';\n\nexport class WebProvider implements UltraWalletProvider {\n private readonly windowManager: WindowManager;\n private readonly clientMessenger: ClientMessenger;\n\n constructor(private readonly options?: UltraWalletSdkOptions) {\n this.windowManager = new WindowManager(this.resolveWalletUrl());\n this.clientMessenger = new ClientMessenger(this.windowManager);\n }\n\n connect(options?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n return this.clientMessenger.sendRequest<ConnectResult>('connect', { options });\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return this.clientMessenger.sendRequest<boolean>('disconnect', {});\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return this.clientMessenger.sendRequest<SignMessageResult>('signMessage', { message });\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n options?: SignTransactionOptions,\n ): Promise<UltraResponse<SignTransactionResult>> {\n return this.clientMessenger.sendRequest<SignTransactionResult>('signTransaction', { transaction, options });\n }\n\n async getChainId(): Promise<UltraResponse<string>> {\n const environment = this.options?.environment || 'mainnet';\n\n switch (environment) {\n case 'mainnet':\n const mainnetChainId = UltraWalletSdkConfig.networkInfo.mainnet.chainId;\n return {\n status: ResponseStatus.SUCCESS,\n data: mainnetChainId,\n };\n\n case 'testnet':\n const testnetChainId = UltraWalletSdkConfig.networkInfo.testnet.chainId;\n return {\n status: ResponseStatus.SUCCESS,\n data: testnetChainId,\n };\n\n default:\n return this.clientMessenger.sendRequest<string>('getChainId', {});\n }\n }\n\n getAccounts(): Promise<UltraResponse<AccountInfo[]>> {\n return this.clientMessenger.sendRequest<AccountInfo[]>('getAccounts', {});\n }\n\n getSelectedAccount(): Promise<UltraResponse<AccountInfo>> {\n return this.clientMessenger.sendRequest<AccountInfo>('getSelectedAccount', {});\n }\n\n getAvailableAuthorizations(): Promise<UltraResponse<AvailableAuth[]>> {\n return this.clientMessenger.sendRequest<AvailableAuth[]>('getAvailableAuthorizations', {});\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n on(_event: WalletEventType, _callback: (data: any) => void): void {\n // The Web Wallet provider communicates via postMessage through a popup window.\n // Long-lived event subscriptions are not supported in this transport model.\n // Consumers requiring real-time events should use the Extension provider.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n off(_event: WalletEventType, _callback: (data: any) => void): void {\n // Not supported in web provider — see on() above.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n switchNetwork(_chainId: string): Promise<UltraResponse<void>> {\n throw new Error('Not supported in web provider');\n }\n\n getNetwork(): Promise<UltraResponse<NetworkDetails>> {\n throw new Error('Not supported in web provider');\n }\n\n getNetworks(): Promise<UltraResponse<NetworkDetails[]>> {\n throw new Error('Not supported in web provider');\n }\n\n dispose(): void {\n // Web provider holds no long-lived timers/listeners — the popup-based\n // postMessage transport is request/response only.\n }\n\n /**\n * Built-in networks map to their configured Web Wallet URL (`null` when none is deployed);\n * any other `environment` value is a custom Web Wallet URL.\n */\n private resolveWalletUrl(): string | null {\n const environment = this.options?.environment || 'mainnet';\n const { walletUrls } = UltraWalletSdkConfig;\n return Object.prototype.hasOwnProperty.call(walletUrls, environment)\n ? walletUrls[environment as keyof typeof walletUrls]\n : environment;\n }\n}\n", "export function isExtensionAvailable(): boolean {\n return typeof window !== 'undefined' && 'ultra' in window;\n}\n", "import {\n AccountInfo,\n AvailableAuth,\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n NetworkDetails,\n SignMessageResult,\n SignTransactionOptions,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n UltraWalletSdkProvider,\n WalletEventType,\n} from './interfaces';\nimport { ExtensionProvider, WebProvider } from './providers';\nimport { isExtensionAvailable } from './utils/detection';\n\n/**\n * UltraWalletClient acts as a Facade for interacting with the Ultra Wallet.\n * It provides a unified API regardless of the underlying provider implementation (Extension or Web).\n */\nexport class UltraWalletSDK {\n private provider: UltraWalletProvider;\n\n /**\n * Constructs an UltraWalletClient instance.\n * If the Ultra Wallet Extension is available (window.ultra), it will be used automatically.\n * If the Extension is not available, the Web Wallet provider will be initialized using the given network options.\n *\n * @param {UltraWalletSdkOptions} [options] - Configuration options for the Web Wallet fallback (environment or custom URL).\n */\n constructor(private readonly options?: UltraWalletSdkOptions) {\n this.provider = this.resolveWalletProvider();\n }\n\n connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n return this.provider.connect(params);\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return this.provider.disconnect();\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return this.provider.signMessage(message);\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n options?: SignTransactionOptions,\n ): Promise<UltraResponse<SignTransactionResult>> {\n return this.provider.signTransaction(transaction, options);\n }\n\n getChainId(): Promise<UltraResponse<string>> {\n return this.provider.getChainId();\n }\n\n getAccounts(): Promise<UltraResponse<AccountInfo[]>> {\n return this.provider.getAccounts();\n }\n\n getSelectedAccount(): Promise<UltraResponse<AccountInfo>> {\n return this.provider.getSelectedAccount();\n }\n\n getAvailableAuthorizations(): Promise<UltraResponse<AvailableAuth[]>> {\n return this.provider.getAvailableAuthorizations();\n }\n\n on(event: WalletEventType, callback: (data: any) => void): void {\n this.provider.on(event, callback);\n }\n\n off(event: WalletEventType, callback: (data: any) => void): void {\n this.provider.off(event, callback);\n }\n\n switchNetwork(chainId: string): Promise<UltraResponse<void>> {\n return this.provider.switchNetwork(chainId);\n }\n\n getNetwork(): Promise<UltraResponse<NetworkDetails>> {\n return this.provider.getNetwork();\n }\n\n getNetworks(): Promise<UltraResponse<NetworkDetails[]>> {\n return this.provider.getNetworks();\n }\n\n dispose(): void {\n this.provider.dispose();\n }\n\n private resolveWalletProvider(): UltraWalletProvider {\n const requestedProvider: UltraWalletSdkProvider | undefined = this.options?.provider;\n if (requestedProvider === 'extension') {\n return new ExtensionProvider(this.options);\n }\n if (requestedProvider === 'web') {\n return new WebProvider(this.options);\n }\n\n const extensionAvailable = isExtensionAvailable();\n return extensionAvailable ? new ExtensionProvider(this.options) : new WebProvider(this.options);\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,IAAY;CAAZ,SAAYA,eAAY;AACtB,EAAAA,cAAAA,cAAA,uBAAA,IAAA,IAAA,IAAA;AACA,EAAAA,cAAAA,cAAA,0BAAA,IAAA,IAAA,IAAA;AACA,EAAAA,cAAAA,cAAA,2BAAA,IAAA,IAAA,IAAA;AACA,EAAAA,cAAAA,cAAA,wBAAA,IAAA,IAAA,IAAA;AACA,EAAAA,cAAAA,cAAA,kCAAA,IAAA,KAAA,IAAA;AACA,EAAAA,cAAAA,cAAA,eAAA,IAAA,MAAA,IAAA;AACF,GAPY,iBAAA,eAAY,CAAA,EAAA;AASjB,IAAM,oBAAuD;EAClE,CAAC,aAAa,qBAAqB,GAAG;EACtC,CAAC,aAAa,wBAAwB,GAAG;EACzC,CAAC,aAAa,yBAAyB,GAAG;EAC1C,CAAC,aAAa,sBAAsB,GAClC;EACF,CAAC,aAAa,gCAAgC,GAAG;EACjD,CAAC,aAAa,aAAa,GAAG;;;;ACYhC,IAAY;CAAZ,SAAYC,iBAAc;AACxB,EAAAA,gBAAA,SAAA,IAAA;AACA,EAAAA,gBAAA,MAAA,IAAA;AACA,EAAAA,gBAAA,OAAA,IAAA;AACF,GAJY,mBAAA,iBAAc,CAAA,EAAA;;;ACV1B,IAAM,uBAA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-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"homepage": "https://developers.ultra.io",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"json-rpc-2.0": "^1.7.0",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
16
|
+
"license": "LGPL-3.0-only",
|
|
16
17
|
"types": "./src/index.d.ts",
|
|
17
18
|
"exports": {
|
|
18
19
|
".": {
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
"dist",
|
|
27
28
|
"src",
|
|
28
29
|
"README.md",
|
|
29
|
-
"CHANGELOG.md"
|
|
30
|
+
"CHANGELOG.md",
|
|
31
|
+
"LICENSE"
|
|
30
32
|
]
|
|
31
33
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './lib/interfaces';
|
|
2
|
-
export * from './lib/ultra-wallet-sdk';
|
|
1
|
+
export * from './lib/interfaces/index.js';
|
|
2
|
+
export * from './lib/ultra-wallet-sdk.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UltraResponse } from '../interfaces';
|
|
2
|
-
import { WindowManager } from './window-manager';
|
|
1
|
+
import { UltraResponse } from '../interfaces/index.js';
|
|
2
|
+
import { WindowManager } from './window-manager.js';
|
|
3
3
|
export declare class ClientMessenger {
|
|
4
4
|
private windowManager;
|
|
5
5
|
private rpcClient;
|
|
@@ -15,6 +15,7 @@ export declare class ClientMessenger {
|
|
|
15
15
|
private processRpcRequest;
|
|
16
16
|
private withWindowMonitoring;
|
|
17
17
|
private isValidReadyMessage;
|
|
18
|
+
private createRpcErrorResponse;
|
|
18
19
|
private createErrorResponse;
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=client-messenger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-messenger.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/common/client-messenger.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgD,aAAa,EAAE,MAAM,eAAe,CAAC;AAG5F,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,eAAe;IAC1B,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,cAAc,CAAS;gBAEnB,aAAa,EAAE,aAAa;IAMxC,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,oBAAoB;IAQtB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"client-messenger.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/common/client-messenger.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgD,aAAa,EAAE,MAAM,eAAe,CAAC;AAG5F,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,eAAe;IAC1B,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,cAAc,CAAS;gBAEnB,aAAa,EAAE,aAAa;IAMxC,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,oBAAoB;IAQtB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAqB9G,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,kBAAkB;YAQZ,cAAc;YAYd,kBAAkB;YA+BlB,iBAAiB;YAuBjB,oBAAoB;IAqBlC,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,mBAAmB;CAI5B"}
|
|
@@ -27,6 +27,9 @@ export class ClientMessenger {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
async sendRequest(requestMethod, requestParams) {
|
|
30
|
+
if (!this.windowManager.walletUrl) {
|
|
31
|
+
throw this.createErrorResponse(SdkErrorCode.WEB_WALLET_UNAVAILABLE);
|
|
32
|
+
}
|
|
30
33
|
if (this.pendingRequest && !this.isWalletWindowClosed()) {
|
|
31
34
|
throw this.createErrorResponse(SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE);
|
|
32
35
|
}
|
|
@@ -91,20 +94,16 @@ export class ClientMessenger {
|
|
|
91
94
|
result = await this.rpcClient.request(requestMethod, requestParams);
|
|
92
95
|
}
|
|
93
96
|
catch (error) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
// JSON-RPC-level failure (e.g. the Web Wallet does not implement the method). The wallet
|
|
98
|
+
// has no request to show, so close the popup — left open it would never re-send `ready`
|
|
99
|
+
// and the next request would time out — and surface the wallet's code/message.
|
|
100
|
+
walletWindow.close();
|
|
101
|
+
throw this.createRpcErrorResponse(error);
|
|
99
102
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
throw result;
|
|
106
|
-
}
|
|
103
|
+
if (result?.status === ResponseStatus.SUCCESS) {
|
|
104
|
+
return result;
|
|
107
105
|
}
|
|
106
|
+
throw result;
|
|
108
107
|
});
|
|
109
108
|
}
|
|
110
109
|
async withWindowMonitoring(walletWindow, operation) {
|
|
@@ -132,6 +131,19 @@ export class ClientMessenger {
|
|
|
132
131
|
const msg = event.data;
|
|
133
132
|
return msg?.jsonrpc === '2.0' && msg.method === 'ready';
|
|
134
133
|
}
|
|
134
|
+
createRpcErrorResponse(error) {
|
|
135
|
+
const { code, message } = (error ?? {});
|
|
136
|
+
if (typeof code === 'number') {
|
|
137
|
+
return {
|
|
138
|
+
status: ResponseStatus.ERROR,
|
|
139
|
+
code,
|
|
140
|
+
message: typeof message === 'string' ? message : '',
|
|
141
|
+
data: error.data,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const clientError = new ClientError(SdkErrorCode.UNKNOWN_ERROR);
|
|
145
|
+
return { status: ResponseStatus.ERROR, code: clientError.code, message: clientError.message, data: error };
|
|
146
|
+
}
|
|
135
147
|
createErrorResponse(errorCode) {
|
|
136
148
|
const { code, message } = new ClientError(errorCode);
|
|
137
149
|
return { status: ResponseStatus.ERROR, code, message, data: null };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-messenger.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/common/client-messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAkB,cAAc,EAAE,YAAY,EAAiB,MAAM,eAAe,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,OAAO,eAAe;IAK1B,YAAY,aAA4B;QAFhC,mBAAc,GAAG,KAAK,CAAC;QAG7B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAEO,mBAAmB;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC;YAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC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CAAC,mBAAmB,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;YAE7C,SAAS,EAAE;iBACR,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;gBACf,aAAa,CAAC,UAAU,CAAC,CAAC;gBAC1B,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,aAAa,CAAC,UAAU,CAAC,CAAC;gBAC1B,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,mBAAmB,CAAC,KAAmB;QAC7C,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,SAAS;YAAE,OAAO,KAAK,CAAC;QAEhE,MAAM,GAAG,GAAmB,KAAK,CAAC,IAAI,CAAC;QACvC,OAAO,GAAG,EAAE,OAAO,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO,CAAC;IAC1D,CAAC;IAEO,mBAAmB,CAAC,SAAuB;QACjD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;QACrD,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAa,EAAE,CAAC;IAC9E,CAAC;CACF","sourcesContent":["import { JSONRPCClient } from 'json-rpc-2.0';\n\nimport UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\nimport { JsonRpcMessage, ResponseStatus, SdkErrorCode, UltraResponse } from '../interfaces';\n\nimport { ClientError } from './client-error';\nimport { WindowManager } from './window-manager';\n\nexport class ClientMessenger {\n private windowManager: WindowManager;\n private rpcClient: JSONRPCClient;\n private pendingRequest = false;\n\n constructor(windowManager: WindowManager) {\n this.windowManager = windowManager;\n this.initializeRpcClient();\n this.setupMessageListener();\n }\n\n private initializeRpcClient(): void {\n this.rpcClient = new JSONRPCClient((request) => {\n const walletWindow = this.windowManager.getWalletWindow();\n if (!walletWindow) {\n return Promise.reject(new ClientError(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE));\n }\n walletWindow.postMessage(request, this.windowManager.walletUrl);\n return Promise.resolve();\n });\n }\n\n private setupMessageListener(): void {\n window.addEventListener('message', (event) => {\n if (event.origin === this.windowManager.walletUrl && event.data?.jsonrpc === '2.0') {\n this.rpcClient.receive(event.data);\n }\n });\n }\n\n async sendRequest<T>(requestMethod: string, requestParams: Record<string, unknown>): Promise<UltraResponse<T>> {\n if (this.pendingRequest && !this.isWalletWindowClosed()) {\n throw this.createErrorResponse(SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE);\n }\n\n this.pendingRequest = true;\n\n try {\n this.windowManager.openOrReuseWallet();\n const walletWindow = this.ensureWalletWindow();\n\n return await this.executeRequest<T>(walletWindow, requestMethod, requestParams);\n } finally {\n this.pendingRequest = false;\n }\n }\n\n private isWalletWindowClosed(): boolean {\n return this.windowManager.getWalletWindow()?.closed === true;\n }\n\n private ensureWalletWindow(): Window {\n const walletWindow = this.windowManager.getWalletWindow();\n if (!walletWindow) {\n throw this.createErrorResponse(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE);\n }\n return walletWindow;\n }\n\n private async executeRequest<T>(\n walletWindow: Window,\n requestMethod: string,\n requestParams: Record<string, unknown>,\n ): Promise<UltraResponse<T>> {\n // Wait for wallet handshake first\n await this.waitForWalletReady(walletWindow);\n\n // Then execute the RPC request with window monitoring\n return this.processRpcRequest<T>(walletWindow, requestMethod, requestParams);\n }\n\n private async waitForWalletReady(walletWindow: Window): Promise<void> {\n return this.withWindowMonitoring(walletWindow, () => {\n return new Promise<void>((resolve, reject) => {\n let isResolved = false;\n let timeoutId: any;\n\n const cleanup = () => {\n if (isResolved) return;\n isResolved = true;\n clearTimeout(timeoutId);\n window.removeEventListener('message', handleWalletHandshake);\n };\n\n const handleWalletHandshake = (event: MessageEvent) => {\n if (!this.isValidReadyMessage(event)) return;\n cleanup();\n resolve();\n };\n\n const handleTimeout = () => {\n cleanup();\n walletWindow.close();\n reject(this.createErrorResponse(SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT));\n };\n\n window.addEventListener('message', handleWalletHandshake);\n timeoutId = setTimeout(handleTimeout, UltraWalletSdkConfig.handshakeTimeout);\n });\n });\n }\n\n private async processRpcRequest<T>(\n walletWindow: Window,\n requestMethod: string,\n requestParams: Record<string, unknown>,\n ): Promise<UltraResponse<T>> {\n return this.withWindowMonitoring(walletWindow, async () => {\n let result: UltraResponse<T>;\n\n try {\n result = await this.rpcClient.request(requestMethod, requestParams);\n } catch (error) {\n const clientError = new ClientError(SdkErrorCode.UNKNOWN_ERROR, error);\n throw {\n status: ResponseStatus.ERROR,\n ...clientError,\n };\n } finally {\n if (result?.status === ResponseStatus.SUCCESS) {\n return result;\n } else {\n throw result;\n }\n }\n });\n }\n\n private async withWindowMonitoring<T>(walletWindow: Window, operation: () => Promise<T>): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const intervalId = setInterval(() => {\n if (walletWindow.closed) {\n clearInterval(intervalId);\n reject(this.createErrorResponse(SdkErrorCode.USER_REJECTED_REQUEST));\n }\n }, UltraWalletSdkConfig.checkWindowInterval);\n\n operation()\n .then((result) => {\n clearInterval(intervalId);\n resolve(result);\n })\n .catch((error) => {\n clearInterval(intervalId);\n reject(error);\n });\n });\n }\n\n private isValidReadyMessage(event: MessageEvent): boolean {\n if (event.origin !== this.windowManager.walletUrl) return false;\n\n const msg: JsonRpcMessage = event.data;\n return msg?.jsonrpc === '2.0' && msg.method === 'ready';\n }\n\n private createErrorResponse(errorCode: SdkErrorCode): UltraResponse<never> {\n const { code, message } = new ClientError(errorCode);\n return { status: ResponseStatus.ERROR, code, message, data: null as never };\n }\n}\n"]}
|
|
1
|
+
{"version":3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n\nimport UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\nimport { JsonRpcMessage, ResponseStatus, SdkErrorCode, UltraResponse } from '../interfaces';\n\nimport { ClientError } from './client-error';\nimport { WindowManager } from './window-manager';\n\nexport class ClientMessenger {\n private windowManager: WindowManager;\n private rpcClient: JSONRPCClient;\n private pendingRequest = false;\n\n constructor(windowManager: WindowManager) {\n this.windowManager = windowManager;\n this.initializeRpcClient();\n this.setupMessageListener();\n }\n\n private initializeRpcClient(): void {\n this.rpcClient = new JSONRPCClient((request) => {\n const walletWindow = this.windowManager.getWalletWindow();\n if (!walletWindow) {\n return Promise.reject(new ClientError(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE));\n }\n walletWindow.postMessage(request, this.windowManager.walletUrl);\n return Promise.resolve();\n });\n }\n\n private setupMessageListener(): void {\n window.addEventListener('message', (event) => {\n if (event.origin === this.windowManager.walletUrl && event.data?.jsonrpc === '2.0') {\n this.rpcClient.receive(event.data);\n }\n });\n }\n\n async sendRequest<T>(requestMethod: string, requestParams: Record<string, unknown>): Promise<UltraResponse<T>> {\n if (!this.windowManager.walletUrl) {\n throw this.createErrorResponse(SdkErrorCode.WEB_WALLET_UNAVAILABLE);\n }\n\n if (this.pendingRequest && !this.isWalletWindowClosed()) {\n throw this.createErrorResponse(SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE);\n }\n\n this.pendingRequest = true;\n\n try {\n this.windowManager.openOrReuseWallet();\n const walletWindow = this.ensureWalletWindow();\n\n return await this.executeRequest<T>(walletWindow, requestMethod, requestParams);\n } finally {\n this.pendingRequest = false;\n }\n }\n\n private isWalletWindowClosed(): boolean {\n return this.windowManager.getWalletWindow()?.closed === true;\n }\n\n private ensureWalletWindow(): Window {\n const walletWindow = this.windowManager.getWalletWindow();\n if (!walletWindow) {\n throw this.createErrorResponse(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE);\n }\n return walletWindow;\n }\n\n private async executeRequest<T>(\n walletWindow: Window,\n requestMethod: string,\n requestParams: Record<string, unknown>,\n ): Promise<UltraResponse<T>> {\n // Wait for wallet handshake first\n await this.waitForWalletReady(walletWindow);\n\n // Then execute the RPC request with window monitoring\n return this.processRpcRequest<T>(walletWindow, requestMethod, requestParams);\n }\n\n private async waitForWalletReady(walletWindow: Window): Promise<void> {\n return this.withWindowMonitoring(walletWindow, () => {\n return new Promise<void>((resolve, reject) => {\n let isResolved = false;\n let timeoutId: any;\n\n const cleanup = () => {\n if (isResolved) return;\n isResolved = true;\n clearTimeout(timeoutId);\n window.removeEventListener('message', handleWalletHandshake);\n };\n\n const handleWalletHandshake = (event: MessageEvent) => {\n if (!this.isValidReadyMessage(event)) return;\n cleanup();\n resolve();\n };\n\n const handleTimeout = () => {\n cleanup();\n walletWindow.close();\n reject(this.createErrorResponse(SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT));\n };\n\n window.addEventListener('message', handleWalletHandshake);\n timeoutId = setTimeout(handleTimeout, UltraWalletSdkConfig.handshakeTimeout);\n });\n });\n }\n\n private async processRpcRequest<T>(\n walletWindow: Window,\n requestMethod: string,\n requestParams: Record<string, unknown>,\n ): Promise<UltraResponse<T>> {\n return this.withWindowMonitoring(walletWindow, async () => {\n let result: UltraResponse<T>;\n try {\n result = await this.rpcClient.request(requestMethod, requestParams);\n } catch (error) {\n // JSON-RPC-level failure (e.g. the Web Wallet does not implement the method). The wallet\n // has no request to show, so close the popup — left open it would never re-send `ready`\n // and the next request would time out — and surface the wallet's code/message.\n walletWindow.close();\n throw this.createRpcErrorResponse(error);\n }\n if (result?.status === ResponseStatus.SUCCESS) {\n return result;\n }\n throw result;\n });\n }\n\n private async withWindowMonitoring<T>(walletWindow: Window, operation: () => Promise<T>): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const intervalId = setInterval(() => {\n if (walletWindow.closed) {\n clearInterval(intervalId);\n reject(this.createErrorResponse(SdkErrorCode.USER_REJECTED_REQUEST));\n }\n }, UltraWalletSdkConfig.checkWindowInterval);\n\n operation()\n .then((result) => {\n clearInterval(intervalId);\n resolve(result);\n })\n .catch((error) => {\n clearInterval(intervalId);\n reject(error);\n });\n });\n }\n\n private isValidReadyMessage(event: MessageEvent): boolean {\n if (event.origin !== this.windowManager.walletUrl) return false;\n\n const msg: JsonRpcMessage = event.data;\n return msg?.jsonrpc === '2.0' && msg.method === 'ready';\n }\n\n private createRpcErrorResponse(error: unknown): UltraResponse<never> {\n const { code, message } = (error ?? {}) as { code?: unknown; message?: unknown };\n if (typeof code === 'number') {\n return {\n status: ResponseStatus.ERROR,\n code,\n message: typeof message === 'string' ? message : '',\n data: (error as { data?: never }).data,\n };\n }\n const clientError = new ClientError(SdkErrorCode.UNKNOWN_ERROR);\n return { status: ResponseStatus.ERROR, code: clientError.code, message: clientError.message, data: error as never };\n }\n\n private createErrorResponse(errorCode: SdkErrorCode): UltraResponse<never> {\n const { code, message } = new ClientError(errorCode);\n return { status: ResponseStatus.ERROR, code, message, data: null as never };\n }\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export declare class WindowManager {
|
|
2
2
|
private currentWindow;
|
|
3
3
|
private walletWindow;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/** `null` when no Web Wallet is deployed for the configured network. */
|
|
5
|
+
readonly walletUrl: string | null;
|
|
6
|
+
constructor(walletUrl: string | null);
|
|
6
7
|
openOrReuseWallet(): void;
|
|
7
8
|
getWalletWindow(): Window | null;
|
|
8
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window-manager.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/common/window-manager.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IACxB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAuB;IAC3C,SAAgB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"window-manager.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/common/window-manager.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IACxB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAuB;IAC3C,wEAAwE;IACxE,SAAgB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;gBAE7B,SAAS,EAAE,MAAM,GAAG,IAAI;IAKpC,iBAAiB;IAkBjB,eAAe,IAAI,MAAM,GAAG,IAAI;CAGjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window-manager.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/common/window-manager.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AAErE,MAAM,OAAO,aAAa;
|
|
1
|
+
{"version":3,"file":"window-manager.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/common/window-manager.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AAErE,MAAM,OAAO,aAAa;IAMxB,YAAY,SAAwB;QAJ5B,iBAAY,GAAkB,IAAI,CAAC;QAKzC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,iBAAiB;QACf,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;YAC1D,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC;YAC3C,MAAM,KAAK,GAAG,oBAAoB,CAAC,KAAK,CAAC;YACzC,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;YACnC,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,KAAK,CAAC;YAEnF,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,IAAI,CAC7B,IAAI,CAAC,SAAS,EACd,QAAQ,EACR,SAAS,KAAK,WAAW,MAAM,QAAQ,GAAG,SAAS,IAAI,cAAc,CACtE,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,4CAA4C;IAC5C,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\n\nexport class WindowManager {\n private currentWindow: Window;\n private walletWindow: Window | null = null;\n /** `null` when no Web Wallet is deployed for the configured network. */\n public readonly walletUrl: string | null;\n\n constructor(walletUrl: string | null) {\n this.currentWindow = window;\n this.walletUrl = walletUrl;\n }\n\n openOrReuseWallet() {\n if (this.walletWindow == null || this.walletWindow.closed) {\n const height = UltraWalletSdkConfig.height;\n const width = UltraWalletSdkConfig.width;\n const top = this.currentWindow.top;\n const left = this.currentWindow.screenLeft + this.currentWindow.innerWidth - width;\n\n this.walletWindow = window.open(\n this.walletUrl,\n '_blank',\n `width=${width},height=${height},top=${top},left=${left},resizable=0`,\n );\n } else {\n this.walletWindow.focus();\n }\n }\n\n // Provides a reference to the wallet window\n getWalletWindow(): Window | null {\n return this.walletWindow;\n }\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
interface UltraWalletSdkConfig {
|
|
2
2
|
width: number;
|
|
3
3
|
height: number;
|
|
4
|
+
/** Web Wallet URL per built-in network; `null` = no Web Wallet deployed for that network. */
|
|
4
5
|
walletUrls: {
|
|
5
6
|
mainnet: string;
|
|
6
|
-
testnet: string;
|
|
7
|
+
testnet: string | null;
|
|
7
8
|
};
|
|
8
9
|
checkWindowInterval: number;
|
|
9
10
|
handshakeTimeout: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ultra-wallet-sdk.config.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/config/ultra-wallet-sdk.config.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ultra-wallet-sdk.config.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/config/ultra-wallet-sdk.config.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,6FAA6F;IAC7F,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;IACF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CACjB,SAAS,GAAG,SAAS,EACrB;QACE,OAAO,EAAE,MAAM,CAAC;KACjB,CACF,CAAC;CACH;AAED,QAAA,MAAM,oBAAoB,EAAE,oBAkB1B,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
|
|
@@ -3,7 +3,8 @@ const UltraWalletSdkConfig = Object.freeze({
|
|
|
3
3
|
height: 815,
|
|
4
4
|
walletUrls: {
|
|
5
5
|
mainnet: 'https://web-wallet.ultra.io',
|
|
6
|
-
testnet
|
|
6
|
+
// The testnet Web Wallet (web-wallet.staging.ultra.io) was decommissioned; testnet is extension-only.
|
|
7
|
+
testnet: null,
|
|
7
8
|
},
|
|
8
9
|
networkInfo: {
|
|
9
10
|
mainnet: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ultra-wallet-sdk.config.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/config/ultra-wallet-sdk.config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ultra-wallet-sdk.config.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/config/ultra-wallet-sdk.config.ts"],"names":[],"mappings":"AAkBA,MAAM,oBAAoB,GAAyB,MAAM,CAAC,MAAM,CAAC;IAC/D,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;IACX,UAAU,EAAE;QACV,OAAO,EAAE,6BAA6B;QACtC,sGAAsG;QACtG,OAAO,EAAE,IAAI;KACd;IACD,WAAW,EAAE;QACX,OAAO,EAAE;YACP,OAAO,EAAE,kEAAkE;SAC5E;QACD,OAAO,EAAE;YACP,OAAO,EAAE,kEAAkE;SAC5E;KACF;IACD,mBAAmB,EAAE,GAAG;IACxB,gBAAgB,EAAE,KAAM;CACzB,CAAC,CAAC;AAEH,eAAe,oBAAoB,CAAC","sourcesContent":["interface UltraWalletSdkConfig {\n width: number;\n height: number;\n /** Web Wallet URL per built-in network; `null` = no Web Wallet deployed for that network. */\n walletUrls: {\n mainnet: string;\n testnet: string | null;\n };\n checkWindowInterval: number;\n handshakeTimeout: number;\n networkInfo: Record<\n 'mainnet' | 'testnet',\n {\n chainId: string;\n }\n >;\n}\n\nconst UltraWalletSdkConfig: UltraWalletSdkConfig = Object.freeze({\n width: 420,\n height: 815,\n walletUrls: {\n mainnet: 'https://web-wallet.ultra.io',\n // The testnet Web Wallet (web-wallet.staging.ultra.io) was decommissioned; testnet is extension-only.\n testnet: null,\n },\n networkInfo: {\n mainnet: {\n chainId: 'a9c481dfbc7d9506dc7e87e9a137c931b0a9303f64fd7a1d08b8230133920097',\n },\n testnet: {\n chainId: '7fc56be645bb76ab9d747b53089f132dcb7681db06f0852cfa03eaf6f7ac80e9',\n },\n },\n checkWindowInterval: 500,\n handshakeTimeout: 10_000,\n});\n\nexport default UltraWalletSdkConfig;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-enum.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/error-enum.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,qBAAqB,OAAO;IAC5B,wBAAwB,OAAO;IAC/B,yBAAyB,OAAO;IAChC,gCAAgC,QAAQ;IACxC,aAAa,SAAS;CACvB;AAED,eAAO,MAAM,iBAAiB,EAAE;KAAG,GAAG,IAAI,YAAY,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"error-enum.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/error-enum.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,qBAAqB,OAAO;IAC5B,wBAAwB,OAAO;IAC/B,yBAAyB,OAAO;IAChC,sBAAsB,OAAO;IAC7B,gCAAgC,QAAQ;IACxC,aAAa,SAAS;CACvB;AAED,eAAO,MAAM,iBAAiB,EAAE;KAAG,GAAG,IAAI,YAAY,GAAG,MAAM;CAQ9D,CAAC"}
|
|
@@ -3,6 +3,7 @@ export var SdkErrorCode;
|
|
|
3
3
|
SdkErrorCode[SdkErrorCode["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
|
|
4
4
|
SdkErrorCode[SdkErrorCode["WALLET_HANDSHAKE_TIMEOUT"] = 4300] = "WALLET_HANDSHAKE_TIMEOUT";
|
|
5
5
|
SdkErrorCode[SdkErrorCode["WALLET_WINDOW_UNAVAILABLE"] = 4301] = "WALLET_WINDOW_UNAVAILABLE";
|
|
6
|
+
SdkErrorCode[SdkErrorCode["WEB_WALLET_UNAVAILABLE"] = 4302] = "WEB_WALLET_UNAVAILABLE";
|
|
6
7
|
SdkErrorCode[SdkErrorCode["REQUESTED_RESOURCE_NOT_AVAILABLE"] = 32002] = "REQUESTED_RESOURCE_NOT_AVAILABLE";
|
|
7
8
|
SdkErrorCode[SdkErrorCode["UNKNOWN_ERROR"] = -32604] = "UNKNOWN_ERROR";
|
|
8
9
|
})(SdkErrorCode || (SdkErrorCode = {}));
|
|
@@ -10,6 +11,7 @@ export const SDK_ERROR_MESSAGE = {
|
|
|
10
11
|
[SdkErrorCode.USER_REJECTED_REQUEST]: 'The user rejected the request.',
|
|
11
12
|
[SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT]: 'Timeout to connect with the web wallet.',
|
|
12
13
|
[SdkErrorCode.WALLET_WINDOW_UNAVAILABLE]: 'Wallet window blocked by browser or failed to open.',
|
|
14
|
+
[SdkErrorCode.WEB_WALLET_UNAVAILABLE]: 'The Ultra Web Wallet is not available on this network. Use the Ultra Wallet browser extension.',
|
|
13
15
|
[SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE]: 'Requested resource not available.',
|
|
14
16
|
[SdkErrorCode.UNKNOWN_ERROR]: 'Unknown error occurred.',
|
|
15
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-enum.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/error-enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"error-enum.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/error-enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,oFAA4B,CAAA;IAC5B,0FAA+B,CAAA;IAC/B,4FAAgC,CAAA;IAChC,sFAA6B,CAAA;IAC7B,2GAAwC,CAAA;IACxC,sEAAsB,CAAA;AACxB,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAsC;IAClE,CAAC,YAAY,CAAC,qBAAqB,CAAC,EAAE,gCAAgC;IACtE,CAAC,YAAY,CAAC,wBAAwB,CAAC,EAAE,yCAAyC;IAClF,CAAC,YAAY,CAAC,yBAAyB,CAAC,EAAE,qDAAqD;IAC/F,CAAC,YAAY,CAAC,sBAAsB,CAAC,EACnC,gGAAgG;IAClG,CAAC,YAAY,CAAC,gCAAgC,CAAC,EAAE,mCAAmC;IACpF,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,yBAAyB;CACxD,CAAC","sourcesContent":["export enum SdkErrorCode {\n USER_REJECTED_REQUEST = 4001,\n WALLET_HANDSHAKE_TIMEOUT = 4300,\n WALLET_WINDOW_UNAVAILABLE = 4301,\n WEB_WALLET_UNAVAILABLE = 4302,\n REQUESTED_RESOURCE_NOT_AVAILABLE = 32002,\n UNKNOWN_ERROR = -32604,\n}\n\nexport const SDK_ERROR_MESSAGE: { [key in SdkErrorCode]: string } = {\n [SdkErrorCode.USER_REJECTED_REQUEST]: 'The user rejected the request.',\n [SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT]: 'Timeout to connect with the web wallet.',\n [SdkErrorCode.WALLET_WINDOW_UNAVAILABLE]: 'Wallet window blocked by browser or failed to open.',\n [SdkErrorCode.WEB_WALLET_UNAVAILABLE]:\n 'The Ultra Web Wallet is not available on this network. Use the Ultra Wallet browser extension.',\n [SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE]: 'Requested resource not available.',\n [SdkErrorCode.UNKNOWN_ERROR]: 'Unknown error occurred.',\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './blockchain-transaction.interface';
|
|
2
|
-
export * from './connect-params.interface';
|
|
3
|
-
export * from './error-enum';
|
|
4
|
-
export * from './json-rpc-message.interface';
|
|
5
|
-
export * from './wallet-provider.interface';
|
|
6
|
-
export * from './wallet-provider-response.interface';
|
|
7
|
-
export * from './wallet-sdk-options.interface';
|
|
1
|
+
export * from './blockchain-transaction.interface.js';
|
|
2
|
+
export * from './connect-params.interface.js';
|
|
3
|
+
export * from './error-enum.js';
|
|
4
|
+
export * from './json-rpc-message.interface.js';
|
|
5
|
+
export * from './wallet-provider.interface.js';
|
|
6
|
+
export * from './wallet-provider-response.interface.js';
|
|
7
|
+
export * from './wallet-sdk-options.interface.js';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -100,6 +100,8 @@ export interface NetworkDetails {
|
|
|
100
100
|
* One account the wallet currently holds signing keys for, plus the permission
|
|
101
101
|
* names whose keys it controls. Sourced from the same set the wallet exposes via
|
|
102
102
|
* `ConnectResult.accounts` — never an FE-supplied (spoofable) list (RFC §2.1 / §5.6).
|
|
103
|
+
*
|
|
104
|
+
* @experimental See {@link ConnectAttestation}.
|
|
103
105
|
*/
|
|
104
106
|
export interface SignableAccount {
|
|
105
107
|
/** The blockchain account name. */
|
|
@@ -110,6 +112,8 @@ export interface SignableAccount {
|
|
|
110
112
|
/**
|
|
111
113
|
* The signed payload of a connect-time identity attestation (RFC §2.1). The canonical
|
|
112
114
|
* form — JSON with sorted keys, UTF-8 encoded, SHA-256 hashed — is what the wallet signs.
|
|
115
|
+
*
|
|
116
|
+
* @experimental See {@link ConnectAttestation}.
|
|
113
117
|
*/
|
|
114
118
|
export interface AttestationPayload {
|
|
115
119
|
/** Attestation format version. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-provider-response.interface.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/wallet-provider-response.interface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IACpC;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IACvB;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IACR;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,EAAE,cAAc,EAAE,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED
|
|
1
|
+
{"version":3,"file":"wallet-provider-response.interface.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/wallet-provider-response.interface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IACpC;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IACvB;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IACR;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,EAAE,cAAc,EAAE,CAAC;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C,EAAE,MAAM,CAAC;IACnD,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;QAClC,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE;QACH,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,EAAE;YACb,KAAK,EAAE,MAAM,CAAC;YACd,UAAU,EAAE,MAAM,CAAC;SACpB,EAAE,CAAC;QACJ,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;YACb,EAAE,EAAE,MAAM,CAAC;YACX,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QACF,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,kBAAkB,EAAE,GAAG,EAAE,CAAC;IAC1B,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,WAAW,EAAE,CAAC;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-provider-response.interface.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/wallet-provider-response.interface.ts"],"names":[],"mappings":"AAyBA;;GAEG;AACH,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,+BAAa,CAAA;IACb,iCAAe,CAAA;AACjB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB","sourcesContent":["/**\n * A generic wrapper for all Ultra Wallet SDK responses.\n * Encapsulates the status, data payload, and optional error messaging or codes.\n *\n * @template T The type of the data payload contained in the response.\n */\nexport interface UltraResponse<T = any> {\n /**\n * The status of the response, e.g., success, fail, or error.\n */\n status: ResponseStatus;\n /**\n * The actual response data payload.\n */\n data: T;\n /**\n * Optional end-user-readable message, explaining what went wrong (if applicable).\n */\n message?: string;\n /**\n * Optional error or status code.\n */\n code?: number;\n}\n\n/**\n * Enumeration of possible response statuses returned by the Ultra Wallet SDK.\n */\nexport enum ResponseStatus {\n SUCCESS = 'success',\n FAIL = 'fail',\n ERROR = 'error',\n}\n\n/**\n * Represents the result of a disconnect request.\n * A boolean indicating whether the disconnection was successful.\n */\nexport type DisconnectResponse = boolean;\n\n/**\n * Represents a single permission entry associated with a blockchain account.\n */\nexport interface PermissionInfo {\n /**\n * The permission level name (e.g., \"active\", \"owner\").\n */\n name: string;\n /**\n * The public keys associated with this permission.\n */\n publicKeys: string[];\n}\n\n/**\n * Represents a blockchain account with its associated permissions.\n */\nexport interface AccountInfo {\n /**\n * The blockchain account name.\n */\n accountName: string;\n /**\n * The list of permissions associated with this account.\n */\n permissions: PermissionInfo[];\n}\n\n/**\n * Represents information about the connected blockchain network.\n */\nexport interface NetworkInfo {\n /**\n * The human-readable name of the network (e.g., \"mainnet\", \"testnet\").\n */\n name: string;\n /**\n * The unique chain identifier.\n */\n chainId: string;\n}\n\n/**\n * Extended network information including connection details.\n * Returned by getNetwork and getNetworks.\n */\nexport interface NetworkDetails {\n /**\n * The human-readable name of the network (e.g., \"mainnet\", \"testnet\").\n */\n name: string;\n /**\n * The unique chain identifier.\n */\n chainId: string;\n /**\n * The RPC node URL for the network.\n */\n nodeUrl: string;\n /**\n * Whether this is a user-defined custom network.\n */\n isCustom?: boolean;\n}\n\n/**\n * One account the wallet currently holds signing keys for, plus the permission\n * names whose keys it controls. Sourced from the same set the wallet exposes via\n * `ConnectResult.accounts` — never an FE-supplied (spoofable) list (RFC §2.1 / §5.6).\n */\nexport interface SignableAccount {\n /** The blockchain account name. */\n account: string;\n /** The permission names the wallet holds the signing key for (e.g. `active`). */\n permissions: string[];\n}\n\n/**\n * The signed payload of a connect-time identity attestation (RFC §2.1). The canonical\n * form — JSON with sorted keys, UTF-8 encoded, SHA-256 hashed — is what the wallet signs.\n */\nexport interface AttestationPayload {\n /** Attestation format version. */\n v: 1;\n /** The signing public key (e.g. `EOS...` / `UTR...`). */\n pubkey: string;\n /** The primary account name (the one signing). */\n account: string;\n /** The permission used to sign (e.g. `active`, `owner`). */\n permission: string;\n /** The dApp origin the attestation is bound to (e.g. `http://localhost:5172`). */\n origin: string;\n /** The chain identifier the attestation is scoped to. */\n chainId: string;\n /** Issued-at, unix seconds. */\n iat: number;\n /** Expiry, unix seconds. */\n exp: number;\n /** 32-byte random value, hex-encoded. */\n nonce: string;\n /**\n * The full set of accounts the wallet currently holds signing keys for, each with\n * the permission names it controls. Lets a backend reason about the user's real\n * account set without trusting an FE-supplied (spoofable) list. Omitted when the\n * wallet doesn't enumerate additional accounts — backends MUST fall back to the\n * primary `account` field on absence.\n */\n signableAccounts?: SignableAccount[];\n}\n\n/**\n * A connect-time identity attestation, optionally produced by the wallet when the\n * user approves a `connect()`. Rides the existing connect consent — no extra popup.\n *\n * Present only if the connected wallet vendor supports silent attestation; absent\n * otherwise. dApps treat absence as \"fall back to whatever auth this dApp uses\n * without attestation\". The SDK does not verify or transform this value — it is\n * passed through verbatim from the wallet. Verification is the consumer backend's\n * responsibility (see RFC §2.4 / §5).\n *\n * @see https://github.com/ultraio/ultra-tool-kit/blob/feature/ai-enhancement/docs/proposals/wallet-native-attestation.md\n *\n * @experimental Issued only by the browser-extension wallet and not yet consumed by any\n * Ultra service; the shape may change before it is stabilised.\n */\nexport interface ConnectAttestation {\n /** The signed identity payload. */\n payload: AttestationPayload;\n /** Signature over the canonical hash of `payload` (e.g. `SIG_K1_...`). */\n signature: string;\n}\n\n/**\n * Represents the result of a successful connection request, containing the user's account details.\n * Backward-compatible: legacy fields `blockchainid` and `publicKey` are preserved alongside\n * the new multi-account fields.\n */\nexport type ConnectResult = {\n /**\n * The connected (selected) account name, e.g. `aa1aa2aa3aa4` — not a chain id.\n * Equals `selectedAccount.accountName` when the wallet returns `selectedAccount`;\n * the Web Wallet returns only this legacy field.\n * @deprecated Use `selectedAccount.accountName` when present.\n */\n blockchainid: string;\n /**\n * The public key associated with the user's account.\n * @deprecated Use `selectedAccount.permissions[n].publicKeys` instead.\n */\n publicKey: string;\n /**\n * All accounts available in the connected wallet.\n */\n accounts?: AccountInfo[];\n /**\n * The currently selected account.\n */\n selectedAccount?: AccountInfo;\n /**\n * Information about the connected blockchain network.\n */\n network?: NetworkInfo;\n /**\n * The nonce passed to `connect({ nonce })`, echoed back. Present only when a nonce was sent.\n */\n nonce?: string;\n /**\n * The wallet's signature over `nonce` (same scheme as `signMessage`). Present only when a nonce was sent.\n */\n signedNonce?: string;\n /**\n * An optional connect-time identity attestation. Present only when the connected\n * wallet vendor supports silent attestation; `undefined` otherwise. Passed through\n * verbatim from the wallet — the SDK does not verify or transform it.\n * @experimental See {@link ConnectAttestation}.\n */\n attestation?: ConnectAttestation;\n};\n\n/**\n * Represents the result returned after signing a message with the Ultra Wallet.\n */\nexport interface SignMessageResult {\n signature: string;\n}\n\n/**\n * Represents the result returned after signing a blockchain transaction with the Ultra Wallet.\n */\nexport interface SignTransactionResult {\n /**\n * The hash of the signed blockchain transaction.\n */\n transactionHash?: string;\n /**\n * Authorizations that couldn't be signed because the wallet lacks the keys.\n * Format: [\"account@permission\", ...]\n * Absent or empty means all authorizations were signed.\n */\n unsignedAuth?: string[];\n processed?: {\n id: string;\n block_num: number;\n block_time: string; // ISO timestamp\n producer_block_id: string | null;\n receipt: {\n status: string;\n cpu_usage_us: number;\n net_usage_words: number;\n };\n elapsed: number;\n net_usage: number;\n scheduled: boolean;\n action_traces: ActionTrace[];\n account_ram_delta: any | null;\n except: any | null;\n error_code: number | null;\n };\n}\n\nexport interface ActionTrace {\n action_ordinal: number;\n creator_action_ordinal: number;\n closest_unnotified_ancestor_action_ordinal: number;\n receipt: {\n receiver: string;\n act_digest: string;\n global_sequence: number;\n recv_sequence: number;\n auth_sequence: [string, number][];\n code_sequence: number;\n abi_sequence: number;\n };\n receiver: string;\n act: {\n account: string;\n name: string;\n authorization: {\n actor: string;\n permission: string;\n }[];\n data: {\n from: string;\n to: string;\n quantity: string;\n memo: string;\n };\n hex_data: string;\n };\n context_free: boolean;\n elapsed: number;\n console: string;\n trx_id: string;\n block_num: number;\n block_time: string;\n producer_block_id: string | null;\n account_ram_deltas: any[];\n except: any | null;\n error_code: number | null;\n return_value_hex_data: string;\n inline_traces: ActionTrace[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wallet-provider-response.interface.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/wallet-provider-response.interface.ts"],"names":[],"mappings":"AAyBA;;GAEG;AACH,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,+BAAa,CAAA;IACb,iCAAe,CAAA;AACjB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB","sourcesContent":["/**\n * A generic wrapper for all Ultra Wallet SDK responses.\n * Encapsulates the status, data payload, and optional error messaging or codes.\n *\n * @template T The type of the data payload contained in the response.\n */\nexport interface UltraResponse<T = any> {\n /**\n * The status of the response, e.g., success, fail, or error.\n */\n status: ResponseStatus;\n /**\n * The actual response data payload.\n */\n data: T;\n /**\n * Optional end-user-readable message, explaining what went wrong (if applicable).\n */\n message?: string;\n /**\n * Optional error or status code.\n */\n code?: number;\n}\n\n/**\n * Enumeration of possible response statuses returned by the Ultra Wallet SDK.\n */\nexport enum ResponseStatus {\n SUCCESS = 'success',\n FAIL = 'fail',\n ERROR = 'error',\n}\n\n/**\n * Represents the result of a disconnect request.\n * A boolean indicating whether the disconnection was successful.\n */\nexport type DisconnectResponse = boolean;\n\n/**\n * Represents a single permission entry associated with a blockchain account.\n */\nexport interface PermissionInfo {\n /**\n * The permission level name (e.g., \"active\", \"owner\").\n */\n name: string;\n /**\n * The public keys associated with this permission.\n */\n publicKeys: string[];\n}\n\n/**\n * Represents a blockchain account with its associated permissions.\n */\nexport interface AccountInfo {\n /**\n * The blockchain account name.\n */\n accountName: string;\n /**\n * The list of permissions associated with this account.\n */\n permissions: PermissionInfo[];\n}\n\n/**\n * Represents information about the connected blockchain network.\n */\nexport interface NetworkInfo {\n /**\n * The human-readable name of the network (e.g., \"mainnet\", \"testnet\").\n */\n name: string;\n /**\n * The unique chain identifier.\n */\n chainId: string;\n}\n\n/**\n * Extended network information including connection details.\n * Returned by getNetwork and getNetworks.\n */\nexport interface NetworkDetails {\n /**\n * The human-readable name of the network (e.g., \"mainnet\", \"testnet\").\n */\n name: string;\n /**\n * The unique chain identifier.\n */\n chainId: string;\n /**\n * The RPC node URL for the network.\n */\n nodeUrl: string;\n /**\n * Whether this is a user-defined custom network.\n */\n isCustom?: boolean;\n}\n\n/**\n * One account the wallet currently holds signing keys for, plus the permission\n * names whose keys it controls. Sourced from the same set the wallet exposes via\n * `ConnectResult.accounts` — never an FE-supplied (spoofable) list (RFC §2.1 / §5.6).\n *\n * @experimental See {@link ConnectAttestation}.\n */\nexport interface SignableAccount {\n /** The blockchain account name. */\n account: string;\n /** The permission names the wallet holds the signing key for (e.g. `active`). */\n permissions: string[];\n}\n\n/**\n * The signed payload of a connect-time identity attestation (RFC §2.1). The canonical\n * form — JSON with sorted keys, UTF-8 encoded, SHA-256 hashed — is what the wallet signs.\n *\n * @experimental See {@link ConnectAttestation}.\n */\nexport interface AttestationPayload {\n /** Attestation format version. */\n v: 1;\n /** The signing public key (e.g. `EOS...` / `UTR...`). */\n pubkey: string;\n /** The primary account name (the one signing). */\n account: string;\n /** The permission used to sign (e.g. `active`, `owner`). */\n permission: string;\n /** The dApp origin the attestation is bound to (e.g. `http://localhost:5172`). */\n origin: string;\n /** The chain identifier the attestation is scoped to. */\n chainId: string;\n /** Issued-at, unix seconds. */\n iat: number;\n /** Expiry, unix seconds. */\n exp: number;\n /** 32-byte random value, hex-encoded. */\n nonce: string;\n /**\n * The full set of accounts the wallet currently holds signing keys for, each with\n * the permission names it controls. Lets a backend reason about the user's real\n * account set without trusting an FE-supplied (spoofable) list. Omitted when the\n * wallet doesn't enumerate additional accounts — backends MUST fall back to the\n * primary `account` field on absence.\n */\n signableAccounts?: SignableAccount[];\n}\n\n/**\n * A connect-time identity attestation, optionally produced by the wallet when the\n * user approves a `connect()`. Rides the existing connect consent — no extra popup.\n *\n * Present only if the connected wallet vendor supports silent attestation; absent\n * otherwise. dApps treat absence as \"fall back to whatever auth this dApp uses\n * without attestation\". The SDK does not verify or transform this value — it is\n * passed through verbatim from the wallet. Verification is the consumer backend's\n * responsibility (see RFC §2.4 / §5).\n *\n * @see https://github.com/ultraio/ultra-tool-kit/blob/feature/ai-enhancement/docs/proposals/wallet-native-attestation.md\n *\n * @experimental Issued only by the browser-extension wallet and not yet consumed by any\n * Ultra service; the shape may change before it is stabilised.\n */\nexport interface ConnectAttestation {\n /** The signed identity payload. */\n payload: AttestationPayload;\n /** Signature over the canonical hash of `payload` (e.g. `SIG_K1_...`). */\n signature: string;\n}\n\n/**\n * Represents the result of a successful connection request, containing the user's account details.\n * Backward-compatible: legacy fields `blockchainid` and `publicKey` are preserved alongside\n * the new multi-account fields.\n */\nexport type ConnectResult = {\n /**\n * The connected (selected) account name, e.g. `aa1aa2aa3aa4` — not a chain id.\n * Equals `selectedAccount.accountName` when the wallet returns `selectedAccount`;\n * the Web Wallet returns only this legacy field.\n * @deprecated Use `selectedAccount.accountName` when present.\n */\n blockchainid: string;\n /**\n * The public key associated with the user's account.\n * @deprecated Use `selectedAccount.permissions[n].publicKeys` instead.\n */\n publicKey: string;\n /**\n * All accounts available in the connected wallet.\n */\n accounts?: AccountInfo[];\n /**\n * The currently selected account.\n */\n selectedAccount?: AccountInfo;\n /**\n * Information about the connected blockchain network.\n */\n network?: NetworkInfo;\n /**\n * The nonce passed to `connect({ nonce })`, echoed back. Present only when a nonce was sent.\n */\n nonce?: string;\n /**\n * The wallet's signature over `nonce` (same scheme as `signMessage`). Present only when a nonce was sent.\n */\n signedNonce?: string;\n /**\n * An optional connect-time identity attestation. Present only when the connected\n * wallet vendor supports silent attestation; `undefined` otherwise. Passed through\n * verbatim from the wallet — the SDK does not verify or transform it.\n * @experimental See {@link ConnectAttestation}.\n */\n attestation?: ConnectAttestation;\n};\n\n/**\n * Represents the result returned after signing a message with the Ultra Wallet.\n */\nexport interface SignMessageResult {\n signature: string;\n}\n\n/**\n * Represents the result returned after signing a blockchain transaction with the Ultra Wallet.\n */\nexport interface SignTransactionResult {\n /**\n * The hash of the signed blockchain transaction.\n */\n transactionHash?: string;\n /**\n * Authorizations that couldn't be signed because the wallet lacks the keys.\n * Format: [\"account@permission\", ...]\n * Absent or empty means all authorizations were signed.\n */\n unsignedAuth?: string[];\n processed?: {\n id: string;\n block_num: number;\n block_time: string; // ISO timestamp\n producer_block_id: string | null;\n receipt: {\n status: string;\n cpu_usage_us: number;\n net_usage_words: number;\n };\n elapsed: number;\n net_usage: number;\n scheduled: boolean;\n action_traces: ActionTrace[];\n account_ram_delta: any | null;\n except: any | null;\n error_code: number | null;\n };\n}\n\nexport interface ActionTrace {\n action_ordinal: number;\n creator_action_ordinal: number;\n closest_unnotified_ancestor_action_ordinal: number;\n receipt: {\n receiver: string;\n act_digest: string;\n global_sequence: number;\n recv_sequence: number;\n auth_sequence: [string, number][];\n code_sequence: number;\n abi_sequence: number;\n };\n receiver: string;\n act: {\n account: string;\n name: string;\n authorization: {\n actor: string;\n permission: string;\n }[];\n data: {\n from: string;\n to: string;\n quantity: string;\n memo: string;\n };\n hex_data: string;\n };\n context_free: boolean;\n elapsed: number;\n console: string;\n trx_id: string;\n block_num: number;\n block_time: string;\n producer_block_id: string | null;\n account_ram_deltas: any[];\n except: any | null;\n error_code: number | null;\n return_value_hex_data: string;\n inline_traces: ActionTrace[];\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BlockchainTransaction, SignTransactionOptions } from './blockchain-transaction.interface';
|
|
2
|
-
import { AvailableAuth } from './blockchain-transaction.interface';
|
|
3
|
-
import { ConnectParams } from './connect-params.interface';
|
|
4
|
-
import { AccountInfo, ConnectResult, DisconnectResponse, NetworkDetails, SignMessageResult, SignTransactionResult, UltraResponse } from './wallet-provider-response.interface';
|
|
1
|
+
import { BlockchainTransaction, SignTransactionOptions } from './blockchain-transaction.interface.js';
|
|
2
|
+
import { AvailableAuth } from './blockchain-transaction.interface.js';
|
|
3
|
+
import { ConnectParams } from './connect-params.interface.js';
|
|
4
|
+
import { AccountInfo, ConnectResult, DisconnectResponse, NetworkDetails, SignMessageResult, SignTransactionResult, UltraResponse } from './wallet-provider-response.interface.js';
|
|
5
5
|
/**
|
|
6
6
|
* Event types emitted by the wallet provider.
|
|
7
7
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountInfo, AvailableAuth, BlockchainTransaction, ConnectParams, ConnectResult, NetworkDetails, SignMessageResult, SignTransactionOptions, SignTransactionResult, UltraResponse, UltraWalletProvider, UltraWalletSdkOptions, WalletEventType } from '../../interfaces';
|
|
1
|
+
import { AccountInfo, AvailableAuth, BlockchainTransaction, ConnectParams, ConnectResult, NetworkDetails, SignMessageResult, SignTransactionOptions, SignTransactionResult, UltraResponse, UltraWalletProvider, UltraWalletSdkOptions, WalletEventType } from '../../interfaces/index.js';
|
|
2
2
|
export declare class ExtensionProvider implements UltraWalletProvider {
|
|
3
3
|
private readonly options?;
|
|
4
4
|
private readonly eventListeners;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './extension-provider/extension.provider';
|
|
2
|
-
export * from './web-provider/web.provider';
|
|
1
|
+
export * from './extension-provider/extension.provider.js';
|
|
2
|
+
export * from './web-provider/web.provider.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountInfo, AvailableAuth, BlockchainTransaction, ConnectParams, ConnectResult, NetworkDetails, SignMessageResult, SignTransactionOptions, SignTransactionResult, UltraResponse, UltraWalletProvider, UltraWalletSdkOptions, WalletEventType } from '../../interfaces';
|
|
1
|
+
import { AccountInfo, AvailableAuth, BlockchainTransaction, ConnectParams, ConnectResult, NetworkDetails, SignMessageResult, SignTransactionOptions, SignTransactionResult, UltraResponse, UltraWalletProvider, UltraWalletSdkOptions, WalletEventType } from '../../interfaces/index.js';
|
|
2
2
|
export declare class WebProvider implements UltraWalletProvider {
|
|
3
3
|
private readonly options?;
|
|
4
4
|
private readonly windowManager;
|
|
@@ -18,6 +18,10 @@ export declare class WebProvider implements UltraWalletProvider {
|
|
|
18
18
|
getNetwork(): Promise<UltraResponse<NetworkDetails>>;
|
|
19
19
|
getNetworks(): Promise<UltraResponse<NetworkDetails[]>>;
|
|
20
20
|
dispose(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Built-in networks map to their configured Web Wallet URL (`null` when none is deployed);
|
|
23
|
+
* any other `environment` value is a custom Web Wallet URL.
|
|
24
|
+
*/
|
|
21
25
|
private resolveWalletUrl;
|
|
22
26
|
}
|
|
23
27
|
//# sourceMappingURL=web.provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.provider.d.ts","sourceRoot":"","sources":["../../../../../../../libs/wallet-sdk/src/lib/providers/web-provider/web.provider.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,cAAc,EAEd,iBAAiB,EACjB,sBAAsB,EACtB,qB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AI7D,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAIpD,WAAW,IAAI,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC;IAIvD,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"web.provider.d.ts","sourceRoot":"","sources":["../../../../../../../libs/wallet-sdk/src/lib/providers/web-provider/web.provider.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,cAAc,EAEd,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,WAAY,YAAW,mBAAmB;IAIzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAHrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;gBAErB,OAAO,CAAC,EAAE,qBAAqB;IAK5D,OAAO,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAIvE,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAI7C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAIvE,eAAe,CACb,WAAW,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,EAC5D,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAI1C,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAuBlD,WAAW,IAAI,OAAO,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IAIpD,kBAAkB,IAAI,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IAIzD,0BAA0B,IAAI,OAAO,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,CAAC;IAKrE,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAOjE,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAKlE,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAI7D,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAIpD,WAAW,IAAI,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC;IAIvD,OAAO,IAAI,IAAI;IAKf;;;OAGG;IACH,OAAO,CAAC,gBAAgB;CAOzB"}
|
|
@@ -72,9 +72,16 @@ export class WebProvider {
|
|
|
72
72
|
// Web provider holds no long-lived timers/listeners — the popup-based
|
|
73
73
|
// postMessage transport is request/response only.
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Built-in networks map to their configured Web Wallet URL (`null` when none is deployed);
|
|
77
|
+
* any other `environment` value is a custom Web Wallet URL.
|
|
78
|
+
*/
|
|
75
79
|
resolveWalletUrl() {
|
|
76
|
-
const
|
|
77
|
-
|
|
80
|
+
const environment = this.options?.environment || 'mainnet';
|
|
81
|
+
const { walletUrls } = UltraWalletSdkConfig;
|
|
82
|
+
return Object.prototype.hasOwnProperty.call(walletUrls, environment)
|
|
83
|
+
? walletUrls[environment]
|
|
84
|
+
: environment;
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
//# sourceMappingURL=web.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.provider.js","sourceRoot":"","sources":["../../../../../../../libs/wallet-sdk/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,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,WAAW,IAAI,SAAS,CAAC;QAC3D,MAAM,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAAC;QAC5C,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC;YAClE,CAAC,CAAC,UAAU,CAAC,WAAsC,CAAC;YACpD,CAAC,CAAC,WAAW,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { ClientMessenger } from '../../common/client-messenger';\nimport { WindowManager } from '../../common/window-manager';\nimport UltraWalletSdkConfig from '../../config/ultra-wallet-sdk.config';\nimport {\n AccountInfo,\n AvailableAuth,\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n NetworkDetails,\n ResponseStatus,\n SignMessageResult,\n SignTransactionOptions,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n WalletEventType,\n} from '../../interfaces';\n\nexport class WebProvider implements UltraWalletProvider {\n private readonly windowManager: WindowManager;\n private readonly clientMessenger: ClientMessenger;\n\n constructor(private readonly options?: UltraWalletSdkOptions) {\n this.windowManager = new WindowManager(this.resolveWalletUrl());\n this.clientMessenger = new ClientMessenger(this.windowManager);\n }\n\n connect(options?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n return this.clientMessenger.sendRequest<ConnectResult>('connect', { options });\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return this.clientMessenger.sendRequest<boolean>('disconnect', {});\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return this.clientMessenger.sendRequest<SignMessageResult>('signMessage', { message });\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n options?: SignTransactionOptions,\n ): Promise<UltraResponse<SignTransactionResult>> {\n return this.clientMessenger.sendRequest<SignTransactionResult>('signTransaction', { transaction, options });\n }\n\n async getChainId(): Promise<UltraResponse<string>> {\n const environment = this.options?.environment || 'mainnet';\n\n switch (environment) {\n case 'mainnet':\n const mainnetChainId = UltraWalletSdkConfig.networkInfo.mainnet.chainId;\n return {\n status: ResponseStatus.SUCCESS,\n data: mainnetChainId,\n };\n\n case 'testnet':\n const testnetChainId = UltraWalletSdkConfig.networkInfo.testnet.chainId;\n return {\n status: ResponseStatus.SUCCESS,\n data: testnetChainId,\n };\n\n default:\n return this.clientMessenger.sendRequest<string>('getChainId', {});\n }\n }\n\n getAccounts(): Promise<UltraResponse<AccountInfo[]>> {\n return this.clientMessenger.sendRequest<AccountInfo[]>('getAccounts', {});\n }\n\n getSelectedAccount(): Promise<UltraResponse<AccountInfo>> {\n return this.clientMessenger.sendRequest<AccountInfo>('getSelectedAccount', {});\n }\n\n getAvailableAuthorizations(): Promise<UltraResponse<AvailableAuth[]>> {\n return this.clientMessenger.sendRequest<AvailableAuth[]>('getAvailableAuthorizations', {});\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n on(_event: WalletEventType, _callback: (data: any) => void): void {\n // The Web Wallet provider communicates via postMessage through a popup window.\n // Long-lived event subscriptions are not supported in this transport model.\n // Consumers requiring real-time events should use the Extension provider.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n off(_event: WalletEventType, _callback: (data: any) => void): void {\n // Not supported in web provider — see on() above.\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n switchNetwork(_chainId: string): Promise<UltraResponse<void>> {\n throw new Error('Not supported in web provider');\n }\n\n getNetwork(): Promise<UltraResponse<NetworkDetails>> {\n throw new Error('Not supported in web provider');\n }\n\n getNetworks(): Promise<UltraResponse<NetworkDetails[]>> {\n throw new Error('Not supported in web provider');\n }\n\n dispose(): void {\n // Web provider holds no long-lived timers/listeners — the popup-based\n // postMessage transport is request/response only.\n }\n\n /**\n * Built-in networks map to their configured Web Wallet URL (`null` when none is deployed);\n * any other `environment` value is a custom Web Wallet URL.\n */\n private resolveWalletUrl(): string | null {\n const environment = this.options?.environment || 'mainnet';\n const { walletUrls } = UltraWalletSdkConfig;\n return Object.prototype.hasOwnProperty.call(walletUrls, environment)\n ? walletUrls[environment as keyof typeof walletUrls]\n : environment;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountInfo, AvailableAuth, BlockchainTransaction, ConnectParams, ConnectResult, NetworkDetails, SignMessageResult, SignTransactionOptions, SignTransactionResult, UltraResponse, UltraWalletSdkOptions, WalletEventType } from './interfaces';
|
|
1
|
+
import { AccountInfo, AvailableAuth, BlockchainTransaction, ConnectParams, ConnectResult, NetworkDetails, SignMessageResult, SignTransactionOptions, SignTransactionResult, UltraResponse, UltraWalletSdkOptions, WalletEventType } from './interfaces/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* UltraWalletClient acts as a Facade for interacting with the Ultra Wallet.
|
|
4
4
|
* It provides a unified API regardless of the underlying provider implementation (Extension or Web).
|