feat-dev: add U2F iframe for desktop client authentication (#2236)
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export const ValidAppViewRoutes = ['u2f'] as const
|
||||
|
||||
export type AppViewRouteParam = typeof ValidAppViewRoutes[number]
|
||||
@@ -4,4 +4,5 @@ export enum RootQueryParam {
|
||||
DemoToken = 'demo-token',
|
||||
AcceptSubscriptionInvite = 'accept-subscription-invite',
|
||||
UserRequest = 'user-request',
|
||||
AppViewRoute = 'route',
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { UserRequestType } from '@standardnotes/common'
|
||||
import { PreferenceId } from './../Preferences/PreferenceId'
|
||||
import { AppViewRouteParam, ValidAppViewRoutes } from './Params/AppViewRouteParams'
|
||||
import { DemoParams } from './Params/DemoParams'
|
||||
import { OnboardingParams } from './Params/OnboardingParams'
|
||||
import { PurchaseParams } from './Params/PurchaseParams'
|
||||
@@ -78,6 +79,18 @@ export class RouteParser implements RouteParserInterface {
|
||||
}
|
||||
}
|
||||
|
||||
get appViewRouteParam(): AppViewRouteParam | undefined {
|
||||
this.checkForProperRouteType(RouteType.AppViewRoute)
|
||||
|
||||
const appViewRoute = this.searchParams.get(RootQueryParam.AppViewRoute) as AppViewRouteParam
|
||||
|
||||
if (!ValidAppViewRoutes.includes(appViewRoute)) {
|
||||
return
|
||||
}
|
||||
|
||||
return this.searchParams.get(RootQueryParam.AppViewRoute) as AppViewRouteParam
|
||||
}
|
||||
|
||||
private checkForProperRouteType(type: RouteType): void {
|
||||
if (this.parsedType !== type) {
|
||||
throw new Error('Accessing invalid params')
|
||||
@@ -99,6 +112,7 @@ export class RouteParser implements RouteParserInterface {
|
||||
[RootQueryParam.DemoToken, RouteType.Demo],
|
||||
[RootQueryParam.AcceptSubscriptionInvite, RouteType.AcceptSubscriptionInvite],
|
||||
[RootQueryParam.UserRequest, RouteType.UserRequest],
|
||||
[RootQueryParam.AppViewRoute, RouteType.AppViewRoute],
|
||||
])
|
||||
|
||||
for (const rootQueryParam of rootQueryParametersMap.keys()) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { AppViewRouteParam } from './Params/AppViewRouteParams'
|
||||
import { DemoParams } from './Params/DemoParams'
|
||||
import { OnboardingParams } from './Params/OnboardingParams'
|
||||
import { PurchaseParams } from './Params/PurchaseParams'
|
||||
@@ -13,5 +14,6 @@ export interface RouteParserInterface {
|
||||
get onboardingParams(): OnboardingParams
|
||||
get subscriptionInviteParams(): SubscriptionInviteParams
|
||||
get userRequestParams(): UserRequestParams
|
||||
get appViewRouteParam(): AppViewRouteParam | undefined
|
||||
get type(): RouteType
|
||||
}
|
||||
|
||||
@@ -5,5 +5,6 @@ export enum RouteType {
|
||||
AcceptSubscriptionInvite = 'accept-subscription-invite',
|
||||
UserRequest = 'user-request',
|
||||
Demo = 'demo',
|
||||
AppViewRoute = 'route',
|
||||
None = 'none',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user