@account-kit/privy-integration 4.73.1-alpha.4 → 4.73.1-alpha.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/dist/esm/adapters/react-native.js +12 -3
- package/dist/esm/adapters/react-native.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/adapters/react-native.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/adapters/react-native.ts +88 -73
- package/src/version.ts +1 -1
|
@@ -22,11 +22,15 @@ export const reactNativeAdapter = {
|
|
|
22
22
|
},
|
|
23
23
|
useAuthorizationSigner() {
|
|
24
24
|
const { wallets } = useEmbeddedEthereumWallet();
|
|
25
|
-
|
|
25
|
+
// Don't memoize the callback - create it fresh each time to ensure we have the latest wallets
|
|
26
|
+
const signAuthorization = async (unsignedAuth) => {
|
|
27
|
+
console.log("[RN Adapter] signAuthorization called with:", unsignedAuth);
|
|
28
|
+
console.log("[RN Adapter] Current wallets:", wallets);
|
|
26
29
|
const wallet = wallets?.[0];
|
|
27
30
|
if (!wallet) {
|
|
28
31
|
throw new Error("Privy embedded wallet not found. Please ensure the user is authenticated and has created a wallet.");
|
|
29
32
|
}
|
|
33
|
+
console.log("[RN Adapter] Using wallet:", wallet.address);
|
|
30
34
|
const provider = await wallet.getProvider?.();
|
|
31
35
|
if (!provider) {
|
|
32
36
|
throw new Error("Provider not available on this wallet. Ensure you're using the embedded Ethereum wallet.");
|
|
@@ -36,6 +40,7 @@ export const reactNativeAdapter = {
|
|
|
36
40
|
if (!implementationAddress) {
|
|
37
41
|
throw new Error("Implementation address is required for EIP-7702 authorization");
|
|
38
42
|
}
|
|
43
|
+
console.log("[RN Adapter] Signing 7702 auth for address:", implementationAddress);
|
|
39
44
|
// EIP-7702 Authorization structure
|
|
40
45
|
const authorization = {
|
|
41
46
|
domain: {
|
|
@@ -61,6 +66,7 @@ export const reactNativeAdapter = {
|
|
|
61
66
|
method: "eth_signTypedData_v4",
|
|
62
67
|
params: [wallet.address, JSON.stringify(authorization)],
|
|
63
68
|
}));
|
|
69
|
+
console.log("[RN Adapter] Received signature:", signature);
|
|
64
70
|
// Parse the signature into r, s, v components
|
|
65
71
|
// Signature format: 0x[r(64)][s(64)][v(2)]
|
|
66
72
|
const r = `0x${signature.slice(2, 66)}`;
|
|
@@ -69,7 +75,7 @@ export const reactNativeAdapter = {
|
|
|
69
75
|
// Convert v to yParity (0 or 1)
|
|
70
76
|
// v can be 27/28 (legacy) or 0/1 (EIP-155)
|
|
71
77
|
const yParity = v >= 27 ? v - 27 : v;
|
|
72
|
-
|
|
78
|
+
const result = {
|
|
73
79
|
chainId: unsignedAuth.chainId,
|
|
74
80
|
address: implementationAddress,
|
|
75
81
|
nonce: unsignedAuth.nonce,
|
|
@@ -77,7 +83,10 @@ export const reactNativeAdapter = {
|
|
|
77
83
|
s,
|
|
78
84
|
yParity,
|
|
79
85
|
};
|
|
80
|
-
|
|
86
|
+
console.log("[RN Adapter] Returning authorization:", result);
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
89
|
+
return signAuthorization;
|
|
81
90
|
},
|
|
82
91
|
};
|
|
83
92
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native.js","sourceRoot":"","sources":["../../../src/adapters/react-native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EACL,QAAQ,EACR,yBAAyB,GAE1B,MAAM,gBAAgB,CAAC;AAexB;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,iBAAiB;QACf,MAAM,EAAE,OAAO,EAAE,GAAG,yBAAyB,EAAE,CAAC;QAEhD,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAmB,EAAE;YACzD,MAAM,MAAM,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC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,uCAAuC,EAAE,MAAM,CAAC,CAAC;YAC7D,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QAEF,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF,CAAC;AAEF;;;;;GAKG;AACH,SAAS,eAAe,CAAC,MAA0B;IACjD,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAwB;QACxC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,GAAG;QAC9B,mBAAmB,EAAE,KAAK,IAAI,EAAE;YAC9B,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback } from \"react\";\nimport {\n usePrivy,\n useEmbeddedEthereumWallet,\n type PrivyEmbeddedWalletProvider,\n} from \"@privy-io/expo\";\nimport type { Authorization } from \"viem\";\nimport type { AuthorizationRequest } from \"@aa-sdk/core\";\nimport type { PrivyAdapter, EmbeddedWallet, PrivyAuthState } from \"./types.js\";\n\n/**\n * Wallet type from @privy-io/expo\n * Based on the example app structure\n */\ninterface ExpoEmbeddedWallet {\n address: string;\n chainId?: string;\n getProvider?: () => Promise<PrivyEmbeddedWalletProvider>;\n}\n\n/**\n * React Native (Expo) adapter for @privy-io/expo\n * Implements platform-specific hooks for React Native applications\n */\nexport const reactNativeAdapter: PrivyAdapter = {\n useEmbeddedWallet() {\n const { wallets } = useEmbeddedEthereumWallet();\n\n const getEmbeddedWallet = useCallback((): EmbeddedWallet => {\n const wallet = wallets?.[0];\n if (!wallet) {\n throw new Error(\n \"Privy embedded wallet not found. Please ensure the user is authenticated and has created a wallet.\",\n );\n }\n\n return adaptExpoWallet(wallet);\n }, [wallets]);\n\n return getEmbeddedWallet;\n },\n\n usePrivyAuth(): PrivyAuthState {\n const { user } = usePrivy();\n return { authenticated: !!user, user };\n },\n\n useAuthorizationSigner() {\n const { wallets } = useEmbeddedEthereumWallet();\n\n // Don't memoize the callback - create it fresh each time to ensure we have the latest wallets\n const signAuthorization = async (\n unsignedAuth: AuthorizationRequest<number>,\n ): Promise<Authorization<number, true>> => {\n console.log(\"[RN Adapter] signAuthorization called with:\", unsignedAuth);\n console.log(\"[RN Adapter] Current wallets:\", wallets);\n\n const wallet = wallets?.[0];\n if (!wallet) {\n throw new Error(\n \"Privy embedded wallet not found. Please ensure the user is authenticated and has created a wallet.\",\n );\n }\n\n console.log(\"[RN Adapter] Using wallet:\", wallet.address);\n\n const provider = await wallet.getProvider?.();\n if (!provider) {\n throw new Error(\n \"Provider not available on this wallet. Ensure you're using the embedded Ethereum wallet.\",\n );\n }\n\n // Extract the implementation address (handle both 'address' and 'contractAddress' fields)\n const implementationAddress =\n unsignedAuth.address ?? unsignedAuth.contractAddress;\n\n if (!implementationAddress) {\n throw new Error(\n \"Implementation address is required for EIP-7702 authorization\",\n );\n }\n\n console.log(\n \"[RN Adapter] Signing 7702 auth for address:\",\n implementationAddress,\n );\n\n // EIP-7702 Authorization structure\n const authorization = {\n domain: {\n name: \"EIP-7702\",\n version: \"1\",\n chainId: unsignedAuth.chainId,\n },\n types: {\n Authorization: [\n { name: \"chainId\", type: \"uint256\" },\n { name: \"address\", type: \"address\" },\n { name: \"nonce\", type: \"uint256\" },\n ],\n },\n primaryType: \"Authorization\" as const,\n message: {\n chainId: unsignedAuth.chainId,\n address: implementationAddress,\n nonce: unsignedAuth.nonce,\n },\n };\n\n const signature = (await provider.request({\n method: \"eth_signTypedData_v4\",\n params: [wallet.address, JSON.stringify(authorization)],\n })) as `0x${string}`;\n\n console.log(\"[RN Adapter] Received signature:\", signature);\n\n // Parse the signature into r, s, v components\n // Signature format: 0x[r(64)][s(64)][v(2)]\n const r = `0x${signature.slice(2, 66)}` as `0x${string}`;\n const s = `0x${signature.slice(66, 130)}` as `0x${string}`;\n const v = parseInt(signature.slice(130, 132), 16);\n\n // Convert v to yParity (0 or 1)\n // v can be 27/28 (legacy) or 0/1 (EIP-155)\n const yParity = v >= 27 ? v - 27 : v;\n\n const result = {\n chainId: unsignedAuth.chainId,\n address: implementationAddress,\n nonce: unsignedAuth.nonce,\n r,\n s,\n yParity,\n };\n\n console.log(\"[RN Adapter] Returning authorization:\", result);\n return result;\n };\n\n return signAuthorization;\n },\n};\n\n/**\n * Adapts an Expo wallet to the common EmbeddedWallet interface\n *\n * @param {ExpoEmbeddedWallet} wallet - The Expo embedded wallet to adapt\n * @returns {EmbeddedWallet} The adapted wallet following the common interface\n */\nfunction adaptExpoWallet(wallet: ExpoEmbeddedWallet): EmbeddedWallet {\n return {\n address: wallet.address as `0x${string}`,\n chainId: wallet.chainId || \"1\",\n getEthereumProvider: async () => {\n if (!wallet.getProvider) {\n throw new Error(\n \"getProvider is not available on this wallet. Ensure you're using the embedded Ethereum wallet.\",\n );\n }\n return await wallet.getProvider();\n },\n };\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.73.1-alpha.
|
|
1
|
+
export declare const VERSION = "4.73.1-alpha.5";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.73.1-alpha.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.73.1-alpha.5\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native.d.ts","sourceRoot":"","sources":["../../../src/adapters/react-native.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAkC,MAAM,YAAY,CAAC;AAY/E;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"react-native.d.ts","sourceRoot":"","sources":["../../../src/adapters/react-native.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAkC,MAAM,YAAY,CAAC;AAY/E;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,YAsHhC,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.73.1-alpha.
|
|
1
|
+
export declare const VERSION = "4.73.1-alpha.5";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/privy-integration",
|
|
3
|
-
"version": "4.73.1-alpha.
|
|
3
|
+
"version": "4.73.1-alpha.5",
|
|
4
4
|
"description": "Use Alchemy gas sponsorship, swaps and more with Privy",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
96
96
|
},
|
|
97
97
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "6492299e9fe5f647c41ba7ba9e33b71d54a52547"
|
|
99
99
|
}
|
|
@@ -48,82 +48,97 @@ export const reactNativeAdapter: PrivyAdapter = {
|
|
|
48
48
|
useAuthorizationSigner() {
|
|
49
49
|
const { wallets } = useEmbeddedEthereumWallet();
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
// Parse the signature into r, s, v components
|
|
107
|
-
// Signature format: 0x[r(64)][s(64)][v(2)]
|
|
108
|
-
const r = `0x${signature.slice(2, 66)}` as `0x${string}`;
|
|
109
|
-
const s = `0x${signature.slice(66, 130)}` as `0x${string}`;
|
|
110
|
-
const v = parseInt(signature.slice(130, 132), 16);
|
|
111
|
-
|
|
112
|
-
// Convert v to yParity (0 or 1)
|
|
113
|
-
// v can be 27/28 (legacy) or 0/1 (EIP-155)
|
|
114
|
-
const yParity = v >= 27 ? v - 27 : v;
|
|
115
|
-
|
|
116
|
-
return {
|
|
51
|
+
// Don't memoize the callback - create it fresh each time to ensure we have the latest wallets
|
|
52
|
+
const signAuthorization = async (
|
|
53
|
+
unsignedAuth: AuthorizationRequest<number>,
|
|
54
|
+
): Promise<Authorization<number, true>> => {
|
|
55
|
+
console.log("[RN Adapter] signAuthorization called with:", unsignedAuth);
|
|
56
|
+
console.log("[RN Adapter] Current wallets:", wallets);
|
|
57
|
+
|
|
58
|
+
const wallet = wallets?.[0];
|
|
59
|
+
if (!wallet) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
"Privy embedded wallet not found. Please ensure the user is authenticated and has created a wallet.",
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
console.log("[RN Adapter] Using wallet:", wallet.address);
|
|
66
|
+
|
|
67
|
+
const provider = await wallet.getProvider?.();
|
|
68
|
+
if (!provider) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
"Provider not available on this wallet. Ensure you're using the embedded Ethereum wallet.",
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Extract the implementation address (handle both 'address' and 'contractAddress' fields)
|
|
75
|
+
const implementationAddress =
|
|
76
|
+
unsignedAuth.address ?? unsignedAuth.contractAddress;
|
|
77
|
+
|
|
78
|
+
if (!implementationAddress) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
"Implementation address is required for EIP-7702 authorization",
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(
|
|
85
|
+
"[RN Adapter] Signing 7702 auth for address:",
|
|
86
|
+
implementationAddress,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// EIP-7702 Authorization structure
|
|
90
|
+
const authorization = {
|
|
91
|
+
domain: {
|
|
92
|
+
name: "EIP-7702",
|
|
93
|
+
version: "1",
|
|
94
|
+
chainId: unsignedAuth.chainId,
|
|
95
|
+
},
|
|
96
|
+
types: {
|
|
97
|
+
Authorization: [
|
|
98
|
+
{ name: "chainId", type: "uint256" },
|
|
99
|
+
{ name: "address", type: "address" },
|
|
100
|
+
{ name: "nonce", type: "uint256" },
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
primaryType: "Authorization" as const,
|
|
104
|
+
message: {
|
|
117
105
|
chainId: unsignedAuth.chainId,
|
|
118
106
|
address: implementationAddress,
|
|
119
107
|
nonce: unsignedAuth.nonce,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const signature = (await provider.request({
|
|
112
|
+
method: "eth_signTypedData_v4",
|
|
113
|
+
params: [wallet.address, JSON.stringify(authorization)],
|
|
114
|
+
})) as `0x${string}`;
|
|
115
|
+
|
|
116
|
+
console.log("[RN Adapter] Received signature:", signature);
|
|
117
|
+
|
|
118
|
+
// Parse the signature into r, s, v components
|
|
119
|
+
// Signature format: 0x[r(64)][s(64)][v(2)]
|
|
120
|
+
const r = `0x${signature.slice(2, 66)}` as `0x${string}`;
|
|
121
|
+
const s = `0x${signature.slice(66, 130)}` as `0x${string}`;
|
|
122
|
+
const v = parseInt(signature.slice(130, 132), 16);
|
|
123
|
+
|
|
124
|
+
// Convert v to yParity (0 or 1)
|
|
125
|
+
// v can be 27/28 (legacy) or 0/1 (EIP-155)
|
|
126
|
+
const yParity = v >= 27 ? v - 27 : v;
|
|
127
|
+
|
|
128
|
+
const result = {
|
|
129
|
+
chainId: unsignedAuth.chainId,
|
|
130
|
+
address: implementationAddress,
|
|
131
|
+
nonce: unsignedAuth.nonce,
|
|
132
|
+
r,
|
|
133
|
+
s,
|
|
134
|
+
yParity,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
console.log("[RN Adapter] Returning authorization:", result);
|
|
138
|
+
return result;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return signAuthorization;
|
|
127
142
|
},
|
|
128
143
|
};
|
|
129
144
|
|
package/src/version.ts
CHANGED