@sphereon/ssi-sdk-ext.key-utils 0.26.1-next.11 → 0.26.1-next.14

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/src/jwk-jcs.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { TextDecoder, TextEncoder } from 'web-encoding'
2
- import isPlainObject from 'lodash.isplainobject'
3
- import type { ByteView } from 'multiformats/codecs/interface'
1
+ import type {ByteView} from 'multiformats/codecs/interface'
2
+ import {TextDecoder, TextEncoder} from 'web-encoding'
4
3
 
5
4
  const textEncoder = new TextEncoder()
6
5
  const textDecoder = new TextDecoder()
@@ -22,9 +21,9 @@ function check(value: unknown, description: string) {
22
21
  *
23
22
  * @param value - The value to check.
24
23
  */
25
- function validatePlainObject(value: unknown) {
26
- if (!isPlainObject(value)) {
27
- throw new Error('JWK must be an object')
24
+ function assertObject(value: unknown) {
25
+ if (!value || typeof (value) !== 'object') {
26
+ throw new Error('Value must be an object')
28
27
  }
29
28
  }
30
29
 
@@ -36,8 +35,8 @@ function validatePlainObject(value: unknown) {
36
35
  *
37
36
  * @param jwk - The JWK to check.
38
37
  */
39
- function validateJwk(jwk: any) {
40
- validatePlainObject(jwk)
38
+ export function validateJwk(jwk: any) {
39
+ assertObject(jwk)
41
40
  // Check JWK required members based on the key type
42
41
  switch (jwk.kty) {
43
42
  /**
@@ -3,7 +3,7 @@ import { IKey, MinimalImportableKey } from '@veramo/core'
3
3
  export const JWK_JCS_PUB_NAME = 'jwk_jcs-pub' as const
4
4
  export const JWK_JCS_PUB_PREFIX = 0xeb51
5
5
 
6
- export type TKeyType = 'Ed25519' | 'Secp256k1' | 'Secp256r1' | 'X25519' | 'Bls12381G1' | 'Bls12381G2' | 'RSA'
6
+ export type TKeyType = 'Ed25519' | 'Secp256k1' | 'Secp256r1' | 'Secp384r1' | 'Secp521r1' | 'X25519' | 'Bls12381G1' | 'Bls12381G2' | 'RSA'
7
7
 
8
8
  export enum Key {
9
9
  Ed25519 = 'Ed25519',
@@ -36,7 +36,7 @@ export interface IImportProvidedOrGeneratedKeyArgs {
36
36
  }
37
37
  export interface IKeyOpts {
38
38
  key?: Partial<MinimalImportableKey> // Optional key to import with only privateKeyHex mandatory. If not specified a key with random kid will be created
39
- type?: TKeyType // The key type. Defaults to Secp256k1
39
+ type?: Exclude<TKeyType, 'Secp384r1' | 'Secp521r1'> // The key type. Defaults to Secp256k1. The exclude is there as we do not support it yet for key generation
40
40
  use?: JwkKeyUse // The key use
41
41
  x509?: X509Opts
42
42
  }
@@ -55,5 +55,7 @@ export type SignatureAlgorithmFromKeyTypeArgs = {
55
55
  }
56
56
 
57
57
  export type KeyTypeFromCryptographicSuiteArgs = {
58
- suite: string
58
+ crv?: string
59
+ kty?: string
60
+ alg?: string
59
61
  }