Skip to content

Commit

Permalink
Move deep link schemes to config.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrizagidulin committed Jan 4, 2024
1 parent 360dad1 commit 4ade9f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions app/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ export const KnownDidRegistries = [
'url': 'https://digitalcredentials.github.io/dcc-registry/registry.json'
}
];

export const DeepLinkConfig = {
schemes: {
customProtocol: ['dccrequest://', 'org.dcconsortium://'],
universalAppLink: 'https://lcw.app/mobile'
}
};
10 changes: 6 additions & 4 deletions app/lib/deepLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import { ChapiCredentialRequest } from '../types/chapi';
import { credentialRequestFromChapiUrl } from './decode';
import { encodeQueryParams } from './encode';
import { onShareIntent } from './shareIntent';
import { DeepLinkConfig } from '../config';

/**
* In order to support OAuth redirects, the Android intent filter was set
* specific to the scheme `dccrequest` and path `request`. If new paths are
* added here, they must also be added to `android/app/src/main/AndroidManifest.xml`.
*/
const DEEP_LINK_SCHEMES = ['https://lcw.app/mobile', 'dccrequest://', 'org.dcconsortium://'];
const DEEP_LINK_SCHEMES = DeepLinkConfig.schemes.customProtocol
.concat(DeepLinkConfig.schemes.universalAppLink);
const DEEP_LINK_PATHS: DeepLinkPaths = {
request: (credentialRequestParams) => deepLinkNavigate('ProfileSelectionScreen', {
request: (credentialRequestParams) => deepLinkNavigate('ProfileSelectionScreen', {
onSelectProfile: (rawProfileRecord) => navigationRef.navigate('AcceptCredentialsNavigation', {
screen: 'ApproveCredentialsScreen',
params: {
Expand Down Expand Up @@ -72,7 +74,7 @@ function deepLinkConfigFor({ schemes, paths, onDeepLink }: DeepLinkConfigOptions
onDeepLink?.(url);
return listener(transformDeepLink(url));
};

const subscription = Linking.addEventListener('url', onReceiveURL);
return () => subscription.remove();
},
Expand Down Expand Up @@ -114,7 +116,7 @@ type DeepLinkConfigOptions = {
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const deepLinkNavigate: typeof navigationRef.navigate = (...args: any[]): ResultState => {
const deepLinkNavigate: typeof navigationRef.navigate = (...args: any[]): ResultState => {
function stateFor(screen: string, params?: Record<string, unknown>): ResultState {
const hasParams = params !== undefined;
const paramsAreNestedScreen = params !== undefined && 'screen' in params && 'params' in params;
Expand Down

0 comments on commit 4ade9f9

Please sign in to comment.