@ever-works/screenshotone-plugin 1.0.0 → 1.0.3
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/index.cjs +488 -0
- package/dist/index.d.cts +99 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +463 -0
- package/package.json +94 -81
- package/LICENSE +0 -661
- package/src/__tests__/screenshotone.plugin.spec.ts +0 -349
- package/src/index.ts +0 -2
- package/src/screenshotone.plugin.ts +0 -542
- package/tsconfig.json +0 -23
- package/tsup.config.ts +0 -12
- package/vitest.config.ts +0 -13
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var screenshotone = require('screenshotone-api-sdk');
|
|
6
|
+
var net = require('net');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var screenshotone__namespace = /*#__PURE__*/_interopNamespace(screenshotone);
|
|
27
|
+
|
|
28
|
+
// src/screenshotone.plugin.ts
|
|
29
|
+
function isSafeWebhookUrl(rawUrl) {
|
|
30
|
+
let url;
|
|
31
|
+
try {
|
|
32
|
+
url = new URL(rawUrl);
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
let host = url.hostname.toLowerCase();
|
|
40
|
+
if (host.startsWith("[") && host.endsWith("]")) {
|
|
41
|
+
host = host.slice(1, -1);
|
|
42
|
+
}
|
|
43
|
+
if (CLOUD_METADATA_HOSTNAMES.has(host)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const ipKind = net.isIP(host);
|
|
47
|
+
if (ipKind === 4 && isPrivateIPv4(host)) return false;
|
|
48
|
+
if (ipKind === 6 && isPrivateIPv6(host)) return false;
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
var CLOUD_METADATA_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
52
|
+
// GCP
|
|
53
|
+
"metadata.google.internal",
|
|
54
|
+
"metadata.goog",
|
|
55
|
+
// AWS
|
|
56
|
+
"instance-data",
|
|
57
|
+
"instance-data.ec2.internal",
|
|
58
|
+
// Azure
|
|
59
|
+
"metadata.azure.internal"
|
|
60
|
+
]);
|
|
61
|
+
function isPrivateIPv4(ip) {
|
|
62
|
+
const parts = ip.split(".").map((p) => Number(p));
|
|
63
|
+
if (parts.length !== 4 || parts.some((n) => Number.isNaN(n))) return false;
|
|
64
|
+
const [a, b] = parts;
|
|
65
|
+
if (a === 10) return true;
|
|
66
|
+
if (a === 127) return true;
|
|
67
|
+
if (a === 0) return true;
|
|
68
|
+
if (a === 169 && b === 254) return true;
|
|
69
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
70
|
+
if (a === 192 && b === 168) return true;
|
|
71
|
+
if (a === 192 && b === 0 && parts[2] === 0) return true;
|
|
72
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
73
|
+
if (a >= 224) return true;
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
function isPrivateIPv6(ip) {
|
|
77
|
+
const lower = ip.toLowerCase();
|
|
78
|
+
if (lower === "::1" || lower === "::") return true;
|
|
79
|
+
if (lower.startsWith("fc") || lower.startsWith("fd")) return true;
|
|
80
|
+
const firstHextet = lower.split(":", 1)[0];
|
|
81
|
+
if (/^[0-9a-f]{1,4}$/.test(firstHextet)) {
|
|
82
|
+
const group0 = parseInt(firstHextet, 16);
|
|
83
|
+
if ((group0 & 65472) === 65152) return true;
|
|
84
|
+
}
|
|
85
|
+
if (lower.startsWith("::ffff:")) {
|
|
86
|
+
const v4 = lower.slice("::ffff:".length);
|
|
87
|
+
if (net.isIP(v4) === 4) return isPrivateIPv4(v4);
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/screenshotone.plugin.ts
|
|
93
|
+
var ScreenshotOnePlugin = class {
|
|
94
|
+
constructor() {
|
|
95
|
+
// ============================================================================
|
|
96
|
+
// IPlugin Properties
|
|
97
|
+
// ============================================================================
|
|
98
|
+
this.id = "screenshotone";
|
|
99
|
+
this.name = "ScreenshotOne";
|
|
100
|
+
this.version = "1.0.0";
|
|
101
|
+
this.category = "screenshot";
|
|
102
|
+
this.capabilities = ["screenshot"];
|
|
103
|
+
/**
|
|
104
|
+
* Provider name for facade identification
|
|
105
|
+
*/
|
|
106
|
+
this.providerName = "ScreenshotOne";
|
|
107
|
+
/**
|
|
108
|
+
* Settings schema with environment variable fallback.
|
|
109
|
+
*
|
|
110
|
+
* The 'x-envVar' extension tells the PluginSettingsService to check
|
|
111
|
+
* the environment variable when no other setting is found.
|
|
112
|
+
*/
|
|
113
|
+
this.settingsSchema = {
|
|
114
|
+
type: "object",
|
|
115
|
+
properties: {
|
|
116
|
+
accessKey: {
|
|
117
|
+
type: "string",
|
|
118
|
+
title: "Access Key",
|
|
119
|
+
description: "Your ScreenshotOne access key. Get one at https://screenshotone.com",
|
|
120
|
+
// Security marker - encrypt and never return via API
|
|
121
|
+
"x-secret": true,
|
|
122
|
+
// Environment variable fallback
|
|
123
|
+
"x-envVar": "PLUGIN_SCREENSHOTONE_ACCESS_KEY",
|
|
124
|
+
"x-scope": "user"
|
|
125
|
+
},
|
|
126
|
+
secretKey: {
|
|
127
|
+
type: "string",
|
|
128
|
+
title: "Secret Key",
|
|
129
|
+
description: "Your ScreenshotOne secret key for signed URLs (recommended for security)",
|
|
130
|
+
// Security marker - encrypt and never return via API
|
|
131
|
+
"x-secret": true,
|
|
132
|
+
// Environment variable fallback
|
|
133
|
+
"x-envVar": "PLUGIN_SCREENSHOTONE_SECRET_KEY",
|
|
134
|
+
"x-scope": "user"
|
|
135
|
+
},
|
|
136
|
+
viewportWidth: {
|
|
137
|
+
type: "number",
|
|
138
|
+
title: "Viewport Width",
|
|
139
|
+
description: "Default viewport width in pixels",
|
|
140
|
+
default: 1280,
|
|
141
|
+
minimum: 320,
|
|
142
|
+
maximum: 3840,
|
|
143
|
+
"x-envVar": "PLUGIN_SCREENSHOTONE_VIEWPORT_WIDTH"
|
|
144
|
+
},
|
|
145
|
+
viewportHeight: {
|
|
146
|
+
type: "number",
|
|
147
|
+
title: "Viewport Height",
|
|
148
|
+
description: "Default viewport height in pixels",
|
|
149
|
+
default: 800,
|
|
150
|
+
minimum: 200,
|
|
151
|
+
maximum: 2160,
|
|
152
|
+
"x-envVar": "PLUGIN_SCREENSHOTONE_VIEWPORT_HEIGHT"
|
|
153
|
+
},
|
|
154
|
+
format: {
|
|
155
|
+
type: "string",
|
|
156
|
+
title: "Image Format",
|
|
157
|
+
description: "Default output image format",
|
|
158
|
+
enum: ["png", "jpg", "jpeg", "webp"],
|
|
159
|
+
default: "png",
|
|
160
|
+
"x-envVar": "PLUGIN_SCREENSHOTONE_FORMAT"
|
|
161
|
+
},
|
|
162
|
+
fullPage: {
|
|
163
|
+
type: "boolean",
|
|
164
|
+
title: "Full Page",
|
|
165
|
+
description: "Capture full page by default",
|
|
166
|
+
default: false
|
|
167
|
+
},
|
|
168
|
+
deviceScaleFactor: {
|
|
169
|
+
type: "number",
|
|
170
|
+
title: "Device Scale Factor",
|
|
171
|
+
description: "Device scale factor (1 = normal, 2 = retina)",
|
|
172
|
+
default: 1,
|
|
173
|
+
minimum: 0.5,
|
|
174
|
+
maximum: 3
|
|
175
|
+
},
|
|
176
|
+
blockAds: {
|
|
177
|
+
type: "boolean",
|
|
178
|
+
title: "Block Ads",
|
|
179
|
+
description: "Block ads when capturing screenshots",
|
|
180
|
+
default: true
|
|
181
|
+
},
|
|
182
|
+
blockTrackers: {
|
|
183
|
+
type: "boolean",
|
|
184
|
+
title: "Block Trackers",
|
|
185
|
+
description: "Block trackers when capturing screenshots",
|
|
186
|
+
default: true
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
required: ["accessKey"]
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Configuration mode: hybrid allows admin-level defaults with user overrides
|
|
193
|
+
*/
|
|
194
|
+
this.configurationMode = "hybrid";
|
|
195
|
+
}
|
|
196
|
+
// ============================================================================
|
|
197
|
+
// IScreenshotPlugin Interface
|
|
198
|
+
// ============================================================================
|
|
199
|
+
/**
|
|
200
|
+
* Capture a screenshot using ScreenshotOne API
|
|
201
|
+
*/
|
|
202
|
+
async capture(options) {
|
|
203
|
+
const settings = this.mergeSettings(options.settings);
|
|
204
|
+
if (!isSafeWebhookUrl(options.url)) {
|
|
205
|
+
return {
|
|
206
|
+
success: false,
|
|
207
|
+
error: `URL host is not safe to capture (SSRF guard blocked: ${options.url})`
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
try {
|
|
211
|
+
const client = this.createClient(settings);
|
|
212
|
+
const takeOptions = this.buildTakeOptions(options, settings);
|
|
213
|
+
const imageBlob = await client.take(takeOptions);
|
|
214
|
+
const arrayBuffer = await imageBlob.arrayBuffer();
|
|
215
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
216
|
+
const imageUrl = settings.secretKey ? await Promise.resolve(client.generateSignedTakeURL(takeOptions)) : await Promise.resolve(client.generateTakeURL(takeOptions));
|
|
217
|
+
return {
|
|
218
|
+
success: true,
|
|
219
|
+
imageBuffer: buffer,
|
|
220
|
+
imageBase64: buffer.toString("base64"),
|
|
221
|
+
imageUrl: String(imageUrl),
|
|
222
|
+
width: options.viewportWidth ?? settings.viewportWidth ?? 1280,
|
|
223
|
+
height: options.viewportHeight ?? settings.viewportHeight ?? 800,
|
|
224
|
+
fileSize: buffer.length
|
|
225
|
+
};
|
|
226
|
+
} catch (error) {
|
|
227
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
228
|
+
this.context?.logger.error(`ScreenshotOne capture failed: ${errorMessage}`);
|
|
229
|
+
return {
|
|
230
|
+
success: false,
|
|
231
|
+
error: errorMessage
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get screenshot URL without actually capturing
|
|
237
|
+
* Uses signed URLs when secret key is available
|
|
238
|
+
*/
|
|
239
|
+
async getScreenshotUrl(options) {
|
|
240
|
+
const settings = this.mergeSettings(options.settings);
|
|
241
|
+
if (!isSafeWebhookUrl(options.url)) {
|
|
242
|
+
this.context?.logger.error(
|
|
243
|
+
`ScreenshotOne URL generation blocked by SSRF guard for unsafe URL: ${options.url}`
|
|
244
|
+
);
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
const client = this.createClient(settings);
|
|
249
|
+
const takeOptions = this.buildTakeOptions(options, settings);
|
|
250
|
+
const url = settings.secretKey ? await Promise.resolve(client.generateSignedTakeURL(takeOptions)) : await Promise.resolve(client.generateTakeURL(takeOptions));
|
|
251
|
+
return String(url);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
this.context?.logger.error(
|
|
254
|
+
`ScreenshotOne URL generation failed: ${error instanceof Error ? error.message : String(error)}`
|
|
255
|
+
);
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Check if the service is available (API key configured)
|
|
261
|
+
*/
|
|
262
|
+
async isAvailable() {
|
|
263
|
+
if (!this.context) return false;
|
|
264
|
+
const settings = await this.context.getSettings();
|
|
265
|
+
return Boolean(settings?.accessKey);
|
|
266
|
+
}
|
|
267
|
+
async validateConnection(settings) {
|
|
268
|
+
const accessKey = settings.accessKey;
|
|
269
|
+
if (!accessKey) {
|
|
270
|
+
return { success: false, message: "ScreenshotOne access key is not configured." };
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
const resolvedSettings = this.mergeSettings(settings);
|
|
274
|
+
const client = this.createClient(resolvedSettings);
|
|
275
|
+
const testOptions = screenshotone__namespace.TakeOptions.url("https://example.com");
|
|
276
|
+
const url = resolvedSettings.secretKey ? await Promise.resolve(client.generateSignedTakeURL(testOptions)) : await Promise.resolve(client.generateTakeURL(testOptions));
|
|
277
|
+
const urlString = String(url);
|
|
278
|
+
if (urlString && urlString.includes("api.screenshotone.com")) {
|
|
279
|
+
return { success: true, message: "ScreenshotOne connection verified." };
|
|
280
|
+
}
|
|
281
|
+
return { success: false, message: "ScreenshotOne credentials appear invalid." };
|
|
282
|
+
} catch (error) {
|
|
283
|
+
return {
|
|
284
|
+
success: false,
|
|
285
|
+
message: `ScreenshotOne connection failed: ${error instanceof Error ? error.message : String(error)}`
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Validate API credentials by making a test request
|
|
291
|
+
*/
|
|
292
|
+
async validateCredentials() {
|
|
293
|
+
if (!this.context) {
|
|
294
|
+
return {
|
|
295
|
+
valid: false,
|
|
296
|
+
message: "Plugin not initialized"
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
const settings = await this.context.getSettings();
|
|
301
|
+
const resolvedSettings = this.mergeSettings(settings);
|
|
302
|
+
if (!resolvedSettings.accessKey) {
|
|
303
|
+
return {
|
|
304
|
+
valid: false,
|
|
305
|
+
message: "Access key is not configured"
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const client = this.createClient(resolvedSettings);
|
|
309
|
+
const testOptions = screenshotone__namespace.TakeOptions.url("https://example.com");
|
|
310
|
+
const url = resolvedSettings.secretKey ? await Promise.resolve(client.generateSignedTakeURL(testOptions)) : await Promise.resolve(client.generateTakeURL(testOptions));
|
|
311
|
+
const urlString = String(url);
|
|
312
|
+
if (urlString && urlString.includes("api.screenshotone.com")) {
|
|
313
|
+
return {
|
|
314
|
+
valid: true,
|
|
315
|
+
message: "Credentials are valid"
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
valid: false,
|
|
320
|
+
message: "Invalid credentials format"
|
|
321
|
+
};
|
|
322
|
+
} catch (error) {
|
|
323
|
+
return {
|
|
324
|
+
valid: false,
|
|
325
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Get supported screenshot formats
|
|
331
|
+
*/
|
|
332
|
+
getSupportedFormats() {
|
|
333
|
+
return ["png", "jpg", "jpeg", "webp"];
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Get maximum viewport dimensions
|
|
337
|
+
*/
|
|
338
|
+
getMaxDimensions() {
|
|
339
|
+
return { width: 3840, height: 2160 };
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* EW-602 — ScreenshotOne charges roughly $0.005 per screenshot on
|
|
343
|
+
* the developer plan (rounds to 1 cent for budget tracking). Free
|
|
344
|
+
* tier covers 100 shots/month; beyond that the platform attributes
|
|
345
|
+
* the per-call cost to PluginUsageEvent on every successful capture.
|
|
346
|
+
*/
|
|
347
|
+
getPricing() {
|
|
348
|
+
return {
|
|
349
|
+
costPerCallCents: 1,
|
|
350
|
+
currency: "usd",
|
|
351
|
+
note: "Approx. $0.005/screenshot (free tier: 100/month)."
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
// ============================================================================
|
|
355
|
+
// Private Helper Methods
|
|
356
|
+
// ============================================================================
|
|
357
|
+
/**
|
|
358
|
+
* Create a ScreenshotOne client with the resolved settings
|
|
359
|
+
*/
|
|
360
|
+
createClient(settings) {
|
|
361
|
+
const accessKey = settings.accessKey;
|
|
362
|
+
const secretKey = settings.secretKey ?? "";
|
|
363
|
+
if (!accessKey) {
|
|
364
|
+
throw new Error(
|
|
365
|
+
"ScreenshotOne access key not configured. Set it in plugin settings or via PLUGIN_SCREENSHOTONE_ACCESS_KEY environment variable."
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
return new screenshotone__namespace.Client(accessKey, secretKey);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Build TakeOptions from screenshot options and settings
|
|
372
|
+
*/
|
|
373
|
+
buildTakeOptions(options, settings) {
|
|
374
|
+
const takeOptions = screenshotone__namespace.TakeOptions.url(options.url);
|
|
375
|
+
const viewportWidth = options.viewportWidth ?? settings.viewportWidth ?? 1280;
|
|
376
|
+
const viewportHeight = options.viewportHeight ?? settings.viewportHeight ?? 800;
|
|
377
|
+
takeOptions.viewportWidth(viewportWidth);
|
|
378
|
+
takeOptions.viewportHeight(viewportHeight);
|
|
379
|
+
const format = options.format ?? settings.format ?? "png";
|
|
380
|
+
takeOptions.format(format);
|
|
381
|
+
const fullPage = options.fullPage ?? settings.fullPage ?? false;
|
|
382
|
+
takeOptions.fullPage(fullPage);
|
|
383
|
+
const deviceScaleFactor = options.deviceScaleFactor ?? settings.deviceScaleFactor ?? 1;
|
|
384
|
+
takeOptions.deviceScaleFactor(deviceScaleFactor);
|
|
385
|
+
const blockAds = options.blockAds ?? settings.blockAds ?? true;
|
|
386
|
+
const blockTrackers = options.blockTrackers ?? settings.blockTrackers ?? true;
|
|
387
|
+
takeOptions.blockAds(blockAds);
|
|
388
|
+
takeOptions.blockTrackers(blockTrackers);
|
|
389
|
+
if (options.blockCookieBanners) {
|
|
390
|
+
takeOptions.blockCookieBanners(true);
|
|
391
|
+
}
|
|
392
|
+
if (options.delay !== void 0) {
|
|
393
|
+
takeOptions.delay(options.delay / 1e3);
|
|
394
|
+
}
|
|
395
|
+
if (options.cache) {
|
|
396
|
+
takeOptions.cache(true);
|
|
397
|
+
if (options.cacheTtl !== void 0) {
|
|
398
|
+
takeOptions.cacheTtl(options.cacheTtl);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (options.waitForSelector) {
|
|
402
|
+
takeOptions.selector(options.waitForSelector);
|
|
403
|
+
}
|
|
404
|
+
if (options.userAgent) {
|
|
405
|
+
takeOptions.userAgent(options.userAgent);
|
|
406
|
+
}
|
|
407
|
+
return takeOptions;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Merge settings with defaults
|
|
411
|
+
*/
|
|
412
|
+
mergeSettings(settings) {
|
|
413
|
+
return {
|
|
414
|
+
accessKey: settings?.accessKey,
|
|
415
|
+
secretKey: settings?.secretKey,
|
|
416
|
+
viewportWidth: settings?.viewportWidth ?? 1280,
|
|
417
|
+
viewportHeight: settings?.viewportHeight ?? 800,
|
|
418
|
+
format: settings?.format ?? "png",
|
|
419
|
+
fullPage: settings?.fullPage ?? false,
|
|
420
|
+
deviceScaleFactor: settings?.deviceScaleFactor ?? 1,
|
|
421
|
+
blockAds: settings?.blockAds ?? true,
|
|
422
|
+
blockTrackers: settings?.blockTrackers ?? true
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
// ============================================================================
|
|
426
|
+
// IPlugin Lifecycle
|
|
427
|
+
// ============================================================================
|
|
428
|
+
async onLoad(context) {
|
|
429
|
+
this.context = context;
|
|
430
|
+
context.logger.log("ScreenshotOne Plugin loaded");
|
|
431
|
+
}
|
|
432
|
+
async onUnload() {
|
|
433
|
+
this.context = void 0;
|
|
434
|
+
}
|
|
435
|
+
async healthCheck() {
|
|
436
|
+
return {
|
|
437
|
+
status: "healthy",
|
|
438
|
+
message: "ScreenshotOne plugin is ready (API key required for operations)",
|
|
439
|
+
checkedAt: Date.now()
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
getManifest() {
|
|
443
|
+
return {
|
|
444
|
+
id: this.id,
|
|
445
|
+
name: this.name,
|
|
446
|
+
version: this.version,
|
|
447
|
+
description: "Automatically capture website screenshots for your work items",
|
|
448
|
+
category: this.category,
|
|
449
|
+
capabilities: [...this.capabilities],
|
|
450
|
+
author: { name: "Ever Works Team" },
|
|
451
|
+
license: "AGPL-3.0",
|
|
452
|
+
builtIn: false,
|
|
453
|
+
systemPlugin: false,
|
|
454
|
+
readme: [
|
|
455
|
+
"## What does ScreenshotOne do?",
|
|
456
|
+
"",
|
|
457
|
+
"ScreenshotOne is a screenshot capture API. When work items include source URLs, this plugin automatically generates preview images by capturing a screenshot of each page.",
|
|
458
|
+
"",
|
|
459
|
+
"## Why use it?",
|
|
460
|
+
"",
|
|
461
|
+
"- **Automated capture** \u2014 preview images are generated for each work item without manual effort",
|
|
462
|
+
"- **Consistent output** \u2014 every screenshot uses the same viewport size, format, and rendering settings",
|
|
463
|
+
"- **Ad and tracker blocking** \u2014 captures clean screenshots free of ads and cookie banners",
|
|
464
|
+
"- **Multiple formats** \u2014 supports PNG, JPG, and WebP output with configurable resolution",
|
|
465
|
+
"",
|
|
466
|
+
"## How it works in Ever Works",
|
|
467
|
+
"",
|
|
468
|
+
"During work generation, the screenshot facade sends capture requests to ScreenshotOne for items that have a source URL. The resulting images are used as item preview thumbnails. You can configure viewport dimensions, image format, device scale factor, and caching behavior.",
|
|
469
|
+
"",
|
|
470
|
+
"## Getting started",
|
|
471
|
+
"",
|
|
472
|
+
"1. Sign up at [screenshotone.com](https://screenshotone.com)",
|
|
473
|
+
"2. Copy your access key and optional secret key (for signed URLs)",
|
|
474
|
+
"3. Enable the ScreenshotOne plugin on this page",
|
|
475
|
+
"4. Enter your credentials in the settings below"
|
|
476
|
+
].join("\n"),
|
|
477
|
+
homepage: "https://screenshotone.com",
|
|
478
|
+
icon: {
|
|
479
|
+
type: "lucide",
|
|
480
|
+
value: "Camera",
|
|
481
|
+
backgroundColor: "#4f46e5"
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
exports.ScreenshotOnePlugin = ScreenshotOnePlugin;
|
|
488
|
+
exports.default = ScreenshotOnePlugin;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { IPlugin, IScreenshotPlugin, PluginCategory, JsonSchema, ScreenshotOptions, ScreenshotResult, ConnectionValidationResult, ScreenshotValidationResult, ScreenshotFormat, PluginContext, PluginHealthCheck, PluginManifest } from '@ever-works/plugin';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ScreenshotOne Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides screenshot capture capabilities using the ScreenshotOne API service.
|
|
7
|
+
* Supports configurable viewport sizes, formats, and advanced options like ad blocking.
|
|
8
|
+
*
|
|
9
|
+
* Settings Resolution:
|
|
10
|
+
* The API keys are resolved through the 4-level hierarchy:
|
|
11
|
+
* 1. Work settings (highest priority)
|
|
12
|
+
* 2. User settings
|
|
13
|
+
* 3. Admin settings
|
|
14
|
+
* 4. Environment variables: PLUGIN_SCREENSHOTONE_ACCESS_KEY, PLUGIN_SCREENSHOTONE_SECRET_KEY
|
|
15
|
+
* 5. Not configured (plugin unavailable)
|
|
16
|
+
*
|
|
17
|
+
* Configuration mode: hybrid - allows admin-level defaults with user/work overrides.
|
|
18
|
+
*/
|
|
19
|
+
declare class ScreenshotOnePlugin implements IPlugin, IScreenshotPlugin {
|
|
20
|
+
readonly id = "screenshotone";
|
|
21
|
+
readonly name = "ScreenshotOne";
|
|
22
|
+
readonly version = "1.0.0";
|
|
23
|
+
readonly category: PluginCategory;
|
|
24
|
+
readonly capabilities: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* Provider name for facade identification
|
|
27
|
+
*/
|
|
28
|
+
readonly providerName = "ScreenshotOne";
|
|
29
|
+
/**
|
|
30
|
+
* Settings schema with environment variable fallback.
|
|
31
|
+
*
|
|
32
|
+
* The 'x-envVar' extension tells the PluginSettingsService to check
|
|
33
|
+
* the environment variable when no other setting is found.
|
|
34
|
+
*/
|
|
35
|
+
readonly settingsSchema: JsonSchema;
|
|
36
|
+
/**
|
|
37
|
+
* Configuration mode: hybrid allows admin-level defaults with user overrides
|
|
38
|
+
*/
|
|
39
|
+
readonly configurationMode: 'admin-only' | 'user-required' | 'hybrid';
|
|
40
|
+
private context?;
|
|
41
|
+
/**
|
|
42
|
+
* Capture a screenshot using ScreenshotOne API
|
|
43
|
+
*/
|
|
44
|
+
capture(options: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Get screenshot URL without actually capturing
|
|
47
|
+
* Uses signed URLs when secret key is available
|
|
48
|
+
*/
|
|
49
|
+
getScreenshotUrl(options: ScreenshotOptions): Promise<string | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Check if the service is available (API key configured)
|
|
52
|
+
*/
|
|
53
|
+
isAvailable(): Promise<boolean>;
|
|
54
|
+
validateConnection(settings: Record<string, unknown>): Promise<ConnectionValidationResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Validate API credentials by making a test request
|
|
57
|
+
*/
|
|
58
|
+
validateCredentials(): Promise<ScreenshotValidationResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Get supported screenshot formats
|
|
61
|
+
*/
|
|
62
|
+
getSupportedFormats(): readonly ScreenshotFormat[];
|
|
63
|
+
/**
|
|
64
|
+
* Get maximum viewport dimensions
|
|
65
|
+
*/
|
|
66
|
+
getMaxDimensions(): {
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* EW-602 — ScreenshotOne charges roughly $0.005 per screenshot on
|
|
72
|
+
* the developer plan (rounds to 1 cent for budget tracking). Free
|
|
73
|
+
* tier covers 100 shots/month; beyond that the platform attributes
|
|
74
|
+
* the per-call cost to PluginUsageEvent on every successful capture.
|
|
75
|
+
*/
|
|
76
|
+
getPricing(): {
|
|
77
|
+
costPerCallCents: number;
|
|
78
|
+
currency: string;
|
|
79
|
+
note: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Create a ScreenshotOne client with the resolved settings
|
|
83
|
+
*/
|
|
84
|
+
private createClient;
|
|
85
|
+
/**
|
|
86
|
+
* Build TakeOptions from screenshot options and settings
|
|
87
|
+
*/
|
|
88
|
+
private buildTakeOptions;
|
|
89
|
+
/**
|
|
90
|
+
* Merge settings with defaults
|
|
91
|
+
*/
|
|
92
|
+
private mergeSettings;
|
|
93
|
+
onLoad(context: PluginContext): Promise<void>;
|
|
94
|
+
onUnload(): Promise<void>;
|
|
95
|
+
healthCheck(): Promise<PluginHealthCheck>;
|
|
96
|
+
getManifest(): PluginManifest;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { ScreenshotOnePlugin, ScreenshotOnePlugin as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { IPlugin, IScreenshotPlugin, PluginCategory, JsonSchema, ScreenshotOptions, ScreenshotResult, ConnectionValidationResult, ScreenshotValidationResult, ScreenshotFormat, PluginContext, PluginHealthCheck, PluginManifest } from '@ever-works/plugin';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ScreenshotOne Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides screenshot capture capabilities using the ScreenshotOne API service.
|
|
7
|
+
* Supports configurable viewport sizes, formats, and advanced options like ad blocking.
|
|
8
|
+
*
|
|
9
|
+
* Settings Resolution:
|
|
10
|
+
* The API keys are resolved through the 4-level hierarchy:
|
|
11
|
+
* 1. Work settings (highest priority)
|
|
12
|
+
* 2. User settings
|
|
13
|
+
* 3. Admin settings
|
|
14
|
+
* 4. Environment variables: PLUGIN_SCREENSHOTONE_ACCESS_KEY, PLUGIN_SCREENSHOTONE_SECRET_KEY
|
|
15
|
+
* 5. Not configured (plugin unavailable)
|
|
16
|
+
*
|
|
17
|
+
* Configuration mode: hybrid - allows admin-level defaults with user/work overrides.
|
|
18
|
+
*/
|
|
19
|
+
declare class ScreenshotOnePlugin implements IPlugin, IScreenshotPlugin {
|
|
20
|
+
readonly id = "screenshotone";
|
|
21
|
+
readonly name = "ScreenshotOne";
|
|
22
|
+
readonly version = "1.0.0";
|
|
23
|
+
readonly category: PluginCategory;
|
|
24
|
+
readonly capabilities: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* Provider name for facade identification
|
|
27
|
+
*/
|
|
28
|
+
readonly providerName = "ScreenshotOne";
|
|
29
|
+
/**
|
|
30
|
+
* Settings schema with environment variable fallback.
|
|
31
|
+
*
|
|
32
|
+
* The 'x-envVar' extension tells the PluginSettingsService to check
|
|
33
|
+
* the environment variable when no other setting is found.
|
|
34
|
+
*/
|
|
35
|
+
readonly settingsSchema: JsonSchema;
|
|
36
|
+
/**
|
|
37
|
+
* Configuration mode: hybrid allows admin-level defaults with user overrides
|
|
38
|
+
*/
|
|
39
|
+
readonly configurationMode: 'admin-only' | 'user-required' | 'hybrid';
|
|
40
|
+
private context?;
|
|
41
|
+
/**
|
|
42
|
+
* Capture a screenshot using ScreenshotOne API
|
|
43
|
+
*/
|
|
44
|
+
capture(options: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Get screenshot URL without actually capturing
|
|
47
|
+
* Uses signed URLs when secret key is available
|
|
48
|
+
*/
|
|
49
|
+
getScreenshotUrl(options: ScreenshotOptions): Promise<string | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Check if the service is available (API key configured)
|
|
52
|
+
*/
|
|
53
|
+
isAvailable(): Promise<boolean>;
|
|
54
|
+
validateConnection(settings: Record<string, unknown>): Promise<ConnectionValidationResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Validate API credentials by making a test request
|
|
57
|
+
*/
|
|
58
|
+
validateCredentials(): Promise<ScreenshotValidationResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Get supported screenshot formats
|
|
61
|
+
*/
|
|
62
|
+
getSupportedFormats(): readonly ScreenshotFormat[];
|
|
63
|
+
/**
|
|
64
|
+
* Get maximum viewport dimensions
|
|
65
|
+
*/
|
|
66
|
+
getMaxDimensions(): {
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* EW-602 — ScreenshotOne charges roughly $0.005 per screenshot on
|
|
72
|
+
* the developer plan (rounds to 1 cent for budget tracking). Free
|
|
73
|
+
* tier covers 100 shots/month; beyond that the platform attributes
|
|
74
|
+
* the per-call cost to PluginUsageEvent on every successful capture.
|
|
75
|
+
*/
|
|
76
|
+
getPricing(): {
|
|
77
|
+
costPerCallCents: number;
|
|
78
|
+
currency: string;
|
|
79
|
+
note: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Create a ScreenshotOne client with the resolved settings
|
|
83
|
+
*/
|
|
84
|
+
private createClient;
|
|
85
|
+
/**
|
|
86
|
+
* Build TakeOptions from screenshot options and settings
|
|
87
|
+
*/
|
|
88
|
+
private buildTakeOptions;
|
|
89
|
+
/**
|
|
90
|
+
* Merge settings with defaults
|
|
91
|
+
*/
|
|
92
|
+
private mergeSettings;
|
|
93
|
+
onLoad(context: PluginContext): Promise<void>;
|
|
94
|
+
onUnload(): Promise<void>;
|
|
95
|
+
healthCheck(): Promise<PluginHealthCheck>;
|
|
96
|
+
getManifest(): PluginManifest;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { ScreenshotOnePlugin, ScreenshotOnePlugin as default };
|