@meowinc/meow-sdk 0.2.0 → 0.3.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/dist/account/app/get-app-list.d.ts +1 -1
- package/dist/account/app/get-by-display-id.d.ts +2 -0
- package/dist/account/app/index.d.ts +1 -1
- package/dist/account/auth/add-email.js +2 -0
- package/dist/account/auth/submit-add-email.js +2 -0
- package/dist/account/user/get-user-by-login.d.ts +1 -1
- package/dist/account/user/index.d.ts +1 -1
- package/dist/http-client.d.ts +1 -1
- package/dist/http-client.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +5 -0
- package/package.json +2 -2
|
@@ -3,6 +3,6 @@ export declare class AppRequests {
|
|
|
3
3
|
private readonly authProvider;
|
|
4
4
|
constructor(authProvider: AuthorizationProvider);
|
|
5
5
|
create(displayId: string, name: string, type: "web" | "mobile"): Promise<import("../../types").MeowResult<void>>;
|
|
6
|
-
getAppList(): Promise<import("
|
|
6
|
+
getAppList(): Promise<import("@meowinc/result").Result<import("./get-app-list").Response, string>>;
|
|
7
7
|
getByDisplayId(displayId: string): Promise<import("../../types").MeowResult<import("./get-by-display-id").Response>>;
|
|
8
8
|
}
|
|
@@ -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({
|
|
@@ -7,5 +7,5 @@ export interface Response {
|
|
|
7
7
|
status: string;
|
|
8
8
|
registrationDate: Date;
|
|
9
9
|
}
|
|
10
|
-
export declare function request(login: string): Promise<import("
|
|
10
|
+
export declare function request(login: string): Promise<import("@meowinc/result").Result<Response, string>>;
|
|
11
11
|
export {};
|
|
@@ -2,5 +2,5 @@ import { AuthorizationProvider } from "../../auth-provider";
|
|
|
2
2
|
export declare class UserRequests {
|
|
3
3
|
private readonly authProvider;
|
|
4
4
|
constructor(authProvider: AuthorizationProvider);
|
|
5
|
-
getUserByLogin(login: string): Promise<import("
|
|
5
|
+
getUserByLogin(login: string): Promise<import("@meowinc/result").Result<import("./get-user-by-login").Response, string>>;
|
|
6
6
|
}
|
package/dist/http-client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AuthorizationProvider } from "./auth-provider";
|
|
2
|
-
import { Result } from "ts-result-meow";
|
|
3
2
|
import { HttpError, type AppError } from "./error";
|
|
3
|
+
import { Result } from "@meowinc/result";
|
|
4
4
|
export declare class HttpClient {
|
|
5
5
|
private url;
|
|
6
6
|
private headers;
|
package/dist/http-client.js
CHANGED
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
|
}
|
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowinc/meow-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Meow SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sdk"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"prettier": "prettier ./src --write"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"
|
|
26
|
+
"@meowinc/result": ">=0.0.13",
|
|
27
27
|
"jwt-decode": ">=4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|