grabzit 3.2.1 → 3.2.2

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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NDVhNGE1NWE2YmM0MjE5ZWI3MzA3YzlmMGU3NzAzYTM0MjRhMzA4Mw==
5
- data.tar.gz: !binary |-
6
- ZGVkMDlmZTNkODUyNjI4OWI0YzdiZGNmMDIyYjhkMWFmODU3MDg1ZA==
2
+ SHA1:
3
+ metadata.gz: a2fab032ddbf0b70c9d7c235f51385c7c8d74740
4
+ data.tar.gz: a85040b9ffcd1bf88aa4c6949cb363128d9f163f
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YTgwY2U4NzgzZTEwNTg4Mjg5ZmI2NTI3YzViZjEzYjg5MmRhMGEwOTFiNjQz
10
- NjZkMWJkZTY5YmUyZjhmNDM0NmRiNGRhMzZjOWRmMmUxYWEzN2IzMGQwODQ2
11
- ZjgzZmQ5NWY5MWQ0Y2RlM2I4ZDIwNDZmMmY0ZjQxZTQ4M2JkM2M=
12
- data.tar.gz: !binary |-
13
- MzEwYTIwZGI3YjA3ZmZhZDAzMDRhZWZmMWNiNWE1MTkxMzBkOGU2MmEyY2Nl
14
- NTJlMGJkYTk2NDA3MGYxYjE2NmMyZTc4ODAyYTAyNDA2MTE0NjdkNjZiOTdj
15
- ZTA5MmNiNmNlZDY1OWFiYWMwYWM0NDA0MjM2NmM1ZWRkZTY2ZmU=
6
+ metadata.gz: b74fd192d70be252a149e0056c2169eda80a6e24ef4bf7f52606e88a8e3243aeb29a4d5ca770f4c5720710b8dc4a9c8ea455a3b7745f3043e23c437257049e3d
7
+ data.tar.gz: 625c1b571df5b2f8bac75616c6ba13a61599075992d8b31960e6ab01d9b0e463657e6cf04234d5945a821d0b1075bf85a25a444d825629b3da858493982796f9
@@ -165,7 +165,7 @@ module GrabzIt
165
165
  GrabzIt::Utility.nil_float_check(@framesPerSecond)+"|"+GrabzIt::Utility.nil_float_check(@speed)+"|"+GrabzIt::Utility.nil_int_check(@duration)+
166
166
  "|"+GrabzIt::Utility.nil_int_check(@repeat)+"|"+GrabzIt::Utility.b_to_str(@reverse)+"|"+GrabzIt::Utility.nil_int_check(@start)+
167
167
  "|"+GrabzIt::Utility.nil_check(@customWaterMarkId)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+
168
- "|"+GrabzIt::Utility.nil_check(@exportURL)
168
+ "|"+GrabzIt::Utility.nil_check(@exportURL)+"|"+GrabzIt::Utility.nil_check(@encryptionKey)
169
169
  end
170
170
 
171
171
  # @!visibility private
@@ -7,6 +7,7 @@ module GrabzIt
7
7
  @customId = nil
8
8
  @country = nil
9
9
  @exportURL = nil
10
+ @encryptionKey = nil
10
11
  @delay = nil
11
12
  end
12
13
 
@@ -31,7 +32,7 @@ module GrabzIt
31
32
  # Set the country the capture should be created from: Default = "", Singapore = "SG", UK = "UK", US = "US".
32
33
  #
33
34
  # @param value [String] the country to use
34
- # @return [void]
35
+ # @return [void]
35
36
  def country(value)
36
37
  @country = value
37
38
  end
@@ -41,14 +42,27 @@ module GrabzIt
41
42
  @exportURL
42
43
  end
43
44
 
44
- # Set the export URL that should be used to transfer the capture to a third party location
45
+ # Set the export URL that should be used to transfer the capture to a third party location.
45
46
  #
46
47
  # @param value [String] export URL to use
47
- # @return [void]
48
+ # @return [void]
48
49
  def exportURL(value)
49
50
  @exportURL = value
50
51
  end
51
52
 
53
+ # @return [String] the encryption key that will be used to encrypt your capture.
54
+ def encryptionKey
55
+ @encryptionKey
56
+ end
57
+
58
+ # Set the encryption key that will be used to encrypt your capture.
59
+ #
60
+ # @param value [String] encryption key to use
61
+ # @return [void]
62
+ def encryptionKey(value)
63
+ @encryptionKey = value
64
+ end
65
+
52
66
  # @!visibility private
53
67
  def startDelay
54
68
  if @delay == nil
@@ -65,6 +79,7 @@ module GrabzIt
65
79
  params['customid'] = GrabzIt::Utility.nil_check(@customId)
66
80
  params['callback'] = GrabzIt::Utility.nil_check(callBackURL)
67
81
  params['export'] = GrabzIt::Utility.nil_check(@exportURL)
82
+ params['encryption'] = GrabzIt::Utility.nil_check(@encryptionKey)
68
83
  params['sig'] = sig
69
84
  params[dataName] = GrabzIt::Utility.nil_check(dataValue)
70
85
 
@@ -5,7 +5,9 @@ module GrabzIt
5
5
  require 'digest/md5'
6
6
  require 'net/http'
7
7
  require 'rexml/document'
8
+ require 'base64'
8
9
  require 'cgi'
10
+ require 'openssl'
9
11
  require 'uri'
10
12
  require File.join(File.dirname(__FILE__), 'utility')
11
13
  require File.join(File.dirname(__FILE__), 'screenshotstatus')
@@ -15,7 +17,8 @@ module GrabzIt
15
17
  require File.join(File.dirname(__FILE__), 'animationoptions')
16
18
  require File.join(File.dirname(__FILE__), 'imageoptions')
17
19
  require File.join(File.dirname(__FILE__), 'tableoptions')
18
- require File.join(File.dirname(__FILE__), 'pdfoptions')
20
+ require File.join(File.dirname(__FILE__), 'pdfoptions')
21
+ require File.join(File.dirname(__FILE__), 'docxoptions')
19
22
 
20
23
  # This client provides access to the GrabzIt web services
21
24
  # This API allows you to take screenshot of websites for free and convert them into images, PDF's and tables.
@@ -107,7 +110,7 @@ module GrabzIt
107
110
  # @param options [ImageOptions, nil] a instance of the ImageOptions class that defines any special options to use when creating the image
108
111
  # @return [void]
109
112
  def file_to_image(path, options = nil)
110
- html_to_image(read_html_file(path), options)
113
+ html_to_image(read_file(path), options)
111
114
  end
112
115
 
113
116
  # This method specifies the URL that the HTML tables should be extracted from
@@ -146,7 +149,7 @@ module GrabzIt
146
149
  # @param options [TableOptions, nil] a instance of the TableOptions class that defines any special options to use when converting the HTML table
147
150
  # @return [void]
148
151
  def file_to_table(path, options = nil)
149
- html_to_table(read_html_file(path), options)
152
+ html_to_table(read_file(path), options)
150
153
  end
151
154
 
152
155
  # This method specifies the URL that should be converted into a PDF
@@ -185,7 +188,7 @@ module GrabzIt
185
188
  # @param options [PDFOptions, nil] a instance of the PDFOptions class that defines any special options to use when creating the PDF
186
189
  # @return [void]
187
190
  def file_to_pdf(path, options = nil)
188
- html_to_pdf(read_html_file(path), options)
191
+ html_to_pdf(read_file(path), options)
189
192
  end
190
193
 
191
194
  # This method specifies the URL that should be converted into a DOCX
@@ -224,7 +227,7 @@ module GrabzIt
224
227
  # @param options [DOCXOptions, nil] a instance of the DOCXOptions class that defines any special options to use when creating the DOCX
225
228
  # @return [void]
226
229
  def file_to_docx(path, options = nil)
227
- html_to_docx(read_html_file(path), options)
230
+ html_to_docx(read_file(path), options)
228
231
  end
229
232
 
230
233
  # Calls the GrabzIt web service to take the screenshot
@@ -296,7 +299,7 @@ module GrabzIt
296
299
 
297
300
  screenshot = File.new(saveToFile, "wb")
298
301
  screenshot.write(result)
299
- screenshot.close
302
+ screenshot.close
300
303
 
301
304
  break
302
305
  end
@@ -515,6 +518,44 @@ module GrabzIt
515
518
  @protocol = 'http'
516
519
  end
517
520
  end
521
+
522
+ # This method creates a cryptographically secure encryption key to pass to the encryption key parameter.
523
+ #
524
+ # @return [String] a encryption key
525
+ def create_encryption_key()
526
+ Base64.strict_encode64(OpenSSL::Random.random_bytes(32));
527
+ end
528
+
529
+ # This method will decrypt a encrypted capture file, using the key you passed to the encryption key parameter.
530
+ #
531
+ # @param path [String] the path of the encrypted capture
532
+ # @param key [String] the encryption key
533
+ def decrypt_file(path, key)
534
+ data = read_file(path)
535
+ decryptedFile = File.new(path, "wb")
536
+ decryptedFile.write(decrypt(data, key))
537
+ decryptedFile.close
538
+ end
539
+
540
+ # This method will decrypt a encrypted capture, using the key you passed to the encryption key parameter.
541
+ #
542
+ # @param path [String] the encrypted bytes
543
+ # @param key [String] the encryption key
544
+ # @return [Array<Byte>] an array of decrypted bytes
545
+ def decrypt(data, key)
546
+ if data == nil
547
+ return nil
548
+ end
549
+ iv = data[0..15]
550
+ payload = data[16..-1]
551
+ cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
552
+ cipher.padding = 0
553
+ cipher.key = Base64.strict_decode64(key);
554
+ cipher.iv = iv
555
+ decrypted = cipher.update(payload);
556
+ decrypted << cipher.final();
557
+ return decrypted
558
+ end
518
559
 
519
560
  private
520
561
  def get_watermarks(identifier = nil)
@@ -568,7 +609,7 @@ module GrabzIt
568
609
 
569
610
  private
570
611
  def check_for_exception(doc)
571
- if (doc == nil)
612
+ if doc == nil
572
613
  return
573
614
  end
574
615
 
@@ -586,13 +627,13 @@ module GrabzIt
586
627
  end
587
628
 
588
629
  private
589
- def read_html_file(path)
630
+ def read_file(path)
590
631
  if !File.file?(path)
591
632
  raise "File: " + path + " does not exist"
592
633
  end
593
634
 
594
635
  file = File.open(path, "rb")
595
- return file.read
636
+ return file.read
596
637
  end
597
638
 
598
639
  private
@@ -236,7 +236,7 @@ module GrabzIt
236
236
  GrabzIt::Utility.b_to_str(@includeImages)+"|"+GrabzIt::Utility.b_to_str(@includeLinks)+"|"+
237
237
  GrabzIt::Utility.nil_check(@title)+"|"+GrabzIt::Utility.nil_int_check(@marginTop)+"|"+GrabzIt::Utility.nil_int_check(@marginLeft)+
238
238
  "|"+GrabzIt::Utility.nil_int_check(@marginBottom)+"|"+GrabzIt::Utility.nil_int_check(@marginRight)+"|"+GrabzIt::Utility.nil_int_check(@delay)+"|"+
239
- GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@hideElement)+"|"+GrabzIt::Utility.nil_check(@exportURL)+"|"+GrabzIt::Utility.nil_check(@waitForElement)
239
+ GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@hideElement)+"|"+GrabzIt::Utility.nil_check(@exportURL)+"|"+GrabzIt::Utility.nil_check(@waitForElement)+"|"+GrabzIt::Utility.nil_check(@encryptionKey)
240
240
  end
241
241
 
242
242
  # @!visibility private
@@ -67,6 +67,7 @@ module GrabzIt
67
67
  PARAMETER_INVALID_EXPORT_URL = 168
68
68
  PARAMETER_INVALID_WAIT_FOR_VALUE = 169
69
69
  PARAMETER_INVALID_TRANSPARENT_VALUE = 170
70
+ PARAMETER_INVALID_ENCRYPTION_KEY = 171
70
71
  NETWORK_SERVER_OFFLINE = 200
71
72
  NETWORK_GENERAL_ERROR = 201
72
73
  NETWORK_DDOS_ATTACK = 202
@@ -204,7 +204,7 @@ module GrabzIt
204
204
  return applicationSecret+"|"+ urlParam + callBackURLParam +
205
205
  "|"+GrabzIt::Utility.nil_check(@format)+"|"+GrabzIt::Utility.nil_int_check(@height)+"|"+GrabzIt::Utility.nil_int_check(@width)+"|"+GrabzIt::Utility.nil_int_check(@browserHeight)+
206
206
  "|"+GrabzIt::Utility.nil_int_check(@browserWidth)+"|"+GrabzIt::Utility.nil_check(@customId)+"|"+GrabzIt::Utility.nil_int_check(@delay)+"|"+GrabzIt::Utility.nil_check(@targetElement)+
207
- "|"+GrabzIt::Utility.nil_check(@customWaterMarkId)+"|"+GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@hideElement)+"|"+GrabzIt::Utility.nil_check(@exportURL)+"|"+GrabzIt::Utility.nil_check(@waitForElement)+"|"+GrabzIt::Utility.b_to_str(@transparent)
207
+ "|"+GrabzIt::Utility.nil_check(@customWaterMarkId)+"|"+GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@hideElement)+"|"+GrabzIt::Utility.nil_check(@exportURL)+"|"+GrabzIt::Utility.nil_check(@waitForElement)+"|"+GrabzIt::Utility.b_to_str(@transparent)+"|"+GrabzIt::Utility.nil_check(@encryptionKey)
208
208
  end
209
209
 
210
210
  # @!visibility private
@@ -292,7 +292,7 @@ module GrabzIt
292
292
  GrabzIt::Utility.nil_check(@customWaterMarkId)+"|"+GrabzIt::Utility.b_to_str(@includeLinks)+"|"+GrabzIt::Utility.b_to_str(@includeOutline)+"|"+
293
293
  GrabzIt::Utility.nil_check(@title)+"|"+GrabzIt::Utility.nil_check(@coverURL)+"|"+GrabzIt::Utility.nil_int_check(@marginTop)+"|"+GrabzIt::Utility.nil_int_check(@marginLeft)+
294
294
  "|"+GrabzIt::Utility.nil_int_check(@marginBottom)+"|"+GrabzIt::Utility.nil_int_check(@marginRight)+"|"+GrabzIt::Utility.nil_int_check(@delay)+"|"+
295
- GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@templateId)+"|"+GrabzIt::Utility.nil_check(@hideElement)+"|"+GrabzIt::Utility.nil_check(@targetElement)+"|"+GrabzIt::Utility.nil_check(@exportURL)+"|"+GrabzIt::Utility.nil_check(@waitForElement)
295
+ GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@templateId)+"|"+GrabzIt::Utility.nil_check(@hideElement)+"|"+GrabzIt::Utility.nil_check(@targetElement)+"|"+GrabzIt::Utility.nil_check(@exportURL)+"|"+GrabzIt::Utility.nil_check(@waitForElement)+"|"+GrabzIt::Utility.nil_check(@encryptionKey)
296
296
  end
297
297
 
298
298
  # @!visibility private
@@ -107,7 +107,8 @@ module GrabzIt
107
107
  return applicationSecret+"|"+ urlParam + callBackURLParam +
108
108
  "|"+GrabzIt::Utility.nil_check(@customId)+"|"+GrabzIt::Utility.nil_int_check(@tableNumberToInclude)+"|"+GrabzIt::Utility.b_to_str(@includeAllTables)+
109
109
  "|"+GrabzIt::Utility.b_to_str(@includeHeaderNames)+"|"+GrabzIt::Utility.nil_check(@targetElement)+"|"+GrabzIt::Utility.nil_check(@format)+"|"+
110
- GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_check(@exportURL)
110
+ GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_check(@exportURL)+"|"+
111
+ GrabzIt::Utility.nil_check(@encryptionKey)
111
112
  end
112
113
 
113
114
  # @!visibility private
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grabzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GrabzIt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-04 00:00:00.000000000 Z
11
+ date: 2017-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: Use GrabzIt to convert HTML or URL's into images, PDF or DOCX documents.
@@ -61,17 +61,17 @@ require_paths:
61
61
  - lib
62
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - ! '>='
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - ! '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
73
  rubyforge_project:
74
- rubygems_version: 2.6.12
74
+ rubygems_version: 2.4.5.2
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: GrabzIt Ruby Client