@pax2pay/model-banking 0.1.577 → 0.1.579

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.
Files changed (60) hide show
  1. package/Backup/User.ts +4 -4
  2. package/Client/index.ts +0 -3
  3. package/Realm.ts +2 -2
  4. package/Supplier/index.ts +1 -1
  5. package/dist/cjs/Backup/User.d.ts +4 -4
  6. package/dist/cjs/Backup/User.js.map +1 -1
  7. package/dist/cjs/Client/index.d.ts +0 -2
  8. package/dist/cjs/Client/index.js +0 -2
  9. package/dist/cjs/Client/index.js.map +1 -1
  10. package/dist/cjs/Realm.d.ts +1 -1
  11. package/dist/cjs/Realm.js +1 -1
  12. package/dist/cjs/Realm.js.map +1 -1
  13. package/dist/cjs/Supplier/index.js +1 -1
  14. package/dist/cjs/Supplier/index.js.map +1 -1
  15. package/dist/cjs/pax2pay.d.ts +0 -2
  16. package/dist/cjs/pax2pay.js +1 -5
  17. package/dist/cjs/pax2pay.js.map +1 -1
  18. package/dist/mjs/Backup/User.d.ts +4 -4
  19. package/dist/mjs/Backup/User.js.map +1 -1
  20. package/dist/mjs/Client/index.d.ts +0 -2
  21. package/dist/mjs/Client/index.js +0 -2
  22. package/dist/mjs/Client/index.js.map +1 -1
  23. package/dist/mjs/Realm.d.ts +1 -1
  24. package/dist/mjs/Realm.js +1 -1
  25. package/dist/mjs/Realm.js.map +1 -1
  26. package/dist/mjs/Supplier/index.js +1 -1
  27. package/dist/mjs/Supplier/index.js.map +1 -1
  28. package/dist/mjs/pax2pay.d.ts +0 -2
  29. package/dist/mjs/pax2pay.js +0 -2
  30. package/dist/mjs/pax2pay.js.map +1 -1
  31. package/package.json +1 -2
  32. package/pax2pay.ts +0 -2
  33. package/Identity.ts +0 -169
  34. package/Key/Permissions.ts +0 -112
  35. package/Key/Roles.ts +0 -111
  36. package/Key/index.ts +0 -40
  37. package/dist/cjs/Identity.d.ts +0 -41
  38. package/dist/cjs/Identity.js +0 -102
  39. package/dist/cjs/Identity.js.map +0 -1
  40. package/dist/cjs/Key/Permissions.d.ts +0 -95
  41. package/dist/cjs/Key/Permissions.js +0 -77
  42. package/dist/cjs/Key/Permissions.js.map +0 -1
  43. package/dist/cjs/Key/Roles.d.ts +0 -27
  44. package/dist/cjs/Key/Roles.js +0 -104
  45. package/dist/cjs/Key/Roles.js.map +0 -1
  46. package/dist/cjs/Key/index.d.ts +0 -23
  47. package/dist/cjs/Key/index.js +0 -29
  48. package/dist/cjs/Key/index.js.map +0 -1
  49. package/dist/mjs/Identity.d.ts +0 -41
  50. package/dist/mjs/Identity.js +0 -98
  51. package/dist/mjs/Identity.js.map +0 -1
  52. package/dist/mjs/Key/Permissions.d.ts +0 -95
  53. package/dist/mjs/Key/Permissions.js +0 -74
  54. package/dist/mjs/Key/Permissions.js.map +0 -1
  55. package/dist/mjs/Key/Roles.d.ts +0 -27
  56. package/dist/mjs/Key/Roles.js +0 -101
  57. package/dist/mjs/Key/Roles.js.map +0 -1
  58. package/dist/mjs/Key/index.d.ts +0 -23
  59. package/dist/mjs/Key/index.js +0 -26
  60. package/dist/mjs/Key/index.js.map +0 -1
@@ -1,112 +0,0 @@
1
- import { userwidgets } from "@userwidgets/model"
2
- import { User } from "../User"
3
-
4
- export type Permissions = Permissions.Organization | Permissions.Realm
5
- export namespace Permissions {
6
- export function stringify(permissions: Permissions): string {
7
- return userwidgets.User.Permissions.stringify(permissions)
8
- }
9
- export interface Realm extends userwidgets.User.Permissions {
10
- organizations?:
11
- | {
12
- create?: true
13
- view?: true
14
- update?: true
15
- remove?: true
16
- accounts?: { balance?: true; view?: true; create?: true; change?: true; cancel?: true } | true
17
- rules?:
18
- | {
19
- edit?: true
20
- view?: true
21
- customer?: { edit?: true; view?: true } | true
22
- product?: { edit?: true; view?: true } | true
23
- fincrime?: { edit?: true; view?: true } | true
24
- }
25
- | true
26
- }
27
- | true
28
- transactions?: { create?: true; view?: true; resolve?: true; comment?: true } | true
29
- cards?: { create?: true; view?: true; change?: true; cancel?: true } | true
30
- rules?:
31
- | {
32
- edit?: true
33
- view?: true
34
- product?: { edit?: true; view?: true } | true
35
- fincrime?: { edit?: true; view?: true } | true
36
- }
37
- | true
38
- settlements?: { create?: true; view?: true; amend?: true } | true
39
- treasury?: { rebalance?: true; view?: true } | true
40
- operations?: { view?: true } | true
41
- logs?: { view?: true } | true
42
- }
43
- export interface Organization extends userwidgets.User.Permissions {
44
- accounts?:
45
- | { balance?: true; view?: true; create?: true; change?: true; transactions?: { view?: true; create?: true } }
46
- | true
47
- cards?: { create?: true; view?: true; change?: true; cancel?: true } | true
48
- }
49
- export function from(permission: User.Access.Permission): Permissions | true {
50
- let result: Permissions | true = {}
51
- if (User.Access.Permission.Level.get(permission["*"]) >= 2)
52
- result = true
53
- else {
54
- if (permission["*"])
55
- result = {
56
- accounts: { view: true },
57
- cards: { view: true },
58
- logs: { view: true },
59
- operations: { view: true },
60
- organizations: {
61
- view: true,
62
- rules: { view: true, customer: { view: true }, product: { view: true }, fincrime: { view: true } },
63
- accounts: { view: true },
64
- },
65
- rules: {
66
- view: true,
67
- customer: { view: true },
68
- product: { view: true },
69
- fincrime: { view: true },
70
- },
71
- settlements: { view: true },
72
- transactions: { view: true },
73
- treasury: { view: true },
74
- org: { view: true },
75
- user: User.Access.Permission.Level.get(permission["user"]) >= 2 || { view: true },
76
- app: { view: true },
77
- }
78
- if (permission["card"])
79
- result.cards = User.Access.Permission.Level.get(permission["card"]) >= 2 || {
80
- view: true,
81
- }
82
- if (permission["log"])
83
- result.logs = User.Access.Permission.Level.get(permission["log"]) >= 2 || {
84
- view: true,
85
- }
86
- if (permission["operation"])
87
- result.operations = User.Access.Permission.Level.get(permission["operation"]) >= 2 || {
88
- view: true,
89
- }
90
- if (permission["organization"])
91
- result.organizations = User.Access.Permission.Level.get(permission["organization"]) >= 2 || {
92
- view: true,
93
- rules: { view: true, customer: { view: true }, product: { view: true }, fincrime: { view: true } },
94
- accounts: { view: true },
95
- }
96
- if (permission["rule"])
97
- result.rules = User.Access.Permission.Level.get(permission["rule"]) >= 2 || {
98
- view: true,
99
- customer: { view: true },
100
- product: { view: true },
101
- fincrime: { view: true },
102
- }
103
- if (permission["settlement"])
104
- result.settlements = User.Access.Permission.Level.get(permission["settlement"]) >= 2 || { view: true }
105
- if (permission["transaction"])
106
- result.transactions = User.Access.Permission.Level.get(permission["transaction"]) >= 2 || { view: true }
107
- if (permission["treasury"])
108
- result.treasury = User.Access.Permission.Level.get(permission["treasury"]) >= 2 || { view: true }
109
- }
110
- return result
111
- }
112
- }
package/Key/Roles.ts DELETED
@@ -1,111 +0,0 @@
1
- import { userwidgets } from "@userwidgets/model"
2
- import { isly } from "isly"
3
- import { Realm } from "../Realm"
4
- import { Permissions } from "./Permissions"
5
-
6
- type OrganizationCode = string
7
- export type Roles =
8
- | Partial<Record<`${Realm | "*"}-*`, (Roles.Realm.Role | Roles.Organization.Role)[]>>
9
- | Partial<Record<`${Realm | "*"}-${OrganizationCode}`, Roles.Organization.Role[]>>
10
- export namespace Roles {
11
- export type Role = Realm.Role | Organization.Role
12
- export function get(realmOrganization: string) {
13
- const [realm] = realmOrganization.split("-")
14
- return [
15
- ...Object.entries(Realm.definitions).map(([role, value]) => ({
16
- label: "realm-" + role,
17
- permissions: () => Permissions.stringify({ [realm + "-*"]: value }),
18
- })),
19
- ...Object.entries(Organization.definitions).map(([role, value]) => ({
20
- label: "organization-" + role,
21
- permissions: (id: string) => Permissions.stringify({ [id]: value }),
22
- })),
23
- ]
24
- }
25
- export function resolve(roles: Roles): Permissions {
26
- let result = {}
27
- for (const [key, role] of Object.entries(roles)) {
28
- const [, organizationCode] = key.split("-")
29
- result =
30
- role?.reduce(
31
- (r, role) =>
32
- userwidgets.User.Permissions.merge(r, {
33
- [key]:
34
- organizationCode == "*" && Realm.type.is(role)
35
- ? Realm.definitions[role]
36
- : Organization.definitions[role as Organization.Role],
37
- }),
38
- result
39
- ) ?? result
40
- }
41
- return result
42
- }
43
- export namespace Realm {
44
- export type Roles = Partial<Record<Role, true>>
45
- export type Role = typeof roles[number]
46
- export const roles = ["admin", "fincrime-readonly", "fincrime", "finance", "operations", "support"] as const
47
- export const type = isly.string(roles)
48
- export const definitions: Record<Role, Permissions.Realm | true> = {
49
- admin: true,
50
- "fincrime-readonly": {
51
- organizations: {
52
- view: true,
53
- accounts: { view: true },
54
- rules: { view: true },
55
- },
56
- transactions: { view: true },
57
- cards: { view: true },
58
- rules: { view: true },
59
- },
60
- fincrime: {
61
- organizations: {
62
- view: true,
63
- accounts: { balance: true, view: true },
64
- rules: true,
65
- },
66
- transactions: { view: true, resolve: true, comment: true },
67
- cards: { view: true, cancel: true },
68
- rules: true,
69
- },
70
- finance: {
71
- treasury: { rebalance: true, view: true },
72
- settlements: { view: true },
73
- },
74
- operations: {
75
- organizations: {
76
- create: true,
77
- update: true,
78
- accounts: true,
79
- rules: true,
80
- },
81
- },
82
- support: {
83
- organizations: {
84
- create: true,
85
- view: true,
86
- accounts: true,
87
- rules: {
88
- view: true,
89
- edit: true,
90
- },
91
- },
92
- transactions: { view: true },
93
- cards: { view: true, cancel: true },
94
- rules: { view: true },
95
- },
96
- }
97
- }
98
- export namespace Organization {
99
- export type Roles = Partial<Record<Role, true>>
100
- export type Role = typeof roles[number]
101
- export const roles = ["admin", "finance", "payments"] as const
102
- export const definitions: Record<Role, Permissions.Organization | true> = {
103
- admin: true,
104
- finance: {
105
- accounts: { balance: true, view: true, transactions: { view: true, create: true } },
106
- cards: true,
107
- },
108
- payments: { cards: true, accounts: { view: true, transactions: { create: true } } },
109
- }
110
- }
111
- }
package/Key/index.ts DELETED
@@ -1,40 +0,0 @@
1
- import { isoly } from "isoly"
2
- import { userwidgets } from "@userwidgets/model"
3
- import { Realm } from "../Realm"
4
- import { User } from "../User"
5
- import { Permissions as KeyPermissions } from "./Permissions"
6
- import { Roles as KeyRoles } from "./Roles"
7
-
8
- type Claims = {
9
- organization: string
10
- realm: Realm
11
- }
12
-
13
- export type Key = userwidgets.User.Key<userwidgets.User.Key.Creatable.Claims | Claims, Key.Permissions>
14
- export namespace Key {
15
- export import Permissions = KeyPermissions
16
- export type Roles = KeyRoles
17
- export const Roles = KeyRoles
18
- export namespace Roles {
19
- export type Role = KeyRoles.Role
20
- export namespace Organization {
21
- export type Role = KeyRoles.Organization.Role
22
- }
23
- }
24
- export function from(payload: User.JWT.Payload, token: string): Key {
25
- return {
26
- audience: payload.aud,
27
- email: payload.sub,
28
- realm: payload.realm,
29
- permissions: {
30
- [payload.realm + "-*"]: Permissions.from(payload.permission),
31
- ...(payload.permission.user ? { ["*"]: true } : {}),
32
- },
33
- expires: payload.exp ? isoly.DateTime.create(payload.exp) : isoly.DateTime.nextYear(isoly.DateTime.now(), 10),
34
- issued: isoly.DateTime.create(payload.iat),
35
- issuer: payload.iss,
36
- name: { first: "", last: "" },
37
- token,
38
- }
39
- }
40
- }
@@ -1,41 +0,0 @@
1
- import { gracely } from "gracely";
2
- import { storage } from "cloudly-storage";
3
- import { slackly } from "slackly";
4
- import { Key } from "./Key";
5
- import { Realm } from "./Realm";
6
- import { User } from "./User";
7
- export declare class Identity<T extends Identity.Require = never> {
8
- #private;
9
- readonly key: Key;
10
- readonly realm: T["realm"] extends true ? Realm : Realm | undefined;
11
- readonly organization: T["organization"] extends true ? string : string | undefined;
12
- get realms(): Realm[] | undefined;
13
- constructor(key: Key, realm: T["realm"] extends true ? Realm : Realm | undefined, organization: T["organization"] extends true ? string : string | undefined);
14
- check(constraint: Key.Permissions | Key.Permissions[], realm?: Realm, organization?: string): boolean;
15
- collectionCheck(collection: string): boolean;
16
- static authenticate<T extends Identity.Require = Record<string, never>>(header: Identity.Header, constraint: Key.Permissions | Key.Permissions[], requires?: T, key?: string, output?: "undefined", notify?: Identity.Notify, store?: storage.KeyValueStore<User.JWT.Payload.LongTerm>): Promise<Identity<T> | undefined>;
17
- static authenticate<T extends Identity.Require = Record<string, never>>(header: {
18
- authorization?: string | undefined;
19
- realm?: Realm;
20
- organization?: string;
21
- }, constraint: Key.Permissions | Key.Permissions[], requires?: T, key?: string, output?: "error", notify?: Identity.Notify, store?: storage.KeyValueStore<User.JWT.Payload.LongTerm>): Promise<Identity<T> | gracely.Error>;
22
- static verify(authorization: string | undefined, key?: string, store?: storage.KeyValueStore<User.JWT.Payload.LongTerm>): Promise<Key | undefined>;
23
- static getRealm(header: Identity.Header, key?: string): Promise<Realm | undefined>;
24
- static getRealms(permissions: Key.Permissions): Realm[];
25
- }
26
- export declare namespace Identity {
27
- type Require = {
28
- realm?: true;
29
- organization?: true;
30
- };
31
- interface Header {
32
- authorization?: string | undefined;
33
- realm?: Realm;
34
- organization?: string;
35
- }
36
- type Notify = {
37
- slack: slackly.Connection<"notifications">;
38
- endpoint: string;
39
- method: string;
40
- };
41
- }
@@ -1,102 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Identity = void 0;
4
- const gracely_1 = require("gracely");
5
- const model_1 = require("@userwidgets/model");
6
- const Key_1 = require("./Key");
7
- const Realm_1 = require("./Realm");
8
- const User_1 = require("./User");
9
- class Identity {
10
- key;
11
- realm;
12
- organization;
13
- #realms;
14
- get realms() {
15
- return (this.#realms ??= Identity.getRealms(this.key.permissions));
16
- }
17
- constructor(key, realm, organization) {
18
- this.key = key;
19
- this.realm = realm;
20
- this.organization = organization;
21
- }
22
- check(constraint, realm, organization) {
23
- return Array.isArray(constraint)
24
- ? constraint.some(c => this.check(c, realm, organization))
25
- : [
26
- { [`${realm ?? this.realm}-${organization ?? this.organization}`]: constraint },
27
- { [`${organization ?? this.organization}`]: constraint },
28
- { [`${realm ?? this.realm}-*`]: constraint },
29
- { [`*-*`]: constraint },
30
- ].some(e => model_1.userwidgets.User.Permissions.check(this.key.permissions, e));
31
- }
32
- collectionCheck(collection) {
33
- return Object.values(this.key.permissions).some(value => (typeof value == "object" && value[collection]) || value == true);
34
- }
35
- static async authenticate(header, constraint, requires, key = publicKey, output = "undefined", notify, store) {
36
- let result;
37
- const authorization = header.authorization?.startsWith("Bearer ")
38
- ? header.authorization.replace("Bearer ", "")
39
- : undefined;
40
- const verified = await Identity.verify(authorization, key, store);
41
- if (!verified)
42
- output !== "undefined" && (result = gracely_1.gracely.client.unauthorized());
43
- else {
44
- const realms = Identity.getRealms(verified.permissions);
45
- const identity = new Identity(verified, ((realms.length == 1 ? realms[0] : header.realm && realms.includes(header.realm) ? header.realm : undefined) ??
46
- verified.realm), (verified.organization ?? header.organization));
47
- const requirement = (value) => (requires?.organization ? !!identity?.organization : true) &&
48
- (requires?.realm ? Realm_1.Realm.type.is(identity?.realm) : true);
49
- if (identity?.check(constraint) && requirement(identity))
50
- result = identity;
51
- else if (output === "undefined")
52
- result = undefined;
53
- else {
54
- await notify?.slack.send("notifications", `Unauthorized access attempt at ${notify.method.toUpperCase()} ${notify.endpoint}`);
55
- console.log(identity.key.email, "unauthorized access attempt at", notify?.method.toUpperCase(), notify?.endpoint);
56
- result = gracely_1.gracely.client.forbidden();
57
- }
58
- }
59
- return result;
60
- }
61
- static async verify(authorization, key = publicKey, store) {
62
- const verifier = model_1.userwidgets.User.Key.Verifier.create(key);
63
- const jwt = User_1.User.JWT.open({ public: key }, store);
64
- const unpacked = authorization ? await jwt.unpack(authorization) : undefined;
65
- let verified;
66
- if (User_1.User.JWT.Payload.type.is(unpacked) && authorization) {
67
- const payload = await jwt.verify(authorization);
68
- verified = payload && Key_1.Key.from(payload, authorization);
69
- }
70
- else
71
- verified = await verifier.verify(authorization);
72
- return verified;
73
- }
74
- static async getRealm(header, key = publicKey) {
75
- let result;
76
- const authorization = header.authorization?.startsWith("Bearer ")
77
- ? header.authorization.replace("Bearer ", "")
78
- : undefined;
79
- const jwt = User_1.User.JWT.open({ public: key });
80
- const unpacked = authorization ? await jwt.unpack(authorization) : undefined;
81
- if (User_1.User.JWT.Payload.type.is(unpacked))
82
- result = unpacked.realm;
83
- else {
84
- const verified = await model_1.userwidgets.User.Key.Verifier.create(key).verify(authorization);
85
- const realms = verified && Identity.getRealms(verified.permissions);
86
- result =
87
- realms &&
88
- (realms.length == 1 ? realms[0] : header.realm && realms.includes(header.realm) ? header.realm : undefined);
89
- }
90
- return result;
91
- }
92
- static getRealms(permissions) {
93
- return [
94
- ...new Set(Object.keys(permissions).flatMap(code => code.split("-").length > 1 && code.split("-")[0] == "*"
95
- ? Realm_1.Realm.realms
96
- : Realm_1.Realm.type.get(code.split("-")[0]) ?? [])),
97
- ];
98
- }
99
- }
100
- exports.Identity = Identity;
101
- const publicKey = "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA2W8CD2kpfS4QIRV2/rgm4NVvsvJsYNMHtnIl9ADvO3A81hAmRKvOAPVoXICe6+EuZ47jGjGL7f48GEoQuITfBPv/MosCDj1YhJ56ILDynCSd8FlxDrhv8pl5IquST7tcL6Hc6m+vuvoTLrFQ5QqNxv0a5eDd/YTrWv7SUuRfBEhYd/wMysGynN3QauHqy5ceBCt1nv1MJLGlSzczMRK7wjy1zi2g9NCHZBOoo1HXOpi727Xh+YXHc9EP2TN0oOXyxykv45nkGIDI0Qek3/pfkavClBffc1sEqA+rUx7YqRN9KGYxwLMLug+NOOh3ptqjfobXbR5fx/sUWhvcjUMTE1JreTrWYbGmVnjd/SeYSClfmGhdTBUfqnZbaABv0ruTXva18qRhP4y143vHMk/k8HzbuROTKAzrtEeLIjgwUgDcnE+JwDqcb8tKSGV6i++TiTldlSBCRTT4dK2hpHJje80b2abqtrbCkxbJlT98UsAAoiq2eW1X6lYmCfiGCJPkfswibQ2tPAKKNe/2xuHPsjx4FuXGmV0dbzmCwSIQoApXqOvKzoNFi6AaKIjxfNmiEigLwKpNrw08H0lVZbq/9MMxI3TzMTZjY9QmBKVLSGy3Z6IJqZpyK22lv7whJcllG0Qw8tv8+7wmC8SR3+4jpuxuFGZ+69CW+otx+CPMJjcCAwEAAQ==";
102
- //# sourceMappingURL=Identity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Identity.js","sourceRoot":"","sources":["../../Identity.ts"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YACL,MAAM,QAAQ,GAAG,MAAM,mBAAW,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAM,GAAG,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;YAC3F,MAAM,MAAM,GAAG,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;YACnE,MAAM;gBACL,MAAM;oBACN,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QAC7G,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IACD,MAAM,CAAC,SAAS,CAAC,WAA4B;QAC5C,OAAO;YACN,GAAG,IAAI,GAAG,CACT,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CACvC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG;gBACtD,CAAC,CAAC,aAAK,CAAC,MAAM;gBACd,CAAC,CAAC,aAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAC3C,CACD;SACD,CAAA;IACF,CAAC;CACD;AA7ID,4BA6IC;AAkBD,MAAM,SAAS,GACd,kuBAAkuB,CAAA"}
@@ -1,95 +0,0 @@
1
- import { userwidgets } from "@userwidgets/model";
2
- import { User } from "../User";
3
- export type Permissions = Permissions.Organization | Permissions.Realm;
4
- export declare namespace Permissions {
5
- function stringify(permissions: Permissions): string;
6
- interface Realm extends userwidgets.User.Permissions {
7
- organizations?: {
8
- create?: true;
9
- view?: true;
10
- update?: true;
11
- remove?: true;
12
- accounts?: {
13
- balance?: true;
14
- view?: true;
15
- create?: true;
16
- change?: true;
17
- cancel?: true;
18
- } | true;
19
- rules?: {
20
- edit?: true;
21
- view?: true;
22
- customer?: {
23
- edit?: true;
24
- view?: true;
25
- } | true;
26
- product?: {
27
- edit?: true;
28
- view?: true;
29
- } | true;
30
- fincrime?: {
31
- edit?: true;
32
- view?: true;
33
- } | true;
34
- } | true;
35
- } | true;
36
- transactions?: {
37
- create?: true;
38
- view?: true;
39
- resolve?: true;
40
- comment?: true;
41
- } | true;
42
- cards?: {
43
- create?: true;
44
- view?: true;
45
- change?: true;
46
- cancel?: true;
47
- } | true;
48
- rules?: {
49
- edit?: true;
50
- view?: true;
51
- product?: {
52
- edit?: true;
53
- view?: true;
54
- } | true;
55
- fincrime?: {
56
- edit?: true;
57
- view?: true;
58
- } | true;
59
- } | true;
60
- settlements?: {
61
- create?: true;
62
- view?: true;
63
- amend?: true;
64
- } | true;
65
- treasury?: {
66
- rebalance?: true;
67
- view?: true;
68
- } | true;
69
- operations?: {
70
- view?: true;
71
- } | true;
72
- logs?: {
73
- view?: true;
74
- } | true;
75
- }
76
- interface Organization extends userwidgets.User.Permissions {
77
- accounts?: {
78
- balance?: true;
79
- view?: true;
80
- create?: true;
81
- change?: true;
82
- transactions?: {
83
- view?: true;
84
- create?: true;
85
- };
86
- } | true;
87
- cards?: {
88
- create?: true;
89
- view?: true;
90
- change?: true;
91
- cancel?: true;
92
- } | true;
93
- }
94
- function from(permission: User.Access.Permission): Permissions | true;
95
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Permissions = void 0;
4
- const model_1 = require("@userwidgets/model");
5
- const User_1 = require("../User");
6
- var Permissions;
7
- (function (Permissions) {
8
- function stringify(permissions) {
9
- return model_1.userwidgets.User.Permissions.stringify(permissions);
10
- }
11
- Permissions.stringify = stringify;
12
- function from(permission) {
13
- let result = {};
14
- if (User_1.User.Access.Permission.Level.get(permission["*"]) >= 2)
15
- result = true;
16
- else {
17
- if (permission["*"])
18
- result = {
19
- accounts: { view: true },
20
- cards: { view: true },
21
- logs: { view: true },
22
- operations: { view: true },
23
- organizations: {
24
- view: true,
25
- rules: { view: true, customer: { view: true }, product: { view: true }, fincrime: { view: true } },
26
- accounts: { view: true },
27
- },
28
- rules: {
29
- view: true,
30
- customer: { view: true },
31
- product: { view: true },
32
- fincrime: { view: true },
33
- },
34
- settlements: { view: true },
35
- transactions: { view: true },
36
- treasury: { view: true },
37
- org: { view: true },
38
- user: User_1.User.Access.Permission.Level.get(permission["user"]) >= 2 || { view: true },
39
- app: { view: true },
40
- };
41
- if (permission["card"])
42
- result.cards = User_1.User.Access.Permission.Level.get(permission["card"]) >= 2 || {
43
- view: true,
44
- };
45
- if (permission["log"])
46
- result.logs = User_1.User.Access.Permission.Level.get(permission["log"]) >= 2 || {
47
- view: true,
48
- };
49
- if (permission["operation"])
50
- result.operations = User_1.User.Access.Permission.Level.get(permission["operation"]) >= 2 || {
51
- view: true,
52
- };
53
- if (permission["organization"])
54
- result.organizations = User_1.User.Access.Permission.Level.get(permission["organization"]) >= 2 || {
55
- view: true,
56
- rules: { view: true, customer: { view: true }, product: { view: true }, fincrime: { view: true } },
57
- accounts: { view: true },
58
- };
59
- if (permission["rule"])
60
- result.rules = User_1.User.Access.Permission.Level.get(permission["rule"]) >= 2 || {
61
- view: true,
62
- customer: { view: true },
63
- product: { view: true },
64
- fincrime: { view: true },
65
- };
66
- if (permission["settlement"])
67
- result.settlements = User_1.User.Access.Permission.Level.get(permission["settlement"]) >= 2 || { view: true };
68
- if (permission["transaction"])
69
- result.transactions = User_1.User.Access.Permission.Level.get(permission["transaction"]) >= 2 || { view: true };
70
- if (permission["treasury"])
71
- result.treasury = User_1.User.Access.Permission.Level.get(permission["treasury"]) >= 2 || { view: true };
72
- }
73
- return result;
74
- }
75
- Permissions.from = from;
76
- })(Permissions || (exports.Permissions = Permissions = {}));
77
- //# sourceMappingURL=Permissions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Permissions.js","sourceRoot":"","sources":["../../../Key/Permissions.ts"],"names":[],"mappings":";;;AAAA,8CAAgD;AAChD,kCAA8B;AAG9B,IAAiB,WAAW,CA2G3B;AA3GD,WAAiB,WAAW;IAC3B,SAAgB,SAAS,CAAC,WAAwB;QACjD,OAAO,mBAAW,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IAC3D,CAAC;IAFe,qBAAS,YAExB,CAAA;IAyCD,SAAgB,IAAI,CAAC,UAAkC;QACtD,IAAI,MAAM,GAAuB,EAAE,CAAA;QACnC,IAAI,WAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACzD,MAAM,GAAG,IAAI,CAAA;aACT,CAAC;YACL,IAAI,UAAU,CAAC,GAAG,CAAC;gBAClB,MAAM,GAAG;oBACR,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;oBACxB,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;oBACrB,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;oBACpB,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;oBAC1B,aAAa,EAAE;wBACd,IAAI,EAAE,IAAI;wBACV,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;wBAClG,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;qBACxB;oBACD,KAAK,EAAE;wBACN,IAAI,EAAE,I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AA;YACzG,IAAI,UAAU,CAAC,UAAU,CAAC;gBACzB,MAAM,CAAC,QAAQ,GAAG,WAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QACnG,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IA9De,gBAAI,OA8DnB,CAAA;AACF,CAAC,EA3GgB,WAAW,2BAAX,WAAW,QA2G3B"}
@@ -1,27 +0,0 @@
1
- import { isly } from "isly";
2
- import { Realm } from "../Realm";
3
- import { Permissions } from "./Permissions";
4
- type OrganizationCode = string;
5
- export type Roles = Partial<Record<`${Realm | "*"}-*`, (Roles.Realm.Role | Roles.Organization.Role)[]>> | Partial<Record<`${Realm | "*"}-${OrganizationCode}`, Roles.Organization.Role[]>>;
6
- export declare namespace Roles {
7
- type Role = Realm.Role | Organization.Role;
8
- function get(realmOrganization: string): {
9
- label: string;
10
- permissions: (id: string) => string;
11
- }[];
12
- function resolve(roles: Roles): Permissions;
13
- namespace Realm {
14
- type Roles = Partial<Record<Role, true>>;
15
- type Role = typeof roles[number];
16
- const roles: readonly ["admin", "fincrime-readonly", "fincrime", "finance", "operations", "support"];
17
- const type: isly.Type<"fincrime" | "operations" | "admin" | "fincrime-readonly" | "finance" | "support">;
18
- const definitions: Record<Role, Permissions.Realm | true>;
19
- }
20
- namespace Organization {
21
- type Roles = Partial<Record<Role, true>>;
22
- type Role = typeof roles[number];
23
- const roles: readonly ["admin", "finance", "payments"];
24
- const definitions: Record<Role, Permissions.Organization | true>;
25
- }
26
- }
27
- export {};