@account-kit/signer 4.86.0 → 4.87.0
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/dist/esm/base.d.ts +7 -0
- package/dist/esm/base.js +14 -0
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/client/base.d.ts +7 -0
- package/dist/esm/client/base.js +37 -1
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/base.d.ts +7 -0
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/client/base.d.ts +7 -0
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/base.ts +10 -0
- package/src/client/base.ts +39 -0
- package/src/version.ts +1 -1
package/src/client/base.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
recoverPublicKey,
|
|
8
8
|
serializeSignature,
|
|
9
9
|
sha256,
|
|
10
|
+
toHex,
|
|
10
11
|
fromHex,
|
|
11
12
|
type Address,
|
|
12
13
|
type Hex,
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
OAuthProvidersError,
|
|
17
18
|
UnsupportedFeatureError,
|
|
18
19
|
} from "../errors.js";
|
|
20
|
+
import { decryptExportBundle } from "@turnkey/crypto";
|
|
19
21
|
import { getDefaultProviderCustomization } from "../oauth.js";
|
|
20
22
|
import type { OauthMode } from "../signer.js";
|
|
21
23
|
import { base64UrlEncode } from "../utils/base64UrlEncode.js";
|
|
@@ -59,6 +61,7 @@ import type {
|
|
|
59
61
|
import { VERSION } from "../version.js";
|
|
60
62
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
61
63
|
import { Point } from "@noble/secp256k1";
|
|
64
|
+
import { p256 } from "@noble/curves/p256";
|
|
62
65
|
|
|
63
66
|
export interface BaseSignerClientParams {
|
|
64
67
|
stamper: TurnkeyClient["stamper"];
|
|
@@ -1562,6 +1565,42 @@ export abstract class BaseSignerClient<
|
|
|
1562
1565
|
};
|
|
1563
1566
|
};
|
|
1564
1567
|
|
|
1568
|
+
/**
|
|
1569
|
+
* Exports a private key for a given account
|
|
1570
|
+
*
|
|
1571
|
+
* @param {ExportPrivateKeyParams} opts the parameters for the export
|
|
1572
|
+
* @returns {Promise<string>} the private key
|
|
1573
|
+
*/
|
|
1574
|
+
public exportPrivateKey = async (
|
|
1575
|
+
opts: ExportPrivateKeyParams,
|
|
1576
|
+
): Promise<string> => {
|
|
1577
|
+
if (!this.user) {
|
|
1578
|
+
throw new NotAuthenticatedError();
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
const targetPrivateKey = p256.utils.randomPrivateKey();
|
|
1582
|
+
const targetPublicKey = p256.getPublicKey(targetPrivateKey, false);
|
|
1583
|
+
const orgId = opts.orgId ?? this.user.orgId;
|
|
1584
|
+
const keyFormat = opts.type === "ETHEREUM" ? "HEXADECIMAL" : "SOLANA";
|
|
1585
|
+
|
|
1586
|
+
const { exportBundle } = await this.exportPrivateKeyEncrypted({
|
|
1587
|
+
type: opts.type,
|
|
1588
|
+
client: opts.client ?? this.turnkeyClient,
|
|
1589
|
+
orgId: orgId,
|
|
1590
|
+
encryptWith: toHex(targetPublicKey).slice(2),
|
|
1591
|
+
});
|
|
1592
|
+
|
|
1593
|
+
const decrypted = await decryptExportBundle({
|
|
1594
|
+
exportBundle,
|
|
1595
|
+
embeddedKey: toHex(targetPrivateKey).slice(2),
|
|
1596
|
+
organizationId: orgId,
|
|
1597
|
+
returnMnemonic: false,
|
|
1598
|
+
keyFormat,
|
|
1599
|
+
});
|
|
1600
|
+
|
|
1601
|
+
return decrypted;
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1565
1604
|
/**
|
|
1566
1605
|
* Exports a private key for a given account in a multi-owner org
|
|
1567
1606
|
*
|
package/src/version.ts
CHANGED