@reallyme/crypto 0.3.9 → 0.3.11

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 (66) hide show
  1. package/README.md +10 -11
  2. package/dist/aead.js +1 -1
  3. package/dist/aesKw.js +1 -1
  4. package/dist/algorithms.js +1 -1
  5. package/dist/argon2id.js +1 -1
  6. package/dist/bip340Schnorr.js +1 -1
  7. package/dist/cryptoFacade.d.ts +60 -81
  8. package/dist/cryptoFacade.js +12 -408
  9. package/dist/cryptoFacadeAsymmetric.d.ts +20 -0
  10. package/dist/cryptoFacadeAsymmetric.js +252 -0
  11. package/dist/cryptoFacadeSymmetric.d.ts +27 -0
  12. package/dist/cryptoFacadeSymmetric.js +166 -0
  13. package/dist/digest.js +1 -1
  14. package/dist/ed25519.d.ts +2 -0
  15. package/dist/ed25519.js +45 -4
  16. package/dist/encodeEcdsaDer.js +1 -1
  17. package/dist/errors.js +1 -1
  18. package/dist/hkdf.js +1 -1
  19. package/dist/hmac.d.ts +3 -3
  20. package/dist/hmac.js +8 -5
  21. package/dist/hpke.d.ts +1 -1
  22. package/dist/hpke.js +4 -2
  23. package/dist/index.js +1 -1
  24. package/dist/jwaConcatKdf.js +1 -1
  25. package/dist/jwk.js +46 -11
  26. package/dist/kmac.js +1 -1
  27. package/dist/memory.js +1 -1
  28. package/dist/mlDsa.js +1 -1
  29. package/dist/mlKem.js +1 -1
  30. package/dist/operationResponse.js +1 -1
  31. package/dist/p256Ecdh.js +1 -1
  32. package/dist/p256Ecdsa.js +1 -1
  33. package/dist/p384Ecdh.js +1 -1
  34. package/dist/p384Ecdsa.js +1 -1
  35. package/dist/p521Ecdh.js +1 -1
  36. package/dist/p521Ecdsa.js +1 -1
  37. package/dist/pbkdf2.js +12 -4
  38. package/dist/proto/generated/reallyme/crypto/v1/crypto_pb.js +1 -1
  39. package/dist/proto.d.ts +8 -117
  40. package/dist/proto.js +6 -1085
  41. package/dist/protoAlgorithms.d.ts +21 -0
  42. package/dist/protoAlgorithms.js +323 -0
  43. package/dist/protoErrors.d.ts +27 -0
  44. package/dist/protoErrors.js +275 -0
  45. package/dist/protoIdentifiers.d.ts +14 -0
  46. package/dist/protoIdentifiers.js +112 -0
  47. package/dist/protoJwk.d.ts +10 -0
  48. package/dist/protoJwk.js +204 -0
  49. package/dist/protoValues.d.ts +63 -0
  50. package/dist/protoValues.js +228 -0
  51. package/dist/providerCatalog.js +1 -1
  52. package/dist/rsa.js +1 -1
  53. package/dist/secp256k1.js +1 -1
  54. package/dist/slhDsa.js +1 -1
  55. package/dist/validateBytes.js +1 -1
  56. package/dist/verifyBundledWasmModule.d.ts +63 -0
  57. package/dist/verifyBundledWasmModule.js +80 -0
  58. package/dist/wasm/reallyme_crypto_wasm.d.ts +383 -0
  59. package/dist/wasm/reallyme_crypto_wasm.js +8 -8
  60. package/dist/wasm/reallyme_crypto_wasm_bg.wasm +0 -0
  61. package/dist/wasmModuleTypes.js +1 -1
  62. package/dist/wasmProvider.d.ts +5 -0
  63. package/dist/wasmProvider.js +61 -3
  64. package/dist/x25519.js +1 -1
  65. package/dist/xWing.js +1 -1
  66. package/package.json +6 -5
package/dist/jwk.js CHANGED
@@ -1,10 +1,11 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { p256 } from "@noble/curves/nist.js";
5
5
  import { secp256k1 } from "@noble/curves/secp256k1.js";
6
6
  import { base64urlDecode as codecBase64urlDecodeValue, base64urlEncode as codecBase64urlEncodeValue, canonicalizeJson as codecCanonicalizeJson, ReallyMeCodecError, } from "@reallyme/codec";
7
7
  import { ReallyMeCryptoError } from "./errors.js";
8
+ import { validateEd25519PublicKeyIdentity } from "./ed25519.js";
8
9
  // JSON and protobuf JWKS ingress routes share this limit so neither boundary
9
10
  // can amplify a small public-key record into unbounded curve validation work.
10
11
  export const MAX_JWKS_KEYS = 1_024;
@@ -68,11 +69,27 @@ const ensureExactMembers = (value, allowedNames) => {
68
69
  if (typeof value !== "object" || value === null) {
69
70
  throw new ReallyMeCryptoError("invalid-input");
70
71
  }
71
- for (const name of Reflect.ownKeys(value)) {
72
- if (typeof name !== "string" || !allowedNames.includes(name)) {
72
+ const names = Reflect.ownKeys(value);
73
+ if (names.length > 16) {
74
+ throw new ReallyMeCryptoError("invalid-input");
75
+ }
76
+ for (const name of names) {
77
+ if (typeof name !== "string" ||
78
+ (!allowedNames.includes(name) && name !== "kid" && !name.startsWith("x-"))) {
73
79
  throw new ReallyMeCryptoError("invalid-input");
74
80
  }
75
81
  }
82
+ optionalString(value, "kid");
83
+ };
84
+ const optionalString = (value, name) => {
85
+ if (typeof value !== "object" || value === null) {
86
+ throw new ReallyMeCryptoError("invalid-input");
87
+ }
88
+ const descriptor = Object.getOwnPropertyDescriptor(value, name);
89
+ if (descriptor !== undefined &&
90
+ (!("value" in descriptor) || typeof descriptor.value !== "string")) {
91
+ throw new ReallyMeCryptoError("invalid-input");
92
+ }
76
93
  };
77
94
  const privateJwkMemberNames = [
78
95
  "d",
@@ -199,10 +216,31 @@ const toJcs = (jwk) => {
199
216
  throw mapCodecError(error);
200
217
  }
201
218
  };
219
+ const isCanonicalX25519Identity = (publicKey) => {
220
+ if (publicKey.length !== 32) {
221
+ return false;
222
+ }
223
+ const highByte = publicKey[31];
224
+ const lowByte = publicKey[0];
225
+ if (highByte === undefined || lowByte === undefined || highByte > 0x7f) {
226
+ return false;
227
+ }
228
+ // RFC 7748 agreement accepts non-canonical u-coordinates. JWK identifiers
229
+ // reject p through 2^255-1 so one field element has one encoding.
230
+ return highByte !== 0x7f
231
+ || publicKey.subarray(1, 31).some((byte) => byte !== 0xff)
232
+ || lowByte < 0xed;
233
+ };
202
234
  export const ReallyMeJwk = {
203
235
  toJwk(algorithm, publicKey) {
204
236
  const spec = jwkSpec(algorithm);
205
237
  ensureLength(publicKey, spec.publicKeyLength);
238
+ if (algorithm === "Ed25519") {
239
+ validateEd25519PublicKeyIdentity(publicKey);
240
+ }
241
+ if (algorithm === "X25519" && !isCanonicalX25519Identity(publicKey)) {
242
+ throw new ReallyMeCryptoError("invalid-input");
243
+ }
206
244
  if (spec.kty === "EC") {
207
245
  const ecAlgorithm = spec.crv === "P-256" ? "P-256" : "secp256k1";
208
246
  const uncompressed = decompressEc(ecAlgorithm, publicKey);
@@ -247,10 +285,8 @@ export const ReallyMeJwk = {
247
285
  }
248
286
  if (spec.kty === "EC") {
249
287
  ensureExactMembers(value, ["alg", "crv", "kty", "use", "x", "y"]);
250
- if (readString(value, "alg") !== spec.alg ||
251
- readString(value, "use") !== spec.use) {
252
- throw new ReallyMeCryptoError("invalid-input");
253
- }
288
+ optionalStringMatches(value, "alg", spec.alg);
289
+ optionalStringMatches(value, "use", spec.use);
254
290
  const ecAlgorithm = spec.crv === "P-256" ? "P-256" : "secp256k1";
255
291
  const x = codecBase64urlDecodeCanonical(readString(value, "x"));
256
292
  const y = codecBase64urlDecodeCanonical(readString(value, "y"));
@@ -274,9 +310,7 @@ export const ReallyMeJwk = {
274
310
  }
275
311
  const algorithm = readString(value, "alg");
276
312
  ensureExactMembers(value, ["alg", "kty", "pub", "use"]);
277
- if (readString(value, "use") !== spec.use) {
278
- throw new ReallyMeCryptoError("invalid-input");
279
- }
313
+ optionalStringMatches(value, "use", spec.use);
280
314
  const akpSpec = specFromAlgorithm(algorithm);
281
315
  const publicKey = codecBase64urlDecodeCanonical(readString(value, "pub"));
282
316
  ensureLength(publicKey, akpSpec.publicKeyLength);
@@ -302,7 +336,8 @@ export const ReallyMeJwk = {
302
336
  },
303
337
  fromJwks(value) {
304
338
  return withJwkBoundaryErrors(() => {
305
- ensureExactMembers(value, ["keys"]);
339
+ // RFC 7517 permits additional set-level members. They do not alter the
340
+ // public-key identities extracted from the required keys array.
306
341
  if (typeof value !== "object" || value === null) {
307
342
  throw new ReallyMeCryptoError("invalid-input");
308
343
  }
package/dist/kmac.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { ReallyMeCryptoError } from "./errors.js";
package/dist/memory.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  /**
package/dist/mlDsa.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { ReallyMeCryptoError } from "./errors.js";
package/dist/mlKem.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { ReallyMeCryptoError } from "./errors.js";
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { ReallyMeCryptoError } from "./errors.js";
package/dist/p256Ecdh.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { p256 } from "@noble/curves/nist.js";
package/dist/p256Ecdsa.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { p256 } from "@noble/curves/nist.js";
package/dist/p384Ecdh.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { p384 } from "@noble/curves/nist.js";
package/dist/p384Ecdsa.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { p384 } from "@noble/curves/nist.js";
package/dist/p521Ecdh.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { p521 } from "@noble/curves/nist.js";
package/dist/p521Ecdsa.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { p521 } from "@noble/curves/nist.js";
package/dist/pbkdf2.js CHANGED
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { pbkdf2 } from "@noble/hashes/pbkdf2.js";
@@ -16,6 +16,9 @@ export const PBKDF2_MIN_ITERATIONS = 100_000;
16
16
  export const PBKDF2_MAX_ITERATIONS = 10_000_000;
17
17
  export const PBKDF2_MIN_OUTPUT_LENGTH = 1;
18
18
  export const PBKDF2_MAX_OUTPUT_LENGTH = 4096;
19
+ const PBKDF2_SHA256_OUTPUT_LENGTH = 32;
20
+ const PBKDF2_SHA512_OUTPUT_LENGTH = 64;
21
+ const PBKDF2_MAX_HMAC_EVALUATIONS = 20_000_000;
19
22
  /**
20
23
  * OWASP Password Storage Cheat Sheet minimum iteration counts for deriving a
21
24
  * *new* password key.
@@ -30,7 +33,7 @@ export const ReallyMePbkdf2 = {
30
33
  * {@link PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA256} iterations.
31
34
  */
32
35
  deriveHmacSha256(password, salt, iterations, outputLength) {
33
- validate(password, salt, iterations, outputLength);
36
+ validate(password, salt, iterations, outputLength, PBKDF2_SHA256_OUTPUT_LENGTH);
34
37
  return pbkdf2(sha256, password, salt, { c: iterations, dkLen: outputLength });
35
38
  },
36
39
  /**
@@ -38,11 +41,11 @@ export const ReallyMePbkdf2 = {
38
41
  * {@link PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA512} iterations.
39
42
  */
40
43
  deriveHmacSha512(password, salt, iterations, outputLength) {
41
- validate(password, salt, iterations, outputLength);
44
+ validate(password, salt, iterations, outputLength, PBKDF2_SHA512_OUTPUT_LENGTH);
42
45
  return pbkdf2(sha512, password, salt, { c: iterations, dkLen: outputLength });
43
46
  },
44
47
  };
45
- function validate(password, salt, iterations, outputLength) {
48
+ function validate(password, salt, iterations, outputLength, digestLength) {
46
49
  ensureByteArray(password);
47
50
  ensureByteArray(salt);
48
51
  if (password.length < PBKDF2_MIN_INPUT_LENGTH ||
@@ -57,4 +60,9 @@ function validate(password, salt, iterations, outputLength) {
57
60
  outputLength > PBKDF2_MAX_OUTPUT_LENGTH) {
58
61
  throw new ReallyMeCryptoError("invalid-input");
59
62
  }
63
+ const blockCount = Math.ceil(outputLength / digestLength);
64
+ const evaluations = iterations * blockCount;
65
+ if (!Number.isSafeInteger(evaluations) || evaluations > PBKDF2_MAX_HMAC_EVALUATIONS) {
66
+ throw new ReallyMeCryptoError("invalid-input");
67
+ }
60
68
  }
@@ -1,4 +1,4 @@
1
- // SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
1
+ // SPDX-FileCopyrightText: 2026 ReallyMe LLC
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
4
  import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
package/dist/proto.d.ts CHANGED
@@ -1,119 +1,10 @@
1
- import type { ReallyMeAeadAlgorithm, ReallyMeHashAlgorithm, ReallyMeHpkeSuite, ReallyMeKdfAlgorithm, ReallyMeKemAlgorithm, ReallyMeKeyAgreementAlgorithm, ReallyMeKeyWrapAlgorithm, ReallyMeMacAlgorithm, ReallyMeSignatureAlgorithm } from "./algorithms.js";
2
- import { ReallyMeCryptoError } from "./errors.js";
3
- import type { ReallyMeHpkeSealedMessage, ReallyMeKemEncapsulation, ReallyMeKemKeyPair, ReallyMeKeyAgreementKeyPair, ReallyMeSignatureKeyPair } from "./cryptoFacade.js";
4
- import type { ReallyMeJwkKey, ReallyMeJwksKeySet } from "./jwk.js";
5
1
  export { AeadAlgorithm, AeadAlgorithmSchema, CryptoAlgorithmFamily, CryptoAlgorithmFamilySchema, CryptoAlgorithmIdentifierSchema, CryptoAeadOpenRequestSchema, CryptoAeadOpenResultSchema, CryptoAeadSealRequestSchema, CryptoAeadSealResultSchema, CryptoBackendErrorSchema, CryptoBip340SchnorrSignRequestSchema, CryptoErrorSchema, CryptoErrorReason, CryptoErrorReasonSchema, CryptoHashRequestSchema, CryptoHashResultSchema, CryptoHkdfDeriveRequestSchema, CryptoHkdfDeriveResultSchema, CryptoHpkeOpenRequestSchema, CryptoHpkeOpenResultSchema, CryptoHpkeSealRequestSchema, CryptoHpkeSealedMessageSchema, CryptoJwaConcatKdfSha256DeriveRequestSchema, CryptoJwaConcatKdfSha256DeriveResultSchema, CryptoKdfDeriveKeyRequestSchema, CryptoKdfDeriveKeyResultSchema, CryptoKemEncapsulationSchema, CryptoKemDecapsulateRequestSchema, CryptoKemDecapsulateResultSchema, CryptoKemEncapsulateRequestSchema, CryptoKemDeriveKeyPairRequestSchema, CryptoKemGenerateKeyPairRequestSchema, CryptoKeyAgreementDeriveKeyPairRequestSchema, CryptoKeyAgreementDeriveSharedSecretRequestSchema, CryptoKeyAgreementDeriveSharedSecretResultSchema, CryptoKeyPairSchema, CryptoKeyUnwrapRequestSchema, CryptoKeyUnwrapResultSchema, CryptoKeyWrapRequestSchema, CryptoKeyWrapResultSchema, CryptoMacAuthenticateRequestSchema, CryptoMacAuthenticateResultSchema, CryptoMacVerifyRequestSchema, CryptoOperationRequestSchema, CryptoOperationResponseSchema, CryptoOperationResultSchema, CryptoPrimitiveErrorSchema, CryptoProviderErrorSchema, CryptoProviderCapabilitySchema, CryptoProviderCapabilitySetSchema, CryptoProviderSupportStatus, CryptoProviderSupportStatusSchema, CryptoRsaVerifyRequestSchema, CryptoSignatureDeriveKeyPairRequestSchema, CryptoSignatureGenerateKeyPairRequestSchema, CryptoSignatureSignRequestSchema, CryptoSignatureSignResultSchema, CryptoSignatureVerifyRequestSchema, CryptoVerificationResultSchema, CryptoVerificationStatus, CryptoVerificationStatusSchema, HashAlgorithm, HashAlgorithmSchema, HpkeAeadId, HpkeAeadIdSchema, HpkeKdfId, HpkeKdfIdSchema, HpkeKemId, HpkeKemIdSchema, HpkeSuiteIdentifierSchema, JsonWebKeySchema, JsonWebKeySetSchema, KdfAlgorithm, KdfAlgorithmSchema, KemAlgorithm, KemAlgorithmSchema, KeyAgreementAlgorithm, KeyAgreementAlgorithmSchema, KeyWrapAlgorithm, KeyWrapAlgorithmSchema, MacAlgorithm, MacAlgorithmSchema, MulticodecKeyAlgorithm, MulticodecKeyAlgorithmSchema, SignatureAlgorithm, SignatureAlgorithmSchema, file_reallyme_crypto_v1_crypto, } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
6
2
  export type { CryptoAlgorithmIdentifier, CryptoAeadOpenRequest, CryptoAeadOpenResult, CryptoAeadSealRequest, CryptoAeadSealResult, CryptoBackendError, CryptoBip340SchnorrSignRequest, CryptoError, CryptoHashRequest, CryptoHashResult, CryptoHkdfDeriveRequest, CryptoHkdfDeriveResult, CryptoHpkeOpenRequest, CryptoHpkeOpenResult, CryptoHpkeSealRequest, CryptoHpkeSealedMessage, CryptoJwaConcatKdfSha256DeriveRequest, CryptoJwaConcatKdfSha256DeriveResult, CryptoKdfDeriveKeyRequest, CryptoKdfDeriveKeyResult, CryptoKemEncapsulation, CryptoKemDecapsulateRequest, CryptoKemDecapsulateResult, CryptoKemEncapsulateRequest, CryptoKemDeriveKeyPairRequest, CryptoKemGenerateKeyPairRequest, CryptoKeyAgreementDeriveKeyPairRequest, CryptoKeyAgreementDeriveSharedSecretRequest, CryptoKeyAgreementDeriveSharedSecretResult, CryptoKeyPair, CryptoKeyUnwrapRequest, CryptoKeyUnwrapResult, CryptoKeyWrapRequest, CryptoKeyWrapResult, CryptoMacAuthenticateRequest, CryptoMacAuthenticateResult, CryptoMacVerifyRequest, CryptoOperationRequest, CryptoOperationResponse, CryptoOperationResult, CryptoPrimitiveError, CryptoProviderCapability, CryptoProviderCapabilitySet, CryptoProviderError, CryptoRsaVerifyRequest, CryptoSignatureDeriveKeyPairRequest, CryptoSignatureGenerateKeyPairRequest, CryptoSignatureSignRequest, CryptoSignatureSignResult, CryptoSignatureVerifyRequest, CryptoVerificationResult, HpkeSuiteIdentifier, JsonWebKey, JsonWebKeySet, } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
7
- import { AeadAlgorithm, HashAlgorithm, KdfAlgorithm, KemAlgorithm, KeyAgreementAlgorithm, KeyWrapAlgorithm, MacAlgorithm, MulticodecKeyAlgorithm, SignatureAlgorithm, CryptoAlgorithmFamily, CryptoErrorReason } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
8
- import type { CryptoAlgorithmIdentifier, CryptoError, CryptoHpkeSealedMessage, CryptoKemEncapsulation, CryptoKeyPair, CryptoProviderCapability, CryptoProviderCapabilitySet, CryptoVerificationResult, HpkeSuiteIdentifier, JsonWebKey, JsonWebKeySet } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
9
- export type ReallyMeCryptoWireErrorBranch = "primitive" | "provider" | "backend";
10
- export type ReallyMeCryptoWireError = Readonly<{
11
- branch: ReallyMeCryptoWireErrorBranch;
12
- reason: CryptoErrorReason;
13
- reasonCode?: number;
14
- }>;
15
- export type ReallyMeCryptoWireErrorValidationCode = "unspecified-reason" | "branch-reason-mismatch" | "reason-code-out-of-range";
16
- export type ReallyMeCryptoWireErrorValidationResult = Readonly<{
17
- ok: true;
18
- value: ReallyMeCryptoWireError;
19
- }> | Readonly<{
20
- ok: false;
21
- error: ReallyMeCryptoWireErrorValidationCode;
22
- }>;
23
- export type ReallyMeMulticodecKeyAlgorithm = "ed25519-pub" | "x25519-pub" | "secp256k1-pub" | "p256-pub" | "p384-pub" | "p521-pub" | "ed448-pub" | "rsa-pub" | "mlkem-512-pub" | "mlkem-768-pub" | "mlkem-1024-pub" | "mldsa-44-pub" | "mldsa-65-pub" | "mldsa-87-pub";
24
- export type ReallyMeProviderSupportStatus = "partial" | "provider-aware" | "supported" | "unsupported";
25
- export type ReallyMeProviderCapability = Readonly<{
26
- algorithm: CryptoAlgorithmIdentifier;
27
- family: CryptoAlgorithmFamily;
28
- providerNames: ReadonlyArray<string>;
29
- status: ReallyMeProviderSupportStatus;
30
- usesRust: boolean;
31
- }>;
32
- export type ReallyMeSignatureKeyPairProtoValue = Readonly<{
33
- algorithm: ReallyMeSignatureAlgorithm;
34
- keyPair: ReallyMeSignatureKeyPair;
35
- }>;
36
- export type ReallyMeKeyAgreementKeyPairProtoValue = Readonly<{
37
- algorithm: ReallyMeKeyAgreementAlgorithm;
38
- keyPair: ReallyMeKeyAgreementKeyPair;
39
- }>;
40
- export type ReallyMeKemKeyPairProtoValue = Readonly<{
41
- algorithm: ReallyMeKemAlgorithm;
42
- keyPair: ReallyMeKemKeyPair;
43
- }>;
44
- export type ReallyMeKemEncapsulationProtoValue = Readonly<{
45
- algorithm: ReallyMeKemAlgorithm;
46
- encapsulation: ReallyMeKemEncapsulation;
47
- }>;
48
- export type ReallyMeHpkeSealedMessageProtoValue = Readonly<{
49
- sealedMessage: ReallyMeHpkeSealedMessage;
50
- suite: ReallyMeHpkeSuite;
51
- }>;
52
- export declare const signatureAlgorithmFromProto: (value: SignatureAlgorithm) => ReallyMeSignatureAlgorithm;
53
- export declare const signatureAlgorithmToProto: (value: ReallyMeSignatureAlgorithm) => SignatureAlgorithm;
54
- export declare const hashAlgorithmFromProto: (value: HashAlgorithm) => ReallyMeHashAlgorithm;
55
- export declare const hashAlgorithmToProto: (value: ReallyMeHashAlgorithm) => HashAlgorithm;
56
- export declare const aeadAlgorithmFromProto: (value: AeadAlgorithm) => ReallyMeAeadAlgorithm;
57
- export declare const aeadAlgorithmToProto: (value: ReallyMeAeadAlgorithm) => AeadAlgorithm;
58
- export declare const kemAlgorithmFromProto: (value: KemAlgorithm) => ReallyMeKemAlgorithm;
59
- export declare const kemAlgorithmToProto: (value: ReallyMeKemAlgorithm) => KemAlgorithm;
60
- export declare const keyAgreementAlgorithmFromProto: (value: KeyAgreementAlgorithm) => ReallyMeKeyAgreementAlgorithm;
61
- export declare const keyAgreementAlgorithmToProto: (value: ReallyMeKeyAgreementAlgorithm) => KeyAgreementAlgorithm;
62
- export declare const macAlgorithmFromProto: (value: MacAlgorithm) => ReallyMeMacAlgorithm;
63
- export declare const macAlgorithmToProto: (value: ReallyMeMacAlgorithm) => MacAlgorithm;
64
- export declare const kdfAlgorithmFromProto: (value: KdfAlgorithm) => ReallyMeKdfAlgorithm;
65
- export declare const kdfAlgorithmToProto: (value: ReallyMeKdfAlgorithm) => KdfAlgorithm;
66
- export declare const keyWrapAlgorithmFromProto: (value: KeyWrapAlgorithm) => ReallyMeKeyWrapAlgorithm;
67
- export declare const keyWrapAlgorithmToProto: (value: ReallyMeKeyWrapAlgorithm) => KeyWrapAlgorithm;
68
- export declare const hpkeSuiteFromProto: (value: HpkeSuiteIdentifier) => ReallyMeHpkeSuite;
69
- export declare const hpkeSuiteToProto: (value: ReallyMeHpkeSuite) => HpkeSuiteIdentifier;
70
- export declare const multicodecKeyAlgorithmFromProto: (value: MulticodecKeyAlgorithm) => ReallyMeMulticodecKeyAlgorithm;
71
- export declare const multicodecKeyAlgorithmToProto: (value: ReallyMeMulticodecKeyAlgorithm) => MulticodecKeyAlgorithm;
72
- export declare const cryptoWireErrorToProto: (error: ReallyMeCryptoWireError) => CryptoError;
73
- export declare const cryptoWireErrorFromProto: (value: CryptoError) => ReallyMeCryptoWireError;
74
- export declare const cryptoWireErrorToProtoBytes: (error: ReallyMeCryptoWireError) => Uint8Array;
75
- export declare const cryptoWireErrorFromProtoBytes: (bytes: Uint8Array) => ReallyMeCryptoWireError;
76
- export declare const cryptoWireErrorTryNew: (branch: ReallyMeCryptoWireErrorBranch, reason: CryptoErrorReason) => ReallyMeCryptoWireErrorValidationResult;
77
- export declare const cryptoWireErrorToFacadeError: (error: ReallyMeCryptoWireError) => ReallyMeCryptoError;
78
- export declare const cryptoErrorToProto: (error: ReallyMeCryptoError) => CryptoError;
79
- export declare const cryptoErrorToProtoBytes: (error: ReallyMeCryptoError) => Uint8Array;
80
- export declare const cryptoErrorFromProto: (value: CryptoError) => ReallyMeCryptoError;
81
- export declare const cryptoErrorFromProtoBytes: (bytes: Uint8Array) => ReallyMeCryptoError;
82
- export declare const jsonWebKeyToProto: (key: ReallyMeJwkKey) => JsonWebKey;
83
- export declare const jsonWebKeyToProtoBytes: (key: ReallyMeJwkKey) => Uint8Array;
84
- export declare const jsonWebKeyFromProto: (value: JsonWebKey) => ReallyMeJwkKey;
85
- export declare const jsonWebKeyFromProtoBytes: (bytes: Uint8Array) => ReallyMeJwkKey;
86
- export declare const jsonWebKeySetToProto: (keySet: ReallyMeJwksKeySet) => JsonWebKeySet;
87
- export declare const jsonWebKeySetToProtoBytes: (keySet: ReallyMeJwksKeySet) => Uint8Array;
88
- export declare const jsonWebKeySetFromProto: (value: JsonWebKeySet) => ReallyMeJwksKeySet;
89
- export declare const jsonWebKeySetFromProtoBytes: (bytes: Uint8Array) => ReallyMeJwksKeySet;
90
- export declare const signatureKeyPairToProto: (algorithm: ReallyMeSignatureAlgorithm, keyPair: ReallyMeSignatureKeyPair) => CryptoKeyPair;
91
- export declare const signatureKeyPairToProtoBytes: (algorithm: ReallyMeSignatureAlgorithm, keyPair: ReallyMeSignatureKeyPair) => Uint8Array;
92
- export declare const signatureKeyPairFromProto: (value: CryptoKeyPair) => ReallyMeSignatureKeyPairProtoValue;
93
- export declare const signatureKeyPairFromProtoBytes: (bytes: Uint8Array) => ReallyMeSignatureKeyPairProtoValue;
94
- export declare const keyAgreementKeyPairToProto: (algorithm: ReallyMeKeyAgreementAlgorithm, keyPair: ReallyMeKeyAgreementKeyPair) => CryptoKeyPair;
95
- export declare const keyAgreementKeyPairToProtoBytes: (algorithm: ReallyMeKeyAgreementAlgorithm, keyPair: ReallyMeKeyAgreementKeyPair) => Uint8Array;
96
- export declare const keyAgreementKeyPairFromProto: (value: CryptoKeyPair) => ReallyMeKeyAgreementKeyPairProtoValue;
97
- export declare const keyAgreementKeyPairFromProtoBytes: (bytes: Uint8Array) => ReallyMeKeyAgreementKeyPairProtoValue;
98
- export declare const kemKeyPairToProto: (algorithm: ReallyMeKemAlgorithm, keyPair: ReallyMeKemKeyPair) => CryptoKeyPair;
99
- export declare const kemKeyPairToProtoBytes: (algorithm: ReallyMeKemAlgorithm, keyPair: ReallyMeKemKeyPair) => Uint8Array;
100
- export declare const kemKeyPairFromProto: (value: CryptoKeyPair) => ReallyMeKemKeyPairProtoValue;
101
- export declare const kemKeyPairFromProtoBytes: (bytes: Uint8Array) => ReallyMeKemKeyPairProtoValue;
102
- export declare const kemEncapsulationToProto: (algorithm: ReallyMeKemAlgorithm, encapsulation: ReallyMeKemEncapsulation) => CryptoKemEncapsulation;
103
- export declare const kemEncapsulationToProtoBytes: (algorithm: ReallyMeKemAlgorithm, encapsulation: ReallyMeKemEncapsulation) => Uint8Array;
104
- export declare const kemEncapsulationFromProto: (value: CryptoKemEncapsulation) => ReallyMeKemEncapsulationProtoValue;
105
- export declare const kemEncapsulationFromProtoBytes: (bytes: Uint8Array) => ReallyMeKemEncapsulationProtoValue;
106
- export declare const hpkeSealedMessageToProto: (suite: ReallyMeHpkeSuite, sealedMessage: ReallyMeHpkeSealedMessage) => CryptoHpkeSealedMessage;
107
- export declare const hpkeSealedMessageToProtoBytes: (suite: ReallyMeHpkeSuite, sealedMessage: ReallyMeHpkeSealedMessage) => Uint8Array;
108
- export declare const hpkeSealedMessageFromProto: (value: CryptoHpkeSealedMessage) => ReallyMeHpkeSealedMessageProtoValue;
109
- export declare const hpkeSealedMessageFromProtoBytes: (bytes: Uint8Array) => ReallyMeHpkeSealedMessageProtoValue;
110
- export declare const verificationResultToProto: (algorithm: CryptoAlgorithmIdentifier, valid: boolean) => CryptoVerificationResult;
111
- export declare const verificationErrorToProto: (algorithm: CryptoAlgorithmIdentifier, error: ReallyMeCryptoError) => CryptoVerificationResult;
112
- export declare const verificationResultToProtoBytes: (value: CryptoVerificationResult) => Uint8Array;
113
- export declare const verificationResultFromProtoBytes: (bytes: Uint8Array) => CryptoVerificationResult;
114
- export declare const providerCapabilityToProto: (value: ReallyMeProviderCapability) => CryptoProviderCapability;
115
- export declare const providerCapabilityFromProto: (value: CryptoProviderCapability) => ReallyMeProviderCapability;
116
- export declare const providerCapabilitySetToProto: (values: ReadonlyArray<ReallyMeProviderCapability>) => CryptoProviderCapabilitySet;
117
- export declare const providerCapabilitySetToProtoBytes: (values: ReadonlyArray<ReallyMeProviderCapability>) => Uint8Array;
118
- export declare const providerCapabilitySetFromProto: (value: CryptoProviderCapabilitySet) => readonly ReallyMeProviderCapability[];
119
- export declare const providerCapabilitySetFromProtoBytes: (bytes: Uint8Array) => readonly ReallyMeProviderCapability[];
3
+ export { aeadAlgorithmFromProto, aeadAlgorithmToProto, hashAlgorithmFromProto, hashAlgorithmToProto, hpkeSuiteFromProto, hpkeSuiteToProto, kdfAlgorithmFromProto, kdfAlgorithmToProto, kemAlgorithmFromProto, kemAlgorithmToProto, keyAgreementAlgorithmFromProto, keyAgreementAlgorithmToProto, keyWrapAlgorithmFromProto, keyWrapAlgorithmToProto, macAlgorithmFromProto, macAlgorithmToProto, signatureAlgorithmFromProto, signatureAlgorithmToProto, } from "./protoAlgorithms.js";
4
+ export { multicodecKeyAlgorithmFromProto, multicodecKeyAlgorithmToProto, } from "./protoIdentifiers.js";
5
+ export type { ReallyMeMulticodecKeyAlgorithm } from "./protoIdentifiers.js";
6
+ export { cryptoErrorFromProto, cryptoErrorFromProtoBytes, cryptoErrorToProto, cryptoErrorToProtoBytes, cryptoWireErrorFromProto, cryptoWireErrorFromProtoBytes, cryptoWireErrorToFacadeError, cryptoWireErrorToProto, cryptoWireErrorToProtoBytes, cryptoWireErrorTryNew, } from "./protoErrors.js";
7
+ export type { ReallyMeCryptoWireError, ReallyMeCryptoWireErrorBranch, ReallyMeCryptoWireErrorValidationCode, ReallyMeCryptoWireErrorValidationResult, } from "./protoErrors.js";
8
+ export { jsonWebKeyFromProto, jsonWebKeyFromProtoBytes, jsonWebKeySetFromProto, jsonWebKeySetFromProtoBytes, jsonWebKeySetToProto, jsonWebKeySetToProtoBytes, jsonWebKeyToProto, jsonWebKeyToProtoBytes, } from "./protoJwk.js";
9
+ export { hpkeSealedMessageFromProto, hpkeSealedMessageFromProtoBytes, hpkeSealedMessageToProto, hpkeSealedMessageToProtoBytes, kemEncapsulationFromProto, kemEncapsulationFromProtoBytes, kemEncapsulationToProto, kemEncapsulationToProtoBytes, kemKeyPairFromProto, kemKeyPairFromProtoBytes, kemKeyPairToProto, kemKeyPairToProtoBytes, keyAgreementKeyPairFromProto, keyAgreementKeyPairFromProtoBytes, keyAgreementKeyPairToProto, keyAgreementKeyPairToProtoBytes, providerCapabilityFromProto, providerCapabilitySetFromProto, providerCapabilitySetFromProtoBytes, providerCapabilitySetToProto, providerCapabilitySetToProtoBytes, providerCapabilityToProto, signatureKeyPairFromProto, signatureKeyPairFromProtoBytes, signatureKeyPairToProto, signatureKeyPairToProtoBytes, verificationErrorToProto, verificationResultFromProtoBytes, verificationResultToProto, verificationResultToProtoBytes, } from "./protoValues.js";
10
+ export type { ReallyMeHpkeSealedMessageProtoValue, ReallyMeKemEncapsulationProtoValue, ReallyMeKemKeyPairProtoValue, ReallyMeKeyAgreementKeyPairProtoValue, ReallyMeProviderCapability, ReallyMeProviderSupportStatus, ReallyMeSignatureKeyPairProtoValue, } from "./protoValues.js";