@abtnode/auth 1.16.6-beta-593a7a98 → 1.16.6-beta-e2082fec

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.
Files changed (2) hide show
  1. package/lib/auth.js +6 -2
  2. package/package.json +7 -7
package/lib/auth.js CHANGED
@@ -10,7 +10,7 @@ const { getChainClient } = require('@abtnode/util/lib/get-chain-client');
10
10
  const { fromPublicKey } = require('@ocap/wallet');
11
11
  const { fromBase58, toAddress } = require('@ocap/util');
12
12
  const { toTypeInfo, isFromPublicKey } = require('@arcblock/did');
13
- const Mcrypto = require('@ocap/mcrypto');
13
+ const { getRandomBytes, Hasher } = require('@ocap/mcrypto');
14
14
  const getBlockletInfo = require('@blocklet/meta/lib/info');
15
15
  const {
16
16
  PASSPORT_STATUS,
@@ -315,7 +315,7 @@ const getPassportStatusEndpoint = ({ baseUrl, userDid, teamDid }) => {
315
315
  };
316
316
 
317
317
  const getRandomMessage = (len = 16) => {
318
- const hex = Mcrypto.getRandomBytes(len);
318
+ const hex = getRandomBytes(len);
319
319
  return hex.replace(/^0x/, '').toUpperCase();
320
320
  };
321
321
 
@@ -328,6 +328,7 @@ const getApplicationInfo = async ({ node, nodeInfo = {}, teamDid }) => {
328
328
  let passportColor;
329
329
  let owner;
330
330
  let dataDir;
331
+ let secret;
331
332
 
332
333
  if (teamDid === nodeInfo.did) {
333
334
  name = nodeInfo.name;
@@ -339,6 +340,7 @@ const getApplicationInfo = async ({ node, nodeInfo = {}, teamDid }) => {
339
340
  passportColor = 'default';
340
341
  owner = nodeInfo.nodeOwner;
341
342
  dataDir = path.join(node.dataDirs.data, NODE_DATA_DIR_NAME);
343
+ secret = Hasher.SHA3.hash256(Buffer.concat([_wallet.secretKey, _wallet.address].map(Buffer.from)));
342
344
  } else {
343
345
  const blocklet = await node.getBlocklet({ did: teamDid, attachRuntimeInfo: false });
344
346
  const blockletInfo = getBlockletInfo(blocklet, nodeInfo.sk);
@@ -350,6 +352,7 @@ const getApplicationInfo = async ({ node, nodeInfo = {}, teamDid }) => {
350
352
  type = TEAM_TYPE.BLOCKLET;
351
353
  owner = get(blocklet, 'settings.owner');
352
354
  dataDir = blocklet.env.dataDir;
355
+ secret = blockletInfo.secret;
353
356
  }
354
357
 
355
358
  return {
@@ -361,6 +364,7 @@ const getApplicationInfo = async ({ node, nodeInfo = {}, teamDid }) => {
361
364
  passportColor,
362
365
  owner,
363
366
  dataDir,
367
+ secret,
364
368
  };
365
369
  };
366
370
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.6-beta-593a7a98",
6
+ "version": "1.16.6-beta-e2082fec",
7
7
  "description": "Simple lib to manage auth in ABT Node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -20,13 +20,13 @@
20
20
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@abtnode/constant": "1.16.6-beta-593a7a98",
24
- "@abtnode/logger": "1.16.6-beta-593a7a98",
25
- "@abtnode/util": "1.16.6-beta-593a7a98",
23
+ "@abtnode/constant": "1.16.6-beta-e2082fec",
24
+ "@abtnode/logger": "1.16.6-beta-e2082fec",
25
+ "@abtnode/util": "1.16.6-beta-e2082fec",
26
26
  "@arcblock/did": "1.18.77",
27
27
  "@arcblock/vc": "1.18.77",
28
- "@blocklet/constant": "1.16.6-beta-593a7a98",
29
- "@blocklet/meta": "1.16.6-beta-593a7a98",
28
+ "@blocklet/constant": "1.16.6-beta-e2082fec",
29
+ "@blocklet/meta": "1.16.6-beta-e2082fec",
30
30
  "@ocap/mcrypto": "1.18.77",
31
31
  "@ocap/util": "1.18.77",
32
32
  "@ocap/wallet": "1.18.77",
@@ -41,5 +41,5 @@
41
41
  "devDependencies": {
42
42
  "jest": "^27.5.1"
43
43
  },
44
- "gitHead": "5ea65d1ddc91e997f029741f01ce453464d86666"
44
+ "gitHead": "851e0ab17f1c6e160aedc47fcdbf7dd54dfa7237"
45
45
  }