@reallyme/jose 0.4.6 → 0.5.1

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/dist/proto.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { file_reallyme_jose_v1_jose, JoseBackendErrorSchema, JoseCompactResultSchema, JoseErrorReason, JoseErrorReasonSchema, JoseErrorSchema, JoseExpectedBytesSchema, JoseExpectedStringSchema, JoseJweContentEncryptionAlgorithm, JoseJweContentEncryptionAlgorithmSchema, JoseJweDecryptRequestSchema, JoseJweDecryptResponseSchema, JoseJweEncryptRequestSchema, JoseJweEncryptResponseSchema, JoseJweHeaderValidationPolicySchema, JoseJweKeyManagementAlgorithm, JoseJweKeyManagementAlgorithmSchema, JoseJwePlaintextResultSchema, JoseJwsSignRequestSchema, JoseJwsSignResponseSchema, JoseJwsVerifyRequestSchema, JoseJwsVerifyResponseSchema, JoseJwtClaimsResultSchema, JoseJwtDecodeUnsignedRequestSchema, JoseJwtDecodeUnsignedResponseSchema, JoseJwtEncodeUnsignedRequestSchema, JoseJwtEncodeUnsignedResponseSchema, JoseJwtHeaderValidationPolicySchema, JoseJwtSignRequestSchema, JoseJwtSignResponseSchema, JoseJwtTemporalValidationPolicySchema, JoseJwtVerifyRequestSchema, JoseJwtVerifyResponseSchema, JoseOperationContractVersion, JoseOperationContractVersionSchema, JoseOperationRequestSchema, JoseOperationResponseSchema, JosePrimitiveErrorSchema, JoseProviderErrorSchema, JoseSignatureAlgorithm, JoseSignatureAlgorithmSchema, JoseVerifyResultSchema, } from "./proto/generated/reallyme/jose/v1/jose_pb.js";
2
- export type { JoseBackendError, JoseCompactResult, JoseError, JoseExpectedBytes, JoseExpectedString, JoseJweDecryptRequest, JoseJweDecryptResponse, JoseJweEncryptRequest, JoseJweEncryptResponse, JoseJweHeaderValidationPolicy, JoseJwePlaintextResult, JoseJwsSignRequest, JoseJwsSignResponse, JoseJwsVerifyRequest, JoseJwsVerifyResponse, JoseJwtClaimsResult, JoseJwtDecodeUnsignedRequest, JoseJwtDecodeUnsignedResponse, JoseJwtEncodeUnsignedRequest, JoseJwtEncodeUnsignedResponse, JoseJwtHeaderValidationPolicy, JoseJwtSignRequest, JoseJwtSignResponse, JoseJwtTemporalValidationPolicy, JoseJwtVerifyRequest, JoseJwtVerifyResponse, JoseOperationRequest, JoseOperationResponse, JosePrimitiveError, JoseProviderError, JoseVerifyResult, } from "./proto/generated/reallyme/jose/v1/jose_pb.js";
1
+ export { file_reallyme_jose_v1_jose, JoseErrorSchema, JosePrimitiveErrorSchema, JoseProviderErrorSchema, JoseBackendErrorSchema, JoseOperationResponseSchema, JoseOperationRequestSchema, JoseJwsSignWithProviderRequestSchema, JoseJwsInspectRequestSchema, JoseInspectedCompactJwsSchema, JoseJwsInspectResponseSchema, JoseJwsVerifyWithProviderRequestSchema, JoseJwsSignRequestSchema, JoseCompactResultSchema, JoseJwsVerifyRequestSchema, JoseVerifyResultSchema, JoseJwtEncodeUnsignedRequestSchema, JoseJwtDecodeUnsignedRequestSchema, JoseJwtClaimsResultSchema, JoseJwtSignRequestSchema, JoseJwtHeaderEncodeOptionsSchema, JoseJwtVerifyRequestSchema, JoseJwtVerificationPolicySchema, JoseJwtSignatureOnlyPolicySchema, JoseJwtTemporalOnlyPolicySchema, JoseJwtTemporalOptionsSchema, JoseJwtHeaderValidationPolicySchema, JoseJwtTemporalValidationPolicySchema, JoseJweEncryptRequestSchema, JoseJweDecryptRequestSchema, JoseExpectedStringSchema, JoseExpectedBytesSchema, JoseJweHeaderValidationPolicySchema, JoseJwePlaintextResultSchema, JoseJwsSignResponseSchema, JoseJwsVerifyResponseSchema, JoseJwtEncodeUnsignedResponseSchema, JoseJwtDecodeUnsignedResponseSchema, JoseJwtSignResponseSchema, JoseJwtVerifyResponseSchema, JoseJweEncryptResponseSchema, JoseJweDecryptResponseSchema, JoseSignatureSignRequestSchema, JoseSignatureVerifyRequestSchema, JoseSignatureResultSchema, JoseValidationResultSchema, JoseSignatureSuiteInfoRequestSchema, JoseSignatureSuiteInfoResultSchema, JoseJwtSignWithProviderRequestSchema, JoseJweProtectedHeaderSchema, JoseJweDeriveKeyRequestSchema, JoseSecretBytesSchema, JoseJweEncryptWithProviderRequestSchema, JoseJwePolicySchema, JoseJweDecryptWithProviderRequestSchema, JoseContractInfoRequestSchema, JoseContractInfoResultSchema, JoseSignatureSignResponseSchema, JoseSignatureVerifyResponseSchema, JoseSignatureSuiteInfoResponseSchema, JoseJwtSignWithProviderResponseSchema, JoseJweDeriveKeyResponseSchema, JoseJweEncryptWithProviderResponseSchema, JoseJweDecryptWithProviderResponseSchema, JoseContractInfoResponseSchema, JoseJwtRegisteredClaimsSchema, JoseJwtAudienceSchema, JoseJwtClaimsParseRequestSchema, JoseJwtClaimsParseResultSchema, JoseJwtClaimsParseResponseSchema, JoseSdkErrorCode, JoseSdkErrorCodeSchema, JoseErrorReason, JoseErrorReasonSchema, JoseSignatureAlgorithm, JoseSignatureAlgorithmSchema, JoseJweKeyManagementAlgorithm, JoseJweKeyManagementAlgorithmSchema, JoseJweHeaderAlgorithm, JoseJweHeaderAlgorithmSchema, JoseJweContentEncryptionAlgorithm, JoseJweContentEncryptionAlgorithmSchema, JoseJweCompressionAlgorithm, JoseJweCompressionAlgorithmSchema, JoseOperationContractVersion, JoseOperationContractVersionSchema, JoseExternalJwsAlgorithm, JoseExternalJwsAlgorithmSchema, JoseNamedCurve, JoseNamedCurveSchema, JoseSignatureEncoding, JoseSignatureEncodingSchema, JoseContractLimit, JoseContractLimitSchema, JoseJwtPolicyLimit, JoseJwtPolicyLimitSchema, JoseJwtClaim, JoseJwtClaimSchema, JoseErrorBranch, JoseErrorBranchSchema, JoseOperationKind, JoseOperationKindSchema, JoseTransportStatus, JoseTransportStatusSchema, JoseNativeAbiVersion, JoseNativeAbiVersionSchema, } from "./proto/generated/reallyme/jose/v1/jose_pb.js";
2
+ export type { JoseError, JosePrimitiveError, JoseProviderError, JoseBackendError, JoseOperationResponse, JoseOperationRequest, JoseJwsSignWithProviderRequest, JoseJwsInspectRequest, JoseInspectedCompactJws, JoseJwsInspectResponse, JoseJwsVerifyWithProviderRequest, JoseJwsSignRequest, JoseCompactResult, JoseJwsVerifyRequest, JoseVerifyResult, JoseJwtEncodeUnsignedRequest, JoseJwtDecodeUnsignedRequest, JoseJwtClaimsResult, JoseJwtSignRequest, JoseJwtHeaderEncodeOptions, JoseJwtVerifyRequest, JoseJwtVerificationPolicy, JoseJwtSignatureOnlyPolicy, JoseJwtTemporalOnlyPolicy, JoseJwtTemporalOptions, JoseJwtHeaderValidationPolicy, JoseJwtTemporalValidationPolicy, JoseJweEncryptRequest, JoseJweDecryptRequest, JoseExpectedString, JoseExpectedBytes, JoseJweHeaderValidationPolicy, JoseJwePlaintextResult, JoseJwsSignResponse, JoseJwsVerifyResponse, JoseJwtEncodeUnsignedResponse, JoseJwtDecodeUnsignedResponse, JoseJwtSignResponse, JoseJwtVerifyResponse, JoseJweEncryptResponse, JoseJweDecryptResponse, JoseSignatureSignRequest, JoseSignatureVerifyRequest, JoseSignatureResult, JoseValidationResult, JoseSignatureSuiteInfoRequest, JoseSignatureSuiteInfoResult, JoseJwtSignWithProviderRequest, JoseJweProtectedHeader, JoseJweDeriveKeyRequest, JoseSecretBytes, JoseJweEncryptWithProviderRequest, JoseJwePolicy, JoseJweDecryptWithProviderRequest, JoseContractInfoRequest, JoseContractInfoResult, JoseSignatureSignResponse, JoseSignatureVerifyResponse, JoseSignatureSuiteInfoResponse, JoseJwtSignWithProviderResponse, JoseJweDeriveKeyResponse, JoseJweEncryptWithProviderResponse, JoseJweDecryptWithProviderResponse, JoseContractInfoResponse, JoseJwtRegisteredClaims, JoseJwtAudience, JoseJwtClaimsParseRequest, JoseJwtClaimsParseResult, JoseJwtClaimsParseResponse, } from "./proto/generated/reallyme/jose/v1/jose_pb.js";
package/dist/proto.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // SPDX-FileCopyrightText: 2026 ReallyMe Technologies Limited
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
- export { file_reallyme_jose_v1_jose, JoseBackendErrorSchema, JoseCompactResultSchema, JoseErrorReason, JoseErrorReasonSchema, JoseErrorSchema, JoseExpectedBytesSchema, JoseExpectedStringSchema, JoseJweContentEncryptionAlgorithm, JoseJweContentEncryptionAlgorithmSchema, JoseJweDecryptRequestSchema, JoseJweDecryptResponseSchema, JoseJweEncryptRequestSchema, JoseJweEncryptResponseSchema, JoseJweHeaderValidationPolicySchema, JoseJweKeyManagementAlgorithm, JoseJweKeyManagementAlgorithmSchema, JoseJwePlaintextResultSchema, JoseJwsSignRequestSchema, JoseJwsSignResponseSchema, JoseJwsVerifyRequestSchema, JoseJwsVerifyResponseSchema, JoseJwtClaimsResultSchema, JoseJwtDecodeUnsignedRequestSchema, JoseJwtDecodeUnsignedResponseSchema, JoseJwtEncodeUnsignedRequestSchema, JoseJwtEncodeUnsignedResponseSchema, JoseJwtHeaderValidationPolicySchema, JoseJwtSignRequestSchema, JoseJwtSignResponseSchema, JoseJwtTemporalValidationPolicySchema, JoseJwtVerifyRequestSchema, JoseJwtVerifyResponseSchema, JoseOperationContractVersion, JoseOperationContractVersionSchema, JoseOperationRequestSchema, JoseOperationResponseSchema, JosePrimitiveErrorSchema, JoseProviderErrorSchema, JoseSignatureAlgorithm, JoseSignatureAlgorithmSchema, JoseVerifyResultSchema, } from "./proto/generated/reallyme/jose/v1/jose_pb.js";
4
+ // Derived from the protobuf contract. Change the schema and regenerate.
5
+ export { file_reallyme_jose_v1_jose, JoseErrorSchema, JosePrimitiveErrorSchema, JoseProviderErrorSchema, JoseBackendErrorSchema, JoseOperationResponseSchema, JoseOperationRequestSchema, JoseJwsSignWithProviderRequestSchema, JoseJwsInspectRequestSchema, JoseInspectedCompactJwsSchema, JoseJwsInspectResponseSchema, JoseJwsVerifyWithProviderRequestSchema, JoseJwsSignRequestSchema, JoseCompactResultSchema, JoseJwsVerifyRequestSchema, JoseVerifyResultSchema, JoseJwtEncodeUnsignedRequestSchema, JoseJwtDecodeUnsignedRequestSchema, JoseJwtClaimsResultSchema, JoseJwtSignRequestSchema, JoseJwtHeaderEncodeOptionsSchema, JoseJwtVerifyRequestSchema, JoseJwtVerificationPolicySchema, JoseJwtSignatureOnlyPolicySchema, JoseJwtTemporalOnlyPolicySchema, JoseJwtTemporalOptionsSchema, JoseJwtHeaderValidationPolicySchema, JoseJwtTemporalValidationPolicySchema, JoseJweEncryptRequestSchema, JoseJweDecryptRequestSchema, JoseExpectedStringSchema, JoseExpectedBytesSchema, JoseJweHeaderValidationPolicySchema, JoseJwePlaintextResultSchema, JoseJwsSignResponseSchema, JoseJwsVerifyResponseSchema, JoseJwtEncodeUnsignedResponseSchema, JoseJwtDecodeUnsignedResponseSchema, JoseJwtSignResponseSchema, JoseJwtVerifyResponseSchema, JoseJweEncryptResponseSchema, JoseJweDecryptResponseSchema, JoseSignatureSignRequestSchema, JoseSignatureVerifyRequestSchema, JoseSignatureResultSchema, JoseValidationResultSchema, JoseSignatureSuiteInfoRequestSchema, JoseSignatureSuiteInfoResultSchema, JoseJwtSignWithProviderRequestSchema, JoseJweProtectedHeaderSchema, JoseJweDeriveKeyRequestSchema, JoseSecretBytesSchema, JoseJweEncryptWithProviderRequestSchema, JoseJwePolicySchema, JoseJweDecryptWithProviderRequestSchema, JoseContractInfoRequestSchema, JoseContractInfoResultSchema, JoseSignatureSignResponseSchema, JoseSignatureVerifyResponseSchema, JoseSignatureSuiteInfoResponseSchema, JoseJwtSignWithProviderResponseSchema, JoseJweDeriveKeyResponseSchema, JoseJweEncryptWithProviderResponseSchema, JoseJweDecryptWithProviderResponseSchema, JoseContractInfoResponseSchema, JoseJwtRegisteredClaimsSchema, JoseJwtAudienceSchema, JoseJwtClaimsParseRequestSchema, JoseJwtClaimsParseResultSchema, JoseJwtClaimsParseResponseSchema, JoseSdkErrorCode, JoseSdkErrorCodeSchema, JoseErrorReason, JoseErrorReasonSchema, JoseSignatureAlgorithm, JoseSignatureAlgorithmSchema, JoseJweKeyManagementAlgorithm, JoseJweKeyManagementAlgorithmSchema, JoseJweHeaderAlgorithm, JoseJweHeaderAlgorithmSchema, JoseJweContentEncryptionAlgorithm, JoseJweContentEncryptionAlgorithmSchema, JoseJweCompressionAlgorithm, JoseJweCompressionAlgorithmSchema, JoseOperationContractVersion, JoseOperationContractVersionSchema, JoseExternalJwsAlgorithm, JoseExternalJwsAlgorithmSchema, JoseNamedCurve, JoseNamedCurveSchema, JoseSignatureEncoding, JoseSignatureEncodingSchema, JoseContractLimit, JoseContractLimitSchema, JoseJwtPolicyLimit, JoseJwtPolicyLimitSchema, JoseJwtClaim, JoseJwtClaimSchema, JoseErrorBranch, JoseErrorBranchSchema, JoseOperationKind, JoseOperationKindSchema, JoseTransportStatus, JoseTransportStatusSchema, JoseNativeAbiVersion, JoseNativeAbiVersionSchema, } from "./proto/generated/reallyme/jose/v1/jose_pb.js";
package/dist/provider.js CHANGED
@@ -1,25 +1,31 @@
1
1
  // SPDX-FileCopyrightText: 2026 ReallyMe Technologies Limited
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
- import { ReallyMeJoseError } from "./errors.js";
4
+ import { ReallyMeJoseError, ReallyMeJoseSdkErrorCode } from "./errors.js";
5
5
  let installedProvider;
6
6
  const requireObject = (value) => {
7
7
  if (typeof value !== "object" || value === null) {
8
- throw new ReallyMeJoseError("provider-failure");
8
+ throw new ReallyMeJoseError(ReallyMeJoseSdkErrorCode.PROVIDER_FAILURE);
9
9
  }
10
10
  return value;
11
11
  };
12
12
  const requireFunction = (module, name) => {
13
- const value = Reflect.get(module, name);
13
+ let value;
14
+ try {
15
+ value = Reflect.get(module, name);
16
+ }
17
+ catch (_error) {
18
+ throw new ReallyMeJoseError(ReallyMeJoseSdkErrorCode.PROVIDER_FAILURE);
19
+ }
14
20
  if (typeof value !== "function") {
15
- throw new ReallyMeJoseError("provider-failure");
21
+ throw new ReallyMeJoseError(ReallyMeJoseSdkErrorCode.PROVIDER_FAILURE);
16
22
  }
17
23
  return (request) => {
18
24
  try {
19
25
  return Reflect.apply(value, undefined, [request]);
20
26
  }
21
27
  catch (_error) {
22
- throw new ReallyMeJoseError("provider-failure");
28
+ throw new ReallyMeJoseError(ReallyMeJoseSdkErrorCode.PROVIDER_FAILURE);
23
29
  }
24
30
  };
25
31
  };
@@ -35,7 +41,7 @@ export const installReallyMeJoseWasmProvider = (module) => {
35
41
  };
36
42
  export const requireReallyMeJoseWasmProvider = () => {
37
43
  if (installedProvider === undefined) {
38
- throw new ReallyMeJoseError("provider-not-installed");
44
+ throw new ReallyMeJoseError(ReallyMeJoseSdkErrorCode.PROVIDER_NOT_INSTALLED);
39
45
  }
40
46
  return installedProvider;
41
47
  };
@@ -1,9 +1,9 @@
1
1
  export declare const MAX_JOSE_BINARY_REQUEST_BYTES = 1048576;
2
2
  export declare const MAX_JOSE_JSON_REQUEST_BYTES = 1572864;
3
- export declare const MAX_JOSE_RESPONSE_BYTES = 1048608;
3
+ export declare const MAX_JOSE_RESPONSE_BYTES: number;
4
4
  export declare const invalidInput: () => never;
5
5
  export declare const resourceLimit: () => never;
6
- export declare const ensureObject: (value: unknown) => void;
6
+ export declare const ensureObjectFields: (value: unknown, allowed: Readonly<Record<string, true>>) => void;
7
7
  export declare const ensureBytes: (value: Uint8Array) => void;
8
8
  export declare const ensureString: (value: string) => void;
9
9
  export declare const ensureBoolean: (value: boolean) => void;
package/dist/validate.js CHANGED
@@ -1,20 +1,36 @@
1
1
  // SPDX-FileCopyrightText: 2026 ReallyMe Technologies Limited
2
2
  //
3
3
  // SPDX-License-Identifier: MIT OR Apache-2.0
4
- import { ReallyMeJoseError } from "./errors.js";
4
+ import { ReallyMeJoseError, ReallyMeJoseSdkErrorCode } from "./errors.js";
5
5
  import { JoseErrorReason } from "./proto/generated/reallyme/jose/v1/jose_pb.js";
6
- export const MAX_JOSE_BINARY_REQUEST_BYTES = 1_048_576;
7
- export const MAX_JOSE_JSON_REQUEST_BYTES = 1_572_864;
8
- export const MAX_JOSE_RESPONSE_BYTES = 1_048_608;
6
+ import { COMPACT_BYTES, PROTO_JSON_BYTES, RESPONSE_OVERHEAD_BYTES } from "./proto/contract-values.js";
7
+ export const MAX_JOSE_BINARY_REQUEST_BYTES = COMPACT_BYTES;
8
+ export const MAX_JOSE_JSON_REQUEST_BYTES = PROTO_JSON_BYTES;
9
+ export const MAX_JOSE_RESPONSE_BYTES = COMPACT_BYTES + RESPONSE_OVERHEAD_BYTES;
9
10
  export const invalidInput = () => {
10
- throw new ReallyMeJoseError("invalid-input");
11
+ throw new ReallyMeJoseError(ReallyMeJoseSdkErrorCode.INVALID_INPUT);
11
12
  };
12
13
  export const resourceLimit = () => {
13
- throw new ReallyMeJoseError("jose-failure", "primitive", JoseErrorReason.COMMON_RESOURCE_LIMIT_EXCEEDED);
14
+ throw new ReallyMeJoseError(ReallyMeJoseSdkErrorCode.JOSE_FAILURE, "primitive", JoseErrorReason.COMMON_RESOURCE_LIMIT_EXCEEDED);
14
15
  };
15
- export const ensureObject = (value) => {
16
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
16
+ export const ensureObjectFields = (value, allowed) => {
17
+ if (typeof value !== "object" || value === null || Array.isArray(value))
18
+ return invalidInput();
19
+ const prototype = Object.getPrototypeOf(value);
20
+ if (prototype !== null && prototype !== Object.prototype)
17
21
  invalidInput();
22
+ for (const field of Object.keys(allowed)) {
23
+ // Optional settings must be absent or owned by this record. A polluted
24
+ // Object.prototype must never supply authorization or verification policy.
25
+ if (!Object.hasOwn(value, field) && field in value)
26
+ invalidInput();
27
+ }
28
+ for (const field of Reflect.ownKeys(value)) {
29
+ if (typeof field !== "string" || !Object.hasOwn(allowed, field))
30
+ invalidInput();
31
+ const descriptor = Object.getOwnPropertyDescriptor(value, field);
32
+ if (descriptor === undefined || !Object.hasOwn(descriptor, "value"))
33
+ invalidInput();
18
34
  }
19
35
  };
20
36
  export const ensureBytes = (value) => {
@@ -84,6 +100,6 @@ export const ensureAggregateLength = (...lengths) => {
84
100
  };
85
101
  export const ensureIndependentBytes = (value, inputs) => {
86
102
  if (inputs.some((input) => input.buffer === value.buffer)) {
87
- throw new ReallyMeJoseError("provider-failure");
103
+ throw new ReallyMeJoseError(ReallyMeJoseSdkErrorCode.PROVIDER_FAILURE);
88
104
  }
89
105
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reallyme/jose",
3
- "version": "0.4.6",
3
+ "version": "0.5.1",
4
4
  "description": "Strict JOSE, JWT, JWS, and JWE for TypeScript through the canonical ReallyMe Rust/WASM operation contract.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "repository": {