strapi-plugin-magic-sessionmanager 4.5.13 → 4.6.1
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/CHANGELOG.md +14 -0
- package/README.md +90 -34
- package/dist/{_chunks/Analytics-DM4_UffY.js → admin/Analytics-BMkhiuRX.js} +3 -121
- package/dist/{_chunks/Analytics--qB2cKuD.mjs → admin/Analytics-CwNJ3TNI.mjs} +5 -123
- package/dist/{_chunks/App-DF-VsbDW.js → admin/App-DazHh7Zi.js} +67 -646
- package/dist/{_chunks/App-CL5q29Mi.mjs → admin/App-Sk0F9UEN.mjs} +69 -648
- package/dist/{_chunks/License-D9piCp34.mjs → admin/License-6SIpR7Rk.mjs} +34 -113
- package/dist/{_chunks/License-Dmm1d3fQ.js → admin/License-BwbmzbP_.js} +34 -113
- package/dist/{_chunks/OnlineUsersWidget-KchZ_ScS.js → admin/OnlineUsersWidget-BIfnbFcZ.js} +44 -36
- package/dist/{_chunks/OnlineUsersWidget-DHsthkt0.mjs → admin/OnlineUsersWidget-Qq_uCTi1.mjs} +44 -36
- package/dist/{_chunks/Settings-D6ILgR9X.mjs → admin/Settings-BA7S_8DF.mjs} +286 -112
- package/dist/{_chunks/Settings-CUNaxDWk.js → admin/Settings-CCYScjxv.js} +284 -110
- package/dist/{_chunks/de-CDA1V0rF.mjs → admin/de-6rIvkYOp.mjs} +37 -14
- package/dist/{_chunks/de-I-Q-pWqu.js → admin/de-DjP2WJ_V.js} +37 -14
- package/dist/{_chunks/en-Bd7_h-4e.js → admin/en-0pesBbOT.js} +37 -14
- package/dist/{_chunks/en-DzmOCyzQ.mjs → admin/en-8hiv31Dv.mjs} +37 -14
- package/dist/{_chunks/es-BcAx18XG.js → admin/es-DdBRpF7F.js} +37 -14
- package/dist/{_chunks/es-Cx-SN6qV.mjs → admin/es-LRQ148f5.mjs} +37 -14
- package/dist/{_chunks/fr-DXlXE5Eo.mjs → admin/fr-CKhx_qil.mjs} +37 -14
- package/dist/{_chunks/fr-DCzYMuJ-.js → admin/fr-DJ6DbeDy.js} +37 -14
- package/dist/{_chunks/index-CTxGMDHr.js → admin/index-DTskQVDl.js} +12 -25
- package/dist/{_chunks/index-CwxKazpc.mjs → admin/index-UTLA1r40.mjs} +12 -25
- package/dist/admin/index.js +3 -2
- package/dist/admin/index.mjs +1 -1
- package/dist/{_chunks/pt-21-MAb72.js → admin/pt-D0SMoAmo.js} +37 -14
- package/dist/{_chunks/pt-zsdTSjba.mjs → admin/pt-DXizUvcj.mjs} +37 -14
- package/dist/server/index.js +9680 -8914
- package/dist/server/index.mjs +9701 -8918
- package/package.json +25 -14
- package/scripts/geoip-updater.cjs +220 -0
- package/scripts/update-geoip-db.mjs +38 -0
- package/strapi-admin.js +2 -1
- package/strapi-server.js +2 -1
- package/dist/_chunks/UpgradePage-D697BVWo.mjs +0 -352
- package/dist/_chunks/UpgradePage-Dwrv7g8L.js +0 -354
- package/dist/_chunks/useLicense-B9WW9s_d.mjs +0 -86
- package/dist/_chunks/useLicense-BEbtA_Zo.js +0 -85
- /package/dist/{_chunks → admin}/StyledButtons-Cz8oYhmc.mjs +0 -0
- /package/dist/{_chunks → admin}/StyledButtons-DDuxnYz8.js +0 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.
|
|
2
|
+
"version": "4.6.1",
|
|
3
3
|
"keywords": [
|
|
4
4
|
"strapi",
|
|
5
5
|
"plugin",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"activity-monitoring"
|
|
12
12
|
],
|
|
13
13
|
"type": "commonjs",
|
|
14
|
+
"bin": {
|
|
15
|
+
"strapi-magic-sessionmanager-geoip": "./scripts/update-geoip-db.mjs"
|
|
16
|
+
},
|
|
14
17
|
"exports": {
|
|
15
18
|
"./package.json": "./package.json",
|
|
16
19
|
"./strapi-admin": {
|
|
@@ -30,47 +33,55 @@
|
|
|
30
33
|
"dist",
|
|
31
34
|
"strapi-admin.js",
|
|
32
35
|
"strapi-server.js",
|
|
36
|
+
"scripts/geoip-updater.cjs",
|
|
37
|
+
"scripts/update-geoip-db.mjs",
|
|
33
38
|
"README.md",
|
|
34
39
|
"LICENSE",
|
|
35
40
|
"CHANGELOG.md",
|
|
36
41
|
"pics"
|
|
37
42
|
],
|
|
38
43
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
44
|
+
"node": ">=20.0.0 <=26.x.x",
|
|
40
45
|
"npm": ">=6.0.0"
|
|
41
46
|
},
|
|
42
47
|
"scripts": {
|
|
43
|
-
"
|
|
48
|
+
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
49
|
+
"test": "node --test tests/*.test.js tests/*.test.mjs",
|
|
50
|
+
"build": "npm run clean && strapi-plugin build && node scripts/build-server-bundle.mjs",
|
|
44
51
|
"watch": "strapi-plugin watch",
|
|
45
52
|
"watch:link": "strapi-plugin watch:link",
|
|
46
|
-
"
|
|
53
|
+
"geoip:update": "node scripts/update-geoip-db.mjs",
|
|
54
|
+
"verify": "strapi-plugin verify",
|
|
55
|
+
"verify:runtime": "node scripts/verify-server-bundle.mjs",
|
|
56
|
+
"prepublishOnly": "npm test && npm run build && npm run verify && npm run verify:runtime"
|
|
47
57
|
},
|
|
48
58
|
"dependencies": {
|
|
49
|
-
"
|
|
59
|
+
"@maxmind/geoip2-node": "^6.3.4",
|
|
60
|
+
"sanitize-html": "^2.17.5"
|
|
50
61
|
},
|
|
51
62
|
"devDependencies": {
|
|
52
63
|
"@semantic-release/changelog": "^6.0.3",
|
|
53
64
|
"@semantic-release/commit-analyzer": "^13.0.0",
|
|
54
65
|
"@semantic-release/git": "^10.0.1",
|
|
55
|
-
"@semantic-release/github": "^12.0.
|
|
66
|
+
"@semantic-release/github": "^12.0.8",
|
|
56
67
|
"@semantic-release/npm": "^13.1.5",
|
|
57
|
-
"@semantic-release/release-notes-generator": "^14.
|
|
68
|
+
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
58
69
|
"@strapi/design-system": "^2.2.0",
|
|
59
70
|
"@strapi/icons": "^2.2.0",
|
|
60
|
-
"@strapi/sdk-plugin": "^
|
|
61
|
-
"@strapi/strapi": "^5.
|
|
62
|
-
"
|
|
71
|
+
"@strapi/sdk-plugin": "^6.1.1",
|
|
72
|
+
"@strapi/strapi": "^5.48.1",
|
|
73
|
+
"esbuild": "^0.28.1",
|
|
74
|
+
"prettier": "^3.8.4",
|
|
63
75
|
"react": "^18.3.1",
|
|
64
76
|
"react-dom": "^18.3.1",
|
|
65
77
|
"react-intl": "^7.1.14",
|
|
66
|
-
"react-router-dom": "^6.30.
|
|
67
|
-
"semantic-release": "^25.0.
|
|
68
|
-
"styled-components": "^6.
|
|
78
|
+
"react-router-dom": "^6.30.4",
|
|
79
|
+
"semantic-release": "^25.0.5",
|
|
80
|
+
"styled-components": "^6.4.2"
|
|
69
81
|
},
|
|
70
82
|
"peerDependencies": {
|
|
71
83
|
"@strapi/design-system": "^2.0.0",
|
|
72
84
|
"@strapi/icons": "^2.0.0",
|
|
73
|
-
"@strapi/sdk-plugin": "^5.3.2 || ^6.0.0",
|
|
74
85
|
"@strapi/strapi": "^5.0.0",
|
|
75
86
|
"@strapi/utils": "^5.0.0",
|
|
76
87
|
"react": "^18.3.1",
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs/promises');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const process = require('node:process');
|
|
6
|
+
const zlib = require('node:zlib');
|
|
7
|
+
const { promisify } = require('node:util');
|
|
8
|
+
|
|
9
|
+
const gunzip = promisify(zlib.gunzip);
|
|
10
|
+
|
|
11
|
+
const DEFAULT_EDITION_ID = 'GeoLite2-Country';
|
|
12
|
+
const DEFAULT_MMDB_NAME = 'GeoLite2-Country.mmdb';
|
|
13
|
+
const DEFAULT_OUTPUT_PATH = path.resolve(process.cwd(), 'data', DEFAULT_MMDB_NAME);
|
|
14
|
+
|
|
15
|
+
function buildDownloadUrl(editionId = DEFAULT_EDITION_ID) {
|
|
16
|
+
return `https://download.maxmind.com/geoip/databases/${encodeURIComponent(editionId)}/download?suffix=tar.gz`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function buildBasicAuthHeader(accountId, licenseKey) {
|
|
20
|
+
return `Basic ${Buffer.from(`${accountId}:${licenseKey}`).toString('base64')}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function resolveConfig(env = process.env, argv = process.argv.slice(2), overrides = {}) {
|
|
24
|
+
const force = argv.includes('--force') || overrides.force === true;
|
|
25
|
+
const editionId = overrides.editionId || env.MAXMIND_EDITION_ID || DEFAULT_EDITION_ID;
|
|
26
|
+
const outputPath = overrides.outputPath || env.MAGIC_SESSIONMANAGER_GEOIP_DATABASE || env.GEOIP_DATABASE_PATH || DEFAULT_OUTPUT_PATH;
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
accountId: overrides.accountId || env.MAXMIND_ACCOUNT_ID || env.MAXMIND_USER_ID || '',
|
|
30
|
+
licenseKey: overrides.licenseKey || env.MAXMIND_LICENSE_KEY || '',
|
|
31
|
+
editionId,
|
|
32
|
+
outputPath,
|
|
33
|
+
mmdbFileName: `${editionId}.mmdb`,
|
|
34
|
+
force,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function needsDownload({
|
|
39
|
+
force,
|
|
40
|
+
localExists,
|
|
41
|
+
localMetadata,
|
|
42
|
+
remoteLastModified,
|
|
43
|
+
}) {
|
|
44
|
+
if (force) return true;
|
|
45
|
+
if (!localExists) return true;
|
|
46
|
+
if (!remoteLastModified) return true;
|
|
47
|
+
return localMetadata?.lastModified !== remoteLastModified;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function extractMmdbFromTarGz(archiveBuffer, preferredFileName = DEFAULT_MMDB_NAME) {
|
|
51
|
+
const tarBuffer = await gunzip(archiveBuffer);
|
|
52
|
+
let offset = 0;
|
|
53
|
+
|
|
54
|
+
while (offset + 512 <= tarBuffer.length) {
|
|
55
|
+
const header = tarBuffer.subarray(offset, offset + 512);
|
|
56
|
+
offset += 512;
|
|
57
|
+
|
|
58
|
+
if (header.every((byte) => byte === 0)) {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const name = readTarString(header, 0, 100);
|
|
63
|
+
const prefix = readTarString(header, 345, 155);
|
|
64
|
+
const fullName = prefix ? `${prefix}/${name}` : name;
|
|
65
|
+
const typeFlag = readTarString(header, 156, 1);
|
|
66
|
+
const sizeOctal = readTarString(header, 124, 12).replace(/\0/g, '').trim();
|
|
67
|
+
const size = Number.parseInt(sizeOctal || '0', 8);
|
|
68
|
+
const data = tarBuffer.subarray(offset, offset + size);
|
|
69
|
+
|
|
70
|
+
const normalizedName = fullName.replace(/\\/g, '/');
|
|
71
|
+
const isRegularFile = typeFlag === '' || typeFlag === '0';
|
|
72
|
+
if (
|
|
73
|
+
isRegularFile &&
|
|
74
|
+
normalizedName.endsWith('.mmdb') &&
|
|
75
|
+
path.posix.basename(normalizedName) === preferredFileName
|
|
76
|
+
) {
|
|
77
|
+
return {
|
|
78
|
+
name: normalizedName,
|
|
79
|
+
data: Buffer.from(data),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
offset += Math.ceil(size / 512) * 512;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
throw new Error(`No ${preferredFileName} file found in MaxMind archive`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function readTarString(buffer, start, length) {
|
|
90
|
+
const slice = buffer.subarray(start, start + length);
|
|
91
|
+
const nullIndex = slice.indexOf(0);
|
|
92
|
+
return slice.subarray(0, nullIndex === -1 ? slice.length : nullIndex).toString('utf8');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function readMetadata(metadataPath) {
|
|
96
|
+
try {
|
|
97
|
+
return JSON.parse(await fs.readFile(metadataPath, 'utf8'));
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function fileExists(filePath) {
|
|
104
|
+
try {
|
|
105
|
+
await fs.access(filePath);
|
|
106
|
+
return true;
|
|
107
|
+
} catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function fetchHead(url, authHeader) {
|
|
113
|
+
const response = await fetch(url, {
|
|
114
|
+
method: 'HEAD',
|
|
115
|
+
headers: {
|
|
116
|
+
Authorization: authHeader,
|
|
117
|
+
'User-Agent': 'Strapi-Magic-SessionManager-GeoIP-Updater/1.0',
|
|
118
|
+
},
|
|
119
|
+
redirect: 'follow',
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (!response.ok) {
|
|
123
|
+
throw new Error(`MaxMind HEAD failed with HTTP ${response.status}`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
lastModified: response.headers.get('last-modified') || '',
|
|
128
|
+
contentDisposition: response.headers.get('content-disposition') || '',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function fetchArchive(url, authHeader) {
|
|
133
|
+
const response = await fetch(url, {
|
|
134
|
+
method: 'GET',
|
|
135
|
+
headers: {
|
|
136
|
+
Authorization: authHeader,
|
|
137
|
+
'User-Agent': 'Strapi-Magic-SessionManager-GeoIP-Updater/1.0',
|
|
138
|
+
},
|
|
139
|
+
redirect: 'follow',
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
if (!response.ok) {
|
|
143
|
+
throw new Error(`MaxMind download failed with HTTP ${response.status}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return Buffer.from(await response.arrayBuffer());
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function writeAtomic(outputPath, data) {
|
|
150
|
+
const directory = path.dirname(outputPath);
|
|
151
|
+
await fs.mkdir(directory, { recursive: true });
|
|
152
|
+
|
|
153
|
+
const tempPath = `${outputPath}.${process.pid}.${Date.now()}.tmp`;
|
|
154
|
+
await fs.writeFile(tempPath, data);
|
|
155
|
+
await fs.rename(tempPath, outputPath);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function updateGeoIpDatabase(config = resolveConfig()) {
|
|
159
|
+
if (!config.accountId || !config.licenseKey) {
|
|
160
|
+
throw new Error('MAXMIND_ACCOUNT_ID and MAXMIND_LICENSE_KEY are required');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const url = buildDownloadUrl(config.editionId);
|
|
164
|
+
const authHeader = buildBasicAuthHeader(config.accountId, config.licenseKey);
|
|
165
|
+
const metadataPath = `${config.outputPath}.metadata.json`;
|
|
166
|
+
|
|
167
|
+
const [head, localMetadata, localExists] = await Promise.all([
|
|
168
|
+
fetchHead(url, authHeader),
|
|
169
|
+
readMetadata(metadataPath),
|
|
170
|
+
fileExists(config.outputPath),
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
if (!needsDownload({
|
|
174
|
+
force: config.force,
|
|
175
|
+
localExists,
|
|
176
|
+
localMetadata,
|
|
177
|
+
remoteLastModified: head.lastModified,
|
|
178
|
+
})) {
|
|
179
|
+
return {
|
|
180
|
+
changed: false,
|
|
181
|
+
outputPath: config.outputPath,
|
|
182
|
+
lastModified: head.lastModified,
|
|
183
|
+
message: 'GeoIP database is already current',
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const archive = await fetchArchive(url, authHeader);
|
|
188
|
+
const extracted = await extractMmdbFromTarGz(archive, config.mmdbFileName);
|
|
189
|
+
|
|
190
|
+
await writeAtomic(config.outputPath, extracted.data);
|
|
191
|
+
await fs.writeFile(metadataPath, JSON.stringify({
|
|
192
|
+
editionId: config.editionId,
|
|
193
|
+
sourceFile: extracted.name,
|
|
194
|
+
lastModified: head.lastModified,
|
|
195
|
+
downloadedAt: new Date().toISOString(),
|
|
196
|
+
sourceUrl: url,
|
|
197
|
+
}, null, 2));
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
changed: true,
|
|
201
|
+
outputPath: config.outputPath,
|
|
202
|
+
sourceFile: extracted.name,
|
|
203
|
+
lastModified: head.lastModified,
|
|
204
|
+
message: 'GeoIP database updated',
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
module.exports = {
|
|
209
|
+
DEFAULT_EDITION_ID,
|
|
210
|
+
DEFAULT_MMDB_NAME,
|
|
211
|
+
DEFAULT_OUTPUT_PATH,
|
|
212
|
+
buildBasicAuthHeader,
|
|
213
|
+
buildDownloadUrl,
|
|
214
|
+
extractMmdbFromTarGz,
|
|
215
|
+
fileExists,
|
|
216
|
+
needsDownload,
|
|
217
|
+
readMetadata,
|
|
218
|
+
resolveConfig,
|
|
219
|
+
updateGeoIpDatabase,
|
|
220
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const updater = require('./geoip-updater.cjs');
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_EDITION_ID = updater.DEFAULT_EDITION_ID;
|
|
10
|
+
export const DEFAULT_MMDB_NAME = updater.DEFAULT_MMDB_NAME;
|
|
11
|
+
export const DEFAULT_OUTPUT_PATH = updater.DEFAULT_OUTPUT_PATH;
|
|
12
|
+
export const buildBasicAuthHeader = updater.buildBasicAuthHeader;
|
|
13
|
+
export const buildDownloadUrl = updater.buildDownloadUrl;
|
|
14
|
+
export const extractMmdbFromTarGz = updater.extractMmdbFromTarGz;
|
|
15
|
+
export const fileExists = updater.fileExists;
|
|
16
|
+
export const needsDownload = updater.needsDownload;
|
|
17
|
+
export const readMetadata = updater.readMetadata;
|
|
18
|
+
export const resolveConfig = updater.resolveConfig;
|
|
19
|
+
export const updateGeoIpDatabase = updater.updateGeoIpDatabase;
|
|
20
|
+
|
|
21
|
+
function isMainModule() {
|
|
22
|
+
return process.argv[1] && import.meta.url === new URL(process.argv[1], 'file:').href;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (isMainModule()) {
|
|
26
|
+
updateGeoIpDatabase()
|
|
27
|
+
.then((result) => {
|
|
28
|
+
console.log(result.message);
|
|
29
|
+
console.log(`Path: ${result.outputPath}`);
|
|
30
|
+
if (result.lastModified) {
|
|
31
|
+
console.log(`Last-Modified: ${result.lastModified}`);
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
.catch((err) => {
|
|
35
|
+
console.error(`GeoIP update failed: ${err.message}`);
|
|
36
|
+
process.exitCode = 1;
|
|
37
|
+
});
|
|
38
|
+
}
|
package/strapi-admin.js
CHANGED
package/strapi-server.js
CHANGED