@abtnode/connect-storage 1.16.19-beta-e6aac665 → 1.16.19-beta-710018ca
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/README.md +17 -1
- package/lib/index.js +8 -11
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Connect Storage
|
|
2
2
|
|
|
3
|
-
Simple
|
|
3
|
+
Simple did connect storage that can be used cross multiple processes.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -11,4 +11,20 @@ yarn add @abtnode/connect-storage
|
|
|
11
11
|
Then:
|
|
12
12
|
|
|
13
13
|
```javascript
|
|
14
|
+
import { join } from 'path';
|
|
15
|
+
|
|
16
|
+
import AuthStorage from '@abtnode/connect-storage';
|
|
17
|
+
import WalletAuthenticator from '@blocklet/sdk/lib/wallet-authenticator';
|
|
18
|
+
import WalletHandler from '@blocklet/sdk/lib/wallet-handler';
|
|
19
|
+
import Config from '@blocklet/sdk/lib/config';
|
|
20
|
+
|
|
21
|
+
export const authenticator = new WalletAuthenticator();
|
|
22
|
+
export const handlers = new WalletHandler({
|
|
23
|
+
authenticator,
|
|
24
|
+
tokenStorage: new AuthStorage({
|
|
25
|
+
// FIXME: update this
|
|
26
|
+
dbPath: join(Config.env.dataDir, 'path/to/component.db'),
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
|
|
14
30
|
```
|
package/lib/index.js
CHANGED
|
@@ -8,22 +8,19 @@ class SequelizeStorage extends EventEmitter {
|
|
|
8
8
|
if (!options.dbPath) {
|
|
9
9
|
throw new Error('SequelizeStorage requires dbPath to be set');
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!options.primaryKey) {
|
|
15
|
-
throw new Error('SequelizeStorage requires primaryKey to be set');
|
|
16
|
-
}
|
|
11
|
+
|
|
12
|
+
const model = options.v2 ? 'ConnectionV2' : 'Connection';
|
|
13
|
+
const primaryKey = options.v2 ? 'sessionId' : 'token';
|
|
17
14
|
|
|
18
15
|
super(options);
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const sequelize = createSequelize(options.dbPath);
|
|
18
|
+
const models = getConnectModels();
|
|
22
19
|
|
|
23
|
-
setupModels(
|
|
20
|
+
setupModels(models, sequelize);
|
|
24
21
|
|
|
25
|
-
this.state = new ConnectionState(
|
|
26
|
-
this.primaryKey =
|
|
22
|
+
this.state = new ConnectionState(models[model], { ...options, primaryKey });
|
|
23
|
+
this.primaryKey = primaryKey;
|
|
27
24
|
|
|
28
25
|
doSchemaMigration(options.dbPath, 'connect')
|
|
29
26
|
.then(() => {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.19-beta-
|
|
6
|
+
"version": "1.16.19-beta-710018ca",
|
|
7
7
|
"description": "Sequelize storage for @arcblock/did-auth",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/models": "1.16.19-beta-
|
|
22
|
+
"@abtnode/models": "1.16.19-beta-710018ca",
|
|
23
23
|
"lodash": "^4.17.21"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"jest": "^27.5.1"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "23518dd7a84664e2a015284d5867cc31540fbdb0"
|
|
29
29
|
}
|