@@ -53,6 +53,7 @@ export interface ModelConfiguration {
53
53
apiNamespace : string
54
54
jsonapiType : string
55
55
endpoint : string
56
+ credentialStorageBackend : StorageBackend ,
56
57
jwt : string
57
58
jwtStorage : string | false
58
59
keyCase : KeyCase
@@ -117,17 +118,30 @@ export const applyModelConfig = <T extends typeof JSORMBase>(
117
118
) : void => {
118
119
let k : keyof ModelConfigurationOptions
119
120
120
- for ( k in config ) {
121
- if ( config . hasOwnProperty ( k ) && k !== 'jwt' ) {
122
- ModelClass [ k ] = config [ k ]
123
- }
121
+ config = { ...config } // clone since we're going to mutate it
122
+
123
+ // Handle all JWT configuration at once since it's run-order dependent
124
+ // We'll delete each key we encounter then pass the rest off to
125
+ // a loop for assigning other arbitrary options
126
+ if ( config . credentialStorageBackend ) {
127
+ ModelClass . credentialStorageBackend = config . credentialStorageBackend
128
+ delete config . jwtStorage
129
+ }
130
+
131
+ if ( config . jwtStorage ) {
132
+ ModelClass . jwtStorage = config . jwtStorage
133
+ delete config . jwtStorage
124
134
}
125
135
126
- // Run this one last, since either the Credential Storage strategy
127
- // or the store key could be set in options alongside this, otherwise
128
- // this is dependent on option declaration order
129
136
if ( config . jwt ) {
130
137
ModelClass . setJWT ( config . jwt )
138
+ delete config . jwt
139
+ }
140
+
141
+ for ( k in config ) {
142
+ if ( config . hasOwnProperty ( k ) ) {
143
+ ModelClass [ k ] = config [ k ]
144
+ }
131
145
}
132
146
133
147
if ( ModelClass . isBaseClass === undefined ) {
0 commit comments