sign.js
510 Bytes
const ps = ['p', 'a', 'r', 'a', 'm', 's'];
const ts = ['t', 's'];
export const getParams = (op) => {
const p = ps.join('');
if (!op[p]) {
op[p] = {};
}
return op[p];
};
export const setTime = (p) => {
p[ts.join('')] = Date.now();
};
export const setSign = (p, sign) => {
p.s = sign;
};
export const sortParams = (p) => {
return Object.keys(p).sort();
};
export const joinParams = (p, sks) => {
return sks.map(key => {
return `${key}:${encodeURIComponent(p[key])}`;
}).join('_');
};