@pax2pay/model-banking 0.1.511 → 0.1.512
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/Client/Users/Invites.ts +20 -0
- package/Client/Users/index.ts +31 -0
- package/Client/index.ts +15 -12
- package/Identity.ts +20 -14
- package/Key/Permissions.ts +46 -0
- package/Key/index.ts +16 -5
- package/User/Access/Permission.ts +1 -1
- package/User/Identity.ts +2 -2
- package/User/JWT/index.ts +3 -1
- package/User/JWT/whitelist.ts +16 -0
- package/dist/cjs/Client/Users/Invites.d.ts +11 -0
- package/dist/cjs/Client/Users/Invites.js +23 -0
- package/dist/cjs/Client/Users/Invites.js.map +1 -0
- package/dist/cjs/Client/Users/index.d.ts +16 -0
- package/dist/cjs/Client/Users/index.js +34 -0
- package/dist/cjs/Client/Users/index.js.map +1 -0
- package/dist/cjs/Client/index.d.ts +8 -6
- package/dist/cjs/Client/index.js +15 -12
- package/dist/cjs/Client/index.js.map +1 -1
- package/dist/cjs/Identity.d.ts +3 -4
- package/dist/cjs/Identity.js +19 -8
- package/dist/cjs/Identity.js.map +1 -1
- package/dist/cjs/Key/Permissions.d.ts +2 -0
- package/dist/cjs/Key/Permissions.js +47 -0
- package/dist/cjs/Key/Permissions.js.map +1 -1
- package/dist/cjs/Key/index.d.ts +3 -5
- package/dist/cjs/Key/index.js +17 -0
- package/dist/cjs/Key/index.js.map +1 -1
- package/dist/cjs/User/Access/Permission.d.ts +4 -4
- package/dist/cjs/User/Access/Permission.js +1 -1
- package/dist/cjs/User/Access/Permission.js.map +1 -1
- package/dist/cjs/User/Identity.d.ts +1 -2
- package/dist/cjs/User/Identity.js +2 -4
- package/dist/cjs/User/Identity.js.map +1 -1
- package/dist/cjs/User/JWT/index.d.ts +1 -0
- package/dist/cjs/User/JWT/index.js +3 -1
- package/dist/cjs/User/JWT/index.js.map +1 -1
- package/dist/cjs/User/JWT/whitelist.d.ts +2 -0
- package/dist/cjs/User/JWT/whitelist.js +17 -0
- package/dist/cjs/User/JWT/whitelist.js.map +1 -0
- package/dist/mjs/Client/Users/Invites.d.ts +11 -0
- package/dist/mjs/Client/Users/Invites.js +19 -0
- package/dist/mjs/Client/Users/Invites.js.map +1 -0
- package/dist/mjs/Client/Users/index.d.ts +16 -0
- package/dist/mjs/Client/Users/index.js +30 -0
- package/dist/mjs/Client/Users/index.js.map +1 -0
- package/dist/mjs/Client/index.d.ts +8 -6
- package/dist/mjs/Client/index.js +15 -12
- package/dist/mjs/Client/index.js.map +1 -1
- package/dist/mjs/Identity.d.ts +3 -4
- package/dist/mjs/Identity.js +19 -8
- package/dist/mjs/Identity.js.map +1 -1
- package/dist/mjs/Key/Permissions.d.ts +2 -0
- package/dist/mjs/Key/Permissions.js +47 -0
- package/dist/mjs/Key/Permissions.js.map +1 -1
- package/dist/mjs/Key/index.d.ts +3 -5
- package/dist/mjs/Key/index.js +17 -0
- package/dist/mjs/Key/index.js.map +1 -1
- package/dist/mjs/User/Access/Permission.d.ts +4 -4
- package/dist/mjs/User/Access/Permission.js +1 -1
- package/dist/mjs/User/Access/Permission.js.map +1 -1
- package/dist/mjs/User/Identity.d.ts +1 -2
- package/dist/mjs/User/Identity.js +2 -4
- package/dist/mjs/User/Identity.js.map +1 -1
- package/dist/mjs/User/JWT/index.d.ts +1 -0
- package/dist/mjs/User/JWT/index.js +3 -1
- package/dist/mjs/User/JWT/index.js.map +1 -1
- package/dist/mjs/User/JWT/whitelist.d.ts +2 -0
- package/dist/mjs/User/JWT/whitelist.js +14 -0
- package/dist/mjs/User/JWT/whitelist.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { gracely } from "gracely"
|
|
2
|
+
import { http } from "cloudly-http"
|
|
3
|
+
import { User } from "../../User"
|
|
4
|
+
|
|
5
|
+
export class Invites {
|
|
6
|
+
constructor(private readonly client: http.Client) {}
|
|
7
|
+
|
|
8
|
+
async create(creatable: User.Invite.Creatable): Promise<User | gracely.Error> {
|
|
9
|
+
return await this.client.post<User>("/user/invite", creatable)
|
|
10
|
+
}
|
|
11
|
+
async fetch(identifier: string): Promise<User | gracely.Error> {
|
|
12
|
+
return await this.client.get<User>(`/user/invite/${identifier}`)
|
|
13
|
+
}
|
|
14
|
+
async list(): Promise<User[] | gracely.Error> {
|
|
15
|
+
return await this.client.get<User[]>("/user/invite")
|
|
16
|
+
}
|
|
17
|
+
async remove(identifier: string): Promise<User | gracely.Error> {
|
|
18
|
+
return await this.client.delete<User>(`/user/invite/:${identifier}`)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { gracely } from "gracely"
|
|
2
|
+
import { http } from "cloudly-http"
|
|
3
|
+
import { User } from "../../User"
|
|
4
|
+
import { Invites } from "./Invites"
|
|
5
|
+
|
|
6
|
+
export class Users {
|
|
7
|
+
#invites?: Invites
|
|
8
|
+
get invites(): Invites {
|
|
9
|
+
return (this.#invites ??= new Invites(this.client))
|
|
10
|
+
}
|
|
11
|
+
constructor(private readonly client: http.Client) {}
|
|
12
|
+
|
|
13
|
+
async create(user: User.Creatable): Promise<User | gracely.Error> {
|
|
14
|
+
return await this.client.post<User>("/user", user)
|
|
15
|
+
}
|
|
16
|
+
async fetch(email: string): Promise<User | gracely.Error> {
|
|
17
|
+
return await this.client.get<User>(`/user/${email}`)
|
|
18
|
+
}
|
|
19
|
+
async list(): Promise<User[] | gracely.Error> {
|
|
20
|
+
return await this.client.get<User[]>("/user")
|
|
21
|
+
}
|
|
22
|
+
async remove(email: string): Promise<User | gracely.Error> {
|
|
23
|
+
return await this.client.delete<User>(`/user/${email}`)
|
|
24
|
+
}
|
|
25
|
+
async updatePassword(email: string, creatable: User.Password.Creatable): Promise<User | gracely.Error> {
|
|
26
|
+
return await this.client.put<User>(`/user/${email}/password`, creatable)
|
|
27
|
+
}
|
|
28
|
+
async updateAccess(email: string, access: User.Access): Promise<User | gracely.Error> {
|
|
29
|
+
return await this.client.put<User>(`/user/${email}/access`, access)
|
|
30
|
+
}
|
|
31
|
+
}
|
package/Client/index.ts
CHANGED
|
@@ -15,26 +15,28 @@ import { Rules } from "./Rules"
|
|
|
15
15
|
import { Settlements } from "./Settlements"
|
|
16
16
|
import { Transactions as ClientTransactions } from "./Transactions"
|
|
17
17
|
import { Treasury } from "./Treasury"
|
|
18
|
+
import { Users } from "./Users"
|
|
18
19
|
import { Version } from "./Version"
|
|
19
20
|
|
|
20
21
|
export class Client {
|
|
21
22
|
realm?: string
|
|
22
23
|
organization?: string
|
|
23
24
|
readonly accounts: Accounts
|
|
25
|
+
readonly audits: Audit
|
|
24
26
|
readonly cards: Cards
|
|
25
|
-
readonly operations: Operations
|
|
26
27
|
readonly exchanges: Exchanges
|
|
28
|
+
readonly flags: Labels
|
|
29
|
+
readonly groups: Labels
|
|
30
|
+
readonly logs: Logs
|
|
31
|
+
readonly operations: Operations
|
|
27
32
|
readonly organizations: Organizations
|
|
33
|
+
readonly processors: Processor
|
|
28
34
|
readonly reports: Reports
|
|
29
|
-
readonly audits: Audit
|
|
30
|
-
readonly logs: Logs
|
|
31
35
|
readonly rules: Rules
|
|
32
36
|
readonly settlements: Settlements
|
|
33
37
|
readonly transactions: ClientTransactions
|
|
34
38
|
readonly treasury: Treasury
|
|
35
|
-
readonly
|
|
36
|
-
readonly groups: Labels
|
|
37
|
-
readonly processors: Processor
|
|
39
|
+
readonly users: Users
|
|
38
40
|
readonly version: Version
|
|
39
41
|
set key(value: string | undefined) {
|
|
40
42
|
this.client.key = value
|
|
@@ -51,20 +53,21 @@ export class Client {
|
|
|
51
53
|
private constructor(private readonly client: http.Client<gracely.Error>) {
|
|
52
54
|
this.client.onUnauthorized = async () => this.onUnauthorized != undefined && (await this.onUnauthorized(this))
|
|
53
55
|
this.accounts = new Accounts(this.client)
|
|
56
|
+
this.audits = new Audit(this.client)
|
|
54
57
|
this.cards = new Cards(this.client)
|
|
55
|
-
this.operations = new Operations(this.client)
|
|
56
58
|
this.exchanges = new Exchanges(this.client)
|
|
59
|
+
this.flags = new Labels(this.client, "flag")
|
|
60
|
+
this.groups = new Labels(this.client, "group")
|
|
61
|
+
this.logs = new Logs(this.client)
|
|
62
|
+
this.operations = new Operations(this.client)
|
|
57
63
|
this.organizations = new Organizations(this.client)
|
|
64
|
+
this.processors = new Processor(this.client)
|
|
58
65
|
this.reports = new Reports(this.client)
|
|
59
|
-
this.audits = new Audit(this.client)
|
|
60
|
-
this.logs = new Logs(this.client)
|
|
61
66
|
this.rules = new Rules(this.client)
|
|
62
67
|
this.settlements = new Settlements(this.client)
|
|
63
68
|
this.transactions = new ClientTransactions(this.client)
|
|
64
69
|
this.treasury = new Treasury(this.client)
|
|
65
|
-
this.
|
|
66
|
-
this.groups = new Labels(this.client, "group")
|
|
67
|
-
this.processors = new Processor(this.client)
|
|
70
|
+
this.users = new Users(this.client)
|
|
68
71
|
this.version = new Version(this.client)
|
|
69
72
|
}
|
|
70
73
|
readonly userwidgets = (server: string, application: string) =>
|
package/Identity.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { userwidgets } from "@userwidgets/model"
|
|
|
3
3
|
import { slackly } from "slackly"
|
|
4
4
|
import { Key } from "./Key"
|
|
5
5
|
import { Realm } from "./Realm"
|
|
6
|
+
import { User } from "./User"
|
|
6
7
|
|
|
7
8
|
export class Identity<T extends Identity.Require = never> {
|
|
8
9
|
#realms: Realm[] | undefined
|
|
@@ -35,7 +36,7 @@ export class Identity<T extends Identity.Require = never> {
|
|
|
35
36
|
header: Identity.Header,
|
|
36
37
|
constraint: Key.Permissions | Key.Permissions[],
|
|
37
38
|
requires?: T,
|
|
38
|
-
|
|
39
|
+
key?: string,
|
|
39
40
|
output?: "undefined",
|
|
40
41
|
notify?: Identity.Notify
|
|
41
42
|
): Promise<Identity<T> | undefined>
|
|
@@ -43,7 +44,7 @@ export class Identity<T extends Identity.Require = never> {
|
|
|
43
44
|
header: { authorization?: string | undefined; realm?: Realm; organization?: string },
|
|
44
45
|
constraint: Key.Permissions | Key.Permissions[],
|
|
45
46
|
requires?: T,
|
|
46
|
-
|
|
47
|
+
key?: string,
|
|
47
48
|
output?: "error",
|
|
48
49
|
notify?: Identity.Notify
|
|
49
50
|
): Promise<Identity<T> | gracely.Error>
|
|
@@ -51,7 +52,7 @@ export class Identity<T extends Identity.Require = never> {
|
|
|
51
52
|
header: { authorization?: string | undefined; realm?: Realm; organization?: string },
|
|
52
53
|
constraint: Key.Permissions | Key.Permissions[],
|
|
53
54
|
requires?: T,
|
|
54
|
-
|
|
55
|
+
key: string = publicKey,
|
|
55
56
|
output: "error" | "undefined" = "undefined",
|
|
56
57
|
notify?: Identity.Notify
|
|
57
58
|
): Promise<Identity<T> | (gracely.Error | undefined)> {
|
|
@@ -59,15 +60,15 @@ export class Identity<T extends Identity.Require = never> {
|
|
|
59
60
|
const authorization = header.authorization?.startsWith("Bearer ")
|
|
60
61
|
? header.authorization.replace("Bearer ", "")
|
|
61
62
|
: undefined
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
63
|
+
const verified = await Identity.verify(authorization, key)
|
|
64
|
+
if (!verified)
|
|
64
65
|
output !== "undefined" && (result = gracely.client.unauthorized())
|
|
65
66
|
else {
|
|
66
|
-
const realms = Identity.getRealms(
|
|
67
|
+
const realms = Identity.getRealms(verified.permissions)
|
|
67
68
|
const identity = new Identity(
|
|
68
|
-
|
|
69
|
+
verified,
|
|
69
70
|
(realms?.length == 1 ? realms[0] : header.realm) as Realm,
|
|
70
|
-
(
|
|
71
|
+
(verified.organization ?? header.organization) as string
|
|
71
72
|
)
|
|
72
73
|
const requirement = (
|
|
73
74
|
value: Identity | undefined
|
|
@@ -96,11 +97,17 @@ export class Identity<T extends Identity.Require = never> {
|
|
|
96
97
|
}
|
|
97
98
|
return result
|
|
98
99
|
}
|
|
99
|
-
static async verify(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
static async verify(authorization: string | undefined, key: string): Promise<Key | undefined> {
|
|
101
|
+
const verifier = userwidgets.User.Key.Verifier.create<Key>(key)
|
|
102
|
+
const jwt = User.JWT.open({ public: key })
|
|
103
|
+
const unpacked = authorization ? await jwt.unpack(authorization) : undefined
|
|
104
|
+
let verified: Key | undefined
|
|
105
|
+
if (User.JWT.Payload.type.is(unpacked) && authorization) {
|
|
106
|
+
const payload = await jwt.verify(authorization)
|
|
107
|
+
verified = payload && Key.from(payload, authorization)
|
|
108
|
+
} else
|
|
109
|
+
verified = await verifier.verify(authorization)
|
|
110
|
+
return verified
|
|
104
111
|
}
|
|
105
112
|
static getRealms(permissions: Key.Permissions): Realm[] {
|
|
106
113
|
return [
|
|
@@ -131,4 +138,3 @@ export namespace Identity {
|
|
|
131
138
|
}
|
|
132
139
|
const publicKey =
|
|
133
140
|
"MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA2W8CD2kpfS4QIRV2/rgm4NVvsvJsYNMHtnIl9ADvO3A81hAmRKvOAPVoXICe6+EuZ47jGjGL7f48GEoQuITfBPv/MosCDj1YhJ56ILDynCSd8FlxDrhv8pl5IquST7tcL6Hc6m+vuvoTLrFQ5QqNxv0a5eDd/YTrWv7SUuRfBEhYd/wMysGynN3QauHqy5ceBCt1nv1MJLGlSzczMRK7wjy1zi2g9NCHZBOoo1HXOpi727Xh+YXHc9EP2TN0oOXyxykv45nkGIDI0Qek3/pfkavClBffc1sEqA+rUx7YqRN9KGYxwLMLug+NOOh3ptqjfobXbR5fx/sUWhvcjUMTE1JreTrWYbGmVnjd/SeYSClfmGhdTBUfqnZbaABv0ruTXva18qRhP4y143vHMk/k8HzbuROTKAzrtEeLIjgwUgDcnE+JwDqcb8tKSGV6i++TiTldlSBCRTT4dK2hpHJje80b2abqtrbCkxbJlT98UsAAoiq2eW1X6lYmCfiGCJPkfswibQ2tPAKKNe/2xuHPsjx4FuXGmV0dbzmCwSIQoApXqOvKzoNFi6AaKIjxfNmiEigLwKpNrw08H0lVZbq/9MMxI3TzMTZjY9QmBKVLSGy3Z6IJqZpyK22lv7whJcllG0Qw8tv8+7wmC8SR3+4jpuxuFGZ+69CW+otx+CPMJjcCAwEAAQ=="
|
|
134
|
-
const productionVerifier = userwidgets.User.Key.Verifier.create<Key>(publicKey)
|
package/Key/Permissions.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { userwidgets } from "@userwidgets/model"
|
|
2
|
+
import { User } from "../User"
|
|
2
3
|
|
|
3
4
|
export type Permissions = Permissions.Organization | Permissions.Realm
|
|
4
5
|
export namespace Permissions {
|
|
@@ -45,4 +46,49 @@ export namespace Permissions {
|
|
|
45
46
|
| true
|
|
46
47
|
cards?: { create?: true; view?: true; change?: true; cancel?: true } | true
|
|
47
48
|
}
|
|
49
|
+
export function from(permission: User.Access.Permission): Permissions {
|
|
50
|
+
const result: Permissions = {}
|
|
51
|
+
if (permission["*"])
|
|
52
|
+
result["*"] = User.Access.Permission.Level.get(permission["*"]) >= 2 || {
|
|
53
|
+
org: { view: true },
|
|
54
|
+
user: User.Access.Permission.Level.get(permission["user"]) >= 2 || { view: true },
|
|
55
|
+
app: { view: true },
|
|
56
|
+
}
|
|
57
|
+
if (permission["account"])
|
|
58
|
+
result.accounts = User.Access.Permission.Level.get(permission["account"]) >= 2 || {
|
|
59
|
+
view: true,
|
|
60
|
+
}
|
|
61
|
+
if (permission["card"])
|
|
62
|
+
result.cards = User.Access.Permission.Level.get(permission["card"]) >= 2 || {
|
|
63
|
+
view: true,
|
|
64
|
+
}
|
|
65
|
+
if (permission["log"])
|
|
66
|
+
result.logs = User.Access.Permission.Level.get(permission["log"]) >= 2 || {
|
|
67
|
+
view: true,
|
|
68
|
+
}
|
|
69
|
+
if (permission["operation"])
|
|
70
|
+
result.operations = User.Access.Permission.Level.get(permission["operation"]) >= 2 || {
|
|
71
|
+
view: true,
|
|
72
|
+
}
|
|
73
|
+
if (permission["organization"])
|
|
74
|
+
result.organizations = User.Access.Permission.Level.get(permission["organization"]) >= 2 || {
|
|
75
|
+
view: true,
|
|
76
|
+
rules: { view: true, customer: { view: true }, product: { view: true }, fincrime: { view: true } },
|
|
77
|
+
accounts: { view: true },
|
|
78
|
+
}
|
|
79
|
+
if (permission["rule"])
|
|
80
|
+
result.rules = User.Access.Permission.Level.get(permission["rule"]) >= 2 || {
|
|
81
|
+
view: true,
|
|
82
|
+
customer: { view: true },
|
|
83
|
+
product: { view: true },
|
|
84
|
+
fincrime: { view: true },
|
|
85
|
+
}
|
|
86
|
+
if (permission["settlement"])
|
|
87
|
+
result.settlements = User.Access.Permission.Level.get(permission["settlement"]) >= 2 || { view: true }
|
|
88
|
+
if (permission["transaction"])
|
|
89
|
+
result.transactions = User.Access.Permission.Level.get(permission["transaction"]) >= 2 || { view: true }
|
|
90
|
+
if (permission["treasury"])
|
|
91
|
+
result.treasury = User.Access.Permission.Level.get(permission["treasury"]) >= 2 || { view: true }
|
|
92
|
+
return result
|
|
93
|
+
}
|
|
48
94
|
}
|
package/Key/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { isoly } from "isoly"
|
|
1
2
|
import { userwidgets } from "@userwidgets/model"
|
|
2
3
|
import { Realm } from "../Realm"
|
|
4
|
+
import { User } from "../User"
|
|
3
5
|
import { Permissions as KeyPermissions } from "./Permissions"
|
|
4
6
|
import { Roles as KeyRoles } from "./Roles"
|
|
5
7
|
|
|
@@ -10,11 +12,7 @@ type Claims = {
|
|
|
10
12
|
|
|
11
13
|
export type Key = userwidgets.User.Key<userwidgets.User.Key.Creatable.Claims | Claims, Key.Permissions>
|
|
12
14
|
export namespace Key {
|
|
13
|
-
export
|
|
14
|
-
export namespace Permissions {
|
|
15
|
-
export type Realm = KeyPermissions.Realm
|
|
16
|
-
export type Organization = KeyPermissions.Organization
|
|
17
|
-
}
|
|
15
|
+
export import Permissions = KeyPermissions
|
|
18
16
|
export type Roles = KeyRoles
|
|
19
17
|
export const Roles = KeyRoles
|
|
20
18
|
export namespace Roles {
|
|
@@ -23,4 +21,17 @@ export namespace Key {
|
|
|
23
21
|
export type Role = KeyRoles.Organization.Role
|
|
24
22
|
}
|
|
25
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: { [payload.realm + "-*"]: Permissions.from(payload.permission) },
|
|
30
|
+
expires: payload.exp ? isoly.DateTime.create(payload.exp) : isoly.DateTime.nextYear(isoly.DateTime.now(), 10),
|
|
31
|
+
issued: isoly.DateTime.create(payload.iat),
|
|
32
|
+
issuer: payload.iss,
|
|
33
|
+
name: { first: "", last: "" },
|
|
34
|
+
token,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
26
37
|
}
|
|
@@ -29,6 +29,7 @@ export namespace Permission {
|
|
|
29
29
|
export type Collection = typeof Collection.values[number]
|
|
30
30
|
export namespace Collection {
|
|
31
31
|
export const values = [
|
|
32
|
+
"*",
|
|
32
33
|
"account",
|
|
33
34
|
"card",
|
|
34
35
|
"log",
|
|
@@ -39,7 +40,6 @@ export namespace Permission {
|
|
|
39
40
|
"transaction",
|
|
40
41
|
"treasury",
|
|
41
42
|
"user",
|
|
42
|
-
"*",
|
|
43
43
|
] as const
|
|
44
44
|
export const type = isly.string(values)
|
|
45
45
|
}
|
package/User/Identity.ts
CHANGED
|
@@ -8,7 +8,7 @@ export class Identity {
|
|
|
8
8
|
get realm(): Realm {
|
|
9
9
|
return this.payload.realm
|
|
10
10
|
}
|
|
11
|
-
constructor(public readonly payload: JWT.Payload
|
|
11
|
+
constructor(public readonly payload: JWT.Payload) {}
|
|
12
12
|
|
|
13
13
|
authenticate(constraint: Access.Permission | Access.Permission[]): Identity | gracely.Error {
|
|
14
14
|
let allowed: boolean
|
|
@@ -26,7 +26,7 @@ export class Identity {
|
|
|
26
26
|
): Promise<Identity | gracely.Error> {
|
|
27
27
|
const jwt = authorization?.startsWith("Bearer ") ? authorization.replace("Bearer ", "") : undefined
|
|
28
28
|
const payload = jwt ? await JWT.open({ public: options.key }, options.whitelist).verify(jwt) : undefined
|
|
29
|
-
return jwt && payload ? new Identity(payload
|
|
29
|
+
return jwt && payload ? new Identity(payload) : gracely.client.unauthorized()
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
export namespace Identity {}
|
package/User/JWT/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { authly } from "authly"
|
|
|
2
2
|
import { Realm } from "../../Realm"
|
|
3
3
|
import { Payload as JWTPayload } from "./Payload"
|
|
4
4
|
import { Signer as JWTSigner } from "./Signer"
|
|
5
|
+
import { whitelist as JWTwhitelist } from "./whitelist"
|
|
5
6
|
|
|
6
7
|
export class JWT {
|
|
7
8
|
#verifier?: authly.Verifier<JWT.Payload>
|
|
@@ -40,11 +41,12 @@ export class JWT {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
static open(key?: { private?: string; public?: string }, whitelist?: JWT.Whitelist): JWT {
|
|
43
|
-
return new this({ private: key?.private, public: key?.public ?? JWT.key }, whitelist)
|
|
44
|
+
return new this({ private: key?.private, public: key?.public ?? JWT.key }, whitelist ?? JWT.whitelist)
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
export namespace JWT {
|
|
47
48
|
export import Signer = JWTSigner
|
|
49
|
+
export const whitelist = JWTwhitelist
|
|
48
50
|
export type Whitelist = Partial<Record<Realm, Payload.LongTerm[]>>
|
|
49
51
|
export async function unpack(token: string): Promise<JWT.Payload | undefined> {
|
|
50
52
|
const algorithm = authly.Algorithm.RS256(undefined)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JWT } from "./index"
|
|
2
|
+
|
|
3
|
+
export const whitelist: JWT.Whitelist = {
|
|
4
|
+
test: [
|
|
5
|
+
{
|
|
6
|
+
aud: "https://banking.pax2pay.app",
|
|
7
|
+
iat: 1751283567,
|
|
8
|
+
// cSpell:disable-next-line
|
|
9
|
+
id: "UUwLn9rhcf8AoRuG",
|
|
10
|
+
iss: "pax2pay",
|
|
11
|
+
permission: {},
|
|
12
|
+
realm: "test",
|
|
13
|
+
sub: "Test",
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { gracely } from "gracely";
|
|
2
|
+
import { http } from "cloudly-http";
|
|
3
|
+
import { User } from "../../User";
|
|
4
|
+
export declare class Invites {
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client: http.Client);
|
|
7
|
+
create(creatable: User.Invite.Creatable): Promise<User | gracely.Error>;
|
|
8
|
+
fetch(identifier: string): Promise<User | gracely.Error>;
|
|
9
|
+
list(): Promise<User[] | gracely.Error>;
|
|
10
|
+
remove(identifier: string): Promise<User | gracely.Error>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Invites = void 0;
|
|
4
|
+
class Invites {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
async create(creatable) {
|
|
10
|
+
return await this.client.post("/user/invite", creatable);
|
|
11
|
+
}
|
|
12
|
+
async fetch(identifier) {
|
|
13
|
+
return await this.client.get(`/user/invite/${identifier}`);
|
|
14
|
+
}
|
|
15
|
+
async list() {
|
|
16
|
+
return await this.client.get("/user/invite");
|
|
17
|
+
}
|
|
18
|
+
async remove(identifier) {
|
|
19
|
+
return await this.client.delete(`/user/invite/:${identifier}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Invites = Invites;
|
|
23
|
+
//# sourceMappingURL=Invites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Invites.js","sourceRoot":"","sources":["../../../../Client/Users/Invites.ts"],"names":[],"mappings":";;;AAIA,MAAa,OAAO;IACU;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD,KAAK,CAAC,MAAM,CAAC,SAAgC;QAC5C,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAO,cAAc,EAAE,SAAS,CAAC,CAAA;IAC/D,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,UAAkB;QAC7B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAO,gBAAgB,UAAU,EAAE,CAAC,CAAA;IACjE,CAAC;IACD,KAAK,CAAC,IAAI;QACT,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAS,cAAc,CAAC,CAAA;IACrD,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC9B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAO,iBAAiB,UAAU,EAAE,CAAC,CAAA;IACrE,CAAC;CACD;AAfD,0BAeC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { gracely } from "gracely";
|
|
2
|
+
import { http } from "cloudly-http";
|
|
3
|
+
import { User } from "../../User";
|
|
4
|
+
import { Invites } from "./Invites";
|
|
5
|
+
export declare class Users {
|
|
6
|
+
#private;
|
|
7
|
+
private readonly client;
|
|
8
|
+
get invites(): Invites;
|
|
9
|
+
constructor(client: http.Client);
|
|
10
|
+
create(user: User.Creatable): Promise<User | gracely.Error>;
|
|
11
|
+
fetch(email: string): Promise<User | gracely.Error>;
|
|
12
|
+
list(): Promise<User[] | gracely.Error>;
|
|
13
|
+
remove(email: string): Promise<User | gracely.Error>;
|
|
14
|
+
updatePassword(email: string, creatable: User.Password.Creatable): Promise<User | gracely.Error>;
|
|
15
|
+
updateAccess(email: string, access: User.Access): Promise<User | gracely.Error>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Users = void 0;
|
|
4
|
+
const Invites_1 = require("./Invites");
|
|
5
|
+
class Users {
|
|
6
|
+
client;
|
|
7
|
+
#invites;
|
|
8
|
+
get invites() {
|
|
9
|
+
return (this.#invites ??= new Invites_1.Invites(this.client));
|
|
10
|
+
}
|
|
11
|
+
constructor(client) {
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
async create(user) {
|
|
15
|
+
return await this.client.post("/user", user);
|
|
16
|
+
}
|
|
17
|
+
async fetch(email) {
|
|
18
|
+
return await this.client.get(`/user/${email}`);
|
|
19
|
+
}
|
|
20
|
+
async list() {
|
|
21
|
+
return await this.client.get("/user");
|
|
22
|
+
}
|
|
23
|
+
async remove(email) {
|
|
24
|
+
return await this.client.delete(`/user/${email}`);
|
|
25
|
+
}
|
|
26
|
+
async updatePassword(email, creatable) {
|
|
27
|
+
return await this.client.put(`/user/${email}/password`, creatable);
|
|
28
|
+
}
|
|
29
|
+
async updateAccess(email, access) {
|
|
30
|
+
return await this.client.put(`/user/${email}/access`, access);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.Users = Users;
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Client/Users/index.ts"],"names":[],"mappings":";;;AAGA,uCAAmC;AAEnC,MAAa,KAAK;IAKY;IAJ7B,QAAQ,CAAU;IAClB,IAAI,OAAO;QACV,OAAO,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,iBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACpD,CAAC;IACD,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD,KAAK,CAAC,MAAM,CAAC,IAAoB;QAChC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAO,OAAO,EAAE,IAAI,CAAC,CAAA;IACnD,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,KAAa;QACxB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAO,SAAS,KAAK,EAAE,CAAC,CAAA;IACrD,CAAC;IACD,KAAK,CAAC,IAAI;QACT,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAS,OAAO,CAAC,CAAA;IAC9C,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,KAAa;QACzB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAO,SAAS,KAAK,EAAE,CAAC,CAAA;IACxD,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,KAAa,EAAE,SAAkC;QACrE,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAO,SAAS,KAAK,WAAW,EAAE,SAAS,CAAC,CAAA;IACzE,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,MAAmB;QACpD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAO,SAAS,KAAK,SAAS,EAAE,MAAM,CAAC,CAAA;IACpE,CAAC;CACD;AAzBD,sBAyBC"}
|
|
@@ -14,26 +14,28 @@ import { Rules } from "./Rules";
|
|
|
14
14
|
import { Settlements } from "./Settlements";
|
|
15
15
|
import { Transactions as ClientTransactions } from "./Transactions";
|
|
16
16
|
import { Treasury } from "./Treasury";
|
|
17
|
+
import { Users } from "./Users";
|
|
17
18
|
import { Version } from "./Version";
|
|
18
19
|
export declare class Client {
|
|
19
20
|
private readonly client;
|
|
20
21
|
realm?: string;
|
|
21
22
|
organization?: string;
|
|
22
23
|
readonly accounts: Accounts;
|
|
24
|
+
readonly audits: Audit;
|
|
23
25
|
readonly cards: Cards;
|
|
24
|
-
readonly operations: Operations;
|
|
25
26
|
readonly exchanges: Exchanges;
|
|
27
|
+
readonly flags: Labels;
|
|
28
|
+
readonly groups: Labels;
|
|
29
|
+
readonly logs: Logs;
|
|
30
|
+
readonly operations: Operations;
|
|
26
31
|
readonly organizations: Organizations;
|
|
32
|
+
readonly processors: Processor;
|
|
27
33
|
readonly reports: Reports;
|
|
28
|
-
readonly audits: Audit;
|
|
29
|
-
readonly logs: Logs;
|
|
30
34
|
readonly rules: Rules;
|
|
31
35
|
readonly settlements: Settlements;
|
|
32
36
|
readonly transactions: ClientTransactions;
|
|
33
37
|
readonly treasury: Treasury;
|
|
34
|
-
readonly
|
|
35
|
-
readonly groups: Labels;
|
|
36
|
-
readonly processors: Processor;
|
|
38
|
+
readonly users: Users;
|
|
37
39
|
readonly version: Version;
|
|
38
40
|
set key(value: string | undefined);
|
|
39
41
|
get key(): string | undefined;
|
package/dist/cjs/Client/index.js
CHANGED
|
@@ -17,26 +17,28 @@ const Rules_1 = require("./Rules");
|
|
|
17
17
|
const Settlements_1 = require("./Settlements");
|
|
18
18
|
const Transactions_1 = require("./Transactions");
|
|
19
19
|
const Treasury_1 = require("./Treasury");
|
|
20
|
+
const Users_1 = require("./Users");
|
|
20
21
|
const Version_1 = require("./Version");
|
|
21
22
|
class Client {
|
|
22
23
|
client;
|
|
23
24
|
realm;
|
|
24
25
|
organization;
|
|
25
26
|
accounts;
|
|
27
|
+
audits;
|
|
26
28
|
cards;
|
|
27
|
-
operations;
|
|
28
29
|
exchanges;
|
|
30
|
+
flags;
|
|
31
|
+
groups;
|
|
32
|
+
logs;
|
|
33
|
+
operations;
|
|
29
34
|
organizations;
|
|
35
|
+
processors;
|
|
30
36
|
reports;
|
|
31
|
-
audits;
|
|
32
|
-
logs;
|
|
33
37
|
rules;
|
|
34
38
|
settlements;
|
|
35
39
|
transactions;
|
|
36
40
|
treasury;
|
|
37
|
-
|
|
38
|
-
groups;
|
|
39
|
-
processors;
|
|
41
|
+
users;
|
|
40
42
|
version;
|
|
41
43
|
set key(value) {
|
|
42
44
|
this.client.key = value;
|
|
@@ -54,20 +56,21 @@ class Client {
|
|
|
54
56
|
this.client = client;
|
|
55
57
|
this.client.onUnauthorized = async () => this.onUnauthorized != undefined && (await this.onUnauthorized(this));
|
|
56
58
|
this.accounts = new Accounts_1.Accounts(this.client);
|
|
59
|
+
this.audits = new Audit_1.Audit(this.client);
|
|
57
60
|
this.cards = new Cards_1.Cards(this.client);
|
|
58
|
-
this.operations = new Operations_1.Operations(this.client);
|
|
59
61
|
this.exchanges = new Exchanges_1.Exchanges(this.client);
|
|
62
|
+
this.flags = new Labels_1.Labels(this.client, "flag");
|
|
63
|
+
this.groups = new Labels_1.Labels(this.client, "group");
|
|
64
|
+
this.logs = new Logs_1.Logs(this.client);
|
|
65
|
+
this.operations = new Operations_1.Operations(this.client);
|
|
60
66
|
this.organizations = new Organizations_1.Organizations(this.client);
|
|
67
|
+
this.processors = new Processor_1.Processor(this.client);
|
|
61
68
|
this.reports = new Reports_1.Reports(this.client);
|
|
62
|
-
this.audits = new Audit_1.Audit(this.client);
|
|
63
|
-
this.logs = new Logs_1.Logs(this.client);
|
|
64
69
|
this.rules = new Rules_1.Rules(this.client);
|
|
65
70
|
this.settlements = new Settlements_1.Settlements(this.client);
|
|
66
71
|
this.transactions = new Transactions_1.Transactions(this.client);
|
|
67
72
|
this.treasury = new Treasury_1.Treasury(this.client);
|
|
68
|
-
this.
|
|
69
|
-
this.groups = new Labels_1.Labels(this.client, "group");
|
|
70
|
-
this.processors = new Processor_1.Processor(this.client);
|
|
73
|
+
this.users = new Users_1.Users(this.client);
|
|
71
74
|
this.version = new Version_1.Version(this.client);
|
|
72
75
|
}
|
|
73
76
|
userwidgets = (server, application) => new model_1.userwidgets.ClientCollection(new cloudly_http_1.http.Client(server), { application });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../Client/index.ts"],"names":[],"mappings":";;;AACA,8CAAgD;AAChD,+CAAmC;AACnC,yCAAqC;AACrC,mCAA+B;AAC/B,mCAA+B;AAC/B,2CAAuC;AACvC,qCAAiC;AACjC,iCAA6B;AAC7B,6CAAyC;AACzC,mDAA+C;AAC/C,2CAAuC;AACvC,uCAAmC;AACnC,mCAA+B;AAC/B,+CAA2C;AAC3C,iDA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K,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;qBACtE,CAAC,CACF,CAAA;gBACF,OAAO,MAAM,CAAA;YACd,CAAC;SACD,CAAC,CAAA;QACF,MAAM,MAAM,GAAW,IAAI,MAAM,CAAC,UAAU,CAAC,CAAA;QAC7C,OAAO,MAAM,CAAA;IACd,CAAC;CACD;AAhFD,wBAgFC;AACD,WAAiB,MAAM;IACR,mBAAY,GAAG,2BAAkB,CAAA;AAChD,CAAC,EAFgB,MAAM,sBAAN,MAAM,QAEtB"}
|
package/dist/cjs/Identity.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { gracely } from "gracely";
|
|
2
|
-
import { userwidgets } from "@userwidgets/model";
|
|
3
2
|
import { slackly } from "slackly";
|
|
4
3
|
import { Key } from "./Key";
|
|
5
4
|
import { Realm } from "./Realm";
|
|
@@ -12,13 +11,13 @@ export declare class Identity<T extends Identity.Require = never> {
|
|
|
12
11
|
constructor(key: Key, realm: T["realm"] extends true ? Realm : Realm | undefined, organization: T["organization"] extends true ? string : string | undefined);
|
|
13
12
|
check(constraint: Key.Permissions | Key.Permissions[], realm?: Realm, organization?: string): boolean;
|
|
14
13
|
collectionCheck(collection: string): boolean;
|
|
15
|
-
static authenticate<T extends Identity.Require = Record<string, never>>(header: Identity.Header, constraint: Key.Permissions | Key.Permissions[], requires?: T,
|
|
14
|
+
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): Promise<Identity<T> | undefined>;
|
|
16
15
|
static authenticate<T extends Identity.Require = Record<string, never>>(header: {
|
|
17
16
|
authorization?: string | undefined;
|
|
18
17
|
realm?: Realm;
|
|
19
18
|
organization?: string;
|
|
20
|
-
}, constraint: Key.Permissions | Key.Permissions[], requires?: T,
|
|
21
|
-
static verify(authorization: string | undefined,
|
|
19
|
+
}, constraint: Key.Permissions | Key.Permissions[], requires?: T, key?: string, output?: "error", notify?: Identity.Notify): Promise<Identity<T> | gracely.Error>;
|
|
20
|
+
static verify(authorization: string | undefined, key: string): Promise<Key | undefined>;
|
|
22
21
|
static getRealms(permissions: Key.Permissions): Realm[];
|
|
23
22
|
}
|
|
24
23
|
export declare namespace Identity {
|