@abtnode/util 1.16.8-beta-186fd5aa → 1.16.8-next-d1e52353
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lock.js +2 -2
- package/lib/{user-avatar.js → user.js} +29 -0
- package/package.json +5 -5
package/lib/lock.js
CHANGED
|
@@ -15,7 +15,7 @@ module.exports = class Lock {
|
|
|
15
15
|
if (!this.locked) {
|
|
16
16
|
this.locked = true;
|
|
17
17
|
this.events.removeListener('release', tryAcquire);
|
|
18
|
-
resolve();
|
|
18
|
+
resolve(true);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ module.exports = class Lock {
|
|
|
23
23
|
} else {
|
|
24
24
|
// Otherwise, take the lock and resolve immediately
|
|
25
25
|
this.locked = true;
|
|
26
|
-
resolve();
|
|
26
|
+
resolve(true);
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const fs = require('fs-extra');
|
|
3
|
+
const cloneDeep = require('lodash/cloneDeep');
|
|
3
4
|
|
|
4
5
|
const { USER_AVATAR_DIR, USER_AVATAR_URL_PREFIX } = require('@abtnode/constant');
|
|
5
6
|
|
|
@@ -62,8 +63,36 @@ const parseUserAvatar = async (avatar, { dataDir } = {}) => {
|
|
|
62
63
|
return data;
|
|
63
64
|
};
|
|
64
65
|
|
|
66
|
+
function updateConnectedAccount(connectedAccounts = [], connectedAccount = {}) {
|
|
67
|
+
const now = new Date().toISOString();
|
|
68
|
+
const accounts = connectedAccounts.filter(Boolean);
|
|
69
|
+
const updated = cloneDeep(accounts);
|
|
70
|
+
const updates = Array.isArray(connectedAccount) ? connectedAccount : [connectedAccount];
|
|
71
|
+
updates.filter(Boolean).forEach((x) => {
|
|
72
|
+
if (x.provider && x.did) {
|
|
73
|
+
const index = updated.findIndex((item) => item.provider === x.provider && item.did === x.did);
|
|
74
|
+
if (index > -1) {
|
|
75
|
+
updated[index] = {
|
|
76
|
+
...accounts[index],
|
|
77
|
+
...x,
|
|
78
|
+
lastLoginAt: now,
|
|
79
|
+
};
|
|
80
|
+
} else {
|
|
81
|
+
updated.push({
|
|
82
|
+
firstLoginAt: now,
|
|
83
|
+
...x,
|
|
84
|
+
lastLoginAt: now,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return updated;
|
|
91
|
+
}
|
|
92
|
+
|
|
65
93
|
module.exports = {
|
|
66
94
|
extractUserAvatar,
|
|
67
95
|
parseUserAvatar,
|
|
68
96
|
getAvatarFile,
|
|
97
|
+
updateConnectedAccount,
|
|
69
98
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.8-
|
|
6
|
+
"version": "1.16.8-next-d1e52353",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.16.8-
|
|
22
|
-
"@abtnode/logger": "1.16.8-
|
|
23
|
-
"@blocklet/constant": "1.16.8-
|
|
21
|
+
"@abtnode/constant": "1.16.8-next-d1e52353",
|
|
22
|
+
"@abtnode/logger": "1.16.8-next-d1e52353",
|
|
23
|
+
"@blocklet/constant": "1.16.8-next-d1e52353",
|
|
24
24
|
"@ocap/client": "1.18.78",
|
|
25
25
|
"@ocap/mcrypto": "1.18.78",
|
|
26
26
|
"@ocap/util": "1.18.78",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"jest": "^27.5.1",
|
|
72
72
|
"unzipper": "^0.10.11"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "d357376aa3df9ef789befc7f548629deecb04d96"
|
|
75
75
|
}
|