@meowinc/meow-sdk 0.1.5 → 0.2.0
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/.prettierrc +4 -4
- package/dist/account/auth/add-email.d.ts +6 -0
- package/dist/account/auth/add-email.js +12 -0
- package/dist/account/auth/index.d.ts +2 -0
- package/dist/account/auth/index.js +8 -0
- package/dist/account/auth/submit-add-email.d.ts +3 -0
- package/dist/account/auth/submit-add-email.js +13 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -10
- package/dist/mail/email/deleteEmailById.d.ts +3 -0
- package/dist/mail/email/deleteEmailById.js +11 -0
- package/dist/mail/email/getEmailById.d.ts +6 -0
- package/dist/mail/email/getEmailById.js +11 -0
- package/dist/mail/email/sendMessage.d.ts +3 -0
- package/dist/mail/email/sendMessage.js +16 -0
- package/dist/mail/email/setReadStatus.d.ts +3 -0
- package/dist/mail/email/setReadStatus.js +12 -0
- package/package.json +32 -32
- package/tsconfig.json +19 -19
- package/dist/utils.d.ts +0 -3
- package/dist/utils.js +0 -5
package/.prettierrc
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tabWidth": 4,
|
|
3
|
-
"printWidth": 120,
|
|
4
|
-
"endOfLine": "lf"
|
|
1
|
+
{
|
|
2
|
+
"tabWidth": 4,
|
|
3
|
+
"printWidth": 120,
|
|
4
|
+
"endOfLine": "lf"
|
|
5
5
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuthorizationProvider } from "../..";
|
|
2
|
+
import { MeowResult } from "../../types";
|
|
3
|
+
export interface Response {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function request(mailbox: string, authorizationProvider: AuthorizationProvider): Promise<MeowResult<Response>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ErrorToMessage } from "../../error";
|
|
2
|
+
import { HttpClient } from "../../http-client";
|
|
3
|
+
export async function request(mailbox, authorizationProvider) {
|
|
4
|
+
return await new HttpClient()
|
|
5
|
+
.withAuthorization(authorizationProvider)
|
|
6
|
+
.withMethodPost()
|
|
7
|
+
.withJsonBody({
|
|
8
|
+
mailbox,
|
|
9
|
+
})
|
|
10
|
+
.send()
|
|
11
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
12
|
+
}
|
|
@@ -6,4 +6,6 @@ export declare class AuthRequests {
|
|
|
6
6
|
baseLogIn(login: string, password: string): Promise<import("../../types").MeowResult<import("./log-in").Response>>;
|
|
7
7
|
twoFactorLogIn(code: string, requestId: string): Promise<import("../../types").MeowResult<import("./log-in").Response>>;
|
|
8
8
|
signIn(login: string, password: string, verificationType: VerificationType): Promise<import("../../types").MeowResult<void>>;
|
|
9
|
+
addTwoFactorEmail(email: string): Promise<import("../../types").MeowResult<import("./add-email").Response>>;
|
|
10
|
+
submitTwoFactorEmail(sessionId: string, code: string): Promise<import("../../types").MeowResult<void>>;
|
|
9
11
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { request as signIn } from "./sign-in";
|
|
2
2
|
import { request as logIn } from "./log-in";
|
|
3
|
+
import { request as addEmail } from "./add-email";
|
|
4
|
+
import { request as submitAddEmail } from "./submit-add-email";
|
|
3
5
|
export class AuthRequests {
|
|
4
6
|
authProvider;
|
|
5
7
|
constructor(authProvider) {
|
|
@@ -26,4 +28,10 @@ export class AuthRequests {
|
|
|
26
28
|
verificationType,
|
|
27
29
|
});
|
|
28
30
|
}
|
|
31
|
+
async addTwoFactorEmail(email) {
|
|
32
|
+
return await addEmail(email, this.authProvider);
|
|
33
|
+
}
|
|
34
|
+
async submitTwoFactorEmail(sessionId, code) {
|
|
35
|
+
return await submitAddEmail(sessionId, code, this.authProvider);
|
|
36
|
+
}
|
|
29
37
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ErrorToMessage } from "../../error";
|
|
2
|
+
import { HttpClient } from "../../http-client";
|
|
3
|
+
export async function request(sessionId, code, authorizationProvider) {
|
|
4
|
+
return await new HttpClient()
|
|
5
|
+
.withMethodPost()
|
|
6
|
+
.withAuthorization(authorizationProvider)
|
|
7
|
+
.withJsonBody({
|
|
8
|
+
sessionId,
|
|
9
|
+
code,
|
|
10
|
+
})
|
|
11
|
+
.send()
|
|
12
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
13
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { MeowResult, UndefinedString } from "./types";
|
|
|
5
5
|
export { AuthorizationProvider } from "./auth-provider";
|
|
6
6
|
export { UndefinedString };
|
|
7
7
|
export { AccessToken } from "./token";
|
|
8
|
-
export { MeowUtils } from "./utils";
|
|
9
8
|
export type AuthorizationUpdateHandler = (data: {
|
|
10
9
|
accessToken: UndefinedString;
|
|
11
10
|
refreshToken: UndefinedString;
|
|
@@ -22,6 +21,5 @@ export declare class MeowSdkClient<T extends AuthorizationProvider> {
|
|
|
22
21
|
getAccessToken(): UndefinedString;
|
|
23
22
|
onAuthorizationUpdated(callback: AuthorizationUpdateHandler): this;
|
|
24
23
|
tryUpdateAuth(): Promise<MeowResult<void>>;
|
|
25
|
-
isContainsExpectedPermissions(expected: string[]): boolean;
|
|
26
24
|
static fromAuthorizationProvider<T extends AuthorizationProvider>(provider: AuthorizationProvider): MeowSdkClient<T>;
|
|
27
25
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,7 @@ import { updateAuthorization } from "./http-client";
|
|
|
4
4
|
import { MailClient } from "./mail";
|
|
5
5
|
import { AccessToken } from "./token";
|
|
6
6
|
import { MeowResult } from "./types";
|
|
7
|
-
import { MeowUtils } from "./utils";
|
|
8
7
|
export { AccessToken } from "./token";
|
|
9
|
-
export { MeowUtils } from "./utils";
|
|
10
8
|
export class MeowSdkClient {
|
|
11
9
|
account;
|
|
12
10
|
mail;
|
|
@@ -52,14 +50,6 @@ export class MeowSdkClient {
|
|
|
52
50
|
this.updateTokens(accessToken, refreshToken);
|
|
53
51
|
return MeowResult.withOk((function () { })());
|
|
54
52
|
}
|
|
55
|
-
isContainsExpectedPermissions(expected) {
|
|
56
|
-
const token = this.getAccessToken();
|
|
57
|
-
if (!token) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const parsedToken = new AccessToken(token);
|
|
61
|
-
return MeowUtils.checkRequiredPermissions(expected, parsedToken.permissions());
|
|
62
|
-
}
|
|
63
53
|
static fromAuthorizationProvider(provider) {
|
|
64
54
|
return new MeowSdkClient(provider);
|
|
65
55
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(id, authorizationProvider) {
|
|
5
|
+
return await new HttpClient()
|
|
6
|
+
.withMethodDelete()
|
|
7
|
+
.withUrl(`${MAIL_API}/v1/email/${id}`)
|
|
8
|
+
.withAuthorization(authorizationProvider)
|
|
9
|
+
.send()
|
|
10
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuthorizationProvider } from "../../auth-provider";
|
|
2
|
+
import { MeowResult } from "../../types";
|
|
3
|
+
import { EmailModel } from "../types";
|
|
4
|
+
type Response = EmailModel;
|
|
5
|
+
export declare function request(id: number, authorizationProvider: AuthorizationProvider): Promise<MeowResult<Response>>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(id, authorizationProvider) {
|
|
5
|
+
return await new HttpClient()
|
|
6
|
+
.withMethodGet()
|
|
7
|
+
.withUrl(`${MAIL_API}/v1/email/${id}`)
|
|
8
|
+
.withAuthorization(authorizationProvider)
|
|
9
|
+
.send()
|
|
10
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(to, subject, content, authorizationProvider) {
|
|
5
|
+
return await new HttpClient()
|
|
6
|
+
.withMethodPost()
|
|
7
|
+
.withAuthorization(authorizationProvider)
|
|
8
|
+
.withUrl(`${MAIL_API}/v1/email/send-message`)
|
|
9
|
+
.withJsonBody({
|
|
10
|
+
to,
|
|
11
|
+
subject,
|
|
12
|
+
content,
|
|
13
|
+
})
|
|
14
|
+
.send()
|
|
15
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MAIL_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(id, isRead, authorizationProvider) {
|
|
5
|
+
return new HttpClient()
|
|
6
|
+
.withMethodPut()
|
|
7
|
+
.withUrl(`${MAIL_API}/v1/email/my/set-read`)
|
|
8
|
+
.withAuthorization(authorizationProvider)
|
|
9
|
+
.withJsonBody({ mailId: id, isRead })
|
|
10
|
+
.send()
|
|
11
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@meowinc/meow-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Meow SDK",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"sdk"
|
|
7
|
-
],
|
|
8
|
-
"homepage": "https://github.com/ProjectMeowInc/meow-sdk-ts#readme",
|
|
9
|
-
"bugs": {
|
|
10
|
-
"url": "https://github.com/ProjectMeowInc/meow-sdk-ts/issues"
|
|
11
|
-
},
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/ProjectMeowInc/meow-sdk-ts.git"
|
|
15
|
-
},
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"author": "BlackSoulHub",
|
|
18
|
-
"type": "module",
|
|
19
|
-
"main": "dist/index.js",
|
|
20
|
-
"types": "dist/index.d.ts",
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsc",
|
|
23
|
-
"prettier": "prettier ./src --write"
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"ts-result-meow": ">=0.0.13",
|
|
27
|
-
"jwt-decode": ">=4"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"typescript": "^5.9.3"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@meowinc/meow-sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Meow SDK",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sdk"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/ProjectMeowInc/meow-sdk-ts#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/ProjectMeowInc/meow-sdk-ts/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/ProjectMeowInc/meow-sdk-ts.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "BlackSoulHub",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"prettier": "prettier ./src --write"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"ts-result-meow": ">=0.0.13",
|
|
27
|
+
"jwt-decode": ">=4"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "^5.9.3"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
// File Layout
|
|
4
|
-
"rootDir": "./src",
|
|
5
|
-
"outDir": "./dist",
|
|
6
|
-
|
|
7
|
-
"module": "ES2022",
|
|
8
|
-
"moduleResolution": "bundler",
|
|
9
|
-
"target": "ES2024",
|
|
10
|
-
"declaration": true,
|
|
11
|
-
|
|
12
|
-
"strict": true,
|
|
13
|
-
"noImplicitAny": true,
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
"strictNullChecks": true,
|
|
16
|
-
},
|
|
17
|
-
"exclude": ["node_modules"],
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// File Layout
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
|
|
7
|
+
"module": "ES2022",
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"target": "ES2024",
|
|
10
|
+
"declaration": true,
|
|
11
|
+
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"strictNullChecks": true,
|
|
16
|
+
},
|
|
17
|
+
"exclude": ["node_modules"],
|
|
18
|
+
"include": ["src/**/*"],
|
|
19
|
+
}
|
package/dist/utils.d.ts
DELETED