@lumiapassport/core 1.0.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/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/auth/index.cjs +652 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +202 -0
- package/dist/auth/index.d.ts +202 -0
- package/dist/auth/index.js +631 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/bundler/index.cjs +497 -0
- package/dist/bundler/index.cjs.map +1 -0
- package/dist/bundler/index.d.cts +144 -0
- package/dist/bundler/index.d.ts +144 -0
- package/dist/bundler/index.js +465 -0
- package/dist/bundler/index.js.map +1 -0
- package/dist/clients/index.cjs +8 -0
- package/dist/clients/index.cjs.map +1 -0
- package/dist/clients/index.d.cts +7 -0
- package/dist/clients/index.d.ts +7 -0
- package/dist/clients/index.js +6 -0
- package/dist/clients/index.js.map +1 -0
- package/dist/index.cjs +1310 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +60 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +1243 -0
- package/dist/index.js.map +1 -0
- package/dist/mpc/index.cjs +8 -0
- package/dist/mpc/index.cjs.map +1 -0
- package/dist/mpc/index.d.cts +7 -0
- package/dist/mpc/index.d.ts +7 -0
- package/dist/mpc/index.js +6 -0
- package/dist/mpc/index.js.map +1 -0
- package/dist/utils/index.cjs +198 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +114 -0
- package/dist/utils/index.d.ts +114 -0
- package/dist/utils/index.js +182 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project ID management for Lumia Passport Core
|
|
3
|
+
* Adapted to work in both browser and Node.js environments
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Set the global project ID
|
|
7
|
+
* @param projectId - The project ID to set
|
|
8
|
+
*/
|
|
9
|
+
declare function setProjectId(projectId: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Get the current project ID
|
|
12
|
+
* Priority: 1. Explicitly set via setProjectId(), 2. window.__LUMIA_PROJECT_ID__ (browser only)
|
|
13
|
+
*/
|
|
14
|
+
declare function getProjectId(): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Add projectId to URL query parameters
|
|
17
|
+
* @param url - The URL to add projectId to
|
|
18
|
+
* @param projectId - Optional explicit projectId (uses getProjectId() if not provided)
|
|
19
|
+
*/
|
|
20
|
+
declare function addProjectIdToUrl(url: string, projectId?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Clear the globally set project ID
|
|
23
|
+
*/
|
|
24
|
+
declare function clearProjectId(): void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Universal environment variable access that works in both browser and Node.js
|
|
28
|
+
*/
|
|
29
|
+
interface EnvVars {
|
|
30
|
+
[key: string]: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get a single environment variable
|
|
34
|
+
* @param name - The environment variable name
|
|
35
|
+
* @returns The environment variable value or undefined
|
|
36
|
+
*/
|
|
37
|
+
declare function getEnvVar(name: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Get an environment variable as boolean
|
|
40
|
+
* @param name - The environment variable name
|
|
41
|
+
* @returns true if value is 'true' or '1', false otherwise
|
|
42
|
+
*/
|
|
43
|
+
declare function getEnvVarBool(name: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get an environment variable as array
|
|
46
|
+
* @param name - The environment variable name
|
|
47
|
+
* @param separator - Separator character (default: ',')
|
|
48
|
+
* @returns Array of trimmed non-empty strings
|
|
49
|
+
*/
|
|
50
|
+
declare function getEnvVarArray(name: string, separator?: string): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Get all environment variables
|
|
53
|
+
* @returns Object containing all environment variables
|
|
54
|
+
*/
|
|
55
|
+
declare function getAllEnvVars(): EnvVars;
|
|
56
|
+
/**
|
|
57
|
+
* Check if running in development mode
|
|
58
|
+
* @returns true if NODE_ENV or MODE is 'development'
|
|
59
|
+
*/
|
|
60
|
+
declare function isDevelopment(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Check if running in production mode
|
|
63
|
+
* @returns true if NODE_ENV or MODE is 'production'
|
|
64
|
+
*/
|
|
65
|
+
declare function isProduction(): boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Account Abstraction helper utilities
|
|
69
|
+
* Adapted from lumia-passport-ui-kit/src/internal/akHelpers.ts
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* Precompile address for ecrecover
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* ABI for ecrecover precompile
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Safely convert value to BigInt with fallback
|
|
81
|
+
* @param val - Value to convert
|
|
82
|
+
* @param fallback - Fallback value if conversion fails
|
|
83
|
+
*/
|
|
84
|
+
declare const safeToBigInt: (val: any, fallback?: string) => bigint;
|
|
85
|
+
/**
|
|
86
|
+
* Pack two 128-bit values into single 256-bit value
|
|
87
|
+
* Used for packing gas limits in ERC-4337 v0.7
|
|
88
|
+
* @param hi - High 128 bits
|
|
89
|
+
* @param lo - Low 128 bits
|
|
90
|
+
* @returns Packed 256-bit value as bigint
|
|
91
|
+
*/
|
|
92
|
+
declare const pack2x128: (hi: bigint, lo: bigint) => bigint;
|
|
93
|
+
/**
|
|
94
|
+
* Verify signature against expected owner address
|
|
95
|
+
* @param opHash - Operation hash that was signed
|
|
96
|
+
* @param signature - Signature to verify
|
|
97
|
+
* @param expectedOwner - Expected owner address
|
|
98
|
+
*/
|
|
99
|
+
declare function verifySignatureAgainstOwner(opHash: `0x${string}`, signature: `0x${string}`, expectedOwner?: `0x${string}`): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Fetch nonce from EntryPoint contract
|
|
102
|
+
* @param account - Account address
|
|
103
|
+
* @param _entryPoint - EntryPoint contract address (unused in placeholder)
|
|
104
|
+
*/
|
|
105
|
+
declare function fetchEntryPointNonce(account: `0x${string}`, _entryPoint: `0x${string}`): Promise<`0x${string}`>;
|
|
106
|
+
/**
|
|
107
|
+
* Make RPC call to bundler
|
|
108
|
+
* @param method - RPC method name
|
|
109
|
+
* @param params - RPC method parameters
|
|
110
|
+
* @param bundlerUrl - Bundler URL (will be fetched from config if not provided)
|
|
111
|
+
*/
|
|
112
|
+
declare function bundlerRpc(method: string, params: any[], bundlerUrl?: string): Promise<any>;
|
|
113
|
+
|
|
114
|
+
export { addProjectIdToUrl, bundlerRpc, clearProjectId, fetchEntryPointNonce, getAllEnvVars, getEnvVar, getEnvVarArray, getEnvVarBool, getProjectId, isDevelopment, isProduction, pack2x128, safeToBigInt, setProjectId, verifySignatureAgainstOwner };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project ID management for Lumia Passport Core
|
|
3
|
+
* Adapted to work in both browser and Node.js environments
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Set the global project ID
|
|
7
|
+
* @param projectId - The project ID to set
|
|
8
|
+
*/
|
|
9
|
+
declare function setProjectId(projectId: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Get the current project ID
|
|
12
|
+
* Priority: 1. Explicitly set via setProjectId(), 2. window.__LUMIA_PROJECT_ID__ (browser only)
|
|
13
|
+
*/
|
|
14
|
+
declare function getProjectId(): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Add projectId to URL query parameters
|
|
17
|
+
* @param url - The URL to add projectId to
|
|
18
|
+
* @param projectId - Optional explicit projectId (uses getProjectId() if not provided)
|
|
19
|
+
*/
|
|
20
|
+
declare function addProjectIdToUrl(url: string, projectId?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Clear the globally set project ID
|
|
23
|
+
*/
|
|
24
|
+
declare function clearProjectId(): void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Universal environment variable access that works in both browser and Node.js
|
|
28
|
+
*/
|
|
29
|
+
interface EnvVars {
|
|
30
|
+
[key: string]: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get a single environment variable
|
|
34
|
+
* @param name - The environment variable name
|
|
35
|
+
* @returns The environment variable value or undefined
|
|
36
|
+
*/
|
|
37
|
+
declare function getEnvVar(name: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Get an environment variable as boolean
|
|
40
|
+
* @param name - The environment variable name
|
|
41
|
+
* @returns true if value is 'true' or '1', false otherwise
|
|
42
|
+
*/
|
|
43
|
+
declare function getEnvVarBool(name: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get an environment variable as array
|
|
46
|
+
* @param name - The environment variable name
|
|
47
|
+
* @param separator - Separator character (default: ',')
|
|
48
|
+
* @returns Array of trimmed non-empty strings
|
|
49
|
+
*/
|
|
50
|
+
declare function getEnvVarArray(name: string, separator?: string): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Get all environment variables
|
|
53
|
+
* @returns Object containing all environment variables
|
|
54
|
+
*/
|
|
55
|
+
declare function getAllEnvVars(): EnvVars;
|
|
56
|
+
/**
|
|
57
|
+
* Check if running in development mode
|
|
58
|
+
* @returns true if NODE_ENV or MODE is 'development'
|
|
59
|
+
*/
|
|
60
|
+
declare function isDevelopment(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Check if running in production mode
|
|
63
|
+
* @returns true if NODE_ENV or MODE is 'production'
|
|
64
|
+
*/
|
|
65
|
+
declare function isProduction(): boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Account Abstraction helper utilities
|
|
69
|
+
* Adapted from lumia-passport-ui-kit/src/internal/akHelpers.ts
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* Precompile address for ecrecover
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* ABI for ecrecover precompile
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Safely convert value to BigInt with fallback
|
|
81
|
+
* @param val - Value to convert
|
|
82
|
+
* @param fallback - Fallback value if conversion fails
|
|
83
|
+
*/
|
|
84
|
+
declare const safeToBigInt: (val: any, fallback?: string) => bigint;
|
|
85
|
+
/**
|
|
86
|
+
* Pack two 128-bit values into single 256-bit value
|
|
87
|
+
* Used for packing gas limits in ERC-4337 v0.7
|
|
88
|
+
* @param hi - High 128 bits
|
|
89
|
+
* @param lo - Low 128 bits
|
|
90
|
+
* @returns Packed 256-bit value as bigint
|
|
91
|
+
*/
|
|
92
|
+
declare const pack2x128: (hi: bigint, lo: bigint) => bigint;
|
|
93
|
+
/**
|
|
94
|
+
* Verify signature against expected owner address
|
|
95
|
+
* @param opHash - Operation hash that was signed
|
|
96
|
+
* @param signature - Signature to verify
|
|
97
|
+
* @param expectedOwner - Expected owner address
|
|
98
|
+
*/
|
|
99
|
+
declare function verifySignatureAgainstOwner(opHash: `0x${string}`, signature: `0x${string}`, expectedOwner?: `0x${string}`): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Fetch nonce from EntryPoint contract
|
|
102
|
+
* @param account - Account address
|
|
103
|
+
* @param _entryPoint - EntryPoint contract address (unused in placeholder)
|
|
104
|
+
*/
|
|
105
|
+
declare function fetchEntryPointNonce(account: `0x${string}`, _entryPoint: `0x${string}`): Promise<`0x${string}`>;
|
|
106
|
+
/**
|
|
107
|
+
* Make RPC call to bundler
|
|
108
|
+
* @param method - RPC method name
|
|
109
|
+
* @param params - RPC method parameters
|
|
110
|
+
* @param bundlerUrl - Bundler URL (will be fetched from config if not provided)
|
|
111
|
+
*/
|
|
112
|
+
declare function bundlerRpc(method: string, params: any[], bundlerUrl?: string): Promise<any>;
|
|
113
|
+
|
|
114
|
+
export { addProjectIdToUrl, bundlerRpc, clearProjectId, fetchEntryPointNonce, getAllEnvVars, getEnvVar, getEnvVarArray, getEnvVarBool, getProjectId, isDevelopment, isProduction, pack2x128, safeToBigInt, setProjectId, verifySignatureAgainstOwner };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// src/utils/project-id.ts
|
|
2
|
+
var globalProjectId;
|
|
3
|
+
function setProjectId(projectId) {
|
|
4
|
+
globalProjectId = projectId;
|
|
5
|
+
}
|
|
6
|
+
function getProjectId() {
|
|
7
|
+
if (globalProjectId) {
|
|
8
|
+
return globalProjectId;
|
|
9
|
+
}
|
|
10
|
+
if (typeof globalThis !== "undefined" && globalThis.window) {
|
|
11
|
+
return globalThis.window.__LUMIA_PROJECT_ID__;
|
|
12
|
+
}
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
function addProjectIdToUrl(url, projectId) {
|
|
16
|
+
try {
|
|
17
|
+
const pid = projectId || getProjectId();
|
|
18
|
+
if (pid) {
|
|
19
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
20
|
+
return `${url}${separator}projectId=${encodeURIComponent(pid)}`;
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
}
|
|
24
|
+
return url;
|
|
25
|
+
}
|
|
26
|
+
function clearProjectId() {
|
|
27
|
+
globalProjectId = void 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/utils/env.ts
|
|
31
|
+
function getEnvironmentVars() {
|
|
32
|
+
const win = typeof globalThis !== "undefined" && globalThis.window;
|
|
33
|
+
if (win && win.__LUMIA_ENV__) {
|
|
34
|
+
return win.__LUMIA_ENV__;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
if (import.meta?.env) {
|
|
38
|
+
return import.meta.env;
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
if (typeof process !== "undefined" && process.env) {
|
|
43
|
+
return process.env;
|
|
44
|
+
}
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
function getEnvVar(name) {
|
|
48
|
+
const env = getEnvironmentVars();
|
|
49
|
+
return env[name];
|
|
50
|
+
}
|
|
51
|
+
function getEnvVarBool(name) {
|
|
52
|
+
const value = getEnvVar(name);
|
|
53
|
+
return value === "true" || value === "1";
|
|
54
|
+
}
|
|
55
|
+
function getEnvVarArray(name, separator = ",") {
|
|
56
|
+
const value = getEnvVar(name);
|
|
57
|
+
return value ? value.split(separator).map((s) => s.trim()).filter(Boolean) : [];
|
|
58
|
+
}
|
|
59
|
+
function getAllEnvVars() {
|
|
60
|
+
return getEnvironmentVars();
|
|
61
|
+
}
|
|
62
|
+
function isDevelopment() {
|
|
63
|
+
const env = getEnvironmentVars();
|
|
64
|
+
return env.NODE_ENV === "development" || env.MODE === "development";
|
|
65
|
+
}
|
|
66
|
+
function isProduction() {
|
|
67
|
+
const env = getEnvironmentVars();
|
|
68
|
+
return env.NODE_ENV === "production" || env.MODE === "production";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/utils/helpers.ts
|
|
72
|
+
var safeToBigInt = (val, fallback = "0x0") => {
|
|
73
|
+
try {
|
|
74
|
+
return BigInt(val || fallback);
|
|
75
|
+
} catch {
|
|
76
|
+
return BigInt(fallback);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var pack2x128 = (hi, lo) => {
|
|
80
|
+
return hi << 128n | lo & (1n << 128n) - 1n;
|
|
81
|
+
};
|
|
82
|
+
async function verifySignatureAgainstOwner(opHash, signature, expectedOwner) {
|
|
83
|
+
if (!signature || signature === "0x") return;
|
|
84
|
+
try {
|
|
85
|
+
console.log("[AA][sign] Signature verification:", {
|
|
86
|
+
opHash,
|
|
87
|
+
signature,
|
|
88
|
+
expectedOwner
|
|
89
|
+
});
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error("[AA][sign][ERROR] Could not verify signature:", error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function fetchEntryPointNonce(account, _entryPoint) {
|
|
95
|
+
console.log("[AA] fetchEntryPointNonce called for:", account);
|
|
96
|
+
return "0x0";
|
|
97
|
+
}
|
|
98
|
+
function sanitizeUserOperation(userOp) {
|
|
99
|
+
const sanitized = { ...userOp };
|
|
100
|
+
if (typeof sanitized.sender === "object" && sanitized.sender) {
|
|
101
|
+
const senderObj = sanitized.sender;
|
|
102
|
+
sanitized.sender = senderObj.sender || senderObj.address || senderObj.smartAccountAddress;
|
|
103
|
+
if (senderObj.factory) {
|
|
104
|
+
sanitized.factory = senderObj.factory;
|
|
105
|
+
}
|
|
106
|
+
if (senderObj.factoryData) {
|
|
107
|
+
sanitized.factoryData = senderObj.factoryData;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const hexFields = [
|
|
111
|
+
"sender",
|
|
112
|
+
"nonce",
|
|
113
|
+
"callData",
|
|
114
|
+
"callGasLimit",
|
|
115
|
+
"verificationGasLimit",
|
|
116
|
+
"preVerificationGas",
|
|
117
|
+
"maxFeePerGas",
|
|
118
|
+
"maxPriorityFeePerGas",
|
|
119
|
+
"signature",
|
|
120
|
+
"factory",
|
|
121
|
+
"factoryData",
|
|
122
|
+
"paymaster",
|
|
123
|
+
"paymasterData",
|
|
124
|
+
"paymasterVerificationGasLimit",
|
|
125
|
+
"paymasterPostOpGasLimit"
|
|
126
|
+
];
|
|
127
|
+
for (const field of hexFields) {
|
|
128
|
+
const value = sanitized[field];
|
|
129
|
+
if (value !== void 0 && value !== null) {
|
|
130
|
+
if (typeof value === "string") {
|
|
131
|
+
if (value === "0x" || value === "") {
|
|
132
|
+
if (["callData", "factoryData", "paymasterData", "signature"].includes(field)) {
|
|
133
|
+
sanitized[field] = "0x";
|
|
134
|
+
} else {
|
|
135
|
+
sanitized[field] = "0x0";
|
|
136
|
+
}
|
|
137
|
+
} else if (field === "sender" || field === "factory" || field === "paymaster") {
|
|
138
|
+
if (!value.startsWith("0x")) {
|
|
139
|
+
sanitized[field] = `0x${value}`;
|
|
140
|
+
}
|
|
141
|
+
} else if (!value.startsWith("0x")) {
|
|
142
|
+
sanitized[field] = `0x${value}`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
Object.keys(sanitized).forEach((key) => {
|
|
148
|
+
if (sanitized[key] === void 0 || sanitized[key] === null) {
|
|
149
|
+
delete sanitized[key];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
if (!sanitized.callData) sanitized.callData = "0x";
|
|
153
|
+
if (!sanitized.signature) sanitized.signature = "0x";
|
|
154
|
+
return sanitized;
|
|
155
|
+
}
|
|
156
|
+
async function bundlerRpc(method, params, bundlerUrl) {
|
|
157
|
+
let cleanParams = params;
|
|
158
|
+
if (method === "eth_sendUserOperation" && params[0]) {
|
|
159
|
+
cleanParams = [sanitizeUserOperation(params[0]), params[1]];
|
|
160
|
+
}
|
|
161
|
+
const body = { jsonrpc: "2.0", id: 1, method, params: cleanParams };
|
|
162
|
+
const bodyStr = JSON.stringify(body, (_k, v) => typeof v === "bigint" ? `0x${v.toString(16)}` : v);
|
|
163
|
+
console.log("[AA][rpc] ->", method, bodyStr);
|
|
164
|
+
const url = bundlerUrl || "http://localhost:4337";
|
|
165
|
+
const res = await fetch(url, {
|
|
166
|
+
method: "POST",
|
|
167
|
+
headers: { "content-type": "application/json" },
|
|
168
|
+
body: bodyStr
|
|
169
|
+
});
|
|
170
|
+
const json = await res.json();
|
|
171
|
+
if (json.error) {
|
|
172
|
+
console.log("[AA][rpc] <- ERROR:", JSON.stringify(json.error));
|
|
173
|
+
const detail = json.error?.data ? ` | data: ${JSON.stringify(json.error.data)}` : "";
|
|
174
|
+
throw new Error((json.error.message || JSON.stringify(json.error)) + detail);
|
|
175
|
+
}
|
|
176
|
+
console.log("[AA][rpc] <- SUCCESS:", JSON.stringify(json.result));
|
|
177
|
+
return json.result;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { addProjectIdToUrl, bundlerRpc, clearProjectId, fetchEntryPointNonce, getAllEnvVars, getEnvVar, getEnvVarArray, getEnvVarBool, getProjectId, isDevelopment, isProduction, pack2x128, safeToBigInt, setProjectId, verifySignatureAgainstOwner };
|
|
181
|
+
//# sourceMappingURL=index.js.map
|
|
182
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/project-id.ts","../../src/utils/env.ts","../../src/utils/helpers.ts"],"names":[],"mappings":";AAKA,IAAI,eAAA;AAMG,SAAS,aAAa,SAAA,EAAyB;AACpD,EAAA,eAAA,GAAkB,SAAA;AACpB;AAMO,SAAS,YAAA,GAAmC;AAEjD,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA,OAAO,eAAA;AAAA,EACT;AAGA,EAAA,IAAI,OAAO,UAAA,KAAe,WAAA,IAAgB,UAAA,CAAmB,MAAA,EAAQ;AACnE,IAAA,OAAS,WAAmB,MAAA,CAAe,oBAAA;AAAA,EAC7C;AAEA,EAAA,OAAO,MAAA;AACT;AAOO,SAAS,iBAAA,CAAkB,KAAa,SAAA,EAA4B;AACzE,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,aAAa,YAAA,EAAa;AACtC,IAAA,IAAI,GAAA,EAAK;AACP,MAAA,MAAM,SAAA,GAAY,GAAA,CAAI,QAAA,CAAS,GAAG,IAAI,GAAA,GAAM,GAAA;AAC5C,MAAA,OAAO,GAAG,GAAG,CAAA,EAAG,SAAS,CAAA,UAAA,EAAa,kBAAA,CAAmB,GAAG,CAAC,CAAA,CAAA;AAAA,IAC/D;AAAA,EACF,SAAS,KAAA,EAAO;AAAA,EAEhB;AACA,EAAA,OAAO,GAAA;AACT;AAKO,SAAS,cAAA,GAAuB;AACrC,EAAA,eAAA,GAAkB,MAAA;AACpB;;;AC5CA,SAAS,kBAAA,GAA8B;AAGrC,EAAA,MAAM,GAAA,GAAM,OAAO,UAAA,KAAe,WAAA,IAAgB,UAAA,CAAmB,MAAA;AACrE,EAAA,IAAI,GAAA,IAAO,IAAI,aAAA,EAAe;AAC5B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,CAAQ,GAAA,CAAI,cAAA,EAAgB,MAAA,EAAQ,OAAO,CAAA;AAI3C,EAAA,MAAM,MAAM,UAAA,IAAc,uBAAA;AAE1B,EAAA,MAAM,GAAA,GAAM,MAAM,KAAA,CAAM,GAAA,EAAK;AAAA,IAC3B,MAAA,EAAQ,MAAA;AAAA,IACR,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,EAAmB;AAAA,IAC9C,IAAA,EAAM;AAAA,GACP,CAAA;AAED,EAAA,MAAM,IAAA,GAAY,MAAM,GAAA,CAAI,IAAA,EAAK;AAEjC,EAAA,IAAI,KAAK,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,IAAI,qBAAA,EAAuB,IAAA,CAAK,SAAA,CAAU,IAAA,CAAK,KAAK,CAAC,CAAA;AAC7D,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,EAAO,IAAA,GAAO,CAAA,SAAA,EAAY,IAAA,CAAK,SAAA,CAAU,IAAA,CAAK,KAAA,CAAM,IAAI,CAAC,CAAA,CAAA,GAAK,EAAA;AAClF,IAAA,MAAM,IAAI,KAAA,CAAA,CAAO,IAAA,CAAK,KAAA,CAAM,OAAA,IAAW,KAAK,SAAA,CAAU,IAAA,CAAK,KAAK,CAAA,IAAK,MAAM,CAAA;AAAA,EAC7E;AAEA,EAAA,OAAA,CAAQ,IAAI,uBAAA,EAAyB,IAAA,CAAK,SAAA,CAAU,IAAA,CAAK,MAAM,CAAC,CAAA;AAChE,EAAA,OAAO,IAAA,CAAK,MAAA;AACd","file":"index.js","sourcesContent":["/**\n * Project ID management for Lumia Passport Core\n * Adapted to work in both browser and Node.js environments\n */\n\nlet globalProjectId: string | undefined;\n\n/**\n * Set the global project ID\n * @param projectId - The project ID to set\n */\nexport function setProjectId(projectId: string): void {\n globalProjectId = projectId;\n}\n\n/**\n * Get the current project ID\n * Priority: 1. Explicitly set via setProjectId(), 2. window.__LUMIA_PROJECT_ID__ (browser only)\n */\nexport function getProjectId(): string | undefined {\n // First check explicitly set projectId\n if (globalProjectId) {\n return globalProjectId;\n }\n\n // Fallback to window global (browser only)\n if (typeof globalThis !== 'undefined' && (globalThis as any).window) {\n return ((globalThis as any).window as any).__LUMIA_PROJECT_ID__;\n }\n\n return undefined;\n}\n\n/**\n * Add projectId to URL query parameters\n * @param url - The URL to add projectId to\n * @param projectId - Optional explicit projectId (uses getProjectId() if not provided)\n */\nexport function addProjectIdToUrl(url: string, projectId?: string): string {\n try {\n const pid = projectId || getProjectId();\n if (pid) {\n const separator = url.includes('?') ? '&' : '?';\n return `${url}${separator}projectId=${encodeURIComponent(pid)}`;\n }\n } catch (error) {\n // Silently fail and return original URL\n }\n return url;\n}\n\n/**\n * Clear the globally set project ID\n */\nexport function clearProjectId(): void {\n globalProjectId = undefined;\n}\n","/**\n * Universal environment variable access that works in both browser and Node.js\n */\n\ninterface EnvVars {\n [key: string]: string | undefined;\n}\n\n/**\n * Get environment variables from various sources\n * Priority: 1. window.__LUMIA_ENV__ (browser), 2. import.meta.env (Vite), 3. process.env (Node.js)\n */\nfunction getEnvironmentVars(): EnvVars {\n // Try browser environment first (injected by LumiaPassportProvider)\n // @ts-ignore - accessing global window object\n const win = typeof globalThis !== 'undefined' && (globalThis as any).window;\n if (win && win.__LUMIA_ENV__) {\n return win.__LUMIA_ENV__;\n }\n\n // Try import.meta.env (ESM/Vite)\n try {\n // @ts-ignore - import.meta may not be available in all environments\n if (import.meta?.env) {\n // @ts-ignore\n return import.meta.env as EnvVars;\n }\n } catch {\n // import.meta not available in this environment\n }\n\n // Try process.env (Node.js/CJS)\n if (typeof process !== 'undefined' && process.env) {\n return process.env;\n }\n\n // Fallback to empty object\n return {};\n}\n\n/**\n * Get a single environment variable\n * @param name - The environment variable name\n * @returns The environment variable value or undefined\n */\nexport function getEnvVar(name: string): string | undefined {\n const env = getEnvironmentVars();\n return env[name];\n}\n\n/**\n * Get an environment variable as boolean\n * @param name - The environment variable name\n * @returns true if value is 'true' or '1', false otherwise\n */\nexport function getEnvVarBool(name: string): boolean {\n const value = getEnvVar(name);\n return value === 'true' || value === '1';\n}\n\n/**\n * Get an environment variable as array\n * @param name - The environment variable name\n * @param separator - Separator character (default: ',')\n * @returns Array of trimmed non-empty strings\n */\nexport function getEnvVarArray(name: string, separator = ','): string[] {\n const value = getEnvVar(name);\n return value ? value.split(separator).map(s => s.trim()).filter(Boolean) : [];\n}\n\n/**\n * Get all environment variables\n * @returns Object containing all environment variables\n */\nexport function getAllEnvVars(): EnvVars {\n return getEnvironmentVars();\n}\n\n/**\n * Check if running in development mode\n * @returns true if NODE_ENV or MODE is 'development'\n */\nexport function isDevelopment(): boolean {\n const env = getEnvironmentVars();\n return env.NODE_ENV === 'development' || env.MODE === 'development';\n}\n\n/**\n * Check if running in production mode\n * @returns true if NODE_ENV or MODE is 'production'\n */\nexport function isProduction(): boolean {\n const env = getEnvironmentVars();\n return env.NODE_ENV === 'production' || env.MODE === 'production';\n}\n","/**\n * Account Abstraction helper utilities\n * Adapted from lumia-passport-ui-kit/src/internal/akHelpers.ts\n */\n\n// Note: publicClient and getBundlerUrl will be imported from clients/base\n// These imports will be added after we create the clients module\n\n/**\n * Precompile address for ecrecover\n * @internal\n */\n// const ECRECOVER_PRECOMPILE = '0x0000000000000000000000000000000000000001' as const;\n\n/**\n * ABI for ecrecover precompile\n * @internal\n */\n// const ECRECOVER_ABI = [\n// {\n// name: 'ecrecover',\n// type: 'function',\n// inputs: [\n// { name: 'hash', type: 'bytes32' },\n// { name: 'v', type: 'uint8' },\n// { name: 'r', type: 'bytes32' },\n// { name: 's', type: 'bytes32' }\n// ],\n// outputs: [{ name: 'addr', type: 'address' }]\n// },\n// ] as const;\n\n/**\n * Safely convert value to BigInt with fallback\n * @param val - Value to convert\n * @param fallback - Fallback value if conversion fails\n */\nexport const safeToBigInt = (val: any, fallback = '0x0'): bigint => {\n try {\n return BigInt(val || fallback);\n } catch {\n return BigInt(fallback);\n }\n};\n\n/**\n * Pack two 128-bit values into single 256-bit value\n * Used for packing gas limits in ERC-4337 v0.7\n * @param hi - High 128 bits\n * @param lo - Low 128 bits\n * @returns Packed 256-bit value as bigint\n */\nexport const pack2x128 = (hi: bigint, lo: bigint): bigint => {\n return (hi << 128n) | (lo & ((1n << 128n) - 1n));\n};\n\n/**\n * Verify signature against expected owner address\n * @param opHash - Operation hash that was signed\n * @param signature - Signature to verify\n * @param expectedOwner - Expected owner address\n */\nexport async function verifySignatureAgainstOwner(\n opHash: `0x${string}`,\n signature: `0x${string}`,\n expectedOwner?: `0x${string}`\n): Promise<void> {\n if (!signature || signature === '0x') return;\n\n try {\n // This will be implemented after we have publicClient from clients module\n // For now, this is a placeholder\n console.log('[AA][sign] Signature verification:', {\n opHash,\n signature,\n expectedOwner,\n });\n } catch (error) {\n console.error('[AA][sign][ERROR] Could not verify signature:', error);\n }\n}\n\n/**\n * Fetch nonce from EntryPoint contract\n * @param account - Account address\n * @param _entryPoint - EntryPoint contract address (unused in placeholder)\n */\nexport async function fetchEntryPointNonce(\n account: `0x${string}`,\n _entryPoint: `0x${string}`\n): Promise<`0x${string}`> {\n // This will be implemented after we have publicClient from clients module\n // For now, return 0x0 as placeholder\n console.log('[AA] fetchEntryPointNonce called for:', account);\n return '0x0';\n}\n\n/**\n * Sanitize UserOperation object by fixing common issues\n * @param userOp - UserOperation to sanitize\n */\nfunction sanitizeUserOperation(userOp: any): any {\n const sanitized = { ...userOp };\n\n // Fix sender field if it's an object (extract address and factory fields)\n if (typeof sanitized.sender === 'object' && sanitized.sender) {\n const senderObj = sanitized.sender;\n\n // Extract the actual sender address\n sanitized.sender = senderObj.sender || senderObj.address || senderObj.smartAccountAddress;\n\n // Extract factory fields if they exist\n if (senderObj.factory) {\n sanitized.factory = senderObj.factory;\n }\n if (senderObj.factoryData) {\n sanitized.factoryData = senderObj.factoryData;\n }\n }\n\n // Ensure all hex fields are valid and properly formatted\n const hexFields = [\n 'sender', 'nonce', 'callData', 'callGasLimit', 'verificationGasLimit',\n 'preVerificationGas', 'maxFeePerGas', 'maxPriorityFeePerGas', 'signature',\n 'factory', 'factoryData', 'paymaster', 'paymasterData',\n 'paymasterVerificationGasLimit', 'paymasterPostOpGasLimit'\n ];\n\n for (const field of hexFields) {\n const value = sanitized[field];\n if (value !== undefined && value !== null) {\n if (typeof value === 'string') {\n if (value === '0x' || value === '') {\n // Convert empty hex to 0x0 for numeric fields, 0x for data fields\n if (['callData', 'factoryData', 'paymasterData', 'signature'].includes(field)) {\n sanitized[field] = '0x';\n } else {\n sanitized[field] = '0x0';\n }\n } else if (field === 'sender' || field === 'factory' || field === 'paymaster') {\n // Address fields should have 0x prefix\n if (!value.startsWith('0x')) {\n sanitized[field] = `0x${value}`;\n }\n } else if (!value.startsWith('0x')) {\n sanitized[field] = `0x${value}`;\n }\n }\n }\n }\n\n // Remove undefined/null fields for v0.7\n Object.keys(sanitized).forEach(key => {\n if (sanitized[key] === undefined || sanitized[key] === null) {\n delete sanitized[key];\n }\n });\n\n // Ensure required fields exist with proper defaults\n if (!sanitized.callData) sanitized.callData = '0x';\n if (!sanitized.signature) sanitized.signature = '0x';\n\n return sanitized;\n}\n\n/**\n * Make RPC call to bundler\n * @param method - RPC method name\n * @param params - RPC method parameters\n * @param bundlerUrl - Bundler URL (will be fetched from config if not provided)\n */\nexport async function bundlerRpc(\n method: string,\n params: any[],\n bundlerUrl?: string\n): Promise<any> {\n // Sanitize UserOperation if this is eth_sendUserOperation\n let cleanParams = params;\n if (method === 'eth_sendUserOperation' && params[0]) {\n cleanParams = [sanitizeUserOperation(params[0]), params[1]];\n }\n\n const body = { jsonrpc: '2.0', id: 1, method, params: cleanParams };\n const bodyStr = JSON.stringify(body, (_k, v) => (typeof v === 'bigint' ? `0x${v.toString(16)}` : v));\n\n console.log('[AA][rpc] ->', method, bodyStr);\n\n // Get bundler URL from config or use provided one\n // This will be implemented after clients module is created\n const url = bundlerUrl || 'http://localhost:4337'; // Temporary fallback\n\n const res = await fetch(url, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: bodyStr\n });\n\n const json: any = await res.json();\n\n if (json.error) {\n console.log('[AA][rpc] <- ERROR:', JSON.stringify(json.error));\n const detail = json.error?.data ? ` | data: ${JSON.stringify(json.error.data)}` : '';\n throw new Error((json.error.message || JSON.stringify(json.error)) + detail);\n }\n\n console.log('[AA][rpc] <- SUCCESS:', JSON.stringify(json.result));\n return json.result;\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lumiapassport/core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Framework-agnostic core SDK for Lumia Passport smart accounts",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./bundler": {
|
|
16
|
+
"types": "./dist/bundler/index.d.ts",
|
|
17
|
+
"import": "./dist/bundler/index.js",
|
|
18
|
+
"require": "./dist/bundler/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./auth": {
|
|
21
|
+
"types": "./dist/auth/index.d.ts",
|
|
22
|
+
"import": "./dist/auth/index.js",
|
|
23
|
+
"require": "./dist/auth/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./clients": {
|
|
26
|
+
"types": "./dist/clients/index.d.ts",
|
|
27
|
+
"import": "./dist/clients/index.js",
|
|
28
|
+
"require": "./dist/clients/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./mpc": {
|
|
31
|
+
"types": "./dist/mpc/index.d.ts",
|
|
32
|
+
"import": "./dist/mpc/index.js",
|
|
33
|
+
"require": "./dist/mpc/index.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./utils": {
|
|
36
|
+
"types": "./dist/utils/index.d.ts",
|
|
37
|
+
"import": "./dist/utils/index.js",
|
|
38
|
+
"require": "./dist/utils/index.cjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"README.md"
|
|
44
|
+
],
|
|
45
|
+
"keywords": [
|
|
46
|
+
"lumia",
|
|
47
|
+
"passport",
|
|
48
|
+
"smart-account",
|
|
49
|
+
"account-abstraction",
|
|
50
|
+
"erc-4337",
|
|
51
|
+
"blockchain",
|
|
52
|
+
"web3",
|
|
53
|
+
"sdk"
|
|
54
|
+
],
|
|
55
|
+
"author": "Lumia",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"viem": ">=2.10.0",
|
|
59
|
+
"dkls23-wasm": ">=0.1.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"dkls23-wasm": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/node": "^20.0.0",
|
|
68
|
+
"tsup": "^8.1.0",
|
|
69
|
+
"typescript": "^5.4.0",
|
|
70
|
+
"viem": "^2.37.9",
|
|
71
|
+
"dkls23-wasm": ">=0.1.0"
|
|
72
|
+
},
|
|
73
|
+
"repository": {
|
|
74
|
+
"type": "git",
|
|
75
|
+
"url": "https://github.com/lumiachain/lumia-passport-sdk",
|
|
76
|
+
"directory": "packages/core"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public"
|
|
80
|
+
},
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build": "tsup",
|
|
83
|
+
"dev": "tsup --watch",
|
|
84
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
85
|
+
"typecheck": "tsc --noEmit",
|
|
86
|
+
"test": "echo \"Tests will be added\""
|
|
87
|
+
}
|
|
88
|
+
}
|