@@ -21,7 +21,7 @@ import {fetchUtils} from './FetchUtils';
21
21
import { findSuitableIcon , generatePackageId , validateNotEmpty } from './util' ;
22
22
import Color = require( 'color' ) ;
23
23
import { ConsoleLog } from './Log' ;
24
- import { ShareTarget , WebManifestIcon , WebManifestJson } from './types/WebManifest' ;
24
+ import { ProtocolHandler , ShareTarget , WebManifestIcon , WebManifestJson } from './types/WebManifest' ;
25
25
import { ShortcutInfo } from './ShortcutInfo' ;
26
26
import { AppsFlyerConfig } from './features/AppsFlyerFeature' ;
27
27
import { LocationDelegationConfig } from './features/LocationDelegationFeature' ;
@@ -169,6 +169,7 @@ export class TwaManifest {
169
169
serviceAccountJsonFile : string | undefined ;
170
170
additionalTrustedOrigins : string [ ] ;
171
171
retainedBundles : number [ ] ;
172
+ protocolHandlers ?: ProtocolHandler [ ] ;
172
173
173
174
private static log = new ConsoleLog ( 'twa-manifest' ) ;
174
175
@@ -219,6 +220,7 @@ export class TwaManifest {
219
220
this . serviceAccountJsonFile = data . serviceAccountJsonFile ;
220
221
this . additionalTrustedOrigins = data . additionalTrustedOrigins || [ ] ;
221
222
this . retainedBundles = data . retainedBundles || [ ] ;
223
+ this . protocolHandlers = data . protocolHandlers ;
222
224
}
223
225
224
226
/**
@@ -343,6 +345,7 @@ export class TwaManifest {
343
345
shareTarget : TwaManifest . verifyShareTarget ( webManifestUrl , webManifest . share_target ) ,
344
346
orientation : asOrientation ( webManifest . orientation ) || DEFAULT_ORIENTATION ,
345
347
fullScopeUrl : fullScopeUrl . toString ( ) ,
348
+ protocolHandlers : webManifest . protocol_handlers ,
346
349
} ) ;
347
350
return twaManifest ;
348
351
}
@@ -479,6 +482,12 @@ export class TwaManifest {
479
482
oldTwaManifestJson . iconUrl ! , webManifest . icons ! , 'monochrome' , MIN_NOTIFICATION_ICON_SIZE ,
480
483
webManifestUrl ) ;
481
484
485
+ let mergedProtocolHandlers = new Map < String , String > ( ) ;
486
+ oldTwaManifest . protocolHandlers ?. forEach ( handler => mergedProtocolHandlers . set ( handler . protocol , handler . url ) ) ;
487
+ if ( ! ( fieldsToIgnore . includes ( 'protocol_handlers' ) ) ) {
488
+ webManifest . protocol_handlers ?. forEach ( handler => mergedProtocolHandlers . set ( handler . protocol , handler . url ) ) ;
489
+ }
490
+
482
491
const fullStartUrl : URL = new URL ( webManifest [ 'start_url' ] || '/' , webManifestUrl ) ;
483
492
const fullScopeUrl : URL = new URL ( webManifest [ 'scope' ] || '.' , webManifestUrl ) ;
484
493
@@ -503,6 +512,7 @@ export class TwaManifest {
503
512
maskableIconUrl : maskableIconUrl || oldTwaManifestJson . maskableIconUrl ,
504
513
monochromeIconUrl : monochromeIconUrl || oldTwaManifestJson . monochromeIconUrl ,
505
514
shortcuts : shortcuts ,
515
+ protocolHandlers : Array . from ( mergedProtocolHandlers . entries ( ) ) . map ( ( [ protocol , url ] ) => ( { protocol, url} as ProtocolHandler ) )
506
516
} ) ;
507
517
return twaManifest ;
508
518
}
@@ -558,6 +568,7 @@ export interface TwaManifestJson {
558
568
serviceAccountJsonFile ?: string ;
559
569
additionalTrustedOrigins ?: string [ ] ;
560
570
retainedBundles ?: number [ ] ;
571
+ protocolHandlers ?: ProtocolHandler [ ] ;
561
572
}
562
573
563
574
export interface SigningKeyInfo {
0 commit comments