mirror of
https://github.com/danbulant/jose
synced 2026-05-19 04:18:52 +00:00
refactor: remove public API default exports in favour of named ones
This commit is contained in:
parent
cd1ccc6936
commit
a51a9f6770
85 changed files with 251 additions and 485 deletions
|
|
@ -7,7 +7,6 @@
|
|||
- [CompactDecryptResult](jwe_compact_decrypt.md#compactdecryptresult)
|
||||
- [DecryptOptions](jwe_compact_decrypt.md#decryptoptions)
|
||||
- [KeyLike](jwe_compact_decrypt.md#keylike)
|
||||
- [default](jwe_compact_decrypt.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
|
|
@ -34,9 +33,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [compactDecrypt](../functions/jwe_compact_decrypt.compactDecrypt.md)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
- [JWEHeaderParameters](jwe_compact_encrypt.md#jweheaderparameters)
|
||||
- [JWEKeyManagementHeaderParameters](jwe_compact_encrypt.md#jwekeymanagementheaderparameters)
|
||||
- [KeyLike](jwe_compact_encrypt.md#keylike)
|
||||
- [default](jwe_compact_encrypt.md#default)
|
||||
|
||||
### Classes
|
||||
|
||||
|
|
@ -30,9 +29,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [CompactEncrypt](../classes/jwe_compact_encrypt.CompactEncrypt.md)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
- [FlattenedJWE](jwe_flattened_decrypt.md#flattenedjwe)
|
||||
- [JWEHeaderParameters](jwe_flattened_decrypt.md#jweheaderparameters)
|
||||
- [KeyLike](jwe_flattened_decrypt.md#keylike)
|
||||
- [default](jwe_flattened_decrypt.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
|
|
@ -48,9 +47,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [flattenedDecrypt](../functions/jwe_flattened_decrypt.flattenedDecrypt.md)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
- [JWEHeaderParameters](jwe_flattened_encrypt.md#jweheaderparameters)
|
||||
- [JWEKeyManagementHeaderParameters](jwe_flattened_encrypt.md#jwekeymanagementheaderparameters)
|
||||
- [KeyLike](jwe_flattened_encrypt.md#keylike)
|
||||
- [default](jwe_flattened_encrypt.md#default)
|
||||
|
||||
### Classes
|
||||
|
||||
|
|
@ -37,9 +36,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [FlattenedEncrypt](../classes/jwe_flattened_encrypt.FlattenedEncrypt.md)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
- [GeneralDecryptResult](jwe_general_decrypt.md#generaldecryptresult)
|
||||
- [GeneralJWE](jwe_general_decrypt.md#generaljwe)
|
||||
- [KeyLike](jwe_general_decrypt.md#keylike)
|
||||
- [default](jwe_general_decrypt.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
|
|
@ -41,9 +40,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [generalDecrypt](../functions/jwe_general_decrypt.generalDecrypt.md)
|
||||
|
|
|
|||
|
|
@ -2,16 +2,6 @@
|
|||
|
||||
## Table of contents
|
||||
|
||||
### References
|
||||
|
||||
- [default](jwk_embedded.md#default)
|
||||
|
||||
### Functions
|
||||
|
||||
- [EmbeddedJWK](../functions/jwk_embedded.EmbeddedJWK.md)
|
||||
|
||||
## References
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [EmbeddedJWK](../functions/jwk_embedded.EmbeddedJWK.md)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
### References
|
||||
|
||||
- [JWK](jwk_thumbprint.md#jwk)
|
||||
- [default](jwk_thumbprint.md#default)
|
||||
|
||||
### Functions
|
||||
|
||||
|
|
@ -16,9 +15,3 @@
|
|||
### JWK
|
||||
|
||||
Re-exports: [JWK](../interfaces/types.JWK.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [calculateJwkThumbprint](../functions/jwk_thumbprint.calculateJwkThumbprint.md)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
## Table of contents
|
||||
|
||||
### References
|
||||
|
||||
- [default](jwks_remote.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
- [RemoteJWKSetOptions](../interfaces/jwks_remote.RemoteJWKSetOptions.md)
|
||||
|
|
@ -13,9 +9,3 @@
|
|||
### Functions
|
||||
|
||||
- [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md)
|
||||
|
||||
## References
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
- [JWSHeaderParameters](jws_compact_sign.md#jwsheaderparameters)
|
||||
- [KeyLike](jws_compact_sign.md#keylike)
|
||||
- [default](jws_compact_sign.md#default)
|
||||
|
||||
### Classes
|
||||
|
||||
|
|
@ -23,9 +22,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [CompactSign](../classes/jws_compact_sign.CompactSign.md)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
- [CompactVerifyResult](jws_compact_verify.md#compactverifyresult)
|
||||
- [KeyLike](jws_compact_verify.md#keylike)
|
||||
- [VerifyOptions](jws_compact_verify.md#verifyoptions)
|
||||
- [default](jws_compact_verify.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
|
|
@ -34,9 +33,3 @@ ___
|
|||
### VerifyOptions
|
||||
|
||||
Re-exports: [VerifyOptions](../interfaces/types.VerifyOptions.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [compactVerify](../functions/jws_compact_verify.compactVerify.md)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
- [FlattenedJWS](jws_flattened_sign.md#flattenedjws)
|
||||
- [JWSHeaderParameters](jws_flattened_sign.md#jwsheaderparameters)
|
||||
- [KeyLike](jws_flattened_sign.md#keylike)
|
||||
- [default](jws_flattened_sign.md#default)
|
||||
|
||||
### Classes
|
||||
|
||||
|
|
@ -30,9 +29,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [FlattenedSign](../classes/jws_flattened_sign.FlattenedSign.md)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
- [JWSHeaderParameters](jws_flattened_verify.md#jwsheaderparameters)
|
||||
- [KeyLike](jws_flattened_verify.md#keylike)
|
||||
- [VerifyOptions](jws_flattened_verify.md#verifyoptions)
|
||||
- [default](jws_flattened_verify.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
|
|
@ -55,9 +54,3 @@ ___
|
|||
### VerifyOptions
|
||||
|
||||
Re-exports: [VerifyOptions](../interfaces/types.VerifyOptions.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [flattenedVerify](../functions/jws_flattened_verify.flattenedVerify.md)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
- [GeneralJWS](jws_general_sign.md#generaljws)
|
||||
- [JWSHeaderParameters](jws_general_sign.md#jwsheaderparameters)
|
||||
- [KeyLike](jws_general_sign.md#keylike)
|
||||
- [default](jws_general_sign.md#default)
|
||||
|
||||
### Classes
|
||||
|
||||
|
|
@ -34,9 +33,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [GeneralSign](../classes/jws_general_sign.GeneralSign.md)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
- [GeneralVerifyResult](jws_general_verify.md#generalverifyresult)
|
||||
- [KeyLike](jws_general_verify.md#keylike)
|
||||
- [VerifyOptions](jws_general_verify.md#verifyoptions)
|
||||
- [default](jws_general_verify.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
|
|
@ -41,9 +40,3 @@ ___
|
|||
### VerifyOptions
|
||||
|
||||
Re-exports: [VerifyOptions](../interfaces/types.VerifyOptions.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [generalVerify](../functions/jws_general_verify.generalVerify.md)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
- [JWTDecryptResult](jwt_decrypt.md#jwtdecryptresult)
|
||||
- [JWTPayload](jwt_decrypt.md#jwtpayload)
|
||||
- [KeyLike](jwt_decrypt.md#keylike)
|
||||
- [default](jwt_decrypt.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
|
|
@ -42,9 +41,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [jwtDecrypt](../functions/jwt_decrypt.jwtDecrypt.md)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
- [JWEHeaderParameters](jwt_encrypt.md#jweheaderparameters)
|
||||
- [JWTPayload](jwt_encrypt.md#jwtpayload)
|
||||
- [KeyLike](jwt_encrypt.md#keylike)
|
||||
- [default](jwt_encrypt.md#default)
|
||||
|
||||
### Classes
|
||||
|
||||
|
|
@ -30,9 +29,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [EncryptJWT](../classes/jwt_encrypt.EncryptJWT.md)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
- [JWSHeaderParameters](jwt_sign.md#jwsheaderparameters)
|
||||
- [JWTPayload](jwt_sign.md#jwtpayload)
|
||||
- [KeyLike](jwt_sign.md#keylike)
|
||||
- [default](jwt_sign.md#default)
|
||||
|
||||
### Classes
|
||||
|
||||
|
|
@ -30,9 +29,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [SignJWT](../classes/jwt_sign.SignJWT.md)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
- [JWSHeaderParameters](jwt_unsecured.md#jwsheaderparameters)
|
||||
- [JWTPayload](jwt_unsecured.md#jwtpayload)
|
||||
- [default](jwt_unsecured.md#default)
|
||||
|
||||
### Classes
|
||||
|
||||
|
|
@ -27,9 +26,3 @@ ___
|
|||
### JWTPayload
|
||||
|
||||
Re-exports: [JWTPayload](../interfaces/types.JWTPayload.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [UnsecuredJWT](../classes/jwt_unsecured.UnsecuredJWT.md)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
- [JWTPayload](jwt_verify.md#jwtpayload)
|
||||
- [JWTVerifyResult](jwt_verify.md#jwtverifyresult)
|
||||
- [KeyLike](jwt_verify.md#keylike)
|
||||
- [default](jwt_verify.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
|
|
@ -49,9 +48,3 @@ ___
|
|||
### KeyLike
|
||||
|
||||
Re-exports: [KeyLike](../types/types.KeyLike.md)
|
||||
|
||||
___
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [jwtVerify](../functions/jwt_verify.jwtVerify.md)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
## Table of contents
|
||||
|
||||
### References
|
||||
|
||||
- [default](util_decode_protected_header.md#default)
|
||||
|
||||
### Type aliases
|
||||
|
||||
- [ProtectedHeaderParameters](../types/util_decode_protected_header.ProtectedHeaderParameters.md)
|
||||
|
|
@ -13,9 +9,3 @@
|
|||
### Functions
|
||||
|
||||
- [decodeProtectedHeader](../functions/util_decode_protected_header.decodeProtectedHeader.md)
|
||||
|
||||
## References
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [decodeProtectedHeader](../functions/util_decode_protected_header.decodeProtectedHeader.md)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
## Table of contents
|
||||
|
||||
### References
|
||||
|
||||
- [default](util_generate_key_pair.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
- [GenerateKeyPairOptions](../interfaces/util_generate_key_pair.GenerateKeyPairOptions.md)
|
||||
|
|
@ -14,9 +10,3 @@
|
|||
### Functions
|
||||
|
||||
- [generateKeyPair](../functions/util_generate_key_pair.generateKeyPair.md)
|
||||
|
||||
## References
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [generateKeyPair](../functions/util_generate_key_pair.generateKeyPair.md)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
## Table of contents
|
||||
|
||||
### References
|
||||
|
||||
- [default](util_generate_secret.md#default)
|
||||
|
||||
### Interfaces
|
||||
|
||||
- [GenerateSecretOptions](../interfaces/util_generate_secret.GenerateSecretOptions.md)
|
||||
|
|
@ -13,9 +9,3 @@
|
|||
### Functions
|
||||
|
||||
- [generateSecret](../functions/util_generate_secret.generateSecret.md)
|
||||
|
||||
## References
|
||||
|
||||
### default
|
||||
|
||||
Renames and exports: [generateSecret](../functions/util_generate_secret.generateSecret.md)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import decrypt from '../flattened/decrypt.js'
|
||||
import { flattenedDecrypt } from '../flattened/decrypt.js'
|
||||
import { JWEInvalid } from '../../util/errors.js'
|
||||
import { decoder } from '../../lib/buffer_utils.js'
|
||||
import type {
|
||||
|
|
@ -50,7 +50,7 @@ export interface CompactDecryptGetKey extends GetKeyFunction<JWEHeaderParameters
|
|||
* import { compactDecrypt } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
async function compactDecrypt(
|
||||
export async function compactDecrypt(
|
||||
jwe: string | Uint8Array,
|
||||
key: KeyLike | Uint8Array,
|
||||
options?: DecryptOptions,
|
||||
|
|
@ -60,12 +60,12 @@ async function compactDecrypt(
|
|||
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with.
|
||||
* @param options JWE Decryption options.
|
||||
*/
|
||||
async function compactDecrypt(
|
||||
export async function compactDecrypt(
|
||||
jwe: string | Uint8Array,
|
||||
getKey: CompactDecryptGetKey,
|
||||
options?: DecryptOptions,
|
||||
): Promise<CompactDecryptResult & ResolvedKey>
|
||||
async function compactDecrypt(
|
||||
export async function compactDecrypt(
|
||||
jwe: string | Uint8Array,
|
||||
key: KeyLike | Uint8Array | CompactDecryptGetKey,
|
||||
options?: DecryptOptions,
|
||||
|
|
@ -90,7 +90,7 @@ async function compactDecrypt(
|
|||
throw new JWEInvalid('Invalid Compact JWE')
|
||||
}
|
||||
|
||||
const decrypted = await decrypt(
|
||||
const decrypted = await flattenedDecrypt(
|
||||
{
|
||||
ciphertext: <string>(ciphertext || undefined),
|
||||
iv: <string>(iv || undefined),
|
||||
|
|
@ -98,7 +98,7 @@ async function compactDecrypt(
|
|||
tag: <string>(tag || undefined),
|
||||
encrypted_key: encryptedKey || undefined,
|
||||
},
|
||||
<Parameters<typeof decrypt>[1]>key,
|
||||
<Parameters<typeof flattenedDecrypt>[1]>key,
|
||||
options,
|
||||
)
|
||||
|
||||
|
|
@ -111,6 +111,4 @@ async function compactDecrypt(
|
|||
return result
|
||||
}
|
||||
|
||||
export { compactDecrypt }
|
||||
export default compactDecrypt
|
||||
export type { KeyLike, DecryptOptions, CompactDecryptResult }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import FlattenedEncrypt from '../flattened/encrypt.js'
|
||||
import { FlattenedEncrypt } from '../flattened/encrypt.js'
|
||||
import type {
|
||||
KeyLike,
|
||||
JWEKeyManagementHeaderParameters,
|
||||
|
|
@ -35,7 +35,7 @@ import type {
|
|||
* import { CompactEncrypt } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
class CompactEncrypt {
|
||||
export class CompactEncrypt {
|
||||
private _flattened: FlattenedEncrypt
|
||||
|
||||
/**
|
||||
|
|
@ -106,6 +106,4 @@ class CompactEncrypt {
|
|||
}
|
||||
}
|
||||
|
||||
export { CompactEncrypt }
|
||||
export default CompactEncrypt
|
||||
export type { KeyLike, JWEKeyManagementHeaderParameters, JWEHeaderParameters }
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export interface FlattenedDecryptGetKey
|
|||
* import { flattenedDecrypt } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
function flattenedDecrypt(
|
||||
export function flattenedDecrypt(
|
||||
jwe: FlattenedJWE,
|
||||
key: KeyLike | Uint8Array,
|
||||
options?: DecryptOptions,
|
||||
|
|
@ -82,12 +82,12 @@ function flattenedDecrypt(
|
|||
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with.
|
||||
* @param options JWE Decryption options.
|
||||
*/
|
||||
function flattenedDecrypt(
|
||||
export function flattenedDecrypt(
|
||||
jwe: FlattenedJWE,
|
||||
getKey: FlattenedDecryptGetKey,
|
||||
options?: DecryptOptions,
|
||||
): Promise<FlattenedDecryptResult & ResolvedKey>
|
||||
async function flattenedDecrypt(
|
||||
export async function flattenedDecrypt(
|
||||
jwe: FlattenedJWE,
|
||||
key: KeyLike | Uint8Array | FlattenedDecryptGetKey,
|
||||
options?: DecryptOptions,
|
||||
|
|
@ -262,6 +262,4 @@ async function flattenedDecrypt(
|
|||
return result
|
||||
}
|
||||
|
||||
export { flattenedDecrypt }
|
||||
export default flattenedDecrypt
|
||||
export type { KeyLike, FlattenedJWE, JWEHeaderParameters, DecryptOptions, FlattenedDecryptResult }
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import validateCrit from '../../lib/validate_crit.js'
|
|||
* import { FlattenedEncrypt } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
class FlattenedEncrypt {
|
||||
export class FlattenedEncrypt {
|
||||
private _plaintext: Uint8Array
|
||||
|
||||
private _protectedHeader!: JWEHeaderParameters
|
||||
|
|
@ -314,6 +314,4 @@ class FlattenedEncrypt {
|
|||
}
|
||||
}
|
||||
|
||||
export { FlattenedEncrypt }
|
||||
export default FlattenedEncrypt
|
||||
export type { KeyLike, FlattenedJWE, JWEHeaderParameters, JWEKeyManagementHeaderParameters }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import decrypt from '../flattened/decrypt.js'
|
||||
import { flattenedDecrypt } from '../flattened/decrypt.js'
|
||||
import { JWEDecryptionFailed, JWEInvalid } from '../../util/errors.js'
|
||||
import type {
|
||||
KeyLike,
|
||||
|
|
@ -67,7 +67,7 @@ export interface GeneralDecryptGetKey extends GetKeyFunction<JWEHeaderParameters
|
|||
* console.log(decoder.decode(additionalAuthenticatedData))
|
||||
* ```
|
||||
*/
|
||||
function generalDecrypt(
|
||||
export function generalDecrypt(
|
||||
jwe: GeneralJWE,
|
||||
key: KeyLike | Uint8Array,
|
||||
options?: DecryptOptions,
|
||||
|
|
@ -77,12 +77,12 @@ function generalDecrypt(
|
|||
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with.
|
||||
* @param options JWE Decryption options.
|
||||
*/
|
||||
function generalDecrypt(
|
||||
export function generalDecrypt(
|
||||
jwe: GeneralJWE,
|
||||
getKey: GeneralDecryptGetKey,
|
||||
options?: DecryptOptions,
|
||||
): Promise<GeneralDecryptResult & ResolvedKey>
|
||||
async function generalDecrypt(
|
||||
export async function generalDecrypt(
|
||||
jwe: GeneralJWE,
|
||||
key: KeyLike | Uint8Array | GeneralDecryptGetKey,
|
||||
options?: DecryptOptions,
|
||||
|
|
@ -97,7 +97,7 @@ async function generalDecrypt(
|
|||
|
||||
for (const recipient of jwe.recipients) {
|
||||
try {
|
||||
return await decrypt(
|
||||
return await flattenedDecrypt(
|
||||
{
|
||||
aad: jwe.aad,
|
||||
ciphertext: jwe.ciphertext,
|
||||
|
|
@ -108,7 +108,7 @@ async function generalDecrypt(
|
|||
tag: jwe.tag,
|
||||
unprotected: jwe.unprotected,
|
||||
},
|
||||
<Parameters<typeof decrypt>[1]>key,
|
||||
<Parameters<typeof flattenedDecrypt>[1]>key,
|
||||
options,
|
||||
)
|
||||
} catch {
|
||||
|
|
@ -118,6 +118,4 @@ async function generalDecrypt(
|
|||
throw new JWEDecryptionFailed()
|
||||
}
|
||||
|
||||
export { generalDecrypt }
|
||||
export default generalDecrypt
|
||||
export type { KeyLike, GeneralJWE, DecryptOptions, GeneralDecryptResult }
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import { JWSInvalid } from '../util/errors.js'
|
|||
* import { EmbeddedJWK } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
async function EmbeddedJWK(protectedHeader: JWSHeaderParameters, token: FlattenedJWSInput) {
|
||||
export async function EmbeddedJWK(protectedHeader: JWSHeaderParameters, token: FlattenedJWSInput) {
|
||||
const joseHeader = {
|
||||
...protectedHeader,
|
||||
...token.header,
|
||||
|
|
@ -57,6 +57,3 @@ async function EmbeddedJWK(protectedHeader: JWSHeaderParameters, token: Flattene
|
|||
|
||||
return key
|
||||
}
|
||||
|
||||
export { EmbeddedJWK }
|
||||
export default EmbeddedJWK
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ const check = (value: unknown, description: string) => {
|
|||
* import { calculateJwkThumbprint } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
async function calculateJwkThumbprint(
|
||||
export async function calculateJwkThumbprint(
|
||||
jwk: JWK,
|
||||
digestAlgorithm: 'sha256' | 'sha384' | 'sha512' = 'sha256',
|
||||
): Promise<string> {
|
||||
|
|
@ -84,6 +84,4 @@ async function calculateJwkThumbprint(
|
|||
return base64url(await digest(digestAlgorithm, data))
|
||||
}
|
||||
|
||||
export { calculateJwkThumbprint }
|
||||
export default calculateJwkThumbprint
|
||||
export type { JWK }
|
||||
|
|
|
|||
|
|
@ -250,12 +250,9 @@ class RemoteJWKSet {
|
|||
* @param url URL to fetch the JSON Web Key Set from.
|
||||
* @param options Options for the remote JSON Web Key Set.
|
||||
*/
|
||||
function createRemoteJWKSet(
|
||||
export function createRemoteJWKSet(
|
||||
url: URL,
|
||||
options?: RemoteJWKSetOptions,
|
||||
): GetKeyFunction<JWSHeaderParameters, FlattenedJWSInput> {
|
||||
return RemoteJWKSet.prototype.getKey.bind(new RemoteJWKSet(url, options))
|
||||
}
|
||||
|
||||
export { createRemoteJWKSet }
|
||||
export default createRemoteJWKSet
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import FlattenedSign from '../flattened/sign.js'
|
||||
import { FlattenedSign } from '../flattened/sign.js'
|
||||
import type { JWSHeaderParameters, KeyLike, SignOptions } from '../../types.d'
|
||||
|
||||
/**
|
||||
|
|
@ -30,7 +30,7 @@ import type { JWSHeaderParameters, KeyLike, SignOptions } from '../../types.d'
|
|||
* import { CompactSign } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
class CompactSign {
|
||||
export class CompactSign {
|
||||
private _flattened: FlattenedSign
|
||||
|
||||
/**
|
||||
|
|
@ -67,6 +67,4 @@ class CompactSign {
|
|||
}
|
||||
}
|
||||
|
||||
export { CompactSign }
|
||||
export default CompactSign
|
||||
export type { JWSHeaderParameters, KeyLike }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import verify from '../flattened/verify.js'
|
||||
import { flattenedVerify } from '../flattened/verify.js'
|
||||
import { JWSInvalid } from '../../util/errors.js'
|
||||
import { decoder } from '../../lib/buffer_utils.js'
|
||||
import type {
|
||||
|
|
@ -54,7 +54,7 @@ export interface CompactVerifyGetKey
|
|||
* import { compactVerify } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
function compactVerify(
|
||||
export function compactVerify(
|
||||
jws: string | Uint8Array,
|
||||
key: KeyLike | Uint8Array,
|
||||
options?: VerifyOptions,
|
||||
|
|
@ -64,12 +64,12 @@ function compactVerify(
|
|||
* @param getKey Function resolving a key to verify the JWS with.
|
||||
* @param options JWS Verify options.
|
||||
*/
|
||||
function compactVerify(
|
||||
export function compactVerify(
|
||||
jws: string | Uint8Array,
|
||||
getKey: CompactVerifyGetKey,
|
||||
options?: VerifyOptions,
|
||||
): Promise<CompactVerifyResult & ResolvedKey>
|
||||
async function compactVerify(
|
||||
export async function compactVerify(
|
||||
jws: string | Uint8Array,
|
||||
key: KeyLike | Uint8Array | CompactVerifyGetKey,
|
||||
options?: VerifyOptions,
|
||||
|
|
@ -87,13 +87,13 @@ async function compactVerify(
|
|||
throw new JWSInvalid('Invalid Compact JWS')
|
||||
}
|
||||
|
||||
const verified = await verify(
|
||||
const verified = await flattenedVerify(
|
||||
{
|
||||
payload: <string>(payload || undefined),
|
||||
protected: protectedHeader || undefined,
|
||||
signature: <string>(signature || undefined),
|
||||
},
|
||||
<Parameters<typeof verify>[1]>key,
|
||||
<Parameters<typeof flattenedVerify>[1]>key,
|
||||
options,
|
||||
)
|
||||
|
||||
|
|
@ -106,6 +106,4 @@ async function compactVerify(
|
|||
return result
|
||||
}
|
||||
|
||||
export { compactVerify }
|
||||
export default compactVerify
|
||||
export type { KeyLike, VerifyOptions, CompactVerifyResult }
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import validateCrit from '../../lib/validate_crit.js'
|
|||
* import { FlattenedSign } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
class FlattenedSign {
|
||||
export class FlattenedSign {
|
||||
private _payload: Uint8Array
|
||||
|
||||
private _protectedHeader!: JWSHeaderParameters
|
||||
|
|
@ -166,6 +166,4 @@ class FlattenedSign {
|
|||
}
|
||||
}
|
||||
|
||||
export { FlattenedSign }
|
||||
export default FlattenedSign
|
||||
export type { KeyLike, FlattenedJWS, JWSHeaderParameters }
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export interface FlattenedVerifyGetKey
|
|||
* import { flattenedVerify } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
function flattenedVerify(
|
||||
export function flattenedVerify(
|
||||
jws: FlattenedJWSInput,
|
||||
key: KeyLike | Uint8Array,
|
||||
options?: VerifyOptions,
|
||||
|
|
@ -76,12 +76,12 @@ function flattenedVerify(
|
|||
* @param getKey Function resolving a key to verify the JWS with.
|
||||
* @param options JWS Verify options.
|
||||
*/
|
||||
function flattenedVerify(
|
||||
export function flattenedVerify(
|
||||
jws: FlattenedJWSInput,
|
||||
getKey: FlattenedVerifyGetKey,
|
||||
options?: VerifyOptions,
|
||||
): Promise<FlattenedVerifyResult & ResolvedKey>
|
||||
async function flattenedVerify(
|
||||
export async function flattenedVerify(
|
||||
jws: FlattenedJWSInput,
|
||||
key: KeyLike | Uint8Array | FlattenedVerifyGetKey,
|
||||
options?: VerifyOptions,
|
||||
|
|
@ -214,8 +214,6 @@ async function flattenedVerify(
|
|||
return result
|
||||
}
|
||||
|
||||
export { flattenedVerify }
|
||||
export default flattenedVerify
|
||||
export type {
|
||||
KeyLike,
|
||||
FlattenedJWSInput,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import FlattenedSign from '../flattened/sign.js'
|
||||
import { FlattenedSign } from '../flattened/sign.js'
|
||||
import { JWSInvalid } from '../../util/errors.js'
|
||||
|
||||
import type { KeyLike, GeneralJWS, JWSHeaderParameters, SignOptions } from '../../types.d'
|
||||
|
|
@ -97,7 +97,7 @@ class IndividualSignature implements Signature {
|
|||
* import { GeneralSign } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
class GeneralSign {
|
||||
export class GeneralSign {
|
||||
private _payload: Uint8Array
|
||||
|
||||
private _signatures: IndividualSignature[] = []
|
||||
|
|
@ -158,6 +158,4 @@ class GeneralSign {
|
|||
}
|
||||
}
|
||||
|
||||
export { GeneralSign }
|
||||
export default GeneralSign
|
||||
export type { KeyLike, GeneralJWS, JWSHeaderParameters }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import verify from '../flattened/verify.js'
|
||||
import { flattenedVerify } from '../flattened/verify.js'
|
||||
import type {
|
||||
GeneralJWSInput,
|
||||
GeneralVerifyResult,
|
||||
|
|
@ -63,7 +63,7 @@ export interface GeneralVerifyGetKey
|
|||
* import { generalVerify } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
function generalVerify(
|
||||
export function generalVerify(
|
||||
jws: GeneralJWSInput,
|
||||
key: KeyLike | Uint8Array,
|
||||
options?: VerifyOptions,
|
||||
|
|
@ -73,12 +73,12 @@ function generalVerify(
|
|||
* @param getKey Function resolving a key to verify the JWS with.
|
||||
* @param options JWS Verify options.
|
||||
*/
|
||||
function generalVerify(
|
||||
export function generalVerify(
|
||||
jws: GeneralJWSInput,
|
||||
getKey: GeneralVerifyGetKey,
|
||||
options?: VerifyOptions,
|
||||
): Promise<GeneralVerifyResult & ResolvedKey>
|
||||
async function generalVerify(
|
||||
export async function generalVerify(
|
||||
jws: GeneralJWSInput,
|
||||
key: KeyLike | Uint8Array | GeneralVerifyGetKey,
|
||||
options?: VerifyOptions,
|
||||
|
|
@ -93,14 +93,14 @@ async function generalVerify(
|
|||
|
||||
for (const signature of jws.signatures) {
|
||||
try {
|
||||
return await verify(
|
||||
return await flattenedVerify(
|
||||
{
|
||||
header: signature.header,
|
||||
payload: jws.payload,
|
||||
protected: signature.protected,
|
||||
signature: signature.signature,
|
||||
},
|
||||
<Parameters<typeof verify>[1]>key,
|
||||
<Parameters<typeof flattenedVerify>[1]>key,
|
||||
options,
|
||||
)
|
||||
} catch {
|
||||
|
|
@ -110,6 +110,4 @@ async function generalVerify(
|
|||
throw new JWSSignatureVerificationFailed()
|
||||
}
|
||||
|
||||
export { generalVerify }
|
||||
export default generalVerify
|
||||
export type { KeyLike, GeneralJWSInput, VerifyOptions, GeneralVerifyResult }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import decrypt from '../jwe/compact/decrypt.js'
|
||||
import { compactDecrypt } from '../jwe/compact/decrypt.js'
|
||||
import type {
|
||||
KeyLike,
|
||||
DecryptOptions,
|
||||
|
|
@ -59,7 +59,7 @@ export interface JWTDecryptGetKey extends GetKeyFunction<JWEHeaderParameters, Fl
|
|||
* import { jwtDecrypt } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
async function jwtDecrypt(
|
||||
export async function jwtDecrypt(
|
||||
jwt: string | Uint8Array,
|
||||
key: KeyLike | Uint8Array,
|
||||
options?: JWTDecryptOptions,
|
||||
|
|
@ -69,17 +69,17 @@ async function jwtDecrypt(
|
|||
* @param getKey Function resolving Private Key or Secret to decrypt and verify the JWT with.
|
||||
* @param options JWT Decryption and JWT Claims Set validation options.
|
||||
*/
|
||||
async function jwtDecrypt(
|
||||
export async function jwtDecrypt(
|
||||
jwt: string | Uint8Array,
|
||||
getKey: JWTDecryptGetKey,
|
||||
options?: JWTDecryptOptions,
|
||||
): Promise<JWTDecryptResult & ResolvedKey>
|
||||
async function jwtDecrypt(
|
||||
export async function jwtDecrypt(
|
||||
jwt: string | Uint8Array,
|
||||
key: KeyLike | Uint8Array | JWTDecryptGetKey,
|
||||
options?: JWTDecryptOptions,
|
||||
) {
|
||||
const decrypted = await decrypt(jwt, <Parameters<typeof decrypt>[1]>key, options)
|
||||
const decrypted = await compactDecrypt(jwt, <Parameters<typeof compactDecrypt>[1]>key, options)
|
||||
const payload = jwtPayload(decrypted.protectedHeader, decrypted.plaintext, options)
|
||||
|
||||
const { protectedHeader } = decrypted
|
||||
|
|
@ -120,6 +120,4 @@ async function jwtDecrypt(
|
|||
return result
|
||||
}
|
||||
|
||||
export { jwtDecrypt }
|
||||
export default jwtDecrypt
|
||||
export type { KeyLike, DecryptOptions, JWTPayload, JWTDecryptOptions, JWTDecryptResult }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import CompactEncrypt from '../jwe/compact/encrypt.js'
|
||||
import { CompactEncrypt } from '../jwe/compact/encrypt.js'
|
||||
import type {
|
||||
EncryptOptions,
|
||||
JWEHeaderParameters,
|
||||
|
|
@ -40,7 +40,7 @@ import { ProduceJWT } from './produce.js'
|
|||
* import { EncryptJWT } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
class EncryptJWT extends ProduceJWT {
|
||||
export class EncryptJWT extends ProduceJWT {
|
||||
private _cek!: Uint8Array
|
||||
|
||||
private _iv!: Uint8Array
|
||||
|
|
@ -176,6 +176,4 @@ class EncryptJWT extends ProduceJWT {
|
|||
}
|
||||
}
|
||||
|
||||
export { EncryptJWT }
|
||||
export default EncryptJWT
|
||||
export type { JWEHeaderParameters, JWTPayload, KeyLike }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import CompactSign from '../jws/compact/sign.js'
|
||||
import { CompactSign } from '../jws/compact/sign.js'
|
||||
import { JWTInvalid } from '../util/errors.js'
|
||||
import type { JWSHeaderParameters, JWTPayload, KeyLike, SignOptions } from '../types.d'
|
||||
import { encoder } from '../lib/buffer_utils.js'
|
||||
|
|
@ -35,7 +35,7 @@ import { ProduceJWT } from './produce.js'
|
|||
* import { SignJWT } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
class SignJWT extends ProduceJWT {
|
||||
export class SignJWT extends ProduceJWT {
|
||||
private _protectedHeader!: JWSHeaderParameters
|
||||
|
||||
/**
|
||||
|
|
@ -68,6 +68,4 @@ class SignJWT extends ProduceJWT {
|
|||
}
|
||||
}
|
||||
|
||||
export { SignJWT }
|
||||
export default SignJWT
|
||||
export type { JWSHeaderParameters, JWTPayload, KeyLike }
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ interface UnsecuredResult {
|
|||
* import { UnsecuredJWT } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
class UnsecuredJWT extends ProduceJWT {
|
||||
export class UnsecuredJWT extends ProduceJWT {
|
||||
/**
|
||||
* Encodes the Unsecured JWT.
|
||||
*/
|
||||
|
|
@ -92,6 +92,4 @@ class UnsecuredJWT extends ProduceJWT {
|
|||
}
|
||||
}
|
||||
|
||||
export { UnsecuredJWT }
|
||||
export default UnsecuredJWT
|
||||
export type { JWSHeaderParameters, JWTPayload, UnsecuredResult }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import verify from '../jws/compact/verify.js'
|
||||
import { compactVerify } from '../jws/compact/verify.js'
|
||||
import type {
|
||||
KeyLike,
|
||||
VerifyOptions,
|
||||
|
|
@ -62,7 +62,7 @@ export interface JWTVerifyGetKey extends GetKeyFunction<JWSHeaderParameters, Fla
|
|||
* import { jwtVerify } from 'https://deno.land/x/jose@VERSION/index.ts'
|
||||
* ```
|
||||
*/
|
||||
async function jwtVerify(
|
||||
export async function jwtVerify(
|
||||
jwt: string | Uint8Array,
|
||||
key: KeyLike | Uint8Array,
|
||||
options?: JWTVerifyOptions,
|
||||
|
|
@ -72,17 +72,17 @@ async function jwtVerify(
|
|||
* @param getKey Function resolving a key to verify the JWT with.
|
||||
* @param options JWT Decryption and JWT Claims Set validation options.
|
||||
*/
|
||||
async function jwtVerify(
|
||||
export async function jwtVerify(
|
||||
jwt: string | Uint8Array,
|
||||
getKey: JWTVerifyGetKey,
|
||||
options?: JWTVerifyOptions,
|
||||
): Promise<JWTVerifyResult & ResolvedKey>
|
||||
async function jwtVerify(
|
||||
export async function jwtVerify(
|
||||
jwt: string | Uint8Array,
|
||||
key: KeyLike | Uint8Array | JWTVerifyGetKey,
|
||||
options?: JWTVerifyOptions,
|
||||
) {
|
||||
const verified = await verify(jwt, <Parameters<typeof verify>[1]>key, options)
|
||||
const verified = await compactVerify(jwt, <Parameters<typeof compactVerify>[1]>key, options)
|
||||
if (verified.protectedHeader.crit?.includes('b64') && verified.protectedHeader.b64 === false) {
|
||||
throw new JWTInvalid('JWTs MUST NOT use unencoded payload')
|
||||
}
|
||||
|
|
@ -94,8 +94,6 @@ async function jwtVerify(
|
|||
return result
|
||||
}
|
||||
|
||||
export { jwtVerify }
|
||||
export default jwtVerify
|
||||
export type {
|
||||
KeyLike,
|
||||
JWTPayload,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export type ProtectedHeaderParameters = JWSHeaderParameters & JWEHeaderParameter
|
|||
*
|
||||
* @param token JWE/JWS/JWT token in any JOSE serialization.
|
||||
*/
|
||||
function decodeProtectedHeader(token: string | object) {
|
||||
export function decodeProtectedHeader(token: string | object) {
|
||||
let protectedB64u!: string
|
||||
|
||||
if (typeof token === 'string') {
|
||||
|
|
@ -60,6 +60,3 @@ function decodeProtectedHeader(token: string | object) {
|
|||
throw new TypeError('Invalid Token or Protected Header formatting')
|
||||
}
|
||||
}
|
||||
|
||||
export { decodeProtectedHeader }
|
||||
export default decodeProtectedHeader
|
||||
|
|
|
|||
|
|
@ -69,12 +69,9 @@ export interface GenerateKeyPairOptions {
|
|||
* @param alg JWA Algorithm Identifier to be used with the generated key pair.
|
||||
* @param options Additional options passed down to the key pair generation.
|
||||
*/
|
||||
async function generateKeyPair(
|
||||
export async function generateKeyPair(
|
||||
alg: string,
|
||||
options?: GenerateKeyPairOptions,
|
||||
): Promise<GenerateKeyPairResult> {
|
||||
return generate(alg, options)
|
||||
}
|
||||
|
||||
export { generateKeyPair }
|
||||
export default generateKeyPair
|
||||
|
|
|
|||
|
|
@ -41,12 +41,9 @@ export interface GenerateSecretOptions {
|
|||
* @param alg JWA Algorithm Identifier to be used with the generated secret.
|
||||
* @param options Additional options passed down to the secret generation.
|
||||
*/
|
||||
async function generateSecret(
|
||||
export async function generateSecret(
|
||||
alg: string,
|
||||
options?: GenerateSecretOptions,
|
||||
): Promise<KeyLike | Uint8Array> {
|
||||
return generate(alg, options)
|
||||
}
|
||||
|
||||
export { generateSecret }
|
||||
export default generateSecret
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import * as Bowser from 'bowser';
|
||||
|
||||
import generateKeyPair from '../dist/browser/util/generate_key_pair';
|
||||
import FlattenedEncrypt from '../dist/browser/jwe/flattened/encrypt';
|
||||
import decryptFlattened from '../dist/browser/jwe/flattened/decrypt';
|
||||
import decodeProtectedHeader from '../dist/browser/util/decode_protected_header';
|
||||
import { generateKeyPair } from '../dist/browser/util/generate_key_pair';
|
||||
import { FlattenedEncrypt } from '../dist/browser/jwe/flattened/encrypt';
|
||||
import { flattenedDecrypt } from '../dist/browser/jwe/flattened/decrypt';
|
||||
import { decodeProtectedHeader } from '../dist/browser/util/decode_protected_header';
|
||||
|
||||
const browser = Bowser.parse(window.navigator.userAgent);
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ async function test(generate, alg, assert) {
|
|||
.encrypt(publicKey);
|
||||
|
||||
assert.ok(decodeProtectedHeader(jwe));
|
||||
await decryptFlattened(jwe, privateKey);
|
||||
await flattenedDecrypt(jwe, privateKey);
|
||||
assert.ok(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import * as Bowser from 'bowser';
|
||||
|
||||
import generateSecret from '../dist/browser/util/generate_secret';
|
||||
import FlattenedEncrypt from '../dist/browser/jwe/flattened/encrypt';
|
||||
import decryptFlattened from '../dist/browser/jwe/flattened/decrypt';
|
||||
import decodeProtectedHeader from '../dist/browser/util/decode_protected_header';
|
||||
import { generateSecret } from '../dist/browser/util/generate_secret';
|
||||
import { FlattenedEncrypt } from '../dist/browser/jwe/flattened/encrypt';
|
||||
import { flattenedDecrypt } from '../dist/browser/jwe/flattened/decrypt';
|
||||
import { decodeProtectedHeader } from '../dist/browser/util/decode_protected_header';
|
||||
|
||||
const browser = Bowser.parse(window.navigator.userAgent);
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ async function test(generate, { alg, enc }, assert) {
|
|||
.encrypt(secretKey);
|
||||
|
||||
assert.ok(decodeProtectedHeader(jwe));
|
||||
await decryptFlattened(jwe, secretKey);
|
||||
await flattenedDecrypt(jwe, secretKey);
|
||||
assert.ok(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import createRemoteJWKSet from '../dist/browser/jwks/remote';
|
||||
import { createRemoteJWKSet } from '../dist/browser/jwks/remote';
|
||||
|
||||
const jwksUri = 'https://www.googleapis.com/oauth2/v3/certs';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import * as Bowser from 'bowser';
|
||||
|
||||
import generateKeyPair from '../dist/browser/util/generate_key_pair';
|
||||
import generateSecret from '../dist/browser/util/generate_secret';
|
||||
import FlattenedSign from '../dist/browser/jws/flattened/sign';
|
||||
import verifyFlattened from '../dist/browser/jws/flattened/verify';
|
||||
import decodeProtectedHeader from '../dist/browser/util/decode_protected_header';
|
||||
import { generateKeyPair } from '../dist/browser/util/generate_key_pair';
|
||||
import { generateSecret } from '../dist/browser/util/generate_secret';
|
||||
import { FlattenedSign } from '../dist/browser/jws/flattened/sign';
|
||||
import { flattenedVerify } from '../dist/browser/jws/flattened/verify';
|
||||
import { decodeProtectedHeader } from '../dist/browser/util/decode_protected_header';
|
||||
|
||||
const browser = Bowser.parse(window.navigator.userAgent);
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ async function test(generate, alg, assert) {
|
|||
.sign(privateKey);
|
||||
|
||||
assert.ok(decodeProtectedHeader(jws));
|
||||
await verifyFlattened(jws, publicKey);
|
||||
await flattenedVerify(jws, publicKey);
|
||||
assert.ok(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import * as Bowser from 'bowser';
|
|||
|
||||
import { importJWK } from '../dist/browser/key/import.js';
|
||||
import { exportJWK } from '../dist/browser/key/export.js';
|
||||
import calculateJwkThumbprint from '../dist/browser/jwk/thumbprint.js';
|
||||
import { calculateJwkThumbprint } from '../dist/browser/jwk/thumbprint.js';
|
||||
|
||||
const browser = Bowser.parse(window.navigator.userAgent);
|
||||
|
||||
|
|
|
|||
|
|
@ -110,9 +110,9 @@ const macro = async (t, testScript) => {
|
|||
test('HS256', macro, async () => {
|
||||
const alg = 'HS256';
|
||||
const jwk = JSON.parse('{"kty":"oct","k":"iPYq7qKZWRaVmo1FiJ17M84uADey7-veCAEEsxpPTus"}');
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const secretKey = await utilGenerateSecret(alg);
|
||||
const secretKey = await generateSecret(alg);
|
||||
await jwsSymmetricTest(secretKey, alg);
|
||||
});
|
||||
|
||||
|
|
@ -121,9 +121,9 @@ test('HS384', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"oct","k":"ATgNcVOYFsjbN4GeyXOyryfqqmGp_48-uvVd5J3GsX7ExUMp3WNTDbbZK_5kTjND"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const secretKey = await utilGenerateSecret(alg);
|
||||
const secretKey = await generateSecret(alg);
|
||||
await jwsSymmetricTest(secretKey, alg);
|
||||
});
|
||||
|
||||
|
|
@ -132,9 +132,9 @@ test('HS512', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"oct","k":"2O5x_zEOhSIDiGcOAOYhB1dyDU_ZW27rl-_xDpKE-8tBlL91z6p_8aYo3by6AOsa6ycx6-JC9LBAio0amINXTQ"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const secretKey = await utilGenerateSecret(alg);
|
||||
const secretKey = await generateSecret(alg);
|
||||
await jwsSymmetricTest(secretKey, alg);
|
||||
});
|
||||
|
||||
|
|
@ -143,9 +143,9 @@ test('RS256', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"RSA","n":"rcbWc-i_C8NtS4CpPcMF3QC025re_zzrhv-3ElzxAsMCCepwEqxCzQtsG7mAtROdGR1N_oNPNqr3jmEZdv5C5NtpPeX_gk4-r30_JLXcGNgVbZpmWVSmUI-nrU0cC3kjMS4RUPx7uDQxAUiVUq0k13qjEbEgcZAA3nEH2zuQWg3iWSmwYL0h1VxdINQ-WZZzBJsI_ONyBS5z3-vbyhtnMbgALRZSvNcYpODrH9AEIWNJhcaBVr1vKBdNT76KOl87ilLiKE1dOr72sLJDDsVqXDfxCjU_wdt2bF-YFcKwlYa5Aj2JF-UH7KLniC3P-2sS1zduLoAPAkyLcHgVdOifhQ","e":"AQAB"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
await testSPKI(fixtures.keys.rsa.publicKey, alg);
|
||||
await testPKCS8(fixtures.keys.rsa.privateKey, alg);
|
||||
|
|
@ -157,9 +157,9 @@ test('RS384', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"RSA","n":"yKV00L6PwdO6DGMgsNwuWZ0xviGMqq7nvkULJ8jyQil8viSUvxDMPDZ80CoHUkgobcBU1DasjGO9nTthPYhcpOFh8Fzat1aG-z5Ola2FBHqpdJpwb7lxsLfq6UJy1bial5RCMrLdW3NhuCxIfhnGmvq4hFLAF7gBnEfkbN9qsrzyZruEGIlNG50r779axmgnRZDZ6YS5o_DVbn27f2yCjBLVYIljW5z9CSm6_NjSYVdeNujrgQUWMIrCZiJqmRSOAvn6GliKXFL7sh5xLh_DiCx1Atr477sBxviLY-tFpeXLOqKJKqZ5GASrspxsO96roE4-I4J-7JgoxYptuKD2Bw","e":"AQAB"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
|
||||
await testSPKI(fixtures.keys.rsa.publicKey, alg);
|
||||
|
|
@ -172,9 +172,9 @@ test('RS512', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"RSA","n":"wdEr4kyCku2F8a2Y45xa1Q-jE5FlkYK6xUDuyckH6U9hhA_1OFaNfTbZ-8ZkXOp0PGzYjCqAk0YxATfnKSc1-PKnOBvBD8FRpgaT61WyOq_yM6YgDrwQvbWTr0r5copjDs4ZA9mrE-bjgvOLut4GpD4NVPWhPkgI45-yYd0H4vjuf36sCe26MBIWBTzInCUdfKTvCdh0Kk__HOENwwke6XrtzvugJymi3zlrdqztq3efJFmA4hvyLzosdBB8g0iWBXFNy51J8RCYygiSXtsPatV1FMVd6ZkTfVrvR3OYJucbuvCbqQwPDB08XjJLXKTE1eolyECk-U-Z_Cg8aNElpw","e":"AQAB"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
|
||||
await testSPKI(fixtures.keys.rsa.publicKey, alg);
|
||||
|
|
@ -187,9 +187,9 @@ test('PS256', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"RSA","n":"5Yv7aQulm2VYKjSfwPQLSEokqtWu-TxKKkRKT_570Yjk0fIg81IbK5T0SrkBzmEV5bjuoGdVMQf6bvkhOeeborTmbISEE6DCNxN_us3EWJKMKp-OSbeqbvbg252l_wPhcC5OC0Q--ryOqoRlsCKYgCmDbKNmZepGm8Nf1ayeqj3kIuKmgzU7y4dy4Le8Sq-9aHD5_QW52WqHeEnmIfrVnR7mJsrd7LY-28aflUHaEDn1TzhPPq0W_F1lMkdniM4c5JNU5_6fZ8NVla51j-pt0PmQMz-Ch97ZcnpB7DGdNyBDzdnQiabJ7sOxRK33so8cUFh3zHnaeX73XeGgrpD5XQ","e":"AQAB"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
|
||||
await testSPKI(fixtures.keys.rsa.publicKey, alg);
|
||||
|
|
@ -202,9 +202,9 @@ test('PS384', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"RSA","n":"vyJy0ZJqdGsH3-AGnaw5I35lPhFdWDxxkRn-TBx1GfhIKCjibEjZTCfzBnBdWwIUnr2fL0Vy6VZvTEUcH66r4AJy380ovOJrVIM5nhAGn8uSLCoJ2yiuKeA50gBylINvdAVG7fDzau4-1aSQ1RXILxa88raqDK1h8DQoGZLnRdiKkfNjKmXVltsvDSUxOmKelHh9WLiF2JCs0ydMCCcGDumosLBlP4LR7XfycW2cIavRdxeajL8oyRckD9-IpZLampTkr0Ja4GWHbHnAX-dXmoRDEhqlMeSpKmbm-e95jT_3SHwLj_TLlwF4HsIj-egX78lHcVJzCvhdUG7ogrbjHw","e":"AQAB"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
|
||||
await testSPKI(fixtures.keys.rsa.publicKey, alg);
|
||||
|
|
@ -217,9 +217,9 @@ test('PS512', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"RSA","n":"sSLTDqh1I2Rt26uCFrbdYuRY3lqDes8Az0GQxgatQhXgIG1jOfuEIaqnMRDuWinroRWuetR1ykQ4SxzIy31ms5PSM5sJm1SNAiynO6dxxGMNaCLt4Rgi_fAn6CD0F4mo2OLmxm1_hQH1SJSymG8p8q9Uu0IToY4KEEmHwc1kfiAosvqfLgY1-CRU8kKbFHzq28x7Jbv4WSDccJ_-Wm8BiyMkIUQfzRsC1hHiMO_NKlLwMqeSQ5XyYqsBxc80cF6Z9IIBzXewjCGGVAfYMeimPcJao6wat-PXEr5axEeBeCFU6Q7TDLcMilotGV6f6-UECUK5q2QCXtoOnZ5TO4yPzQ","e":"AQAB"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
|
||||
await testSPKI(fixtures.keys.rsa.publicKey, alg);
|
||||
|
|
@ -232,9 +232,9 @@ test('ES256', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"EC","crv":"P-256","x":"E8KpG0wpGUfRBYx8tUhd6tYaFaTZaIyHvAudXbSUFxQ","y":"gcVDlKTo-UhZ-wHDNUdoQP0M9zevurU6A5WMR07B-wQ"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
await testSPKI(fixtures.keys['P-256'].publicKey, alg);
|
||||
await testPKCS8(fixtures.keys['P-256'].privateKey, alg);
|
||||
|
|
@ -246,9 +246,9 @@ test('ES384', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"EC","crv":"P-384","x":"HnBAtgpS-GJzTCdLBELPm1VIRoQwlk7luJIGEYWKhWtMHmOq14Hh7674Oxcc52mE","y":"jXGek8Zapkjav7mO-KB-7vEWrqNxHSoXgNn1r6C0BiqS89SVciz6O8uriPdxoWem"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
await testSPKI(fixtures.keys['P-384'].publicKey, alg);
|
||||
await testPKCS8(fixtures.keys['P-384'].privateKey, alg);
|
||||
|
|
@ -260,9 +260,9 @@ test('ES512', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"EC","crv":"P-521","x":"AIwG869tNnEGIDg2hSyvXKIOk9rWPO_riIixGliBGBV0kB57QoTrjK-g5JCtazDTcBT23igX9gvAVkLvr2oFTQ9p","y":"AeGZ0Z3JHM1rQWvmmpdfVu0zSNpmu0xPjGUE2hGhloRqF-JJV3aVMS72ZhGlbWi-O7OCcypIfndhpYgrc3qx0Y1w"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
await testSPKI(fixtures.keys['P-521'].publicKey, alg);
|
||||
await testPKCS8(fixtures.keys['P-521'].privateKey, alg);
|
||||
|
|
@ -274,9 +274,9 @@ test('EdDSA', macro, async () => {
|
|||
const jwk = JSON.parse(
|
||||
'{"kty":"OKP","crv":"Ed25519","x":"zjV_JsgzH--qhtVlJEYDFeRFITSD0k6lYSSpOKBarZQ"}',
|
||||
);
|
||||
await jwkThumbprint(jwk);
|
||||
await calculateJwkThumbprint(jwk);
|
||||
await keyExport.exportJWK(await keyImport.importJWK({ ...jwk, ext: true }, alg));
|
||||
const keypair = await utilGenerateKeyPair(alg);
|
||||
const keypair = await generateKeyPair(alg);
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
await testSPKI(fixtures.keys.ed25519.publicKey, alg);
|
||||
await testPKCS8(fixtures.keys.ed25519.privateKey, alg);
|
||||
|
|
@ -284,7 +284,7 @@ test('EdDSA', macro, async () => {
|
|||
|
||||
test('EdDSA crv: Ed25519', macro, async () => {
|
||||
const alg = 'EdDSA';
|
||||
const keypair = await utilGenerateKeyPair(alg, { crv: 'Ed25519' });
|
||||
const keypair = await generateKeyPair(alg, { crv: 'Ed25519' });
|
||||
await jwsAsymmetricTest(keypair, alg);
|
||||
});
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ test('EdDSA crv: Ed448', macro, async () => {
|
|||
},
|
||||
() => {},
|
||||
);
|
||||
await utilGenerateKeyPair(alg, { crv: 'Ed448' }).then(
|
||||
await generateKeyPair(alg, { crv: 'Ed448' }).then(
|
||||
() => {
|
||||
throw new Error('should fail');
|
||||
},
|
||||
|
|
@ -315,7 +315,7 @@ test('ECDH-ES crv: X25519', macro, async () => {
|
|||
},
|
||||
() => {},
|
||||
);
|
||||
await utilGenerateKeyPair(alg, { crv: 'X25519' }).then(
|
||||
await generateKeyPair(alg, { crv: 'X25519' }).then(
|
||||
() => {
|
||||
throw new Error('should fail');
|
||||
},
|
||||
|
|
@ -333,7 +333,7 @@ test('ECDH-ES crv: X448', macro, async () => {
|
|||
},
|
||||
() => {},
|
||||
);
|
||||
await utilGenerateKeyPair(alg, { crv: 'X448' }).then(
|
||||
await generateKeyPair(alg, { crv: 'X448' }).then(
|
||||
() => {
|
||||
throw new Error('should fail');
|
||||
},
|
||||
|
|
@ -345,13 +345,13 @@ test('createRemoteJWKSet', macro, async () => {
|
|||
const jwksUri = 'https://www.googleapis.com/oauth2/v3/certs';
|
||||
const response = await fetch(jwksUri).then((r) => r.json());
|
||||
const { alg, kid } = response.keys[0];
|
||||
const jwks = jwksRemote(new URL(jwksUri));
|
||||
const jwks = createRemoteJWKSet(new URL(jwksUri));
|
||||
await jwks({ alg, kid });
|
||||
});
|
||||
|
||||
test('remote jwk set timeout', macro, async () => {
|
||||
const jwksUri = 'https://www.googleapis.com/oauth2/v3/certs';
|
||||
const jwks = jwksRemote(new URL(jwksUri), { timeoutDuration: 0 });
|
||||
const jwks = createRemoteJWKSet(new URL(jwksUri), { timeoutDuration: 0 });
|
||||
await jwks({ alg: 'RS256' }).then(
|
||||
() => {
|
||||
throw new Error('should fail');
|
||||
|
|
@ -365,102 +365,102 @@ test('remote jwk set timeout', macro, async () => {
|
|||
});
|
||||
|
||||
test('ECDH-ES', macro, async () => {
|
||||
const keypair = await utilGenerateKeyPair('ECDH-ES');
|
||||
const keypair = await generateKeyPair('ECDH-ES');
|
||||
await jweAsymmetricTest(keypair, 'ECDH-ES');
|
||||
});
|
||||
|
||||
test('ECDH-ES crv: P-256', macro, async () => {
|
||||
const keypair = await utilGenerateKeyPair('ECDH-ES', { crv: 'P-256' });
|
||||
const keypair = await generateKeyPair('ECDH-ES', { crv: 'P-256' });
|
||||
await jweAsymmetricTest(keypair, 'ECDH-ES');
|
||||
});
|
||||
|
||||
test('ECDH-ES crv: P-384', macro, async () => {
|
||||
const keypair = await utilGenerateKeyPair('ECDH-ES', { crv: 'P-384' });
|
||||
const keypair = await generateKeyPair('ECDH-ES', { crv: 'P-384' });
|
||||
await jweAsymmetricTest(keypair, 'ECDH-ES');
|
||||
});
|
||||
|
||||
test('ECDH-ES crv: P-521', macro, async () => {
|
||||
const keypair = await utilGenerateKeyPair('ECDH-ES', { crv: 'P-521' });
|
||||
const keypair = await generateKeyPair('ECDH-ES', { crv: 'P-521' });
|
||||
await jweAsymmetricTest(keypair, 'ECDH-ES');
|
||||
});
|
||||
|
||||
test('RSA-OAEP-256', macro, async () => {
|
||||
const keypair = await utilGenerateKeyPair('RSA-OAEP-256');
|
||||
const keypair = await generateKeyPair('RSA-OAEP-256');
|
||||
await jweAsymmetricTest(keypair, 'RSA-OAEP-256');
|
||||
});
|
||||
|
||||
test('RSA-OAEP-384', macro, async () => {
|
||||
const keypair = await utilGenerateKeyPair('RSA-OAEP-384');
|
||||
const keypair = await generateKeyPair('RSA-OAEP-384');
|
||||
await jweAsymmetricTest(keypair, 'RSA-OAEP-384');
|
||||
});
|
||||
|
||||
test('RSA-OAEP-512', macro, async () => {
|
||||
const keypair = await utilGenerateKeyPair('RSA-OAEP-512');
|
||||
const keypair = await generateKeyPair('RSA-OAEP-512');
|
||||
await jweAsymmetricTest(keypair, 'RSA-OAEP-512');
|
||||
});
|
||||
|
||||
test('RSA-OAEP', macro, async () => {
|
||||
const keypair = await utilGenerateKeyPair('RSA-OAEP');
|
||||
const keypair = await generateKeyPair('RSA-OAEP');
|
||||
await jweAsymmetricTest(keypair, 'RSA-OAEP');
|
||||
});
|
||||
|
||||
test('A128CBC-HS256', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A128CBC-HS256');
|
||||
const secretKey = await generateSecret('A128CBC-HS256');
|
||||
await jweSymmetricTest(secretKey, { alg: 'dir', enc: 'A128CBC-HS256' });
|
||||
});
|
||||
|
||||
test('A128GCM', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A128GCM');
|
||||
const secretKey = await generateSecret('A128GCM');
|
||||
await jweSymmetricTest(secretKey, { alg: 'dir', enc: 'A128GCM' });
|
||||
});
|
||||
|
||||
test('A192CBC-HS384', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A192CBC-HS384');
|
||||
const secretKey = await generateSecret('A192CBC-HS384');
|
||||
await jweSymmetricTest(secretKey, { alg: 'dir', enc: 'A192CBC-HS384' });
|
||||
});
|
||||
|
||||
test('A192GCM', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A192GCM');
|
||||
const secretKey = await generateSecret('A192GCM');
|
||||
await jweSymmetricTest(secretKey, { alg: 'dir', enc: 'A192GCM' });
|
||||
});
|
||||
|
||||
test('A256CBC-HS512', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A256CBC-HS512');
|
||||
const secretKey = await generateSecret('A256CBC-HS512');
|
||||
await jweSymmetricTest(secretKey, { alg: 'dir', enc: 'A256CBC-HS512' });
|
||||
});
|
||||
|
||||
test('A256GCM', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A256GCM');
|
||||
const secretKey = await generateSecret('A256GCM');
|
||||
await jweSymmetricTest(secretKey, { alg: 'dir', enc: 'A256GCM' });
|
||||
});
|
||||
|
||||
test('A128GCMKW', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A128GCMKW');
|
||||
const secretKey = await generateSecret('A128GCMKW');
|
||||
await jweSymmetricTest(secretKey, { alg: 'A128GCMKW', enc: 'A256GCM' });
|
||||
});
|
||||
|
||||
test('A128KW', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A128KW');
|
||||
const secretKey = await generateSecret('A128KW');
|
||||
await jweSymmetricTest(secretKey, { alg: 'A128KW', enc: 'A256GCM' });
|
||||
});
|
||||
|
||||
test('A192GCMKW', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A192GCMKW');
|
||||
const secretKey = await generateSecret('A192GCMKW');
|
||||
await jweSymmetricTest(secretKey, { alg: 'A192GCMKW', enc: 'A256GCM' });
|
||||
});
|
||||
|
||||
test('A192KW', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A192KW');
|
||||
const secretKey = await generateSecret('A192KW');
|
||||
await jweSymmetricTest(secretKey, { alg: 'A192KW', enc: 'A256GCM' });
|
||||
});
|
||||
|
||||
test('A256GCMKW', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A256GCMKW');
|
||||
const secretKey = await generateSecret('A256GCMKW');
|
||||
await jweSymmetricTest(secretKey, { alg: 'A256GCMKW', enc: 'A256GCM' });
|
||||
});
|
||||
|
||||
test('A256KW', macro, async () => {
|
||||
const secretKey = await utilGenerateSecret('A256KW');
|
||||
const secretKey = await generateSecret('A256KW');
|
||||
await jweSymmetricTest(secretKey, { alg: 'A256KW', enc: 'A256GCM' });
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
import jweCompactEncrypt from '../dist/browser/jwe/compact/encrypt.js';
|
||||
import jweFlattenedEncrypt from '../dist/browser/jwe/flattened/encrypt.js';
|
||||
import jwsCompactSign from '../dist/browser/jws/compact/sign.js';
|
||||
import jwsFlattenedSign from '../dist/browser/jws/flattened/sign.js';
|
||||
import jwsGeneralSign from '../dist/browser/jws/general/sign.js';
|
||||
import jwtEncrypt from '../dist/browser/jwt/encrypt.js';
|
||||
import jwtSign from '../dist/browser/jwt/sign.js';
|
||||
import jwtUnsecured from '../dist/browser/jwt/unsecured.js';
|
||||
import jweCompactDecrypt from '../dist/browser/jwe/compact/decrypt.js';
|
||||
import jweFlattenedDecrypt from '../dist/browser/jwe/flattened/decrypt.js';
|
||||
import jweGeneralDecrypt from '../dist/browser/jwe/general/decrypt.js';
|
||||
import jwkEmbedded from '../dist/browser/jwk/embedded.js';
|
||||
import jwkThumbprint from '../dist/browser/jwk/thumbprint.js';
|
||||
import jwksRemote from '../dist/browser/jwks/remote.js';
|
||||
import jwsCompactVerify from '../dist/browser/jws/compact/verify.js';
|
||||
import jwsFlattenedVerify from '../dist/browser/jws/flattened/verify.js';
|
||||
import jwsGeneralVerify from '../dist/browser/jws/general/verify.js';
|
||||
import jwtDecrypt from '../dist/browser/jwt/decrypt.js';
|
||||
import jwtVerify from '../dist/browser/jwt/verify.js';
|
||||
import utilDecodeProtectedHeader from '../dist/browser/util/decode_protected_header.js';
|
||||
import utilGenerateKeyPair from '../dist/browser/util/generate_key_pair.js';
|
||||
import utilGenerateSecret from '../dist/browser/util/generate_secret.js';
|
||||
import { CompactEncrypt } from '../dist/browser/jwe/compact/encrypt.js';
|
||||
import { FlattenedEncrypt } from '../dist/browser/jwe/flattened/encrypt.js';
|
||||
import { CompactSign } from '../dist/browser/jws/compact/sign.js';
|
||||
import { FlattenedSign } from '../dist/browser/jws/flattened/sign.js';
|
||||
import { GeneralSign } from '../dist/browser/jws/general/sign.js';
|
||||
import { EncryptJWT } from '../dist/browser/jwt/encrypt.js';
|
||||
import { SignJWT } from '../dist/browser/jwt/sign.js';
|
||||
import { UnsecuredJWT } from '../dist/browser/jwt/unsecured.js';
|
||||
import { compactDecrypt } from '../dist/browser/jwe/compact/decrypt.js';
|
||||
import { flattenedDecrypt } from '../dist/browser/jwe/flattened/decrypt.js';
|
||||
import { generalDecrypt } from '../dist/browser/jwe/general/decrypt.js';
|
||||
import { EmbeddedJWK } from '../dist/browser/jwk/embedded.js';
|
||||
import { calculateJwkThumbprint } from '../dist/browser/jwk/thumbprint.js';
|
||||
import { createRemoteJWKSet } from '../dist/browser/jwks/remote.js';
|
||||
import { compactVerify } from '../dist/browser/jws/compact/verify.js';
|
||||
import { flattenedVerify } from '../dist/browser/jws/flattened/verify.js';
|
||||
import { generalVerify } from '../dist/browser/jws/general/verify.js';
|
||||
import { jwtDecrypt } from '../dist/browser/jwt/decrypt.js';
|
||||
import { jwtVerify } from '../dist/browser/jwt/verify.js';
|
||||
import { decodeProtectedHeader } from '../dist/browser/util/decode_protected_header.js';
|
||||
import { generateKeyPair } from '../dist/browser/util/generate_key_pair.js';
|
||||
import { generateSecret } from '../dist/browser/util/generate_secret.js';
|
||||
import * as keyImport from '../dist/browser/key/import.js';
|
||||
import * as keyExport from '../dist/browser/key/export.js';
|
||||
|
||||
|
|
@ -111,41 +111,41 @@ addEventListener('fetch', (event) => {
|
|||
});
|
||||
|
||||
async function jweAsymmetricTest({ publicKey, privateKey }, alg) {
|
||||
const jwe = await new jweFlattenedEncrypt(crypto.getRandomValues(new Uint8Array(32)))
|
||||
const jwe = await new FlattenedEncrypt(crypto.getRandomValues(new Uint8Array(32)))
|
||||
.setProtectedHeader({ alg, enc: 'A256GCM' })
|
||||
.setAdditionalAuthenticatedData(crypto.getRandomValues(new Uint8Array(32)))
|
||||
.encrypt(publicKey);
|
||||
|
||||
utilDecodeProtectedHeader(jwe);
|
||||
await jweFlattenedDecrypt(jwe, privateKey);
|
||||
decodeProtectedHeader(jwe);
|
||||
await flattenedDecrypt(jwe, privateKey);
|
||||
}
|
||||
|
||||
async function jwsAsymmetricTest({ publicKey, privateKey }, alg) {
|
||||
const jws = await new jwsFlattenedSign(crypto.getRandomValues(new Uint8Array(32)))
|
||||
const jws = await new FlattenedSign(crypto.getRandomValues(new Uint8Array(32)))
|
||||
.setProtectedHeader({ alg })
|
||||
.sign(privateKey);
|
||||
|
||||
utilDecodeProtectedHeader(jws);
|
||||
await jwsFlattenedVerify(jws, publicKey);
|
||||
decodeProtectedHeader(jws);
|
||||
await flattenedVerify(jws, publicKey);
|
||||
}
|
||||
|
||||
async function jwsSymmetricTest(secretKey, alg) {
|
||||
const jws = await new jwsFlattenedSign(crypto.getRandomValues(new Uint8Array(32)))
|
||||
const jws = await new FlattenedSign(crypto.getRandomValues(new Uint8Array(32)))
|
||||
.setProtectedHeader({ alg })
|
||||
.sign(secretKey);
|
||||
|
||||
utilDecodeProtectedHeader(jws);
|
||||
await jwsFlattenedVerify(jws, secretKey);
|
||||
decodeProtectedHeader(jws);
|
||||
await flattenedVerify(jws, secretKey);
|
||||
}
|
||||
|
||||
async function jweSymmetricTest(secretKey, { alg, enc }) {
|
||||
const jwe = await new jweFlattenedEncrypt(crypto.getRandomValues(new Uint8Array(32)))
|
||||
const jwe = await new FlattenedEncrypt(crypto.getRandomValues(new Uint8Array(32)))
|
||||
.setProtectedHeader({ alg, enc })
|
||||
.setAdditionalAuthenticatedData(crypto.getRandomValues(new Uint8Array(32)))
|
||||
.encrypt(secretKey);
|
||||
|
||||
utilDecodeProtectedHeader(jwe);
|
||||
await jweFlattenedDecrypt(jwe, secretKey);
|
||||
decodeProtectedHeader(jwe);
|
||||
await flattenedDecrypt(jwe, secretKey);
|
||||
}
|
||||
|
||||
async function testSPKI(pem, alg) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { assert, assertThrowsAsync } from 'https://deno.land/std@0.109.0/testing/asserts.ts';
|
||||
|
||||
import generateKeyPair from '../dist/deno/util/generate_key_pair.ts';
|
||||
import FlattenedEncrypt from '../dist/deno/jwe/flattened/encrypt.ts';
|
||||
import decryptFlattened from '../dist/deno/jwe/flattened/decrypt.ts';
|
||||
import decodeProtectedHeader from '../dist/deno/util/decode_protected_header.ts';
|
||||
import { generateKeyPair } from '../dist/deno/util/generate_key_pair.ts';
|
||||
import { FlattenedEncrypt } from '../dist/deno/jwe/flattened/encrypt.ts';
|
||||
import { flattenedDecrypt } from '../dist/deno/jwe/flattened/decrypt.ts';
|
||||
import { decodeProtectedHeader } from '../dist/deno/util/decode_protected_header.ts';
|
||||
|
||||
async function test(generate: () => ReturnType<typeof generateKeyPair>, alg: string) {
|
||||
const { publicKey, privateKey } = await generate();
|
||||
|
|
@ -14,7 +14,7 @@ async function test(generate: () => ReturnType<typeof generateKeyPair>, alg: str
|
|||
.encrypt(publicKey);
|
||||
|
||||
assert(decodeProtectedHeader(jwe));
|
||||
await decryptFlattened(jwe, privateKey);
|
||||
await flattenedDecrypt(jwe, privateKey);
|
||||
}
|
||||
|
||||
async function failing(generate: () => ReturnType<typeof generateKeyPair>, alg: string) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { assert } from 'https://deno.land/std@0.109.0/testing/asserts.ts';
|
||||
|
||||
import generateSecret from '../dist/deno/util/generate_secret.ts';
|
||||
import FlattenedEncrypt from '../dist/deno/jwe/flattened/encrypt.ts';
|
||||
import decryptFlattened from '../dist/deno/jwe/flattened/decrypt.ts';
|
||||
import decodeProtectedHeader from '../dist/deno/util/decode_protected_header.ts';
|
||||
import { generateSecret } from '../dist/deno/util/generate_secret.ts';
|
||||
import { FlattenedEncrypt } from '../dist/deno/jwe/flattened/encrypt.ts';
|
||||
import { flattenedDecrypt } from '../dist/deno/jwe/flattened/decrypt.ts';
|
||||
import { decodeProtectedHeader } from '../dist/deno/util/decode_protected_header.ts';
|
||||
|
||||
async function test(
|
||||
generate: () => ReturnType<typeof generateSecret>,
|
||||
|
|
@ -17,7 +17,7 @@ async function test(
|
|||
.encrypt(secretKey);
|
||||
|
||||
assert(decodeProtectedHeader(jwe));
|
||||
await decryptFlattened(jwe, secretKey);
|
||||
await flattenedDecrypt(jwe, secretKey);
|
||||
}
|
||||
|
||||
Deno.test(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { assertThrowsAsync } from 'https://deno.land/std@0.109.0/testing/asserts.ts';
|
||||
|
||||
import createRemoteJWKSet from '../dist/deno/jwks/remote.ts';
|
||||
import { createRemoteJWKSet } from '../dist/deno/jwks/remote.ts';
|
||||
import {
|
||||
JWKSTimeout,
|
||||
JWKSNoMatchingKey,
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import {
|
|||
unreachable,
|
||||
} from 'https://deno.land/std@0.109.0/testing/asserts.ts';
|
||||
|
||||
import generateKeyPair from '../dist/deno/util/generate_key_pair.ts';
|
||||
import generateSecret from '../dist/deno/util/generate_secret.ts';
|
||||
import FlattenedSign from '../dist/deno/jws/flattened/sign.ts';
|
||||
import verifyFlattened from '../dist/deno/jws/flattened/verify.ts';
|
||||
import decodeProtectedHeader from '../dist/deno/util/decode_protected_header.ts';
|
||||
import { generateKeyPair } from '../dist/deno/util/generate_key_pair.ts';
|
||||
import { generateSecret } from '../dist/deno/util/generate_secret.ts';
|
||||
import { FlattenedSign } from '../dist/deno/jws/flattened/sign.ts';
|
||||
import { flattenedVerify } from '../dist/deno/jws/flattened/verify.ts';
|
||||
import { decodeProtectedHeader } from '../dist/deno/util/decode_protected_header.ts';
|
||||
|
||||
async function test(
|
||||
generate: () => ReturnType<typeof generateKeyPair> | ReturnType<typeof generateSecret>,
|
||||
|
|
@ -30,7 +30,7 @@ async function test(
|
|||
.sign(privateKey);
|
||||
|
||||
assert(decodeProtectedHeader(jws));
|
||||
await verifyFlattened({ ...jws }, publicKey);
|
||||
await flattenedVerify({ ...jws }, publicKey);
|
||||
}
|
||||
|
||||
async function failing(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { assertEquals, assertThrowsAsync } from 'https://deno.land/std@0.109.0/t
|
|||
|
||||
import { importJWK } from '../dist/deno/key/import.ts';
|
||||
import { exportJWK } from '../dist/deno/key/export.ts';
|
||||
import calculateJwkThumbprint from '../dist/deno/jwk/thumbprint.ts';
|
||||
import { calculateJwkThumbprint } from '../dist/deno/jwk/thumbprint.ts';
|
||||
|
||||
async function test(jwk: { [key: string]: unknown }, alg: string) {
|
||||
await calculateJwkThumbprint(jwk);
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ import test from 'ava';
|
|||
|
||||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
import(`${root}/jwe/compact/decrypt`).then(
|
||||
({ default: flattenedDecrypt }) => {
|
||||
({ compactDecrypt }) => {
|
||||
test('JWE format validation', async (t) => {
|
||||
await t.throwsAsync(flattenedDecrypt(null, new Uint8Array(0)), {
|
||||
await t.throwsAsync(compactDecrypt(null, new Uint8Array(0)), {
|
||||
message: 'Compact JWE must be a string or Uint8Array',
|
||||
code: 'ERR_JWE_INVALID',
|
||||
});
|
||||
await t.throwsAsync(flattenedDecrypt('...', new Uint8Array(0)), {
|
||||
await t.throwsAsync(compactDecrypt('...', new Uint8Array(0)), {
|
||||
message: 'Invalid Compact JWE',
|
||||
code: 'ERR_JWE_INVALID',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import test from 'ava';
|
|||
|
||||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
import(`${root}/jwe/compact/encrypt`).then(
|
||||
({ default: CompactEncrypt }) => {
|
||||
({ CompactEncrypt }) => {
|
||||
test.before(async (t) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
t.context.plaintext = encode('It’s a dangerous business, Frodo, going out your door.');
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ Promise.all([
|
|||
import(`${root}/util/base64url`),
|
||||
]).then(
|
||||
([
|
||||
{ default: FlattenedEncrypt },
|
||||
{ default: flattenedDecrypt },
|
||||
{ default: CompactEncrypt },
|
||||
{ default: compactDecrypt },
|
||||
{ FlattenedEncrypt },
|
||||
{ flattenedDecrypt },
|
||||
{ CompactEncrypt },
|
||||
{ compactDecrypt },
|
||||
{ importJWK },
|
||||
base64url,
|
||||
]) => {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Promise.all([
|
|||
import(`${root}/jwe/flattened/encrypt`),
|
||||
import(`${root}/jwe/flattened/decrypt`),
|
||||
]).then(
|
||||
([{ default: FlattenedEncrypt }, { default: flattenedDecrypt }]) => {
|
||||
([{ FlattenedEncrypt }, { flattenedDecrypt }]) => {
|
||||
test.before(async (t) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
t.context.plaintext = encode('It’s a dangerous business, Frodo, going out your door.');
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import test from 'ava';
|
|||
|
||||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
import(`${root}/jwe/flattened/encrypt`).then(
|
||||
({ default: FlattenedEncrypt }) => {
|
||||
({ FlattenedEncrypt }) => {
|
||||
test.before(async (t) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
t.context.plaintext = encode('It’s a dangerous business, Frodo, going out your door.');
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import * as crypto from 'crypto';
|
|||
|
||||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
Promise.all([import(`${root}/jwe/flattened/encrypt`), import(`${root}/jwe/general/decrypt`)]).then(
|
||||
([{ default: FlattenedEncrypt }, { default: generalDecrypt }]) => {
|
||||
([{ FlattenedEncrypt }, { generalDecrypt }]) => {
|
||||
test.before(async (t) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
t.context.plaintext = encode('It’s a dangerous business, Frodo, going out your door.');
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ Promise.all([
|
|||
import(`${keyRoot}/util/generate_secret`),
|
||||
]).then(
|
||||
([
|
||||
{ default: FlattenedEncrypt },
|
||||
{ default: decryptFlattened },
|
||||
{ FlattenedEncrypt },
|
||||
{ flattenedDecrypt },
|
||||
{ encode: base64url },
|
||||
{ importJWK },
|
||||
{ default: generateKeyPair },
|
||||
{ default: generateSecret },
|
||||
{ generateKeyPair },
|
||||
{ generateSecret },
|
||||
]) => {
|
||||
function pubjwk(jwk) {
|
||||
const { d, p, q, dp, dq, qi, ...publicJwk } = jwk;
|
||||
|
|
@ -268,7 +268,7 @@ Promise.all([
|
|||
)
|
||||
.setAdditionalAuthenticatedData(crypto.randomFillSync(new Uint8Array(128 >> 3)))
|
||||
.encrypt(pub);
|
||||
await decryptFlattened(jwe, priv);
|
||||
await flattenedDecrypt(jwe, priv);
|
||||
}),
|
||||
...fixtures.algs.map(async (alg) => {
|
||||
let priv;
|
||||
|
|
@ -296,7 +296,7 @@ Promise.all([
|
|||
)
|
||||
.setAdditionalAuthenticatedData(crypto.randomFillSync(new Uint8Array(128 >> 3)))
|
||||
.encrypt(pub);
|
||||
await decryptFlattened(jwe, priv);
|
||||
await flattenedDecrypt(jwe, priv);
|
||||
}),
|
||||
]);
|
||||
t.pass();
|
||||
|
|
|
|||
|
|
@ -18,12 +18,7 @@ Promise.all([
|
|||
import(`${keyRoot}/key/import`),
|
||||
import(`${keyRoot}/jwk/embedded`),
|
||||
]).then(
|
||||
([
|
||||
{ default: FlattenedSign },
|
||||
{ default: flattenedVerify },
|
||||
{ importJWK },
|
||||
{ default: EmbeddedJWK },
|
||||
]) => {
|
||||
([{ FlattenedSign }, { flattenedVerify }, { importJWK }, { EmbeddedJWK }]) => {
|
||||
function pubjwk(jwk) {
|
||||
const { d, p, q, dp, dq, qi, ext, alg, ...publicJwk } = jwk;
|
||||
return publicJwk;
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ if ('WEBCRYPTO' in process.env) {
|
|||
}
|
||||
|
||||
import(`${keyRoot}/jwk/thumbprint`).then(
|
||||
({ default: thumbprint }) => {
|
||||
({ calculateJwkThumbprint }) => {
|
||||
test('https://tools.ietf.org/html/rfc7638#section-3.1', async (t) => {
|
||||
t.is(
|
||||
await thumbprint({
|
||||
await calculateJwkThumbprint({
|
||||
kty: 'RSA',
|
||||
n: '0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbISD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqbw0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw',
|
||||
e: 'AQAB',
|
||||
|
|
@ -27,23 +27,23 @@ import(`${keyRoot}/jwk/thumbprint`).then(
|
|||
});
|
||||
|
||||
test('JWK must be an object', async (t) => {
|
||||
await t.throwsAsync(thumbprint(true), {
|
||||
await t.throwsAsync(calculateJwkThumbprint(true), {
|
||||
instanceOf: TypeError,
|
||||
message: 'JWK must be an object',
|
||||
});
|
||||
await t.throwsAsync(thumbprint(null), {
|
||||
await t.throwsAsync(calculateJwkThumbprint(null), {
|
||||
instanceOf: TypeError,
|
||||
message: 'JWK must be an object',
|
||||
});
|
||||
await t.throwsAsync(thumbprint(Boolean), {
|
||||
await t.throwsAsync(calculateJwkThumbprint(Boolean), {
|
||||
instanceOf: TypeError,
|
||||
message: 'JWK must be an object',
|
||||
});
|
||||
await t.throwsAsync(thumbprint([]), {
|
||||
await t.throwsAsync(calculateJwkThumbprint([]), {
|
||||
instanceOf: TypeError,
|
||||
message: 'JWK must be an object',
|
||||
});
|
||||
await t.throwsAsync(thumbprint(''), {
|
||||
await t.throwsAsync(calculateJwkThumbprint(''), {
|
||||
instanceOf: TypeError,
|
||||
message: 'JWK must be an object',
|
||||
});
|
||||
|
|
@ -52,11 +52,11 @@ import(`${keyRoot}/jwk/thumbprint`).then(
|
|||
nullPrototype.kty = 'EC';
|
||||
nullPrototype.x = 'q3zAwR_kUwtdLEwtB2oVfucXiLHmEhu9bJUFYjJxYGs';
|
||||
nullPrototype.y = '8h0D-ONoU-iZqrq28TyUxEULxuGwJZGMJYTMbeMshvI';
|
||||
await t.notThrowsAsync(thumbprint(nullPrototype));
|
||||
await t.notThrowsAsync(calculateJwkThumbprint(nullPrototype));
|
||||
});
|
||||
|
||||
test('JWK kty must be recognized', async (t) => {
|
||||
await t.throwsAsync(thumbprint({ kty: 'unrecognized' }), {
|
||||
await t.throwsAsync(calculateJwkThumbprint({ kty: 'unrecognized' }), {
|
||||
code: 'ERR_JOSE_NOT_SUPPORTED',
|
||||
message: '"kty" (Key Type) Parameter missing or unsupported',
|
||||
});
|
||||
|
|
@ -70,19 +70,19 @@ import(`${keyRoot}/jwk/thumbprint`).then(
|
|||
y: '8h0D-ONoU-iZqrq28TyUxEULxuGwJZGMJYTMbeMshvI',
|
||||
};
|
||||
|
||||
await t.throwsAsync(thumbprint({ ...ec, crv: undefined }), {
|
||||
await t.throwsAsync(calculateJwkThumbprint({ ...ec, crv: undefined }), {
|
||||
code: 'ERR_JWK_INVALID',
|
||||
message: '"crv" (Curve) Parameter missing or invalid',
|
||||
});
|
||||
await t.throwsAsync(thumbprint({ ...ec, x: undefined }), {
|
||||
await t.throwsAsync(calculateJwkThumbprint({ ...ec, x: undefined }), {
|
||||
code: 'ERR_JWK_INVALID',
|
||||
message: '"x" (X Coordinate) Parameter missing or invalid',
|
||||
});
|
||||
await t.throwsAsync(thumbprint({ ...ec, y: undefined }), {
|
||||
await t.throwsAsync(calculateJwkThumbprint({ ...ec, y: undefined }), {
|
||||
code: 'ERR_JWK_INVALID',
|
||||
message: '"y" (Y Coordinate) Parameter missing or invalid',
|
||||
});
|
||||
t.is(await thumbprint(ec), 'ZrBaai73Hi8Fg4MElvDGzIne2NsbI75RHubOViHYE5Q');
|
||||
t.is(await calculateJwkThumbprint(ec), 'ZrBaai73Hi8Fg4MElvDGzIne2NsbI75RHubOViHYE5Q');
|
||||
});
|
||||
|
||||
test('OKP JWK', async (t) => {
|
||||
|
|
@ -92,15 +92,15 @@ import(`${keyRoot}/jwk/thumbprint`).then(
|
|||
x: '5fL1GDeyNTIxtuzTeFnvZTo4Oz0EkMfAdhIJA-EFn0w',
|
||||
};
|
||||
|
||||
await t.throwsAsync(thumbprint({ ...okp, crv: undefined }), {
|
||||
await t.throwsAsync(calculateJwkThumbprint({ ...okp, crv: undefined }), {
|
||||
code: 'ERR_JWK_INVALID',
|
||||
message: '"crv" (Subtype of Key Pair) Parameter missing or invalid',
|
||||
});
|
||||
await t.throwsAsync(thumbprint({ ...okp, x: undefined }), {
|
||||
await t.throwsAsync(calculateJwkThumbprint({ ...okp, x: undefined }), {
|
||||
code: 'ERR_JWK_INVALID',
|
||||
message: '"x" (Public Key) Parameter missing or invalid',
|
||||
});
|
||||
t.is(await thumbprint(okp), '1OzNmMHhNzbSJyoePAtdoVedRZlFvER3K3RAzCrfX0k');
|
||||
t.is(await calculateJwkThumbprint(okp), '1OzNmMHhNzbSJyoePAtdoVedRZlFvER3K3RAzCrfX0k');
|
||||
});
|
||||
|
||||
test('RSA JWK', async (t) => {
|
||||
|
|
@ -110,15 +110,15 @@ import(`${keyRoot}/jwk/thumbprint`).then(
|
|||
n: 'ok6WYUlmj2J1p-Sm0kwaZlAbWetUooe2LR6iAOJfntavWlyBO0shK_550YG3lQ6R1YeKisNAqbQ1pjqo3vwvR_v_AWtZ1gY1h6KX4DhCv0nNMexZ4g67LxEweoQ4_InMMiwMyQ3CRVJ3P1w0TQZYqzfSye-llY39tyzHeHeuotgrZrM427iUuIJdN38nZ2vW9VpK3bo_Nsvl12ZBe6x7DBzWEFHqQDFyjy8lH8EZyxqDArLA7T5OAcEdkm3RI8jBbsrUD9IySCE5SdEU3n0VGNGkT88DFU85QGvLpL2ITbGX0amaJvxYjIRhIYTfZS6Mqoxr6K1LIwP8pu0VD2Ca5Q',
|
||||
};
|
||||
|
||||
await t.throwsAsync(thumbprint({ ...rsa, e: undefined }), {
|
||||
await t.throwsAsync(calculateJwkThumbprint({ ...rsa, e: undefined }), {
|
||||
code: 'ERR_JWK_INVALID',
|
||||
message: '"e" (Exponent) Parameter missing or invalid',
|
||||
});
|
||||
await t.throwsAsync(thumbprint({ ...rsa, n: undefined }), {
|
||||
await t.throwsAsync(calculateJwkThumbprint({ ...rsa, n: undefined }), {
|
||||
code: 'ERR_JWK_INVALID',
|
||||
message: '"n" (Modulus) Parameter missing or invalid',
|
||||
});
|
||||
t.is(await thumbprint(rsa), 'dQiQXSGtV4XcPK143Cu2-ZSsQtVNjQZrleUMs9nLnKQ');
|
||||
t.is(await calculateJwkThumbprint(rsa), 'dQiQXSGtV4XcPK143Cu2-ZSsQtVNjQZrleUMs9nLnKQ');
|
||||
});
|
||||
|
||||
test('oct JWK', async (t) => {
|
||||
|
|
@ -127,11 +127,11 @@ import(`${keyRoot}/jwk/thumbprint`).then(
|
|||
kty: 'oct',
|
||||
};
|
||||
|
||||
await t.throwsAsync(thumbprint({ ...oct, k: undefined }), {
|
||||
await t.throwsAsync(calculateJwkThumbprint({ ...oct, k: undefined }), {
|
||||
code: 'ERR_JWK_INVALID',
|
||||
message: '"k" (Key Value) Parameter missing or invalid',
|
||||
});
|
||||
t.is(await thumbprint(oct), 'prDKy90VJzrDTpm8-W2Q_pv_kzrX_zyZ7ANjRAasDxc');
|
||||
t.is(await calculateJwkThumbprint(oct), 'prDKy90VJzrDTpm8-W2Q_pv_kzrX_zyZ7ANjRAasDxc');
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
|
|
|
|||
|
|
@ -22,12 +22,7 @@ Promise.all([
|
|||
import(`${keyRoot}/key/import`),
|
||||
import(`${keyRoot}/jwks/remote`),
|
||||
]).then(
|
||||
([
|
||||
{ default: jwtVerify },
|
||||
{ default: SignJWT },
|
||||
{ importJWK },
|
||||
{ default: createRemoteJWKSet },
|
||||
]) => {
|
||||
([{ jwtVerify }, { SignJWT }, { importJWK }, { createRemoteJWKSet }]) => {
|
||||
const now = 1604416038;
|
||||
|
||||
test.before(async (t) => {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import test from 'ava';
|
|||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
|
||||
import(`${root}/jws/compact/sign`).then(
|
||||
({ default: CompactSign }) => {
|
||||
({ CompactSign }) => {
|
||||
test.before((t) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
t.context.payload = encode('It’s a dangerous business, Frodo, going out your door.');
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ import test from 'ava';
|
|||
|
||||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
import(`${root}/jws/compact/verify`).then(
|
||||
({ default: flattenedVerify }) => {
|
||||
({ compactVerify }) => {
|
||||
test('JWS format validation', async (t) => {
|
||||
await t.throwsAsync(flattenedVerify(null, new Uint8Array(0)), {
|
||||
await t.throwsAsync(compactVerify(null, new Uint8Array(0)), {
|
||||
message: 'Compact JWS must be a string or Uint8Array',
|
||||
code: 'ERR_JWS_INVALID',
|
||||
});
|
||||
await t.throwsAsync(flattenedVerify('.....', new Uint8Array(0)), {
|
||||
await t.throwsAsync(compactVerify('.....', new Uint8Array(0)), {
|
||||
message: 'Invalid Compact JWS',
|
||||
code: 'ERR_JWS_INVALID',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,13 +19,7 @@ Promise.all([
|
|||
import(`${root}/jws/compact/verify`),
|
||||
import(`${keyRoot}/key/import`),
|
||||
]).then(
|
||||
([
|
||||
{ default: FlattenedSign },
|
||||
{ default: flattenedVerify },
|
||||
{ default: CompactSign },
|
||||
{ default: compactVerify },
|
||||
{ importJWK },
|
||||
]) => {
|
||||
([{ FlattenedSign }, { flattenedVerify }, { CompactSign }, { compactVerify }, { importJWK }]) => {
|
||||
const flattened = {
|
||||
Sign: FlattenedSign,
|
||||
verify: flattenedVerify,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import test from 'ava';
|
|||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
|
||||
Promise.all([import(`${root}/jws/flattened/sign`), import(`${root}/jws/flattened/verify`)]).then(
|
||||
([{ default: FlattenedSign }, { default: flattenedVerify }]) => {
|
||||
([{ FlattenedSign }, { flattenedVerify }]) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
|
||||
test('crit member checks check', async (t) => {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import test from 'ava';
|
|||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
|
||||
import(`${root}/jws/flattened/sign`).then(
|
||||
({ default: FlattenedSign }) => {
|
||||
({ FlattenedSign }) => {
|
||||
test.before(async (t) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
t.context.payload = encode('It’s a dangerous business, Frodo, going out your door.');
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import * as crypto from 'crypto';
|
|||
|
||||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
Promise.all([import(`${root}/jws/flattened/sign`), import(`${root}/jws/flattened/verify`)]).then(
|
||||
([{ default: FlattenedSign }, { default: flattenedVerify }]) => {
|
||||
([{ FlattenedSign }, { flattenedVerify }]) => {
|
||||
test.before(async (t) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
t.context.plaintext = encode('It’s a dangerous business, Frodo, going out your door.');
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import * as crypto from 'crypto';
|
|||
|
||||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
Promise.all([import(`${root}/jws/general/sign`), import(`${root}/jws/general/verify`)]).then(
|
||||
([{ default: GeneralSign }, { default: generalVerify }]) => {
|
||||
([{ GeneralSign }, { generalVerify }]) => {
|
||||
test.before(async (t) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
t.context.plaintext = encode('It’s a dangerous business, Frodo, going out your door.');
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ Promise.all([
|
|||
import(`${keyRoot}/key/import`),
|
||||
]).then(
|
||||
([
|
||||
{ default: FlattenedSign },
|
||||
{ default: flattenedVerify },
|
||||
{ default: FlattenedEncrypt },
|
||||
{ default: flattenedDecrypt },
|
||||
{ FlattenedSign },
|
||||
{ flattenedVerify },
|
||||
{ FlattenedEncrypt },
|
||||
{ flattenedDecrypt },
|
||||
base64url,
|
||||
{ default: generateKeyPair },
|
||||
{ generateKeyPair },
|
||||
{ importJWK },
|
||||
]) => {
|
||||
function pubjwk(jwk) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const rsaPssParams = major >= 17 || (major === 16 && minor >= 9);
|
|||
const electron = 'electron' in process.versions;
|
||||
|
||||
Promise.all([import('jose/jws/flattened/sign'), import('jose/jws/flattened/verify')]).then(
|
||||
([{ default: FlattenedSign }, { default: flattenedVerify }]) => {
|
||||
([{ FlattenedSign }, { flattenedVerify }]) => {
|
||||
if (rsaPssParams) {
|
||||
for (const length of [256, 384, 512]) {
|
||||
test(`valid RSASSA-PSS-Params PS${length}`, async (t) => {
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ Promise.all([
|
|||
import(`${keyRoot}/util/generate_secret`),
|
||||
]).then(
|
||||
([
|
||||
{ default: FlattenedSign },
|
||||
{ default: verifyFlattened },
|
||||
{ FlattenedSign },
|
||||
{ flattenedVerify },
|
||||
{ encode: base64url },
|
||||
{ importJWK },
|
||||
{ default: generateKeyPair },
|
||||
{ default: generateSecret },
|
||||
{ generateKeyPair },
|
||||
{ generateSecret },
|
||||
]) => {
|
||||
function pubjwk(jwk) {
|
||||
const { d, p, q, dp, dq, qi, ...publicJwk } = jwk;
|
||||
|
|
@ -183,7 +183,7 @@ Promise.all([
|
|||
const jws = await new FlattenedSign(crypto.randomFillSync(new Uint8Array(256 >> 3)))
|
||||
.setProtectedHeader({ alg })
|
||||
.sign(priv);
|
||||
await verifyFlattened(jws, pub);
|
||||
await flattenedVerify(jws, pub);
|
||||
}),
|
||||
...fixtures.algs.map(async (alg) => {
|
||||
let priv;
|
||||
|
|
@ -199,7 +199,7 @@ Promise.all([
|
|||
const jws = await new FlattenedSign(crypto.randomFillSync(new Uint8Array(256 >> 3)))
|
||||
.setProtectedHeader({ alg })
|
||||
.sign(priv);
|
||||
await verifyFlattened(jws, pub);
|
||||
await flattenedVerify(jws, pub);
|
||||
}),
|
||||
]);
|
||||
t.pass();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import test from 'ava';
|
|||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
|
||||
Promise.all([import(`${root}/jws/flattened/sign`), import(`${root}/jws/flattened/verify`)]).then(
|
||||
([{ default: FlattenedSign }, { default: flattenedVerify }]) => {
|
||||
([{ FlattenedSign }, { flattenedVerify }]) => {
|
||||
const encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
||||
|
||||
test('JSON Web Signature (JWS) Unencoded Payload Option', async (t) => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Promise.all([
|
|||
import(`${root}/jwt/decrypt`),
|
||||
import(`${root}/jwe/compact/encrypt`),
|
||||
]).then(
|
||||
([{ default: EncryptJWT }, { default: jwtDecrypt }, { default: CompactEncrypt }]) => {
|
||||
([{ EncryptJWT }, { jwtDecrypt }, { CompactEncrypt }]) => {
|
||||
const now = 1604416038;
|
||||
|
||||
test.before(async (t) => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Promise.all([
|
|||
import(`${root}/jwe/compact/decrypt`),
|
||||
import(`${root}/jwt/decrypt`),
|
||||
]).then(
|
||||
([{ default: EncryptJWT }, { default: compactDecrypt }, { default: jwtDecrypt }]) => {
|
||||
([{ EncryptJWT }, { compactDecrypt }, { jwtDecrypt }]) => {
|
||||
const now = 1604416038;
|
||||
|
||||
test.before(async (t) => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Promise.all([
|
|||
import(`${root}/jws/compact/verify`),
|
||||
import(`${root}/jwt/verify`),
|
||||
]).then(
|
||||
([{ default: SignJWT }, { default: compactVerify }, { default: jwtVerify }]) => {
|
||||
([{ SignJWT }, { compactVerify }, { jwtVerify }]) => {
|
||||
const now = 1604416038;
|
||||
|
||||
test.before(async (t) => {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import timekeeper from 'timekeeper';
|
|||
|
||||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
import(`${root}/jwt/unsecured`).then(
|
||||
({ default: UnsecuredJWT }) => {
|
||||
({ UnsecuredJWT }) => {
|
||||
const now = 1604416038;
|
||||
|
||||
test.before(async (t) => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Promise.all([
|
|||
import(`${root}/jwt/verify`),
|
||||
import(`${root}/jws/compact/sign`),
|
||||
]).then(
|
||||
([{ default: SignJWT }, { default: jwtVerify }, { default: CompactSign }]) => {
|
||||
([{ SignJWT }, { jwtVerify }, { CompactSign }]) => {
|
||||
const now = 1604416038;
|
||||
|
||||
test.before(async (t) => {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ Promise.all([
|
|||
import(`${keyRoot}/util/generate_key_pair`),
|
||||
import(`${keyRoot}/util/generate_secret`),
|
||||
]).then(
|
||||
([{ default: checkKeyType }, { default: generateKeyPair }, { default: generateSecret }]) => {
|
||||
([{ default: checkKeyType }, { generateKeyPair }, { generateSecret }]) => {
|
||||
test('lib/check_key_type.ts', async (t) => {
|
||||
const expected = {
|
||||
instanceOf: TypeError,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import test from 'ava';
|
|||
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
||||
|
||||
import(`${root}/util/decode_protected_header`).then(
|
||||
({ default: decodeProtectedHeader }) => {
|
||||
({ decodeProtectedHeader }) => {
|
||||
test('invalid inputs', (t) => {
|
||||
t.throws(() => decodeProtectedHeader(null), {
|
||||
instanceOf: TypeError,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Promise.all([
|
|||
import(`${keyRoot}/util/generate_key_pair`),
|
||||
import(`${keyRoot}/util/generate_secret`),
|
||||
]).then(
|
||||
([{ default: generateKeyPair }, { default: generateSecret }]) => {
|
||||
([{ generateKeyPair }, { generateSecret }]) => {
|
||||
let checkModulusLength;
|
||||
let getNamedCurve;
|
||||
async function testKeyPair(t, alg, options) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue