feat(openalias): add openalias helper with crc32 checksum support
Replaces the hand-crafted OpenAlias TXT record for arirex.me with a reusable openalias() function that builds spec-compliant oa1 records. Includes an optional CRC-32 checksum appended as the last field.
This commit is contained in:
59
dnsconfig.js
59
dnsconfig.js
@@ -51,10 +51,15 @@ D("arirex.me", REG_101DOMAIN,
|
|||||||
protonmail("6fd60590dc31588ca5a85c7e311649ff5f93cab2", "dodai2qaszneyk5jeyfloq24ttjcqfer2gdopw3nfmxn3bugtw2hq"),
|
protonmail("6fd60590dc31588ca5a85c7e311649ff5f93cab2", "dodai2qaszneyk5jeyfloq24ttjcqfer2gdopw3nfmxn3bugtw2hq"),
|
||||||
|
|
||||||
// Verifications
|
// Verifications
|
||||||
TXT("@", "oa1:xmr recipient_address=89dQNyY3E9gJGYrEeRw4EFAdezWQg7BBbHJdBpLRwrjH52ngNfAYRcEhAHQotCswGxTeSoFi5nQ7Gf86kySmXzuQE9CXjUH; recipient_name=AriRexouium;", CF_COMMENT("OpenAlias > XMR > Kraken")),
|
|
||||||
TXT("_discord", "dh=1c93b7effbe0bf428cb55d33175c2721ef715bb6", CF_COMMENT("Discord Verify")),
|
TXT("_discord", "dh=1c93b7effbe0bf428cb55d33175c2721ef715bb6", CF_COMMENT("Discord Verify")),
|
||||||
TXT("_atproto", "did=did:plc:53kf45pcsqgayjmoau42lhsk", CF_COMMENT("BlueSky Verify")),
|
TXT("_atproto", "did=did:plc:53kf45pcsqgayjmoau42lhsk", CF_COMMENT("BlueSky Verify")),
|
||||||
TXT("_github-pages-challenge-arirexouium", "0b62c2fb7a8422145d5b5e6637257d", CF_COMMENT("GitHub Pages Verify")),
|
TXT("_github-pages-challenge-arirexouium", "0b62c2fb7a8422145d5b5e6637257d", CF_COMMENT("GitHub Pages Verify")),
|
||||||
|
|
||||||
|
// OpenAlias
|
||||||
|
openalias("xmr", "89dQNyY3E9gJGYrEeRw4EFAdezWQg7BBbHJdBpLRwrjH52ngNfAYRcEhAHQotCswGxTeSoFi5nQ7Gf86kySmXzuQE9CXjUH", {
|
||||||
|
name: "AriRexouium",
|
||||||
|
checksum: true,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
D("achl.fr", REG_101DOMAIN,
|
D("achl.fr", REG_101DOMAIN,
|
||||||
@@ -215,3 +220,55 @@ function simplelogin(verification) {
|
|||||||
dmarcRecord,
|
dmarcRecord,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate OpenAlias TXT record
|
||||||
|
* @param {string} prefix - Application prefix (e.g., "xmr", "btc")
|
||||||
|
* @param {string} address - Recipient address
|
||||||
|
* @param {object} [opts] - Optional key-value pairs
|
||||||
|
* @param {string} [opts.name] - Recipient name
|
||||||
|
* @param {string} [opts.description] - Transaction description
|
||||||
|
* @param {string} [opts.amount] - Transaction amount
|
||||||
|
* @param {string} [opts.paymentId] - Payment ID (e.g., for Monero)
|
||||||
|
* @param {string} [opts.signature] - Address signature
|
||||||
|
* @param {boolean} [opts.checksum] - Optional CRC-32 checksum
|
||||||
|
* @returns {DomainModifier} TXT record
|
||||||
|
*/
|
||||||
|
function openalias(prefix, address, opts) {
|
||||||
|
// Prefix and address are minimum requirement.
|
||||||
|
// Everything else is optional.
|
||||||
|
// Checksum must be last: CRC-32 of the record trimmed of surrounding spaces.
|
||||||
|
|
||||||
|
opts = opts || {};
|
||||||
|
var record = "oa1:" + prefix + " recipient_address=" + address + ";";
|
||||||
|
|
||||||
|
if (opts.name) { record += " recipient_name=" + opts.name + ";"; }
|
||||||
|
if (opts.description) { record += " tx_description=" + opts.description + ";"; }
|
||||||
|
if (opts.amount) { record += " tx_amount=" + opts.amount + ";"; }
|
||||||
|
if (opts.paymentId) { record += " tx_payment_id=" + opts.paymentId + ";"; }
|
||||||
|
if (opts.signature) { record += " address_signature=" + opts.signature + ";"; }
|
||||||
|
if (opts.checksum) { record += " checksum=" + crc32(record.trim()) + ";"; }
|
||||||
|
|
||||||
|
return TXT("@", record, CF_COMMENT("OpenAlias > " + prefix.toUpperCase() + (opts.name ? " > " + opts.name : "")));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate CRC-32 checksum of a string (returns unsigned 32-bit integer)
|
||||||
|
* @param {string} str - Input string
|
||||||
|
* @returns {number} CRC-32 value
|
||||||
|
*/
|
||||||
|
function crc32(str) {
|
||||||
|
var table = [];
|
||||||
|
for (var i = 0; i < 256; i++) {
|
||||||
|
var c = i;
|
||||||
|
for (var j = 0; j < 8; j++) {
|
||||||
|
c = (c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1);
|
||||||
|
}
|
||||||
|
table[i] = c;
|
||||||
|
}
|
||||||
|
var crc = 0xFFFFFFFF;
|
||||||
|
for (var k = 0; k < str.length; k++) {
|
||||||
|
crc = table[(crc ^ str.charCodeAt(k)) & 0xFF] ^ (crc >>> 8);
|
||||||
|
}
|
||||||
|
return (crc ^ 0xFFFFFFFF) >>> 0;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user