Add new template format with hashing algorithm
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 4s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 1m18s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 6s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 0s
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 4s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 1m18s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 6s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 0s
This commit is contained in:
parent
280cc2da40
commit
ac6c0dc71e
17 changed files with 2157 additions and 609 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { extractContentControls } from "../lib-tmpl";
|
||||
import { extractContentControls, extractBookmark, templateContentControls, setCustomDocProps, getDocProps,templateDynamicContents } from "@/lib/lib-tmpl";
|
||||
import { verifyDataEd25519, verifyHmacSha256 } from "@/lib/lib-utils";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
|
|
@ -14,6 +15,9 @@ export async function POST(request: Request) {
|
|||
try {
|
||||
const formData = await request.formData();
|
||||
const file = formData.get("file");
|
||||
const TEST_SECRET = String(formData.get("secret"))??"";
|
||||
const TEST_PUBLIC_KEY_HEX = String(formData.get("public_key"))??"";
|
||||
|
||||
|
||||
if (!(file instanceof File)) {
|
||||
return NextResponse.json(
|
||||
|
|
@ -52,12 +56,35 @@ export async function POST(request: Request) {
|
|||
const buffer = Buffer.from(await file.arrayBuffer());
|
||||
|
||||
// ใช้ lib-tmpl.ts เดิม
|
||||
const data = extractContentControls(buffer);
|
||||
// const data = extractContentControls(buffer);
|
||||
|
||||
return NextResponse.json({
|
||||
const cc = extractContentControls(buffer);
|
||||
const bookmark = extractBookmark(buffer)
|
||||
const properties = getDocProps(buffer)
|
||||
let verify: Record<string, unknown> ={}
|
||||
const ticket_data = String(properties?.custom?.ticket_data)
|
||||
const HmacSha256 = String(properties?.custom?.HmacSha256)
|
||||
const Ed25519 = String(properties?.custom?.Ed25519)
|
||||
|
||||
if(ticket_data){
|
||||
const ticketDataObj= JSON.parse(ticket_data)
|
||||
const unix_timestamp = Number(ticketDataObj.exp)*1000
|
||||
if(unix_timestamp){
|
||||
verify['exp'] = new Date(unix_timestamp).toLocaleString("th-TH", { timeZone: "Asia/Bangkok" })
|
||||
}
|
||||
if(TEST_SECRET && HmacSha256){
|
||||
verify['verifyHmacSha256'] = verifyHmacSha256(ticket_data,TEST_SECRET,HmacSha256)
|
||||
}
|
||||
if(TEST_PUBLIC_KEY_HEX&& Ed25519){
|
||||
verify["Ed25519"]=verifyDataEd25519(ticket_data,Ed25519,TEST_PUBLIC_KEY_HEX)
|
||||
}
|
||||
}
|
||||
let returnData : Record<string, unknown> = {
|
||||
success: true,
|
||||
data,
|
||||
});
|
||||
cc,bookmark,properties,verify
|
||||
}
|
||||
|
||||
return NextResponse.json(returnData);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue