Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@mixmaxhq/url-id
Advanced tools
A utility for encoding and parsing tiny, url-safe objects of identifiers
$ npm install @mixmaxhq/url-id
Create an Encoder
instance, define encoding/decoding rules on it, and begin encoding objects.
const Encoder = require('url-id');
// The default context to encode/decode in.
const encoder = new Encoder('main');
encoder.define('main', {
token: 'g',
match: (obj) => obj && obj.type === 'gmailMessageId',
encode(obj) {
this.assert(typeof obj.userId === 'string');
return this.encode('id', obj.userId) + this.encode('id', obj.gmailMessageId);
},
decode() {
const data = {
type: 'gmailMessageId'
};
[data.userId, data.gmailMessageId] = this.decode('id', 2);
return data;
}
});
encoder.define('id', {
token: 'z',
encode(input) {
return this.string(input, 'utf8');
},
decode() {
return this.string('utf8');
}
});
const exampleData = {
type: 'gmailMessageId',
userId: '76456789976',
gmailMessageId: 'some id here (full unicode)'
};
encoder.encode(exampleData);
// => gzALNzY0NTY3ODk5NzYzAbc29tZSBpZCBoZXJlIChmdWxsIHVuaWNvZGUp
// (length: 58)
encoder.decode('gzALNzY0NTY3ODk5NzYzAbc29tZSBpZCBoZXJlIChmdWxsIHVuaWNvZGUp');
// => { type: 'gmailMessageId',
// userId: '76456789976',
// gmailMessageId: 'some id here (full unicode)' }
// compare to just base64-encoding JSON.stringify:
Buffer.from(JSON.stringify(exampleData)).toString('base64');
// eyJ0eXBlIjoiZ21haWxNZXNzYWdlSWQiLCJ1c2VySWQiOiI3NjQ1Njc4OTk3NiIsImdtYWlsTWVzc2FnZUlkIjoic29tZSBpZCBoZXJlIChmdWxsIHVuaWNvZGUpIn0=
// (length: 128)
FAQs
Encode and parse tiny, url-safe objects of identifiers
The npm package @mixmaxhq/url-id receives a total of 48 weekly downloads. As such, @mixmaxhq/url-id popularity was classified as not popular.
We found that @mixmaxhq/url-id demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 22 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.