@tryghost/acme-http-01-sequelize
Advanced tools
+8
-8
@@ -15,2 +15,4 @@ const {Sequelize, Model, DataTypes} = require('sequelize'); | ||
| this._Challenge = class Challenge extends Model {}; | ||
| this._setupPromise = this.init(); | ||
| } | ||
@@ -51,2 +53,3 @@ | ||
| async get(options) { | ||
| await this._setupPromise; | ||
| const subject = options.challenge.identifier.value; | ||
@@ -72,16 +75,12 @@ const token = options.challenge.token; | ||
| async set(options) { | ||
| const [challenge, created] = await this._Challenge.findOrCreate({ | ||
| await this._setupPromise; | ||
| const [challenge] = await this._Challenge.findOrCreate({ | ||
| where: { | ||
| subject: options.challenge.identifier.value, | ||
| token: options.challenge.token | ||
| }, | ||
| defaults: { | ||
| authorizationKey: options.challenge.keyAuthorization | ||
| } | ||
| }); | ||
| if (!created) { | ||
| challenge.authorizationKey = options.challenge.keyAuthorization; | ||
| challenge.save(); | ||
| } | ||
| challenge.authorizationKey = options.challenge.keyAuthorization; | ||
| challenge.save(); | ||
@@ -92,2 +91,3 @@ return null; | ||
| async remove(options) { | ||
| await this._setupPromise; | ||
| const deleted = await this._Challenge.destroy({ | ||
@@ -94,0 +94,0 @@ where: { |
+1
-1
| { | ||
| "name": "@tryghost/acme-http-01-sequelize", | ||
| "version": "0.1.0", | ||
| "version": "0.2.0", | ||
| "repository": "git@github.com:TryGhost/acme-http-01-sequelize.git", | ||
@@ -5,0 +5,0 @@ "author": "Ghost Foundation", |
6496
-0.22%143
-0.69%