fix package issue jwt jwta with node version
This commit is contained in:
@@ -1,16 +1,27 @@
|
|||||||
// CRITICAL FIX: Ensure Buffer is available globally before ANY modules load
|
// CRITICAL FIX: Ensure Buffer and SlowBuffer are available globally before ANY modules load
|
||||||
// This fixes the "Cannot read properties of undefined (reading 'prototype')" error
|
// This fixes the "Cannot read properties of undefined (reading 'prototype')" error
|
||||||
if (typeof global !== 'undefined') {
|
// SlowBuffer was deprecated in Node 18+ and removed in Node 22+, but some packages still use it
|
||||||
// Force load buffer module and make it globally available
|
(function() {
|
||||||
|
const Module = require('module');
|
||||||
|
const originalRequire = Module.prototype.require;
|
||||||
|
|
||||||
|
// Patch require to ensure buffer module always has SlowBuffer
|
||||||
|
Module.prototype.require = function(id) {
|
||||||
|
if (id === 'buffer') {
|
||||||
|
const buf = originalRequire.apply(this, arguments);
|
||||||
|
if (!buf.SlowBuffer) buf.SlowBuffer = buf.Buffer;
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
return originalRequire.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Also ensure global Buffer/SlowBuffer are available
|
||||||
const buffer = require('buffer');
|
const buffer = require('buffer');
|
||||||
if (!global.Buffer) {
|
if (!global.Buffer) global.Buffer = buffer.Buffer;
|
||||||
global.Buffer = buffer.Buffer;
|
if (!global.SlowBuffer) global.SlowBuffer = buffer.Buffer;
|
||||||
}
|
if (globalThis && !globalThis.Buffer) globalThis.Buffer = buffer.Buffer;
|
||||||
// Also ensure it's available in this scope
|
if (globalThis && !globalThis.SlowBuffer) globalThis.SlowBuffer = buffer.Buffer;
|
||||||
if (typeof Buffer === 'undefined') {
|
})();
|
||||||
global.Buffer = buffer.Buffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Double-check Buffer is available
|
// Double-check Buffer is available
|
||||||
if (typeof Buffer === 'undefined') {
|
if (typeof Buffer === 'undefined') {
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ const Odmdb = require("./Odmdb.js");
|
|||||||
|
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod = "Pagans";
|
const currentmod = "Pagans";
|
||||||
const log = process.env.ACTIVELOG ? process.env.ACTIVELOG.split(',').includes(currentmod) : false;
|
const log = process.env.ACTIVELOG
|
||||||
|
? process.env.ACTIVELOG.split(",").includes(currentmod)
|
||||||
|
: false;
|
||||||
/**
|
/**
|
||||||
* Pagan Management numeric Identity and Person (Person = Pagan Id + tribe)
|
* Pagan Management numeric Identity and Person (Person = Pagan Id + tribe)
|
||||||
*
|
*
|
||||||
@@ -56,22 +58,22 @@ Pagans.keyrecovery = (emailalias, tribe, search, lg) => {
|
|||||||
emailalias,
|
emailalias,
|
||||||
tribe,
|
tribe,
|
||||||
search,
|
search,
|
||||||
lg
|
lg,
|
||||||
);
|
);
|
||||||
if (!search || search.length<3) {
|
if (!search || search.length < 3) {
|
||||||
console.log(
|
console.log(
|
||||||
currentmod,
|
currentmod,
|
||||||
"issue with search : emailalias, tribe, search, lg:",
|
"issue with search : emailalias, tribe, search, lg:",
|
||||||
emailalias,
|
emailalias,
|
||||||
tribe,
|
tribe,
|
||||||
search,
|
search,
|
||||||
lg
|
lg,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
status: 406,
|
status: 406,
|
||||||
ref: "Pagans",
|
ref: "Pagans",
|
||||||
msg: "nosearchstring",
|
msg: "nosearchstring",
|
||||||
data: {emailalias,tribe,search,lg},
|
data: { emailalias, tribe, search, lg },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!["email", "alias"].includes(emailalias)) {
|
if (!["email", "alias"].includes(emailalias)) {
|
||||||
@@ -79,7 +81,7 @@ Pagans.keyrecovery = (emailalias, tribe, search, lg) => {
|
|||||||
status: 406,
|
status: 406,
|
||||||
ref: "Pagans",
|
ref: "Pagans",
|
||||||
msg: "emailaliasnotemailoralias",
|
msg: "emailaliasnotemailoralias",
|
||||||
data: {emailalias,tribe,search,lg},
|
data: { emailalias, tribe, search, lg },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let emaillist = [];
|
let emaillist = [];
|
||||||
@@ -109,7 +111,7 @@ Pagans.keyrecovery = (emailalias, tribe, search, lg) => {
|
|||||||
for (let i = 0; i < emaillist.length && i < 3; i++) {
|
for (let i = 0; i < emaillist.length && i < 3; i++) {
|
||||||
const e = emaillist[i];
|
const e = emaillist[i];
|
||||||
const ret = Pagans.sendmailkey(e);
|
const ret = Pagans.sendmailkey(e);
|
||||||
}
|
}
|
||||||
if (emaillist.length > 0) {
|
if (emaillist.length > 0) {
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
@@ -143,14 +145,16 @@ Pagans.getalias = (alias) => {
|
|||||||
data: fs.readJSONSync(`../adminapi/objects/pagans/itm/${alias}.json`),
|
data: fs.readJSONSync(`../adminapi/objects/pagans/itm/${alias}.json`),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
try{
|
try {
|
||||||
const lst_alias=fs.readJSONSync(`../adminapi/objects/pagans/idx/lst_alias.json`)
|
const lst_alias = fs.readJSONSync(
|
||||||
let suggestedalias=[]
|
`../adminapi/objects/pagans/idx/lst_alias.json`,
|
||||||
|
);
|
||||||
|
let suggestedalias = [];
|
||||||
let counter = 1;
|
let counter = 1;
|
||||||
while (suggestedalias.length < 3){
|
while (suggestedalias.length < 3) {
|
||||||
const candidate = `${alias}${counter}`;
|
const candidate = `${alias}${counter}`;
|
||||||
if (!lst_alias.includes(candidate)){
|
if (!lst_alias.includes(candidate)) {
|
||||||
suggestedalias.push(candidate)
|
suggestedalias.push(candidate);
|
||||||
}
|
}
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
@@ -160,8 +164,9 @@ Pagans.getalias = (alias) => {
|
|||||||
msg: "aliasdoesnotexist",
|
msg: "aliasdoesnotexist",
|
||||||
data: { alias, suggestedalias },
|
data: { alias, suggestedalias },
|
||||||
};
|
};
|
||||||
} catch(err){
|
} catch (err) {
|
||||||
return {status:500,msg:"lst_aliaserror",ref:"Pagans",data:{}}
|
return { status: 500, msg: "lst_aliaserror", ref: "Pagans", data: {} };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -195,7 +200,7 @@ Pagans.sendmailkey = (data) => {
|
|||||||
"-",
|
"-",
|
||||||
data.email,
|
data.email,
|
||||||
"-",
|
"-",
|
||||||
data.lg
|
data.lg,
|
||||||
);
|
);
|
||||||
const person = {
|
const person = {
|
||||||
alias: data.alias,
|
alias: data.alias,
|
||||||
@@ -275,7 +280,7 @@ Pagans.authenticatedetachedSignature = async (
|
|||||||
alias,
|
alias,
|
||||||
pubK,
|
pubK,
|
||||||
detachedSignature,
|
detachedSignature,
|
||||||
message
|
message,
|
||||||
) => {
|
) => {
|
||||||
/**
|
/**
|
||||||
* Check that a message was signed with a privateKey from a publicKey
|
* Check that a message was signed with a privateKey from a publicKey
|
||||||
|
|||||||
Reference in New Issue
Block a user