Skip to content

Commit ab18881

Browse files
committed
refactor: hide internal private fields and drop ProduceJWT inheritance
1 parent 8b73687 commit ab18881

File tree

22 files changed

+581
-477
lines changed

22 files changed

+581
-477
lines changed

docs/jwe/general/encrypt/interfaces/Recipient.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Used to build General JWE object's individual recipients.
1212

1313
**addRecipient**(...`args`): [`Recipient`](Recipient.md)
1414

15-
A shorthand for calling addRecipient() on the enclosing GeneralEncrypt instance
15+
A shorthand for calling addRecipient() on the enclosing [GeneralEncrypt](../classes/GeneralEncrypt.md) instance
1616

1717
#### Parameters
1818

@@ -30,7 +30,7 @@ A shorthand for calling addRecipient() on the enclosing GeneralEncrypt instance
3030

3131
**done**(): [`GeneralEncrypt`](../classes/GeneralEncrypt.md)
3232

33-
Returns the enclosing GeneralEncrypt
33+
Returns the enclosing [GeneralEncrypt](../classes/GeneralEncrypt.md) instance
3434

3535
#### Returns
3636

@@ -42,7 +42,7 @@ Returns the enclosing GeneralEncrypt
4242

4343
**encrypt**(...`args`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`GeneralJWE`](../../../../types/interfaces/GeneralJWE.md)\>
4444

45-
A shorthand for calling encrypt() on the enclosing GeneralEncrypt instance
45+
A shorthand for calling encrypt() on the enclosing [GeneralEncrypt](../classes/GeneralEncrypt.md) instance
4646

4747
#### Parameters
4848

docs/jws/general/sign/interfaces/Signature.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Used to build General JWS object's individual signatures.
1212

1313
**addSignature**(...`args`): [`Signature`](Signature.md)
1414

15-
A shorthand for calling addSignature() on the enclosing GeneralSign instance
15+
A shorthand for calling addSignature() on the enclosing [GeneralSign](../classes/GeneralSign.md) instance
1616

1717
#### Parameters
1818

@@ -30,7 +30,7 @@ A shorthand for calling addSignature() on the enclosing GeneralSign instance
3030

3131
**done**(): [`GeneralSign`](../classes/GeneralSign.md)
3232

33-
Returns the enclosing GeneralSign
33+
Returns the enclosing [GeneralSign](../classes/GeneralSign.md) instance
3434

3535
#### Returns
3636

@@ -78,7 +78,7 @@ Sets the JWS Unprotected Header on the Signature object.
7878

7979
**sign**(...`args`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`GeneralJWS`](../../../../types/interfaces/GeneralJWS.md)\>
8080

81-
A shorthand for calling encrypt() on the enclosing GeneralSign instance
81+
A shorthand for calling encrypt() on the enclosing [GeneralSign](../classes/GeneralSign.md) instance
8282

8383
#### Parameters
8484

docs/jwt/produce/README.md

-7
This file was deleted.

docs/types/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
- [JWTPayload](interfaces/JWTPayload.md)
4343
- [JWTVerifyResult](interfaces/JWTVerifyResult.md)
4444
- [KeyObject](interfaces/KeyObject.md)
45+
- [ProduceJWT](interfaces/ProduceJWT.md)
4546
- [ResolvedKey](interfaces/ResolvedKey.md)
4647
- [SignOptions](interfaces/SignOptions.md)
4748
- [VerifyOptions](interfaces/VerifyOptions.md)

docs/jwt/produce/classes/ProduceJWT.md renamed to docs/types/interfaces/ProduceJWT.md

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
1-
# Class: ProduceJWT
1+
# Interface: ProduceJWT
22

33
## [💗 Help the project](https://github.com/sponsors/panva)
44

55
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).
66

7-
Generic class for JWT producing.
8-
9-
## Constructors
10-
11-
### new ProduceJWT()
12-
13-
**new ProduceJWT**(`payload`): [`ProduceJWT`](ProduceJWT.md)
14-
15-
[ProduceJWT](ProduceJWT.md) constructor
16-
17-
#### Parameters
18-
19-
| Parameter | Type | Description |
20-
| ------ | ------ | ------ |
21-
| `payload` | [`JWTPayload`](../../../types/interfaces/JWTPayload.md) | The JWT Claims Set object. Defaults to an empty object. |
22-
23-
#### Returns
24-
25-
[`ProduceJWT`](ProduceJWT.md)
7+
Generic interface for JWT producing classes.
268

279
## Methods
2810

docs/util/errors/classes/JWTExpired.md

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ if (err instanceof jose.errors.JWTExpired) {
2424
}
2525
```
2626

27-
## Implements
28-
29-
- [`JWTClaimValidationFailed`](JWTClaimValidationFailed.md)
30-
3127
## Properties
3228

3329
### claim

patches/typedoc-plugin-markdown+4.3.1.patch

+19
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ index 3bac9b3..147c793 100644
3131
const md = [];
3232
if (model.implementationOf) {
3333
if (options.headingLevel !== -1) {
34+
diff --git a/node_modules/typedoc-plugin-markdown/dist/theme/context/partials/member.memberWithGroups.js b/node_modules/typedoc-plugin-markdown/dist/theme/context/partials/member.memberWithGroups.js
35+
index 98bc919..4854c90 100644
36+
--- a/node_modules/typedoc-plugin-markdown/dist/theme/context/partials/member.memberWithGroups.js
37+
+++ b/node_modules/typedoc-plugin-markdown/dist/theme/context/partials/member.memberWithGroups.js
38+
@@ -24,10 +24,10 @@ export function memberWithGroups(model, options) {
39+
md.push(this.partials.typeParametersList(model.typeParameters));
40+
}
41+
}
42+
- if (model.implementedTypes?.length) {
43+
- md.push(heading(options.headingLevel, this.i18n.theme_implements()));
44+
- md.push(unorderedList(model.implementedTypes.map((implementedType) => this.partials.someType(implementedType))));
45+
- }
46+
+ // if (model.implementedTypes?.length) {
47+
+ // md.push(heading(options.headingLevel, this.i18n.theme_implements()));
48+
+ // md.push(unorderedList(model.implementedTypes.map((implementedType) => this.partials.someType(implementedType))));
49+
+ // }
50+
if (model.kind === ReflectionKind.Class && model.categories?.length) {
51+
model.groups
52+
?.filter((group) => group.title === this.i18n.kind_plural_constructor())
3453
diff --git a/node_modules/typedoc-plugin-markdown/dist/theme/context/partials/member.reflectionIndex.js b/node_modules/typedoc-plugin-markdown/dist/theme/context/partials/member.reflectionIndex.js
3554
index bcb597c..d96c2eb 100644
3655
--- a/node_modules/typedoc-plugin-markdown/dist/theme/context/partials/member.reflectionIndex.js

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export { jwtVerify } from './jwt/verify.js'
1818
export type { JWTVerifyOptions, JWTVerifyGetKey } from './jwt/verify.js'
1919
export { jwtDecrypt } from './jwt/decrypt.js'
2020
export type { JWTDecryptOptions, JWTDecryptGetKey } from './jwt/decrypt.js'
21-
export type { ProduceJWT } from './jwt/produce.js'
2221

2322
export { CompactEncrypt } from './jwe/compact/encrypt.js'
2423
export { FlattenedEncrypt } from './jwe/flattened/encrypt.js'
@@ -104,6 +103,7 @@ export type {
104103
JWTPayload,
105104
JWTVerifyResult,
106105
KeyObject,
106+
ProduceJWT,
107107
ResolvedKey,
108108
SignOptions,
109109
VerifyOptions,

src/jwe/compact/encrypt.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,15 @@ import { FlattenedEncrypt } from '../flattened/encrypt.js'
2626
* ```
2727
*/
2828
export class CompactEncrypt {
29-
/** @ignore */
30-
private _flattened: FlattenedEncrypt
29+
#flattened: FlattenedEncrypt
3130

3231
/**
3332
* {@link CompactEncrypt} constructor
3433
*
3534
* @param plaintext Binary representation of the plaintext to encrypt.
3635
*/
3736
constructor(plaintext: Uint8Array) {
38-
this._flattened = new FlattenedEncrypt(plaintext)
37+
this.#flattened = new FlattenedEncrypt(plaintext)
3938
}
4039

4140
/**
@@ -48,7 +47,7 @@ export class CompactEncrypt {
4847
* @param cek JWE Content Encryption Key.
4948
*/
5049
setContentEncryptionKey(cek: Uint8Array): this {
51-
this._flattened.setContentEncryptionKey(cek)
50+
this.#flattened.setContentEncryptionKey(cek)
5251
return this
5352
}
5453

@@ -62,7 +61,7 @@ export class CompactEncrypt {
6261
* @param iv JWE Initialization Vector.
6362
*/
6463
setInitializationVector(iv: Uint8Array): this {
65-
this._flattened.setInitializationVector(iv)
64+
this.#flattened.setInitializationVector(iv)
6665
return this
6766
}
6867

@@ -72,7 +71,7 @@ export class CompactEncrypt {
7271
* @param protectedHeader JWE Protected Header object.
7372
*/
7473
setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this {
75-
this._flattened.setProtectedHeader(protectedHeader)
74+
this.#flattened.setProtectedHeader(protectedHeader)
7675
return this
7776
}
7877

@@ -84,7 +83,7 @@ export class CompactEncrypt {
8483
* @param parameters JWE Key Management parameters.
8584
*/
8685
setKeyManagementParameters(parameters: types.JWEKeyManagementHeaderParameters): this {
87-
this._flattened.setKeyManagementParameters(parameters)
86+
this.#flattened.setKeyManagementParameters(parameters)
8887
return this
8988
}
9089

@@ -99,7 +98,7 @@ export class CompactEncrypt {
9998
key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array,
10099
options?: types.EncryptOptions,
101100
): Promise<string> {
102-
const jwe = await this._flattened.encrypt(key, options)
101+
const jwe = await this.#flattened.encrypt(key, options)
103102

104103
return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.')
105104
}

0 commit comments

Comments
 (0)