create-blocklet 0.2.11 → 0.2.12
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/package.json +2 -2
- package/template-dapp/react/blocklet.yml +0 -5
- package/template-dapp/react/server/hooks/pre-start.js +3 -4
- package/template-dapp/react/server/libs/auth.js +4 -8
- package/template-dapp/react/server/libs/env.js +2 -8
- package/template-dapp/react/server/routes/index.js +2 -0
- package/template-dapp/vue/blocklet.yml +0 -5
- package/template-dapp/vue/server/hooks/pre-start.js +3 -4
- package/template-dapp/vue/server/libs/auth.js +4 -8
- package/template-dapp/vue/server/libs/env.js +2 -8
- package/template-dapp/vue/server/routes/index.js +2 -0
- package/template-dapp/vue2/blocklet.yml +0 -5
- package/template-dapp/vue2/server/hooks/pre-start.js +3 -4
- package/template-dapp/vue2/server/libs/auth.js +4 -8
- package/template-dapp/vue2/server/libs/env.js +2 -8
- package/template-dapp/vue2/server/routes/index.js +2 -0
- package/template-dapp/react/server/middlewares/user.js +0 -10
- package/template-dapp/vue/server/middlewares/user.js +0 -10
- package/template-dapp/vue2/server/middlewares/user.js +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-blocklet",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"exports": "./index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "git@github.com:blocklet/create-blocklet.git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"prompts": "^2.4.1",
|
|
41
41
|
"rc": "^1.2.8",
|
|
42
42
|
"semver": "^7.3.5",
|
|
43
|
-
"shelljs": "^0.8.
|
|
43
|
+
"shelljs": "^0.8.5",
|
|
44
44
|
"terminal-link": "^3.0.0",
|
|
45
45
|
"yaml": "^1.10.2"
|
|
46
46
|
},
|
|
@@ -48,11 +48,6 @@ scripts:
|
|
|
48
48
|
preStart: node server/hooks/pre-start.js
|
|
49
49
|
dev: npm run start
|
|
50
50
|
environments:
|
|
51
|
-
- name: CHAIN_ID
|
|
52
|
-
description: What's endpoint of the chain id?
|
|
53
|
-
required: true
|
|
54
|
-
default: 'beta'
|
|
55
|
-
secure: false
|
|
56
51
|
- name: CHAIN_HOST
|
|
57
52
|
description: What's endpoint of the chain?
|
|
58
53
|
required: true
|
|
@@ -4,16 +4,15 @@ require('dotenv-flow').config();
|
|
|
4
4
|
const Client = require('@ocap/client');
|
|
5
5
|
|
|
6
6
|
const env = require('../libs/env');
|
|
7
|
-
const { wallet } = require('../libs/auth');
|
|
8
7
|
const logger = require('../libs/logger');
|
|
8
|
+
const { wallet } = require('../libs/auth');
|
|
9
9
|
const { name } = require('../../package.json');
|
|
10
10
|
|
|
11
|
-
const client = new Client(env.chainHost);
|
|
12
|
-
|
|
13
11
|
const ensureAccountDeclared = async () => {
|
|
14
|
-
// Check for application account, skip this if we are running as a child component
|
|
15
12
|
if (env.isComponent) return;
|
|
13
|
+
if (!env.chainHost) return;
|
|
16
14
|
|
|
15
|
+
const client = new Client(env.chainHost);
|
|
17
16
|
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
18
17
|
if (!state) {
|
|
19
18
|
const hash = await client.declare({ moniker: name, wallet });
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
3
4
|
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
4
|
-
const
|
|
5
|
-
const { types } = require('@ocap/mcrypto');
|
|
6
|
-
const { fromSecretKey, WalletType } = require('@ocap/wallet');
|
|
5
|
+
const WalletHandler = require('@blocklet/sdk/lib/wallet-handler');
|
|
7
6
|
const logger = require('./logger');
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
const wallet = fromSecretKey(appSk, WalletType({ role: types.RoleType.ROLE_APPLICATION }));
|
|
11
|
-
|
|
8
|
+
const wallet = getWallet();
|
|
12
9
|
const authenticator = new WalletAuthenticator();
|
|
13
|
-
|
|
14
|
-
const handlers = new WalletHandlers({
|
|
10
|
+
const handlers = new WalletHandler({
|
|
15
11
|
authenticator,
|
|
16
12
|
tokenGenerator: () => Date.now().toString(),
|
|
17
13
|
tokenStorage: new AuthStorage({
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const blockletDid = process.env.BLOCKLET_DID || '';
|
|
3
|
-
const isComponent = blockletRealDid && blockletDid && blockletRealDid !== blockletDid;
|
|
1
|
+
const env = require('@blocklet/sdk/lib/env');
|
|
4
2
|
|
|
5
3
|
module.exports = {
|
|
6
|
-
|
|
4
|
+
...env,
|
|
7
5
|
chainHost: process.env.CHAIN_HOST || '',
|
|
8
|
-
appId: process.env.BLOCKLET_APP_ID || '',
|
|
9
|
-
appName: process.env.APP_NAME || process.env.BLOCKLET_APP_NAME || '',
|
|
10
|
-
appDescription: process.env.APP_DESCRIPTION || process.env.BLOCKLET_APP_DESCRIPTION || '',
|
|
11
|
-
isComponent,
|
|
12
6
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const middleware = require('@blocklet/sdk/lib/middlewares');
|
|
1
2
|
const router = require('express').Router();
|
|
2
3
|
const env = require('../libs/env');
|
|
3
4
|
|
|
4
5
|
router.use('/env', (req, res) => res.json(env));
|
|
6
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user));
|
|
5
7
|
|
|
6
8
|
module.exports = router;
|
|
@@ -47,11 +47,6 @@ scripts:
|
|
|
47
47
|
preStart: node server/hooks/pre-start.js
|
|
48
48
|
dev: npm run start
|
|
49
49
|
environments:
|
|
50
|
-
- name: CHAIN_ID
|
|
51
|
-
description: What's endpoint of the chain id?
|
|
52
|
-
required: true
|
|
53
|
-
default: 'beta'
|
|
54
|
-
secure: false
|
|
55
50
|
- name: CHAIN_HOST
|
|
56
51
|
description: What's endpoint of the chain?
|
|
57
52
|
required: true
|
|
@@ -4,16 +4,15 @@ require('dotenv-flow').config();
|
|
|
4
4
|
const Client = require('@ocap/client');
|
|
5
5
|
|
|
6
6
|
const env = require('../libs/env');
|
|
7
|
-
const { wallet } = require('../libs/auth');
|
|
8
7
|
const logger = require('../libs/logger');
|
|
8
|
+
const { wallet } = require('../libs/auth');
|
|
9
9
|
const { name } = require('../../package.json');
|
|
10
10
|
|
|
11
|
-
const client = new Client(env.chainHost);
|
|
12
|
-
|
|
13
11
|
const ensureAccountDeclared = async () => {
|
|
14
|
-
// Check for application account, skip this if we are running as a child component
|
|
15
12
|
if (env.isComponent) return;
|
|
13
|
+
if (!env.chainHost) return;
|
|
16
14
|
|
|
15
|
+
const client = new Client(env.chainHost);
|
|
17
16
|
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
18
17
|
if (!state) {
|
|
19
18
|
const hash = await client.declare({ moniker: name, wallet });
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
3
4
|
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
4
|
-
const
|
|
5
|
-
const { types } = require('@ocap/mcrypto');
|
|
6
|
-
const { fromSecretKey, WalletType } = require('@ocap/wallet');
|
|
5
|
+
const WalletHandler = require('@blocklet/sdk/lib/wallet-handler');
|
|
7
6
|
const logger = require('./logger');
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
const wallet = fromSecretKey(appSk, WalletType({ role: types.RoleType.ROLE_APPLICATION }));
|
|
11
|
-
|
|
8
|
+
const wallet = getWallet();
|
|
12
9
|
const authenticator = new WalletAuthenticator();
|
|
13
|
-
|
|
14
|
-
const handlers = new WalletHandlers({
|
|
10
|
+
const handlers = new WalletHandler({
|
|
15
11
|
authenticator,
|
|
16
12
|
tokenGenerator: () => Date.now().toString(),
|
|
17
13
|
tokenStorage: new AuthStorage({
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const blockletDid = process.env.BLOCKLET_DID || '';
|
|
3
|
-
const isComponent = blockletRealDid && blockletDid && blockletRealDid !== blockletDid;
|
|
1
|
+
const env = require('@blocklet/sdk/lib/env');
|
|
4
2
|
|
|
5
3
|
module.exports = {
|
|
6
|
-
|
|
4
|
+
...env,
|
|
7
5
|
chainHost: process.env.CHAIN_HOST || '',
|
|
8
|
-
appId: process.env.BLOCKLET_APP_ID || '',
|
|
9
|
-
appName: process.env.APP_NAME || process.env.BLOCKLET_APP_NAME || '',
|
|
10
|
-
appDescription: process.env.APP_DESCRIPTION || process.env.BLOCKLET_APP_DESCRIPTION || '',
|
|
11
|
-
isComponent,
|
|
12
6
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const middleware = require('@blocklet/sdk/lib/middlewares');
|
|
1
2
|
const router = require('express').Router();
|
|
2
3
|
const env = require('../libs/env');
|
|
3
4
|
|
|
4
5
|
router.use('/env', (req, res) => res.json(env));
|
|
6
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user));
|
|
5
7
|
|
|
6
8
|
module.exports = router;
|
|
@@ -45,11 +45,6 @@ requirements:
|
|
|
45
45
|
scripts:
|
|
46
46
|
dev: npm run start
|
|
47
47
|
environments:
|
|
48
|
-
- name: CHAIN_ID
|
|
49
|
-
description: What's endpoint of the chain id?
|
|
50
|
-
required: true
|
|
51
|
-
default: 'beta'
|
|
52
|
-
secure: false
|
|
53
48
|
- name: CHAIN_HOST
|
|
54
49
|
description: What's endpoint of the chain?
|
|
55
50
|
required: true
|
|
@@ -4,16 +4,15 @@ require('dotenv-flow').config();
|
|
|
4
4
|
const Client = require('@ocap/client');
|
|
5
5
|
|
|
6
6
|
const env = require('../libs/env');
|
|
7
|
-
const { wallet } = require('../libs/auth');
|
|
8
7
|
const logger = require('../libs/logger');
|
|
8
|
+
const { wallet } = require('../libs/auth');
|
|
9
9
|
const { name } = require('../../package.json');
|
|
10
10
|
|
|
11
|
-
const client = new Client(env.chainHost);
|
|
12
|
-
|
|
13
11
|
const ensureAccountDeclared = async () => {
|
|
14
|
-
// Check for application account, skip this if we are running as a child component
|
|
15
12
|
if (env.isComponent) return;
|
|
13
|
+
if (!env.chainHost) return;
|
|
16
14
|
|
|
15
|
+
const client = new Client(env.chainHost);
|
|
17
16
|
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
18
17
|
if (!state) {
|
|
19
18
|
const hash = await client.declare({ moniker: name, wallet });
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
3
4
|
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
4
|
-
const
|
|
5
|
-
const { types } = require('@ocap/mcrypto');
|
|
6
|
-
const { fromSecretKey, WalletType } = require('@ocap/wallet');
|
|
5
|
+
const WalletHandler = require('@blocklet/sdk/lib/wallet-handler');
|
|
7
6
|
const logger = require('./logger');
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
const wallet = fromSecretKey(appSk, WalletType({ role: types.RoleType.ROLE_APPLICATION }));
|
|
11
|
-
|
|
8
|
+
const wallet = getWallet();
|
|
12
9
|
const authenticator = new WalletAuthenticator();
|
|
13
|
-
|
|
14
|
-
const handlers = new WalletHandlers({
|
|
10
|
+
const handlers = new WalletHandler({
|
|
15
11
|
authenticator,
|
|
16
12
|
tokenGenerator: () => Date.now().toString(),
|
|
17
13
|
tokenStorage: new AuthStorage({
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const blockletDid = process.env.BLOCKLET_DID || '';
|
|
3
|
-
const isComponent = blockletRealDid && blockletDid && blockletRealDid !== blockletDid;
|
|
1
|
+
const env = require('@blocklet/sdk/lib/env');
|
|
4
2
|
|
|
5
3
|
module.exports = {
|
|
6
|
-
|
|
4
|
+
...env,
|
|
7
5
|
chainHost: process.env.CHAIN_HOST || '',
|
|
8
|
-
appId: process.env.BLOCKLET_APP_ID || '',
|
|
9
|
-
appName: process.env.APP_NAME || process.env.BLOCKLET_APP_NAME || '',
|
|
10
|
-
appDescription: process.env.APP_DESCRIPTION || process.env.BLOCKLET_APP_DESCRIPTION || '',
|
|
11
|
-
isComponent,
|
|
12
6
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const middleware = require('@blocklet/sdk/lib/middlewares');
|
|
1
2
|
const router = require('express').Router();
|
|
2
3
|
const env = require('../libs/env');
|
|
3
4
|
|
|
4
5
|
router.use('/env', (req, res) => res.json(env));
|
|
6
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user));
|
|
5
7
|
|
|
6
8
|
module.exports = router;
|