use separate base64url module, update dependencies and devDependencies
authorJustin Wind <justin.wind+git@gmail.com>
Sat, 30 Jul 2022 19:01:52 +0000 (12:01 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Sat, 30 Jul 2022 19:01:52 +0000 (12:01 -0700)
README.md
lib/common.js
lib/communication.js
package-lock.json
package.json
test/lib/common.js

index bd005a7e83b23355752f82d1e78e9e0d6845d93c..985c6b0356de83f02310c9d4b613824d0e62cf7f 100644 (file)
--- 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:
 
index 0a8723b0115a5c2ba2cbd21313e0ad367b6a59fe..cfdf9db7e5c47feda5e05b52624a17a25949d853 100644 (file)
@@ -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,
index 2b0c621388aa322a599766064a0658afba50c97d..540eaafa14623ca251a2a7b8d1267bf26a57105b 100644 (file)
@@ -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);
 
index 11380466e84b92cb1e08c9a861fa3a9c804e0b5e..291c1f102a72bee66806b0206f5a4b207921318c 100644 (file)
@@ -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",
       "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"
       }
       }
     },
     "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",
       }
     },
     "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"
       "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",
       "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",
       }
     },
     "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": {}
     },
index 1914aad4d6f3ec935f463d95a2391159903e8837..ef5bb576b7416ef9cbdbeb2f93ac1bbeee51ba4d 100644 (file)
   "author": "Justin Wind <jwind-npm@squeep.com>",
   "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",
index 8b223dadc0ea9c429d7023f3ba1056f534e12aac..05a0cfcb11b02668bf813486ec7deaa0c87a1cdf 100644 (file)
@@ -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 = {