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
24
Issue boards
Milestones
Wiki
Code
Merge requests
5
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
249214fc
Commit
249214fc
authored
6 years ago
by
Markin Igor
Browse files
Options
Downloads
Patches
Plain Diff
Dispatch DeviceRevoked event to clients.
parent
6b1beabe
Branches
390-device-management-ability-to-remove-device
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!28
Dispatch DeviceRevoked event to clients.
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Gopkg.toml
+1
-1
1 addition, 1 deletion
Gopkg.toml
javascript/src/constants/statuses.js
+1
-0
1 addition, 0 deletions
javascript/src/constants/statuses.js
javascript/src/iframe/viamapi-iframe.js
+48
-13
48 additions, 13 deletions
javascript/src/iframe/viamapi-iframe.js
with
50 additions
and
14 deletions
Gopkg.toml
+
1
−
1
View file @
249214fc
...
...
@@ -25,7 +25,7 @@
# unused-packages = true
[[constraint]]
branch
=
"
master
"
branch
=
"
390-device-management-ability-to-remove-device
"
name
=
"code.vereign.com/code/restful-api"
[prune]
...
...
This diff is collapsed.
Click to expand it.
javascript/src/constants/statuses.js
0 → 100644
+
1
−
0
View file @
249214fc
export
const
STATUS_DEVICE_REVOKED
=
"
Device revoked
"
;
This diff is collapsed.
Click to expand it.
javascript/src/iframe/viamapi-iframe.js
+
48
−
13
View file @
249214fc
...
...
@@ -18,6 +18,7 @@ import {
}
from
'
../utilities/signingUtilities
'
;
import
CryptoData
from
'
../CryptoData
'
;
import
Identity
from
'
../Identity
'
;
import
{
STATUS_DEVICE_REVOKED
}
from
'
../constants/statuses
'
;
const
penpalMethods
=
require
(
'
../../temp/penpal-methods
'
).
default
;
const
WopiAPI
=
require
(
'
./wopiapi-iframe
'
);
...
...
@@ -193,6 +194,34 @@ function createEvent(actionId, type, payloads) {
}
}
const
destroyAuthentication
=
()
=>
{
const
authenticationPublicKey
=
localStorage
.
getItem
(
"
authenticatedIdentity
"
);
window
.
viamApi
.
setIdentity
(
""
);
window
.
viamApi
.
setSessionData
(
""
,
""
);
clearPinCodeTtl
(
authenticationPublicKey
);
localStorage
.
removeItem
(
"
uuid
"
);
localStorage
.
removeItem
(
"
token
"
);
localStorage
.
removeItem
(
"
authenticatedIdentity
"
);
window
.
currentlyAuthenticatedIdentity
=
null
;
window
.
lastTimeGetProfile
=
0
;
};
const
destroyIdentity
=
()
=>
{
destroyAuthentication
();
if
(
window
.
currentlyLoadedIdentity
)
{
const
{
publicKey
}
=
window
.
currentlyLoadedIdentity
.
authentication
;
delete
window
.
loadedIdentities
[
publicKey
];
window
.
currentlyLoadedIdentity
=
null
;
destroyIdentityFromLocalStorage
(
publicKey
);
}
};
window
.
loadedIdentities
=
{};
window
.
wopiAPI
=
new
WopiAPI
();
window
.
collaboraApi
=
new
CollaboraAPI
();
...
...
@@ -202,6 +231,8 @@ window.currentlyAuthenticatedIdentity = null;
window
.
currentlyLoadedIdentity
=
null
;
window
.
lastTimeGetProfile
=
0
;
let
iframeParent
=
null
;
const
handleIdentityLogin
=
(
identity
,
uuid
,
token
)
=>
{
const
{
loadedIdentities
,
viamApi
}
=
window
;
const
{
publicKey
}
=
identity
.
authentication
;
...
...
@@ -219,10 +250,22 @@ function executeRestfulFunction(type, that, fn, ...args) {
const
{
currentlyAuthenticatedIdentity
,
viamApi
,
currentlyLoadedIdentity
}
=
window
;
return
new
Penpal
.
Promise
(
executeResult
=>
{
fn
.
apply
(
that
,
args
).
then
((
response
)
=>
{
fn
.
apply
(
that
,
args
).
then
(
async
(
response
)
=>
{
const
identity
=
currentlyAuthenticatedIdentity
||
currentlyLoadedIdentity
;
if
(
type
===
"
private
"
&&
identity
&&
response
.
data
.
code
===
"
400
"
&&
response
.
data
.
status
===
"
Bad session
"
)
{
const
{
code
,
status
}
=
response
.
data
;
// Destroy local storage in case device was revoked
if
(
type
===
"
private
"
&&
code
===
"
401
"
&&
status
===
STATUS_DEVICE_REVOKED
)
{
destroyIdentity
();
const
event
=
createEvent
(
""
,
"
DeviceRevoked
"
);
iframeParent
.
onEvent
(
event
);
return
executeResult
(
response
.
data
);
}
if
(
type
===
"
private
"
&&
identity
&&
code
===
"
400
"
&&
status
===
"
Bad session
"
)
{
viamApi
.
identityLogin
(
"
previousaddeddevice
"
)
.
then
((
response
)
=>
{
if
(
response
.
data
.
code
===
"
200
"
)
{
...
...
@@ -696,17 +739,7 @@ const connection = Penpal.connectToParent({
window
.
viamApi
.
identityLogout
);
window
.
viamApi
.
setIdentity
(
""
);
window
.
viamApi
.
setSessionData
(
""
,
""
);
clearPinCodeTtl
(
authenticationPublicKey
);
localStorage
.
removeItem
(
"
uuid
"
);
localStorage
.
removeItem
(
"
token
"
);
localStorage
.
removeItem
(
"
authenticatedIdentity
"
);
delete
window
.
loadedIdentities
[
authenticationPublicKey
];
window
.
currentlyLoadedIdentity
=
null
;
window
.
currentlyAuthenticatedIdentity
=
null
;
window
.
lastTimeGetProfile
=
0
;
destroyAuthentication
();
return
identityLogoutResponse
;
},
...
...
@@ -1041,6 +1074,8 @@ const connection = Penpal.connectToParent({
});
connection
.
promise
.
then
(
parent
=>
{
iframeParent
=
parent
;
if
(
!
navigator
.
cookieEnabled
)
{
console
.
warn
(
"
Cookie disabled. Can't start library.
"
);
return
;
...
...
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