@sphereon/ssi-sdk-ext.jwt-service 0.28.1-feature.esm.cjs.9 → 0.28.1-feature.jose.vcdm.20
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/index.cjs +28430 -5497
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27639 -4734
- package/dist/index.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +16 -15
- package/plugin.schema.json +28331 -5428
- package/src/agent/JwtService.ts +19 -19
- package/src/functions/JWE.ts +15 -17
- package/src/functions/index.ts +17 -12
- package/src/types/IJwtService.ts +4 -4
package/src/agent/JwtService.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Loggers } from '@sphereon/ssi-types'
|
|
2
|
+
import type { IAgentPlugin } from '@veramo/core'
|
|
3
|
+
const logger = Loggers.DEFAULT.get("sphereon:jwt-service")
|
|
3
4
|
import { importJWK } from 'jose'
|
|
4
5
|
|
|
5
6
|
// @ts-ignore
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import { toString } from 'uint8arrays/to-string'
|
|
7
|
+
import * as u8a from 'uint8arrays'
|
|
8
|
+
const { fromString } = u8a
|
|
9
9
|
import {
|
|
10
10
|
createJwsCompact,
|
|
11
|
-
CreateJwsCompactArgs,
|
|
12
|
-
CreateJwsFlattenedArgs,
|
|
13
|
-
CreateJwsJsonArgs,
|
|
11
|
+
type CreateJwsCompactArgs,
|
|
12
|
+
type CreateJwsFlattenedArgs,
|
|
13
|
+
type CreateJwsJsonArgs,
|
|
14
14
|
createJwsJsonFlattened,
|
|
15
15
|
createJwsJsonGeneral,
|
|
16
|
-
DecryptJweCompactJwtArgs,
|
|
17
|
-
EncryptJweCompactJwtArgs,
|
|
18
|
-
IJwsValidationResult,
|
|
19
|
-
IJwtService,
|
|
20
|
-
IRequiredContext,
|
|
16
|
+
type DecryptJweCompactJwtArgs,
|
|
17
|
+
type EncryptJweCompactJwtArgs,
|
|
18
|
+
type IJwsValidationResult,
|
|
19
|
+
type IJwtService,
|
|
20
|
+
type IRequiredContext,
|
|
21
21
|
jweAlg,
|
|
22
22
|
jweEnc,
|
|
23
|
-
JwsJsonFlattened,
|
|
24
|
-
JwsJsonGeneral,
|
|
25
|
-
JwtCompactResult,
|
|
23
|
+
type JwsJsonFlattened,
|
|
24
|
+
type JwsJsonGeneral,
|
|
25
|
+
type JwtCompactResult,
|
|
26
26
|
JwtLogger,
|
|
27
|
-
PreparedJwsObject,
|
|
27
|
+
type PreparedJwsObject,
|
|
28
28
|
prepareJwsObject,
|
|
29
29
|
schema,
|
|
30
30
|
verifyJws,
|
|
31
|
-
VerifyJwsArgs,
|
|
31
|
+
type VerifyJwsArgs,
|
|
32
32
|
} from '..'
|
|
33
33
|
import { CompactJwtEncrypter } from '../functions/JWE'
|
|
34
34
|
|
|
@@ -72,7 +72,7 @@ export class JwtService implements IAgentPlugin {
|
|
|
72
72
|
const { payload, protectedHeader = { alg: args.alg, enc: args.enc }, recipientKey, issuer, expirationTime, audience } = args
|
|
73
73
|
|
|
74
74
|
try {
|
|
75
|
-
debug(`JWE Encrypt: ${JSON.stringify(args, null, 2)}`)
|
|
75
|
+
logger.debug(`JWE Encrypt: ${JSON.stringify(args, null, 2)}`)
|
|
76
76
|
|
|
77
77
|
const alg = jweAlg(args.alg) ?? jweAlg(protectedHeader.alg) ?? 'ECDH-ES'
|
|
78
78
|
const enc = jweEnc(args.enc) ?? jweEnc(protectedHeader.enc) ?? 'A256GCM'
|
package/src/functions/JWE.ts
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import { defaultRandomSource, randomBytes, RandomSource } from '@stablelib/random'
|
|
1
|
+
import { defaultRandomSource, randomBytes, type RandomSource } from '@stablelib/random'
|
|
2
2
|
import { base64ToBytes, bytesToBase64url, decodeBase64url } from '@veramo/utils'
|
|
3
3
|
import * as jose from 'jose'
|
|
4
|
-
import { JWEKeyManagementHeaderParameters, JWTDecryptOptions } from 'jose'
|
|
4
|
+
import type { JWEKeyManagementHeaderParameters, JWTDecryptOptions } from 'jose'
|
|
5
|
+
// // @ts-ignore
|
|
6
|
+
// import type { KeyLike } from 'jose/dist/types/types'
|
|
7
|
+
export type KeyLike = { type: string }
|
|
5
8
|
// @ts-ignore
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import { fromString } from 'uint8arrays/from-string'
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
import { toString } from 'uint8arrays/to-string'
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
import { concat } from 'uint8arrays/concat'
|
|
9
|
+
import * as u8a from 'uint8arrays'
|
|
10
|
+
const { fromString, toString, concat } = u8a
|
|
13
11
|
import {
|
|
14
|
-
JweAlg,
|
|
12
|
+
type JweAlg,
|
|
15
13
|
JweAlgs,
|
|
16
|
-
JweEnc,
|
|
14
|
+
type JweEnc,
|
|
17
15
|
JweEncs,
|
|
18
|
-
JweHeader,
|
|
19
|
-
JweJsonGeneral,
|
|
20
|
-
JweProtectedHeader,
|
|
21
|
-
JweRecipient,
|
|
22
|
-
JweRecipientUnprotectedHeader,
|
|
23
|
-
JwsPayload,
|
|
16
|
+
type JweHeader,
|
|
17
|
+
type JweJsonGeneral,
|
|
18
|
+
type JweProtectedHeader,
|
|
19
|
+
type JweRecipient,
|
|
20
|
+
type JweRecipientUnprotectedHeader,
|
|
21
|
+
type JwsPayload,
|
|
24
22
|
} from '../types/IJwtService'
|
|
25
23
|
|
|
26
24
|
export interface EncryptionResult {
|
package/src/functions/index.ts
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureManagedIdentifierResult,
|
|
3
|
-
ExternalIdentifierDidOpts,
|
|
4
|
-
ExternalIdentifierX5cOpts,
|
|
5
|
-
IIdentifierResolution,
|
|
3
|
+
type ExternalIdentifierDidOpts,
|
|
4
|
+
type ExternalIdentifierX5cOpts,
|
|
5
|
+
type IIdentifierResolution,
|
|
6
6
|
isManagedIdentifierDidResult,
|
|
7
7
|
isManagedIdentifierX5cResult,
|
|
8
|
-
ManagedIdentifierMethod,
|
|
9
|
-
ManagedIdentifierResult,
|
|
8
|
+
type ManagedIdentifierMethod,
|
|
9
|
+
type ManagedIdentifierResult,
|
|
10
10
|
resolveExternalJwkIdentifier,
|
|
11
11
|
} from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
12
12
|
import { verifyRawSignature } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
13
|
-
import { JWK } from '@sphereon/ssi-types'
|
|
14
|
-
import { IAgentContext } from '@veramo/core'
|
|
13
|
+
import type { JWK } from '@sphereon/ssi-types'
|
|
14
|
+
import type { IAgentContext } from '@veramo/core'
|
|
15
15
|
import { base64ToBytes, bytesToBase64url, decodeJoseBlob, encodeJoseBlob } from '@veramo/utils'
|
|
16
16
|
// @ts-ignore
|
|
17
|
-
import
|
|
17
|
+
import * as u8a from 'uint8arrays'
|
|
18
|
+
const { fromString } = u8a
|
|
18
19
|
|
|
19
|
-
import {
|
|
20
|
+
import type {
|
|
20
21
|
CreateJwsCompactArgs,
|
|
21
22
|
CreateJwsFlattenedArgs,
|
|
22
23
|
CreateJwsJsonArgs,
|
|
23
24
|
IJwsValidationResult,
|
|
24
25
|
IRequiredContext,
|
|
25
|
-
isJwsCompact,
|
|
26
|
-
isJwsJsonFlattened,
|
|
27
|
-
isJwsJsonGeneral,
|
|
28
26
|
JweHeader,
|
|
29
27
|
Jws,
|
|
30
28
|
JwsCompact,
|
|
@@ -40,6 +38,13 @@ import {
|
|
|
40
38
|
VerifyJwsArgs,
|
|
41
39
|
} from '../types/IJwtService'
|
|
42
40
|
|
|
41
|
+
import {
|
|
42
|
+
isJwsCompact,
|
|
43
|
+
isJwsJsonFlattened,
|
|
44
|
+
isJwsJsonGeneral,
|
|
45
|
+
} from '../types/IJwtService'
|
|
46
|
+
|
|
47
|
+
|
|
43
48
|
const payloadToBytes = (payload: string | JwsPayload | Uint8Array): Uint8Array => {
|
|
44
49
|
const isBytes = payload instanceof Uint8Array
|
|
45
50
|
const isString = typeof payload === 'string'
|
package/src/types/IJwtService.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
ExternalIdentifierDidOpts,
|
|
3
3
|
ExternalIdentifierResult,
|
|
4
4
|
ExternalIdentifierX5cOpts,
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
ManagedIdentifierOptsOrResult,
|
|
7
7
|
ManagedIdentifierResult,
|
|
8
8
|
} from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
9
|
-
import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
10
|
-
import { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types'
|
|
11
|
-
import { IAgentContext, IKeyManager, IPluginMethodMap } from '@veramo/core'
|
|
9
|
+
import type { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
10
|
+
import type { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types'
|
|
11
|
+
import type { IAgentContext, IKeyManager, IPluginMethodMap } from '@veramo/core'
|
|
12
12
|
|
|
13
13
|
export type IRequiredContext = IAgentContext<IIdentifierResolution & IKeyManager> // could we still interop with Veramo?
|
|
14
14
|
|