SubtleCrypto.hx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C)2005-2017 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. /**
  25. 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`).
  26. 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/).
  27. @see <https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto>
  28. **/
  29. @:native("SubtleCrypto")
  30. extern class SubtleCrypto
  31. {
  32. /** @throws DOMError */
  33. /**
  34. Returns a `Promise` of the encrypted data corresponding to the clear text, algorithm and key given as parameters.
  35. **/
  36. function encrypt( algorithm : haxe.extern.EitherType<Dynamic,String>, key : CryptoKey, data : haxe.extern.EitherType<ArrayBufferView,ArrayBuffer> ) : Promise<Dynamic>;
  37. /** @throws DOMError */
  38. /**
  39. Returns a `Promise` of the clear data corresponding to the encrypted text, algorithm and key given as parameters.
  40. **/
  41. function decrypt( algorithm : haxe.extern.EitherType<Dynamic,String>, key : CryptoKey, data : haxe.extern.EitherType<ArrayBufferView,ArrayBuffer> ) : Promise<Dynamic>;
  42. /** @throws DOMError */
  43. /**
  44. Returns a `Promise` of the signature corresponding to the text, algorithm and key given as parameters.
  45. **/
  46. function sign( algorithm : haxe.extern.EitherType<Dynamic,String>, key : CryptoKey, data : haxe.extern.EitherType<ArrayBufferView,ArrayBuffer> ) : Promise<Dynamic>;
  47. /** @throws DOMError */
  48. /**
  49. Returns a `Promise` of a `Boolean` value indicating if the signature given as parameter matches the text, algorithm and key also given as parameters.
  50. **/
  51. function verify( algorithm : haxe.extern.EitherType<Dynamic,String>, key : CryptoKey, signature : haxe.extern.EitherType<ArrayBufferView,ArrayBuffer>, data : haxe.extern.EitherType<ArrayBufferView,ArrayBuffer> ) : Promise<Dynamic>;
  52. /** @throws DOMError */
  53. /**
  54. Returns a `Promise` of a digest generated from the algorithm and text given as parameters.
  55. **/
  56. function digest( algorithm : haxe.extern.EitherType<Dynamic,String>, data : haxe.extern.EitherType<ArrayBufferView,ArrayBuffer> ) : Promise<Dynamic>;
  57. /** @throws DOMError */
  58. /**
  59. 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.
  60. **/
  61. function generateKey( algorithm : haxe.extern.EitherType<Dynamic,String>, extractable : Bool, keyUsages : Array<String> ) : Promise<Dynamic>;
  62. /** @throws DOMError */
  63. /**
  64. Returns a `Promise` of a newly generated `CryptoKey` derived from a master key and a specific algorithm given as parameters.
  65. **/
  66. function deriveKey( algorithm : haxe.extern.EitherType<Dynamic,String>, baseKey : CryptoKey, derivedKeyType : haxe.extern.EitherType<Dynamic,String>, extractable : Bool, keyUsages : Array<String> ) : Promise<Dynamic>;
  67. /** @throws DOMError */
  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. **/
  71. function deriveBits( algorithm : haxe.extern.EitherType<Dynamic,String>, baseKey : CryptoKey, length : Int ) : Promise<Dynamic>;
  72. /** @throws DOMError */
  73. /**
  74. Returns a `Promise` of a `CryptoKey` corresponding to the format, the algorithm, the raw key data, the usages and the extractability given as parameters.
  75. **/
  76. function importKey( format : String, keyData : Dynamic, algorithm : haxe.extern.EitherType<Dynamic,String>, extractable : Bool, keyUsages : Array<String> ) : Promise<Dynamic>;
  77. /** @throws DOMError */
  78. /**
  79. Returns a `Promise` of a buffer containing the key in the format requested.
  80. **/
  81. function exportKey( format : String, key : CryptoKey ) : Promise<Dynamic>;
  82. /** @throws DOMError */
  83. /**
  84. 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.
  85. **/
  86. function wrapKey( format : String, key : CryptoKey, wrappingKey : CryptoKey, wrapAlgorithm : haxe.extern.EitherType<Dynamic,String> ) : Promise<Dynamic>;
  87. /** @throws DOMError */
  88. /**
  89. Returns a `Promise` of a `CryptoKey` corresponding to the wrapped key given in parameter.
  90. **/
  91. function unwrapKey( format : String, wrappedKey : haxe.extern.EitherType<ArrayBufferView,ArrayBuffer>, unwrappingKey : CryptoKey, unwrapAlgorithm : haxe.extern.EitherType<Dynamic,String>, unwrappedKeyAlgorithm : haxe.extern.EitherType<Dynamic,String>, extractable : Bool, keyUsages : Array<String> ) : Promise<Dynamic>;
  92. }