Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vereign Client Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
Vereign Client Library
Commits
084d14ac
Commit
084d14ac
authored
6 years ago
by
Alexey Lunin
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into 479-image-fetching-optimiation
parents
a56e35c9
a0aeb3ef
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!39
Implement centralized image fetching logic
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
javascript/src/iframe/viamapi-iframe.js
+40
-64
40 additions, 64 deletions
javascript/src/iframe/viamapi-iframe.js
with
40 additions
and
64 deletions
javascript/src/iframe/viamapi-iframe.js
+
40
−
64
View file @
084d14ac
...
...
@@ -327,36 +327,6 @@ function loadIdentityInternal(identityKey, pinCode) {
});
}
function
changeIdentityPinCodeInternal
(
key
,
oldPinCode
,
newPinCode
)
{
return
new
Penpal
.
Promise
(
result
=>
{
getIdentityFromLocalStorage
(
key
,
oldPinCode
,
false
).
then
((
identity
)
=>
{
identity
.
pinCode
=
newPinCode
;
setIdentityInLocalStorage
(
identity
).
then
(()
=>
{
result
({
"
data
"
:
""
,
"
code
"
:
"
200
"
,
"
status
"
:
"
Successfully changed pincode
"
});
}).
catch
((
e
)
=>
{
result
({
"
data
"
:
""
,
"
code
"
:
"
400
"
,
"
status
"
:
"
Cannot store identity
"
+
e
});
});
}).
catch
((
e
)
=>
{
result
({
"
data
"
:
""
,
"
code
"
:
"
400
"
,
"
status
"
:
"
Cannot get identity
"
+
e
});
});
});
}
function
getCertificateForPassport
(
passportUUID
,
internal
)
{
return
new
Penpal
.
Promise
(
certificateResult
=>
{
...
...
@@ -501,8 +471,34 @@ const connection = Penpal.connectToParent({
loadIdentity
(
identityKey
,
pinCode
)
{
return
loadIdentityInternal
(
identityKey
,
pinCode
)
},
changeIdentityPinCode
(
key
,
oldPinCode
,
newPinCode
)
{
return
changeIdentityPinCodeInternal
(
key
,
oldPinCode
,
newPinCode
)
checkIdentityPinCode
:
async
(
key
,
pinCode
)
=>
{
try
{
const
identity
=
await
getIdentityFromLocalStorage
(
key
,
pinCode
,
false
);
if
(
identity
)
{
return
encodeResponse
(
"
200
"
,
null
,
"
Pincode check successful
"
);
}
else
{
return
encodeResponse
(
"
400
"
,
null
,
"
Pincode check failed
"
);
}
}
catch
(
e
)
{
return
encodeResponse
(
"
400
"
,
e
,
"
Pincode check error
"
);
}
},
changeIdentityPinCode
:
async
(
key
,
oldPinCode
,
newPinCode
)
=>
{
try
{
const
identity
=
await
getIdentityFromLocalStorage
(
key
,
oldPinCode
,
false
);
if
(
identity
)
{
identity
.
pinCode
=
newPinCode
;
await
setIdentityInLocalStorage
(
identity
);
return
encodeResponse
(
"
200
"
,
null
,
"
Successfully changed pincode
"
);
}
else
{
return
encodeResponse
(
"
400
"
,
null
,
"
Identity not found
"
);
}
}
catch
(
e
)
{
return
encodeResponse
(
"
400
"
,
e
.
message
,
"
Change pincode error
"
);
}
},
getIdentityProfile
(
identityKey
)
{
return
new
Penpal
.
Promise
(
result
=>
{
...
...
@@ -520,18 +516,15 @@ const connection = Penpal.connectToParent({
}
});
},
clearIdentities
()
{
return
new
Penpal
.
Promise
(
result
=>
{
var
identitiesTemp
=
listIdentitiesFromLocalStorage
();
clearIdentities
:
async
()
=>
{
destroyAuthentication
();
for
(
var
i
in
identitiesTemp
)
{
destroyIdentityFromLocalStorage
(
i
)
}
result
({
"
data
"
:
""
,
"
code
"
:
"
200
"
,
"
status
"
:
"
Identities cleared
"
})
});
const
identitiesTemp
=
listIdentitiesFromLocalStorage
();
for
(
const
i
in
identitiesTemp
)
{
destroyIdentityFromLocalStorage
(
i
);
}
return
encodeResponse
(
"
200
"
,
""
,
"
Identities cleared
"
);
},
confirmIdentificator
(
identity
,
confirmationCodeArg
)
{
return
new
Penpal
.
Promise
(
result
=>
{
...
...
@@ -612,6 +605,7 @@ const connection = Penpal.connectToParent({
}
const
deviceHash
=
await
createDeviceHash
(
loginIdentity
.
authentication
.
publicKey
);
window
.
viamApi
.
setSessionData
(
""
,
""
);
window
.
viamApi
.
setDeviceHash
(
deviceHash
);
window
.
viamApi
.
setIdentity
(
loginIdentity
.
authentication
.
publicKey
);
...
...
@@ -644,19 +638,6 @@ const connection = Penpal.connectToParent({
return
responseToClient
;
},
identityPullAvatarFromGravatar
:
async
()
=>
{
const
authenticationPublicKey
=
localStorage
.
getItem
(
"
authenticatedIdentity
"
);
if
(
!
authenticationPublicKey
||
!
window
.
loadedIdentities
[
authenticationPublicKey
]
||
!
extendPinCodeTtl
(
authenticationPublicKey
)
)
{
return
encodeResponse
(
"
400
"
,
""
,
"
Identity not authenticated
"
);
}
return
await
executeRestfulFunction
(
"
private
"
,
viamApi
,
viamApi
.
identityPullAvatarFromGravatar
);
},
identityAddNewDevice
()
{
return
new
Penpal
.
Promise
(
result
=>
{
const
authenticationPublicKey
=
localStorage
.
getItem
(
"
authenticatedIdentity
"
);
...
...
@@ -751,6 +732,7 @@ const connection = Penpal.connectToParent({
},
identityRestoreAccess
(
restoreAccessIdentity
,
identificator
)
{
return
new
Penpal
.
Promise
(
result
=>
{
viamApi
.
setSessionData
(
""
,
""
);
viamApi
.
setIdentity
(
restoreAccessIdentity
.
authentication
.
publicKey
);
executeRestfulFunction
(
"
public
"
,
viamApi
,
viamApi
.
identityRestoreAccess
,
null
,
identificator
).
then
(
executeResult
=>
{
...
...
@@ -1299,14 +1281,8 @@ connection.promise.then(parent => {
for
(
let
i
=
0
;
i
<
eventsLen
;
i
++
)
{
const
event
=
executeResult
.
data
[
i
];
switch
(
event
.
type
)
{
case
"
Authenticated
"
:
{
const
uuid
=
event
.
payloads
[
0
];
const
token
=
event
.
payloads
[
1
];
handleIdentityLogin
(
window
.
currentlyLoadedIdentity
,
uuid
,
token
);
const
identityToStore
=
window
.
currentlyAuthenticatedIdentity
;
event
.
payloads
=
[{
fromQRCode
:
true
}];
await
setIdentityInLocalStorage
(
identityToStore
);
await
getProfileData
(
identityToStore
);
case
"
DeviceConfirmed
"
:
{
await
setIdentityInLocalStorage
(
window
.
currentlyLoadedIdentity
);
parent
.
onEvent
(
event
);
break
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment