@temboplus/afloat 0.1.11 → 0.1.12
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/esm/src/features/auth/manager.d.ts +9 -1
- package/esm/src/features/auth/manager.d.ts.map +1 -1
- package/esm/src/features/auth/manager.js +20 -3
- package/esm/src/features/contact/repository.d.ts +12 -1
- package/esm/src/features/contact/repository.d.ts.map +1 -1
- package/esm/src/features/contact/repository.js +25 -11
- package/esm/src/features/files-gen/repository.d.ts +4 -1
- package/esm/src/features/files-gen/repository.d.ts.map +1 -1
- package/esm/src/features/files-gen/repository.js +10 -3
- package/esm/src/features/payout/repository.d.ts +6 -1
- package/esm/src/features/payout/repository.d.ts.map +1 -1
- package/esm/src/features/payout/repository.js +12 -7
- package/esm/src/features/wallet/repository.d.ts +8 -1
- package/esm/src/features/wallet/repository.d.ts.map +1 -1
- package/esm/src/features/wallet/repository.js +17 -8
- package/esm/src/shared/base_repository.d.ts +25 -1
- package/esm/src/shared/base_repository.d.ts.map +1 -1
- package/esm/src/shared/base_repository.js +57 -6
- package/package.json +1 -1
- package/script/src/features/auth/manager.d.ts +9 -1
- package/script/src/features/auth/manager.d.ts.map +1 -1
- package/script/src/features/auth/manager.js +21 -4
- package/script/src/features/contact/repository.d.ts +12 -1
- package/script/src/features/contact/repository.d.ts.map +1 -1
- package/script/src/features/contact/repository.js +31 -17
- package/script/src/features/files-gen/repository.d.ts +4 -1
- package/script/src/features/files-gen/repository.d.ts.map +1 -1
- package/script/src/features/files-gen/repository.js +10 -3
- package/script/src/features/payout/repository.d.ts +6 -1
- package/script/src/features/payout/repository.d.ts.map +1 -1
- package/script/src/features/payout/repository.js +12 -7
- package/script/src/features/wallet/repository.d.ts +8 -1
- package/script/src/features/wallet/repository.d.ts.map +1 -1
- package/script/src/features/wallet/repository.js +17 -8
- package/script/src/shared/base_repository.d.ts +25 -1
- package/script/src/shared/base_repository.d.ts.map +1 -1
- package/script/src/shared/base_repository.js +57 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { initClient } from "@ts-rest/core";
|
|
2
2
|
import { APIError } from "../errors/api_error.js";
|
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
|
4
|
-
import { AfloatAuth } from "../features/auth/
|
|
4
|
+
import { AfloatAuth, AuthContext } from "../features/auth/manager.js";
|
|
5
5
|
/**
|
|
6
6
|
* BaseRepository
|
|
7
7
|
*
|
|
@@ -15,8 +15,11 @@ export class BaseRepository {
|
|
|
15
15
|
/**
|
|
16
16
|
* Constructs a new instance of `BaseRepository`.
|
|
17
17
|
*
|
|
18
|
-
* @param contract - The "ts-rest" contract
|
|
19
18
|
* @param endpoint - API endpoint
|
|
19
|
+
* @param contract - The "ts-rest" contract
|
|
20
|
+
* @param args - Optional constructor arguments
|
|
21
|
+
* @param args.root - Optional API root URL
|
|
22
|
+
* @param args.auth - Optional auth instance to use
|
|
20
23
|
*/
|
|
21
24
|
constructor(endpoint, contract, args) {
|
|
22
25
|
/**
|
|
@@ -52,20 +55,68 @@ export class BaseRepository {
|
|
|
52
55
|
writable: true,
|
|
53
56
|
value: void 0
|
|
54
57
|
});
|
|
58
|
+
/**
|
|
59
|
+
* The auth instance to use for authentication
|
|
60
|
+
*
|
|
61
|
+
* @protected
|
|
62
|
+
*/
|
|
63
|
+
Object.defineProperty(this, "auth", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: void 0
|
|
68
|
+
});
|
|
55
69
|
this.contract = contract;
|
|
56
70
|
this.endpoint = endpoint;
|
|
57
71
|
this.root = args?.root;
|
|
72
|
+
// Use provided auth or try to get the current context
|
|
73
|
+
this.auth = args?.auth || AuthContext.current;
|
|
58
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets an auth instance that can be used for permission checks.
|
|
77
|
+
* Follows a fallback strategy to find a valid auth instance.
|
|
78
|
+
*
|
|
79
|
+
* @protected
|
|
80
|
+
* @returns {AfloatAuth} A valid auth instance
|
|
81
|
+
* @throws {Error} If no valid auth instance is available
|
|
82
|
+
*/
|
|
83
|
+
getAuthForPermissionCheck() {
|
|
84
|
+
// Use the instance provided in constructor, or fallback to context
|
|
85
|
+
const auth = this.auth || AuthContext.current;
|
|
86
|
+
if (!auth) {
|
|
87
|
+
try {
|
|
88
|
+
// Last resort: try to get the client singleton
|
|
89
|
+
return AfloatAuth.instance;
|
|
90
|
+
}
|
|
91
|
+
catch (_) {
|
|
92
|
+
throw new Error(`No valid auth instance available for ${this.endpoint} repository`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return auth;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets the initialized client for making API requests.
|
|
99
|
+
* Uses authentication token if available.
|
|
100
|
+
*/
|
|
59
101
|
get client() {
|
|
60
102
|
const baseUrl = this.root
|
|
61
103
|
? `${this.root}/${this.endpoint}`
|
|
62
104
|
: `https://api.afloat.money/v1/${this.endpoint}`;
|
|
63
105
|
let token = "";
|
|
64
|
-
|
|
65
|
-
|
|
106
|
+
// Try to get token from the provided auth instance
|
|
107
|
+
if (this.auth) {
|
|
108
|
+
token = this.auth.getUserToken() ?? "";
|
|
66
109
|
}
|
|
67
|
-
|
|
68
|
-
|
|
110
|
+
// Fall back to singleton if no auth was provided, but handle exceptions
|
|
111
|
+
// that occur in server environments
|
|
112
|
+
else {
|
|
113
|
+
try {
|
|
114
|
+
token = AfloatAuth.instance.getUserToken() ?? "";
|
|
115
|
+
}
|
|
116
|
+
catch (_) {
|
|
117
|
+
// This will fail when called within the server without initialization
|
|
118
|
+
// We'll proceed with an empty token
|
|
119
|
+
}
|
|
69
120
|
}
|
|
70
121
|
const args = {
|
|
71
122
|
baseUrl,
|
package/package.json
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { User } from "../../models/index.js";
|
|
2
2
|
import type { Permission } from "../../models/permission.js";
|
|
3
|
+
/**
|
|
4
|
+
* Global context to hold the current auth instance reference.
|
|
5
|
+
* This provides a way to access the auth instance across the application
|
|
6
|
+
* without directly coupling to the singleton pattern.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AuthContext: {
|
|
9
|
+
current: AfloatAuth | undefined;
|
|
10
|
+
};
|
|
3
11
|
/**
|
|
4
12
|
* Main authentication class that works in both client and server environments.
|
|
5
13
|
* Provides authentication functionality and user management.
|
|
@@ -12,7 +20,7 @@ export declare class AfloatAuth {
|
|
|
12
20
|
/** client AfloatAuth instance */
|
|
13
21
|
private static _instance;
|
|
14
22
|
/**
|
|
15
|
-
* Private constructor to
|
|
23
|
+
* Private constructor to maintain control over instantiation.
|
|
16
24
|
* @param {AuthStore} store - The auth store implementation to use
|
|
17
25
|
* @param {TokenHandler} tokenHandler - The token handler implementation to use
|
|
18
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAU7D;;;GAGG;AACH,qBAAa,UAAU;IACrB,oCAAoC;IACpC,OAAO,CAAC,KAAK,CAAY;IAEzB,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAAe;IAEnC,iCAAiC;IACjC,OAAO,CAAC,MAAM,CAAC,SAAS,CAA2B;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAU7D;;;;GAIG;AACH,eAAO,MAAM,WAAW;aAEA,UAAU,GAAG,SAAS;CAC7C,CAAC;AAEF;;;GAGG;AACH,qBAAa,UAAU;IACrB,oCAAoC;IACpC,OAAO,CAAC,KAAK,CAAY;IAEzB,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAAe;IAEnC,iCAAiC;IACjC,OAAO,CAAC,MAAM,CAAC,SAAS,CAA2B;IAEnD;;;;OAIG;IACH,OAAO;IAKP;;;;;;;;;;;;OAYG;IACH,WAAkB,QAAQ,IAAI,UAAU,CAYvC;IAED;;;;;;;OAOG;WACiB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA8BxE;;;;OAIG;IACH,OAAO,KAAK,IAAI,GAEf;IAED;;;OAGG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC;;;OAGG;IACH,IAAI,WAAW,IAAI,IAAI,GAAG,SAAS,CAElC;IAED;;;;OAIG;IACH,cAAc,IAAI,IAAI,GAAG,SAAS;IAIlC;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAI1C;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3D;;;;;;OAMG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMvE;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,OAAO,CAAC,cAAc;CAIvB"}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AfloatAuth = void 0;
|
|
3
|
+
exports.AfloatAuth = exports.AuthContext = void 0;
|
|
4
4
|
const repository_js_1 = require("./repository.js");
|
|
5
5
|
const client_store_js_1 = require("./storage/client_store.js");
|
|
6
6
|
const client_token_handler_js_1 = require("./storage/client_token_handler.js");
|
|
7
7
|
const server_store_js_1 = require("./storage/server_store.js");
|
|
8
8
|
const server_token_handler_js_1 = require("./storage/server_token_handler.js");
|
|
9
|
+
/**
|
|
10
|
+
* Global context to hold the current auth instance reference.
|
|
11
|
+
* This provides a way to access the auth instance across the application
|
|
12
|
+
* without directly coupling to the singleton pattern.
|
|
13
|
+
*/
|
|
14
|
+
exports.AuthContext = {
|
|
15
|
+
// Default undefined state - will be set during initialization
|
|
16
|
+
current: undefined,
|
|
17
|
+
};
|
|
9
18
|
/**
|
|
10
19
|
* Main authentication class that works in both client and server environments.
|
|
11
20
|
* Provides authentication functionality and user management.
|
|
12
21
|
*/
|
|
13
22
|
class AfloatAuth {
|
|
14
23
|
/**
|
|
15
|
-
* Private constructor to
|
|
24
|
+
* Private constructor to maintain control over instantiation.
|
|
16
25
|
* @param {AuthStore} store - The auth store implementation to use
|
|
17
26
|
* @param {TokenHandler} tokenHandler - The token handler implementation to use
|
|
18
27
|
*/
|
|
@@ -48,7 +57,12 @@ class AfloatAuth {
|
|
|
48
57
|
* const serverAuth = await AfloatAuth.initializeServer(token);
|
|
49
58
|
*/
|
|
50
59
|
static get instance() {
|
|
51
|
-
|
|
60
|
+
if (!AfloatAuth._instance) {
|
|
61
|
+
AfloatAuth._instance = new AfloatAuth((0, client_store_js_1.createClientStore)(), client_token_handler_js_1.ClientTokenHandler.instance);
|
|
62
|
+
// Set as current instance for global access
|
|
63
|
+
exports.AuthContext.current = AfloatAuth._instance;
|
|
64
|
+
}
|
|
65
|
+
return AfloatAuth._instance;
|
|
52
66
|
}
|
|
53
67
|
/**
|
|
54
68
|
* Creates a new server-side instance of AfloatAuth.
|
|
@@ -69,7 +83,10 @@ class AfloatAuth {
|
|
|
69
83
|
const user = await tokenHandler.constructUser();
|
|
70
84
|
store.setUser(user);
|
|
71
85
|
// Create and initialize auth instance
|
|
72
|
-
|
|
86
|
+
const auth = new AfloatAuth(store, tokenHandler);
|
|
87
|
+
// Set as current instance for global access
|
|
88
|
+
exports.AuthContext.current = auth;
|
|
89
|
+
return auth;
|
|
73
90
|
}
|
|
74
91
|
catch (error) {
|
|
75
92
|
if (error instanceof Error) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseRepository } from "../../shared/base_repository.js";
|
|
2
2
|
import { contract } from "./contract.js";
|
|
3
3
|
import { Contact, type ContactInput } from "../../models/contact/index.js";
|
|
4
|
+
import type { AfloatAuth } from "../auth/manager.js";
|
|
4
5
|
/**
|
|
5
6
|
* Repository class for managing `Contact` data through API interactions.
|
|
6
7
|
* Extends the `BaseRepository` to leverage shared functionality.
|
|
@@ -8,12 +9,19 @@ import { Contact, type ContactInput } from "../../models/contact/index.js";
|
|
|
8
9
|
export declare class ContactRepository extends BaseRepository<typeof contract> {
|
|
9
10
|
/**
|
|
10
11
|
* Creates an instance of `ContactRepository` using the contact contract.
|
|
12
|
+
* @param {Object} [props] - Optional constructor properties
|
|
13
|
+
* @param {AfloatAuth} [props.auth] - Optional auth instance to use
|
|
14
|
+
* @param {string} [props.root] - Optional API root URL
|
|
11
15
|
*/
|
|
12
|
-
constructor(
|
|
16
|
+
constructor(props?: {
|
|
17
|
+
auth?: AfloatAuth;
|
|
18
|
+
root?: string;
|
|
19
|
+
});
|
|
13
20
|
/**
|
|
14
21
|
* Creates a new contact record.
|
|
15
22
|
* @param {ContactInput} input - The data required to create a new contact.
|
|
16
23
|
* @returns {Promise<Contact>} A promise that resolves to the newly created contact.
|
|
24
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
17
25
|
* @throws {APIError} If the response status code is not 201.
|
|
18
26
|
*/
|
|
19
27
|
create(input: ContactInput): Promise<Contact>;
|
|
@@ -22,6 +30,7 @@ export declare class ContactRepository extends BaseRepository<typeof contract> {
|
|
|
22
30
|
* @param {string} id - The unique identifier of the contact to edit.
|
|
23
31
|
* @param {ContactInput} input - The data to update the contact with.
|
|
24
32
|
* @returns {Promise<Contact>} A promise that resolves to the updated contact.
|
|
33
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
25
34
|
* @throws {APIError} If the response status code is not 200.
|
|
26
35
|
*/
|
|
27
36
|
edit(id: string, input: ContactInput): Promise<Contact>;
|
|
@@ -29,6 +38,7 @@ export declare class ContactRepository extends BaseRepository<typeof contract> {
|
|
|
29
38
|
* Deletes a contact record by ID.
|
|
30
39
|
* @param {string} id - The unique identifier of the contact to remove.
|
|
31
40
|
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
|
|
41
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
32
42
|
* @throws {APIError} If the response status code is not 200.
|
|
33
43
|
*/
|
|
34
44
|
remove(id: string): Promise<void>;
|
|
@@ -37,6 +47,7 @@ export declare class ContactRepository extends BaseRepository<typeof contract> {
|
|
|
37
47
|
* Results are ordered in descending order by default.
|
|
38
48
|
*
|
|
39
49
|
* @returns {Promise<Contact[]>} A promise that resolves to an array of contacts.
|
|
50
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
40
51
|
* @throws {APIError} If the response status code is not 200 or the range is invalid.
|
|
41
52
|
* @example
|
|
42
53
|
* const repository = new ContactRepository();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/contact/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,OAAO,EAEP,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/contact/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,OAAO,EAEP,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,OAAO,QAAQ,CAAC;IACpE;;;;;OAKG;gBACS,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAIxD;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBnD;;;;;;;OAOG;IACG,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAmB7D;;;;;;OAMG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAevC;;;;;;;;;;OAUG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAgBnC"}
|
|
@@ -4,9 +4,8 @@ exports.ContactRepository = void 0;
|
|
|
4
4
|
const base_repository_js_1 = require("../../shared/base_repository.js");
|
|
5
5
|
const contract_js_1 = require("./contract.js");
|
|
6
6
|
const index_js_1 = require("../../models/contact/index.js");
|
|
7
|
-
const index_js_2 = require("
|
|
8
|
-
const index_js_3 = require("../../
|
|
9
|
-
const index_js_4 = require("../../errors/index.js");
|
|
7
|
+
const index_js_2 = require("../../models/index.js");
|
|
8
|
+
const index_js_3 = require("../../errors/index.js");
|
|
10
9
|
/**
|
|
11
10
|
* Repository class for managing `Contact` data through API interactions.
|
|
12
11
|
* Extends the `BaseRepository` to leverage shared functionality.
|
|
@@ -14,21 +13,27 @@ const index_js_4 = require("../../errors/index.js");
|
|
|
14
13
|
class ContactRepository extends base_repository_js_1.BaseRepository {
|
|
15
14
|
/**
|
|
16
15
|
* Creates an instance of `ContactRepository` using the contact contract.
|
|
16
|
+
* @param {Object} [props] - Optional constructor properties
|
|
17
|
+
* @param {AfloatAuth} [props.auth] - Optional auth instance to use
|
|
18
|
+
* @param {string} [props.root] - Optional API root URL
|
|
17
19
|
*/
|
|
18
|
-
constructor() {
|
|
19
|
-
super("contact", contract_js_1.contract);
|
|
20
|
+
constructor(props) {
|
|
21
|
+
super("contact", contract_js_1.contract, props);
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Creates a new contact record.
|
|
23
25
|
* @param {ContactInput} input - The data required to create a new contact.
|
|
24
26
|
* @returns {Promise<Contact>} A promise that resolves to the newly created contact.
|
|
27
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
25
28
|
* @throws {APIError} If the response status code is not 201.
|
|
26
29
|
*/
|
|
27
30
|
async create(input) {
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
const auth = this.getAuthForPermissionCheck();
|
|
32
|
+
const requiredPerm = index_js_2.Permissions.Contact.Create;
|
|
33
|
+
if (!auth.checkPermission(requiredPerm)) {
|
|
34
|
+
throw new index_js_3.PermissionError({
|
|
30
35
|
message: "You are not authorized to add contacts.",
|
|
31
|
-
requiredPermissions: [
|
|
36
|
+
requiredPermissions: [requiredPerm],
|
|
32
37
|
});
|
|
33
38
|
}
|
|
34
39
|
const result = await this.client.postContact({ body: input });
|
|
@@ -40,13 +45,16 @@ class ContactRepository extends base_repository_js_1.BaseRepository {
|
|
|
40
45
|
* @param {string} id - The unique identifier of the contact to edit.
|
|
41
46
|
* @param {ContactInput} input - The data to update the contact with.
|
|
42
47
|
* @returns {Promise<Contact>} A promise that resolves to the updated contact.
|
|
48
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
43
49
|
* @throws {APIError} If the response status code is not 200.
|
|
44
50
|
*/
|
|
45
51
|
async edit(id, input) {
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
const auth = this.getAuthForPermissionCheck();
|
|
53
|
+
const requiredPerm = index_js_2.Permissions.Contact.Update;
|
|
54
|
+
if (!auth.checkPermission(requiredPerm)) {
|
|
55
|
+
throw new index_js_3.PermissionError({
|
|
48
56
|
message: "You are not authorized to update contacts.",
|
|
49
|
-
requiredPermissions: [
|
|
57
|
+
requiredPermissions: [requiredPerm],
|
|
50
58
|
});
|
|
51
59
|
}
|
|
52
60
|
const result = await this.client.editContact({
|
|
@@ -60,13 +68,16 @@ class ContactRepository extends base_repository_js_1.BaseRepository {
|
|
|
60
68
|
* Deletes a contact record by ID.
|
|
61
69
|
* @param {string} id - The unique identifier of the contact to remove.
|
|
62
70
|
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
|
|
71
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
63
72
|
* @throws {APIError} If the response status code is not 200.
|
|
64
73
|
*/
|
|
65
74
|
async remove(id) {
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
const auth = this.getAuthForPermissionCheck();
|
|
76
|
+
const requiredPerm = index_js_2.Permissions.Contact.Delete;
|
|
77
|
+
if (!auth.checkPermission(requiredPerm)) {
|
|
78
|
+
throw new index_js_3.PermissionError({
|
|
68
79
|
message: "You are not authorized to delete contacts.",
|
|
69
|
-
requiredPermissions: [
|
|
80
|
+
requiredPermissions: [requiredPerm],
|
|
70
81
|
});
|
|
71
82
|
}
|
|
72
83
|
const result = await this.client.deleteContact({ params: { id } });
|
|
@@ -77,16 +88,19 @@ class ContactRepository extends base_repository_js_1.BaseRepository {
|
|
|
77
88
|
* Results are ordered in descending order by default.
|
|
78
89
|
*
|
|
79
90
|
* @returns {Promise<Contact[]>} A promise that resolves to an array of contacts.
|
|
91
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
80
92
|
* @throws {APIError} If the response status code is not 200 or the range is invalid.
|
|
81
93
|
* @example
|
|
82
94
|
* const repository = new ContactRepository();
|
|
83
95
|
* repository.getAll().then(contacts => console.log(contacts));
|
|
84
96
|
*/
|
|
85
97
|
async getAll() {
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
const auth = this.getAuthForPermissionCheck();
|
|
99
|
+
const requiredPerm = index_js_2.Permissions.Contact.List;
|
|
100
|
+
if (!auth.checkPermission(requiredPerm)) {
|
|
101
|
+
throw new index_js_3.PermissionError({
|
|
88
102
|
message: "You are not authorized to view contacts.",
|
|
89
|
-
requiredPermissions: [
|
|
103
|
+
requiredPermissions: [requiredPerm],
|
|
90
104
|
});
|
|
91
105
|
}
|
|
92
106
|
const query = { orderByDesc: "createdAt" };
|
|
@@ -2,6 +2,7 @@ import { contract } from "./contract.js";
|
|
|
2
2
|
import { BaseRepository } from "../../shared/index.js";
|
|
3
3
|
import type { ClientInferRequest, ClientInferResponseBody } from "@ts-rest/core";
|
|
4
4
|
import type { StatementFile } from "../../models/wallet/index.js";
|
|
5
|
+
import type { AfloatAuth } from "../auth/index.js";
|
|
5
6
|
/**
|
|
6
7
|
* Type definition for statement generation input parameters.
|
|
7
8
|
* Inferred from the contract's genStatementPDF endpoint request body.
|
|
@@ -24,7 +25,9 @@ export declare class AfloatFilesRepo extends BaseRepository<typeof contract> {
|
|
|
24
25
|
* Creates an instance of AfloatFilesRepo initialized with the files generation contract.
|
|
25
26
|
* Configures the repository with the PDF maker service endpoint.
|
|
26
27
|
*/
|
|
27
|
-
constructor(
|
|
28
|
+
constructor(props?: {
|
|
29
|
+
auth?: AfloatAuth;
|
|
30
|
+
});
|
|
28
31
|
/**
|
|
29
32
|
* Generates and downloads a statement PDF based on the provided parameters.
|
|
30
33
|
* @param {GenStatementInput} body - The statement generation parameters
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/files-gen/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/files-gen/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,KAAK,iBAAiB,GAAG,kBAAkB,CACzC,OAAO,QAAQ,CAAC,eAAe,CAChC,CAAC,MAAM,CAAC,CAAC;AAEV;;;;GAIG;AACH,KAAK,yBAAyB,GAAG,uBAAuB,CACtD,OAAO,QAAQ,CAAC,oBAAoB,CACrC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,OAAO,QAAQ,CAAC;IAClE;;;OAGG;gBACS,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,UAAU,CAAA;KAAE;IAQzC;;;;;;;;;OASG;IACG,iBAAiB,CACrB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,aAAa,CAAC;IAiBzB;;;;OAIG;IACG,oBAAoB,IAAI,OAAO,CAAC,yBAAyB,CAAC;CAWjE"}
|
|
@@ -14,10 +14,11 @@ class AfloatFilesRepo extends index_js_1.BaseRepository {
|
|
|
14
14
|
* Creates an instance of AfloatFilesRepo initialized with the files generation contract.
|
|
15
15
|
* Configures the repository with the PDF maker service endpoint.
|
|
16
16
|
*/
|
|
17
|
-
constructor() {
|
|
17
|
+
constructor(props) {
|
|
18
18
|
super("wallet", contract_js_1.contract, {
|
|
19
|
-
|
|
20
|
-
root: "http://localhost:3000/afloat"
|
|
19
|
+
root: "https://api.afloat.money/pdf-maker/afloat",
|
|
20
|
+
// root: "http://localhost:3000/afloat",
|
|
21
|
+
auth: props?.auth,
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
@@ -35,6 +36,12 @@ class AfloatFilesRepo extends index_js_1.BaseRepository {
|
|
|
35
36
|
if (result.status === 201) {
|
|
36
37
|
return result.body;
|
|
37
38
|
}
|
|
39
|
+
if (result.status === 202) {
|
|
40
|
+
throw new api_error_js_1.APIError({
|
|
41
|
+
message: result.body.message,
|
|
42
|
+
statusCode: 202,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
38
45
|
throw api_error_js_1.APIError.unknown("An error occurred while generating statement PDF");
|
|
39
46
|
}
|
|
40
47
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseRepository } from "../../shared/index.js";
|
|
2
2
|
import { type PayoutAPI } from "./contract.js";
|
|
3
3
|
import { type GetPayoutsAPIArgs, type PayoutInput } from "../../models/payout/index.js";
|
|
4
|
+
import type { AfloatAuth } from "../auth/manager.js";
|
|
4
5
|
import { Payout } from "../../models/payout/derivatives/payout.js";
|
|
5
6
|
/**
|
|
6
7
|
* Repository class for managing payout operations including creation, approval,
|
|
@@ -10,8 +11,12 @@ import { Payout } from "../../models/payout/derivatives/payout.js";
|
|
|
10
11
|
export declare class PayoutRepository extends BaseRepository<PayoutAPI> {
|
|
11
12
|
/**
|
|
12
13
|
* Creates an instance of PayoutRepository initialized with the payout contract.
|
|
14
|
+
* @param {Object} [props] - Optional constructor properties
|
|
15
|
+
* @param {AfloatAuth} [props.auth] - Optional auth instance to use
|
|
13
16
|
*/
|
|
14
|
-
constructor(
|
|
17
|
+
constructor(props?: {
|
|
18
|
+
auth?: AfloatAuth;
|
|
19
|
+
});
|
|
15
20
|
/**
|
|
16
21
|
* Retrieves a paginated list of payouts with optional filtering for pending status.
|
|
17
22
|
* @param {GetPayoutsAPIArgs} [args] - Optional arguments for filtering and pagination
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/payout/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/payout/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,SAAS,CAAC;IAC7D;;;;OAIG;gBACS,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,UAAU,CAAA;KAAE;IAIzC;;;;;;;;;OASG;IACG,MAAM,CAAC,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IA6CF;;;;;;OAMG;IACG,GAAG,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB9C;;;;;;;;OAQG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAgCrE;;;;;;;;OAQG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CA+BrE"}
|
|
@@ -4,7 +4,6 @@ exports.PayoutRepository = void 0;
|
|
|
4
4
|
const index_js_1 = require("../../shared/index.js");
|
|
5
5
|
const contract_js_1 = require("./contract.js");
|
|
6
6
|
const index_js_2 = require("../../models/payout/index.js");
|
|
7
|
-
const manager_js_1 = require("../auth/manager.js");
|
|
8
7
|
const permission_js_1 = require("../../models/permission.js");
|
|
9
8
|
const index_js_3 = require("../../errors/index.js");
|
|
10
9
|
const payout_js_1 = require("../../models/payout/derivatives/payout.js");
|
|
@@ -16,9 +15,11 @@ const payout_js_1 = require("../../models/payout/derivatives/payout.js");
|
|
|
16
15
|
class PayoutRepository extends index_js_1.BaseRepository {
|
|
17
16
|
/**
|
|
18
17
|
* Creates an instance of PayoutRepository initialized with the payout contract.
|
|
18
|
+
* @param {Object} [props] - Optional constructor properties
|
|
19
|
+
* @param {AfloatAuth} [props.auth] - Optional auth instance to use
|
|
19
20
|
*/
|
|
20
|
-
constructor() {
|
|
21
|
-
super("payout", contract_js_1.contract);
|
|
21
|
+
constructor(props) {
|
|
22
|
+
super("payout", contract_js_1.contract, { auth: props?.auth });
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Retrieves a paginated list of payouts with optional filtering for pending status.
|
|
@@ -31,8 +32,9 @@ class PayoutRepository extends index_js_1.BaseRepository {
|
|
|
31
32
|
* @returns {Promise<{results: Payout[]; total: number}>} Paginated payout results and total count
|
|
32
33
|
*/
|
|
33
34
|
async getAll(args) {
|
|
35
|
+
const auth = this.getAuthForPermissionCheck();
|
|
34
36
|
const requiredPerm = permission_js_1.Permissions.Payout.List;
|
|
35
|
-
if (!
|
|
37
|
+
if (!auth.checkPermission(requiredPerm)) {
|
|
36
38
|
throw new index_js_3.PermissionError({
|
|
37
39
|
message: "You are not authorized to view payouts.",
|
|
38
40
|
requiredPermissions: [requiredPerm],
|
|
@@ -73,8 +75,9 @@ class PayoutRepository extends index_js_1.BaseRepository {
|
|
|
73
75
|
* @returns {Promise<Payout>} The created payout
|
|
74
76
|
*/
|
|
75
77
|
async pay(input) {
|
|
78
|
+
const auth = this.getAuthForPermissionCheck();
|
|
76
79
|
const requiredPerm = permission_js_1.Permissions.Payout.Create;
|
|
77
|
-
if (!
|
|
80
|
+
if (!auth.checkPermission(requiredPerm)) {
|
|
78
81
|
throw new index_js_3.PermissionError({
|
|
79
82
|
message: "You are not authorized to create payouts.",
|
|
80
83
|
requiredPermissions: [requiredPerm],
|
|
@@ -98,8 +101,9 @@ class PayoutRepository extends index_js_1.BaseRepository {
|
|
|
98
101
|
* @returns {Promise<Payout>} The approved payout
|
|
99
102
|
*/
|
|
100
103
|
async approve(id, args) {
|
|
104
|
+
const auth = this.getAuthForPermissionCheck();
|
|
101
105
|
const requiredPerm = permission_js_1.Permissions.Payout.Approve;
|
|
102
|
-
if (!
|
|
106
|
+
if (!auth.checkPermission(requiredPerm)) {
|
|
103
107
|
throw new index_js_3.PermissionError({
|
|
104
108
|
message: "You are not authorized to approve or reject payouts.",
|
|
105
109
|
requiredPermissions: [requiredPerm],
|
|
@@ -133,8 +137,9 @@ class PayoutRepository extends index_js_1.BaseRepository {
|
|
|
133
137
|
* @returns {Promise<Payout>} The rejected payout
|
|
134
138
|
*/
|
|
135
139
|
async reject(id, args) {
|
|
140
|
+
const auth = this.getAuthForPermissionCheck();
|
|
136
141
|
const requiredPerm = permission_js_1.Permissions.Payout.Approve;
|
|
137
|
-
if (!
|
|
142
|
+
if (!auth.checkPermission(requiredPerm)) {
|
|
138
143
|
throw new index_js_3.PermissionError({
|
|
139
144
|
message: "You are not authorized to approve or reject payouts.",
|
|
140
145
|
requiredPermissions: [requiredPerm],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseRepository } from "../../shared/base_repository.js";
|
|
2
2
|
import { contract } from "./contract.js";
|
|
3
3
|
import type { STATEMENT_OUTPUT_TYPE, StatementFile, Wallet, WalletStatementItem } from "../../models/wallet/index.js";
|
|
4
|
+
import type { AfloatAuth } from "../auth/manager.js";
|
|
4
5
|
/**
|
|
5
6
|
* Repository class for managing wallet operations including balance checking,
|
|
6
7
|
* statement generation, and wallet information retrieval.
|
|
@@ -9,8 +10,14 @@ import type { STATEMENT_OUTPUT_TYPE, StatementFile, Wallet, WalletStatementItem
|
|
|
9
10
|
export declare class WalletRepo extends BaseRepository<typeof contract> {
|
|
10
11
|
/**
|
|
11
12
|
* Creates an instance of WalletRepo initialized with the wallet contract.
|
|
13
|
+
* @param {Object} [options] - Optional configuration
|
|
14
|
+
* @param {string} [options.root] - Custom API root URL
|
|
15
|
+
* @param {AfloatAuth} [options.auth] - Auth instance to use
|
|
12
16
|
*/
|
|
13
|
-
constructor(
|
|
17
|
+
constructor(props?: {
|
|
18
|
+
root?: string;
|
|
19
|
+
auth?: AfloatAuth;
|
|
20
|
+
});
|
|
14
21
|
/**
|
|
15
22
|
* Gets an instance of the file generation repository.
|
|
16
23
|
* @private
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/wallet/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,MAAM,EACN,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/wallet/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,MAAM,EACN,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,cAAc,CAAC,OAAO,QAAQ,CAAC;IAC7D;;;;;OAKG;gBACS,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,UAAU,CAAA;KAAE;IAOxD;;;;OAIG;IACH,OAAO,KAAK,WAAW,GAEtB;IAED;;;;;OAKG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAoBnC;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAUrC;;;;;;;;;;;OAWG;IACG,YAAY,CAChB,KAAK,EAAE;QACL,KAAK,CAAC,EAAE;YAAE,SAAS,EAAE,IAAI,CAAC;YAAC,OAAO,EAAE,IAAI,CAAA;SAAE,CAAC;QAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,OAAO,CAAC,mBAAmB,EAAE,CAAC;IA4BjC;;;;;;;;;OASG;IACG,YAAY,CAChB,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE;QACL,SAAS,EAAE,IAAI,CAAC;QAChB,OAAO,EAAE,IAAI,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,OAAO,CAAC,aAAa,CAAC;IAmBzB;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC;CAapD"}
|
|
@@ -4,7 +4,6 @@ exports.WalletRepo = void 0;
|
|
|
4
4
|
const base_repository_js_1 = require("../../shared/base_repository.js");
|
|
5
5
|
const contract_js_1 = require("./contract.js");
|
|
6
6
|
const repository_js_1 = require("../files-gen/repository.js");
|
|
7
|
-
const manager_js_1 = require("../auth/manager.js");
|
|
8
7
|
const permission_js_1 = require("../../models/permission.js");
|
|
9
8
|
const index_js_1 = require("../../errors/index.js");
|
|
10
9
|
/**
|
|
@@ -15,9 +14,15 @@ const index_js_1 = require("../../errors/index.js");
|
|
|
15
14
|
class WalletRepo extends base_repository_js_1.BaseRepository {
|
|
16
15
|
/**
|
|
17
16
|
* Creates an instance of WalletRepo initialized with the wallet contract.
|
|
17
|
+
* @param {Object} [options] - Optional configuration
|
|
18
|
+
* @param {string} [options.root] - Custom API root URL
|
|
19
|
+
* @param {AfloatAuth} [options.auth] - Auth instance to use
|
|
18
20
|
*/
|
|
19
|
-
constructor() {
|
|
20
|
-
super("wallet", contract_js_1.contract
|
|
21
|
+
constructor(props) {
|
|
22
|
+
super("wallet", contract_js_1.contract, {
|
|
23
|
+
root: props?.root,
|
|
24
|
+
auth: props?.auth,
|
|
25
|
+
});
|
|
21
26
|
}
|
|
22
27
|
/**
|
|
23
28
|
* Gets an instance of the file generation repository.
|
|
@@ -25,7 +30,7 @@ class WalletRepo extends base_repository_js_1.BaseRepository {
|
|
|
25
30
|
* @returns {AfloatFilesRepo} A new instance of AfloatFilesRepo
|
|
26
31
|
*/
|
|
27
32
|
get fileGenRepo() {
|
|
28
|
-
return new repository_js_1.AfloatFilesRepo();
|
|
33
|
+
return new repository_js_1.AfloatFilesRepo({ auth: this.auth });
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
36
|
* Retrieves the current available balance for the wallet.
|
|
@@ -34,8 +39,9 @@ class WalletRepo extends base_repository_js_1.BaseRepository {
|
|
|
34
39
|
* @returns {Promise<number>} The available balance amount
|
|
35
40
|
*/
|
|
36
41
|
async getBalance() {
|
|
42
|
+
const auth = this.getAuthForPermissionCheck();
|
|
37
43
|
const requirePerm = permission_js_1.Permissions.Wallet.ViewBalance;
|
|
38
|
-
if (!
|
|
44
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
39
45
|
throw new index_js_1.PermissionError({
|
|
40
46
|
message: "You are not authorized to view the account balance.",
|
|
41
47
|
requiredPermissions: [requirePerm],
|
|
@@ -72,8 +78,9 @@ class WalletRepo extends base_repository_js_1.BaseRepository {
|
|
|
72
78
|
* @returns {Promise<WalletStatementItem[]>} Array of statement items for the specified period
|
|
73
79
|
*/
|
|
74
80
|
async getStatement(props) {
|
|
81
|
+
const auth = this.getAuthForPermissionCheck();
|
|
75
82
|
const requirePerm = permission_js_1.Permissions.Wallet.ViewStatement;
|
|
76
|
-
if (!
|
|
83
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
77
84
|
throw new index_js_1.PermissionError({
|
|
78
85
|
message: "You are not authorized to view the statement.",
|
|
79
86
|
requiredPermissions: [requirePerm],
|
|
@@ -103,8 +110,9 @@ class WalletRepo extends base_repository_js_1.BaseRepository {
|
|
|
103
110
|
* @returns {Promise<StatementFile>} The generated statement file
|
|
104
111
|
*/
|
|
105
112
|
async genStatement(fileType, props) {
|
|
113
|
+
const auth = this.getAuthForPermissionCheck();
|
|
106
114
|
const requirePerm = permission_js_1.Permissions.Wallet.ViewStatement;
|
|
107
|
-
if (!
|
|
115
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
108
116
|
throw new index_js_1.PermissionError({
|
|
109
117
|
message: "You are not authorized to view the statement.",
|
|
110
118
|
requiredPermissions: [requirePerm],
|
|
@@ -123,8 +131,9 @@ class WalletRepo extends base_repository_js_1.BaseRepository {
|
|
|
123
131
|
* @returns {Promise<StatementFile>} The generated PDF file containing wallet details
|
|
124
132
|
*/
|
|
125
133
|
async genWalletDetailsPDF() {
|
|
134
|
+
const auth = this.getAuthForPermissionCheck();
|
|
126
135
|
const requirePerm = permission_js_1.Permissions.Wallet.ViewBalance;
|
|
127
|
-
if (!
|
|
136
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
128
137
|
throw new index_js_1.PermissionError({
|
|
129
138
|
message: "You are not authorized to view the account details.",
|
|
130
139
|
requiredPermissions: [requirePerm],
|