@blocklet/sdk 1.16.8-beta-ca58a421 → 1.16.8-beta-81db8efa
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/service/auth.d.ts +4 -1
- package/lib/service/auth.js +10 -2
- package/lib/types/email.d.ts +7 -0
- package/lib/types/email.js +3 -0
- package/lib/validators/email.d.ts +3 -0
- package/lib/validators/email.js +17 -0
- package/package.json +8 -7
package/lib/service/auth.d.ts
CHANGED
|
@@ -7,7 +7,10 @@ declare class AuthService {
|
|
|
7
7
|
constructor(httpEndpoint?: string);
|
|
8
8
|
}
|
|
9
9
|
interface AuthService {
|
|
10
|
-
login: (params: object) => Promise<
|
|
10
|
+
login: (params: object) => Promise<{
|
|
11
|
+
user: Object;
|
|
12
|
+
token: string;
|
|
13
|
+
}>;
|
|
11
14
|
getUser(did: string, options?: {
|
|
12
15
|
enableConnectedAccount?: boolean;
|
|
13
16
|
enableNormalize?: boolean;
|
package/lib/service/auth.js
CHANGED
|
@@ -7,8 +7,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
const pickBy_1 = __importDefault(require("lodash/pickBy"));
|
|
8
8
|
const url_join_1 = __importDefault(require("url-join"));
|
|
9
9
|
const client_1 = __importDefault(require("@abtnode/client"));
|
|
10
|
+
const semver_1 = __importDefault(require("semver"));
|
|
10
11
|
const mcrypto_1 = require("@ocap/mcrypto");
|
|
11
12
|
const wallet_1 = require("@ocap/wallet");
|
|
13
|
+
const env_1 = require("@blocklet/env");
|
|
12
14
|
const constant_1 = __importDefault(require("@abtnode/constant"));
|
|
13
15
|
const check_blocklet_env_1 = __importDefault(require("../util/check-blocklet-env"));
|
|
14
16
|
const version_1 = require("../version");
|
|
@@ -29,15 +31,18 @@ const fixAvatar = (user) => {
|
|
|
29
31
|
}
|
|
30
32
|
return user;
|
|
31
33
|
};
|
|
34
|
+
const toBuffer = (str) => (str.startsWith('0x') ? Buffer.from(str.slice(2), 'hex') : str);
|
|
32
35
|
class AuthClient extends client_1.default {
|
|
33
36
|
constructor(httpEndpoint) {
|
|
34
37
|
(0, check_blocklet_env_1.default)();
|
|
35
38
|
super(httpEndpoint || `http://127.0.0.1:${process.env.ABT_NODE_PORT}/api/gql`.trim(), `BlockletSDK/${VERSION}`);
|
|
36
39
|
const wallet = (0, wallet_2.default)();
|
|
40
|
+
const useNewSigner = !env_1.serverVersion || semver_1.default.gte(env_1.serverVersion, '1.16.7');
|
|
37
41
|
this.setAuthAccessKey({
|
|
38
42
|
accessKeyId: wallet.address,
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
// for backward compatibility
|
|
44
|
+
accessKeySecret: useNewSigner ? toBuffer(wallet.secretKey) : wallet.secretKey,
|
|
45
|
+
type: useNewSigner ? 'sha256' : type,
|
|
41
46
|
});
|
|
42
47
|
}
|
|
43
48
|
_getAuthHeaders() {
|
|
@@ -131,6 +136,9 @@ class AuthService {
|
|
|
131
136
|
this.login = async (data) => {
|
|
132
137
|
try {
|
|
133
138
|
const { data: resData } = await service_api_1.default.post('/user/login', data);
|
|
139
|
+
if (resData?.user) {
|
|
140
|
+
fixAvatar(resData.user);
|
|
141
|
+
}
|
|
134
142
|
return resData;
|
|
135
143
|
}
|
|
136
144
|
catch (err) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.emailConfigSchema = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const emailConfigSchema = joi_1.default.object({
|
|
9
|
+
from: joi_1.default.string().email().required(),
|
|
10
|
+
host: joi_1.default.string().hostname().required(),
|
|
11
|
+
port: joi_1.default.number().port().required(),
|
|
12
|
+
user: joi_1.default.string().required(),
|
|
13
|
+
password: joi_1.default.string().required(),
|
|
14
|
+
})
|
|
15
|
+
.empty(null)
|
|
16
|
+
.meta({ className: 'TEmailConfigSchema' });
|
|
17
|
+
exports.emailConfigSchema = emailConfigSchema;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.8-beta-
|
|
6
|
+
"version": "1.16.8-beta-81db8efa",
|
|
7
7
|
"description": "graphql client to read/write data on abt node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"typings": "lib/index.d.ts",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@abtnode/client": "1.16.8-beta-
|
|
30
|
-
"@abtnode/constant": "1.16.8-beta-
|
|
29
|
+
"@abtnode/client": "1.16.8-beta-81db8efa",
|
|
30
|
+
"@abtnode/constant": "1.16.8-beta-81db8efa",
|
|
31
31
|
"@arcblock/did": "1.18.78",
|
|
32
32
|
"@arcblock/did-auth": "1.18.78",
|
|
33
33
|
"@arcblock/jwt": "1.18.78",
|
|
34
34
|
"@arcblock/ws": "1.18.78",
|
|
35
|
-
"@blocklet/constant": "1.16.8-beta-
|
|
36
|
-
"@blocklet/env": "1.16.8-beta-
|
|
37
|
-
"@blocklet/meta": "1.16.8-beta-
|
|
35
|
+
"@blocklet/constant": "1.16.8-beta-81db8efa",
|
|
36
|
+
"@blocklet/env": "1.16.8-beta-81db8efa",
|
|
37
|
+
"@blocklet/meta": "1.16.8-beta-81db8efa",
|
|
38
38
|
"@did-connect/authenticator": "^2.1.54",
|
|
39
39
|
"@did-connect/handler": "^2.1.54",
|
|
40
40
|
"@nedb/core": "^2.1.5",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"json-stable-stringify": "^1.0.1",
|
|
48
48
|
"lodash": "^4.17.21",
|
|
49
49
|
"lru-cache": "^6.0.0",
|
|
50
|
+
"semver": "^7.3.8",
|
|
50
51
|
"ufo": "^1.1.1",
|
|
51
52
|
"url-join": "^4.0.1"
|
|
52
53
|
},
|
|
@@ -72,5 +73,5 @@
|
|
|
72
73
|
"ts-node": "^10.9.1",
|
|
73
74
|
"typescript": "^4.8.4"
|
|
74
75
|
},
|
|
75
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "8c4e3190de79a1fb2aaa14646255d938324cc5c2"
|
|
76
77
|
}
|