@keetanetwork/keetanet-client 0.14.13 → 0.16.0

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.
Files changed (194) hide show
  1. package/client/builder.d.ts +29 -3
  2. package/client/index-browser.d.ts +24 -6
  3. package/client/index-browser.js +3426 -2704
  4. package/client/index.d.ts +24 -6
  5. package/client/index.js +1107 -501
  6. package/config/index.d.ts +3 -0
  7. package/docs/assets/hierarchy.js +1 -1
  8. package/docs/assets/search.js +1 -1
  9. package/docs/classes/KeetaNetSDK.Client.html +6 -5
  10. package/docs/classes/KeetaNetSDK.Referenced.Account.html +13 -13
  11. package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
  12. package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
  13. package/docs/classes/KeetaNetSDK.Referenced.Block.html +33 -30
  14. package/docs/classes/KeetaNetSDK.Referenced.BlockBuilder.html +2 -1
  15. package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +3 -2
  16. package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
  17. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +2 -2
  18. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +2 -2
  19. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +2 -2
  20. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +2 -2
  21. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +2 -2
  22. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +2 -2
  23. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +2 -2
  24. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +2 -2
  25. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +2 -2
  26. package/docs/classes/KeetaNetSDK.Referenced.Certificate.html +11 -5
  27. package/docs/classes/KeetaNetSDK.Referenced.CertificateBundle.html +1 -1
  28. package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +3 -2
  29. package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
  30. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
  31. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +4 -2
  32. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +4 -2
  33. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +4 -2
  34. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
  35. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +4 -2
  36. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +4 -2
  37. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +4 -2
  38. package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
  39. package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +4 -2
  40. package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +4 -2
  41. package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +4 -2
  42. package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
  43. package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
  44. package/docs/classes/KeetaNetSDK.Referenced.IdempotentKey.html +3 -2
  45. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +4 -2
  46. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
  47. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +2 -2
  48. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +1 -1
  49. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +1 -1
  50. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerIdempotentKeyError.html +1 -1
  51. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.html +1 -1
  52. package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
  53. package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +4 -2
  54. package/docs/classes/KeetaNetSDK.Referenced.Log.html +15 -3
  55. package/docs/classes/KeetaNetSDK.Referenced.LogTargetConsole.html +3 -2
  56. package/docs/classes/KeetaNetSDK.Referenced.Node.html +1 -1
  57. package/docs/classes/KeetaNetSDK.Referenced.P2PSwitch.html +4 -2
  58. package/docs/classes/KeetaNetSDK.Referenced.PendingAccount.html +1 -1
  59. package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
  60. package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +2 -2
  61. package/docs/classes/KeetaNetSDK.Referenced.PossiblyUnsignedBlock.html +38 -0
  62. package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +4 -2
  63. package/docs/classes/KeetaNetSDK.Referenced.Stats.html +1 -1
  64. package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +1 -1
  65. package/docs/classes/KeetaNetSDK.Referenced.UnsignedBlock.html +42 -0
  66. package/docs/classes/KeetaNetSDK.Referenced.UserClientBuilder.html +13 -1
  67. package/docs/classes/KeetaNetSDK.Referenced.Vote.html +2 -2
  68. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +11 -9
  69. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +4 -2
  70. package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
  71. package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +4 -2
  72. package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +2 -2
  73. package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +2 -2
  74. package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
  75. package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +10 -8
  76. package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +4 -2
  77. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +4 -2
  78. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_certificate.CertificateBuilder.html +4 -2
  79. package/docs/classes/KeetaNetSDK.UserClient.html +19 -11
  80. package/docs/documents/GETTING-STARTED.html +2 -2
  81. package/docs/enums/KeetaNetSDK.Referenced.AdjustMethod.html +4 -4
  82. package/docs/enums/KeetaNetSDK.Referenced.OperationType.html +10 -10
  83. package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_buffer.DecodeBase32.html +2 -2
  84. package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_buffer.DecodeBase64URL.html +1 -0
  85. package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_buffer.EncodeBase64URL.html +1 -0
  86. package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_conversion.toJSONSerializable.html +1 -1
  87. package/docs/hierarchy.html +1 -1
  88. package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
  89. package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
  90. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
  91. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
  92. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
  93. package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
  94. package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
  95. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
  96. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
  97. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +2 -2
  98. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +2 -2
  99. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +2 -2
  100. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +2 -2
  101. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +2 -2
  102. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +2 -2
  103. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +2 -2
  104. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +2 -2
  105. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +2 -2
  106. package/docs/interfaces/KeetaNetSDK.Referenced.BlockOperationValidateContext.html +2 -2
  107. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
  108. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
  109. package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
  110. package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
  111. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
  112. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
  113. package/docs/interfaces/KeetaNetSDK.Referenced.IdentifierCreateRequest.html +3 -2
  114. package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
  115. package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
  116. package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
  117. package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
  118. package/docs/interfaces/KeetaNetSDK.Referenced.LogTarget.html +3 -2
  119. package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
  120. package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
  121. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
  122. package/docs/interfaces/KeetaNetSDK.Referenced.NodeConfig.html +2 -2
  123. package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
  124. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
  125. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
  126. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
  127. package/docs/interfaces/KeetaNetSDK.Referenced.PendingOperations.html +2 -2
  128. package/docs/interfaces/KeetaNetSDK.Referenced.PendingOperationsJSON.html +2 -2
  129. package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +3 -2
  130. package/docs/interfaces/KeetaNetSDK.Referenced.PublishOptions.html +1 -1
  131. package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
  132. package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
  133. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +1 -1
  134. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +1 -1
  135. package/docs/interfaces/KeetaNetSDK.Referenced.VoteBundleConstructor.html +2 -2
  136. package/docs/interfaces/KeetaNetSDK.Referenced.VoteStapleJSON.html +2 -2
  137. package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
  138. package/docs/interfaces/KeetaNetSDK.Referenced.src_config.ValidationConfig.html +2 -2
  139. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
  140. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
  141. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
  142. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
  143. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
  144. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Struct.html +1 -1
  145. package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
  146. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_buffer.html +1 -1
  147. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_certificate.html +1 -1
  148. package/docs/types/KeetaNetSDK.Referenced.BlockJSONOptionalSigned.html +1 -0
  149. package/docs/types/KeetaNetSDK.Referenced.BlockV1JSONOptionalSigned.html +1 -0
  150. package/docs/types/KeetaNetSDK.Referenced.BlockV2JSONOptionalSigned.html +1 -0
  151. package/docs/types/KeetaNetSDK.Referenced.CertificateUpdate.html +1 -1
  152. package/docs/types/KeetaNetSDK.Referenced.IsTuple.html +1 -0
  153. package/docs/types/KeetaNetSDK.Referenced.JSONDepthLimit.html +1 -0
  154. package/docs/types/KeetaNetSDK.Referenced.KeyUsage.html +1 -0
  155. package/docs/types/KeetaNetSDK.Referenced.KeyUsageBits.html +1 -0
  156. package/docs/types/KeetaNetSDK.Referenced.LogTargetConsoleConfig.html +3 -2
  157. package/docs/types/KeetaNetSDK.Referenced.MultisigSignerFieldJSON.html +1 -1
  158. package/docs/types/KeetaNetSDK.Referenced.VoteOptions.html +7 -3
  159. package/docs/types/KeetaNetSDK.Referenced.VoteStapleInputs.html +2 -0
  160. package/docs/types/KeetaNetSDK.Referenced.VoteStapleOptions.html +9 -0
  161. package/docs/types/KeetaNetSDK.Referenced.src_config.NetworkConfig.html +1 -1
  162. package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_certificate.CertificateBundleJSONOutput.html +1 -0
  163. package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_certificate.CertificateJSONOutput.html +1 -1
  164. package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_conversion.ToJSONSerializable.html +1 -1
  165. package/docs/variables/KeetaNetSDK.Referenced.BlockOperationASN1Schema.html +2 -2
  166. package/docs/variables/KeetaNetSDK.Referenced.allFullErrorCodes.html +1 -1
  167. package/docs/variables/KeetaNetSDK.Referenced.keyUsageBits.html +1 -0
  168. package/lib/block/index.d.ts +341 -46
  169. package/lib/block/operations.d.ts +14 -21
  170. package/lib/error/block.d.ts +2 -2
  171. package/lib/error/index.d.ts +1 -1
  172. package/lib/ledger/common.d.ts +3 -0
  173. package/lib/ledger/db_spanner_helper.d.ts +1 -1
  174. package/lib/log/common.d.ts +3 -0
  175. package/lib/log/index.d.ts +20 -0
  176. package/lib/log/internal.d.ts +22 -0
  177. package/lib/log/target_console.d.ts +6 -0
  178. package/lib/log/target_gcp.d.ts +6 -0
  179. package/lib/log/target_gcp.js +259 -77
  180. package/lib/log/target_https.d.ts +28 -0
  181. package/lib/log/target_https.js +6055 -0
  182. package/lib/p2p.d.ts +6 -2
  183. package/lib/utils/buffer.d.ts +8 -2
  184. package/lib/utils/certificate.d.ts +41 -25
  185. package/lib/utils/conversion.d.ts +8 -4
  186. package/lib/utils/external-keys/passkey-prf.d.ts +156 -0
  187. package/lib/utils/external-keys/passkey-prf.js +391 -0
  188. package/lib/vote.d.ts +230 -35
  189. package/npm-shrinkwrap.json +2 -2
  190. package/package.json +1 -1
  191. package/version.d.ts +1 -1
  192. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATESerializable.html +0 -5
  193. package/docs/types/KeetaNetSDK.Referenced.ExportedJSONOperation.html +0 -1
  194. package/docs/types/KeetaNetSDK.Referenced.MultisigSignerField.html +0 -1
@@ -0,0 +1,391 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ // The require scope
4
+ /******/ var __webpack_require__ = {};
5
+ /******/
6
+ /************************************************************************/
7
+ /******/ /* webpack/runtime/define property getters */
8
+ /******/ (() => {
9
+ /******/ // define getter functions for harmony exports
10
+ /******/ __webpack_require__.d = (exports, definition) => {
11
+ /******/ for(var key in definition) {
12
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
+ /******/ }
15
+ /******/ }
16
+ /******/ };
17
+ /******/ })();
18
+ /******/
19
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
+ /******/ (() => {
21
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22
+ /******/ })();
23
+ /******/
24
+ /******/ /* webpack/runtime/make namespace object */
25
+ /******/ (() => {
26
+ /******/ // define __esModule on exports
27
+ /******/ __webpack_require__.r = (exports) => {
28
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30
+ /******/ }
31
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
32
+ /******/ };
33
+ /******/ })();
34
+ /******/
35
+ /************************************************************************/
36
+ var __webpack_exports__ = {};
37
+ __webpack_require__.r(__webpack_exports__);
38
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
39
+ /* harmony export */ KeetaPasskeyPRFKeyPairFactory: () => (/* binding */ KeetaPasskeyPRFKeyPairFactory)
40
+ /* harmony export */ });
41
+ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
42
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
43
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
44
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
45
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
46
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
47
+ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
48
+ function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
49
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
50
+ /**
51
+ * ExternalKeyPair for the Keeta Network which uses the PRF (Pseudo-Random
52
+ * Function) extension of the WebAuthn API to generate a key pair that can be
53
+ * used for signing and verifying messages. The PRF extension allows for the
54
+ * generation of a key pair that is derived from a secret value, which can be
55
+ * used for authentication and encryption purposes. This implementation uses
56
+ * the WebAuthn API to create a new credential with the PRF extension and then
57
+ * extracts the public key from the generated credential.
58
+ */
59
+
60
+ /**
61
+ * Options for looking up an existing Passkey PRF key pair. You can look up
62
+ * a key pair by its key ID, or by its public key string (not supported yet),
63
+ * or you can just look up any key pair (the user will be prompted to select a
64
+ * credential.
65
+ */
66
+
67
+ function KeetaPasskeyPRFKeyPairFactory(packages) {
68
+ var _KeetaPasskeyPRFKeyPair;
69
+ let includeTesting = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
70
+ if (!packages.KeetaNet || !packages.navigator || !packages.bip39) {
71
+ throw new Error('Missing required packages for KeetaPasskeyPRFKeyPairFactory');
72
+ }
73
+ const KeetaNet = Object.freeze({
74
+ lib: Object.freeze({
75
+ Account: packages.KeetaNet.lib.Account,
76
+ Utils: Object.freeze({
77
+ Helper: Object.freeze({
78
+ bufferToArrayBuffer: packages.KeetaNet.lib.Utils.Helper.bufferToArrayBuffer,
79
+ crypto: Object.freeze({
80
+ randomBytes: packages.KeetaNet.lib.Utils.Helper.crypto.randomBytes
81
+ })
82
+ }),
83
+ Buffer: packages.KeetaNet.lib.Utils.Buffer
84
+ })
85
+ })
86
+ });
87
+ const navigator = Object.freeze({
88
+ credentials: Object.freeze({
89
+ create: packages.navigator.credentials.create.bind(packages.navigator.credentials),
90
+ get: packages.navigator.credentials.get.bind(packages.navigator.credentials)
91
+ })
92
+ });
93
+ const bip39 = Object.freeze({
94
+ entropyToMnemonic: packages.bip39.entropyToMnemonic.bind(packages.bip39)
95
+ });
96
+ const bufferToArrayBuffer = KeetaNet.lib.Utils.Helper.bufferToArrayBuffer;
97
+ const crypto = KeetaNet.lib.Utils.Helper.crypto;
98
+ const Buffer = KeetaNet.lib.Utils.Buffer.Buffer;
99
+
100
+ /**
101
+ * Default salt: SHA2-256('keeta.com/wallet/seed/v1' as UTF-8 bytes)
102
+ */
103
+ const defaultSalt = new Uint8Array([0x25, 0x6D, 0x61, 0xF0, 0x1F, 0x6F, 0xBF, 0x96, 0x44, 0x49, 0x3B, 0xE0, 0x34, 0x1B, 0x4F, 0x0E, 0xBD, 0x8F, 0xD1, 0x4B, 0x1C, 0xFC, 0x6C, 0x1A, 0x10, 0xAE, 0x42, 0x63, 0x06, 0x69, 0x29, 0x0C]);
104
+ function isArrayBufferLike(value) {
105
+ if (typeof value !== 'object' || value === null) {
106
+ return false;
107
+ }
108
+ if (!('byteLength' in value) || !('slice' in value)) {
109
+ return false;
110
+ }
111
+ if (typeof value.byteLength !== 'number' || typeof value.slice !== 'function') {
112
+ return false;
113
+ }
114
+ return true;
115
+ }
116
+ function credentialHasRawId(credential) {
117
+ if (typeof credential !== 'object' || credential === null) {
118
+ return false;
119
+ }
120
+ if (!('rawId' in credential)) {
121
+ return false;
122
+ }
123
+ if (typeof credential.rawId !== 'object' || credential.rawId === null) {
124
+ return false;
125
+ }
126
+ if (!isArrayBufferLike(credential.rawId)) {
127
+ return false;
128
+ }
129
+ return true;
130
+ }
131
+ function credentialToEntropy(credential) {
132
+ if (typeof credential !== 'object' || credential === null) {
133
+ throw new Error('Credential is not an object');
134
+ }
135
+ if (!('getClientExtensionResults' in credential) || typeof credential.getClientExtensionResults !== 'function') {
136
+ throw new Error('Credential does not support getClientExtensionResults');
137
+ }
138
+ const extensions = credential.getClientExtensionResults();
139
+ if (typeof extensions !== 'object' || extensions === null) {
140
+ throw new Error('Credential extensions are not an object');
141
+ }
142
+ if (!('prf' in extensions) || typeof extensions.prf !== 'object' || extensions.prf === null) {
143
+ throw new Error('Credential does not have PRF extension results');
144
+ }
145
+ const prfExtension = extensions.prf;
146
+ if ('enabled' in prfExtension && prfExtension.enabled !== true) {
147
+ throw new Error('PRF extension does not indicate PRF is enabled');
148
+ }
149
+ if (!('results' in prfExtension) || typeof prfExtension.results !== 'object' || prfExtension.results === null) {
150
+ throw new Error('PRF extension results do not contain a valid result');
151
+ }
152
+ const prfResults = prfExtension.results;
153
+ if (!('first' in prfResults) || typeof prfResults.first !== 'object' || prfResults.first === null) {
154
+ throw new Error('PRF extension results do not contain a "first" value');
155
+ }
156
+ if (!isArrayBufferLike(prfResults.first)) {
157
+ throw new Error('PRF extension "first" value is not an ArrayBuffer');
158
+ }
159
+ return Buffer.from(prfResults.first);
160
+ }
161
+ async function entropyToAccount(entropy, index, keyType) {
162
+ const passphrase = bip39.entropyToMnemonic(new Uint8Array(entropy));
163
+ const seed = await KeetaNet.lib.Account.seedFromPassphrase(passphrase);
164
+ const account = KeetaNet.lib.Account.fromSeed(seed, index, keyType);
165
+ return {
166
+ passphrase: passphrase,
167
+ account: account,
168
+ rawPublicKey: account.publicKey.get()
169
+ };
170
+ }
171
+
172
+ /**
173
+ * A KeetaNet ExternalKeyPair implementation backed by the WebAuthn API with the PRF extension.
174
+ */
175
+ var _salt = /*#__PURE__*/new WeakMap();
176
+ var _keyID = /*#__PURE__*/new WeakMap();
177
+ var _index = /*#__PURE__*/new WeakMap();
178
+ var _KeetaPasskeyPRFKeyPair_brand = /*#__PURE__*/new WeakSet();
179
+ class KeetaPasskeyPRFKeyPair extends KeetaNet.lib.Account.ExternalKeyPair {
180
+ /**
181
+ * Creates a new KeetaPasskeyPRFKeyPair instance with the
182
+ * given public key, key ID, and key type. Generally this
183
+ * constructor should not be called directly, as the preferred
184
+ * way to access an existing key pair is through the static
185
+ * @see KeetaPasskeyPRFKeyPair.lookup, or to create a
186
+ * new key pair through the static @see KeetaPasskeyPRFKeyPair.generate method.
187
+ */
188
+ constructor(rawPublicKey, keyID, salt, index, keyType) {
189
+ super({
190
+ sign: async (data, options) => {
191
+ const account = await _assertClassBrand(_KeetaPasskeyPRFKeyPair_brand, this, _lookupBackingAccount).call(this);
192
+ return await account.sign(data, {
193
+ ...options,
194
+ raw: true
195
+ });
196
+ },
197
+ decrypt: async data => {
198
+ const account = await _assertClassBrand(_KeetaPasskeyPRFKeyPair_brand, this, _lookupBackingAccount).call(this);
199
+ return await account.decrypt(data);
200
+ },
201
+ supportsEncryption: true
202
+ }, rawPublicKey, keyType, false);
203
+ _classPrivateMethodInitSpec(this, _KeetaPasskeyPRFKeyPair_brand);
204
+ _classPrivateFieldInitSpec(this, _salt, void 0);
205
+ _classPrivateFieldInitSpec(this, _keyID, void 0);
206
+ _classPrivateFieldInitSpec(this, _index, void 0);
207
+ _classPrivateFieldSet(_keyID, this, keyID);
208
+ _classPrivateFieldSet(_index, this, index);
209
+ _classPrivateFieldSet(_salt, this, new Uint8Array(salt !== null && salt !== void 0 ? salt : defaultSalt));
210
+ this.keyID = keyID;
211
+ Object.freeze(this);
212
+ }
213
+
214
+ /**
215
+ * Lookup an existing credential
216
+ *
217
+ * @param keyID The key ID of the credential to lookup. If null, any credential will be accepted.
218
+ * @param salt The salt to use for the PRF extension.
219
+ * @param keyType The key type to generate from the PRF output.
220
+ * @returns An object containing the key ID, key type, and public key string of the retrieved credential.
221
+ */
222
+
223
+ /**
224
+ * Lookup an existing public key by prompting the user to
225
+ * select a credential from their authenticator.
226
+ */
227
+ static async lookup(options) {
228
+ var _options$salt, _options, _options$keyType, _options2, _options$index, _options3;
229
+ options = {
230
+ ...options
231
+ };
232
+ let keyID = null;
233
+ if ('publicKeyString' in options) {
234
+ throw new Error('Lookup by public key string is not supported yet');
235
+ } else if ('keyID' in options) {
236
+ keyID = options.keyID;
237
+ } else {
238
+ keyID = null;
239
+ }
240
+ const salt = (_options$salt = (_options = options) === null || _options === void 0 ? void 0 : _options.salt) !== null && _options$salt !== void 0 ? _options$salt : defaultSalt;
241
+ const keyType = (_options$keyType = (_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.keyType) !== null && _options$keyType !== void 0 ? _options$keyType : KeetaNet.lib.Account.AccountKeyAlgorithm.ECDSA_SECP256K1;
242
+ const index = (_options$index = (_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.index) !== null && _options$index !== void 0 ? _options$index : 0;
243
+ const key = await _lookupByKeyIDWithSalt.call(KeetaPasskeyPRFKeyPair, keyID, salt, index, keyType);
244
+ const keyPair = new KeetaPasskeyPRFKeyPair(key.rawPublicKey, key.keyID, key.salt, key.index, key.keyType);
245
+ return keyPair;
246
+ }
247
+
248
+ /**
249
+ * Generate a new key pair by prompting the user to create a
250
+ * new Passkey credential with the PRF extension, and then
251
+ * extracting
252
+ */
253
+ static async generate(options) {
254
+ var _options$salt2, _options$keyType2, _options$index2, _options$rp$name, _options$user$id;
255
+ const salt = new Uint8Array(bufferToArrayBuffer(Buffer.from((_options$salt2 = options === null || options === void 0 ? void 0 : options.salt) !== null && _options$salt2 !== void 0 ? _options$salt2 : defaultSalt)));
256
+ const keyType = (_options$keyType2 = options === null || options === void 0 ? void 0 : options.keyType) !== null && _options$keyType2 !== void 0 ? _options$keyType2 : KeetaNet.lib.Account.AccountKeyAlgorithm.ECDSA_SECP256K1;
257
+ const index = (_options$index2 = options === null || options === void 0 ? void 0 : options.index) !== null && _options$index2 !== void 0 ? _options$index2 : 0;
258
+ const challenge = bufferToArrayBuffer(crypto.randomBytes(32));
259
+ const credential = await navigator.credentials.create({
260
+ publicKey: {
261
+ challenge: challenge,
262
+ pubKeyCredParams: [{
263
+ type: 'public-key',
264
+ alg: -7 /* ES256 */
265
+ }, {
266
+ type: 'public-key',
267
+ alg: -257 /* RS256 */
268
+ }],
269
+ rp: {
270
+ name: (_options$rp$name = options.rp.name) !== null && _options$rp$name !== void 0 ? _options$rp$name : 'Keeta Network',
271
+ id: options.rp.id
272
+ },
273
+ user: {
274
+ displayName: options.user.displayName,
275
+ name: options.user.name,
276
+ id: (_options$user$id = options.user.id) !== null && _options$user$id !== void 0 ? _options$user$id : bufferToArrayBuffer(crypto.randomBytes(16))
277
+ },
278
+ extensions: {
279
+ // @ts-ignore
280
+ prf: {
281
+ eval: {
282
+ first: salt
283
+ }
284
+ }
285
+ }
286
+ }
287
+ });
288
+ if (credential === null) {
289
+ throw new Error('Failed to create credential');
290
+ }
291
+ if (!credentialHasRawId(credential)) {
292
+ throw new Error('Created credential does not have a raw ID');
293
+ }
294
+ const entropy = credentialToEntropy(credential);
295
+ const {
296
+ rawPublicKey
297
+ } = await entropyToAccount(entropy, index, keyType);
298
+ const keyID = Buffer.from(credential.rawId).toString('base64');
299
+ return new KeetaPasskeyPRFKeyPair(rawPublicKey, keyID, salt, index, keyType);
300
+ }
301
+ async exportPassphrase() {
302
+ const keyInfo = await _assertClassBrand(_KeetaPasskeyPRFKeyPair_brand, this, _lookupKeyInfo).call(this);
303
+ return keyInfo.passphrase;
304
+ }
305
+ }
306
+ _KeetaPasskeyPRFKeyPair = KeetaPasskeyPRFKeyPair;
307
+ async function _lookupByKeyIDWithSalt(keyID, salt, index, keyType) {
308
+ const challenge = bufferToArrayBuffer(crypto.randomBytes(32));
309
+ let allowCredentials = undefined;
310
+ if (keyID !== null) {
311
+ allowCredentials = [{
312
+ type: 'public-key',
313
+ id: bufferToArrayBuffer(Buffer.from(keyID, 'base64'))
314
+ }];
315
+ }
316
+ const credential = await navigator.credentials.get({
317
+ publicKey: {
318
+ challenge: challenge,
319
+ allowCredentials: allowCredentials,
320
+ extensions: {
321
+ /*
322
+ * This extension is standardized
323
+ * by the NodeJS DOM library
324
+ */
325
+ // @ts-ignore
326
+ prf: {
327
+ eval: {
328
+ first: bufferToArrayBuffer(Buffer.from(salt))
329
+ }
330
+ }
331
+ },
332
+ userVerification: 'required'
333
+ }
334
+ });
335
+ if (credential === null) {
336
+ throw new Error('Failed to retrieve credential with assertion');
337
+ }
338
+ if (!credentialHasRawId(credential)) {
339
+ throw new Error('Retrieved credential does not have a raw ID');
340
+ }
341
+ const checkKeyID = Buffer.from(credential.rawId);
342
+ if (keyID !== null) {
343
+ if (checkKeyID.toString('base64') !== keyID) {
344
+ throw new Error('Retrieved credential does not match the expected key ID');
345
+ }
346
+ } else {
347
+ keyID = checkKeyID.toString('base64');
348
+ }
349
+ const entropy = credentialToEntropy(credential);
350
+ const convertedData = await entropyToAccount(entropy, index, keyType);
351
+
352
+ /* Should we check the challenge is correctly signed ? */
353
+
354
+ return {
355
+ keyID: keyID,
356
+ keyType: keyType,
357
+ index: index,
358
+ salt: salt,
359
+ ...convertedData
360
+ };
361
+ }
362
+ async function _lookupKeyInfo() {
363
+ const keyInfo = await _lookupByKeyIDWithSalt.call(_KeetaPasskeyPRFKeyPair, _classPrivateFieldGet(_keyID, this), _classPrivateFieldGet(_salt, this), _classPrivateFieldGet(_index, this), this.keyType);
364
+ return keyInfo;
365
+ }
366
+ async function _lookupBackingAccount() {
367
+ const keyInfo = await _assertClassBrand(_KeetaPasskeyPRFKeyPair_brand, this, _lookupKeyInfo).call(this);
368
+ return keyInfo.account;
369
+ }
370
+ /** @internal */
371
+ _defineProperty(KeetaPasskeyPRFKeyPair, "_Testing", {
372
+ entropyToAccount: entropyToAccount
373
+ });
374
+ if (!includeTesting) {
375
+ /**
376
+ * The _Testing property is only included for testing
377
+ * so remove it if we're not including testing.
378
+ */
379
+ // @ts-ignore
380
+ delete KeetaPasskeyPRFKeyPair._Testing;
381
+ }
382
+ Object.freeze(KeetaPasskeyPRFKeyPair);
383
+ Object.freeze(KeetaPasskeyPRFKeyPair.prototype);
384
+ return KeetaPasskeyPRFKeyPair;
385
+ }
386
+ Object.freeze(KeetaPasskeyPRFKeyPairFactory);
387
+ var __webpack_export_target__ = exports;
388
+ for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
389
+ if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
390
+ /******/ })()
391
+ ;