mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 09:28:28 +00:00
Fix new account again
This commit is contained in:
@@ -12,6 +12,7 @@ export const PkiAcmeAccountsSchema = z.object({
|
|||||||
profileId: z.string().uuid(),
|
profileId: z.string().uuid(),
|
||||||
emails: z.string().array(),
|
emails: z.string().array(),
|
||||||
publicKey: z.unknown(),
|
publicKey: z.unknown(),
|
||||||
|
alg: z.string(),
|
||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
updatedAt: z.date()
|
updatedAt: z.date()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export const registerPkiAcmeRouter = async (server: FastifyZodProvider) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
const { payload, protectedHeader, jwk } = await server.services.pkiAcme.validateJwsPayload(
|
const { payload, protectedHeader } = await server.services.pkiAcme.validateJwsPayload(
|
||||||
req.body as TRawJwsPayload,
|
req.body as TRawJwsPayload,
|
||||||
async (protectedHeader) => {
|
async (protectedHeader) => {
|
||||||
if (!protectedHeader.jwk) {
|
if (!protectedHeader.jwk) {
|
||||||
@@ -120,13 +120,11 @@ export const registerPkiAcmeRouter = async (server: FastifyZodProvider) => {
|
|||||||
},
|
},
|
||||||
CreateAcmeAccountBodySchema
|
CreateAcmeAccountBodySchema
|
||||||
);
|
);
|
||||||
if (!jwk) {
|
const { alg, jwk } = protectedHeader;
|
||||||
throw new AcmeBadPublicKeyError({ detail: "JWK is required in the protected header" });
|
|
||||||
}
|
|
||||||
const { status, body, headers } = await server.services.pkiAcme.createAcmeAccount(
|
const { status, body, headers } = await server.services.pkiAcme.createAcmeAccount(
|
||||||
req.params.profileId,
|
req.params.profileId,
|
||||||
protectedHeader.alg,
|
alg,
|
||||||
jwk,
|
jwk!,
|
||||||
payload
|
payload
|
||||||
);
|
);
|
||||||
// TODO: DRY
|
// TODO: DRY
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ export const pkiAcmeServiceFactory = ({
|
|||||||
|
|
||||||
const newAccount = await acmeAccountDAL.create({
|
const newAccount = await acmeAccountDAL.create({
|
||||||
profileId: profile.id,
|
profileId: profile.id,
|
||||||
|
alg,
|
||||||
publicKey: jwk,
|
publicKey: jwk,
|
||||||
emails: contact ?? []
|
emails: contact ?? []
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ export type TFinalizeAcmeOrderPayload = z.infer<typeof FinalizeAcmeOrderBodySche
|
|||||||
|
|
||||||
export type TJwsPayload<T> = {
|
export type TJwsPayload<T> = {
|
||||||
protectedHeader: TProtectedHeader;
|
protectedHeader: TProtectedHeader;
|
||||||
jwk?: JsonWebKey;
|
|
||||||
payload: T;
|
payload: T;
|
||||||
};
|
};
|
||||||
export type TAcmeResponse<TPayload> = {
|
export type TAcmeResponse<TPayload> = {
|
||||||
|
|||||||
Reference in New Issue
Block a user