@0xpass/passport
Advanced tools
Comparing version 0.1.7 to 0.1.8
# @0xpass/passport | ||
## 0.1.8 | ||
### Patch Changes | ||
- e77a2de: Updates signTransaction and eth_signTypedData_v4 | ||
## 0.1.7 | ||
@@ -4,0 +10,0 @@ |
@@ -42,3 +42,2 @@ import { AuthenticationParams, AuthenticationResponse, DelegatedRegisterAccountParams, DelegatedRegisterAccountResponse, LambaCallParams, LambdaListParams, LambdaNewParams, Method, NewScopeParams, NewScopeResponse, RegistrationParams, RegistrationResponse, RpcHeaders, RpcMethodParams, SignMessageParams, SignMessageResponse, SignTransactionParams, SignTransactionResponse, UpdateScopeParams, UpdateScopeResponse } from "./types"; | ||
* Signs a message. | ||
* @param {object} params.session - The session object returned from getSession | ||
* @param {string} params.message - The message to sign | ||
@@ -50,3 +49,2 @@ * @returns A Promise that resolves to return a signature | ||
* Signs a transaction. | ||
* @param {object} params.session - The session object returned from getSession | ||
* @param {object} params.transaction - The transaction to sign | ||
@@ -58,3 +56,2 @@ * @returns A Promise that resolves to return a signature | ||
* Signs a EIP712 payload. | ||
* @param {object} params.session - The session object returned from getSession | ||
* @param {object} params.payload - The EIP712 payload to sign | ||
@@ -61,0 +58,0 @@ * @returns A Promise that resolves to return a signature |
@@ -129,3 +129,2 @@ import axios from 'axios'; | ||
* Signs a message. | ||
* @param {object} params.session - The session object returned from getSession | ||
* @param {string} params.message - The message to sign | ||
@@ -139,3 +138,2 @@ * @returns A Promise that resolves to return a signature | ||
* Signs a transaction. | ||
* @param {object} params.session - The session object returned from getSession | ||
* @param {object} params.transaction - The transaction to sign | ||
@@ -145,31 +143,6 @@ * @returns A Promise that resolves to return a signature | ||
this.signTransaction = async (params) => { | ||
const payload = { | ||
jsonrpc: "2.0", | ||
id: 1, | ||
method: "eth_signTransaction", | ||
params: [{ ...params.transaction }], | ||
}; | ||
try { | ||
const { data } = await axios.post(this.endpoint, payload, { | ||
headers: { | ||
session: "", | ||
secure_context: "1", | ||
}, | ||
}); | ||
return data; | ||
} | ||
catch (error) { | ||
if (axios.isAxiosError(error)) { | ||
if (error.response) { | ||
throw new Error(`Server error: ${error.response.status}`); | ||
} | ||
} | ||
else { | ||
throw new Error("Unexpected error: " + error); | ||
} | ||
} | ||
return this.call("eth_signTransaction", [params], this.authenticatedHeaders); | ||
}; | ||
/** | ||
* Signs a EIP712 payload. | ||
* @param {object} params.session - The session object returned from getSession | ||
* @param {object} params.payload - The EIP712 payload to sign | ||
@@ -179,28 +152,3 @@ * @returns A Promise that resolves to return a signature | ||
this.signTypedData = async (params) => { | ||
const payload = { | ||
jsonrpc: "2.0", | ||
id: 1, | ||
method: "eth_signTypedData_v4", | ||
// change this to address although for now it's fine as we sign with session info | ||
params: ["0x000000", params.payload], | ||
}; | ||
try { | ||
const { data } = await axios.post(this.endpoint, payload, { | ||
headers: { | ||
session: JSON.stringify(params.session), | ||
secure_context: "1", | ||
}, | ||
}); | ||
return data; | ||
} | ||
catch (error) { | ||
if (axios.isAxiosError(error)) { | ||
if (error.response) { | ||
throw new Error(`Server error: ${error.response.status}`); | ||
} | ||
} | ||
else { | ||
throw new Error("Unexpected error: " + error); | ||
} | ||
} | ||
return this.call("eth_signTypedData_v4", [this.parsedJwt.address, params], this.authenticatedHeaders); | ||
}; | ||
@@ -207,0 +155,0 @@ this.createScope = async (params) => { |
import { LambdaExecutable, NewLambda } from "./lambda"; | ||
export type Method = "personal_sign" | "eth_signTransaction" | "verify" | "exchangeKey" | "createScope" | "updateScope" | "delegatedRegistration" | "initiateRegistration" | "completeRegistration" | "initiateAuthentication" | "completeAuthentication"; | ||
export type Method = "personal_sign" | "eth_signTransaction" | "eth_signTypedData_v4" | "verify" | "exchangeKey" | "createScope" | "updateScope" | "delegatedRegistration" | "initiateRegistration" | "completeRegistration" | "initiateAuthentication" | "completeAuthentication"; | ||
export type SignMessageParams = string; | ||
@@ -7,6 +7,3 @@ export type SignMessageResponse = { | ||
}; | ||
export type SignTransactionParams = { | ||
encrypted_jwt: string; | ||
transaction: any; | ||
}; | ||
export type SignTransactionParams = any; | ||
export type SignTransactionResponse = { | ||
@@ -13,0 +10,0 @@ result: string; |
{ | ||
"name": "@0xpass/passport", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -144,3 +144,2 @@ import axios from "axios"; | ||
* Signs a message. | ||
* @param {object} params.session - The session object returned from getSession | ||
* @param {string} params.message - The message to sign | ||
@@ -155,3 +154,2 @@ * @returns A Promise that resolves to return a signature | ||
* Signs a transaction. | ||
* @param {object} params.session - The session object returned from getSession | ||
* @param {object} params.transaction - The transaction to sign | ||
@@ -163,26 +161,3 @@ * @returns A Promise that resolves to return a signature | ||
): Promise<SignTransactionResponse> => { | ||
const payload = { | ||
jsonrpc: "2.0", | ||
id: 1, | ||
method: "eth_signTransaction", | ||
params: [{ ...params.transaction }], | ||
}; | ||
try { | ||
const { data } = await axios.post(this.endpoint, payload, { | ||
headers: { | ||
session: "", | ||
secure_context: "1", | ||
}, | ||
}); | ||
return data; | ||
} catch (error) { | ||
if (axios.isAxiosError(error)) { | ||
if (error.response) { | ||
throw new Error(`Server error: ${error.response.status}`); | ||
} | ||
} else { | ||
throw new Error("Unexpected error: " + error); | ||
} | ||
} | ||
return this.call("eth_signTransaction", [params], this.authenticatedHeaders); | ||
}; | ||
@@ -192,3 +167,2 @@ | ||
* Signs a EIP712 payload. | ||
* @param {object} params.session - The session object returned from getSession | ||
* @param {object} params.payload - The EIP712 payload to sign | ||
@@ -198,27 +172,7 @@ * @returns A Promise that resolves to return a signature | ||
public signTypedData = async (params: any): Promise<SignMessageResponse> => { | ||
const payload = { | ||
jsonrpc: "2.0", | ||
id: 1, | ||
method: "eth_signTypedData_v4", | ||
// change this to address although for now it's fine as we sign with session info | ||
params: ["0x000000", params.payload], | ||
}; | ||
try { | ||
const { data } = await axios.post(this.endpoint, payload, { | ||
headers: { | ||
session: JSON.stringify(params.session), | ||
secure_context: "1", | ||
}, | ||
}); | ||
return data; | ||
} catch (error) { | ||
if (axios.isAxiosError(error)) { | ||
if (error.response) { | ||
throw new Error(`Server error: ${error.response.status}`); | ||
} | ||
} else { | ||
throw new Error("Unexpected error: " + error); | ||
} | ||
} | ||
return this.call( | ||
"eth_signTypedData_v4", | ||
[this.parsedJwt.address, params], | ||
this.authenticatedHeaders | ||
); | ||
}; | ||
@@ -225,0 +179,0 @@ |
@@ -6,2 +6,3 @@ import { LambdaExecutable, NewLambda } from "./lambda"; | ||
| "eth_signTransaction" | ||
| "eth_signTypedData_v4" | ||
| "verify" | ||
@@ -23,6 +24,3 @@ | "exchangeKey" | ||
export type SignTransactionParams = { | ||
encrypted_jwt: string; | ||
transaction: any; // todo | ||
}; | ||
export type SignTransactionParams = any; // TODO: change to transaction type | ||
@@ -29,0 +27,0 @@ export type SignTransactionResponse = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58903
1352