From: Justin Wind Date: Sat, 30 Jul 2022 19:01:52 +0000 (-0700) Subject: use separate base64url module, update dependencies and devDependencies X-Git-Tag: v1.1.5~1 X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=1c4bb7e3bbdc1121ceba373c5be4459521197155;p=squeep-indieauth-helper use separate base64url module, update dependencies and devDependencies --- diff --git a/README.md b/README.md index bd005a7..985c6b0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # IndieAuth Helper -Just some abstractions for interacting with IndieAuth sites. +Just some abstractions for interacting with IndieAuth sites, basically wrapping axios and mf2 parsing. + +This is currently quite opinionated, and likely is only really useful in the context of Squeep Framework Applications. Notable methods on the Communication class: diff --git a/lib/common.js b/lib/common.js index 0a8723b..cfdf9db 100644 --- a/lib/common.js +++ b/lib/common.js @@ -15,19 +15,6 @@ const fileScope = (filename) => { } -/** - * Convert Base64 to Base64URL. - * @param {String} input - * @returns {String} - */ -const base64ToBase64URL = (input) => { - return input - .replace(/=/g, '') - .replace(/\+/g, '-') - .replace(/\//g, '_'); -}; - - /** * Pick out useful axios response fields. * @param {*} res @@ -79,7 +66,6 @@ const pick = (obj, props) => { module.exports = { fileScope, - base64ToBase64URL, axiosResponseLogData, logTruncate, pick, diff --git a/lib/communication.js b/lib/communication.js index 2b0c621..540eaaf 100644 --- a/lib/communication.js +++ b/lib/communication.js @@ -2,6 +2,7 @@ const axios = require('axios'); const { mf2 } = require('microformats-parser'); +const { base64ToBase64URL } = require('@squeep/base64url'); const { parse: parseLinkHeader } = require('@squeep/web-linking'); const { Iconv } = require('iconv'); const { version: packageVersion, name: packageName } = require('../package.json'); @@ -46,7 +47,7 @@ class Communication { static _challengeFromVerifier(verifier) { const hash = createHash('sha256'); hash.update(verifier); - return common.base64ToBase64URL(hash.digest('base64')); + return base64ToBase64URL(hash.digest('base64')); } /** @@ -61,7 +62,7 @@ class Communication { const bufferLength = Math.floor(length * 3 / 4); const randomBuffer = await randomBytesAsync(bufferLength); - const verifier = common.base64ToBase64URL(randomBuffer.toString('base64')); + const verifier = base64ToBase64URL(randomBuffer.toString('base64')); const challenge = Communication._challengeFromVerifier(verifier); diff --git a/package-lock.json b/package-lock.json index 1138046..291c1f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,16 +9,17 @@ "version": "1.1.4", "license": "ISC", "dependencies": { - "@squeep/web-linking": "git+https://git.squeep.com/squeep-web-linking/#v1.0.6", + "@squeep/base64url": "^1.0.3", + "@squeep/web-linking": "^1.0.7", "axios": "^0.27.2", "iconv": "^3.0.1", "microformats-parser": "^1.4.1" }, "devDependencies": { - "eslint": "^8.18.0", + "eslint": "^8.20.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-security": "^1.5.0", - "eslint-plugin-sonarjs": "^0.13.0", + "eslint-plugin-sonarjs": "^0.14.0", "mocha": "^10.0.0", "nyc": "^15.1.0", "pre-commit": "^1.2.2", @@ -643,10 +644,18 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, + "node_modules/@squeep/base64url": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@squeep/base64url/-/base64url-1.0.3.tgz", + "integrity": "sha512-0yFGRBMjVKkj2mir0bJStbyaVbZhduP1UYFkbTSaGtVgwY0LsUzuf05S1D22v1ZBeG318ITiQeG3LJcqVf0Rxg==", + "engines": { + "node": ">=14" + } + }, "node_modules/@squeep/web-linking": { - "version": "1.0.6", - "resolved": "git+https://git.squeep.com/squeep-web-linking/#b24731414817523f3a78f10bcbeab8b692797cb8", - "license": "ISC", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@squeep/web-linking/-/web-linking-1.0.7.tgz", + "integrity": "sha512-9d3QijrWc/WNE7p/K7NLUHbmPf92CURRqfzDLV0cGqYNA4QWAPfzwC8hxWpdUkUnep3KakvLKK60l0kEBMM3ag==", "engines": { "node": ">=14.0" } @@ -1190,9 +1199,9 @@ } }, "node_modules/eslint": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.18.0.tgz", - "integrity": "sha512-As1EfFMVk7Xc6/CvhssHUjsAQSkpfXvUGMFC3ce8JDe6WvqCgRrLOBQbVpsBFr1X1V+RACOadnzVvcUS5ni2bA==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.20.0.tgz", + "integrity": "sha512-d4ixhz5SKCa1D6SCPrivP7yYVi7nyD6A4vs6HIAul9ujBzcEmZVM3/0NN/yu5nKhmO1wjp5xQ46iRfmDGlOviA==", "dev": true, "dependencies": { "@eslint/eslintrc": "^1.3.0", @@ -1338,9 +1347,9 @@ } }, "node_modules/eslint-plugin-sonarjs": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.13.0.tgz", - "integrity": "sha512-t3m7ta0EspzDxSOZh3cEOJIJVZgN/TlJYaBGnQlK6W/PZNbWep8q4RQskkJkA7/zwNpX0BaoEOSUUrqaADVoqA==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.14.0.tgz", + "integrity": "sha512-0X0q3fB8ghppms19cR2oIK2ajoFp7DEy3AVGDqO7WX02r1aWOzkrHa+veatGZw+R7amgBvfcF0qHCG66p9Zoag==", "dev": true, "engines": { "node": ">=12" @@ -4073,9 +4082,15 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, + "@squeep/base64url": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@squeep/base64url/-/base64url-1.0.3.tgz", + "integrity": "sha512-0yFGRBMjVKkj2mir0bJStbyaVbZhduP1UYFkbTSaGtVgwY0LsUzuf05S1D22v1ZBeG318ITiQeG3LJcqVf0Rxg==" + }, "@squeep/web-linking": { - "version": "git+https://git.squeep.com/squeep-web-linking/#b24731414817523f3a78f10bcbeab8b692797cb8", - "from": "@squeep/web-linking@git+https://git.squeep.com/squeep-web-linking/#v1.0.6" + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@squeep/web-linking/-/web-linking-1.0.7.tgz", + "integrity": "sha512-9d3QijrWc/WNE7p/K7NLUHbmPf92CURRqfzDLV0cGqYNA4QWAPfzwC8hxWpdUkUnep3KakvLKK60l0kEBMM3ag==" }, "@ungap/promise-all-settled": { "version": "1.1.2", @@ -4477,9 +4492,9 @@ "dev": true }, "eslint": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.18.0.tgz", - "integrity": "sha512-As1EfFMVk7Xc6/CvhssHUjsAQSkpfXvUGMFC3ce8JDe6WvqCgRrLOBQbVpsBFr1X1V+RACOadnzVvcUS5ni2bA==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.20.0.tgz", + "integrity": "sha512-d4ixhz5SKCa1D6SCPrivP7yYVi7nyD6A4vs6HIAul9ujBzcEmZVM3/0NN/yu5nKhmO1wjp5xQ46iRfmDGlOviA==", "dev": true, "requires": { "@eslint/eslintrc": "^1.3.0", @@ -4587,9 +4602,9 @@ } }, "eslint-plugin-sonarjs": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.13.0.tgz", - "integrity": "sha512-t3m7ta0EspzDxSOZh3cEOJIJVZgN/TlJYaBGnQlK6W/PZNbWep8q4RQskkJkA7/zwNpX0BaoEOSUUrqaADVoqA==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.14.0.tgz", + "integrity": "sha512-0X0q3fB8ghppms19cR2oIK2ajoFp7DEy3AVGDqO7WX02r1aWOzkrHa+veatGZw+R7amgBvfcF0qHCG66p9Zoag==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index 1914aad..ef5bb57 100644 --- a/package.json +++ b/package.json @@ -25,16 +25,17 @@ "author": "Justin Wind ", "license": "ISC", "dependencies": { - "@squeep/web-linking": "git+https://git.squeep.com/squeep-web-linking/#v1.0.6", + "@squeep/base64url": "^1.0.3", + "@squeep/web-linking": "^1.0.7", "axios": "^0.27.2", "iconv": "^3.0.1", "microformats-parser": "^1.4.1" }, "devDependencies": { - "eslint": "^8.18.0", + "eslint": "^8.20.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-security": "^1.5.0", - "eslint-plugin-sonarjs": "^0.13.0", + "eslint-plugin-sonarjs": "^0.14.0", "mocha": "^10.0.0", "nyc": "^15.1.0", "pre-commit": "^1.2.2", diff --git a/test/lib/common.js b/test/lib/common.js index 8b223da..05a0cfc 100644 --- a/test/lib/common.js +++ b/test/lib/common.js @@ -18,15 +18,6 @@ describe('common', function () { }); }); // fileScope - describe('base64ToBase64URL', function () { - it('works', function () { - const b64 = 'ab/cd+e='; - const expected = 'ab_cd-e'; - const result = common.base64ToBase64URL(b64); - assert.strictEqual(result, expected); - }); - }); // base64ToBase64URL - describe('pick', function () { it('picks', function () { const srcObj = {