@abtnode/auth 1.6.31 → 1.7.2

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
@@ -22,8 +22,8 @@ const createPassportSvg = require('./util/create-passport-svg');
22
22
 
23
23
  const messages = {
24
24
  description: {
25
- en: 'Login with your DID Wallet',
26
- zh: ' DID 钱包登录',
25
+ en: 'Connect your DID Wallet',
26
+ zh: '连接 DID 钱包',
27
27
  },
28
28
  requestProfile: {
29
29
  en: 'Please provide following information to continue',
@@ -1,6 +1,4 @@
1
- const { toHex } = require('@ocap/util');
2
- const { Hasher } = require('@ocap/mcrypto');
3
- const { getNftBGColor, DEFAULT_COLOR } = require('./passport-color');
1
+ const { getNftBGColor, DEFAULT_COLOR, getNftBGColorFromDid } = require('./passport-color');
4
2
 
5
3
  /**
6
4
  * Generate Passport SVG
@@ -29,7 +27,7 @@ const createPassportSvg = ({
29
27
  if (preferredColor === 'default') {
30
28
  colors = DEFAULT_COLOR;
31
29
  } else if (preferredColor === 'auto') {
32
- colors = getNftBGColor(`#${toHex(Hasher.SHA3.hash224(issuerDid)).slice(-6)}`);
30
+ colors = getNftBGColorFromDid(issuerDid);
33
31
  } else {
34
32
  colors = getNftBGColor(preferredColor);
35
33
  }
@@ -1,3 +1,6 @@
1
+ const { toHex } = require('@ocap/util');
2
+ const { Hasher } = require('@ocap/mcrypto');
3
+
1
4
  const DEFAULT_COLOR = {
2
5
  startColor: '#2B3845',
3
6
  endColor: '#5A7A8A',
@@ -47,6 +50,14 @@ const getNftBGColor = (rgbString) => {
47
50
  };
48
51
  };
49
52
 
53
+ function getPassportColorFromDid(did) {
54
+ return `#${toHex(Hasher.SHA3.hash224(did)).slice(-6)}`;
55
+ }
56
+
57
+ function getNftBGColorFromDid(did) {
58
+ return getNftBGColor(getPassportColorFromDid(did));
59
+ }
60
+
50
61
  /**
51
62
  * RGB 转换为 HSL 颜色
52
63
  *
@@ -130,5 +141,7 @@ function hslToRgb(h, s, l) {
130
141
 
131
142
  module.exports = {
132
143
  getNftBGColor,
144
+ getNftBGColorFromDid,
133
145
  DEFAULT_COLOR,
146
+ getPassportColorFromDid,
134
147
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.31",
6
+ "version": "1.7.2",
7
7
  "description": "Simple lib to manage auth in ABT Node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -20,15 +20,15 @@
20
20
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@abtnode/constant": "1.6.31",
24
- "@abtnode/logger": "1.6.31",
25
- "@abtnode/util": "1.6.31",
26
- "@arcblock/did": "^1.14.24",
27
- "@arcblock/vc": "^1.14.24",
28
- "@blocklet/meta": "1.6.31",
29
- "@ocap/mcrypto": "^1.14.24",
30
- "@ocap/util": "^1.14.24",
31
- "@ocap/wallet": "^1.14.24",
23
+ "@abtnode/constant": "1.7.2",
24
+ "@abtnode/logger": "1.7.2",
25
+ "@abtnode/util": "1.7.2",
26
+ "@arcblock/did": "^1.15.3",
27
+ "@arcblock/vc": "^1.15.3",
28
+ "@blocklet/meta": "1.7.2",
29
+ "@ocap/mcrypto": "^1.15.3",
30
+ "@ocap/util": "^1.15.3",
31
+ "@ocap/wallet": "^1.15.3",
32
32
  "axios": "^0.25.0",
33
33
  "joi": "^17.6.0",
34
34
  "jsonwebtoken": "^8.5.1",
@@ -39,5 +39,5 @@
39
39
  "devDependencies": {
40
40
  "jest": "^27.4.5"
41
41
  },
42
- "gitHead": "ccda31a16ac6b606d34336fcc6db0b2aff15c32e"
42
+ "gitHead": "b84e7406d84fb9c3be5bf7ce968cb7b6b661d550"
43
43
  }