@abtnode/auth 1.16.17-beta-703fb879 → 1.16.17-beta-a8cf4b25

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/auth.js CHANGED
@@ -1234,6 +1234,50 @@ const verifyNFT = async ({ claims, challenge, chainHost, locale }) => {
1234
1234
  return state;
1235
1235
  };
1236
1236
 
1237
+ /**
1238
+ * @typedef {Object} UserSessionRequstData
1239
+ * @property {string} teamDid
1240
+ * @property {string} userDid
1241
+ * @property {string} [visitorId]
1242
+ */
1243
+
1244
+ /**
1245
+ * @typedef {Object} UserSessionRequstOption
1246
+ * @property {object} req - 当前请求的 req 上下文
1247
+ * @property {object} node - 注入的 node 对象
1248
+ * @property {string} [sourceAppPid] - 统一登录的 master appPid
1249
+ * @property {string} [appPid] - 统一登录的 master appPid
1250
+ */
1251
+
1252
+ /**
1253
+ *
1254
+ * @param {UserSessionRequstData} data
1255
+ * @param {UserSessionRequstOption} options
1256
+ * @returns
1257
+ */
1258
+ async function upsertUserSession(
1259
+ { visitorId, teamDid, userDid, appPid, passportId, status },
1260
+ { req, node, sourceAppPid }
1261
+ ) {
1262
+ const lastLoginIp = req.headers['x-real-ip'];
1263
+ const ua = req.headers['user-agent'];
1264
+
1265
+ const doc = await node.upsertUserSession({
1266
+ teamDid,
1267
+ visitorId,
1268
+ lastLoginIp,
1269
+ userDid,
1270
+ ua,
1271
+ appPid,
1272
+ passportId,
1273
+ status,
1274
+ // 如果是来自统一登录流程,则需要向 master 再发起一次记录的请求
1275
+ sourceAppPid,
1276
+ });
1277
+
1278
+ return doc;
1279
+ }
1280
+
1237
1281
  module.exports = {
1238
1282
  getUser,
1239
1283
  getApplicationInfo,
@@ -1257,4 +1301,5 @@ module.exports = {
1257
1301
  setUserInfoHeaders,
1258
1302
  createBlockletControllerAuthToken,
1259
1303
  TEAM_TYPE,
1304
+ upsertUserSession,
1260
1305
  };
@@ -56,7 +56,7 @@ const getApplicationInfo = async ({ type, node, req, baseUrl = '' }) => {
56
56
  const blockletInfo = getBlockletInfo(blocklet, info.sk);
57
57
  issuerDid = blockletInfo.wallet.address;
58
58
  issuerDidList = uniq([blockletInfo.wallet.address, ...getBlockletAppIdList(blocklet)]);
59
- issuerName = getDisplayName(blocklet, true);
59
+ issuerName = getDisplayName(blocklet);
60
60
  issuerWallet = blockletInfo.wallet;
61
61
  passportColor = blockletInfo.passportColor;
62
62
  dataDir = blocklet.env.dataDir;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.17-beta-703fb879",
6
+ "version": "1.16.17-beta-a8cf4b25",
7
7
  "description": "Simple lib to manage auth in ABT Node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -20,17 +20,17 @@
20
20
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@abtnode/constant": "1.16.17-beta-703fb879",
24
- "@abtnode/logger": "1.16.17-beta-703fb879",
25
- "@abtnode/util": "1.16.17-beta-703fb879",
26
- "@arcblock/did": "1.18.92",
27
- "@arcblock/nft-display": "2.8.2",
28
- "@arcblock/vc": "1.18.92",
29
- "@blocklet/constant": "1.16.17-beta-703fb879",
30
- "@blocklet/meta": "1.16.17-beta-703fb879",
31
- "@ocap/mcrypto": "1.18.92",
32
- "@ocap/util": "1.18.92",
33
- "@ocap/wallet": "1.18.92",
23
+ "@abtnode/constant": "1.16.17-beta-a8cf4b25",
24
+ "@abtnode/logger": "1.16.17-beta-a8cf4b25",
25
+ "@abtnode/util": "1.16.17-beta-a8cf4b25",
26
+ "@arcblock/did": "1.18.93",
27
+ "@arcblock/nft-display": "2.8.4",
28
+ "@arcblock/vc": "1.18.93",
29
+ "@blocklet/constant": "1.16.17-beta-a8cf4b25",
30
+ "@blocklet/meta": "1.16.17-beta-a8cf4b25",
31
+ "@ocap/mcrypto": "1.18.93",
32
+ "@ocap/util": "1.18.93",
33
+ "@ocap/wallet": "1.18.93",
34
34
  "fs-extra": "^10.1.0",
35
35
  "joi": "17.7.0",
36
36
  "jsonwebtoken": "^9.0.0",
@@ -43,5 +43,5 @@
43
43
  "devDependencies": {
44
44
  "jest": "^27.5.1"
45
45
  },
46
- "gitHead": "97d63c671d823076e58b994107e10866367edd5d"
46
+ "gitHead": "df8486ab9a180f0f3fc812821440a995d65bc63d"
47
47
  }