screenshotone-api-sdk 1.1.5 → 1.1.7

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.
@@ -4,7 +4,8 @@
4
4
  export declare class Client {
5
5
  private readonly accessKey;
6
6
  private readonly secretKey;
7
- constructor(accessKey: string, secretKey: string);
7
+ private readonly apiBaseUrl;
8
+ constructor(accessKey: string, secretKey: string, apiBaseUrl?: string);
8
9
  /**
9
10
  * Generates an URL that can be used to send GET requests for taking screenshots.
10
11
  *
@@ -50,7 +51,7 @@ export declare class Client {
50
51
  * @param options
51
52
  * @returns
52
53
  */
53
- store(options: AnimateOptions | TakeOptions, path: string, bucket?: string, acl?: "public-read" | "", storageClass?: string): Promise<{
54
+ store(options: AnimateOptions | TakeOptions, path: string, bucket?: string, acl?: "public-read" | "", storageClass?: string, accessKeyId?: string, secretAccessKey?: string): Promise<{
54
55
  bucket: string | null;
55
56
  key: string | null;
56
57
  }>;
@@ -311,6 +312,14 @@ export declare class TakeOptions {
311
312
  * You can override the default bucket you configured with storage_bucket=<bucket name>.
312
313
  */
313
314
  storageBucket(bucket: string): TakeOptions;
315
+ /**
316
+ * Access key ID. It overrides the one specified in the dashboard configuration.
317
+ */
318
+ storageAccessKeyId(accessKeyId: string): TakeOptions;
319
+ /**
320
+ * Secret access key. It overrides the one specified in the dashboard configuration.
321
+ */
322
+ storageSecretAccessKey(secretAccessKey: string): TakeOptions;
314
323
  /**
315
324
  * Storage class allows you to specify the object storage class.
316
325
  */
package/dist/main.js CHANGED
@@ -14,12 +14,13 @@ const API_ANIMATE_PATH = "/animate";
14
14
  * Represents an API client for the ScreenshotOne.com API.
15
15
  */
16
16
  class Client {
17
- constructor(accessKey, secretKey) {
17
+ constructor(accessKey, secretKey, apiBaseUrl) {
18
18
  if (!accessKey || !secretKey) {
19
19
  throw new Error("Both non-empty access and secret keys are required");
20
20
  }
21
21
  this.accessKey = accessKey;
22
22
  this.secretKey = secretKey;
23
+ this.apiBaseUrl = apiBaseUrl ? apiBaseUrl : API_BASE_URL;
23
24
  }
24
25
  /**
25
26
  * Generates an URL that can be used to send GET requests for taking screenshots.
@@ -33,7 +34,7 @@ class Client {
33
34
  const query = options.toQuery();
34
35
  query.append("access_key", this.accessKey);
35
36
  let queryString = query.toString();
36
- return `${API_BASE_URL}${API_TAKE_PATH}?${queryString}`;
37
+ return `${this.apiBaseUrl}${API_TAKE_PATH}?${queryString}`;
37
38
  }
38
39
  /**
39
40
  * Generates the link that can be publicly available, but make sure
@@ -48,7 +49,7 @@ class Client {
48
49
  let queryString = query.toString();
49
50
  const signature = await (0, signature_1.signQueryString)(queryString, this.secretKey);
50
51
  queryString += "&signature=" + signature;
51
- return `${API_BASE_URL}${API_TAKE_PATH}?${queryString}`;
52
+ return `${this.apiBaseUrl}${API_TAKE_PATH}?${queryString}`;
52
53
  }
53
54
  /**
54
55
  * Generates the link that can be publicly available, but make sure
@@ -63,7 +64,7 @@ class Client {
63
64
  let queryString = query.toString();
64
65
  const signature = await (0, signature_1.signQueryString)(queryString, this.secretKey);
65
66
  queryString += "&signature=" + signature;
66
- return `${API_BASE_URL}${API_ANIMATE_PATH}?${queryString}`;
67
+ return `${this.apiBaseUrl}${API_ANIMATE_PATH}?${queryString}`;
67
68
  }
68
69
  /**
69
70
  * Generates a screenshot and return the image blob.
@@ -111,7 +112,7 @@ class Client {
111
112
  * @param options
112
113
  * @returns
113
114
  */
114
- async store(options, path, bucket, acl, storageClass) {
115
+ async store(options, path, bucket, acl, storageClass, accessKeyId, secretAccessKey) {
115
116
  options.store(true).storagePath(path).responseType("empty");
116
117
  if (bucket) {
117
118
  options.storageBucket(bucket);
@@ -122,6 +123,12 @@ class Client {
122
123
  if (storageClass) {
123
124
  options.storageClass(storageClass);
124
125
  }
126
+ if (accessKeyId) {
127
+ options.storageAccessKeyId(accessKeyId);
128
+ }
129
+ if (secretAccessKey) {
130
+ options.storageSecretAccessKey(secretAccessKey);
131
+ }
125
132
  const url = options instanceof TakeOptions
126
133
  ? await this.generateSignedTakeURL(options)
127
134
  : await this.generateSignedAnimateURL(options);
@@ -569,6 +576,20 @@ class TakeOptions {
569
576
  this.put("storage_bucket", bucket);
570
577
  return this;
571
578
  }
579
+ /**
580
+ * Access key ID. It overrides the one specified in the dashboard configuration.
581
+ */
582
+ storageAccessKeyId(accessKeyId) {
583
+ this.put("storage_access_key_id", accessKeyId);
584
+ return this;
585
+ }
586
+ /**
587
+ * Secret access key. It overrides the one specified in the dashboard configuration.
588
+ */
589
+ storageSecretAccessKey(secretAccessKey) {
590
+ this.put("storage_secret_access_key", secretAccessKey);
591
+ return this;
592
+ }
572
593
  /**
573
594
  * Storage class allows you to specify the object storage class.
574
595
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "screenshotone-api-sdk",
3
3
  "homepage": "https://screenshotone.com",
4
- "version": "1.1.5",
4
+ "version": "1.1.7",
5
5
  "description": "Use ScreenshotOne.com API to generate screenshots of any website.",
6
6
  "repository": {
7
7
  "type": "git",
package/src/main.ts CHANGED
@@ -12,8 +12,9 @@ const API_ANIMATE_PATH = "/animate";
12
12
  export class Client {
13
13
  private readonly accessKey: string;
14
14
  private readonly secretKey: string;
15
+ private readonly apiBaseUrl: string;
15
16
 
16
- constructor(accessKey: string, secretKey: string) {
17
+ constructor(accessKey: string, secretKey: string, apiBaseUrl?: string) {
17
18
  if (!accessKey || !secretKey) {
18
19
  throw new Error(
19
20
  "Both non-empty access and secret keys are required"
@@ -22,6 +23,7 @@ export class Client {
22
23
 
23
24
  this.accessKey = accessKey;
24
25
  this.secretKey = secretKey;
26
+ this.apiBaseUrl = apiBaseUrl ? apiBaseUrl : API_BASE_URL;
25
27
  }
26
28
 
27
29
  /**
@@ -37,7 +39,7 @@ export class Client {
37
39
  query.append("access_key", this.accessKey);
38
40
  let queryString = query.toString();
39
41
 
40
- return `${API_BASE_URL}${API_TAKE_PATH}?${queryString}`;
42
+ return `${this.apiBaseUrl}${API_TAKE_PATH}?${queryString}`;
41
43
  }
42
44
 
43
45
  /**
@@ -55,7 +57,7 @@ export class Client {
55
57
  const signature = await signQueryString(queryString, this.secretKey);
56
58
  queryString += "&signature=" + signature;
57
59
 
58
- return `${API_BASE_URL}${API_TAKE_PATH}?${queryString}`;
60
+ return `${this.apiBaseUrl}${API_TAKE_PATH}?${queryString}`;
59
61
  }
60
62
 
61
63
  /**
@@ -73,7 +75,7 @@ export class Client {
73
75
  const signature = await signQueryString(queryString, this.secretKey);
74
76
  queryString += "&signature=" + signature;
75
77
 
76
- return `${API_BASE_URL}${API_ANIMATE_PATH}?${queryString}`;
78
+ return `${this.apiBaseUrl}${API_ANIMATE_PATH}?${queryString}`;
77
79
  }
78
80
 
79
81
  /**
@@ -139,7 +141,9 @@ export class Client {
139
141
  path: string,
140
142
  bucket?: string,
141
143
  acl?: "public-read" | "",
142
- storageClass?: string
144
+ storageClass?: string,
145
+ accessKeyId?: string,
146
+ secretAccessKey?: string
143
147
  ): Promise<{ bucket: string | null; key: string | null }> {
144
148
  options.store(true).storagePath(path).responseType("empty");
145
149
 
@@ -152,6 +156,12 @@ export class Client {
152
156
  if (storageClass) {
153
157
  options.storageClass(storageClass);
154
158
  }
159
+ if (accessKeyId) {
160
+ options.storageAccessKeyId(accessKeyId);
161
+ }
162
+ if (secretAccessKey) {
163
+ options.storageSecretAccessKey(secretAccessKey);
164
+ }
155
165
 
156
166
  const url =
157
167
  options instanceof TakeOptions
@@ -724,6 +734,24 @@ export class TakeOptions {
724
734
  return this;
725
735
  }
726
736
 
737
+ /**
738
+ * Access key ID. It overrides the one specified in the dashboard configuration.
739
+ */
740
+ storageAccessKeyId(accessKeyId: string): TakeOptions {
741
+ this.put("storage_access_key_id", accessKeyId);
742
+
743
+ return this;
744
+ }
745
+
746
+ /**
747
+ * Secret access key. It overrides the one specified in the dashboard configuration.
748
+ */
749
+ storageSecretAccessKey(secretAccessKey: string): TakeOptions {
750
+ this.put("storage_secret_access_key", secretAccessKey);
751
+
752
+ return this;
753
+ }
754
+
727
755
  /**
728
756
  * Storage class allows you to specify the object storage class.
729
757
  */
@@ -1194,7 +1222,7 @@ export class AnimateOptions {
1194
1222
  storageAccessKeyId(accessKeyId: string): AnimateOptions {
1195
1223
  this.put("storage_access_key_id", accessKeyId);
1196
1224
 
1197
- return this
1225
+ return this;
1198
1226
  }
1199
1227
 
1200
1228
  /**
@@ -1203,7 +1231,7 @@ export class AnimateOptions {
1203
1231
  storageSecretAccessKey(secretAccessKey: string): AnimateOptions {
1204
1232
  this.put("storage_secret_access_key", secretAccessKey);
1205
1233
 
1206
- return this
1234
+ return this;
1207
1235
  }
1208
1236
 
1209
1237
  /**