Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
emiMobile
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mac Stephens
emiMobile
Commits
4c72694c
Commit
4c72694c
authored
Oct 21, 2026
by
Mac Stephens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quick fix to device update code
parent
97fe9d07
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
96 additions
and
219 deletions
+96
-219
Auth.Service.pas
emiMobileServer/Clients/BFD/Web/Auth.Service.pas
+12
-12
Auth.Service.pas
emiMobileServer/Clients/WC/Web/Auth.Service.pas
+12
-12
Device.Store.pas
emiMobileServer/Shared/Clients/Device.Store.pas
+6
-6
Oracle.Device.Database.dfm
...eServer/Shared/Database/Oracle/Oracle.Device.Database.dfm
+6
-42
Oracle.Device.Database.pas
...eServer/Shared/Database/Oracle/Oracle.Device.Database.pas
+12
-18
PostgreSQL.Device.Database.dfm
...Shared/Database/PostgreSQL/PostgreSQL.Device.Database.dfm
+6
-42
PostgreSQL.Device.Database.pas
...Shared/Database/PostgreSQL/PostgreSQL.Device.Database.pas
+12
-18
Api.ServiceImpl.pas
emiMobileServer/Shared/Server/Api.ServiceImpl.pas
+3
-3
Auth.Service.pas
emiMobileServer/Shared/Server/Auth.Service.pas
+4
-4
Auth.ServiceImpl.pas
emiMobileServer/Shared/Server/Auth.ServiceImpl.pas
+18
-28
View.DeviceRegistration.dfm
emiMobileServer/Shared/Web/View.DeviceRegistration.dfm
+0
-13
View.DeviceRegistration.html
emiMobileServer/Shared/Web/View.DeviceRegistration.html
+1
-6
View.DeviceRegistration.pas
emiMobileServer/Shared/Web/View.DeviceRegistration.pas
+4
-15
No files found.
emiMobileServer/Clients/BFD/Web/Auth.Service.pas
View file @
4c72694c
...
@@ -51,13 +51,13 @@ type
...
@@ -51,13 +51,13 @@ type
procedure
ClearCredentialId
;
procedure
ClearCredentialId
;
// Section: Device registration verification
// Section: Device registration verification
procedure
BeginRegistration
(
APhoneNumber
,
ADeviceType
:
string
;
procedure
BeginRegistration
(
APhoneNumber
:
string
;
ASuccess
:
TOnCodeSentSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnCodeSentSuccess
;
AError
:
TOnDeviceError
);
procedure
VerifyRegistrationCode
(
APhoneNumber
,
A
DeviceType
,
A
VerificationCode
:
string
;
procedure
VerifyRegistrationCode
(
APhoneNumber
,
AVerificationCode
:
string
;
ASuccess
:
TOnBeginSuccess
;
ASuccess
:
TOnBeginSuccess
;
AError
:
TOnDeviceError
);
AError
:
TOnDeviceError
);
// Section: WebAuthn registration
// Section: WebAuthn registration
procedure
CompleteRegistration
(
APhoneNumber
,
A
DeviceType
,
A
CredentialId
,
procedure
CompleteRegistration
(
APhoneNumber
,
ACredentialId
,
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
:
string
;
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
:
string
;
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
...
@@ -74,7 +74,7 @@ type
...
@@ -74,7 +74,7 @@ type
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
// Simple-key registration and login
// Simple-key registration and login
procedure
CompleteRegistrationSimple
(
APhoneNumber
,
ADevice
Type
,
ADevice
Key
,
AChallengeToken
:
string
;
procedure
CompleteRegistrationSimple
(
APhoneNumber
,
ADeviceKey
,
AChallengeToken
:
string
;
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
procedure
LoginDeviceKey
(
ACredentialId
,
AChallengeToken
:
string
;
procedure
LoginDeviceKey
(
ACredentialId
,
AChallengeToken
:
string
;
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
...
@@ -218,7 +218,7 @@ end;
...
@@ -218,7 +218,7 @@ end;
// ---- WebAuthn registration ----
// ---- WebAuthn registration ----
procedure
TAuthService
.
BeginRegistration
(
APhoneNumber
,
ADeviceType
:
string
;
procedure
TAuthService
.
BeginRegistration
(
APhoneNumber
:
string
;
ASuccess
:
TOnCodeSentSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnCodeSentSuccess
;
AError
:
TOnDeviceError
);
procedure
OnLoad
(
Response
:
TXDataClientResponse
);
procedure
OnLoad
(
Response
:
TXDataClientResponse
);
...
@@ -244,12 +244,12 @@ procedure TAuthService.BeginRegistration(APhoneNumber, ADeviceType: string;
...
@@ -244,12 +244,12 @@ procedure TAuthService.BeginRegistration(APhoneNumber, ADeviceType: string;
begin
begin
FClient
.
RawInvoke
(
FClient
.
RawInvoke
(
'IAuthService.BeginRegistration'
,
'IAuthService.BeginRegistration'
,
[
APhoneNumber
,
ADeviceType
],
[
APhoneNumber
],
@
OnLoad
,
@
OnError
@
OnLoad
,
@
OnError
);
);
end
;
end
;
procedure
TAuthService
.
VerifyRegistrationCode
(
APhoneNumber
,
ADeviceType
,
procedure
TAuthService
.
VerifyRegistrationCode
(
APhoneNumber
,
AVerificationCode
:
string
;
ASuccess
:
TOnBeginSuccess
;
AVerificationCode
:
string
;
ASuccess
:
TOnBeginSuccess
;
AError
:
TOnDeviceError
);
AError
:
TOnDeviceError
);
...
@@ -278,12 +278,12 @@ procedure TAuthService.VerifyRegistrationCode(APhoneNumber, ADeviceType,
...
@@ -278,12 +278,12 @@ procedure TAuthService.VerifyRegistrationCode(APhoneNumber, ADeviceType,
begin
begin
FClient
.
RawInvoke
(
FClient
.
RawInvoke
(
'IAuthService.VerifyRegistrationCode'
,
'IAuthService.VerifyRegistrationCode'
,
[
APhoneNumber
,
A
DeviceType
,
A
VerificationCode
],
[
APhoneNumber
,
AVerificationCode
],
@
OnLoad
,
@
OnError
@
OnLoad
,
@
OnError
);
);
end
;
end
;
procedure
TAuthService
.
CompleteRegistration
(
APhoneNumber
,
A
DeviceType
,
A
CredentialId
,
procedure
TAuthService
.
CompleteRegistration
(
APhoneNumber
,
ACredentialId
,
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
:
string
;
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
:
string
;
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
...
@@ -317,7 +317,7 @@ procedure TAuthService.CompleteRegistration(APhoneNumber, ADeviceType, ACredenti
...
@@ -317,7 +317,7 @@ procedure TAuthService.CompleteRegistration(APhoneNumber, ADeviceType, ACredenti
begin
begin
FClient
.
RawInvoke
(
FClient
.
RawInvoke
(
'IAuthService.CompleteRegistration'
,
'IAuthService.CompleteRegistration'
,
[
APhoneNumber
,
A
DeviceType
,
A
CredentialId
,
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
],
[
APhoneNumber
,
ACredentialId
,
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
],
@
OnLoad
,
@
OnError
@
OnLoad
,
@
OnError
);
);
end
;
end
;
...
@@ -431,7 +431,7 @@ end;
...
@@ -431,7 +431,7 @@ end;
// ---- Simple-key registration and login ----
// ---- Simple-key registration and login ----
procedure
TAuthService
.
CompleteRegistrationSimple
(
APhoneNumber
,
ADevice
Type
,
ADevice
Key
,
AChallengeToken
:
string
;
procedure
TAuthService
.
CompleteRegistrationSimple
(
APhoneNumber
,
ADeviceKey
,
AChallengeToken
:
string
;
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
procedure
OnLoad
(
Response
:
TXDataClientResponse
);
procedure
OnLoad
(
Response
:
TXDataClientResponse
);
...
@@ -462,7 +462,7 @@ procedure TAuthService.CompleteRegistrationSimple(APhoneNumber, ADeviceType, ADe
...
@@ -462,7 +462,7 @@ procedure TAuthService.CompleteRegistrationSimple(APhoneNumber, ADeviceType, ADe
begin
begin
FClient
.
RawInvoke
(
FClient
.
RawInvoke
(
'IAuthService.CompleteRegistrationSimple'
,
'IAuthService.CompleteRegistrationSimple'
,
[
APhoneNumber
,
ADevice
Type
,
ADevice
Key
,
AChallengeToken
],
[
APhoneNumber
,
ADeviceKey
,
AChallengeToken
],
@
OnLoad
,
@
OnError
@
OnLoad
,
@
OnError
);
);
end
;
end
;
...
...
emiMobileServer/Clients/WC/Web/Auth.Service.pas
View file @
4c72694c
...
@@ -51,13 +51,13 @@ type
...
@@ -51,13 +51,13 @@ type
procedure
ClearCredentialId
;
procedure
ClearCredentialId
;
// Section: Device registration verification
// Section: Device registration verification
procedure
BeginRegistration
(
APhoneNumber
,
ADeviceType
:
string
;
procedure
BeginRegistration
(
APhoneNumber
:
string
;
ASuccess
:
TOnCodeSentSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnCodeSentSuccess
;
AError
:
TOnDeviceError
);
procedure
VerifyRegistrationCode
(
APhoneNumber
,
A
DeviceType
,
A
VerificationCode
:
string
;
procedure
VerifyRegistrationCode
(
APhoneNumber
,
AVerificationCode
:
string
;
ASuccess
:
TOnBeginSuccess
;
ASuccess
:
TOnBeginSuccess
;
AError
:
TOnDeviceError
);
AError
:
TOnDeviceError
);
// Section: WebAuthn registration
// Section: WebAuthn registration
procedure
CompleteRegistration
(
APhoneNumber
,
A
DeviceType
,
A
CredentialId
,
procedure
CompleteRegistration
(
APhoneNumber
,
ACredentialId
,
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
:
string
;
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
:
string
;
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
...
@@ -74,7 +74,7 @@ type
...
@@ -74,7 +74,7 @@ type
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
// Simple-key registration and login
// Simple-key registration and login
procedure
CompleteRegistrationSimple
(
APhoneNumber
,
ADevice
Type
,
ADevice
Key
,
AChallengeToken
:
string
;
procedure
CompleteRegistrationSimple
(
APhoneNumber
,
ADeviceKey
,
AChallengeToken
:
string
;
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
procedure
LoginDeviceKey
(
ACredentialId
,
AChallengeToken
:
string
;
procedure
LoginDeviceKey
(
ACredentialId
,
AChallengeToken
:
string
;
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
...
@@ -246,7 +246,7 @@ end;
...
@@ -246,7 +246,7 @@ end;
// ---- WebAuthn registration ----
// ---- WebAuthn registration ----
procedure
TAuthService
.
BeginRegistration
(
APhoneNumber
,
ADeviceType
:
string
;
procedure
TAuthService
.
BeginRegistration
(
APhoneNumber
:
string
;
ASuccess
:
TOnCodeSentSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnCodeSentSuccess
;
AError
:
TOnDeviceError
);
procedure
OnLoad
(
Response
:
TXDataClientResponse
);
procedure
OnLoad
(
Response
:
TXDataClientResponse
);
...
@@ -272,12 +272,12 @@ procedure TAuthService.BeginRegistration(APhoneNumber, ADeviceType: string;
...
@@ -272,12 +272,12 @@ procedure TAuthService.BeginRegistration(APhoneNumber, ADeviceType: string;
begin
begin
FClient
.
RawInvoke
(
FClient
.
RawInvoke
(
'IAuthService.BeginRegistration'
,
'IAuthService.BeginRegistration'
,
[
APhoneNumber
,
ADeviceType
],
[
APhoneNumber
],
@
OnLoad
,
@
OnError
@
OnLoad
,
@
OnError
);
);
end
;
end
;
procedure
TAuthService
.
VerifyRegistrationCode
(
APhoneNumber
,
ADeviceType
,
procedure
TAuthService
.
VerifyRegistrationCode
(
APhoneNumber
,
AVerificationCode
:
string
;
ASuccess
:
TOnBeginSuccess
;
AVerificationCode
:
string
;
ASuccess
:
TOnBeginSuccess
;
AError
:
TOnDeviceError
);
AError
:
TOnDeviceError
);
...
@@ -306,12 +306,12 @@ procedure TAuthService.VerifyRegistrationCode(APhoneNumber, ADeviceType,
...
@@ -306,12 +306,12 @@ procedure TAuthService.VerifyRegistrationCode(APhoneNumber, ADeviceType,
begin
begin
FClient
.
RawInvoke
(
FClient
.
RawInvoke
(
'IAuthService.VerifyRegistrationCode'
,
'IAuthService.VerifyRegistrationCode'
,
[
APhoneNumber
,
A
DeviceType
,
A
VerificationCode
],
[
APhoneNumber
,
AVerificationCode
],
@
OnLoad
,
@
OnError
@
OnLoad
,
@
OnError
);
);
end
;
end
;
procedure
TAuthService
.
CompleteRegistration
(
APhoneNumber
,
A
DeviceType
,
A
CredentialId
,
procedure
TAuthService
.
CompleteRegistration
(
APhoneNumber
,
ACredentialId
,
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
:
string
;
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
:
string
;
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
...
@@ -345,7 +345,7 @@ procedure TAuthService.CompleteRegistration(APhoneNumber, ADeviceType, ACredenti
...
@@ -345,7 +345,7 @@ procedure TAuthService.CompleteRegistration(APhoneNumber, ADeviceType, ACredenti
begin
begin
FClient
.
RawInvoke
(
FClient
.
RawInvoke
(
'IAuthService.CompleteRegistration'
,
'IAuthService.CompleteRegistration'
,
[
APhoneNumber
,
A
DeviceType
,
A
CredentialId
,
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
],
[
APhoneNumber
,
ACredentialId
,
AAttestationObject
,
AClientDataJSON
,
AChallengeToken
],
@
OnLoad
,
@
OnError
@
OnLoad
,
@
OnError
);
);
end
;
end
;
...
@@ -459,7 +459,7 @@ end;
...
@@ -459,7 +459,7 @@ end;
// ---- Simple-key registration and login ----
// ---- Simple-key registration and login ----
procedure
TAuthService
.
CompleteRegistrationSimple
(
APhoneNumber
,
ADevice
Type
,
ADevice
Key
,
AChallengeToken
:
string
;
procedure
TAuthService
.
CompleteRegistrationSimple
(
APhoneNumber
,
ADeviceKey
,
AChallengeToken
:
string
;
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
ASuccess
:
TOnDeviceSuccess
;
AError
:
TOnDeviceError
);
procedure
OnLoad
(
Response
:
TXDataClientResponse
);
procedure
OnLoad
(
Response
:
TXDataClientResponse
);
...
@@ -490,7 +490,7 @@ procedure TAuthService.CompleteRegistrationSimple(APhoneNumber, ADeviceType, ADe
...
@@ -490,7 +490,7 @@ procedure TAuthService.CompleteRegistrationSimple(APhoneNumber, ADeviceType, ADe
begin
begin
FClient
.
RawInvoke
(
FClient
.
RawInvoke
(
'IAuthService.CompleteRegistrationSimple'
,
'IAuthService.CompleteRegistrationSimple'
,
[
APhoneNumber
,
ADevice
Type
,
ADevice
Key
,
AChallengeToken
],
[
APhoneNumber
,
ADeviceKey
,
AChallengeToken
],
@
OnLoad
,
@
OnError
@
OnLoad
,
@
OnError
);
);
end
;
end
;
...
...
emiMobileServer/Shared/Clients/Device.Store.pas
View file @
4c72694c
...
@@ -14,17 +14,17 @@ type
...
@@ -14,17 +14,17 @@ type
// Note: A supplied connection is borrowed and must outlive this store.
// Note: A supplied connection is borrowed and must outlive this store.
procedure
UseConnection
(
AConnection
:
TUniConnection
);
virtual
;
abstract
;
procedure
UseConnection
(
AConnection
:
TUniConnection
);
virtual
;
abstract
;
property
Connection
:
TUniConnection
read
GetConnection
;
property
Connection
:
TUniConnection
read
GetConnection
;
function
PendingDevice
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
virtual
;
abstract
;
function
PendingDevice
(
PhoneNumber
:
string
):
TDataSet
;
virtual
;
abstract
;
function
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
virtual
;
abstract
;
function
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
):
Int64
;
virtual
;
abstract
;
function
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
;
DeviceType
:
string
):
Int64
;
virtual
;
abstract
;
function
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
):
Int64
;
virtual
;
abstract
;
function
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
virtual
;
abstract
;
function
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
):
Int64
;
virtual
;
abstract
;
function
UnrevokedDeviceUser
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
UnrevokedDeviceUser
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
ActiveDeviceUser
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
ActiveDeviceUser
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
UnrevokedDeviceKey
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
UnrevokedDeviceKey
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
UpdateSignCount
(
SignCount
:
Integer
;
CredentialId
:
string
):
Int64
;
virtual
;
abstract
;
function
UpdateSignCount
(
SignCount
:
Integer
;
CredentialId
:
string
):
Int64
;
virtual
;
abstract
;
function
SaveDeviceUser
(
Username
:
string
;
Agency
:
string
;
CredentialId
:
string
):
Int64
;
virtual
;
abstract
;
function
SaveDeviceUser
(
Username
:
string
;
Agency
:
string
;
CredentialId
:
string
):
Int64
;
virtual
;
abstract
;
function
ActiveDeviceKey
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
ActiveDeviceKey
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
virtual
;
abstract
;
function
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
):
Int64
;
virtual
;
abstract
;
function
ActiveSimpleDeviceUser
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
ActiveSimpleDeviceUser
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
ActiveSimpleDevice
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
ActiveSimpleDevice
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
DeviceStatus
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
function
DeviceStatus
(
CredentialId
:
string
):
TDataSet
;
virtual
;
abstract
;
...
@@ -32,7 +32,7 @@ type
...
@@ -32,7 +32,7 @@ type
function
RevokeDevice
(
RevokedBy
:
string
;
CredentialId
:
string
):
Int64
;
virtual
;
abstract
;
function
RevokeDevice
(
RevokedBy
:
string
;
CredentialId
:
string
):
Int64
;
virtual
;
abstract
;
function
UnrevokeDevice
(
CredentialId
:
string
):
Int64
;
virtual
;
abstract
;
function
UnrevokeDevice
(
CredentialId
:
string
):
Int64
;
virtual
;
abstract
;
function
DeviceNameExists
(
DeviceName
:
string
):
Boolean
;
virtual
;
abstract
;
function
DeviceNameExists
(
DeviceName
:
string
):
Boolean
;
virtual
;
abstract
;
function
PendingPhone
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
virtual
;
abstract
;
function
PendingPhone
(
PhoneNumber
:
string
):
TDataSet
;
virtual
;
abstract
;
function
AddPendingDevice
(
DeviceName
:
string
;
DeviceType
:
string
;
PhoneNumber
:
string
):
Int64
;
virtual
;
abstract
;
function
AddPendingDevice
(
DeviceName
:
string
;
DeviceType
:
string
;
PhoneNumber
:
string
):
Int64
;
virtual
;
abstract
;
function
DeleteDevice
(
DeviceId
:
Integer
):
Int64
;
virtual
;
abstract
;
function
DeleteDevice
(
DeviceId
:
Integer
):
Int64
;
virtual
;
abstract
;
function
ReserveRedeemCode
(
PhoneNumber
:
string
;
out
Code
:
string
):
Boolean
;
virtual
;
abstract
;
function
ReserveRedeemCode
(
PhoneNumber
:
string
;
out
Code
:
string
):
Boolean
;
virtual
;
abstract
;
...
...
emiMobileServer/Shared/Database/Oracle/Oracle.Device.Database.dfm
View file @
4c72694c
...
@@ -18,8 +18,7 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
...
@@ -18,8 +18,7 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
'SELECT ID, DEVICE_NAME'
'SELECT ID, DEVICE_NAME'
'FROM DEVICE_REGISTRATIONS'
'FROM DEVICE_REGISTRATIONS'
'WHERE PHONE_NUMBER = :PHONE'
'WHERE PHONE_NUMBER = :PHONE'
' AND STATUS = ''pending'''
' AND STATUS = ''pending''')
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
ReadOnly = True
ReadOnly = True
Active = False
Active = False
Left = 60
Left = 60
...
@@ -27,11 +26,6 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
...
@@ -27,11 +26,6 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'PHONE'
Name = 'PHONE'
ParamType = ptInput
ParamType = ptInput
end>
end>
...
@@ -42,19 +36,13 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
...
@@ -42,19 +36,13 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
'UPDATE DEVICE_REGISTRATIONS'
'UPDATE DEVICE_REGISTRATIONS'
'SET VERIFICATION_CODE = :CODE, VERIFICATION_EXPIRES_AT = SYSTIMESTAMP + INTERVAL ''5'' MINUTE'
'SET VERIFICATION_CODE = :CODE, VERIFICATION_EXPIRES_AT = SYSTIMESTAMP + INTERVAL ''5'' MINUTE'
'WHERE PHONE_NUMBER = :PHONE'
'WHERE PHONE_NUMBER = :PHONE'
' AND STATUS = ''pending'''
' AND STATUS = ''pending''')
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Active = False
Active = False
Left = 250
Left = 250
Top = 110
Top = 110
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'CODE'
Name = 'CODE'
ParamType = ptInput
ParamType = ptInput
end
end
...
@@ -72,19 +60,13 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
...
@@ -72,19 +60,13 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
'WHERE PHONE_NUMBER = :PHONE'
'WHERE PHONE_NUMBER = :PHONE'
' AND STATUS = ''pending'''
' AND STATUS = ''pending'''
' AND VERIFICATION_CODE = :CODE'
' AND VERIFICATION_CODE = :CODE'
' AND VERIFICATION_EXPIRES_AT > SYSTIMESTAMP'
' AND VERIFICATION_EXPIRES_AT > SYSTIMESTAMP')
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Active = False
Active = False
Left = 630
Left = 630
Top = 110
Top = 110
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'PHONE'
Name = 'PHONE'
ParamType = ptInput
ParamType = ptInput
end
end
...
@@ -100,19 +82,13 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
...
@@ -100,19 +82,13 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
'UPDATE DEVICE_REGISTRATIONS'
'UPDATE DEVICE_REGISTRATIONS'
'SET CREDENTIAL_ID = :CID, USER_AGENT = :AGENT, PUBLIC_KEY_X = :KEYX, PUBLIC_KEY_Y = :KEYY, PUBLIC_KEY_ALG = :ALG, SIGN_COUNT = :CNT, VERIFICATION_CODE = NULL, VERIFICATION_EXPIRES_AT = NULL, STATUS = ''active'', REGISTERED_AT = SYSTIMESTAMP'
'SET CREDENTIAL_ID = :CID, USER_AGENT = :AGENT, PUBLIC_KEY_X = :KEYX, PUBLIC_KEY_Y = :KEYY, PUBLIC_KEY_ALG = :ALG, SIGN_COUNT = :CNT, VERIFICATION_CODE = NULL, VERIFICATION_EXPIRES_AT = NULL, STATUS = ''active'', REGISTERED_AT = SYSTIMESTAMP'
'WHERE PHONE_NUMBER = :PHONE'
'WHERE PHONE_NUMBER = :PHONE'
' AND STATUS = ''pending'''
' AND STATUS = ''pending''')
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Active = False
Active = False
Left = 820
Left = 820
Top = 110
Top = 110
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'CID'
Name = 'CID'
ParamType = ptInput
ParamType = ptInput
end
end
...
@@ -274,19 +250,13 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
...
@@ -274,19 +250,13 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
'UPDATE DEVICE_REGISTRATIONS'
'UPDATE DEVICE_REGISTRATIONS'
'SET CREDENTIAL_ID = :CID, USER_AGENT = :AGENT, KEY_TYPE = ''simple'', VERIFICATION_CODE = NULL, VERIFICATION_EXPIRES_AT = NULL, STATUS = ''active'', REGISTERED_AT = SYSTIMESTAMP'
'SET CREDENTIAL_ID = :CID, USER_AGENT = :AGENT, KEY_TYPE = ''simple'', VERIFICATION_CODE = NULL, VERIFICATION_EXPIRES_AT = NULL, STATUS = ''active'', REGISTERED_AT = SYSTIMESTAMP'
'WHERE PHONE_NUMBER = :PHONE'
'WHERE PHONE_NUMBER = :PHONE'
' AND STATUS = ''pending'''
' AND STATUS = ''pending''')
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Active = False
Active = False
Left = 250
Left = 250
Top = 330
Top = 330
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'CID'
Name = 'CID'
ParamType = ptInput
ParamType = ptInput
end
end
...
@@ -428,8 +398,7 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
...
@@ -428,8 +398,7 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
'SELECT ID'
'SELECT ID'
'FROM DEVICE_REGISTRATIONS'
'FROM DEVICE_REGISTRATIONS'
'WHERE PHONE_NUMBER = :PHONE'
'WHERE PHONE_NUMBER = :PHONE'
' AND STATUS = ''pending'''
' AND STATUS = ''pending''')
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
ReadOnly = True
ReadOnly = True
Active = False
Active = False
Left = 630
Left = 630
...
@@ -437,11 +406,6 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
...
@@ -437,11 +406,6 @@ object OracleDeviceDatabase: TOracleDeviceDatabase
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'PHONE'
Name = 'PHONE'
ParamType = ptInput
ParamType = ptInput
end>
end>
...
...
emiMobileServer/Shared/Database/Oracle/Oracle.Device.Database.pas
View file @
4c72694c
...
@@ -40,17 +40,17 @@ type
...
@@ -40,17 +40,17 @@ type
function
GetConnection
:
TUniConnection
;
override
;
function
GetConnection
:
TUniConnection
;
override
;
public
public
procedure
UseConnection
(
AConnection
:
TUniConnection
);
override
;
procedure
UseConnection
(
AConnection
:
TUniConnection
);
override
;
function
PendingDevice
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
override
;
function
PendingDevice
(
PhoneNumber
:
string
):
TDataSet
;
override
;
function
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
override
;
function
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
):
Int64
;
override
;
function
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
;
DeviceType
:
string
):
Int64
;
override
;
function
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
):
Int64
;
override
;
function
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
override
;
function
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
):
Int64
;
override
;
function
UnrevokedDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
UnrevokedDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
UnrevokedDeviceKey
(
CredentialId
:
string
):
TDataSet
;
override
;
function
UnrevokedDeviceKey
(
CredentialId
:
string
):
TDataSet
;
override
;
function
UpdateSignCount
(
SignCount
:
Integer
;
CredentialId
:
string
):
Int64
;
override
;
function
UpdateSignCount
(
SignCount
:
Integer
;
CredentialId
:
string
):
Int64
;
override
;
function
SaveDeviceUser
(
Username
:
string
;
Agency
:
string
;
CredentialId
:
string
):
Int64
;
override
;
function
SaveDeviceUser
(
Username
:
string
;
Agency
:
string
;
CredentialId
:
string
):
Int64
;
override
;
function
ActiveDeviceKey
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveDeviceKey
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
override
;
function
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
):
Int64
;
override
;
function
ActiveSimpleDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveSimpleDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveSimpleDevice
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveSimpleDevice
(
CredentialId
:
string
):
TDataSet
;
override
;
function
DeviceStatus
(
CredentialId
:
string
):
TDataSet
;
override
;
function
DeviceStatus
(
CredentialId
:
string
):
TDataSet
;
override
;
...
@@ -58,7 +58,7 @@ type
...
@@ -58,7 +58,7 @@ type
function
RevokeDevice
(
RevokedBy
:
string
;
CredentialId
:
string
):
Int64
;
override
;
function
RevokeDevice
(
RevokedBy
:
string
;
CredentialId
:
string
):
Int64
;
override
;
function
UnrevokeDevice
(
CredentialId
:
string
):
Int64
;
override
;
function
UnrevokeDevice
(
CredentialId
:
string
):
Int64
;
override
;
function
DeviceNameExists
(
DeviceName
:
string
):
Boolean
;
override
;
function
DeviceNameExists
(
DeviceName
:
string
):
Boolean
;
override
;
function
PendingPhone
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
override
;
function
PendingPhone
(
PhoneNumber
:
string
):
TDataSet
;
override
;
function
AddPendingDevice
(
DeviceName
:
string
;
DeviceType
:
string
;
PhoneNumber
:
string
):
Int64
;
override
;
function
AddPendingDevice
(
DeviceName
:
string
;
DeviceType
:
string
;
PhoneNumber
:
string
):
Int64
;
override
;
function
DeleteDevice
(
DeviceId
:
Integer
):
Int64
;
override
;
function
DeleteDevice
(
DeviceId
:
Integer
):
Int64
;
override
;
function
ReserveRedeemCode
(
PhoneNumber
:
string
;
out
Code
:
string
):
Boolean
;
override
;
function
ReserveRedeemCode
(
PhoneNumber
:
string
;
out
Code
:
string
):
Boolean
;
override
;
...
@@ -93,36 +93,33 @@ begin
...
@@ -93,36 +93,33 @@ begin
TUniQuery
(
Components
[
i
]).
Connection
:=
Connection
;
TUniQuery
(
Components
[
i
]).
Connection
:=
Connection
;
end
;
end
;
function
TOracleDeviceDatabase
.
PendingDevice
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
function
TOracleDeviceDatabase
.
PendingDevice
(
PhoneNumber
:
string
):
TDataSet
;
begin
begin
uqPendingDevice
.
Close
;
uqPendingDevice
.
Close
;
uqPendingDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqPendingDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqPendingDevice
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqPendingDevice
.
Open
;
uqPendingDevice
.
Open
;
Result
:=
uqPendingDevice
;
Result
:=
uqPendingDevice
;
end
;
end
;
function
TOracleDeviceDatabase
.
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
function
TOracleDeviceDatabase
.
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
):
Int64
;
begin
begin
uqSetVerificationCode
.
Close
;
uqSetVerificationCode
.
Close
;
uqSetVerificationCode
.
ParamByName
(
'CODE'
).
AsString
:=
Code
;
uqSetVerificationCode
.
ParamByName
(
'CODE'
).
AsString
:=
Code
;
uqSetVerificationCode
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqSetVerificationCode
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqSetVerificationCode
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqSetVerificationCode
.
ExecSQL
;
uqSetVerificationCode
.
ExecSQL
;
Result
:=
uqSetVerificationCode
.
RowsAffected
;
Result
:=
uqSetVerificationCode
.
RowsAffected
;
end
;
end
;
function
TOracleDeviceDatabase
.
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
;
DeviceType
:
string
):
Int64
;
function
TOracleDeviceDatabase
.
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
):
Int64
;
begin
begin
uqConsumeVerificationCode
.
Close
;
uqConsumeVerificationCode
.
Close
;
uqConsumeVerificationCode
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqConsumeVerificationCode
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqConsumeVerificationCode
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqConsumeVerificationCode
.
ParamByName
(
'CODE'
).
AsString
:=
Code
;
uqConsumeVerificationCode
.
ParamByName
(
'CODE'
).
AsString
:=
Code
;
uqConsumeVerificationCode
.
ExecSQL
;
uqConsumeVerificationCode
.
ExecSQL
;
Result
:=
uqConsumeVerificationCode
.
RowsAffected
;
Result
:=
uqConsumeVerificationCode
.
RowsAffected
;
end
;
end
;
function
TOracleDeviceDatabase
.
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
function
TOracleDeviceDatabase
.
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
):
Int64
;
begin
begin
uqActivateWebAuthnDevice
.
Close
;
uqActivateWebAuthnDevice
.
Close
;
uqActivateWebAuthnDevice
.
ParamByName
(
'CID'
).
AsString
:=
CredentialId
;
uqActivateWebAuthnDevice
.
ParamByName
(
'CID'
).
AsString
:=
CredentialId
;
...
@@ -132,7 +129,6 @@ begin
...
@@ -132,7 +129,6 @@ begin
uqActivateWebAuthnDevice
.
ParamByName
(
'ALG'
).
AsInteger
:=
PublicKeyAlg
;
uqActivateWebAuthnDevice
.
ParamByName
(
'ALG'
).
AsInteger
:=
PublicKeyAlg
;
uqActivateWebAuthnDevice
.
ParamByName
(
'CNT'
).
AsInteger
:=
SignCount
;
uqActivateWebAuthnDevice
.
ParamByName
(
'CNT'
).
AsInteger
:=
SignCount
;
uqActivateWebAuthnDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqActivateWebAuthnDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqActivateWebAuthnDevice
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqActivateWebAuthnDevice
.
ExecSQL
;
uqActivateWebAuthnDevice
.
ExecSQL
;
Result
:=
uqActivateWebAuthnDevice
.
RowsAffected
;
Result
:=
uqActivateWebAuthnDevice
.
RowsAffected
;
end
;
end
;
...
@@ -188,13 +184,12 @@ begin
...
@@ -188,13 +184,12 @@ begin
Result
:=
uqActiveDeviceKey
;
Result
:=
uqActiveDeviceKey
;
end
;
end
;
function
TOracleDeviceDatabase
.
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
function
TOracleDeviceDatabase
.
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
):
Int64
;
begin
begin
uqActivateSimpleDevice
.
Close
;
uqActivateSimpleDevice
.
Close
;
uqActivateSimpleDevice
.
ParamByName
(
'CID'
).
AsString
:=
CredentialId
;
uqActivateSimpleDevice
.
ParamByName
(
'CID'
).
AsString
:=
CredentialId
;
uqActivateSimpleDevice
.
ParamByName
(
'AGENT'
).
AsString
:=
UserAgent
;
uqActivateSimpleDevice
.
ParamByName
(
'AGENT'
).
AsString
:=
UserAgent
;
uqActivateSimpleDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqActivateSimpleDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqActivateSimpleDevice
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqActivateSimpleDevice
.
ExecSQL
;
uqActivateSimpleDevice
.
ExecSQL
;
Result
:=
uqActivateSimpleDevice
.
RowsAffected
;
Result
:=
uqActivateSimpleDevice
.
RowsAffected
;
end
;
end
;
...
@@ -259,11 +254,10 @@ begin
...
@@ -259,11 +254,10 @@ begin
end
;
end
;
end
;
end
;
function
TOracleDeviceDatabase
.
PendingPhone
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
function
TOracleDeviceDatabase
.
PendingPhone
(
PhoneNumber
:
string
):
TDataSet
;
begin
begin
uqPendingPhone
.
Close
;
uqPendingPhone
.
Close
;
uqPendingPhone
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqPendingPhone
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqPendingPhone
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqPendingPhone
.
Open
;
uqPendingPhone
.
Open
;
Result
:=
uqPendingPhone
;
Result
:=
uqPendingPhone
;
end
;
end
;
...
...
emiMobileServer/Shared/Database/PostgreSQL/PostgreSQL.Device.Database.dfm
View file @
4c72694c
...
@@ -16,18 +16,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
...
@@ -16,18 +16,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
SQL.Strings = (
SQL.Strings = (
'SELECT id, device_name FROM lems.device_registrations WHERE phon' +
'SELECT id, device_name FROM lems.device_registrations WHERE phon' +
'e_number = :PHONE AND status = '#39'pending'#39
'e_number = :PHONE AND status = '#39'pending'#39)
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Left = 60
Left = 60
Top = 110
Top = 110
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'PHONE'
Name = 'PHONE'
ParamType = ptInput
ParamType = ptInput
Value = nil
Value = nil
...
@@ -39,18 +33,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
...
@@ -39,18 +33,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
'UPDATE lems.device_registrations SET verification_code = :CODE, ' +
'UPDATE lems.device_registrations SET verification_code = :CODE, ' +
' verification_expires_at = NOW() + INTERVAL '#39'5 minutes'#39' WHERE' +
' verification_expires_at = NOW() + INTERVAL '#39'5 minutes'#39' WHERE' +
' phone_number = :PHONE AND status = '#39'pending'#39
' phone_number = :PHONE AND status = '#39'pending'#39)
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Left = 188
Left = 188
Top = 178
Top = 178
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'CODE'
Name = 'CODE'
ParamType = ptInput
ParamType = ptInput
Value = nil
Value = nil
...
@@ -69,18 +57,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
...
@@ -69,18 +57,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
'UPDATE lems.device_registrations SET verification_code = NULL, v' +
'UPDATE lems.device_registrations SET verification_code = NULL, v' +
'erification_expires_at = NULL WHERE phone_number = :PHONE AND st' +
'erification_expires_at = NULL WHERE phone_number = :PHONE AND st' +
'atus = '#39'pending'#39' AND verification_code = :CODE AND verification_' +
'atus = '#39'pending'#39' AND verification_code = :CODE AND verification_' +
'expires_at > NOW()'
'expires_at > NOW()')
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Left = 502
Left = 502
Top = 130
Top = 130
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'PHONE'
Name = 'PHONE'
ParamType = ptInput
ParamType = ptInput
Value = nil
Value = nil
...
@@ -101,18 +83,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
...
@@ -101,18 +83,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
' public_key_alg = :ALG, sign_count = :CNT, verification_c' +
' public_key_alg = :ALG, sign_count = :CNT, verification_c' +
'ode = NULL, verification_expires_at = NULL, status = '#39'active' +
'ode = NULL, verification_expires_at = NULL, status = '#39'active' +
#39', registered_at = NOW() WHERE phone_number = :PHONE AND status ' +
#39', registered_at = NOW() WHERE phone_number = :PHONE AND status ' +
'= '#39'pending'#39
'= '#39'pending'#39)
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Left = 618
Left = 618
Top = 164
Top = 164
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'CID'
Name = 'CID'
ParamType = ptInput
ParamType = ptInput
Value = nil
Value = nil
...
@@ -279,18 +255,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
...
@@ -279,18 +255,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
'agent = :AGENT, key_type = '#39'simple'#39', verification_code =' +
'agent = :AGENT, key_type = '#39'simple'#39', verification_code =' +
' NULL, verification_expires_at = NULL, status = '#39'active'#39', re' +
' NULL, verification_expires_at = NULL, status = '#39'active'#39', re' +
'gistered_at = NOW() WHERE phone_number = :PHONE AND status = '#39'pe' +
'gistered_at = NOW() WHERE phone_number = :PHONE AND status = '#39'pe' +
'nding'#39
'nding'#39)
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Left = 190
Left = 190
Top = 364
Top = 364
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'CID'
Name = 'CID'
ParamType = ptInput
ParamType = ptInput
Value = nil
Value = nil
...
@@ -429,18 +399,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
...
@@ -429,18 +399,12 @@ object PostgreSQLDeviceDatabase: TPostgreSQLDeviceDatabase
SQL.Strings = (
SQL.Strings = (
'SELECT id FROM lems.device_registrations WHERE phone_number = :P' +
'SELECT id FROM lems.device_registrations WHERE phone_number = :P' +
'HONE AND status = '#39'pending'#39
'HONE AND status = '#39'pending'#39)
' AND LOWER(TRIM(DEVICE_TYPE)) = :TYPE')
Left = 470
Left = 470
Top = 458
Top = 458
ParamData = <
ParamData = <
item
item
DataType = ftString
DataType = ftString
Name = 'TYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'PHONE'
Name = 'PHONE'
ParamType = ptInput
ParamType = ptInput
Value = nil
Value = nil
...
...
emiMobileServer/Shared/Database/PostgreSQL/PostgreSQL.Device.Database.pas
View file @
4c72694c
...
@@ -41,17 +41,17 @@ type
...
@@ -41,17 +41,17 @@ type
function
GetConnection
:
TUniConnection
;
override
;
function
GetConnection
:
TUniConnection
;
override
;
public
public
procedure
UseConnection
(
AConnection
:
TUniConnection
);
override
;
procedure
UseConnection
(
AConnection
:
TUniConnection
);
override
;
function
PendingDevice
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
override
;
function
PendingDevice
(
PhoneNumber
:
string
):
TDataSet
;
override
;
function
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
override
;
function
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
):
Int64
;
override
;
function
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
;
DeviceType
:
string
):
Int64
;
override
;
function
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
):
Int64
;
override
;
function
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
override
;
function
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
):
Int64
;
override
;
function
UnrevokedDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
UnrevokedDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
UnrevokedDeviceKey
(
CredentialId
:
string
):
TDataSet
;
override
;
function
UnrevokedDeviceKey
(
CredentialId
:
string
):
TDataSet
;
override
;
function
UpdateSignCount
(
SignCount
:
Integer
;
CredentialId
:
string
):
Int64
;
override
;
function
UpdateSignCount
(
SignCount
:
Integer
;
CredentialId
:
string
):
Int64
;
override
;
function
SaveDeviceUser
(
Username
:
string
;
Agency
:
string
;
CredentialId
:
string
):
Int64
;
override
;
function
SaveDeviceUser
(
Username
:
string
;
Agency
:
string
;
CredentialId
:
string
):
Int64
;
override
;
function
ActiveDeviceKey
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveDeviceKey
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
override
;
function
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
):
Int64
;
override
;
function
ActiveSimpleDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveSimpleDeviceUser
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveSimpleDevice
(
CredentialId
:
string
):
TDataSet
;
override
;
function
ActiveSimpleDevice
(
CredentialId
:
string
):
TDataSet
;
override
;
function
DeviceStatus
(
CredentialId
:
string
):
TDataSet
;
override
;
function
DeviceStatus
(
CredentialId
:
string
):
TDataSet
;
override
;
...
@@ -59,7 +59,7 @@ type
...
@@ -59,7 +59,7 @@ type
function
RevokeDevice
(
RevokedBy
:
string
;
CredentialId
:
string
):
Int64
;
override
;
function
RevokeDevice
(
RevokedBy
:
string
;
CredentialId
:
string
):
Int64
;
override
;
function
UnrevokeDevice
(
CredentialId
:
string
):
Int64
;
override
;
function
UnrevokeDevice
(
CredentialId
:
string
):
Int64
;
override
;
function
DeviceNameExists
(
DeviceName
:
string
):
Boolean
;
override
;
function
DeviceNameExists
(
DeviceName
:
string
):
Boolean
;
override
;
function
PendingPhone
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
override
;
function
PendingPhone
(
PhoneNumber
:
string
):
TDataSet
;
override
;
function
AddPendingDevice
(
DeviceName
:
string
;
DeviceType
:
string
;
PhoneNumber
:
string
):
Int64
;
override
;
function
AddPendingDevice
(
DeviceName
:
string
;
DeviceType
:
string
;
PhoneNumber
:
string
):
Int64
;
override
;
function
DeleteDevice
(
DeviceId
:
Integer
):
Int64
;
override
;
function
DeleteDevice
(
DeviceId
:
Integer
):
Int64
;
override
;
function
ReserveRedeemCode
(
PhoneNumber
:
string
;
out
Code
:
string
):
Boolean
;
override
;
function
ReserveRedeemCode
(
PhoneNumber
:
string
;
out
Code
:
string
):
Boolean
;
override
;
...
@@ -94,36 +94,33 @@ begin
...
@@ -94,36 +94,33 @@ begin
TUniQuery
(
Components
[
i
]).
Connection
:=
Connection
;
TUniQuery
(
Components
[
i
]).
Connection
:=
Connection
;
end
;
end
;
function
TPostgreSQLDeviceDatabase
.
PendingDevice
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
function
TPostgreSQLDeviceDatabase
.
PendingDevice
(
PhoneNumber
:
string
):
TDataSet
;
begin
begin
uqPendingDevice
.
Close
;
uqPendingDevice
.
Close
;
uqPendingDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqPendingDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqPendingDevice
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqPendingDevice
.
Open
;
uqPendingDevice
.
Open
;
Result
:=
uqPendingDevice
;
Result
:=
uqPendingDevice
;
end
;
end
;
function
TPostgreSQLDeviceDatabase
.
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
function
TPostgreSQLDeviceDatabase
.
SetVerificationCode
(
Code
:
string
;
PhoneNumber
:
string
):
Int64
;
begin
begin
uqSetVerificationCode
.
Close
;
uqSetVerificationCode
.
Close
;
uqSetVerificationCode
.
ParamByName
(
'CODE'
).
AsString
:=
Code
;
uqSetVerificationCode
.
ParamByName
(
'CODE'
).
AsString
:=
Code
;
uqSetVerificationCode
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqSetVerificationCode
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqSetVerificationCode
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqSetVerificationCode
.
ExecSQL
;
uqSetVerificationCode
.
ExecSQL
;
Result
:=
uqSetVerificationCode
.
RowsAffected
;
Result
:=
uqSetVerificationCode
.
RowsAffected
;
end
;
end
;
function
TPostgreSQLDeviceDatabase
.
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
;
DeviceType
:
string
):
Int64
;
function
TPostgreSQLDeviceDatabase
.
ConsumeVerificationCode
(
PhoneNumber
:
string
;
Code
:
string
):
Int64
;
begin
begin
uqConsumeVerificationCode
.
Close
;
uqConsumeVerificationCode
.
Close
;
uqConsumeVerificationCode
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqConsumeVerificationCode
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqConsumeVerificationCode
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqConsumeVerificationCode
.
ParamByName
(
'CODE'
).
AsString
:=
Code
;
uqConsumeVerificationCode
.
ParamByName
(
'CODE'
).
AsString
:=
Code
;
uqConsumeVerificationCode
.
ExecSQL
;
uqConsumeVerificationCode
.
ExecSQL
;
Result
:=
uqConsumeVerificationCode
.
RowsAffected
;
Result
:=
uqConsumeVerificationCode
.
RowsAffected
;
end
;
end
;
function
TPostgreSQLDeviceDatabase
.
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
function
TPostgreSQLDeviceDatabase
.
ActivateWebAuthnDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PublicKeyX
:
TBytes
;
PublicKeyY
:
TBytes
;
PublicKeyAlg
:
Integer
;
SignCount
:
Integer
;
PhoneNumber
:
string
):
Int64
;
begin
begin
uqActivateWebAuthnDevice
.
Close
;
uqActivateWebAuthnDevice
.
Close
;
uqActivateWebAuthnDevice
.
ParamByName
(
'CID'
).
AsString
:=
CredentialId
;
uqActivateWebAuthnDevice
.
ParamByName
(
'CID'
).
AsString
:=
CredentialId
;
...
@@ -133,7 +130,6 @@ begin
...
@@ -133,7 +130,6 @@ begin
uqActivateWebAuthnDevice
.
ParamByName
(
'ALG'
).
AsInteger
:=
PublicKeyAlg
;
uqActivateWebAuthnDevice
.
ParamByName
(
'ALG'
).
AsInteger
:=
PublicKeyAlg
;
uqActivateWebAuthnDevice
.
ParamByName
(
'CNT'
).
AsInteger
:=
SignCount
;
uqActivateWebAuthnDevice
.
ParamByName
(
'CNT'
).
AsInteger
:=
SignCount
;
uqActivateWebAuthnDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqActivateWebAuthnDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqActivateWebAuthnDevice
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqActivateWebAuthnDevice
.
ExecSQL
;
uqActivateWebAuthnDevice
.
ExecSQL
;
Result
:=
uqActivateWebAuthnDevice
.
RowsAffected
;
Result
:=
uqActivateWebAuthnDevice
.
RowsAffected
;
end
;
end
;
...
@@ -189,13 +185,12 @@ begin
...
@@ -189,13 +185,12 @@ begin
Result
:=
uqActiveDeviceKey
;
Result
:=
uqActiveDeviceKey
;
end
;
end
;
function
TPostgreSQLDeviceDatabase
.
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
;
DeviceType
:
string
):
Int64
;
function
TPostgreSQLDeviceDatabase
.
ActivateSimpleDevice
(
CredentialId
:
string
;
UserAgent
:
string
;
PhoneNumber
:
string
):
Int64
;
begin
begin
uqActivateSimpleDevice
.
Close
;
uqActivateSimpleDevice
.
Close
;
uqActivateSimpleDevice
.
ParamByName
(
'CID'
).
AsString
:=
CredentialId
;
uqActivateSimpleDevice
.
ParamByName
(
'CID'
).
AsString
:=
CredentialId
;
uqActivateSimpleDevice
.
ParamByName
(
'AGENT'
).
AsString
:=
UserAgent
;
uqActivateSimpleDevice
.
ParamByName
(
'AGENT'
).
AsString
:=
UserAgent
;
uqActivateSimpleDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqActivateSimpleDevice
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqActivateSimpleDevice
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqActivateSimpleDevice
.
ExecSQL
;
uqActivateSimpleDevice
.
ExecSQL
;
Result
:=
uqActivateSimpleDevice
.
RowsAffected
;
Result
:=
uqActivateSimpleDevice
.
RowsAffected
;
end
;
end
;
...
@@ -260,11 +255,10 @@ begin
...
@@ -260,11 +255,10 @@ begin
end
;
end
;
end
;
end
;
function
TPostgreSQLDeviceDatabase
.
PendingPhone
(
PhoneNumber
:
string
;
DeviceType
:
string
):
TDataSet
;
function
TPostgreSQLDeviceDatabase
.
PendingPhone
(
PhoneNumber
:
string
):
TDataSet
;
begin
begin
uqPendingPhone
.
Close
;
uqPendingPhone
.
Close
;
uqPendingPhone
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqPendingPhone
.
ParamByName
(
'PHONE'
).
AsString
:=
PhoneNumber
;
uqPendingPhone
.
ParamByName
(
'TYPE'
).
AsString
:=
DeviceType
;
uqPendingPhone
.
Open
;
uqPendingPhone
.
Open
;
Result
:=
uqPendingPhone
;
Result
:=
uqPendingPhone
;
end
;
end
;
...
...
emiMobileServer/Shared/Server/Api.ServiceImpl.pas
View file @
4c72694c
...
@@ -533,13 +533,13 @@ begin
...
@@ -533,13 +533,13 @@ begin
Exit
;
Exit
;
end
;
end
;
//
Note: A phone number can have one pending registration per device type.
//
Reject if a pending entry with this phone already exists
q
:=
store
.
PendingPhone
(
normalizedPhone
,
normalizedDeviceType
);
q
:=
store
.
PendingPhone
(
normalizedPhone
);
if
not
q
.
IsEmpty
then
if
not
q
.
IsEmpty
then
begin
begin
q
.
Close
;
q
.
Close
;
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'message'
,
'A pending entry for that phone number a
nd device type a
lready exists.'
);
Result
.
AddPair
(
'message'
,
'A pending entry for that phone number already exists.'
);
Exit
;
Exit
;
end
;
end
;
q
.
Close
;
q
.
Close
;
...
...
emiMobileServer/Shared/Server/Auth.Service.pas
View file @
4c72694c
...
@@ -79,12 +79,12 @@ type
...
@@ -79,12 +79,12 @@ type
function
VerifyVersion
(
ClientVersion
:
string
):
TJSONObject
;
function
VerifyVersion
(
ClientVersion
:
string
):
TJSONObject
;
// Section: Device registration step 1 checks phone pre-auth and sends an SMS code
// Section: Device registration step 1 checks phone pre-auth and sends an SMS code
function
BeginRegistration
(
const
PhoneNumber
,
DeviceType
:
string
):
TJSONObject
;
function
BeginRegistration
(
const
PhoneNumber
:
string
):
TJSONObject
;
// Section: Device registration step 2 verifies the SMS code and returns a challenge
// Section: Device registration step 2 verifies the SMS code and returns a challenge
function
VerifyRegistrationCode
(
const
PhoneNumber
,
DeviceType
,
function
VerifyRegistrationCode
(
const
PhoneNumber
,
VerificationCode
:
string
):
TJSONObject
;
VerificationCode
:
string
):
TJSONObject
;
// Section: WebAuthn registration verifies the credential and activates the pending row
// Section: WebAuthn registration verifies the credential and activates the pending row
function
CompleteRegistration
(
const
PhoneNumber
,
DeviceType
,
CredentialId
,
function
CompleteRegistration
(
const
PhoneNumber
,
CredentialId
,
AttestationObject
,
ClientDataJSON
,
AttestationObject
,
ClientDataJSON
,
ChallengeToken
:
string
):
TJSONObject
;
ChallengeToken
:
string
):
TJSONObject
;
// WebAuthn authentication challenge — called before Login
// WebAuthn authentication challenge — called before Login
...
@@ -96,7 +96,7 @@ type
...
@@ -96,7 +96,7 @@ type
AuthenticatorData
,
ClientDataJSON
,
AuthenticatorData
,
ClientDataJSON
,
Signature
:
string
):
string
;
Signature
:
string
):
string
;
// Simple-key registration — client generates key, no crypto verification
// Simple-key registration — client generates key, no crypto verification
function
CompleteRegistrationSimple
(
const
PhoneNumber
,
Device
Type
,
Device
Key
,
function
CompleteRegistrationSimple
(
const
PhoneNumber
,
DeviceKey
,
ChallengeToken
:
string
):
TJSONObject
;
ChallengeToken
:
string
):
TJSONObject
;
// Simple-key auto-login — verifies challenge token + credential ownership
// Simple-key auto-login — verifies challenge token + credential ownership
function
LoginDeviceKey
(
const
CredentialId
,
ChallengeToken
:
string
):
string
;
function
LoginDeviceKey
(
const
CredentialId
,
ChallengeToken
:
string
):
string
;
...
...
emiMobileServer/Shared/Server/Auth.ServiceImpl.pas
View file @
4c72694c
...
@@ -41,16 +41,16 @@ type
...
@@ -41,16 +41,16 @@ type
destructor
Destroy
;
override
;
destructor
Destroy
;
override
;
function
GetAgencieslist
():
TAgenciesList
;
function
GetAgencieslist
():
TAgenciesList
;
function
GetAgencyConfiglist
:
TAgencyConfigList
;
function
GetAgencyConfiglist
:
TAgencyConfigList
;
function
BeginRegistration
(
const
PhoneNumber
,
DeviceType
:
string
):
TJSONObject
;
function
BeginRegistration
(
const
PhoneNumber
:
string
):
TJSONObject
;
function
VerifyRegistrationCode
(
const
PhoneNumber
,
DeviceType
,
function
VerifyRegistrationCode
(
const
PhoneNumber
,
VerificationCode
:
string
):
TJSONObject
;
VerificationCode
:
string
):
TJSONObject
;
function
CompleteRegistration
(
const
PhoneNumber
,
DeviceType
,
CredentialId
,
AttestationObject
,
ClientDataJSON
,
ChallengeToken
:
string
):
TJSONObject
;
function
CompleteRegistration
(
const
PhoneNumber
,
CredentialId
,
AttestationObject
,
ClientDataJSON
,
ChallengeToken
:
string
):
TJSONObject
;
function
BeginAuthentication
(
const
CredentialId
:
string
):
TJSONObject
;
function
BeginAuthentication
(
const
CredentialId
:
string
):
TJSONObject
;
function
GetDeviceUser
(
const
CredentialId
:
string
):
TJSONObject
;
function
GetDeviceUser
(
const
CredentialId
:
string
):
TJSONObject
;
function
LoginAutomatic
(
const
CredentialId
,
ChallengeToken
,
function
LoginAutomatic
(
const
CredentialId
,
ChallengeToken
,
AuthenticatorData
,
ClientDataJSON
,
AuthenticatorData
,
ClientDataJSON
,
Signature
:
string
):
string
;
Signature
:
string
):
string
;
function
CompleteRegistrationSimple
(
const
PhoneNumber
,
Device
Type
,
Device
Key
,
function
CompleteRegistrationSimple
(
const
PhoneNumber
,
DeviceKey
,
ChallengeToken
:
string
):
TJSONObject
;
ChallengeToken
:
string
):
TJSONObject
;
function
LoginDeviceKey
(
const
CredentialId
,
ChallengeToken
:
string
):
string
;
function
LoginDeviceKey
(
const
CredentialId
,
ChallengeToken
:
string
):
string
;
function
LoginPasswordAndSimpleKey
(
const
User
,
Password
,
Agency
,
function
LoginPasswordAndSimpleKey
(
const
User
,
Password
,
Agency
,
...
@@ -257,7 +257,7 @@ end;
...
@@ -257,7 +257,7 @@ end;
// BeginRegistration
// BeginRegistration
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function
TAuthService
.
BeginRegistration
(
const
PhoneNumber
,
DeviceType
:
string
):
TJSONObject
;
function
TAuthService
.
BeginRegistration
(
const
PhoneNumber
:
string
):
TJSONObject
;
var
var
affectedRows
:
Int64
;
affectedRows
:
Int64
;
code
,
normalizedPhone
,
deviceName
:
string
;
code
,
normalizedPhone
,
deviceName
:
string
;
...
@@ -287,24 +287,14 @@ begin
...
@@ -287,24 +287,14 @@ begin
end
;
end
;
end
;
end
;
if
(
not
SameText
(
Trim
(
DeviceType
),
'iphone'
))
and
(
not
SameText
(
Trim
(
DeviceType
),
'android'
))
and
(
not
SameText
(
Trim
(
DeviceType
),
'browser'
))
and
(
not
SameText
(
Trim
(
DeviceType
),
'other'
))
then
begin
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'message'
,
'Please select a valid device type.'
);
Exit
;
end
;
// Verify phone number was pre-authorized by admin
// Verify phone number was pre-authorized by admin
q
:=
FDeviceStore
.
PendingDevice
(
normalizedPhone
,
LowerCase
(
Trim
(
DeviceType
))
);
q
:=
FDeviceStore
.
PendingDevice
(
normalizedPhone
);
if
q
.
IsEmpty
then
if
q
.
IsEmpty
then
begin
begin
q
.
Close
;
q
.
Close
;
Logger
.
Log
(
2
,
'BeginRegistration - phone not pre-authorized: "'
+
normalizedPhone
+
'"'
);
Logger
.
Log
(
2
,
'BeginRegistration - phone not pre-authorized: "'
+
normalizedPhone
+
'"'
);
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'message'
,
'
No pending registration matches that phone number and device type
. Contact your administrator.'
);
Result
.
AddPair
(
'message'
,
'
Phone number not recognized
. Contact your administrator.'
);
Exit
;
Exit
;
end
;
end
;
deviceId
:=
q
.
FieldByName
(
'id'
).
AsInteger
;
deviceId
:=
q
.
FieldByName
(
'id'
).
AsInteger
;
...
@@ -330,11 +320,11 @@ begin
...
@@ -330,11 +320,11 @@ begin
end
;
end
;
// Note: Persist the code only after the SMS provider accepts the message.
// Note: Persist the code only after the SMS provider accepts the message.
affectedRows
:=
FDeviceStore
.
SetVerificationCode
(
code
,
normalizedPhone
,
LowerCase
(
Trim
(
DeviceType
))
);
affectedRows
:=
FDeviceStore
.
SetVerificationCode
(
code
,
normalizedPhone
);
if
affectedRows
=
0
then
if
affectedRows
=
0
then
begin
begin
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'message'
,
'
No pending registration matches that phone number and device type
. Contact your administrator.'
);
Result
.
AddPair
(
'message'
,
'
Phone number not recognized
. Contact your administrator.'
);
Exit
;
Exit
;
end
;
end
;
...
@@ -346,7 +336,7 @@ begin
...
@@ -346,7 +336,7 @@ begin
Logger
.
Log
(
3
,
'---TAuthService.BeginRegistration End'
);
Logger
.
Log
(
3
,
'---TAuthService.BeginRegistration End'
);
end
;
end
;
function
TAuthService
.
VerifyRegistrationCode
(
const
PhoneNumber
,
DeviceType
,
function
TAuthService
.
VerifyRegistrationCode
(
const
PhoneNumber
,
VerificationCode
:
string
):
TJSONObject
;
VerificationCode
:
string
):
TJSONObject
;
var
var
affectedRows
:
Int64
;
affectedRows
:
Int64
;
...
@@ -370,7 +360,7 @@ begin
...
@@ -370,7 +360,7 @@ begin
verificationValid
:=
False
;
verificationValid
:=
False
;
if
Length
(
Trim
(
VerificationCode
))
=
6
then
if
Length
(
Trim
(
VerificationCode
))
=
6
then
begin
begin
affectedRows
:=
FDeviceStore
.
ConsumeVerificationCode
(
normalizedPhone
,
Trim
(
VerificationCode
)
,
LowerCase
(
Trim
(
DeviceType
))
);
affectedRows
:=
FDeviceStore
.
ConsumeVerificationCode
(
normalizedPhone
,
Trim
(
VerificationCode
));
verificationValid
:=
affectedRows
>
0
;
verificationValid
:=
affectedRows
>
0
;
end
;
end
;
...
@@ -383,7 +373,7 @@ begin
...
@@ -383,7 +373,7 @@ begin
Exit
;
Exit
;
end
;
end
;
token
:=
MakeChallengeToken
(
'reg-'
+
normalizedPhone
+
'-'
+
LowerCase
(
Trim
(
DeviceType
))
);
token
:=
MakeChallengeToken
(
'reg-'
+
normalizedPhone
);
challengeB64
:=
token
.
Split
([
':'
],
4
)[
0
];
challengeB64
:=
token
.
Split
([
':'
],
4
)[
0
];
Result
.
AddPair
(
'status'
,
'ok'
);
Result
.
AddPair
(
'status'
,
'ok'
);
...
@@ -399,7 +389,7 @@ end;
...
@@ -399,7 +389,7 @@ end;
// CompleteRegistration
// CompleteRegistration
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function
TAuthService
.
CompleteRegistration
(
const
PhoneNumber
,
DeviceType
,
CredentialId
,
function
TAuthService
.
CompleteRegistration
(
const
PhoneNumber
,
CredentialId
,
AttestationObject
,
ClientDataJSON
,
ChallengeToken
:
string
):
TJSONObject
;
AttestationObject
,
ClientDataJSON
,
ChallengeToken
:
string
):
TJSONObject
;
var
var
affectedRows
:
Int64
;
affectedRows
:
Int64
;
...
@@ -434,7 +424,7 @@ begin
...
@@ -434,7 +424,7 @@ begin
// 1. Verify challenge token
// 1. Verify challenge token
if
not
VerifyChallengeToken
(
ChallengeToken
,
if
not
VerifyChallengeToken
(
ChallengeToken
,
'reg-'
+
normalizedPhone
+
'-'
+
LowerCase
(
Trim
(
DeviceType
))
,
challengeB64
)
then
'reg-'
+
normalizedPhone
,
challengeB64
)
then
begin
begin
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'message'
,
'Invalid or expired registration challenge.'
);
Result
.
AddPair
(
'message'
,
'Invalid or expired registration challenge.'
);
...
@@ -557,7 +547,7 @@ begin
...
@@ -557,7 +547,7 @@ begin
if
ctx
<>
nil
then
if
ctx
<>
nil
then
userAgent
:=
ctx
.
Request
.
Headers
.
Get
(
'User-Agent'
);
userAgent
:=
ctx
.
Request
.
Headers
.
Get
(
'User-Agent'
);
affectedRows
:=
FDeviceStore
.
ActivateWebAuthnDevice
(
Trim
(
CredentialId
),
userAgent
,
pubKeyX
,
pubKeyY
,
pubKeyAlg
,
Integer
(
signCount
),
normalizedPhone
,
LowerCase
(
Trim
(
DeviceType
))
);
affectedRows
:=
FDeviceStore
.
ActivateWebAuthnDevice
(
Trim
(
CredentialId
),
userAgent
,
pubKeyX
,
pubKeyY
,
pubKeyAlg
,
Integer
(
signCount
),
normalizedPhone
);
if
affectedRows
=
0
then
if
affectedRows
=
0
then
begin
begin
...
@@ -1008,7 +998,7 @@ end;
...
@@ -1008,7 +998,7 @@ end;
// CompleteRegistrationSimple — client-generated key, no crypto verification
// CompleteRegistrationSimple — client-generated key, no crypto verification
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function
TAuthService
.
CompleteRegistrationSimple
(
const
PhoneNumber
,
Device
Type
,
Device
Key
,
function
TAuthService
.
CompleteRegistrationSimple
(
const
PhoneNumber
,
DeviceKey
,
ChallengeToken
:
string
):
TJSONObject
;
ChallengeToken
:
string
):
TJSONObject
;
var
var
affectedRows
:
Int64
;
affectedRows
:
Int64
;
...
@@ -1031,7 +1021,7 @@ begin
...
@@ -1031,7 +1021,7 @@ begin
end
;
end
;
if
not
VerifyChallengeToken
(
ChallengeToken
,
if
not
VerifyChallengeToken
(
ChallengeToken
,
'reg-'
+
normalizedPhone
+
'-'
+
LowerCase
(
Trim
(
DeviceType
))
,
challengeB64
)
then
'reg-'
+
normalizedPhone
,
challengeB64
)
then
begin
begin
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'status'
,
'error'
);
Result
.
AddPair
(
'message'
,
'Invalid or expired registration challenge.'
);
Result
.
AddPair
(
'message'
,
'Invalid or expired registration challenge.'
);
...
@@ -1050,7 +1040,7 @@ begin
...
@@ -1050,7 +1040,7 @@ begin
if
ctx
<>
nil
then
if
ctx
<>
nil
then
userAgent
:=
ctx
.
Request
.
Headers
.
Get
(
'User-Agent'
);
userAgent
:=
ctx
.
Request
.
Headers
.
Get
(
'User-Agent'
);
affectedRows
:=
FDeviceStore
.
ActivateSimpleDevice
(
Trim
(
DeviceKey
),
userAgent
,
normalizedPhone
,
LowerCase
(
Trim
(
DeviceType
))
);
affectedRows
:=
FDeviceStore
.
ActivateSimpleDevice
(
Trim
(
DeviceKey
),
userAgent
,
normalizedPhone
);
if
affectedRows
=
0
then
if
affectedRows
=
0
then
begin
begin
...
...
emiMobileServer/Shared/Web/View.DeviceRegistration.dfm
View file @
4c72694c
...
@@ -18,19 +18,6 @@ object FViewDeviceRegistration: TFViewDeviceRegistration
...
@@ -18,19 +18,6 @@ object FViewDeviceRegistration: TFViewDeviceRegistration
TextHint = '(303) 555-1234'
TextHint = '(303) 555-1234'
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
end
object cmbDeviceType: TWebComboBox
Left = 240
Top = 110
Width = 177
Height = 25
ElementID = 'view.devicereg.devicetype'
ItemIndex = -1
Items.Strings = (
'iPhone'
'Android'
'Browser'
'Other')
end
object btnRegister: TWebButton
object btnRegister: TWebButton
Left = 240
Left = 240
Top = 163
Top = 163
...
...
emiMobileServer/Shared/Web/View.DeviceRegistration.html
View file @
4c72694c
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
<p
class=
"text-muted small mb-3"
>
<p
class=
"text-muted small mb-3"
>
This browser has not been registered for emiMobile access.
This browser has not been registered for emiMobile access.
Enter the phone number
and select the device type
your administrator registered for this device,
Enter the phone number your administrator registered for this device,
then click
<strong>
Send Code
</strong>
.
then click
<strong>
Send Code
</strong>
.
</p>
</p>
...
@@ -46,11 +46,6 @@
...
@@ -46,11 +46,6 @@
autofocus
>
autofocus
>
</div>
</div>
<div
class=
"mb-3"
>
<label
class=
"form-label small text-muted"
for=
"view.devicereg.devicetype"
>
Device type
</label>
<select
id=
"view.devicereg.devicetype"
class=
"form-select"
aria-label=
"Device type"
></select>
</div>
<div
id=
"view.devicereg.verification"
class=
"mb-3 d-none"
>
<div
id=
"view.devicereg.verification"
class=
"mb-3 d-none"
>
<label
class=
"form-label small text-muted"
>
Verification code
</label>
<label
class=
"form-label small text-muted"
>
Verification code
</label>
<input
id=
"view.devicereg.edtverificationcode"
<input
id=
"view.devicereg.edtverificationcode"
...
...
emiMobileServer/Shared/Web/View.DeviceRegistration.pas
View file @
4c72694c
...
@@ -11,7 +11,6 @@ uses
...
@@ -11,7 +11,6 @@ uses
type
type
TFViewDeviceRegistration
=
class
(
TWebForm
)
TFViewDeviceRegistration
=
class
(
TWebForm
)
edtPhoneNumber
:
TWebEdit
;
edtPhoneNumber
:
TWebEdit
;
cmbDeviceType
:
TWebComboBox
;
btnRegister
:
TWebButton
;
btnRegister
:
TWebButton
;
pnlVerification
:
TWebPanel
;
pnlVerification
:
TWebPanel
;
edtVerificationCode
:
TWebEdit
;
edtVerificationCode
:
TWebEdit
;
...
@@ -26,7 +25,6 @@ type
...
@@ -26,7 +25,6 @@ type
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
WebFormCreate
(
Sender
:
TObject
);
private
private
FRegistrationProc
:
TSuccessProc
;
FRegistrationProc
:
TSuccessProc
;
FDeviceType
:
string
;
procedure
ShowNotification
(
const
AMsg
:
string
;
AIsError
:
Boolean
=
True
);
procedure
ShowNotification
(
const
AMsg
:
string
;
AIsError
:
Boolean
=
True
);
procedure
HideNotification
;
procedure
HideNotification
;
procedure
SetBusy
(
ABusy
:
Boolean
);
procedure
SetBusy
(
ABusy
:
Boolean
);
...
@@ -92,7 +90,6 @@ end;
...
@@ -92,7 +90,6 @@ end;
procedure
TFViewDeviceRegistration
.
SetBusy
(
ABusy
:
Boolean
);
procedure
TFViewDeviceRegistration
.
SetBusy
(
ABusy
:
Boolean
);
begin
begin
cmbDeviceType
.
Enabled
:=
(
not
ABusy
)
and
edtPhoneNumber
.
Enabled
;
asm
asm
var
btn
=
document
.
getElementById
(
'view.devicereg.btnregister'
);
var
btn
=
document
.
getElementById
(
'view.devicereg.btnregister'
);
if
(
btn
)
{
if
(
btn
)
{
...
@@ -121,7 +118,6 @@ var
...
@@ -121,7 +118,6 @@ var
begin
begin
SetBusy
(
False
);
SetBusy
(
False
);
edtPhoneNumber
.
Enabled
:=
False
;
edtPhoneNumber
.
Enabled
:=
False
;
cmbDeviceType
.
Enabled
:=
False
;
pnlVerification
.
ElementHandle
.
classList
.
remove
(
'd-none'
);
pnlVerification
.
ElementHandle
.
classList
.
remove
(
'd-none'
);
edtVerificationCode
.
SetFocus
;
edtVerificationCode
.
SetFocus
;
ShowNotification
(
'Verification code sent. Enter the six-digit code to continue.'
,
False
);
ShowNotification
(
'Verification code sent. Enter the six-digit code to continue.'
,
False
);
...
@@ -141,17 +137,10 @@ begin
...
@@ -141,17 +137,10 @@ begin
Exit
;
Exit
;
end
;
end
;
if
cmbDeviceType
.
ItemIndex
<
0
then
begin
ShowNotification
(
'Please select the device type your administrator registered.'
);
Exit
;
end
;
FDeviceType
:=
LowerCase
(
cmbDeviceType
.
Text
);
SetBusy
(
True
);
SetBusy
(
True
);
HideNotification
;
HideNotification
;
AuthService
.
BeginRegistration
(
phoneNumber
,
FDeviceType
,
@
OnCodeSent
,
@
OnCodeError
);
AuthService
.
BeginRegistration
(
phoneNumber
,
@
OnCodeSent
,
@
OnCodeError
);
end
;
end
;
procedure
TFViewDeviceRegistration
.
btnVerifyCodeClick
(
Sender
:
TObject
);
procedure
TFViewDeviceRegistration
.
btnVerifyCodeClick
(
Sender
:
TObject
);
...
@@ -189,7 +178,7 @@ begin
...
@@ -189,7 +178,7 @@ begin
SetVerifyBusy
(
True
);
SetVerifyBusy
(
True
);
HideNotification
;
HideNotification
;
AuthService
.
VerifyRegistrationCode
(
phoneNumber
,
FDeviceType
,
verificationCode
,
AuthService
.
VerifyRegistrationCode
(
phoneNumber
,
verificationCode
,
@
OnVerified
,
@
OnVerifyError
);
@
OnVerified
,
@
OnVerifyError
);
end
;
end
;
...
@@ -212,7 +201,7 @@ var
...
@@ -212,7 +201,7 @@ var
procedure
OnCredential
(
ACredentialId
,
AAttestationObject
,
AClientDataJSON
:
string
);
procedure
OnCredential
(
ACredentialId
,
AAttestationObject
,
AClientDataJSON
:
string
);
begin
begin
AuthService
.
CompleteRegistration
(
AuthService
.
CompleteRegistration
(
phoneNumber
,
FDeviceType
,
ACredentialId
,
AAttestationObject
,
AClientDataJSON
,
challengeToken
,
phoneNumber
,
ACredentialId
,
AAttestationObject
,
AClientDataJSON
,
challengeToken
,
@
OnCompleteOK
,
@
OnCompleteError
@
OnCompleteOK
,
@
OnCompleteError
);
);
end
;
end
;
...
@@ -306,7 +295,7 @@ begin
...
@@ -306,7 +295,7 @@ begin
end
;
end
;
AuthService
.
CompleteRegistrationSimple
(
AuthService
.
CompleteRegistrationSimple
(
phoneNumber
,
FDeviceType
,
deviceKey
,
challengeToken
,
phoneNumber
,
deviceKey
,
challengeToken
,
@
OnCompleteOK
,
@
OnCompleteError
@
OnCompleteOK
,
@
OnCompleteError
);
);
end
;
end
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment