Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/auth-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@elysiajs/cors": "^1.2.0",
"@elysiajs/static": "^1.3.0",
"@elysiajs/swagger": "^1.2.0",
"@lit-protocol/contracts": "^0.4.0",
"@lit-protocol/contracts": "^0.5.0",
"@simplewebauthn/server": "6.2.1",
"@simplewebauthn/typescript-types": "^8.3.4",
"@t3-oss/env-core": "^0.12.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type AuthServiceMintRequestTransformed = z.infer<
export const tAuthServiceMintRequestSchema = t.Object({
authMethodType: t.String(),
authMethodId: t.String(),
pubkey: t.Optional(t.String({ default: '0x' })),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused Unable to decode credential public key CBOR

pubkey: t.Optional(t.String()),
scopes: t.Optional(
t.Array(
t.Union([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ export async function handlePkpMintTask(jobData: {
pubkey: Hex;
scopes?: ('sign-anything' | 'personal-sign' | 'no-permissions')[];
};
reqId?: string;
}): Promise<any> {
if (
// AUTH_METHOD_TYPE.WebAuthn = 3 (without importing the constants package)
Number(jobData.requestBody.authMethodType) === 3 &&
(!jobData.requestBody.pubkey || jobData.requestBody.pubkey === '0x')
) {
throw new Error(
`[PKP Mint][HANDLER] WebAuthn requires a non-empty COSE pubkey; got '${jobData.requestBody.pubkey}'. reqId=${jobData.reqId}`
);
}

const userAuthData: Optional<AuthData, 'accessToken'> = {
authMethodId: jobData.requestBody.authMethodId,
authMethodType: Number(jobData.requestBody.authMethodType),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class WebAuthnAuthenticator {
public static async registerAndMintPKP(params: {
username?: string;
authServiceBaseUrl: string;
scopes?: ('sign-anything' | 'personal-sign' | 'no-permissions')[];
}): Promise<{
pkpInfo: PKPData;

Expand Down Expand Up @@ -183,6 +184,7 @@ export class WebAuthnAuthenticator {
authMethodType: AUTH_METHOD_TYPE.WebAuthn,
authMethodId: authMethodId,
pubkey: authMethodPubkey,
scopes: params.scopes,
};

// Immediate mint a new PKP to associate with the auth method
Expand Down
3 changes: 2 additions & 1 deletion packages/lit-client/src/lib/LitClient/createLitClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ export const _createNagaLitClient = async (
return await networkModule.api.signCustomSessionKey.handleResponse(
result as any,
params.requestBody.pkpPublicKey,
jitContext
jitContext,
requestId
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/networks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"directory": "../../dist/packages/networks"
},
"dependencies": {
"@lit-protocol/contracts": "^0.4.0",
"@lit-protocol/contracts": "^0.5.0",
"@lit-protocol/nacl": "7.1.1",
"@noble/curves": "^1.8.1",
"@wagmi/core": "^2.17.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,8 @@ export function createBaseModule<T, M>(config: BaseModuleConfig<T, M>) {
handleResponse: async (
result: z.infer<typeof GenericEncryptedPayloadSchema>,
pkpPublicKey: Hex | string,
jitContext: NagaJitContext
jitContext: NagaJitContext,
requestId?: string
) => {
if (!result.success) {
E2EERequestManager.handleEncryptedError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export const MintPKPSchema = z

// Determine pubkey based on the (potentially derived) authMethodType
if (data.authMethodType === AUTH_METHOD_TYPE.WebAuthn) {
if (!data.pubkey) {
throw new Error('pubkey is required for WebAuthn');
if (!data.pubkey || data.pubkey === '0x') {
throw new Error(
`pubkey is required for WebAuthn and cannot be 0x. Received pubkey: "${data.pubkey}" and authMethodType: ${data.authMethodType}`
);
}
derivedPubkey = data.pubkey as Hex;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const mintPKP = async (
const tx = await mintNextAndAddAuthMethods(
{
keyType: 2,
keySetId: 'naga-keyset1',
permittedAuthMethodTypes: [validatedRequest.authMethodType],
permittedAuthMethodIds: [validatedRequest.authMethodId],
permittedAuthMethodPubkeys: [validatedRequest.pubkey],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const mintWithMultiAuths = async (
const tx = await mintNextAndAddAuthMethods(
{
keyType: 2,
keySetId: 'naga-keyset1',
permittedAuthMethodTypes: validatedRequest.authMethodTypes,
permittedAuthMethodIds: validatedRequest.authMethodIds,
permittedAuthMethodPubkeys: validatedRequest.pubkeys,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function mintNext(
const hash = await callWithAdjustedOverrides(
pkpNftContract,
'mintNext',
[2],
[2,'naga-keyset1'],
{
value: mintCost,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export async function mintNextAndAddAuthMethods(
'mintNextAndAddAuthMethods',
[
validatedRequest.keyType,
validatedRequest.keySetId,
validatedRequest.permittedAuthMethodTypes,
validatedRequest.permittedAuthMethodIds,
validatedRequest.permittedAuthMethodPubkeys,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {

export const MintRequestSchema = z.object({
keyType: toBigInt,
keySetId: z.literal('naga-keyset1'),
permittedAuthMethodTypes: toBigIntArray,
permittedAuthMethodIds: toHexStringArray,
permittedAuthMethodPubkeys: toHexStringArray,
Expand Down
68 changes: 34 additions & 34 deletions packages/wasm/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading