@meowinc/meow-sdk 0.1.4 → 0.1.5

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 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
  }
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ 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";
8
9
  export type AuthorizationUpdateHandler = (data: {
9
10
  accessToken: UndefinedString;
10
11
  refreshToken: UndefinedString;
@@ -21,5 +22,6 @@ export declare class MeowSdkClient<T extends AuthorizationProvider> {
21
22
  getAccessToken(): UndefinedString;
22
23
  onAuthorizationUpdated(callback: AuthorizationUpdateHandler): this;
23
24
  tryUpdateAuth(): Promise<MeowResult<void>>;
25
+ isContainsExpectedPermissions(expected: string[]): boolean;
24
26
  static fromAuthorizationProvider<T extends AuthorizationProvider>(provider: AuthorizationProvider): MeowSdkClient<T>;
25
27
  }
package/dist/index.js CHANGED
@@ -4,7 +4,9 @@ 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";
7
8
  export { AccessToken } from "./token";
9
+ export { MeowUtils } from "./utils";
8
10
  export class MeowSdkClient {
9
11
  account;
10
12
  mail;
@@ -50,6 +52,14 @@ export class MeowSdkClient {
50
52
  this.updateTokens(accessToken, refreshToken);
51
53
  return MeowResult.withOk((function () { })());
52
54
  }
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
+ }
53
63
  static fromAuthorizationProvider(provider) {
54
64
  return new MeowSdkClient(provider);
55
65
  }
@@ -0,0 +1,3 @@
1
+ export declare class MeowUtils {
2
+ static checkRequiredPermissions(expected: string[], permissions: string[]): boolean;
3
+ }
package/dist/utils.js ADDED
@@ -0,0 +1,5 @@
1
+ export class MeowUtils {
2
+ static checkRequiredPermissions(expected, permissions) {
3
+ return permissions.every((permission) => expected.includes(permission));
4
+ }
5
+ }
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
- {
2
- "name": "@meowinc/meow-sdk",
3
- "version": "0.1.4",
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.1.5",
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
+ }
@@ -1,3 +0,0 @@
1
- import { AuthorizationProvider } from "../../auth-provider";
2
- import { MeowResult } from "../../types";
3
- export declare function request(id: number, authorizationProvider: AuthorizationProvider): Promise<MeowResult<void>>;
@@ -1,11 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
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 {};
@@ -1,11 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- import { AuthorizationProvider } from "../../auth-provider";
2
- import { MeowResult } from "../../types";
3
- export declare function request(to: string, subject: string, content: string, authorizationProvider: AuthorizationProvider): Promise<MeowResult<void>>;
@@ -1,16 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- import { AuthorizationProvider } from "../../auth-provider";
2
- import { MeowResult } from "../../types";
3
- export declare function request(id: number, isRead: boolean, authorizationProvider: AuthorizationProvider): Promise<MeowResult<void>>;
@@ -1,12 +0,0 @@
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
- }