@meowinc/meow-sdk 0.2.0 → 0.2.1

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.
@@ -2,8 +2,10 @@ import { MeowResult } from "../../types";
2
2
  export interface Response {
3
3
  id: string;
4
4
  name: string;
5
+ type: "web" | "mobile";
5
6
  owner: {
6
7
  id: number;
8
+ login: string;
7
9
  name: string;
8
10
  };
9
11
  }
@@ -1,7 +1,9 @@
1
+ import { ACCOUNT_API } from "..";
1
2
  import { ErrorToMessage } from "../../error";
2
3
  import { HttpClient } from "../../http-client";
3
4
  export async function request(mailbox, authorizationProvider) {
4
5
  return await new HttpClient()
6
+ .withUrl(`${ACCOUNT_API}/v1/auth/2fa/email`)
5
7
  .withAuthorization(authorizationProvider)
6
8
  .withMethodPost()
7
9
  .withJsonBody({
@@ -1,7 +1,9 @@
1
+ import { ACCOUNT_API } from "..";
1
2
  import { ErrorToMessage } from "../../error";
2
3
  import { HttpClient } from "../../http-client";
3
4
  export async function request(sessionId, code, authorizationProvider) {
4
5
  return await new HttpClient()
6
+ .withUrl(`${ACCOUNT_API}/v1/auth/2fa/email/submit`)
5
7
  .withMethodPost()
6
8
  .withAuthorization(authorizationProvider)
7
9
  .withJsonBody({
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@meowinc/meow-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Meow SDK",
5
5
  "keywords": [
6
6
  "sdk"