@abtnode/webapp 1.8.63-beta-a36b5e1a → 1.8.63

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 (198) hide show
  1. package/blocklet.yml +6 -3
  2. package/build/asset-manifest.json +93 -0
  3. package/build/favicon.ico +0 -0
  4. package/build/icons/css/all.css +5919 -0
  5. package/build/icons/css/brands.css +14 -0
  6. package/build/icons/css/brands.min.css +12 -0
  7. package/build/icons/css/fontawesome.css +7816 -0
  8. package/build/icons/css/fontawesome.min.css +5864 -0
  9. package/build/icons/css/light.css +15 -0
  10. package/build/icons/css/light.min.css +13 -0
  11. package/build/icons/webfonts/fa-brands-400.eot +0 -0
  12. package/build/icons/webfonts/fa-brands-400.svg +1256 -0
  13. package/build/icons/webfonts/fa-brands-400.ttf +0 -0
  14. package/build/icons/webfonts/fa-brands-400.woff +0 -0
  15. package/build/icons/webfonts/fa-brands-400.woff2 +0 -0
  16. package/build/icons/webfonts/fa-light-300.eot +0 -0
  17. package/build/icons/webfonts/fa-light-300.svg +4445 -0
  18. package/build/icons/webfonts/fa-light-300.ttf +0 -0
  19. package/build/icons/webfonts/fa-light-300.woff +0 -0
  20. package/build/icons/webfonts/fa-light-300.woff2 +0 -0
  21. package/build/images/blocklet.png +0 -0
  22. package/build/images/blocklets-00c2c4.png +0 -0
  23. package/build/images/blocklets-222222.png +0 -0
  24. package/build/images/celebrate.png +0 -0
  25. package/build/images/community.svg +6 -0
  26. package/build/images/console-00c2c4.png +0 -0
  27. package/build/images/console-222222.png +0 -0
  28. package/build/images/dashboard-00c2c4.png +0 -0
  29. package/build/images/dashboard-222222.png +0 -0
  30. package/build/images/doc-222222.png +0 -0
  31. package/build/images/hourglass-222222.png +0 -0
  32. package/build/images/https-certificate-icon.png +0 -0
  33. package/build/images/labs-00c2c4.png +0 -0
  34. package/build/images/labs-222222.png +0 -0
  35. package/build/images/log-00c2c4.png +0 -0
  36. package/build/images/log-222222.png +0 -0
  37. package/build/images/member-222222.png +0 -0
  38. package/build/images/node.png +0 -0
  39. package/build/images/official.svg +1 -0
  40. package/build/images/private-222222.png +0 -0
  41. package/build/images/public-222222.png +0 -0
  42. package/build/images/public_avatar.png +0 -0
  43. package/build/images/router-00c2c4.png +0 -0
  44. package/build/images/router-222222.png +0 -0
  45. package/build/images/settings-00c2c4.png +0 -0
  46. package/build/images/settings-222222.png +0 -0
  47. package/build/images/slack.png +0 -0
  48. package/build/images/storage-222222.png +0 -0
  49. package/build/images/store-00c2c4.png +0 -0
  50. package/build/images/store-222222.png +0 -0
  51. package/build/images/team-00c2c4.png +0 -0
  52. package/build/images/team-222222.png +0 -0
  53. package/build/images/time-222222.png +0 -0
  54. package/build/images/upgrade.png +0 -0
  55. package/build/index.html +1 -0
  56. package/build/manifest.json +15 -0
  57. package/build/static/css/4381.5ade355d.chunk.css +1 -0
  58. package/build/static/css/4691.56c2f951.chunk.css +1 -0
  59. package/build/static/css/5245.5d6e9197.chunk.css +1 -0
  60. package/build/static/css/8213.f696fdbf.chunk.css +1 -0
  61. package/build/static/css/9779.f696fdbf.chunk.css +1 -0
  62. package/build/static/css/main.c9e90622.css +1 -0
  63. package/build/static/images/logo.png +0 -0
  64. package/build/static/js/1057.8280393f.chunk.js +1 -0
  65. package/build/static/js/1361.85e46159.chunk.js +1 -0
  66. package/build/static/js/1366.2f174c9b.chunk.js +2 -0
  67. package/build/static/js/1366.2f174c9b.chunk.js.LICENSE.txt +37 -0
  68. package/build/static/js/154.94956824.chunk.js +1 -0
  69. package/build/static/js/1826.07c285de.chunk.js +1 -0
  70. package/build/static/js/2129.120e36ae.chunk.js +1 -0
  71. package/build/static/js/2308.b65bc299.chunk.js +1 -0
  72. package/build/static/js/2564.eef717f3.chunk.js +1 -0
  73. package/build/static/js/2657.d3c62d57.chunk.js +1 -0
  74. package/build/static/js/2720.26eb1788.chunk.js +1 -0
  75. package/build/static/js/2828.4f318970.chunk.js +1 -0
  76. package/build/static/js/2878.5626558d.chunk.js +1 -0
  77. package/build/static/js/3111.84e02823.chunk.js +1 -0
  78. package/build/static/js/3476.c0b3411b.chunk.js +1 -0
  79. package/build/static/js/3633.8c7cf02d.chunk.js +1 -0
  80. package/build/static/js/3732.f5d8b39b.chunk.js +1 -0
  81. package/build/static/js/3776.1490b0f7.chunk.js +1 -0
  82. package/build/static/js/3829.b6d6cf45.chunk.js +1 -0
  83. package/build/static/js/4074.19db40ec.chunk.js +1 -0
  84. package/build/static/js/4104.b47ae0e1.chunk.js +1 -0
  85. package/build/static/js/4241.83e4f741.chunk.js +1 -0
  86. package/build/static/js/4274.e18ffddd.chunk.js +1 -0
  87. package/build/static/js/4349.7c2f6507.chunk.js +1 -0
  88. package/build/static/js/4381.631ef61d.chunk.js +2 -0
  89. package/build/static/js/4381.631ef61d.chunk.js.LICENSE.txt +22 -0
  90. package/build/static/js/4557.3907550e.chunk.js +1 -0
  91. package/build/static/js/4590.5a14012c.chunk.js +1 -0
  92. package/build/static/js/4633.9f946ed5.chunk.js +1 -0
  93. package/build/static/js/4691.550fcb40.chunk.js +2 -0
  94. package/build/static/js/4691.550fcb40.chunk.js.LICENSE.txt +8 -0
  95. package/build/static/js/5074.9ea094a9.chunk.js +1 -0
  96. package/build/static/js/5082.18d16cb9.chunk.js +1 -0
  97. package/build/static/js/519.adae6e43.chunk.js +1 -0
  98. package/build/static/js/556.381dcbd8.chunk.js +1 -0
  99. package/build/static/js/5984.25af6288.chunk.js +1 -0
  100. package/build/static/js/6158.8a43296d.chunk.js +1 -0
  101. package/build/static/js/6189.d6d74d14.chunk.js +1 -0
  102. package/build/static/js/6239.5a873a03.chunk.js +2 -0
  103. package/build/static/js/6239.5a873a03.chunk.js.LICENSE.txt +14 -0
  104. package/build/static/js/629.1a7f2553.chunk.js +1 -0
  105. package/build/static/js/6413.ab4a8e01.chunk.js +1 -0
  106. package/build/static/js/6602.c417a217.chunk.js +1 -0
  107. package/build/static/js/6780.64314507.chunk.js +1 -0
  108. package/build/static/js/6830.88b993a0.chunk.js +1 -0
  109. package/build/static/js/6866.2131ea60.chunk.js +2 -0
  110. package/build/static/js/6866.2131ea60.chunk.js.LICENSE.txt +8 -0
  111. package/build/static/js/6898.6fe0c32d.chunk.js +2 -0
  112. package/build/static/js/6898.6fe0c32d.chunk.js.LICENSE.txt +5 -0
  113. package/build/static/js/7016.835958ef.chunk.js +1 -0
  114. package/build/static/js/7298.a7286c09.chunk.js +1 -0
  115. package/build/static/js/7327.56a5e016.chunk.js +1 -0
  116. package/build/static/js/744.8b656dd2.chunk.js +1 -0
  117. package/build/static/js/7652.722b9180.chunk.js +1 -0
  118. package/build/static/js/8034.c4dcdeff.chunk.js +1 -0
  119. package/build/static/js/8058.0b2d4727.chunk.js +1 -0
  120. package/build/static/js/8213.09f25083.chunk.js +1 -0
  121. package/build/static/js/8235.add24931.chunk.js +1 -0
  122. package/build/static/js/8249.63c55b3a.chunk.js +1 -0
  123. package/build/static/js/8262.869cc799.chunk.js +1 -0
  124. package/build/static/js/8352.b57b0e44.chunk.js +1 -0
  125. package/build/static/js/8464.b4b82828.chunk.js +1 -0
  126. package/build/static/js/8606.66db67e2.chunk.js +1 -0
  127. package/build/static/js/9038.2908c176.chunk.js +1 -0
  128. package/build/static/js/9076.c77366bc.chunk.js +1 -0
  129. package/build/static/js/9301.a65db324.chunk.js +2 -0
  130. package/build/static/js/9301.a65db324.chunk.js.LICENSE.txt +8 -0
  131. package/build/static/js/9575.36f3de5b.chunk.js +2 -0
  132. package/build/static/js/9575.36f3de5b.chunk.js.LICENSE.txt +194 -0
  133. package/build/static/js/9779.bbf0dd81.chunk.js +1 -0
  134. package/build/static/js/main.cb5d8d67.js +2 -0
  135. package/build/static/js/main.cb5d8d67.js.LICENSE.txt +159 -0
  136. package/build/static/media/iconify.32b54549e843e448ee9b.cjs +2 -0
  137. package/build/static/media/iconify.32b54549e843e448ee9b.cjs.LICENSE.txt +13 -0
  138. package/build/static/media/lato-all-400-normal.3dc1eff492ab1f598560.woff +0 -0
  139. package/build/static/media/lato-all-700-normal.1e7707c9ec98d9b97e7f.woff +0 -0
  140. package/build/static/media/lato-latin-400-normal.be36596da218e1eec01c.woff2 +0 -0
  141. package/build/static/media/lato-latin-700-normal.8f28e0e1fdb195149f1c.woff2 +0 -0
  142. package/build/static/media/lato-latin-ext-400-normal.361f3dbb9db6a5980326.woff2 +0 -0
  143. package/build/static/media/lato-latin-ext-700-normal.9c8812eaec45956201e1.woff2 +0 -0
  144. package/build/static/media/logo.60f66bbe1ce9674a4df4e374c9d97fc4.svg +16 -0
  145. package/build/static/media/ubuntu-mono-all-400-normal.c879328bc62e9c68268f.woff +0 -0
  146. package/build/static/media/ubuntu-mono-cyrillic-400-normal.c367f416832eb8f1b846.woff2 +0 -0
  147. package/build/static/media/ubuntu-mono-cyrillic-ext-400-normal.eda1c4946b1f7bf58386.woff2 +0 -0
  148. package/build/static/media/ubuntu-mono-greek-400-normal.22f3bfc91f79c342bdf4.woff2 +0 -0
  149. package/build/static/media/ubuntu-mono-greek-ext-400-normal.b3459900ea8a25d1f7c2.woff2 +0 -0
  150. package/build/static/media/ubuntu-mono-latin-400-normal.18e32d9d743af28f913e.woff2 +0 -0
  151. package/build/static/media/ubuntu-mono-latin-ext-400-normal.b56e2315611d10838ad5.woff2 +0 -0
  152. package/package.json +1 -1
  153. package/api/gql/config.js +0 -392
  154. package/api/gql/index.js +0 -102
  155. package/api/gql/middlewares/create-audit-log.js +0 -3
  156. package/api/gql/middlewares/get-blocklet-list.js +0 -14
  157. package/api/gql/middlewares/install-blocklet.js +0 -13
  158. package/api/gql/middlewares/verify-blocklet.js +0 -21
  159. package/api/gql/middlewares/verify-team.js +0 -9
  160. package/api/index.js +0 -249
  161. package/api/libs/auth.js +0 -78
  162. package/api/libs/env.js +0 -3
  163. package/api/libs/login.js +0 -212
  164. package/api/libs/security.js +0 -90
  165. package/api/libs/storage.js +0 -69
  166. package/api/middlewares/mutate-blocklet-permission.js +0 -18
  167. package/api/routes/auth/accept-server.js +0 -28
  168. package/api/routes/auth/connect-owner.js +0 -143
  169. package/api/routes/auth/delegate-transfer-owner-nft.js +0 -86
  170. package/api/routes/auth/invite.js +0 -93
  171. package/api/routes/auth/issue-passport.js +0 -61
  172. package/api/routes/auth/launch-free-blocklet-by-nft.js +0 -9
  173. package/api/routes/auth/launch-free-blocklet.js +0 -9
  174. package/api/routes/auth/launch-paid-blocklet-by-nft.js +0 -9
  175. package/api/routes/auth/launch-paid-blocklet.js +0 -9
  176. package/api/routes/auth/login.js +0 -63
  177. package/api/routes/auth/lost-passport-issue.js +0 -5
  178. package/api/routes/auth/lost-passport-list.js +0 -5
  179. package/api/routes/auth/switch-passport.js +0 -47
  180. package/api/routes/auth/switch-profile.js +0 -69
  181. package/api/routes/auth/util.js +0 -135
  182. package/api/routes/auth/verify-owner.js +0 -39
  183. package/api/routes/auth/verify-purchase.js +0 -185
  184. package/api/routes/blocklet-info.js +0 -246
  185. package/api/routes/blocklet-preference.js +0 -161
  186. package/api/routes/blocklet-proxy.js +0 -220
  187. package/api/routes/did-resolver.js +0 -38
  188. package/api/routes/dns-resolver.js +0 -73
  189. package/api/routes/log.js +0 -31
  190. package/api/routes/passport.js +0 -19
  191. package/api/routes/session.js +0 -61
  192. package/api/routes/user.js +0 -38
  193. package/api/util/find-routing-rule.js +0 -95
  194. package/api/util/get-configs.js +0 -31
  195. package/api/util/index.js +0 -5
  196. package/api/util/navigation.js +0 -84
  197. package/api/webpack.blocklet.js +0 -43
  198. package/api/ws/index.js +0 -146
@@ -1,69 +0,0 @@
1
- /* eslint-disable consistent-return */
2
- const fs = require('fs');
3
- const os = require('os');
4
- const path = require('path');
5
- const crypto = require('crypto');
6
-
7
- function getFilename(req, file, cb) {
8
- crypto.randomBytes(16, (err, raw) => {
9
- cb(err, err ? undefined : raw.toString('hex'));
10
- });
11
- }
12
-
13
- function getDestination(req, file, cb) {
14
- cb(null, os.tmpdir());
15
- }
16
-
17
- function DiskStorage(opts) {
18
- this.getFilename = opts.filename || getFilename;
19
- this.getDestination = opts.destination || getDestination;
20
- }
21
-
22
- // A better version from https://github.com/expressjs/multer/blob/master/storage/disk.js
23
- // Because it stores the file with the content hash
24
- DiskStorage.prototype._handleFile = function _handleFile(req, file, cb) {
25
- const that = this;
26
- const hash = crypto.createHash('md5');
27
-
28
- that.getDestination(req, file, (err, destination) => {
29
- if (err) return cb(err);
30
-
31
- that.getFilename(req, file, (e, filename) => {
32
- if (e) return cb(e);
33
-
34
- let finalPath = path.join(destination, filename);
35
- const outStream = fs.createWriteStream(finalPath);
36
-
37
- file.stream.pipe(outStream);
38
- file.stream.on('data', x => hash.update(x));
39
-
40
- outStream.on('error', cb);
41
- outStream.on('finish', () => {
42
- const md5 = hash.digest('hex').toLowerCase();
43
- const finalName = md5 + path.extname(file.originalname);
44
- const oldPath = finalPath;
45
- finalPath = path.join(destination, finalName);
46
-
47
- fs.rename(oldPath, finalPath, () => {
48
- cb(null, {
49
- destination,
50
- filename: finalName,
51
- path: finalPath,
52
- size: outStream.bytesWritten,
53
- });
54
- });
55
- });
56
- });
57
- });
58
- };
59
-
60
- DiskStorage.prototype._removeFile = function _removeFile(req, file, cb) {
61
- const filePath = file.path;
62
- delete file.destination;
63
- delete file.filename;
64
- delete file.path;
65
-
66
- fs.unlink(filePath, cb);
67
- };
68
-
69
- module.exports = DiskStorage;
@@ -1,18 +0,0 @@
1
- const ensurePermission = node => async (req, res, next) => {
2
- if (req.user) {
3
- const rbac = await node.getRBAC();
4
- const can = rbac.canAny(
5
- req.user.role,
6
- ['mutate_blocklets', 'mutate_blocklet'].map(x => x.split('_'))
7
- );
8
- if (!can) {
9
- return res.status(403).json({ code: 'forbidden', error: 'no permission' });
10
- }
11
- } else {
12
- return res.status(403).json({ code: 'forbidden', error: 'not authorized' });
13
- }
14
-
15
- return next();
16
- };
17
-
18
- module.exports = ensurePermission;
@@ -1,28 +0,0 @@
1
- const { onAddNodeOwnerAuth, getProfileClaim, getAssetProfile } = require('./util');
2
-
3
- module.exports = function createRoutes(node) {
4
- return {
5
- action: 'accept-server',
6
- onConnect: () => {
7
- return {
8
- asset: getAssetProfile(node),
9
- profile: ({ extraParams: { locale } }) => getProfileClaim(locale),
10
- };
11
- },
12
-
13
- onAuth: async ({ claims, userDid, userPk, challenge, updateSession, extraParams: { locale }, req, baseUrl }) => {
14
- return onAddNodeOwnerAuth({
15
- action: 'accept-server',
16
- node,
17
- req,
18
- claims,
19
- userDid,
20
- userPk,
21
- challenge,
22
- locale,
23
- baseUrl,
24
- updateSession,
25
- });
26
- },
27
- };
28
- };
@@ -1,143 +0,0 @@
1
- const get = require('lodash/get');
2
- const path = require('path');
3
- const { ROLES, VC_TYPE_NODE_PASSPORT, NODE_DATA_DIR_NAME } = require('@abtnode/constant');
4
- const getNodeWallet = require('@abtnode/util/lib/get-app-wallet');
5
- const getRandomMessage = require('@abtnode/util/lib/get-random-message');
6
- const formatContext = require('@abtnode/util/lib/format-context');
7
- const { extractUserAvatar } = require('@abtnode/util/lib/user-avatar');
8
- const { createPassport, createPassportVC, createUserPassport } = require('@abtnode/auth/lib/passport');
9
-
10
- const createPassportSvg = require('@abtnode/auth/lib/util/create-passport-svg');
11
-
12
- const verifySignature = require('@abtnode/auth/lib/util/verify-signature');
13
- const { messages, checkWalletVersion, getPassportStatusEndpoint } = require('@abtnode/auth/lib/auth');
14
- const logger = require('@abtnode/logger')(require('../../../package.json').name);
15
-
16
- const { createSessionToken } = require('../../libs/login');
17
-
18
- module.exports = function createRoutes(node) {
19
- return {
20
- action: 'connect-owner',
21
- onConnect: () => {
22
- return {
23
- profile: async ({ extraParams: { locale } }) => {
24
- const info = await node.getNodeInfo();
25
-
26
- if (info.ownerNft && info.ownerNft.holder && info.ownerNft.issuer) {
27
- throw new Error(messages.requestOwnershipNft[locale]);
28
- }
29
-
30
- return {
31
- fields: ['fullName', 'email', 'avatar'],
32
- description: messages.requestProfile[locale],
33
- };
34
- },
35
-
36
- signature: async ({ extraParams: { locale }, context: { didwallet } }) => {
37
- checkWalletVersion({ didwallet, locale });
38
- const info = await node.getNodeInfo();
39
- const passport = await createPassport({
40
- name: ROLES.OWNER,
41
- node,
42
- teamDid: info.did,
43
- locale,
44
- });
45
- const issuerName = info.name;
46
-
47
- return {
48
- description: messages.receivePassport[locale],
49
- data: getRandomMessage(),
50
- type: 'mime:text/plain',
51
- display: JSON.stringify({
52
- type: 'svg',
53
- content: createPassportSvg({
54
- title: passport.title,
55
- issuer: issuerName,
56
- issuerDid: info.did,
57
- ownerName: 'Your Name',
58
- preferredColor: 'default',
59
- }),
60
- }),
61
- };
62
- },
63
- };
64
- },
65
-
66
- onAuth: async ({ claims, userDid, userPk, updateSession, extraParams: { locale }, req, baseUrl }) => {
67
- const profile = claims.find(x => x.type === 'profile');
68
- const info = await node.getNodeInfo();
69
- const teamDid = info.did;
70
-
71
- // Verify signature
72
- const claim = claims.find(x => x.type === 'signature');
73
- logger.info('claim.signature.onAuth', { userPk, userDid, claim });
74
- verifySignature(claim, userDid, userPk, locale);
75
-
76
- // Add owner
77
- await node.updateNodeOwner({ nodeOwner: { did: userDid, pk: userPk } });
78
- logger.info('connect owner to node', { userDid });
79
-
80
- // Issue owner passport
81
- const vc = createPassportVC({
82
- issuerName: info.name,
83
- issuerWallet: getNodeWallet(info.sk),
84
- ownerDid: userDid,
85
- passport: await createPassport({
86
- name: ROLES.OWNER,
87
- node,
88
- teamDid,
89
- locale,
90
- endpoint: baseUrl,
91
- }),
92
- endpoint: getPassportStatusEndpoint({
93
- baseUrl,
94
- userDid,
95
- teamDid,
96
- }),
97
- types: [VC_TYPE_NODE_PASSPORT],
98
- tag: info.did,
99
- ownerProfile: profile,
100
- });
101
-
102
- const role = ROLES.OWNER;
103
-
104
- const passport = createUserPassport(vc, { role });
105
-
106
- const doc = await node.addUser({
107
- teamDid,
108
- user: {
109
- ...profile,
110
- avatar: await extractUserAvatar(get(profile, 'avatar'), {
111
- dataDir: path.join(node.dataDirs.data, NODE_DATA_DIR_NAME),
112
- }),
113
- did: userDid,
114
- pk: userPk,
115
- passports: [passport],
116
- approved: true,
117
- locale,
118
- firstLoginAt: new Date().toISOString(),
119
- lastLoginAt: new Date().toISOString(),
120
- },
121
- });
122
- await node.createAuditLog(
123
- {
124
- action: 'addUser',
125
- args: { teamDid, userDid, reason: 'claim server' },
126
- context: formatContext(Object.assign(req, { user: doc })),
127
- result: doc,
128
- },
129
- node
130
- );
131
-
132
- // Generate new session token that client can save to localStorage
133
- const sessionToken = await createSessionToken(userDid, { passport, role });
134
- await updateSession({ sessionToken }, true);
135
-
136
- return {
137
- disposition: 'attachment',
138
- type: 'VerifiableCredential',
139
- data: vc,
140
- };
141
- },
142
- };
143
- };
@@ -1,86 +0,0 @@
1
- const { fromPublicKey } = require('@ocap/wallet');
2
- const Client = require('@ocap/client');
3
- const { toDelegateAddress } = require('@arcblock/did-util');
4
- const { toTypeInfo } = require('@arcblock/did');
5
- const formatContext = require('@abtnode/util/lib/format-context');
6
-
7
- const logger = require('@abtnode/logger')(require('../../../package.json').name);
8
-
9
- const messages = {
10
- selectNFTOwner: {
11
- en: 'Please select the owner of the NFT to proceed',
12
- zh: '请选择 NFT 所有者',
13
- },
14
- authorizeToServer: {
15
- en: 'Please authorize Blocklet Server to transfer owner NFT',
16
- zh: '请授权该节点交易 NFT',
17
- },
18
- };
19
-
20
- module.exports = function createRoutes(node) {
21
- return {
22
- action: 'delegate-transfer-nft',
23
- authPrincipal: false,
24
- claims: [
25
- {
26
- authPrincipal: async ({ extraParams: { locale } }) => {
27
- const info = await node.getNodeInfo();
28
-
29
- return {
30
- target: info.ownerNft.holder,
31
- description: messages.selectNFTOwner[locale],
32
- };
33
- },
34
- },
35
- {
36
- signature: async ({ userDid, userPk, extraParams: { locale } }) => {
37
- const info = await node.getNodeInfo();
38
-
39
- return {
40
- type: 'DelegateTx',
41
- chainInfo: { host: info.launcher.chainHost },
42
- data: {
43
- from: userDid,
44
- pk: userPk,
45
- itx: {
46
- address: toDelegateAddress(userDid, info.did),
47
- to: info.did,
48
- ops: [{ typeUrl: 'fg:t:transfer_v2', rules: [] }],
49
- },
50
- },
51
- description: messages.authorizeToServer[locale],
52
- };
53
- },
54
- },
55
- ],
56
- onAuth: async ({ userDid, userPk, claims, req }) => {
57
- const info = await node.getNodeInfo();
58
- const claim = claims.find(x => x.type === 'signature');
59
- const client = new Client(info.launcher.chainHost);
60
-
61
- logger.info('delegating.onAuth', { userDid, userPk, claims });
62
-
63
- const tx = client.decodeTx(claim.origin);
64
- const hash = await client.sendDelegateTx({
65
- tx,
66
- wallet: fromPublicKey(userPk, toTypeInfo(userDid)),
67
- signature: claim.sig,
68
- });
69
-
70
- logger.info('delegated.onAuth', { userDid, userPk, hash });
71
-
72
- const owner = await node.getOwner({ teamDid: info.did });
73
-
74
- await node.createAuditLog(
75
- {
76
- action: 'delegateTransferNFT',
77
- args: { owner: userDid, reason: 'delegate server to transfer nft' },
78
- context: formatContext(Object.assign(req, { user: owner })),
79
- },
80
- node
81
- );
82
-
83
- return { hash, tx: claim.origin };
84
- },
85
- };
86
- };
@@ -1,93 +0,0 @@
1
- const {
2
- createInvitationRequest,
3
- handleInvitationResponse,
4
- messages,
5
- checkWalletVersion,
6
- beforeInvitationRequest,
7
- } = require('@abtnode/auth/lib/auth');
8
- const { get } = require('lodash');
9
- const logger = require('@abtnode/logger')(require('../../../package.json').name);
10
-
11
- const { createSessionToken } = require('../../libs/login');
12
-
13
- module.exports = function createRoutes(node) {
14
- return {
15
- action: 'invite',
16
-
17
- onStart: async ({ extraParams }) => {
18
- const { locale = 'en', inviteId } = extraParams;
19
- const nodeInfo = await node.getNodeInfo();
20
- const teamDid = nodeInfo.did;
21
-
22
- await beforeInvitationRequest({ node, teamDid, locale, inviteId });
23
- },
24
-
25
- claims: {
26
- profile: async ({ userDid, extraParams }) => {
27
- const nodeInfo = await node.getNodeInfo();
28
- const { locale, inviteId } = extraParams;
29
-
30
- const tmpInvitation = await node.getInvitation({ teamDid: nodeInfo.did, inviteId });
31
-
32
- if (tmpInvitation.role === 'owner' && userDid === nodeInfo.nodeOwner.did) {
33
- throw new Error(messages.notAllowedTransferToSelf[locale]);
34
- }
35
-
36
- if ((await node.isInitialized()) === false) {
37
- throw new Error(messages.notInitialized[locale]);
38
- }
39
-
40
- return {
41
- fields: ['fullName', 'email', 'avatar'],
42
- description: messages.description[locale],
43
- };
44
- },
45
-
46
- signature: async ({ extraParams, context: { didwallet } }) => {
47
- const { locale, inviteId } = extraParams;
48
- checkWalletVersion({ didwallet, locale });
49
- const nodeInfo = await node.getNodeInfo();
50
- const teamDid = nodeInfo.did;
51
-
52
- return createInvitationRequest({
53
- node,
54
- nodeInfo,
55
- teamDid,
56
- inviteId,
57
- locale,
58
- });
59
- },
60
- },
61
-
62
- onAuth: async ({ claims, userDid, userPk, updateSession, extraParams, req, baseUrl }) => {
63
- const { locale, inviteId, previousWorkflowData } = extraParams;
64
- const nodeInfo = await node.getNodeInfo();
65
- const teamDid = nodeInfo.did;
66
- const statusEndpointBaseUrl = baseUrl;
67
- const endpoint = baseUrl;
68
-
69
- const { passport, response, role } = await handleInvitationResponse({
70
- req,
71
- node,
72
- nodeInfo,
73
- teamDid,
74
- userDid,
75
- userPk,
76
- inviteId,
77
- locale,
78
- claims,
79
- statusEndpointBaseUrl,
80
- endpoint,
81
- newNftOwner: get(previousWorkflowData, 'userDid'),
82
- });
83
-
84
- // Generate new session token that client can save to localStorage
85
- const sessionToken = await createSessionToken(userDid, { passport, role });
86
- await updateSession({ sessionToken }, true);
87
- await updateSession({ passportId: response.data.id });
88
- logger.info('invite.success', { userDid });
89
-
90
- return response;
91
- },
92
- };
93
- };
@@ -1,61 +0,0 @@
1
- const {
2
- createIssuePassportRequest,
3
- handleIssuePassportResponse,
4
- checkWalletVersion,
5
- beforeIssuePassportRequest,
6
- } = require('@abtnode/auth/lib/auth');
7
-
8
- module.exports = function createRoutes(node) {
9
- return {
10
- action: 'issue-passport',
11
-
12
- onStart: async ({ extraParams }) => {
13
- const { locale = 'en', id } = extraParams;
14
-
15
- const nodeInfo = await node.getNodeInfo();
16
- const teamDid = nodeInfo.did;
17
-
18
- await beforeIssuePassportRequest({ node, teamDid, locale, id });
19
- },
20
-
21
- claims: {
22
- signature: async ({ extraParams, context: { didwallet } }) => {
23
- const { id, locale } = extraParams;
24
- checkWalletVersion({ didwallet, locale });
25
- const nodeInfo = await node.getNodeInfo();
26
- const teamDid = nodeInfo.did;
27
-
28
- return createIssuePassportRequest({
29
- node,
30
- nodeInfo,
31
- teamDid,
32
- id,
33
- locale,
34
- });
35
- },
36
- },
37
-
38
- onAuth: async ({ userDid, userPk, claims, extraParams, updateSession, req, baseUrl }) => {
39
- const { locale, id } = extraParams;
40
- const nodeInfo = await node.getNodeInfo();
41
- const teamDid = nodeInfo.did;
42
- const statusEndpointBaseUrl = baseUrl;
43
- const endpoint = baseUrl;
44
-
45
- return handleIssuePassportResponse({
46
- req,
47
- node,
48
- nodeInfo,
49
- teamDid,
50
- userDid,
51
- userPk,
52
- id,
53
- locale,
54
- claims,
55
- statusEndpointBaseUrl,
56
- updateSession,
57
- endpoint,
58
- });
59
- },
60
- };
61
- };
@@ -1,9 +0,0 @@
1
- const { createLaunchBlockletHandler, getLaunchBlockletClaims } = require('@abtnode/auth/lib/server');
2
-
3
- module.exports = function createRoutes(node) {
4
- return {
5
- action: 'launch-free-blocklet-by-nft',
6
- claims: getLaunchBlockletClaims(node, 'nft'),
7
- onAuth: createLaunchBlockletHandler(node, 'nft'),
8
- };
9
- };
@@ -1,9 +0,0 @@
1
- const { createLaunchBlockletHandler, getLaunchBlockletClaims } = require('@abtnode/auth/lib/server');
2
-
3
- module.exports = function createRoutes(node) {
4
- return {
5
- action: 'launch-free-blocklet-by-vc',
6
- claims: getLaunchBlockletClaims(node, 'vc'),
7
- onAuth: createLaunchBlockletHandler(node, 'vc'),
8
- };
9
- };
@@ -1,9 +0,0 @@
1
- const { createLaunchBlockletHandler, getLaunchBlockletClaims } = require('@abtnode/auth/lib/server');
2
-
3
- module.exports = function createRoutes(node) {
4
- return {
5
- action: 'launch-paid-blocklet-by-nft',
6
- claims: getLaunchBlockletClaims(node, 'nft'),
7
- onAuth: createLaunchBlockletHandler(node, 'nft'),
8
- };
9
- };
@@ -1,9 +0,0 @@
1
- const { createLaunchBlockletHandler, getLaunchBlockletClaims } = require('@abtnode/auth/lib/server');
2
-
3
- module.exports = function createRoutes(node) {
4
- return {
5
- action: 'launch-paid-blocklet-by-vc',
6
- claims: getLaunchBlockletClaims(node, 'vc'),
7
- onAuth: createLaunchBlockletHandler(node, 'vc'),
8
- };
9
- };
@@ -1,63 +0,0 @@
1
- const { messages } = require('@abtnode/auth/lib/auth');
2
- const { authenticateByVc, getAuthVcClaim } = require('@abtnode/auth/lib/server');
3
- const formatContext = require('@abtnode/util/lib/format-context');
4
-
5
- const logger = require('@abtnode/logger')(require('../../../package.json').name);
6
-
7
- const { createSessionToken } = require('../../libs/login');
8
-
9
- module.exports = function createRoutes(node) {
10
- return {
11
- action: 'login',
12
- onConnect: async ({ userDid, extraParams }) => {
13
- const { locale } = extraParams;
14
-
15
- if ((await node.isInitialized()) === false) {
16
- throw new Error(messages.notInitialized[locale]);
17
- }
18
-
19
- const info = await node.getNodeInfo();
20
- const user = await node.getUser({ teamDid: info.did, user: { did: userDid } });
21
- if (!user) {
22
- throw new Error(messages.notAllowed[locale]);
23
- }
24
-
25
- return { verifiableCredential: getAuthVcClaim({ node }) };
26
- },
27
-
28
- onAuth: async ({ claims, challenge, userDid, userPk, updateSession, extraParams, req }) => {
29
- const { locale } = extraParams;
30
- const { role, teamDid, passport } = await authenticateByVc({ node, locale, userDid, claims, challenge });
31
-
32
- try {
33
- // Update user
34
- const doc = await node.updateUser({
35
- teamDid,
36
- user: {
37
- did: userDid,
38
- pk: userPk,
39
- locale,
40
- lastLoginAt: new Date().toISOString(),
41
- },
42
- });
43
- await node.createAuditLog(
44
- {
45
- action: 'login',
46
- args: { teamDid, userDid, passport },
47
- context: formatContext(Object.assign(req, { user: doc })),
48
- result: doc,
49
- },
50
- node
51
- );
52
-
53
- // Generate new session token that client can save to localStorage
54
- const sessionToken = await createSessionToken(userDid, { passport, role });
55
- await updateSession({ sessionToken }, true);
56
- logger.info('login.success', { userDid });
57
- } catch (err) {
58
- logger.error('login.error', { error: err, userDid });
59
- throw new Error(err.message);
60
- }
61
- },
62
- };
63
- };
@@ -1,5 +0,0 @@
1
- const { createLostPassportIssueRoute, TEAM_TYPES } = require('@abtnode/auth/lib/lost-passport');
2
-
3
- module.exports = function createRoutes(node) {
4
- return createLostPassportIssueRoute({ node, type: TEAM_TYPES.NODE });
5
- };
@@ -1,5 +0,0 @@
1
- const { createLostPassportListRoute } = require('@abtnode/auth/lib/lost-passport');
2
-
3
- module.exports = function createRoutes(node) {
4
- return createLostPassportListRoute({ node, type: 'node' });
5
- };
@@ -1,47 +0,0 @@
1
- const { messages } = require('@abtnode/auth/lib/auth');
2
- const { getAuthVcClaim, authenticateByVc } = require('@abtnode/auth/lib/server');
3
- const formatContext = require('@abtnode/util/lib/format-context');
4
-
5
- const { createSessionToken } = require('../../libs/login');
6
-
7
- module.exports = function createRoutes(node) {
8
- return {
9
- action: 'switch-passport',
10
- onConnect: async ({ userDid, extraParams: { locale, connectedDid } }) => {
11
- if (userDid && connectedDid && userDid !== connectedDid) {
12
- throw new Error(messages.userMismatch[locale]);
13
- }
14
-
15
- const info = await node.getNodeInfo();
16
- const user = await node.getUser({ teamDid: info.did, user: { did: userDid } });
17
- if (!user) {
18
- throw new Error(messages.notAllowed[locale]);
19
- }
20
- if (!user.approved) {
21
- throw new Error(messages.notAuthorized[locale]);
22
- }
23
-
24
- return { verifiableCredential: getAuthVcClaim({ node }) };
25
- },
26
-
27
- onAuth: async ({ claims, challenge, userDid, updateSession, extraParams, req }) => {
28
- const { locale } = extraParams;
29
- const { role, passport } = await authenticateByVc({ node, locale, userDid, claims, challenge });
30
- const info = await node.getNodeInfo();
31
- const user = await node.getUser({ teamDid: info.did, user: { did: userDid } });
32
- await node.createAuditLog(
33
- {
34
- action: 'switchPassport',
35
- args: { teamDid: info.did, userDid, passport },
36
- context: formatContext(Object.assign(req, { user })),
37
- result: {},
38
- },
39
- node
40
- );
41
-
42
- // Generate new session token that client can save to localStorage
43
- const sessionToken = await createSessionToken(userDid, { passport, role });
44
- await updateSession({ sessionToken }, true);
45
- },
46
- };
47
- };