File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
app-config-encryption/src Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -778,7 +778,22 @@ export function getRevisionNumber(revision: string) {
778778export function latestSymmetricKeyRevision (
779779 keys : ( EncryptedSymmetricKey | DecryptedSymmetricKey ) [ ] ,
780780) : string {
781- keys . sort ( ( a , b ) => getRevisionNumber ( a . revision ) - getRevisionNumber ( b . revision ) ) ;
781+ keys . sort ( ( a , b ) => {
782+ // sort the default keys first
783+ // this is ok because if we have an environment the keys should be filtered by env first
784+ let aRevNum = getRevisionNumber ( a . revision ) ;
785+ let bRevNum = getRevisionNumber ( b . revision ) ;
786+
787+ if ( ! a . revision . includes ( '-' ) ) {
788+ aRevNum += 1000 ;
789+ }
790+
791+ if ( ! b . revision . includes ( '-' ) ) {
792+ bRevNum += 1000 ;
793+ }
794+
795+ return aRevNum - bRevNum ;
796+ } ) ;
782797
783798 if ( keys . length === 0 ) throw new InvalidEncryptionKey ( 'No symmetric keys were found' ) ;
784799
You can’t perform that action at this time.
0 commit comments