@zerodev/sdk
Advanced tools
Comparing version 4.0.8 to 4.0.9
@@ -14,2 +14,3 @@ "use strict"; | ||
const challenge = (0, utils_js_1.generateRandomBuffer)(); | ||
const authenticatorUserId = (0, utils_js_1.generateRandomBuffer)(); | ||
try { | ||
@@ -26,3 +27,2 @@ const attestation = await (0, http_1.getWebAuthnAttestation)({ | ||
}, | ||
excludeCredentials: await (0, utils_js_1.getCredentials)(projectId), | ||
extensions: { credProps: true }, | ||
@@ -37,3 +37,3 @@ challenge, | ||
user: { | ||
id: Uint8Array.from(name, (c) => c.charCodeAt(0)), | ||
id: authenticatorUserId, | ||
name, | ||
@@ -40,0 +40,0 @@ displayName: name, |
@@ -19,3 +19,2 @@ "use strict"; | ||
userVerification: "required", | ||
allowCredentials: await (0, utils_js_1.getCredentials)(projectId), | ||
}, | ||
@@ -22,0 +21,0 @@ })); |
@@ -10,3 +10,2 @@ import type { Hex, Signature } from "./types.js"; | ||
export declare const signTypedData: (params: SignTypedDataParams, id: string, walletId: string, projectId: string, credentialId: string, apiUrl?: string) => Promise<`0x${string}`>; | ||
export declare const getCredentials: (projectId: string, apiUrl?: string) => Promise<any>; | ||
export declare function base64URLStringToBuffer(base64URLString: string): ArrayBuffer; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.base64URLStringToBuffer = exports.getCredentials = exports.signTypedData = exports.signMessage = exports.signatureToHex = exports.base64UrlEncode = exports.generateRandomBuffer = exports.es256 = exports.publicKey = void 0; | ||
exports.base64URLStringToBuffer = exports.signTypedData = exports.signMessage = exports.signatureToHex = exports.base64UrlEncode = exports.generateRandomBuffer = exports.es256 = exports.publicKey = void 0; | ||
const http_1 = require("@turnkey/http"); | ||
@@ -84,11 +84,2 @@ const axios_1 = __importDefault(require("axios")); | ||
exports.signTypedData = signTypedData; | ||
const getCredentials = async (projectId, apiUrl = constants_js_1.API_URL) => { | ||
const response = await axios_1.default.get(`${apiUrl}/projects/${projectId}/wallets`); | ||
const credentials = response.data; | ||
return credentials.map((credential) => ({ | ||
id: base64URLStringToBuffer(credential), | ||
type: "public-key", | ||
})); | ||
}; | ||
exports.getCredentials = getCredentials; | ||
function base64URLStringToBuffer(base64URLString) { | ||
@@ -95,0 +86,0 @@ const base64 = base64URLString.replace(/-/g, "+").replace(/_/g, "/"); |
import { getWebAuthnAttestation } from "@turnkey/http"; | ||
import axios from "axios"; | ||
import { base64UrlEncode, es256, generateRandomBuffer, getCredentials, publicKey, signMessage, signTypedData, } from "./utils.js"; | ||
import { base64UrlEncode, es256, generateRandomBuffer, publicKey, signMessage, signTypedData, } from "./utils.js"; | ||
import { API_URL } from "../../constants.js"; | ||
@@ -8,2 +8,3 @@ export async function createPasskeyOwner({ name, projectId, fallback, apiUrl = API_URL, }) { | ||
const challenge = generateRandomBuffer(); | ||
const authenticatorUserId = generateRandomBuffer(); | ||
try { | ||
@@ -20,3 +21,2 @@ const attestation = await getWebAuthnAttestation({ | ||
}, | ||
excludeCredentials: await getCredentials(projectId), | ||
extensions: { credProps: true }, | ||
@@ -31,3 +31,3 @@ challenge, | ||
user: { | ||
id: Uint8Array.from(name, (c) => c.charCodeAt(0)), | ||
id: authenticatorUserId, | ||
name, | ||
@@ -34,0 +34,0 @@ displayName: name, |
import { getWebAuthnAssertion } from "@turnkey/http/dist/webauthn"; | ||
import axios from "axios"; | ||
import { base64UrlEncode, generateRandomBuffer, getCredentials, signMessage, signTypedData, } from "./utils.js"; | ||
import { base64UrlEncode, generateRandomBuffer, signMessage, signTypedData, } from "./utils.js"; | ||
import { API_URL } from "../../constants.js"; | ||
@@ -13,3 +13,2 @@ export async function getPasskeyOwner({ projectId, apiUrl = API_URL, }) { | ||
userVerification: "required", | ||
allowCredentials: await getCredentials(projectId), | ||
}, | ||
@@ -16,0 +15,0 @@ })); |
@@ -10,3 +10,2 @@ import type { Hex, Signature } from "./types.js"; | ||
export declare const signTypedData: (params: SignTypedDataParams, id: string, walletId: string, projectId: string, credentialId: string, apiUrl?: string) => Promise<`0x${string}`>; | ||
export declare const getCredentials: (projectId: string, apiUrl?: string) => Promise<any>; | ||
export declare function base64URLStringToBuffer(base64URLString: string): ArrayBuffer; |
@@ -72,10 +72,2 @@ import { browserInit, TurnkeyApi } from "@turnkey/http"; | ||
}; | ||
export const getCredentials = async (projectId, apiUrl = API_URL) => { | ||
const response = await axios.get(`${apiUrl}/projects/${projectId}/wallets`); | ||
const credentials = response.data; | ||
return credentials.map((credential) => ({ | ||
id: base64URLStringToBuffer(credential), | ||
type: "public-key", | ||
})); | ||
}; | ||
export function base64URLStringToBuffer(base64URLString) { | ||
@@ -82,0 +74,0 @@ const base64 = base64URLString.replace(/-/g, "+").replace(/_/g, "/"); |
@@ -10,4 +10,3 @@ import type { Hex, Signature } from "./types.js"; | ||
export declare const signTypedData: (params: SignTypedDataParams, id: string, walletId: string, projectId: string, credentialId: string, apiUrl?: string) => Promise<`0x${string}`>; | ||
export declare const getCredentials: (projectId: string, apiUrl?: string) => Promise<any>; | ||
export declare function base64URLStringToBuffer(base64URLString: string): ArrayBuffer; | ||
//# sourceMappingURL=utils.d.ts.map |
{ | ||
"name": "@zerodev/sdk", | ||
"version": "4.0.8", | ||
"version": "4.0.9", | ||
"description": "A collection of ERC-4337 compliant smart contract account interfaces", | ||
@@ -5,0 +5,0 @@ "author": "ZeroDev", |
@@ -8,3 +8,2 @@ import { getWebAuthnAttestation } from "@turnkey/http"; | ||
generateRandomBuffer, | ||
getCredentials, | ||
publicKey, | ||
@@ -30,2 +29,3 @@ signMessage, | ||
const challenge = generateRandomBuffer(); | ||
const authenticatorUserId = generateRandomBuffer(); | ||
try { | ||
@@ -44,3 +44,3 @@ const attestation = await getWebAuthnAttestation({ | ||
}, | ||
excludeCredentials: await getCredentials(projectId), | ||
// excludeCredentials: await getCredentials(projectId), | ||
extensions: { credProps: true }, | ||
@@ -55,3 +55,3 @@ challenge, | ||
user: { | ||
id: Uint8Array.from(name, (c) => c.charCodeAt(0)), | ||
id: authenticatorUserId, | ||
name, | ||
@@ -58,0 +58,0 @@ displayName: name, |
@@ -7,3 +7,2 @@ import { getWebAuthnAssertion } from "@turnkey/http/dist/webauthn"; | ||
generateRandomBuffer, | ||
getCredentials, | ||
signMessage, | ||
@@ -31,3 +30,3 @@ signTypedData, | ||
userVerification: "required", | ||
allowCredentials: await getCredentials(projectId), | ||
// allowCredentials: await getCredentials(projectId), | ||
}, | ||
@@ -34,0 +33,0 @@ }) |
@@ -122,11 +122,2 @@ import { browserInit, TurnkeyApi } from "@turnkey/http"; | ||
export const getCredentials = async (projectId: string, apiUrl = API_URL) => { | ||
const response = await axios.get(`${apiUrl}/projects/${projectId}/wallets`); | ||
const credentials = response.data; | ||
return credentials.map((credential: string) => ({ | ||
id: base64URLStringToBuffer(credential), | ||
type: "public-key", | ||
})); | ||
}; | ||
// https://github.com/MasterKale/SimpleWebAuthn/blob/master/packages/browser/src/helpers/base64URLStringToBuffer.ts#L8 | ||
@@ -133,0 +124,0 @@ export function base64URLStringToBuffer(base64URLString: string): ArrayBuffer { |
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
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
Sorry, the diff of this file is not supported yet
1409935
22964