strapi-plugin-magic-sessionmanager 4.2.9 → 4.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/index.js +44 -2
- package/dist/server/index.mjs +44 -2
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -286,6 +286,7 @@ var bootstrap$1 = async ({ strapi: strapi2 }) => {
|
|
|
286
286
|
const log = createLogger$3(strapi2);
|
|
287
287
|
log.info("[START] Bootstrap starting...");
|
|
288
288
|
try {
|
|
289
|
+
await ensureTokenHashIndex(strapi2, log);
|
|
289
290
|
const licenseGuardService = strapi2.plugin("magic-sessionmanager").service("license-guard");
|
|
290
291
|
setTimeout(async () => {
|
|
291
292
|
const licenseStatus = await licenseGuardService.initialize();
|
|
@@ -642,6 +643,46 @@ async function ensureContentApiPermissions(strapi2, log) {
|
|
|
642
643
|
log.warn("Please manually enable plugin permissions in Settings > Users & Permissions > Roles > Authenticated");
|
|
643
644
|
}
|
|
644
645
|
}
|
|
646
|
+
async function ensureTokenHashIndex(strapi2, log) {
|
|
647
|
+
try {
|
|
648
|
+
const knex = strapi2.db.connection;
|
|
649
|
+
const tableName = "magic_sessions";
|
|
650
|
+
const indexName = "idx_magic_sessions_token_hash";
|
|
651
|
+
const hasIndex = await knex.schema.hasTable(tableName).then(async (exists) => {
|
|
652
|
+
if (!exists) return false;
|
|
653
|
+
const dialect = strapi2.db.dialect.client;
|
|
654
|
+
if (dialect === "postgres") {
|
|
655
|
+
const result = await knex.raw(`
|
|
656
|
+
SELECT indexname FROM pg_indexes
|
|
657
|
+
WHERE tablename = ? AND indexname = ?
|
|
658
|
+
`, [tableName, indexName]);
|
|
659
|
+
return result.rows.length > 0;
|
|
660
|
+
} else if (dialect === "mysql" || dialect === "mysql2") {
|
|
661
|
+
const result = await knex.raw(`
|
|
662
|
+
SHOW INDEX FROM ${tableName} WHERE Key_name = ?
|
|
663
|
+
`, [indexName]);
|
|
664
|
+
return result[0].length > 0;
|
|
665
|
+
} else if (dialect === "sqlite" || dialect === "better-sqlite3") {
|
|
666
|
+
const result = await knex.raw(`
|
|
667
|
+
SELECT name FROM sqlite_master
|
|
668
|
+
WHERE type='index' AND name = ?
|
|
669
|
+
`, [indexName]);
|
|
670
|
+
return result.length > 0;
|
|
671
|
+
}
|
|
672
|
+
return false;
|
|
673
|
+
});
|
|
674
|
+
if (hasIndex) {
|
|
675
|
+
log.debug("[INDEX] tokenHash index already exists");
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
await knex.schema.alterTable(tableName, (table) => {
|
|
679
|
+
table.index(["token_hash", "is_active"], indexName);
|
|
680
|
+
});
|
|
681
|
+
log.info("[INDEX] Created tokenHash index for O(1) session lookup");
|
|
682
|
+
} catch (err) {
|
|
683
|
+
log.debug("[INDEX] Could not create tokenHash index (will retry on next startup):", err.message);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
645
686
|
const { createLogger: createLogger$2 } = logger;
|
|
646
687
|
var destroy$1 = async ({ strapi: strapi2 }) => {
|
|
647
688
|
const log = createLogger$2(strapi2);
|
|
@@ -722,7 +763,8 @@ const attributes = {
|
|
|
722
763
|
},
|
|
723
764
|
tokenHash: {
|
|
724
765
|
type: "string",
|
|
725
|
-
configurable: false
|
|
766
|
+
configurable: false,
|
|
767
|
+
unique: false
|
|
726
768
|
},
|
|
727
769
|
refreshToken: {
|
|
728
770
|
type: "text",
|
|
@@ -2068,7 +2110,7 @@ var session$1 = ({ strapi: strapi2 }) => {
|
|
|
2068
2110
|
}
|
|
2069
2111
|
};
|
|
2070
2112
|
};
|
|
2071
|
-
const version = "4.2.
|
|
2113
|
+
const version = "4.2.9";
|
|
2072
2114
|
const require$$2 = {
|
|
2073
2115
|
version
|
|
2074
2116
|
};
|
package/dist/server/index.mjs
CHANGED
|
@@ -282,6 +282,7 @@ var bootstrap$1 = async ({ strapi: strapi2 }) => {
|
|
|
282
282
|
const log = createLogger$3(strapi2);
|
|
283
283
|
log.info("[START] Bootstrap starting...");
|
|
284
284
|
try {
|
|
285
|
+
await ensureTokenHashIndex(strapi2, log);
|
|
285
286
|
const licenseGuardService = strapi2.plugin("magic-sessionmanager").service("license-guard");
|
|
286
287
|
setTimeout(async () => {
|
|
287
288
|
const licenseStatus = await licenseGuardService.initialize();
|
|
@@ -638,6 +639,46 @@ async function ensureContentApiPermissions(strapi2, log) {
|
|
|
638
639
|
log.warn("Please manually enable plugin permissions in Settings > Users & Permissions > Roles > Authenticated");
|
|
639
640
|
}
|
|
640
641
|
}
|
|
642
|
+
async function ensureTokenHashIndex(strapi2, log) {
|
|
643
|
+
try {
|
|
644
|
+
const knex = strapi2.db.connection;
|
|
645
|
+
const tableName = "magic_sessions";
|
|
646
|
+
const indexName = "idx_magic_sessions_token_hash";
|
|
647
|
+
const hasIndex = await knex.schema.hasTable(tableName).then(async (exists) => {
|
|
648
|
+
if (!exists) return false;
|
|
649
|
+
const dialect = strapi2.db.dialect.client;
|
|
650
|
+
if (dialect === "postgres") {
|
|
651
|
+
const result = await knex.raw(`
|
|
652
|
+
SELECT indexname FROM pg_indexes
|
|
653
|
+
WHERE tablename = ? AND indexname = ?
|
|
654
|
+
`, [tableName, indexName]);
|
|
655
|
+
return result.rows.length > 0;
|
|
656
|
+
} else if (dialect === "mysql" || dialect === "mysql2") {
|
|
657
|
+
const result = await knex.raw(`
|
|
658
|
+
SHOW INDEX FROM ${tableName} WHERE Key_name = ?
|
|
659
|
+
`, [indexName]);
|
|
660
|
+
return result[0].length > 0;
|
|
661
|
+
} else if (dialect === "sqlite" || dialect === "better-sqlite3") {
|
|
662
|
+
const result = await knex.raw(`
|
|
663
|
+
SELECT name FROM sqlite_master
|
|
664
|
+
WHERE type='index' AND name = ?
|
|
665
|
+
`, [indexName]);
|
|
666
|
+
return result.length > 0;
|
|
667
|
+
}
|
|
668
|
+
return false;
|
|
669
|
+
});
|
|
670
|
+
if (hasIndex) {
|
|
671
|
+
log.debug("[INDEX] tokenHash index already exists");
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
await knex.schema.alterTable(tableName, (table) => {
|
|
675
|
+
table.index(["token_hash", "is_active"], indexName);
|
|
676
|
+
});
|
|
677
|
+
log.info("[INDEX] Created tokenHash index for O(1) session lookup");
|
|
678
|
+
} catch (err) {
|
|
679
|
+
log.debug("[INDEX] Could not create tokenHash index (will retry on next startup):", err.message);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
641
682
|
const { createLogger: createLogger$2 } = logger;
|
|
642
683
|
var destroy$1 = async ({ strapi: strapi2 }) => {
|
|
643
684
|
const log = createLogger$2(strapi2);
|
|
@@ -718,7 +759,8 @@ const attributes = {
|
|
|
718
759
|
},
|
|
719
760
|
tokenHash: {
|
|
720
761
|
type: "string",
|
|
721
|
-
configurable: false
|
|
762
|
+
configurable: false,
|
|
763
|
+
unique: false
|
|
722
764
|
},
|
|
723
765
|
refreshToken: {
|
|
724
766
|
type: "text",
|
|
@@ -2064,7 +2106,7 @@ var session$1 = ({ strapi: strapi2 }) => {
|
|
|
2064
2106
|
}
|
|
2065
2107
|
};
|
|
2066
2108
|
};
|
|
2067
|
-
const version = "4.2.
|
|
2109
|
+
const version = "4.2.9";
|
|
2068
2110
|
const require$$2 = {
|
|
2069
2111
|
version
|
|
2070
2112
|
};
|
package/package.json
CHANGED