-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* DEV: add the mobile flow * DEV: finishing flow for the mobile --------- Co-authored-by: Apostolos GALANOPOULOS <Apostolos.GALANOPOULOS@netcompany.com>
- Loading branch information
1 parent
9c0ccce
commit 0654120
Showing
19 changed files
with
278 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const UI_PRESENTATION = 'UI_PRESENTATION'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { PLATFORM_ID, Inject, Injectable } from '@angular/core'; | ||
import { isPlatformBrowser } from '@angular/common'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class DeviceDetectorService { | ||
userAgent = ''; | ||
|
||
constructor (@Inject(PLATFORM_ID) private platformId: object) { | ||
if (isPlatformBrowser(this.platformId) && typeof window !== 'undefined') { | ||
this.userAgent = window.navigator.userAgent; | ||
} | ||
} | ||
|
||
public isMobile (userAgent = this.userAgent): boolean { | ||
const regexs = [/(Android)(.+)(Mobile)/i, /BlackBerry/i, /iPhone|iPod/i, /Opera Mini/i, /IEMobile/i]; | ||
return regexs.some((b) => userAgent.match(b)); | ||
} | ||
|
||
public isTablet (userAgent = this.userAgent): boolean { | ||
const regex = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/; | ||
return regex.test(userAgent.toLowerCase()); | ||
} | ||
|
||
isDesktop = (): boolean => !this.isMobile() && !this.isMobile(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class LocalStorageService { | ||
|
||
get (key: string): string | null { | ||
return localStorage.getItem(key); | ||
} | ||
set (key: string, value: string): void { | ||
localStorage.setItem(key,value); | ||
} | ||
remove (key: string) { | ||
localStorage.removeItem(key); | ||
} | ||
} |
28 changes: 24 additions & 4 deletions
28
src/app/core/services/online-authentication-siop.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,46 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { tap } from 'rxjs/operators'; | ||
import { HttpService } from '../network/http/http.service'; | ||
import { PresentationDefinitionResponse } from '../models/presentation-definition-response'; | ||
import { PID_PRESENTATION_DEFINITION } from '../data/pid_presentation_definition'; | ||
import { LocalStorageService } from './local-storage.service'; | ||
import * as constants from '@core/constants/constants'; | ||
import { DeviceDetectorService } from './device-detector.service'; | ||
import { environment } from '@environments/environment'; | ||
|
||
@Injectable() | ||
export class OnlineAuthenticationSIOPService { | ||
|
||
constructor ( | ||
private readonly httpService: HttpService | ||
private readonly httpService: HttpService, | ||
private readonly localStorageService: LocalStorageService, | ||
private readonly deviceDetectorService: DeviceDetectorService | ||
) { } | ||
|
||
initTransaction (): Observable<PresentationDefinitionResponse> { | ||
const dataRequest = { | ||
const dataRequest: any = { | ||
'type': 'id_token', | ||
'id_token_type': 'subject_signed_id_token', | ||
'nonce': 'nonce' | ||
}; | ||
if (!this.deviceDetectorService.isDesktop()) { | ||
dataRequest['wallet_response_redirect_uri_template'] = environment.apiUrl+'/get-wallet-code/?response_code={RESPONSE_CODE}'; | ||
} | ||
return this.httpService.post<PresentationDefinitionResponse, {type: string, 'id_token_type': string, 'nonce': string}> | ||
('ui/presentations', dataRequest); | ||
('ui/presentations', dataRequest) | ||
.pipe( | ||
tap((res) => { this.localStorageService.set(constants.UI_PRESENTATION, JSON.stringify(res));}) | ||
); | ||
} | ||
initCborTransaction (): Observable<PresentationDefinitionResponse> { | ||
return this.httpService.post('ui/presentations', PID_PRESENTATION_DEFINITION); | ||
const payload: any = PID_PRESENTATION_DEFINITION; | ||
if (!this.deviceDetectorService.isDesktop()) { | ||
payload['wallet_response_redirect_uri_template'] = environment.apiUrl+'/get-wallet-code?response_code={RESPONSE_CODE}'; | ||
} | ||
return this.httpService.post<PresentationDefinitionResponse, any>('ui/presentations', payload) | ||
.pipe( | ||
tap((res) => { this.localStorageService.set(constants.UI_PRESENTATION, JSON.stringify(res));}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const uuidv4 = () => { | ||
return crypto.randomUUID(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
:host { | ||
.qr-container { | ||
display: flex; | ||
flex-direction: row; | ||
:first-child { | ||
margin-right: 3rem; | ||
.qr-container { | ||
display: flex; | ||
flex-direction: row; | ||
|
||
:first-child { | ||
margin-right: 3rem; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.