@xian-tech/wallet-core 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +18 -0
- package/dist/approvals.d.ts +26 -2
- package/dist/approvals.d.ts.map +1 -1
- package/dist/approvals.js +358 -280
- package/dist/approvals.js.map +1 -1
- package/dist/controller.d.ts +37 -2
- package/dist/controller.d.ts.map +1 -1
- package/dist/controller.js +349 -159
- package/dist/controller.js.map +1 -1
- package/dist/crypto.d.ts +7 -1
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +39 -13
- package/dist/crypto.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +3 -0
- package/dist/network.js.map +1 -1
- package/dist/signing-context.d.ts +5 -0
- package/dist/signing-context.d.ts.map +1 -0
- package/dist/signing-context.js +22 -0
- package/dist/signing-context.js.map +1 -0
- package/dist/simulation.d.ts +10 -0
- package/dist/simulation.d.ts.map +1 -0
- package/dist/simulation.js +25 -0
- package/dist/simulation.js.map +1 -0
- package/dist/text-safety.d.ts +4 -0
- package/dist/text-safety.d.ts.map +1 -0
- package/dist/text-safety.js +15 -0
- package/dist/text-safety.js.map +1 -0
- package/dist/types.d.ts +12 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/wallet-encryption.d.ts +7 -0
- package/dist/wallet-encryption.d.ts.map +1 -0
- package/dist/wallet-encryption.js +23 -0
- package/dist/wallet-encryption.js.map +1 -0
- package/package.json +7 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Xian Technology
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -32,3 +32,21 @@ flowchart LR
|
|
|
32
32
|
Core --> Provider["Provider enforcement"]
|
|
33
33
|
Provider --> Client["@xian-tech/client"]
|
|
34
34
|
```
|
|
35
|
+
|
|
36
|
+
## Wallet encryption and session persistence
|
|
37
|
+
|
|
38
|
+
New wallets and version-2 encrypted backups use PBKDF2-SHA256 at 600,000
|
|
39
|
+
iterations with AES-256-GCM. Wallets lacking stored iteration metadata use the
|
|
40
|
+
original 250,000 iterations. Password unlock prepares every account key,
|
|
41
|
+
mnemonic and shielded snapshot before replacing a legacy encrypted record.
|
|
42
|
+
|
|
43
|
+
Custom `WalletStateStore` implementations can enable migration with
|
|
44
|
+
`replaceState(expected, next)`, which must compare and replace atomically with
|
|
45
|
+
respect to ordinary saves and deletion. Return `false` if the expected record
|
|
46
|
+
changed. Stores without this capability keep legacy wallets readable at their
|
|
47
|
+
existing work factor. Ordinary writers must reject changed encryption contexts and removed records.
|
|
48
|
+
The controller marks explicit setup/import with `saveState(state, { replace: true })`
|
|
49
|
+
so a deliberate wallet replacement remains possible.
|
|
50
|
+
|
|
51
|
+
Session persistence serializes saves and deletion. Lock invalidates pending
|
|
52
|
+
reads and writes, so an earlier operation cannot restore an obsolete session.
|
package/dist/approvals.d.ts
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
import type { ApprovalKind, ApprovalView, PendingApprovalRecord } from "./types.js";
|
|
2
2
|
export declare function formatChiWithXianCost(value: unknown, chiRate: number | null | undefined): string | null;
|
|
3
|
+
export type UnusedChiSeverity = "none" | "caution" | "high";
|
|
4
|
+
export interface UnusedChiCost {
|
|
5
|
+
supplied: number;
|
|
6
|
+
estimated: number;
|
|
7
|
+
/** Supplied chi the call leaves unused. */
|
|
8
|
+
unused: number;
|
|
9
|
+
/** What the unused chi costs: half of it, rounded down (execution revision 14). */
|
|
10
|
+
extraChi: number;
|
|
11
|
+
/** none: at most the SDK margin's 1 chi; high: the extra at least doubles the fee. */
|
|
12
|
+
severity: UnusedChiSeverity;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What a chi limit costs beyond what the call needs: a paid transaction pays
|
|
16
|
+
* the chi it uses plus half of the chi it supplies but leaves unused.
|
|
17
|
+
*/
|
|
18
|
+
export declare function unusedChiCost(input: {
|
|
19
|
+
supplied: number;
|
|
20
|
+
estimated: number;
|
|
21
|
+
}): UnusedChiCost | null;
|
|
22
|
+
/** The sentence that tells the user what the unused chi costs, or null when nothing does. */
|
|
23
|
+
export declare function unusedChiWarning(cost: UnusedChiCost, chiRate: number | null | undefined): string | null;
|
|
3
24
|
export declare function approvalKindFromMethod(method: string): ApprovalKind;
|
|
4
|
-
export
|
|
25
|
+
export interface ApprovalViewOptions {
|
|
5
26
|
account?: string;
|
|
6
27
|
chainId?: string;
|
|
7
28
|
targetChainId?: string;
|
|
8
29
|
chiRate?: number | null;
|
|
9
|
-
|
|
30
|
+
/** The simulated chi of a transaction whose chi limit the site chose. */
|
|
31
|
+
estimatedChi?: number | null;
|
|
32
|
+
}
|
|
33
|
+
export declare function buildApprovalView(approval: PendingApprovalRecord, options?: ApprovalViewOptions): ApprovalView;
|
|
10
34
|
//# sourceMappingURL=approvals.d.ts.map
|
package/dist/approvals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../src/approvals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../src/approvals.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,YAAY,EAEZ,YAAY,EACZ,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAyEpB,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACjC,MAAM,GAAG,IAAI,CAaf;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAE5D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAMD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,GAAG,IAAI,CASlG;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACjC,MAAM,GAAG,IAAI,CAWf;AA6FD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAmBnE;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AA8XD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CAed"}
|