SubtleCrypto.hx 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. // This file is generated from mozilla\SubtleCrypto.webidl. Do not edit!
  23. package js.html;
  24. import js.lib.Promise;
  25. /**
  26. The `SubtleCrypto` interface represents a set of cryptographic primitives. It is available via the `Crypto.subtle` properties available in a window context (via `Window.crypto`).
  27. Documentation [SubtleCrypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
  28. @see <https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto>
  29. **/
  30. @:native("SubtleCrypto")
  31. extern class SubtleCrypto {
  32. /**
  33. Returns a `Promise` of the encrypted data corresponding to the clear text, algorithm and key given as parameters.
  34. @throws DOMError
  35. **/
  36. function encrypt( algorithm : haxe.extern.EitherType<Dynamic,String>, key : CryptoKey, data : haxe.extern.EitherType<js.lib.ArrayBufferView,js.lib.ArrayBuffer> ) : Promise<Dynamic>;
  37. /**
  38. Returns a `Promise` of the clear data corresponding to the encrypted text, algorithm and key given as parameters.
  39. @throws DOMError
  40. **/
  41. function decrypt( algorithm : haxe.extern.EitherType<Dynamic,String>, key : CryptoKey, data : haxe.extern.EitherType<js.lib.ArrayBufferView,js.lib.ArrayBuffer> ) : Promise<Dynamic>;
  42. /**
  43. Returns a `Promise` of the signature corresponding to the text, algorithm and key given as parameters.
  44. @throws DOMError
  45. **/
  46. function sign( algorithm : haxe.extern.EitherType<Dynamic,String>, key : CryptoKey, data : haxe.extern.EitherType<js.lib.ArrayBufferView,js.lib.ArrayBuffer> ) : Promise<Dynamic>;
  47. /**
  48. Returns a `Promise` of a `Boolean` value indicating if the signature given as parameter matches the text, algorithm and key also given as parameters.
  49. @throws DOMError
  50. **/
  51. function verify( algorithm : haxe.extern.EitherType<Dynamic,String>, key : CryptoKey, signature : haxe.extern.EitherType<js.lib.ArrayBufferView,js.lib.ArrayBuffer>, data : haxe.extern.EitherType<js.lib.ArrayBufferView,js.lib.ArrayBuffer> ) : Promise<Dynamic>;
  52. /**
  53. Returns a `Promise` of a digest generated from the algorithm and text given as parameters.
  54. @throws DOMError
  55. **/
  56. function digest( algorithm : haxe.extern.EitherType<Dynamic,String>, data : haxe.extern.EitherType<js.lib.ArrayBufferView,js.lib.ArrayBuffer> ) : Promise<Dynamic>;
  57. /**
  58. Returns a `Promise` of a newly generated `CryptoKey`, for symmetrical algorithms, or a `CryptoKeyPair`, containing two newly generated keys, for asymmetrical algorithm, that matches the algorithm, the usages and the extractability given as parameters.
  59. @throws DOMError
  60. **/
  61. @:overload( function( algorithm : String, extractable : Bool, keyUsages : Array<String>) : Promise<Dynamic> {} )
  62. function generateKey( algorithm : Dynamic, extractable : Bool, keyUsages : Array<String> ) : Promise<Dynamic>;
  63. /**
  64. Returns a `Promise` of a newly generated `CryptoKey` derived from a master key and a specific algorithm given as parameters.
  65. @throws DOMError
  66. **/
  67. function deriveKey( algorithm : haxe.extern.EitherType<Dynamic,String>, baseKey : CryptoKey, derivedKeyType : haxe.extern.EitherType<Dynamic,String>, extractable : Bool, keyUsages : Array<String> ) : Promise<Dynamic>;
  68. /**
  69. Returns a `Promise` of a newly generated buffer of pseudo-random bits derived from a master key and a specific algorithm given as parameters.
  70. @throws DOMError
  71. **/
  72. @:overload( function( algorithm : String, baseKey : CryptoKey, length : Int) : Promise<Dynamic> {} )
  73. function deriveBits( algorithm : Dynamic, baseKey : CryptoKey, length : Int ) : Promise<Dynamic>;
  74. /**
  75. Returns a `Promise` of a `CryptoKey` corresponding to the format, the algorithm, the raw key data, the usages and the extractability given as parameters.
  76. @throws DOMError
  77. **/
  78. @:overload( function( format : String, keyData : Dynamic, algorithm : String, extractable : Bool, keyUsages : Array<String>) : Promise<Dynamic> {} )
  79. function importKey( format : String, keyData : Dynamic, algorithm : Dynamic, extractable : Bool, keyUsages : Array<String> ) : Promise<Dynamic>;
  80. /**
  81. Returns a `Promise` of a buffer containing the key in the format requested.
  82. @throws DOMError
  83. **/
  84. function exportKey( format : String, key : CryptoKey ) : Promise<Dynamic>;
  85. /**
  86. Returns a `Promise` of a wrapped symmetric key for usage (transfer, storage) in insecure environments. The wrapped buffer returned is in the format given in parameters, and contains the key wrapped by the given wrapping key with the given algorithm.
  87. @throws DOMError
  88. **/
  89. @:overload( function( format : String, key : CryptoKey, wrappingKey : CryptoKey, wrapAlgorithm : String) : Promise<Dynamic> {} )
  90. function wrapKey( format : String, key : CryptoKey, wrappingKey : CryptoKey, wrapAlgorithm : Dynamic ) : Promise<Dynamic>;
  91. /**
  92. Returns a `Promise` of a `CryptoKey` corresponding to the wrapped key given in parameter.
  93. @throws DOMError
  94. **/
  95. function unwrapKey( format : String, wrappedKey : haxe.extern.EitherType<js.lib.ArrayBufferView,js.lib.ArrayBuffer>, unwrappingKey : CryptoKey, unwrapAlgorithm : haxe.extern.EitherType<Dynamic,String>, unwrappedKeyAlgorithm : haxe.extern.EitherType<Dynamic,String>, extractable : Bool, keyUsages : Array<String> ) : Promise<Dynamic>;
  96. }