Skip to content

Commit

Permalink
Allow legacy signature service to start without actorsKeyPairsDir s…
Browse files Browse the repository at this point in the history
…etting
  • Loading branch information
Laurin-W committed Oct 11, 2024
1 parent 8cfa146 commit 3f25fc2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/middleware/packages/crypto/keys/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ module.exports = {

/** Returns true, if the server has migrated to the new keys service yet, i.e. keys are stored in the user dataset, not on fs. */
async isMigrated() {
// If the `actorsKeyPairsDir` setting is not set, we assume migration has happened or was never needed.
if (!this.settings.actorsKeyPairsDir) {
return true;
}

// Check actorsKeyPairsDir for existing keys.
if (!fs.existsSync(this.settings.actorsKeyPairsDir)) {
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/middleware/packages/crypto/signature/keypair.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const SignatureService = {
actorsKeyPairsDir: null
},
async created() {
if (!this.settings.actorsKeyPairsDir) {
throw new Error('You must set the actorsKeyPairsDir setting in the signature service');
} else if (!fs.existsSync(this.settings.actorsKeyPairsDir)) {
throw new Error(`The actorsKeyPairsDir (${this.settings.actorsKeyPairsDir}) does not exist! Please create it.`);
if (this.settings.actorsKeyPairsDir && !fs.existsSync(this.settings.actorsKeyPairsDir)) {
throw new Error(
`The \`actorsKeyPairsDir\` is configured for the keys legacy service but the directory (${this.settings.actorsKeyPairsDir}) does not exist! Please remove the setting (preferred) or create the directory.`
);
}
},
async started() {
Expand Down

0 comments on commit 3f25fc2

Please sign in to comment.