@swivy/core 1.0.0 → 1.0.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.
|
@@ -5,6 +5,8 @@ export interface SealedExportEncryption {
|
|
|
5
5
|
encapsulatedKey: string;
|
|
6
6
|
ciphertext: string;
|
|
7
7
|
aead?: string;
|
|
8
|
+
kem?: string;
|
|
9
|
+
kdf?: string;
|
|
8
10
|
}
|
|
9
11
|
/** A one-time X25519 key pair for receiving a sealed export. Send `publicKeyBase64`. */
|
|
10
12
|
export declare function generateExportRecipientKeyPair(): {
|
|
@@ -49,6 +49,9 @@ export function generateExportRecipientKeyPair() {
|
|
|
49
49
|
}
|
|
50
50
|
export function openHpkeBase(params) {
|
|
51
51
|
const aead = params.aead ?? "aes-256-gcm";
|
|
52
|
+
if (aead !== "aes-128-gcm" && aead !== "aes-256-gcm") {
|
|
53
|
+
throw new Error("unsupported_hpke_aead");
|
|
54
|
+
}
|
|
52
55
|
const aeadId = aead === "aes-128-gcm" ? 0x0001 : 0x0002;
|
|
53
56
|
const keyLength = aead === "aes-128-gcm" ? 16 : 32;
|
|
54
57
|
const recipientPublic = x25519.getPublicKey(params.recipientPrivateKey);
|
|
@@ -67,6 +70,14 @@ export function openHpkeBase(params) {
|
|
|
67
70
|
}
|
|
68
71
|
/** Open the `encryption` object a sealed export returns. Throws if it was tampered with. */
|
|
69
72
|
export function openSealedExport(encryption, recipientPrivateKey) {
|
|
73
|
+
// Older v1 clients omitted suite labels. Preserve that fixed-suite format,
|
|
74
|
+
// but never interpret an explicitly different or future suite as v1.
|
|
75
|
+
if (encryption.info !== "swivy-export-v1"
|
|
76
|
+
|| (encryption.kem !== undefined && encryption.kem !== "DHKEM(X25519, HKDF-SHA256)")
|
|
77
|
+
|| (encryption.kdf !== undefined && encryption.kdf !== "HKDF-SHA256")
|
|
78
|
+
|| (encryption.aead !== undefined && encryption.aead !== "AES-256-GCM")) {
|
|
79
|
+
throw new Error("unsupported_sealed_export_suite");
|
|
80
|
+
}
|
|
70
81
|
const plaintext = openHpkeBase({
|
|
71
82
|
recipientPrivateKey,
|
|
72
83
|
encapsulatedKey: fromBase64(encryption.encapsulatedKey),
|
|
@@ -376,6 +376,8 @@ export interface SessionGrantRules {
|
|
|
376
376
|
allowedSelectors?: string[];
|
|
377
377
|
/** Max native value per transaction, in wei (decimal string). */
|
|
378
378
|
maxValueWei?: string | null;
|
|
379
|
+
/** Maximum gasLimit × gasPrice/maxFeePerGas, in wei. Excludes L2 data fees and sponsor costs. */
|
|
380
|
+
maxExecutionGasCostWei?: string;
|
|
379
381
|
allowedChainIds?: number[];
|
|
380
382
|
/**
|
|
381
383
|
* EIP-712. `allowedVerifyingContracts` is required to sign typed data at all. The
|
|
@@ -427,6 +429,13 @@ export interface SessionGrantScope {
|
|
|
427
429
|
/** Valid until revoked (Privy-style standing signer). Needs sessionPolicy.allowStandingGrants and rules. */
|
|
428
430
|
standing?: boolean;
|
|
429
431
|
rules?: SessionGrantRules;
|
|
432
|
+
/** Gross encoded components only; not total wallet loss or USD. Never automatically refunded. */
|
|
433
|
+
cumulativeEvmComponents?: {
|
|
434
|
+
mode: "encoded_native_components_v1";
|
|
435
|
+
chainId: 1 | 11155111;
|
|
436
|
+
maxValueWei: string;
|
|
437
|
+
maxExecutionGasCostWei: string;
|
|
438
|
+
};
|
|
430
439
|
}
|
|
431
440
|
export interface SessionGrantDescriptor {
|
|
432
441
|
id: string;
|
|
@@ -438,6 +447,11 @@ export interface SessionGrantDescriptor {
|
|
|
438
447
|
publicKey: string;
|
|
439
448
|
label: string | null;
|
|
440
449
|
scope: SessionGrantScope;
|
|
450
|
+
/** Null means unavailable/corrupt state; never interpret it as a zero balance. */
|
|
451
|
+
cumulativeEvmUsage?: {
|
|
452
|
+
reservedValueWei: string;
|
|
453
|
+
reservedExecutionGasCostWei: string;
|
|
454
|
+
} | null;
|
|
441
455
|
uses: number;
|
|
442
456
|
expiresAt: string;
|
|
443
457
|
lastUsedAt: string | null;
|