@keetanetwork/keetanet-client 0.16.1 → 0.16.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.
- package/client/index-browser.d.ts +3 -2
- package/client/index-browser.js +296 -98
- package/client/index.d.ts +3 -2
- package/client/index.js +232 -43
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Account.html +6 -3
- package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Block.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdempotentKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerIdempotentKeyError.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PossiblyUnsignedBlock.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Stats.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.UnsignedBlock.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Vote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
- package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.applyNamespace.html +5 -0
- package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_helper.getTypedObjectEntries.html +1 -0
- package/docs/hierarchy.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseAccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierAccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ECDSA_SECP256K1AccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ECDSA_SECP256R1AccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ED25519AccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +2 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultisigAccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.NetworkAccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.PublishOptions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.StorageAccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.TokenAccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.signOptionsType.html +16 -3
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Struct.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.html +1 -0
- package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_helper.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.allFullErrorCodes.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.KeetaNamespaceVersion.html +3 -0
- package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.MaxNamespaceLength.html +3 -0
- package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.namespacePrefixSchema.html +9 -0
- package/docs/variables/KeetaNetSDK.lib.html +2 -2
- package/lib/account.d.ts +37 -0
- package/lib/error/account.d.ts +2 -2
- package/lib/error/index.d.ts +1 -1
- package/lib/error/vote.d.ts +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/ledger/common.d.ts +12 -0
- package/lib/ledger/db_dynamodb.d.ts +2 -2
- package/lib/ledger/db_postgres.d.ts +1 -1
- package/lib/ledger/db_spanner.d.ts +1 -1
- package/lib/ledger/db_spanner_helper.d.ts +1 -1
- package/lib/ledger/db_sqlite.d.ts +1 -1
- package/lib/ledger/index.d.ts +2 -2
- package/lib/utils/domain-separation.d.ts +31 -0
- package/lib/utils/external-keys/gcp-kms.d.ts +53 -0
- package/lib/utils/external-keys/gcp-kms.js +328 -0
- package/lib/utils/external-keys/passkey-prf.d.ts +1 -3
- package/lib/utils/external-keys/passkey-prf.js +6 -0
- package/lib/utils/helper.d.ts +1 -0
- package/npm-shrinkwrap.json +27 -9
- package/package.json +1 -1
- package/version.d.ts +1 -1
package/lib/error/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeetaNetErrorBase } from './base';
|
|
2
2
|
import { KeetaNetLedgerError, KeetaNetLedgerVoteError, KeetaNetLedgerIdempotentKeyError } from './ledger';
|
|
3
|
-
declare const allFullErrorCodes: readonly ("PERMISSIONS_CANNOT_MIX_FLAGS_AND_TYPES" | "PERMISSIONS_EXTERNAL_OFFSET_TOO_LARGE" | "PERMISSIONS_INVALID_EXTERNAL_FLAG" | "PERMISSIONS_INVALID_FLAG" | "PERMISSIONS_INVALID_FLAG_ASSERTION" | "BLOCK_AMOUNT_BELOW_ZERO" | "BLOCK_CANNOT_FORWARD_TO_SELF" | "BLOCK_CANNOT_SEND_NON_TOKEN" | "BLOCK_CERTIFICATE_SUBJECT_MISMATCH" | "BLOCK_EXACT_TRUE_WHEN_FORWARDING" | "BLOCK_EXTERNAL_INVALID" | "BLOCK_EXTERNAL_MISSING" | "BLOCK_EXTERNAL_TOO_LONG" | "BLOCK_GENERAL_FIELD_INVALID" | "BLOCK_IDENTIFIER_INVALID" | "BLOCK_IDENTIFIER_NEED_DEFAULT_PERMISSIONS" | "BLOCK_INTERMEDIATE_CERTIFICATES_ONLY_ADD" | "BLOCK_INVALID_ACCOUNT_TYPE" | "BLOCK_INVALID_CERTIFICATE_VALUE" | "BLOCK_INVALID_CREATE_IDENTIFIER_ARGS" | "BLOCK_INVALID_IDEMPOTENT_FORMAT" | "BLOCK_INVALID_IDEMPOTENT_LENGTH" | "BLOCK_INVALID_MULTISIG_QUORUM" | "BLOCK_INVALID_MULTISIG_SIGNER_COUNT" | "BLOCK_INVALID_MULTISIG_SIGNER_DEPTH" | "BLOCK_INVALID_MULTISIG_SIGNER_DUPLICATE" | "BLOCK_INVALID_PURPOSE_VALIDATION" | "BLOCK_INVALID_SIGNATURE" | "BLOCK_INVALID_SIGNER" | "BLOCK_INVALID_TYPE" | "BLOCK_INVALID_VERSION" | "BLOCK_NO_ADMIN_ON_TARGET" | "BLOCK_NO_DELEGATE_ADMIN" | "BLOCK_NO_DUPLICATE_CERTIFICATE_OPERATION" | "BLOCK_NO_IDENTIFIER_OP" | "BLOCK_NO_MODIFY_PERMISSION_DUPE" | "BLOCK_NO_MULTIPLE_SET_REP" | "BLOCK_NO_MULTISIG_OP" | "BLOCK_NO_TOKEN_OP" | "BLOCK_ONLY_IDENTIFIER_OP" | "BLOCK_ONLY_TOKEN_OP" | "BLOCK_PERMISSIONS_INVALID_DEFAULT" | "BLOCK_PERMISSIONS_INVALID_ENTITY" | "BLOCK_PERMISSIONS_INVALID_PRINCIPAL" | "BLOCK_PERMISSIONS_INVALID_TARGET" | "BLOCK_PREVIOUS_SELF" | "BLOCK_SUPPLY_INVALID" | "BLOCK_TOKEN_RECEIVE_DIFFERS" | "BLOCK_SIGNATURE_REQUIRED" | "BLOCK_SIGNATURE_PARAMETER_DIFFERS" | "CERTIFICATE_INVALID_VERSION" | "CERTIFICATE_DUPLICATE_INCLUDED" | "CERTIFICATE_ORPHAN_FOUND" | "CERTIFICATE_CYCLE_FOUND" | "CERTIFICATE_SECONDARY_GRAPH" | "CERTIFICATE_MISSING_FIELD" | "CERTIFICATE_SIGNATURE_ALGORITHM_MISMATCH" | "CERTIFICATE_SELF_SIGNED_VALIDATION_FAILED" | "CERTIFICATE_CHAIN_VERIFICATION_FAILED" | "CERTIFICATE_DUPLICATE_EXTENSION" | "CERTIFICATE_EXTENSION_NOT_PROCESSED" | "CERTIFICATE_INVALID_SIGNATURE_ALGORITHM" | "CERTIFICATE_INVALID_GRAPH_COUNT" | "CERTIFICATE_MOMENT_INVALID" | "
|
|
3
|
+
declare const allFullErrorCodes: readonly ("ACCOUNT_INVALID_PREFIX" | "ACCOUNT_INVALID_KEYTYPE" | "ACCOUNT_INVALID_KEYTYPE_EXTERNAL" | "ACCOUNT_PASSPHRASE_WEAK" | "ACCOUNT_INVALID_CONSTRUCTION" | "ACCOUNT_NO_IDENTIFIER_SIGN" | "ACCOUNT_NO_IDENTIFIER_VERIFY" | "ACCOUNT_NOT_ACCOUNT" | "ACCOUNT_NOT_IDENTIFIER" | "ACCOUNT_INVALID_IDENTIFIER_CONSTRUCTION" | "ACCOUNT_SEED_INDEX_UNDEFINED" | "ACCOUNT_SEED_INDEX_NEGATIVE" | "ACCOUNT_SEED_INDEX_NOT_INT" | "ACCOUNT_SEED_INDEX_TOO_LARGE" | "ACCOUNT_ENCRYPTION_NOT_SUPPORTED" | "ACCOUNT_NAMESPACE_EMPTY" | "ACCOUNT_NAMESPACE_TOO_LONG" | "PERMISSIONS_CANNOT_MIX_FLAGS_AND_TYPES" | "PERMISSIONS_EXTERNAL_OFFSET_TOO_LARGE" | "PERMISSIONS_INVALID_EXTERNAL_FLAG" | "PERMISSIONS_INVALID_FLAG" | "PERMISSIONS_INVALID_FLAG_ASSERTION" | "BLOCK_AMOUNT_BELOW_ZERO" | "BLOCK_CANNOT_FORWARD_TO_SELF" | "BLOCK_CANNOT_SEND_NON_TOKEN" | "BLOCK_CERTIFICATE_SUBJECT_MISMATCH" | "BLOCK_EXACT_TRUE_WHEN_FORWARDING" | "BLOCK_EXTERNAL_INVALID" | "BLOCK_EXTERNAL_MISSING" | "BLOCK_EXTERNAL_TOO_LONG" | "BLOCK_GENERAL_FIELD_INVALID" | "BLOCK_IDENTIFIER_INVALID" | "BLOCK_IDENTIFIER_NEED_DEFAULT_PERMISSIONS" | "BLOCK_INTERMEDIATE_CERTIFICATES_ONLY_ADD" | "BLOCK_INVALID_ACCOUNT_TYPE" | "BLOCK_INVALID_CERTIFICATE_VALUE" | "BLOCK_INVALID_CREATE_IDENTIFIER_ARGS" | "BLOCK_INVALID_IDEMPOTENT_FORMAT" | "BLOCK_INVALID_IDEMPOTENT_LENGTH" | "BLOCK_INVALID_MULTISIG_QUORUM" | "BLOCK_INVALID_MULTISIG_SIGNER_COUNT" | "BLOCK_INVALID_MULTISIG_SIGNER_DEPTH" | "BLOCK_INVALID_MULTISIG_SIGNER_DUPLICATE" | "BLOCK_INVALID_PURPOSE_VALIDATION" | "BLOCK_INVALID_SIGNATURE" | "BLOCK_INVALID_SIGNER" | "BLOCK_INVALID_TYPE" | "BLOCK_INVALID_VERSION" | "BLOCK_NO_ADMIN_ON_TARGET" | "BLOCK_NO_DELEGATE_ADMIN" | "BLOCK_NO_DUPLICATE_CERTIFICATE_OPERATION" | "BLOCK_NO_IDENTIFIER_OP" | "BLOCK_NO_MODIFY_PERMISSION_DUPE" | "BLOCK_NO_MULTIPLE_SET_REP" | "BLOCK_NO_MULTISIG_OP" | "BLOCK_NO_TOKEN_OP" | "BLOCK_ONLY_IDENTIFIER_OP" | "BLOCK_ONLY_TOKEN_OP" | "BLOCK_PERMISSIONS_INVALID_DEFAULT" | "BLOCK_PERMISSIONS_INVALID_ENTITY" | "BLOCK_PERMISSIONS_INVALID_PRINCIPAL" | "BLOCK_PERMISSIONS_INVALID_TARGET" | "BLOCK_PREVIOUS_SELF" | "BLOCK_SUPPLY_INVALID" | "BLOCK_TOKEN_RECEIVE_DIFFERS" | "BLOCK_SIGNATURE_REQUIRED" | "BLOCK_SIGNATURE_PARAMETER_DIFFERS" | "CERTIFICATE_INVALID_VERSION" | "CERTIFICATE_DUPLICATE_INCLUDED" | "CERTIFICATE_ORPHAN_FOUND" | "CERTIFICATE_CYCLE_FOUND" | "CERTIFICATE_SECONDARY_GRAPH" | "CERTIFICATE_MISSING_FIELD" | "CERTIFICATE_SIGNATURE_ALGORITHM_MISMATCH" | "CERTIFICATE_SELF_SIGNED_VALIDATION_FAILED" | "CERTIFICATE_CHAIN_VERIFICATION_FAILED" | "CERTIFICATE_DUPLICATE_EXTENSION" | "CERTIFICATE_EXTENSION_NOT_PROCESSED" | "CERTIFICATE_INVALID_SIGNATURE_ALGORITHM" | "CERTIFICATE_INVALID_GRAPH_COUNT" | "CERTIFICATE_MOMENT_INVALID" | "VOTE_INVALID_CONSTRUCTION" | "VOTE_INVALID_VERSION" | "VOTE_SERIAL_MISMATCH" | "VOTE_INVALID_CONSTRUCTION_JSON" | "VOTE_SIGNATURE_INVALID" | "VOTE_EXPIRED" | "VOTE_INVALID_VALIDITY" | "VOTE_MOMENT_BEFORE_VALIDITY_FROM" | "VOTE_STAPLE_INVALID_CONSTRUCTION" | "VOTE_STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_COUNT" | "VOTE_STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_MISSING" | "VOTE_STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_ORDER" | "VOTE_STAPLE_DUPLICATE_VOTE_ISSUER" | "VOTE_STAPLE_PERMANENCE_MISMATCH" | "VOTE_BUILDER_INVALID_CONSTRUCTION" | "VOTE_BUILDER_INVALID_BLOCK_TYPE" | "VOTE_BUILDER_INVALID_SERIAL" | "VOTE_BUILDER_INVALID_VALID_TO_FROM" | "VOTE_BUILDER_INVALID_FEE" | "VOTE_MALFORMED_WRAPPER" | "VOTE_MALFORMED_VOTE_WRAPPER" | "VOTE_MALFORMED_VOTE_CONTENT" | "VOTE_MALFORMED_VOTE_CONTENT_EXTRA_DATA" | "VOTE_MALFORMED_VOTE_VERSION" | "VOTE_MALFORMED_VOTE_SERIAL" | "VOTE_MALFORMED_VOTE_SIGNATURE_INFORMATION" | "VOTE_MALFORMED_VOTE_ISSUER_INFORMATION" | "VOTE_MALFORMED_VOTE_SUBJECT_INFORMATION" | "VOTE_MALFORMED_VOTE_VALIDITY_INFORMATION" | "VOTE_MALFORMED_VOTE_EXTENSIONS" | "VOTE_MALFORMED_VOTE_EXTENSIONS_DATA" | "VOTE_MALFORMED_VOTE_EXTENSIONS_VALUE" | "VOTE_MALFORMED_VOTE_EXTENSIONS_VALUE_OID" | "VOTE_MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL" | "VOTE_MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL_TYPE" | "VOTE_MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_ISSUER" | "VOTE_MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_WRAPPER" | "VOTE_MALFORMED_VOTE_SIGNATURE_SCHEME_ECDSA_INVALID_CURVE" | "VOTE_MALFORMED_VOTE_SIGNATURE_UNSUPPORTED_SCHEME" | "VOTE_MALFORMED_VOTE_SUBJECT_PUBLIC_KEY_INFORMATION" | "VOTE_MALFORMED_VOTE_SIGNATURE_VALUE" | "VOTE_MALFORMED_VOTE_NO_BLOCKS_FOUND" | "VOTE_MALFORMED_STAPLE" | "VOTE_MALFORMED_STAPLE_BLOCKS" | "VOTE_MALFORMED_STAPLE_BLOCKS_AT_LEAST_ONE" | "VOTE_MALFORMED_STAPLE_VOTES" | "VOTE_MALFORMED_STAPLE_VOTES_AT_LEAST_ONE" | "VOTE_MALFORMED_FIND_RDN_INVALID_TYPE" | "VOTE_MALFORMED_FIND_RDN_MUST_HAVE_ONE" | "VOTE_MALFORMED_FIND_RDN_PART_WELL_FORMED" | "VOTE_MALFORMED_FIND_RDN_MUST_BE_SET" | "VOTE_MALFORMED_FIND_RDN_TYPE_MUST_BE_OID" | "VOTE_MALFORMED_HASHES_FROM_VOTE_INVALID_INPUT" | "VOTE_MALFORMED_HASHES_FROM_VOTE_INVALID_TYPE" | "VOTE_MALFORMED_HASHES_FROM_VOTE_INVALID_CONTEXT_SPECIFIC" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_NEEDS_OID" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_HASH_DATA_MUST_BE_SEQUENCE" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_NOT_TWO_ITEMS" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_FUNC" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_TYPE" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_SECOND_MUST_BE_SEQUENCE" | "VOTE_MALFORMED_FEES_AMOUNT" | "VOTE_MALFORMED_FEES_FROM_VOTE_INVALID_INPUT" | "VOTE_MALFORMED_FEES_IN_PERMANENT_VOTE" | "VOTE_MALFORMED_FEES_INVALID_QUOTE_VALUE" | "VOTE_MALFORMED_FEES_MULTIPLE_FEE_EMPTY" | "VOTE_MALFORMED_FEES_PAY_TO_INVALID" | "VOTE_MALFORMED_FEES_TOKEN_NOT_TOKEN" | "VOTE_FEE_IS_QUOTE" | "VOTE_FEE_QUOTE_MISSING_FEES" | "VOTE_FEE_NOT_QUOTE" | "VOTE_MALFORMED_FEES_KIND_MISSING" | "VOTE_MALFORMED_FEES_QUOTE_INVALID" | "LEDGER_BLOCK_ALREADY_EXISTS" | "LEDGER_BLOCK_EXPIRED" | "LEDGER_TRANSACTION_ABORTED" | "LEDGER_INVALID_CHAIN" | "LEDGER_INVALID_NETWORK" | "LEDGER_INVALID_SUBNET" | "LEDGER_INVALID_PERMISSIONS" | "LEDGER_INVALID_OWNER_COUNT" | "LEDGER_INVALID_BALANCE" | "LEDGER_INVALID_SET_REP" | "LEDGER_OPERATION_NOT_SUPPORTED" | "LEDGER_NOT_EMPTY" | "LEDGER_PREVIOUS_ALREADY_USED" | "LEDGER_PREVIOUS_NOT_SEEN" | "LEDGER_SUCCESSOR_VOTE_EXISTS" | "LEDGER_INSUFFICIENT_VOTING_WEIGHT" | "LEDGER_INVALID_ACCOUNT_INFO_KEY" | "LEDGER_RECEIVE_NOT_MET" | "LEDGER_DUPLICATE_VOTE_FOUND" | "LEDGER_CANNOT_EXCHANGE_PERM_VOTE" | "LEDGER_TEMP_VOTE_INCLUDES_SELF" | "LEDGER_BLOCKS_DIFFER_FROM_VOTED_ON" | "LEDGER_NO_PERM_WITHOUT_SELF_TEMP" | "LEDGER_DUPLICATE_VOTE_ISSUER_FOUND" | "LEDGER_OTHER" | "LEDGER_MISSING_BLOCKS" | "LEDGER_FEE_AMOUNT_MISMATCH" | "LEDGER_FEE_TOKEN_MISMATCH" | "LEDGER_FEE_MISSING" | "LEDGER_MISSING_REQUIRED_FEE_BLOCK" | "LEDGER_MULTIPLE_FEE_BLOCK" | "LEDGER_VOTE_WITH_QUOTE" | "LEDGER_QUOTE_MISMATCH" | "LEDGER_REQUIRED_FEE_MISMATCH" | "LEDGER_NOT_SUCCESSOR" | "LEDGER_NOT_OPENING" | "LEDGER_IDEMPOTENT_KEY_EXISTS" | "API_INVALID_LIMIT" | "API_INVALID_SIDE" | "API_INVALID_START" | "API_LIMIT_NOT_NUMBER" | "API_LIMIT_NOT_GREATER_THAN_ZERO" | "API_REP_MISSING" | "API_START_MISSING" | "CLIENT_BUILDER_AMOUNT_IS_ZERO" | "CLIENT_BUILDER_CANNOT_READ_BEFORE_RENDER" | "CLIENT_BUILDER_REQUIRES_PRIVATE_KEY" | "CLIENT_BUILDER_USER_CLIENT_REQUIRED" | "CLIENT_PUBLISH_AID_NOT_AVAILABLE" | "CLIENT_SIGNER_REQUIRES_PRIVATE_KEY" | "CLIENT_SYNC_PUBLISH_FAILED" | "CLIENT_SWAP_INVALID_ACCOUNT_OPTION" | "CLIENT_SWAP_OPTIONS_INVALID" | "CLIENT_SWAP_MISSING_SEND" | "CLIENT_SWAP_MISSING_RECEIVE" | "CLIENT_SWAP_SEND_RECEIVE_ACCOUNT_MISMATCH" | "CLIENT_SWAP_SEND_ACCOUNT_MISMATCH" | "CLIENT_SWAP_SEND_TOKEN_MISMATCH" | "CLIENT_SWAP_SEND_AMOUNT_TOO_LOW" | "CLIENT_SWAP_SEND_AMOUNT_RECEIVE_EXACT_MISMATCH" | "CLIENT_SWAP_REQUEST_TOKEN_MISMATCH" | "CLIENT_SWAP_REQUEST_AMOUNT_MISMATCH" | "KV_TTL_NOT_SUPPORTED" | "KV_KEY_ALREADY_EXISTS")[];
|
|
4
4
|
export type ErrorCode = typeof allFullErrorCodes[number];
|
|
5
5
|
export declare function ExpectErrorCode(code: ErrorCode, test: () => any): Promise<void>;
|
|
6
6
|
export declare class KeetaNetError extends KeetaNetErrorBase<ErrorCode> {
|
package/lib/error/vote.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeetaNetErrorBase } from './base';
|
|
2
2
|
export declare const VoteErrorCodes: readonly ["SERIAL_MISMATCH", "INVALID_VERSION", "INVALID_CONSTRUCTION", "INVALID_CONSTRUCTION_JSON", "SIGNATURE_INVALID", "EXPIRED", "INVALID_VALIDITY", "MOMENT_BEFORE_VALIDITY_FROM", "STAPLE_INVALID_CONSTRUCTION", "STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_COUNT", "STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_MISSING", "STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_ORDER", "STAPLE_DUPLICATE_VOTE_ISSUER", "STAPLE_PERMANENCE_MISMATCH", "BUILDER_INVALID_CONSTRUCTION", "BUILDER_INVALID_BLOCK_TYPE", "BUILDER_INVALID_SERIAL", "BUILDER_INVALID_VALID_TO_FROM", "BUILDER_INVALID_FEE", "MALFORMED_WRAPPER", "MALFORMED_VOTE_WRAPPER", "MALFORMED_VOTE_CONTENT", "MALFORMED_VOTE_CONTENT_EXTRA_DATA", "MALFORMED_VOTE_VERSION", "MALFORMED_VOTE_SERIAL", "MALFORMED_VOTE_SIGNATURE_INFORMATION", "MALFORMED_VOTE_ISSUER_INFORMATION", "MALFORMED_VOTE_SUBJECT_INFORMATION", "MALFORMED_VOTE_VALIDITY_INFORMATION", "MALFORMED_VOTE_SERIAL", "MALFORMED_VOTE_EXTENSIONS", "MALFORMED_VOTE_EXTENSIONS_DATA", "MALFORMED_VOTE_EXTENSIONS_VALUE", "MALFORMED_VOTE_EXTENSIONS_VALUE_OID", "MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL", "MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL_TYPE", "MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_ISSUER", "MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_WRAPPER", "MALFORMED_VOTE_SIGNATURE_SCHEME_ECDSA_INVALID_CURVE", "MALFORMED_VOTE_SIGNATURE_UNSUPPORTED_SCHEME", "MALFORMED_VOTE_SUBJECT_PUBLIC_KEY_INFORMATION", "MALFORMED_VOTE_SIGNATURE_VALUE", "MALFORMED_VOTE_NO_BLOCKS_FOUND", "MALFORMED_STAPLE", "MALFORMED_STAPLE_BLOCKS", "MALFORMED_STAPLE_BLOCKS_AT_LEAST_ONE", "MALFORMED_STAPLE_VOTES", "MALFORMED_STAPLE_VOTES_AT_LEAST_ONE", "MALFORMED_FIND_RDN_INVALID_TYPE", "MALFORMED_FIND_RDN_MUST_HAVE_ONE", "MALFORMED_FIND_RDN_PART_WELL_FORMED", "MALFORMED_FIND_RDN_MUST_BE_SET", "MALFORMED_FIND_RDN_TYPE_MUST_BE_OID", "MALFORMED_HASHES_FROM_VOTE_INVALID_INPUT", "MALFORMED_HASHES_FROM_VOTE_INVALID_TYPE", "MALFORMED_HASHES_FROM_VOTE_INVALID_CONTEXT_SPECIFIC", "MALFORMED_HASHES_FROM_VOTE_DATA_NEEDS_OID", "MALFORMED_HASHES_FROM_VOTE_DATA_HASH_DATA_MUST_BE_SEQUENCE", "MALFORMED_HASHES_FROM_VOTE_DATA_NOT_TWO_ITEMS", "MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_FUNC", "MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_TYPE", "MALFORMED_HASHES_FROM_VOTE_DATA_SECOND_MUST_BE_SEQUENCE", "MALFORMED_FEES_AMOUNT", "MALFORMED_FEES_FROM_VOTE_INVALID_INPUT", "MALFORMED_FEES_IN_PERMANENT_VOTE", "MALFORMED_FEES_INVALID_QUOTE_VALUE", "MALFORMED_FEES_MULTIPLE_FEE_EMPTY", "MALFORMED_FEES_PAY_TO_INVALID", "MALFORMED_FEES_TOKEN_NOT_TOKEN", "FEE_IS_QUOTE", "FEE_QUOTE_MISSING_FEES", "FEE_NOT_QUOTE", "MALFORMED_FEES_KIND_MISSING", "MALFORMED_FEES_QUOTE_INVALID"];
|
|
3
|
-
export declare const FullVoteErrorCodes: ("
|
|
3
|
+
export declare const FullVoteErrorCodes: ("VOTE_INVALID_CONSTRUCTION" | "VOTE_INVALID_VERSION" | "VOTE_SERIAL_MISMATCH" | "VOTE_INVALID_CONSTRUCTION_JSON" | "VOTE_SIGNATURE_INVALID" | "VOTE_EXPIRED" | "VOTE_INVALID_VALIDITY" | "VOTE_MOMENT_BEFORE_VALIDITY_FROM" | "VOTE_STAPLE_INVALID_CONSTRUCTION" | "VOTE_STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_COUNT" | "VOTE_STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_MISSING" | "VOTE_STAPLE_ALL_VOTES_MUST_HAVE_SAME_BLOCKS_ORDER" | "VOTE_STAPLE_DUPLICATE_VOTE_ISSUER" | "VOTE_STAPLE_PERMANENCE_MISMATCH" | "VOTE_BUILDER_INVALID_CONSTRUCTION" | "VOTE_BUILDER_INVALID_BLOCK_TYPE" | "VOTE_BUILDER_INVALID_SERIAL" | "VOTE_BUILDER_INVALID_VALID_TO_FROM" | "VOTE_BUILDER_INVALID_FEE" | "VOTE_MALFORMED_WRAPPER" | "VOTE_MALFORMED_VOTE_WRAPPER" | "VOTE_MALFORMED_VOTE_CONTENT" | "VOTE_MALFORMED_VOTE_CONTENT_EXTRA_DATA" | "VOTE_MALFORMED_VOTE_VERSION" | "VOTE_MALFORMED_VOTE_SERIAL" | "VOTE_MALFORMED_VOTE_SIGNATURE_INFORMATION" | "VOTE_MALFORMED_VOTE_ISSUER_INFORMATION" | "VOTE_MALFORMED_VOTE_SUBJECT_INFORMATION" | "VOTE_MALFORMED_VOTE_VALIDITY_INFORMATION" | "VOTE_MALFORMED_VOTE_EXTENSIONS" | "VOTE_MALFORMED_VOTE_EXTENSIONS_DATA" | "VOTE_MALFORMED_VOTE_EXTENSIONS_VALUE" | "VOTE_MALFORMED_VOTE_EXTENSIONS_VALUE_OID" | "VOTE_MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL" | "VOTE_MALFORMED_VOTE_EXTENSIONS_VALUE_CRITICAL_TYPE" | "VOTE_MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_ISSUER" | "VOTE_MALFORMED_VOTE_SIGNATURE_SCHEME_DOES_NOT_MATCH_WRAPPER" | "VOTE_MALFORMED_VOTE_SIGNATURE_SCHEME_ECDSA_INVALID_CURVE" | "VOTE_MALFORMED_VOTE_SIGNATURE_UNSUPPORTED_SCHEME" | "VOTE_MALFORMED_VOTE_SUBJECT_PUBLIC_KEY_INFORMATION" | "VOTE_MALFORMED_VOTE_SIGNATURE_VALUE" | "VOTE_MALFORMED_VOTE_NO_BLOCKS_FOUND" | "VOTE_MALFORMED_STAPLE" | "VOTE_MALFORMED_STAPLE_BLOCKS" | "VOTE_MALFORMED_STAPLE_BLOCKS_AT_LEAST_ONE" | "VOTE_MALFORMED_STAPLE_VOTES" | "VOTE_MALFORMED_STAPLE_VOTES_AT_LEAST_ONE" | "VOTE_MALFORMED_FIND_RDN_INVALID_TYPE" | "VOTE_MALFORMED_FIND_RDN_MUST_HAVE_ONE" | "VOTE_MALFORMED_FIND_RDN_PART_WELL_FORMED" | "VOTE_MALFORMED_FIND_RDN_MUST_BE_SET" | "VOTE_MALFORMED_FIND_RDN_TYPE_MUST_BE_OID" | "VOTE_MALFORMED_HASHES_FROM_VOTE_INVALID_INPUT" | "VOTE_MALFORMED_HASHES_FROM_VOTE_INVALID_TYPE" | "VOTE_MALFORMED_HASHES_FROM_VOTE_INVALID_CONTEXT_SPECIFIC" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_NEEDS_OID" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_HASH_DATA_MUST_BE_SEQUENCE" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_NOT_TWO_ITEMS" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_FUNC" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_UNSUPPORTED_HASH_TYPE" | "VOTE_MALFORMED_HASHES_FROM_VOTE_DATA_SECOND_MUST_BE_SEQUENCE" | "VOTE_MALFORMED_FEES_AMOUNT" | "VOTE_MALFORMED_FEES_FROM_VOTE_INVALID_INPUT" | "VOTE_MALFORMED_FEES_IN_PERMANENT_VOTE" | "VOTE_MALFORMED_FEES_INVALID_QUOTE_VALUE" | "VOTE_MALFORMED_FEES_MULTIPLE_FEE_EMPTY" | "VOTE_MALFORMED_FEES_PAY_TO_INVALID" | "VOTE_MALFORMED_FEES_TOKEN_NOT_TOKEN" | "VOTE_FEE_IS_QUOTE" | "VOTE_FEE_QUOTE_MISSING_FEES" | "VOTE_FEE_NOT_QUOTE" | "VOTE_MALFORMED_FEES_KIND_MISSING" | "VOTE_MALFORMED_FEES_QUOTE_INVALID")[];
|
|
4
4
|
export type VoteErrorCode = typeof FullVoteErrorCodes[number];
|
|
5
5
|
export default class KeetaNetVoteError extends KeetaNetErrorBase<VoteErrorCode> {
|
|
6
6
|
static readonly isInstance: (obj: any, strict?: boolean) => obj is KeetaNetVoteError;
|
package/lib/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { KeetaNetError as Error } from './error';
|
|
|
11
11
|
import * as ASN1 from './utils/asn1';
|
|
12
12
|
import * as Bloom from './utils/bloom';
|
|
13
13
|
import * as Buffer from './utils/buffer';
|
|
14
|
+
import * as DomainSeparation from './utils/domain-separation';
|
|
14
15
|
import * as Hash from './utils/hash';
|
|
15
16
|
import * as Helper from './utils/helper';
|
|
16
17
|
import * as Initial from './utils/initial';
|
|
@@ -35,11 +36,12 @@ declare const _default: {
|
|
|
35
36
|
ASN1: typeof ASN1;
|
|
36
37
|
Bloom: typeof Bloom;
|
|
37
38
|
Buffer: typeof Buffer;
|
|
39
|
+
Certificate: typeof Certificate;
|
|
40
|
+
Conversion: typeof Conversion;
|
|
41
|
+
DomainSeparation: typeof DomainSeparation;
|
|
38
42
|
Hash: typeof Hash;
|
|
39
43
|
Helper: typeof Helper;
|
|
40
44
|
Initial: typeof Initial;
|
|
41
|
-
Conversion: typeof Conversion;
|
|
42
|
-
Certificate: typeof Certificate;
|
|
43
45
|
};
|
|
44
46
|
};
|
|
45
47
|
export default _default;
|
package/lib/ledger/common.d.ts
CHANGED
|
@@ -62,6 +62,18 @@ export declare function validateNumericValue(value: bigint, block: Pick<Block, '
|
|
|
62
62
|
}): void;
|
|
63
63
|
export declare function validateBlockSignerCount(amount: bigint, network: bigint): void;
|
|
64
64
|
export declare function validateBlockSignerDepth(depth: bigint, network: bigint): void;
|
|
65
|
+
/**
|
|
66
|
+
* Determines if an account type can delegate voting weight via SET_REP.
|
|
67
|
+
*
|
|
68
|
+
* Regular accounts (ECDSA_SECP256K1, ED25519, ECDSA_SECP256R1) can always delegate.
|
|
69
|
+
* Among identifier accounts, only STORAGE accounts can delegate.
|
|
70
|
+
* TOKEN, NETWORK, and MULTISIG identifier accounts cannot delegate.
|
|
71
|
+
*
|
|
72
|
+
* @param keyType - The account key algorithm type to check
|
|
73
|
+
* @returns true if the account type can use SET_REP to delegate, false otherwise
|
|
74
|
+
*
|
|
75
|
+
*/
|
|
76
|
+
export declare function canDelegate(keyType: AccountKeyAlgorithm): boolean;
|
|
65
77
|
/**
|
|
66
78
|
* Compute effects on the ledger from block effects
|
|
67
79
|
*/
|
|
@@ -50,7 +50,7 @@ declare class DynamoDBTransaction extends LedgerStorageTransactionBase {
|
|
|
50
50
|
getHeadBlocks(accounts: GenericAccount[], from: LedgerSelector): Promise<{
|
|
51
51
|
[publicKey: string]: Block | null;
|
|
52
52
|
}>;
|
|
53
|
-
getAccountRep(userAccount:
|
|
53
|
+
getAccountRep(userAccount: GenericAccount | string): Promise<Account | null>;
|
|
54
54
|
getAccountInfo<T extends AccountKeyAlgorithm = AccountKeyAlgorithm>(account: Account<T> | string): Promise<AccountInfoForType<T>>;
|
|
55
55
|
listOwners(identifier: IdentifierAddress): Promise<Account[]>;
|
|
56
56
|
listACLsByEntity(entity: GenericAccount): Promise<ACLRow[]>;
|
|
@@ -90,7 +90,7 @@ export declare class DBDynamoDB extends LedgerStorageBase implements LedgerStora
|
|
|
90
90
|
getHeadBlocks(transaction: DynamoDBTransaction, accounts: GenericAccount[], from: LedgerSelector): Promise<{
|
|
91
91
|
[publicKey: string]: Block | null;
|
|
92
92
|
}>;
|
|
93
|
-
getAccountRep(transaction: DynamoDBTransaction, account:
|
|
93
|
+
getAccountRep(transaction: DynamoDBTransaction, account: GenericAccount | string): Promise<Account | null>;
|
|
94
94
|
getAccountInfo<T extends AccountKeyAlgorithm = AccountKeyAlgorithm>(transaction: DynamoDBTransaction, account: Account<T> | string): Promise<AccountInfoForType<T>>;
|
|
95
95
|
listOwners(transaction: DynamoDBTransaction, identifier: IdentifierAddress): Promise<Account[]>;
|
|
96
96
|
listACLsByPrincipal(transaction: DynamoDBTransaction, principal: GenericAccount, entityList?: GenericAccount[]): Promise<ACLRow[]>;
|
|
@@ -35,7 +35,7 @@ export declare class DBPostgres extends LedgerStorageBase implements LedgerStora
|
|
|
35
35
|
getBalance(transaction: PostgresTransaction, account: GenericAccount, token: TokenAddress, options?: PostgresSelectOptions): Promise<bigint>;
|
|
36
36
|
getAllBalances(transaction: PostgresTransaction, account: GenericAccount): Promise<GetAllBalancesResponse>;
|
|
37
37
|
addPendingVote(transaction: PostgresTransaction, votesAndBlocks: VoteStaple): Promise<void>;
|
|
38
|
-
getAccountRep(transaction: PostgresTransaction, userAccount:
|
|
38
|
+
getAccountRep(transaction: PostgresTransaction, userAccount: GenericAccount | string): Promise<Account | null>;
|
|
39
39
|
/**
|
|
40
40
|
* If an adjustment cannot be made right now, defer it for follow-up
|
|
41
41
|
*/
|
|
@@ -70,7 +70,7 @@ export declare class DBSpanner extends LedgerStorageBase implements LedgerStorag
|
|
|
70
70
|
getBalance(transaction: SpannerTransaction, account: GenericAccount | string, token: TokenAddress | string): Promise<bigint>;
|
|
71
71
|
getAllBalances(transaction: SpannerTransaction, account: GenericAccount): Promise<GetAllBalancesResponse>;
|
|
72
72
|
addPendingVote(transaction: SpannerTransaction, votesAndBlocks: VoteStaple): Promise<void>;
|
|
73
|
-
getAccountRep(transaction: SpannerTransaction, userAccount:
|
|
73
|
+
getAccountRep(transaction: SpannerTransaction, userAccount: GenericAccount | string): Promise<Account | null>;
|
|
74
74
|
/**
|
|
75
75
|
* If an adjustment cannot be made right now, defer it for follow-up
|
|
76
76
|
*/
|
|
@@ -304,7 +304,7 @@ declare const schema: {
|
|
|
304
304
|
readonly delegation: {
|
|
305
305
|
readonly type: "TABLE";
|
|
306
306
|
readonly columns: {
|
|
307
|
-
readonly account: ColumnInterface<"
|
|
307
|
+
readonly account: ColumnInterface<"GENERIC_ACCOUNT", false>;
|
|
308
308
|
readonly delegatedToRep: ColumnInterface<"ACCOUNT", false>;
|
|
309
309
|
};
|
|
310
310
|
readonly key: readonly [Key];
|
|
@@ -34,7 +34,7 @@ export declare class DBSqlite extends LedgerStorageBase implements LedgerStorage
|
|
|
34
34
|
getBalance(transaction: DBSqliteTransaction, account: GenericAccount, token: TokenAddress): Promise<bigint>;
|
|
35
35
|
getAllBalances(transaction: DBSqliteTransaction, account: GenericAccount): Promise<GetAllBalancesResponse>;
|
|
36
36
|
addPendingVote(transaction: DBSqliteTransaction, votesAndBlocks: VoteStaple): Promise<void>;
|
|
37
|
-
getAccountRep(transaction: DBSqliteTransaction, userAccount:
|
|
37
|
+
getAccountRep(transaction: DBSqliteTransaction, userAccount: GenericAccount | string): Promise<Account | null>;
|
|
38
38
|
/**
|
|
39
39
|
* If an adjustment cannot be made right now, defer it for follow-up
|
|
40
40
|
*/
|
package/lib/ledger/index.d.ts
CHANGED
|
@@ -285,7 +285,7 @@ export interface LedgerStorageAPI {
|
|
|
285
285
|
/**
|
|
286
286
|
* Get the Account Representative
|
|
287
287
|
*/
|
|
288
|
-
getAccountRep: (transaction: any, account:
|
|
288
|
+
getAccountRep: (transaction: any, account: GenericAccount | string) => Promise<Account | null>;
|
|
289
289
|
/**
|
|
290
290
|
* Get Votes after a specific moment
|
|
291
291
|
*/
|
|
@@ -350,7 +350,7 @@ declare class LedgerAtomicInterface {
|
|
|
350
350
|
[account: string]: Block | null;
|
|
351
351
|
}>;
|
|
352
352
|
getHeadBlock(account: GenericAccount, from: LedgerSelector): Promise<Block | null>;
|
|
353
|
-
getAccountRep(account:
|
|
353
|
+
getAccountRep(account: GenericAccount | string): Promise<Account | null>;
|
|
354
354
|
getAccountInfo<T extends AccountKeyAlgorithm = AccountKeyAlgorithm>(account: Account<T> | string): Promise<AccountInfoForType<T>>;
|
|
355
355
|
getBlock(blockhash: BlockHash, from?: LedgerSelector): Promise<Block | null>;
|
|
356
356
|
getAccountsBlockHeightInfo(toFetch: {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ValidateASN1 } from './asn1';
|
|
2
|
+
/**
|
|
3
|
+
* Version for Keeta's domain separation namespace schema, encoded as the
|
|
4
|
+
* `INTEGER` field of `namespacePrefixSchema`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const KeetaNamespaceVersion = 0;
|
|
7
|
+
/**
|
|
8
|
+
* Maximum domain separation namespace length in bytes (for strings,
|
|
9
|
+
* this is the UTF-8 byte length, not the character count).
|
|
10
|
+
*/
|
|
11
|
+
export declare const MaxNamespaceLength = 255;
|
|
12
|
+
/**
|
|
13
|
+
* Schema for the namespace prefix:
|
|
14
|
+
*
|
|
15
|
+
* ```asn1
|
|
16
|
+
* NamespacePrefix ::= SEQUENCE {
|
|
17
|
+
* version INTEGER,
|
|
18
|
+
* namespace OCTET STRING,
|
|
19
|
+
* data OCTET STRING
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const namespacePrefixSchema: readonly [typeof ValidateASN1.IsInteger, typeof ValidateASN1.IsOctetString, typeof ValidateASN1.IsOctetString];
|
|
24
|
+
/**
|
|
25
|
+
* Apply the `NamespacePrefix` domain separator to `data`.
|
|
26
|
+
*
|
|
27
|
+
* String namespaces are UTF-8 encoded; ArrayBuffer namespaces are used
|
|
28
|
+
* verbatim. Namespace length MUST be 1-`MaxNamespaceLength` bytes after
|
|
29
|
+
* encoding.
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyNamespace(namespace: string | ArrayBuffer, data: ArrayBuffer): ArrayBuffer;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExternalKeyPair for the Keeta Network which uses Google Cloud KMS
|
|
3
|
+
* for signing operations. This implementation supports ECDSA keys on
|
|
4
|
+
* both SECP256K1 and SECP256R1 curves, with potential for ED25519
|
|
5
|
+
* support in the future.
|
|
6
|
+
*/
|
|
7
|
+
import type { KeyManagementServiceClient } from '@google-cloud/kms';
|
|
8
|
+
import type * as KeetaNet from '../../../client';
|
|
9
|
+
import type { AccountKeyAlgorithm } from '../../../lib/account';
|
|
10
|
+
import type * as crypto from 'node:crypto';
|
|
11
|
+
type KeetaGCPKMSKeyPairPackages = {
|
|
12
|
+
KeyManagementServiceClient: typeof KeyManagementServiceClient;
|
|
13
|
+
KeetaNet: {
|
|
14
|
+
lib: {
|
|
15
|
+
Account: typeof KeetaNet.lib.Account;
|
|
16
|
+
Utils: {
|
|
17
|
+
Helper: typeof KeetaNet.lib.Utils.Helper;
|
|
18
|
+
Buffer: typeof KeetaNet.lib.Utils.Buffer;
|
|
19
|
+
ASN1: typeof KeetaNet.lib.Utils.ASN1;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
crypto: Pick<typeof crypto, 'createPublicKey'>;
|
|
24
|
+
};
|
|
25
|
+
type KeetaGCPKMSKeyPairOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* The GCP KMS key resource name or config object.
|
|
28
|
+
* Format: projects/<project>/locations/<location>/keyRings/<keyRing>/cryptoKeys/<key>
|
|
29
|
+
*/
|
|
30
|
+
key: string | {
|
|
31
|
+
projectId: string;
|
|
32
|
+
locationId: string;
|
|
33
|
+
keyRingId: string;
|
|
34
|
+
keyId: string;
|
|
35
|
+
versionId?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Key type for the KMS key. Optional - will be auto-detected from KMS
|
|
39
|
+
* if not provided, but can be explicitly specified for validation.
|
|
40
|
+
*/
|
|
41
|
+
keyType?: AccountKeyAlgorithm;
|
|
42
|
+
};
|
|
43
|
+
interface KeetaGCPKMSKeyPair extends InstanceType<typeof KeetaNet.lib.Account.ExternalKeyPair> {
|
|
44
|
+
/**
|
|
45
|
+
* The full GCP KMS key resource name used for this key pair.
|
|
46
|
+
*/
|
|
47
|
+
readonly keyName: string;
|
|
48
|
+
}
|
|
49
|
+
interface KeetaGCPKMSKeyPairClass {
|
|
50
|
+
lookup: (options: KeetaGCPKMSKeyPairOptions) => Promise<KeetaGCPKMSKeyPair>;
|
|
51
|
+
}
|
|
52
|
+
export declare function KeetaGCPKMSKeyPairFactory(packages: KeetaGCPKMSKeyPairPackages): Omit<KeetaGCPKMSKeyPairClass, '_Testing'>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,328 @@
|
|
|
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 */ KeetaGCPKMSKeyPairFactory: () => (/* binding */ KeetaGCPKMSKeyPairFactory)
|
|
40
|
+
/* harmony export */ });
|
|
41
|
+
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; }
|
|
42
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
43
|
+
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); }
|
|
44
|
+
/**
|
|
45
|
+
* ExternalKeyPair for the Keeta Network which uses Google Cloud KMS
|
|
46
|
+
* for signing operations. This implementation supports ECDSA keys on
|
|
47
|
+
* both SECP256K1 and SECP256R1 curves, with potential for ED25519
|
|
48
|
+
* support in the future.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Parse a full KMS key name into its components.
|
|
53
|
+
* Example: projects/<project_name>/locations/<location>/keyRings/<keyRingName>/cryptoKeys/<keyName>
|
|
54
|
+
*/
|
|
55
|
+
function parseGCPKMSKeyName(fullName) {
|
|
56
|
+
const pattern = /^projects\/([^/]+)\/locations\/([^/]+)\/keyRings\/([^/]+)\/cryptoKeys\/([^/]+)(?:\/cryptoKeyVersions\/(\d+))?$/;
|
|
57
|
+
const match = fullName.match(pattern);
|
|
58
|
+
if (!match) {
|
|
59
|
+
throw new Error(`Invalid KMS key name format: ${fullName}`);
|
|
60
|
+
}
|
|
61
|
+
const projectId = match[1];
|
|
62
|
+
const locationId = match[2];
|
|
63
|
+
const keyRingId = match[3];
|
|
64
|
+
const keyId = match[4];
|
|
65
|
+
const versionId = match[5];
|
|
66
|
+
if (!projectId || !locationId || !keyRingId || !keyId) {
|
|
67
|
+
throw new Error(`Invalid KMS key name format: ${fullName}`);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
projectId,
|
|
71
|
+
locationId,
|
|
72
|
+
keyRingId,
|
|
73
|
+
keyId,
|
|
74
|
+
versionId
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** @internal */
|
|
79
|
+
|
|
80
|
+
/** @internal */
|
|
81
|
+
|
|
82
|
+
/** @internal */
|
|
83
|
+
|
|
84
|
+
function KeetaGCPKMSKeyPairFactory(packages) {
|
|
85
|
+
let includeTesting = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
86
|
+
if (!packages.KeyManagementServiceClient || !packages.KeetaNet || !packages.crypto) {
|
|
87
|
+
throw new Error('Missing required packages for KeetaGCPKMSKeyPairFactory');
|
|
88
|
+
}
|
|
89
|
+
const KeetaNet = Object.freeze({
|
|
90
|
+
lib: Object.freeze({
|
|
91
|
+
Account: packages.KeetaNet.lib.Account,
|
|
92
|
+
Utils: Object.freeze({
|
|
93
|
+
Helper: Object.freeze({
|
|
94
|
+
bufferToArrayBuffer: packages.KeetaNet.lib.Utils.Helper.bufferToArrayBuffer
|
|
95
|
+
}),
|
|
96
|
+
Buffer: packages.KeetaNet.lib.Utils.Buffer,
|
|
97
|
+
ASN1: packages.KeetaNet.lib.Utils.ASN1
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
const crypto = packages.crypto;
|
|
102
|
+
const bufferToArrayBuffer = KeetaNet.lib.Utils.Helper.bufferToArrayBuffer;
|
|
103
|
+
const Buffer = KeetaNet.lib.Utils.Buffer.Buffer;
|
|
104
|
+
const BufferStorage = KeetaNet.lib.Utils.Buffer.BufferStorage;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Build a full KMS key resource name from components.
|
|
108
|
+
*/
|
|
109
|
+
async function buildGCPKMSKeyName(config) {
|
|
110
|
+
var _cryptoKey$primary$na, _cryptoKey$primary;
|
|
111
|
+
let lookupVersion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
112
|
+
const base = `projects/${config.projectId}/locations/${config.locationId}/keyRings/${config.keyRingId}/cryptoKeys/${config.keyId}`;
|
|
113
|
+
if (config.versionId) {
|
|
114
|
+
return `${base}/cryptoKeyVersions/${config.versionId}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* Just omit the version if it's not requested
|
|
119
|
+
*/
|
|
120
|
+
if (!lookupVersion) {
|
|
121
|
+
return base;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/*
|
|
125
|
+
* If the versionID is missing, get the latest
|
|
126
|
+
* version from KMS.
|
|
127
|
+
*/
|
|
128
|
+
const client = new packages.KeyManagementServiceClient({
|
|
129
|
+
projectId: config.projectId
|
|
130
|
+
});
|
|
131
|
+
const [cryptoKey] = await client.getCryptoKey({
|
|
132
|
+
name: base
|
|
133
|
+
});
|
|
134
|
+
const latestVersionNumber = (_cryptoKey$primary$na = (_cryptoKey$primary = cryptoKey.primary) === null || _cryptoKey$primary === void 0 || (_cryptoKey$primary = _cryptoKey$primary.name) === null || _cryptoKey$primary === void 0 ? void 0 : _cryptoKey$primary.split('/').at(-1)) !== null && _cryptoKey$primary$na !== void 0 ? _cryptoKey$primary$na : '1';
|
|
135
|
+
return `${base}/cryptoKeyVersions/${latestVersionNumber}`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Extract raw EC public key bytes from PEM format.
|
|
140
|
+
*/
|
|
141
|
+
function extractPublicKeyFromPem(pem, cryptoPkg) {
|
|
142
|
+
const publicKey = cryptoPkg.createPublicKey(pem);
|
|
143
|
+
const jwk = publicKey.export({
|
|
144
|
+
format: "jwk"
|
|
145
|
+
});
|
|
146
|
+
if (typeof jwk !== 'object' || jwk === null) {
|
|
147
|
+
throw new Error("Invalid JWK format");
|
|
148
|
+
}
|
|
149
|
+
if (!('x' in jwk) || !('y' in jwk) || typeof jwk.x !== 'string' || typeof jwk.y !== 'string') {
|
|
150
|
+
throw new Error("Invalid EC public key in JWK format");
|
|
151
|
+
}
|
|
152
|
+
const xBuf = Buffer.from(jwk.x, "base64url");
|
|
153
|
+
const yBuf = Buffer.from(jwk.y, "base64url");
|
|
154
|
+
const uncompressed = new Uint8Array(65);
|
|
155
|
+
uncompressed[0] = 0x04;
|
|
156
|
+
uncompressed.set(xBuf, 1);
|
|
157
|
+
uncompressed.set(yBuf, 33);
|
|
158
|
+
return uncompressed;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Convert uncompressed public key to compressed format.
|
|
163
|
+
*/
|
|
164
|
+
function compressPublicKey(uncompressed) {
|
|
165
|
+
if (uncompressed.length !== 65 || uncompressed[0] !== 0x04) {
|
|
166
|
+
throw new Error("Invalid uncompressed public key format");
|
|
167
|
+
}
|
|
168
|
+
const x = uncompressed.slice(1, 33);
|
|
169
|
+
const y = uncompressed.slice(33, 65);
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
171
|
+
const prefix = (y[31] & 1) === 0 ? 0x02 : 0x03;
|
|
172
|
+
const compressed = new Uint8Array(33);
|
|
173
|
+
compressed[0] = prefix;
|
|
174
|
+
compressed.set(x, 1);
|
|
175
|
+
return compressed;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Convert DER-encoded ECDSA signature to raw R||S format (64 bytes).
|
|
180
|
+
*/
|
|
181
|
+
function derSignatureToRaw(derSig, pkgs) {
|
|
182
|
+
const ValidateASN1 = pkgs.KeetaNet.lib.Utils.ASN1.ValidateASN1;
|
|
183
|
+
const bufferToArrayBufferLocal = pkgs.KeetaNet.lib.Utils.Helper.bufferToArrayBuffer;
|
|
184
|
+
const BufferLocal = pkgs.KeetaNet.lib.Utils.Buffer.Buffer;
|
|
185
|
+
const BufferStorageLocal = pkgs.KeetaNet.lib.Utils.Buffer.BufferStorage;
|
|
186
|
+
const validator = new ValidateASN1({
|
|
187
|
+
type: 'struct',
|
|
188
|
+
fieldNames: ['r', 's'],
|
|
189
|
+
contains: {
|
|
190
|
+
r: ValidateASN1.IsInteger,
|
|
191
|
+
s: ValidateASN1.IsInteger
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
const parts = validator.validate(pkgs.KeetaNet.lib.Utils.ASN1.ASN1toJS(bufferToArrayBufferLocal(BufferLocal.from(derSig))));
|
|
195
|
+
const rBuffer = new BufferStorageLocal(parts.contains.r, 32);
|
|
196
|
+
const sBuffer = new BufferStorageLocal(parts.contains.s, 32);
|
|
197
|
+
const r = new Uint8Array(rBuffer.get());
|
|
198
|
+
const s = new Uint8Array(sBuffer.get());
|
|
199
|
+
const rawSig = new Uint8Array(64);
|
|
200
|
+
rawSig.set(r, 0);
|
|
201
|
+
rawSig.set(s, 32);
|
|
202
|
+
return rawSig;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Detect the key algorithm from the algorithm name or curve name.
|
|
207
|
+
*/
|
|
208
|
+
function detectKeyAlgorithm(algorithmOrCurve) {
|
|
209
|
+
if (typeof algorithmOrCurve !== 'string' && algorithmOrCurve !== null && algorithmOrCurve !== undefined) {
|
|
210
|
+
algorithmOrCurve = String(algorithmOrCurve);
|
|
211
|
+
}
|
|
212
|
+
const algoStr = algorithmOrCurve;
|
|
213
|
+
switch (algoStr) {
|
|
214
|
+
case 'EC_SIGN_SECP256K1_SHA256':
|
|
215
|
+
case 'secp256k1':
|
|
216
|
+
return KeetaNet.lib.Account.AccountKeyAlgorithm.ECDSA_SECP256K1;
|
|
217
|
+
case 'EC_SIGN_P256_SHA256':
|
|
218
|
+
case 'prime256v1':
|
|
219
|
+
case 'P-256':
|
|
220
|
+
return KeetaNet.lib.Account.AccountKeyAlgorithm.ECDSA_SECP256R1;
|
|
221
|
+
default:
|
|
222
|
+
throw new Error(`Unsupported algorithm or curve: ${String(algoStr)}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* A KeetaNet ExternalKeyPair implementation backed by Google Cloud KMS.
|
|
228
|
+
*/
|
|
229
|
+
class KeetaGCPKMSKeyPair extends KeetaNet.lib.Account.ExternalKeyPair {
|
|
230
|
+
/**
|
|
231
|
+
* Creates a new KeetaGCPKMSKeyPair instance with the given
|
|
232
|
+
* parameters. Generally this constructor should not be called
|
|
233
|
+
* directly, as the preferred way to access a key is through
|
|
234
|
+
* the static @see KeetaGCPKMSKeyPair.lookup method.
|
|
235
|
+
*/
|
|
236
|
+
constructor(client, keyVersionName, rawPublicKey, keyType) {
|
|
237
|
+
super({
|
|
238
|
+
sign: async (data, options) => {
|
|
239
|
+
// data is already hashed by the SDK (since rawSignatures = false)
|
|
240
|
+
const digest = {
|
|
241
|
+
sha256: Buffer.from(data)
|
|
242
|
+
};
|
|
243
|
+
const [signResponse] = await client.asymmetricSign({
|
|
244
|
+
name: keyVersionName,
|
|
245
|
+
digest: digest
|
|
246
|
+
});
|
|
247
|
+
if (!signResponse.signature) {
|
|
248
|
+
throw new Error("No signature returned from KMS");
|
|
249
|
+
}
|
|
250
|
+
const derSigBuffer = Buffer.from(signResponse.signature);
|
|
251
|
+
if (options !== null && options !== void 0 && options.forCert) {
|
|
252
|
+
return new BufferStorage(derSigBuffer, derSigBuffer.byteLength);
|
|
253
|
+
}
|
|
254
|
+
const derSig = new Uint8Array(derSigBuffer);
|
|
255
|
+
let signature;
|
|
256
|
+
switch (keyType) {
|
|
257
|
+
case KeetaNet.lib.Account.AccountKeyAlgorithm.ECDSA_SECP256K1:
|
|
258
|
+
case KeetaNet.lib.Account.AccountKeyAlgorithm.ECDSA_SECP256R1:
|
|
259
|
+
signature = KeetaNet.lib.Account.KeyPairs[keyType].signatureFromDER([...derSig]);
|
|
260
|
+
break;
|
|
261
|
+
default:
|
|
262
|
+
throw new Error(`Unsupported key type for signature conversion: ${keyType}`);
|
|
263
|
+
}
|
|
264
|
+
return signature;
|
|
265
|
+
},
|
|
266
|
+
supportsEncryption: false
|
|
267
|
+
}, rawPublicKey, keyType, false);
|
|
268
|
+
this.keyName = keyVersionName;
|
|
269
|
+
Object.freeze(this);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Lookup (or open) an existing GCP KMS key and create a
|
|
274
|
+
* KeetaGCPKMSKeyPair instance for it.
|
|
275
|
+
*/
|
|
276
|
+
static async lookup(options) {
|
|
277
|
+
var _options$keyType;
|
|
278
|
+
let keyConfig;
|
|
279
|
+
if (typeof options.key === 'string') {
|
|
280
|
+
keyConfig = parseGCPKMSKeyName(options.key);
|
|
281
|
+
} else {
|
|
282
|
+
keyConfig = options.key;
|
|
283
|
+
}
|
|
284
|
+
const client = new packages.KeyManagementServiceClient({
|
|
285
|
+
projectId: keyConfig.projectId
|
|
286
|
+
});
|
|
287
|
+
const keyVersionName = await buildGCPKMSKeyName(keyConfig);
|
|
288
|
+
const [publicKeyResponse] = await client.getPublicKey({
|
|
289
|
+
name: keyVersionName
|
|
290
|
+
});
|
|
291
|
+
const detectedKeyType = detectKeyAlgorithm(publicKeyResponse.algorithm);
|
|
292
|
+
const keyType = (_options$keyType = options.keyType) !== null && _options$keyType !== void 0 ? _options$keyType : detectedKeyType;
|
|
293
|
+
if (options.keyType !== undefined && options.keyType !== detectedKeyType) {
|
|
294
|
+
throw new Error(`Key type mismatch: expected ${options.keyType}, but KMS key has ${detectedKeyType}`);
|
|
295
|
+
}
|
|
296
|
+
if (!publicKeyResponse.pem) {
|
|
297
|
+
throw new Error("No public key PEM data available from KMS");
|
|
298
|
+
}
|
|
299
|
+
const uncompressedPublicKey = extractPublicKeyFromPem(publicKeyResponse.pem, crypto);
|
|
300
|
+
const compressedPublicKey = compressPublicKey(uncompressedPublicKey);
|
|
301
|
+
return new KeetaGCPKMSKeyPair(client, keyVersionName, bufferToArrayBuffer(Buffer.from(compressedPublicKey)), keyType);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/** @internal */
|
|
305
|
+
_defineProperty(KeetaGCPKMSKeyPair, "_Testing", {
|
|
306
|
+
parseKeyName: parseGCPKMSKeyName,
|
|
307
|
+
buildKeyName: buildGCPKMSKeyName,
|
|
308
|
+
extractPublicKeyFromPem: extractPublicKeyFromPem,
|
|
309
|
+
derSignatureToRaw: derSignatureToRaw
|
|
310
|
+
});
|
|
311
|
+
if (!includeTesting) {
|
|
312
|
+
/**
|
|
313
|
+
* The _Testing property is only included for testing
|
|
314
|
+
* so remove it if we're not including testing.
|
|
315
|
+
*/
|
|
316
|
+
// @ts-ignore
|
|
317
|
+
delete KeetaGCPKMSKeyPair._Testing;
|
|
318
|
+
}
|
|
319
|
+
Object.freeze(KeetaGCPKMSKeyPair);
|
|
320
|
+
Object.freeze(KeetaGCPKMSKeyPair.prototype);
|
|
321
|
+
return KeetaGCPKMSKeyPair;
|
|
322
|
+
}
|
|
323
|
+
Object.freeze(KeetaGCPKMSKeyPairFactory);
|
|
324
|
+
var __webpack_export_target__ = exports;
|
|
325
|
+
for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
|
|
326
|
+
if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
|
|
327
|
+
/******/ })()
|
|
328
|
+
;
|
|
@@ -150,7 +150,5 @@ interface KeetaPasskeyPRFKeyPairClass {
|
|
|
150
150
|
lookup: (options?: KeetaPasskeyPRFKeyPairLookupOptions) => Promise<KeetaPasskeyPRFKeyPair>;
|
|
151
151
|
generate: (options: KeetaPasskeyPRFKeyPairGenerateOptions) => Promise<KeetaPasskeyPRFKeyPair>;
|
|
152
152
|
}
|
|
153
|
-
export declare function KeetaPasskeyPRFKeyPairFactory(packages: KeetaPasskeyPRFKeyPairPackages
|
|
154
|
-
export declare function KeetaPasskeyPRFKeyPairFactory(packages: KeetaPasskeyPRFKeyPairPackages, includeTesting?: false): Omit<KeetaPasskeyPRFKeyPairClass, '_Testing'>;
|
|
155
|
-
export declare function KeetaPasskeyPRFKeyPairFactory(packages: KeetaPasskeyPRFKeyPairPackages, includeTesting?: boolean): KeetaPasskeyPRFKeyPairClass;
|
|
153
|
+
export declare function KeetaPasskeyPRFKeyPairFactory(packages: KeetaPasskeyPRFKeyPairPackages): Omit<KeetaPasskeyPRFKeyPairClass, '_Testing'>;
|
|
156
154
|
export {};
|
|
@@ -64,6 +64,12 @@ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.h
|
|
|
64
64
|
* credential.
|
|
65
65
|
*/
|
|
66
66
|
|
|
67
|
+
/** @internal */
|
|
68
|
+
|
|
69
|
+
/** @internal */
|
|
70
|
+
|
|
71
|
+
/** @internal */
|
|
72
|
+
|
|
67
73
|
function KeetaPasskeyPRFKeyPairFactory(packages) {
|
|
68
74
|
var _KeetaPasskeyPRFKeyPair;
|
|
69
75
|
let includeTesting = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
package/lib/utils/helper.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _crypto from 'crypto';
|
|
2
2
|
import { inspect as nodeUtilsInspect, types as nodeUtilsTypes } from 'util';
|
|
3
3
|
import type { JSONSerializable } from './conversion';
|
|
4
|
+
export declare function getTypedObjectEntries<T extends object>(obj: T): Array<[keyof T, T[keyof T]]>;
|
|
4
5
|
export type DistributiveOmit<T, P extends PropertyKey> = T extends T ? Omit<T, P> : never;
|
|
5
6
|
export declare function validateBase64ToBuffer(input: string): Buffer;
|
|
6
7
|
export declare function bufferToArrayBuffer(input: Buffer): ArrayBuffer;
|