@@ -36,6 +36,7 @@ import { AsymmetricKeyFormatValues } from "@/features/common/values/asymmetric-k
36
36
import { useDebuggerStore } from "@/features/debugger/services/debugger.store" ;
37
37
import { SigningAlgCategoryValues } from "@/features/common/values/signing-alg-category.values" ;
38
38
import { EncoderInputsModel } from "@/features/debugger/models/encoder-inputs.model" ;
39
+ import { EncoderResult } from "@/features/common/models/encoder-result.model" ;
39
40
40
41
type EncodingHeaderErrors = {
41
42
headerErrors : string [ ] | null ;
@@ -68,11 +69,6 @@ type EncodingJwtErrors = {
68
69
encodingErrors : string [ ] | null ;
69
70
} ;
70
71
71
- type EncodingResult = {
72
- jwt : string ;
73
- signingErrors : string [ ] | null ;
74
- }
75
-
76
72
class _TokenEncoderService {
77
73
async selectEncodingExample (
78
74
algorithmPickerOptionValue : string ,
@@ -490,7 +486,7 @@ class _TokenEncoderService {
490
486
payload : DecodedJwtPayloadModel ,
491
487
key : string ,
492
488
encodingFormat : EncodingValues ,
493
- ) : Promise < Result < EncodingResult , DebuggerErrorModel > > {
489
+ ) : Promise < Result < EncoderResult , DebuggerErrorModel > > {
494
490
if ( ! isHmacAlg ( header . alg ) ) {
495
491
return err ( {
496
492
task : DebuggerTaskValues . ENCODE ,
@@ -542,7 +538,7 @@ class _TokenEncoderService {
542
538
} ) ;
543
539
}
544
540
545
- return ok < EncodingResult > ( {
541
+ return ok < EncoderResult > ( {
546
542
jwt : signWithSymmetricSecretKeyResult . value ,
547
543
signingErrors : signingError ,
548
544
} ) ;
@@ -553,7 +549,7 @@ class _TokenEncoderService {
553
549
payload : DecodedJwtPayloadModel ,
554
550
key : string ,
555
551
keyFormat : AsymmetricKeyFormatValues ,
556
- ) : Promise < Result < EncodingResult , DebuggerErrorModel > > {
552
+ ) : Promise < Result < EncoderResult , DebuggerErrorModel > > {
557
553
if ( isDigitalSignatureAlg ( header . alg ) ) {
558
554
if ( ! key ) {
559
555
return err ( {
@@ -716,7 +712,7 @@ class _TokenEncoderService {
716
712
symmetricSecretKeyEncoding : EncodingValues ;
717
713
} ) : Promise <
718
714
Result <
719
- EncodingResult ,
715
+ EncoderResult ,
720
716
EncodingSymmetricSecretKeyErrors
721
717
>
722
718
> {
@@ -892,15 +888,15 @@ class _TokenEncoderService {
892
888
} ,
893
889
) : Promise <
894
890
Result <
895
- EncodingResult ,
891
+ EncoderResult ,
896
892
EncodingJwtErrors
897
893
>
898
894
> {
899
895
const algType = params . algType ;
900
896
const header = params . header ;
901
897
const payload = params . payload ;
902
898
903
- let encodeJWTResult : Result < EncodingResult , DebuggerErrorModel > | null = null ;
899
+ let encodeJWTResult : Result < EncoderResult , DebuggerErrorModel > | null = null ;
904
900
905
901
if ( algType === SigningAlgCategoryValues . ANY ) {
906
902
const symmetricSecretKey = params . symmetricSecretKey ;
@@ -1027,7 +1023,7 @@ class _TokenEncoderService {
1027
1023
}
1028
1024
}
1029
1025
1030
- return ok < EncodingResult > ( {
1026
+ return ok < EncoderResult > ( {
1031
1027
jwt : encodeJWTResult . value . jwt ,
1032
1028
signingErrors : encodeJWTResult . value . signingErrors ,
1033
1029
} ) ;
0 commit comments