@pax2pay/model-banking 0.1.582 → 0.1.584
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/Identifier.ts +2 -2
- package/Log/Entry.ts +7 -7
- package/Log/Locations.ts +7 -7
- package/Log/Message/Configuration.ts +7 -7
- package/Log/Message/Entry.ts +6 -6
- package/Log/index.ts +9 -9
- package/Realm.ts +3 -3
- package/User/Access/Permission.ts +7 -3
- package/User/Access/index.ts +9 -7
- package/User/JWT/Payload.ts +26 -27
- package/User/JWT/index.ts +2 -2
- package/User/Password.ts +3 -5
- package/User/index.ts +9 -29
- package/Warning/Base.ts +7 -0
- package/Warning/Snapshot/Counterbalance.ts +2 -0
- package/Warning/Snapshot/MissingBuffer.ts +2 -0
- package/Warning/Snapshot/MissingEmoney.ts +2 -0
- package/Warning/Snapshot/MissingFiat.ts +2 -0
- package/Warning/Snapshot/Overdraft.ts +2 -0
- package/Warning/Snapshot/StaleFiat.ts +2 -0
- package/dist/cjs/Identifier.d.ts +2 -2
- package/dist/cjs/Identifier.js +2 -35
- package/dist/cjs/Identifier.js.map +1 -1
- package/dist/cjs/Log/Entry.d.ts +12 -12
- package/dist/cjs/Log/Entry.js +5 -38
- package/dist/cjs/Log/Entry.js.map +1 -1
- package/dist/cjs/Log/Locations.d.ts +8 -8
- package/dist/cjs/Log/Locations.js +6 -39
- package/dist/cjs/Log/Locations.js.map +1 -1
- package/dist/cjs/Log/Message/Configuration.d.ts +8 -8
- package/dist/cjs/Log/Message/Configuration.js +6 -39
- package/dist/cjs/Log/Message/Configuration.js.map +1 -1
- package/dist/cjs/Log/Message/Entry.d.ts +7 -7
- package/dist/cjs/Log/Message/Entry.js +5 -38
- package/dist/cjs/Log/Message/Entry.js.map +1 -1
- package/dist/cjs/Log/index.d.ts +14 -14
- package/dist/cjs/Log/index.js +8 -41
- package/dist/cjs/Log/index.js.map +1 -1
- package/dist/cjs/Realm.d.ts +3 -3
- package/dist/cjs/Realm.js +2 -35
- package/dist/cjs/Realm.js.map +1 -1
- package/dist/cjs/User/Access/Permission.d.ts +42 -6
- package/dist/cjs/User/Access/Permission.js +4 -0
- package/dist/cjs/User/Access/Permission.js.map +1 -1
- package/dist/cjs/User/Access/index.d.ts +80 -7
- package/dist/cjs/User/Access/index.js +8 -0
- package/dist/cjs/User/Access/index.js.map +1 -1
- package/dist/cjs/User/JWT/Payload.d.ts +234 -26
- package/dist/cjs/User/JWT/Payload.js +20 -4
- package/dist/cjs/User/JWT/Payload.js.map +1 -1
- package/dist/cjs/User/JWT/index.js +2 -2
- package/dist/cjs/User/JWT/index.js.map +1 -1
- package/dist/cjs/User/Password.d.ts +12 -6
- package/dist/cjs/User/Password.js +2 -0
- package/dist/cjs/User/Password.js.map +1 -1
- package/dist/cjs/User/index.d.ts +112 -10
- package/dist/cjs/User/index.js +6 -18
- package/dist/cjs/User/index.js.map +1 -1
- package/dist/cjs/Warning/Base.d.ts +7 -0
- package/dist/cjs/Warning/Base.js +6 -0
- package/dist/cjs/Warning/Base.js.map +1 -1
- package/dist/cjs/Warning/Snapshot/Counterbalance.d.ts +1 -0
- package/dist/cjs/Warning/Snapshot/Counterbalance.js +1 -0
- package/dist/cjs/Warning/Snapshot/Counterbalance.js.map +1 -1
- package/dist/cjs/Warning/Snapshot/MissingBuffer.d.ts +1 -0
- package/dist/cjs/Warning/Snapshot/MissingBuffer.js +1 -0
- package/dist/cjs/Warning/Snapshot/MissingBuffer.js.map +1 -1
- package/dist/cjs/Warning/Snapshot/MissingEmoney.d.ts +1 -0
- package/dist/cjs/Warning/Snapshot/MissingEmoney.js +1 -0
- package/dist/cjs/Warning/Snapshot/MissingEmoney.js.map +1 -1
- package/dist/cjs/Warning/Snapshot/MissingFiat.d.ts +1 -0
- package/dist/cjs/Warning/Snapshot/MissingFiat.js +1 -0
- package/dist/cjs/Warning/Snapshot/MissingFiat.js.map +1 -1
- package/dist/cjs/Warning/Snapshot/Overdraft.d.ts +1 -0
- package/dist/cjs/Warning/Snapshot/Overdraft.js +1 -0
- package/dist/cjs/Warning/Snapshot/Overdraft.js.map +1 -1
- package/dist/cjs/Warning/Snapshot/StaleFiat.d.ts +1 -0
- package/dist/cjs/Warning/Snapshot/StaleFiat.js +1 -0
- package/dist/cjs/Warning/Snapshot/StaleFiat.js.map +1 -1
- package/dist/cjs/pax2pay.d.ts +1 -0
- package/dist/cjs/pax2pay.js +3 -1
- package/dist/cjs/pax2pay.js.map +1 -1
- package/dist/cjs/zod.d.ts +12 -0
- package/dist/cjs/zod.js +52 -0
- package/dist/cjs/zod.js.map +1 -0
- package/dist/mjs/Identifier.d.ts +2 -2
- package/dist/mjs/Identifier.js +2 -2
- package/dist/mjs/Identifier.js.map +1 -1
- package/dist/mjs/Log/Entry.d.ts +12 -12
- package/dist/mjs/Log/Entry.js +5 -5
- package/dist/mjs/Log/Entry.js.map +1 -1
- package/dist/mjs/Log/Locations.d.ts +8 -8
- package/dist/mjs/Log/Locations.js +6 -6
- package/dist/mjs/Log/Locations.js.map +1 -1
- package/dist/mjs/Log/Message/Configuration.d.ts +8 -8
- package/dist/mjs/Log/Message/Configuration.js +6 -6
- package/dist/mjs/Log/Message/Configuration.js.map +1 -1
- package/dist/mjs/Log/Message/Entry.d.ts +7 -7
- package/dist/mjs/Log/Message/Entry.js +5 -5
- package/dist/mjs/Log/Message/Entry.js.map +1 -1
- package/dist/mjs/Log/index.d.ts +14 -14
- package/dist/mjs/Log/index.js +8 -8
- package/dist/mjs/Log/index.js.map +1 -1
- package/dist/mjs/Realm.d.ts +3 -3
- package/dist/mjs/Realm.js +2 -2
- package/dist/mjs/Realm.js.map +1 -1
- package/dist/mjs/User/Access/Permission.d.ts +42 -6
- package/dist/mjs/User/Access/Permission.js +4 -0
- package/dist/mjs/User/Access/Permission.js.map +1 -1
- package/dist/mjs/User/Access/index.d.ts +80 -7
- package/dist/mjs/User/Access/index.js +8 -0
- package/dist/mjs/User/Access/index.js.map +1 -1
- package/dist/mjs/User/JWT/Payload.d.ts +234 -26
- package/dist/mjs/User/JWT/Payload.js +20 -4
- package/dist/mjs/User/JWT/Payload.js.map +1 -1
- package/dist/mjs/User/JWT/index.js +2 -2
- package/dist/mjs/User/JWT/index.js.map +1 -1
- package/dist/mjs/User/Password.d.ts +12 -6
- package/dist/mjs/User/Password.js +2 -0
- package/dist/mjs/User/Password.js.map +1 -1
- package/dist/mjs/User/index.d.ts +112 -10
- package/dist/mjs/User/index.js +6 -18
- package/dist/mjs/User/index.js.map +1 -1
- package/dist/mjs/Warning/Base.d.ts +7 -0
- package/dist/mjs/Warning/Base.js +6 -0
- package/dist/mjs/Warning/Base.js.map +1 -1
- package/dist/mjs/Warning/Snapshot/Counterbalance.d.ts +1 -0
- package/dist/mjs/Warning/Snapshot/Counterbalance.js +1 -0
- package/dist/mjs/Warning/Snapshot/Counterbalance.js.map +1 -1
- package/dist/mjs/Warning/Snapshot/MissingBuffer.d.ts +1 -0
- package/dist/mjs/Warning/Snapshot/MissingBuffer.js +1 -0
- package/dist/mjs/Warning/Snapshot/MissingBuffer.js.map +1 -1
- package/dist/mjs/Warning/Snapshot/MissingEmoney.d.ts +1 -0
- package/dist/mjs/Warning/Snapshot/MissingEmoney.js +1 -0
- package/dist/mjs/Warning/Snapshot/MissingEmoney.js.map +1 -1
- package/dist/mjs/Warning/Snapshot/MissingFiat.d.ts +1 -0
- package/dist/mjs/Warning/Snapshot/MissingFiat.js +1 -0
- package/dist/mjs/Warning/Snapshot/MissingFiat.js.map +1 -1
- package/dist/mjs/Warning/Snapshot/Overdraft.d.ts +1 -0
- package/dist/mjs/Warning/Snapshot/Overdraft.js +1 -0
- package/dist/mjs/Warning/Snapshot/Overdraft.js.map +1 -1
- package/dist/mjs/Warning/Snapshot/StaleFiat.d.ts +1 -0
- package/dist/mjs/Warning/Snapshot/StaleFiat.js +1 -0
- package/dist/mjs/Warning/Snapshot/StaleFiat.js.map +1 -1
- package/dist/mjs/pax2pay.d.ts +1 -0
- package/dist/mjs/pax2pay.js +1 -0
- package/dist/mjs/pax2pay.js.map +1 -1
- package/dist/mjs/zod.d.ts +12 -0
- package/dist/mjs/zod.js +16 -0
- package/dist/mjs/zod.js.map +1 -0
- package/package.json +2 -2
- package/pax2pay.ts +1 -0
- package/tsconfig.json +1 -2
- package/zod.ts +20 -0
package/Identifier.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cryptly } from "cryptly"
|
|
2
2
|
import { isoly } from "isoly"
|
|
3
3
|
import { isly } from "isly"
|
|
4
|
-
import
|
|
4
|
+
import { zod } from "./zod"
|
|
5
5
|
|
|
6
6
|
export type Identifier = cryptly.Identifier
|
|
7
7
|
export namespace Identifier {
|
|
@@ -20,5 +20,5 @@ export namespace Identifier {
|
|
|
20
20
|
return isoly.DateTime.create(Number(new BigUint64Array(decoded.slice(decoded.length - 8).buffer)), "milliseconds")
|
|
21
21
|
}
|
|
22
22
|
export const type = isly.fromIs("Identifier", cryptly.Identifier.is)
|
|
23
|
-
export const
|
|
23
|
+
export const typeZod = zod.string().refine(cryptly.Identifier.is)
|
|
24
24
|
}
|
package/Log/Entry.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { zod } from "../zod"
|
|
2
2
|
|
|
3
3
|
export namespace Entry {
|
|
4
|
-
export const type =
|
|
5
|
-
message:
|
|
6
|
-
data:
|
|
4
|
+
export const type = zod.object({
|
|
5
|
+
message: zod.string(),
|
|
6
|
+
data: zod.any().optional(),
|
|
7
7
|
})
|
|
8
8
|
export namespace Message {
|
|
9
|
-
export const type =
|
|
9
|
+
export const type = zod.object({ ...Entry.type.shape, resource: zod.string().optional() })
|
|
10
10
|
export function to(message: string, data: any | undefined, resource: string | undefined): Entry.Message {
|
|
11
11
|
const result: Entry.Message = { message }
|
|
12
12
|
resource && (result.resource = resource)
|
|
@@ -14,6 +14,6 @@ export namespace Entry {
|
|
|
14
14
|
return result
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
export type Message =
|
|
17
|
+
export type Message = zod.infer<typeof Message.type>
|
|
18
18
|
}
|
|
19
|
-
export type Entry =
|
|
19
|
+
export type Entry = zod.infer<typeof Entry.type>
|
package/Log/Locations.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { zod } from "../zod"
|
|
2
2
|
|
|
3
3
|
export namespace Locations {
|
|
4
|
-
export const type =
|
|
5
|
-
cfConnectionIp:
|
|
6
|
-
cfIpCountry:
|
|
7
|
-
datacenter:
|
|
8
|
-
country:
|
|
4
|
+
export const type = zod.object({
|
|
5
|
+
cfConnectionIp: zod.string().optional(),
|
|
6
|
+
cfIpCountry: zod.string().optional(),
|
|
7
|
+
datacenter: zod.string().optional(),
|
|
8
|
+
country: zod.string().optional(),
|
|
9
9
|
})
|
|
10
10
|
export function getLocations(request: any): Locations | undefined {
|
|
11
11
|
const locations = {
|
|
@@ -17,4 +17,4 @@ export namespace Locations {
|
|
|
17
17
|
return type.safeParse(locations).success ? locations : undefined
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export type Locations =
|
|
20
|
+
export type Locations = zod.infer<typeof Locations.type>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TraceLog } from "@cloudflare/workers-types"
|
|
2
|
-
import * as z from "zod"
|
|
3
2
|
import { Realm } from "../../Realm"
|
|
3
|
+
import { zod } from "../../zod"
|
|
4
4
|
|
|
5
5
|
export namespace Configuration {
|
|
6
|
-
export const type =
|
|
7
|
-
realm: Realm.
|
|
8
|
-
collection:
|
|
9
|
-
resource:
|
|
10
|
-
requireEntries:
|
|
6
|
+
export const type = zod.object({
|
|
7
|
+
realm: Realm.typeZod,
|
|
8
|
+
collection: zod.string(),
|
|
9
|
+
resource: zod.string().optional(),
|
|
10
|
+
requireEntries: zod.boolean().optional(),
|
|
11
11
|
})
|
|
12
12
|
export function fromTraceLog(trace: TraceLog | undefined): Configuration | undefined {
|
|
13
13
|
return trace && Configuration.type.safeParse(trace.message[0]).success
|
|
@@ -20,4 +20,4 @@ export namespace Configuration {
|
|
|
20
20
|
: undefined
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
export type Configuration =
|
|
23
|
+
export type Configuration = zod.infer<typeof Configuration.type>
|
package/Log/Message/Entry.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TraceLog } from "@cloudflare/workers-types"
|
|
2
|
-
import
|
|
2
|
+
import { zod } from "../../zod"
|
|
3
3
|
import type { Log } from "../index"
|
|
4
4
|
|
|
5
5
|
export namespace Entry {
|
|
6
|
-
export const type =
|
|
7
|
-
message:
|
|
8
|
-
resource:
|
|
9
|
-
data:
|
|
6
|
+
export const type = zod.object({
|
|
7
|
+
message: zod.string(),
|
|
8
|
+
resource: zod.string().optional(),
|
|
9
|
+
data: zod.any().optional(),
|
|
10
10
|
})
|
|
11
11
|
export function fromEventLogs(trace: TraceLog): { entry: Log.Entry; resource: Log["resource"] } | undefined {
|
|
12
12
|
return Entry.type.safeParse(trace.message[0]).success
|
|
@@ -20,4 +20,4 @@ export namespace Entry {
|
|
|
20
20
|
: undefined
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
export type Entry =
|
|
23
|
+
export type Entry = zod.infer<typeof Entry.type>
|
package/Log/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { TraceItem } from "@cloudflare/workers-types"
|
|
3
|
-
import * as z from "zod"
|
|
4
3
|
import { Identifier } from "../Identifier"
|
|
5
4
|
import { Realm } from "../Realm"
|
|
5
|
+
import { zod } from "../zod"
|
|
6
6
|
import { Entry as LogEntry } from "./Entry"
|
|
7
7
|
import { Locations as LogLocations } from "./Locations"
|
|
8
8
|
import { Message as LogMessage } from "./Message"
|
|
@@ -11,14 +11,14 @@ export namespace Log {
|
|
|
11
11
|
export import Message = LogMessage
|
|
12
12
|
export import Entry = LogEntry
|
|
13
13
|
export import Locations = LogLocations
|
|
14
|
-
export const type =
|
|
15
|
-
id: Identifier.
|
|
16
|
-
realm: Realm.
|
|
17
|
-
script:
|
|
18
|
-
collection:
|
|
19
|
-
resource:
|
|
14
|
+
export const type = zod.object({
|
|
15
|
+
id: Identifier.typeZod,
|
|
16
|
+
realm: Realm.typeZod,
|
|
17
|
+
script: zod.string().optional(),
|
|
18
|
+
collection: zod.string(),
|
|
19
|
+
resource: zod.string().optional(),
|
|
20
20
|
entries: Log.Entry.type.array(),
|
|
21
|
-
created:
|
|
21
|
+
created: zod.iso.datetime({ offset: true }),
|
|
22
22
|
})
|
|
23
23
|
export function fromEvents(events: TraceItem[]): Log[] {
|
|
24
24
|
const result: Log[] = []
|
|
@@ -65,4 +65,4 @@ export namespace Log {
|
|
|
65
65
|
console.error(Log.Entry.Message.to(message, data, resource))
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
export type Log =
|
|
68
|
+
export type Log = zod.infer<typeof Log.type>
|
package/Realm.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { isly as isly2 } from "isly2"
|
|
4
|
-
import * as z from "zod"
|
|
5
4
|
import { Supplier as modelSupplier } from "./Supplier"
|
|
5
|
+
import { zod } from "./zod"
|
|
6
6
|
|
|
7
|
-
export type Realm = typeof Realm.
|
|
7
|
+
export type Realm = zod.infer<typeof Realm.typeZod>
|
|
8
8
|
|
|
9
9
|
export namespace Realm {
|
|
10
10
|
export const realms = ["test", "uk", "uguk", "eea"] as const
|
|
11
11
|
export const type = isly.string<Realm>(realms)
|
|
12
|
-
export const
|
|
12
|
+
export const typeZod = zod.enum(realms)
|
|
13
13
|
export const type2 = isly2
|
|
14
14
|
.string<Realm>("value", ...realms)
|
|
15
15
|
.rename("Realm")
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
2
|
import { typedly } from "typedly"
|
|
3
|
+
import { zod } from "../../zod"
|
|
3
4
|
|
|
4
|
-
export type Permission =
|
|
5
|
+
export type Permission = zod.infer<typeof Permission.typeZod>
|
|
5
6
|
export namespace Permission {
|
|
6
7
|
export type Realm = Record<Permission.Collection.Realm, Permission.Level>
|
|
7
8
|
export type Global = Record<Permission.Collection.Global, Permission.Level>
|
|
@@ -12,9 +13,10 @@ export namespace Permission {
|
|
|
12
13
|
(collection != "user" && Permission.Level.get(privilege["*"]) >= Permission.Level.get(level))
|
|
13
14
|
)
|
|
14
15
|
}
|
|
15
|
-
export type Level = typeof Level.
|
|
16
|
+
export type Level = zod.infer<typeof Level.typeZod>
|
|
16
17
|
export namespace Level {
|
|
17
18
|
export const values = ["read", "write", "developer", "admin"] as const
|
|
19
|
+
export const typeZod = zod.enum(values)
|
|
18
20
|
export const type = isly.string(values)
|
|
19
21
|
export function get(level: Level | undefined): number {
|
|
20
22
|
return level ? value[level] : 0
|
|
@@ -26,7 +28,7 @@ export namespace Permission {
|
|
|
26
28
|
admin: 4,
|
|
27
29
|
} as const
|
|
28
30
|
}
|
|
29
|
-
export type Collection = typeof Collection.
|
|
31
|
+
export type Collection = zod.infer<typeof Collection.typeZod>
|
|
30
32
|
export namespace Collection {
|
|
31
33
|
export type Realm = typeof Realm.values[number]
|
|
32
34
|
export namespace Realm {
|
|
@@ -47,7 +49,9 @@ export namespace Permission {
|
|
|
47
49
|
export const values = ["user"] as const
|
|
48
50
|
}
|
|
49
51
|
export const values = [...Realm.values, ...Global.values] as const
|
|
52
|
+
export const typeZod = zod.enum(values)
|
|
50
53
|
export const type = isly.string(values)
|
|
51
54
|
}
|
|
52
55
|
export const type = isly.record<Permission>(Collection.type, Level.type)
|
|
56
|
+
export const typeZod = zod.partialRecord(Collection.typeZod, Level.typeZod)
|
|
53
57
|
}
|
package/User/Access/index.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
|
+
import { zod } from "../../zod"
|
|
2
3
|
import { Permission as AccessPermission } from "./Permission"
|
|
3
4
|
|
|
4
5
|
/** read < write < developer < admin */
|
|
5
|
-
export
|
|
6
|
-
uk?: Access.Permission.Realm
|
|
7
|
-
uguk?: Access.Permission.Realm
|
|
8
|
-
eea?: Access.Permission.Realm
|
|
9
|
-
test?: Access.Permission.Realm
|
|
10
|
-
"*"?: Access.Permission.Global
|
|
11
|
-
}
|
|
6
|
+
export type Access = zod.infer<typeof Access.typeZod>
|
|
12
7
|
export namespace Access {
|
|
13
8
|
export import Permission = AccessPermission
|
|
14
9
|
export const type = isly.object({
|
|
@@ -18,4 +13,11 @@ export namespace Access {
|
|
|
18
13
|
test: Access.Permission.type.optional(),
|
|
19
14
|
"*": isly.object({ user: Access.Permission.Level.type.optional() }).optional(),
|
|
20
15
|
})
|
|
16
|
+
export const typeZod = zod.object({
|
|
17
|
+
uk: Access.Permission.typeZod.optional(),
|
|
18
|
+
uguk: Access.Permission.typeZod.optional(),
|
|
19
|
+
eea: Access.Permission.typeZod.optional(),
|
|
20
|
+
test: Access.Permission.typeZod.optional(),
|
|
21
|
+
"*": zod.object({ user: Access.Permission.Level.typeZod.optional() }).optional(),
|
|
22
|
+
})
|
|
21
23
|
}
|
package/User/JWT/Payload.ts
CHANGED
|
@@ -1,56 +1,55 @@
|
|
|
1
|
-
import { authly } from "authly"
|
|
2
1
|
import { isly } from "isly"
|
|
3
2
|
import { Realm } from "../../Realm"
|
|
3
|
+
import { zod } from "../../zod"
|
|
4
4
|
import { Access } from "../Access"
|
|
5
5
|
|
|
6
|
-
export type Payload = Payload.LongTerm | Payload.ShortTerm
|
|
6
|
+
export type Payload = Payload.LongTerm | Payload.ShortTerm //zod.infer<typeof Payload.typeZod>
|
|
7
7
|
export namespace Payload {
|
|
8
|
-
export
|
|
9
|
-
sub: string
|
|
10
|
-
permission: Access.Permission
|
|
11
|
-
realm: Realm
|
|
12
|
-
}
|
|
8
|
+
export type Creatable = zod.infer<typeof Creatable.typeZod>
|
|
13
9
|
export namespace Creatable {
|
|
14
10
|
export const type = isly.object<Creatable>({
|
|
15
11
|
sub: isly.string(),
|
|
16
12
|
permission: Access.Permission.type,
|
|
17
13
|
realm: Realm.type,
|
|
18
14
|
})
|
|
15
|
+
export const typeZod = zod.object({
|
|
16
|
+
sub: zod.string(),
|
|
17
|
+
permission: Access.Permission.typeZod,
|
|
18
|
+
realm: Realm.typeZod,
|
|
19
|
+
})
|
|
19
20
|
}
|
|
20
|
-
export
|
|
21
|
-
aud: string
|
|
22
|
-
iat: number
|
|
23
|
-
iss: string
|
|
24
|
-
sub: string
|
|
25
|
-
permission: Access.Permission
|
|
26
|
-
realm: Realm
|
|
27
|
-
}
|
|
21
|
+
export type Base = zod.infer<typeof Base.typeZod>
|
|
28
22
|
export namespace Base {
|
|
29
|
-
export const type = isly.object<
|
|
23
|
+
export const type = isly.object<Base>({
|
|
30
24
|
aud: isly.string(),
|
|
31
25
|
iat: isly.number(),
|
|
32
26
|
iss: isly.string(),
|
|
33
27
|
sub: isly.string(),
|
|
34
28
|
permission: Access.Permission.type,
|
|
35
29
|
realm: Realm.type,
|
|
30
|
+
token: isly.string().optional(),
|
|
31
|
+
})
|
|
32
|
+
export const typeZod = zod.object({
|
|
33
|
+
aud: zod.string(),
|
|
34
|
+
iat: zod.number(),
|
|
35
|
+
iss: zod.string(),
|
|
36
|
+
sub: zod.string(),
|
|
37
|
+
permission: Access.Permission.typeZod,
|
|
38
|
+
realm: Realm.typeZod,
|
|
39
|
+
token: zod.string().optional(),
|
|
36
40
|
})
|
|
37
41
|
}
|
|
38
|
-
export
|
|
39
|
-
id: string
|
|
40
|
-
}
|
|
42
|
+
export type LongTerm = zod.infer<typeof LongTerm.typeZod>
|
|
41
43
|
export namespace LongTerm {
|
|
42
44
|
export const type = Base.type.extend<LongTerm>({ id: isly.string() })
|
|
45
|
+
export const typeZod = Base.typeZod.extend({ id: zod.string() })
|
|
43
46
|
}
|
|
44
|
-
export
|
|
45
|
-
exp: number
|
|
46
|
-
}
|
|
47
|
+
export type ShortTerm = zod.infer<typeof ShortTerm.typeZod>
|
|
47
48
|
export namespace ShortTerm {
|
|
48
49
|
export const type = Base.type.extend<ShortTerm>({ exp: isly.number() })
|
|
50
|
+
export const typeZod = Base.typeZod.extend({ exp: zod.number() })
|
|
49
51
|
}
|
|
50
|
-
|
|
51
|
-
export const configuration = {
|
|
52
|
-
aud: "https://banking.pax2pay.app",
|
|
53
|
-
iss: "pax2pay",
|
|
54
|
-
}
|
|
52
|
+
export const configuration = { aud: "https://banking.pax2pay.app", iss: "pax2pay" }
|
|
55
53
|
export const type = isly.union<Payload>(LongTerm.type, ShortTerm.type)
|
|
54
|
+
export const typeZod = zod.union([LongTerm.typeZod, ShortTerm.typeZod])
|
|
56
55
|
}
|
package/User/JWT/index.ts
CHANGED
|
@@ -28,8 +28,8 @@ export class JWT {
|
|
|
28
28
|
const verified = await this.verifier?.verify(token, JWT.Payload.configuration.aud)
|
|
29
29
|
delete verified?.token
|
|
30
30
|
return JWT.Payload.type.is(verified) &&
|
|
31
|
-
verified
|
|
32
|
-
(
|
|
31
|
+
verified.iss == JWT.Payload.configuration.iss &&
|
|
32
|
+
("exp" in verified || (await this.store?.get(verified.id).then(s => s?.value)))
|
|
33
33
|
? verified
|
|
34
34
|
: undefined
|
|
35
35
|
}
|
package/User/Password.ts
CHANGED
|
@@ -2,18 +2,16 @@ import { cryptly } from "cryptly"
|
|
|
2
2
|
import { gracely } from "gracely"
|
|
3
3
|
import { isoly } from "isoly"
|
|
4
4
|
import { isly } from "isly"
|
|
5
|
+
import { zod } from "../zod"
|
|
5
6
|
|
|
6
7
|
export interface Password {
|
|
7
8
|
hash: cryptly.Password.Hash
|
|
8
9
|
changed: isoly.DateTime
|
|
9
10
|
}
|
|
10
11
|
export namespace Password {
|
|
11
|
-
export
|
|
12
|
-
current?: string
|
|
13
|
-
new: string
|
|
14
|
-
repeat: string
|
|
15
|
-
}
|
|
12
|
+
export type Creatable = zod.infer<typeof Creatable.typeZod>
|
|
16
13
|
export namespace Creatable {
|
|
14
|
+
export const typeZod = zod.object({ current: zod.string().optional(), new: zod.string(), repeat: zod.string() })
|
|
17
15
|
export const type = isly.object<Creatable>({
|
|
18
16
|
current: isly.string().optional(),
|
|
19
17
|
new: isly.string(),
|
package/User/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { Realm } from "../Realm"
|
|
4
|
+
import { zod } from "../zod"
|
|
4
5
|
import { Access as UserAccess } from "./Access"
|
|
5
6
|
import { Identity as UserIdentity } from "./Identity"
|
|
6
7
|
import { JWT as UserJWT } from "./JWT"
|
|
@@ -11,9 +12,7 @@ export interface User {
|
|
|
11
12
|
access: User.Access
|
|
12
13
|
changed: isoly.DateTime
|
|
13
14
|
created: isoly.DateTime
|
|
14
|
-
password: {
|
|
15
|
-
changed: isoly.DateTime
|
|
16
|
-
}
|
|
15
|
+
password: { changed: isoly.DateTime }
|
|
17
16
|
}
|
|
18
17
|
export namespace User {
|
|
19
18
|
export import Access = UserAccess
|
|
@@ -22,32 +21,15 @@ export namespace User {
|
|
|
22
21
|
export import Password = UserPassword
|
|
23
22
|
export function fromInvite(invite: Invite): User {
|
|
24
23
|
const now = isoly.DateTime.now()
|
|
25
|
-
return {
|
|
26
|
-
email: invite.email,
|
|
27
|
-
access: invite.access,
|
|
28
|
-
changed: now,
|
|
29
|
-
created: now,
|
|
30
|
-
password: {
|
|
31
|
-
changed: now,
|
|
32
|
-
},
|
|
33
|
-
}
|
|
24
|
+
return { email: invite.email, access: invite.access, changed: now, created: now, password: { changed: now } }
|
|
34
25
|
}
|
|
35
26
|
export function toJWTPayloadCreatable(user: User, realm: Realm): User.JWT.Payload.Creatable {
|
|
36
|
-
return {
|
|
37
|
-
sub: user.email,
|
|
38
|
-
permission: { ...(user.access[realm] ?? {}), ...(user.access["*"] ?? {}) },
|
|
39
|
-
realm,
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export interface Creatable {
|
|
43
|
-
invite: string
|
|
44
|
-
password: Password.Creatable
|
|
27
|
+
return { sub: user.email, permission: { ...(user.access[realm] ?? {}), ...(user.access["*"] ?? {}) }, realm }
|
|
45
28
|
}
|
|
29
|
+
export type Creatable = zod.infer<typeof Creatable.typeZod>
|
|
46
30
|
export namespace Creatable {
|
|
47
|
-
export const type = isly.object<Creatable>({
|
|
48
|
-
|
|
49
|
-
password: Password.Creatable.type,
|
|
50
|
-
})
|
|
31
|
+
export const type = isly.object<Creatable>({ invite: isly.string(), password: Password.Creatable.type })
|
|
32
|
+
export const typeZod = zod.object({ invite: zod.string(), password: Password.Creatable.typeZod })
|
|
51
33
|
}
|
|
52
34
|
export interface Invite {
|
|
53
35
|
id: string
|
|
@@ -55,11 +37,9 @@ export namespace User {
|
|
|
55
37
|
access: Access
|
|
56
38
|
}
|
|
57
39
|
export namespace Invite {
|
|
58
|
-
export
|
|
59
|
-
email: string
|
|
60
|
-
access: Access
|
|
61
|
-
}
|
|
40
|
+
export type Creatable = zod.infer<typeof Creatable.typeZod>
|
|
62
41
|
export namespace Creatable {
|
|
42
|
+
export const typeZod = zod.object({ email: zod.string(), access: Access.typeZod })
|
|
63
43
|
export const type = isly.object<Creatable>({ email: isly.string(), access: Access.type })
|
|
64
44
|
}
|
|
65
45
|
}
|
package/Warning/Base.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Issue } from "./Issue"
|
|
|
4
4
|
|
|
5
5
|
export interface Base {
|
|
6
6
|
type: string
|
|
7
|
+
severity?: Base.Severity
|
|
7
8
|
resource: string
|
|
8
9
|
value?: number
|
|
9
10
|
date: isoly.Date
|
|
@@ -11,8 +12,14 @@ export interface Base {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export namespace Base {
|
|
15
|
+
export type Severity = typeof Severity.values[number]
|
|
16
|
+
export namespace Severity {
|
|
17
|
+
export const values = ["low", "medium", "high"] as const
|
|
18
|
+
export const type = isly.string<Severity>(values)
|
|
19
|
+
}
|
|
14
20
|
export const type = isly.object<Base>({
|
|
15
21
|
type: isly.string(),
|
|
22
|
+
severity: Severity.type.optional(),
|
|
16
23
|
resource: isly.string(),
|
|
17
24
|
value: isly.number().optional(),
|
|
18
25
|
date: isly.string(),
|
|
@@ -4,11 +4,13 @@ import { Base } from "../Base"
|
|
|
4
4
|
|
|
5
5
|
export interface Counterbalance extends Base {
|
|
6
6
|
type: "counterbalance"
|
|
7
|
+
severity?: "low"
|
|
7
8
|
currency: isoly.Currency
|
|
8
9
|
}
|
|
9
10
|
export namespace Counterbalance {
|
|
10
11
|
export const type = Base.type.extend<Counterbalance>({
|
|
11
12
|
type: isly.string("counterbalance"),
|
|
13
|
+
severity: isly.string("low").optional(),
|
|
12
14
|
currency: isly.string(),
|
|
13
15
|
})
|
|
14
16
|
}
|
|
@@ -5,6 +5,7 @@ import { Base } from "../Base"
|
|
|
5
5
|
|
|
6
6
|
export interface MissingBuffer extends Base {
|
|
7
7
|
type: "missing-buffer"
|
|
8
|
+
severity?: "high"
|
|
8
9
|
currency: isoly.Currency
|
|
9
10
|
minimum: number
|
|
10
11
|
balance: number
|
|
@@ -12,6 +13,7 @@ export interface MissingBuffer extends Base {
|
|
|
12
13
|
export namespace MissingBuffer {
|
|
13
14
|
export const type = Base.type.extend<MissingBuffer>({
|
|
14
15
|
type: isly.string("missing-buffer"),
|
|
16
|
+
severity: isly.string("high").optional(),
|
|
15
17
|
currency: isly.string(),
|
|
16
18
|
minimum: isly.number(),
|
|
17
19
|
balance: isly.number(),
|
|
@@ -4,11 +4,13 @@ import { Base } from "../Base"
|
|
|
4
4
|
|
|
5
5
|
export interface MissingEmoney extends Base {
|
|
6
6
|
type: "missing-emoney"
|
|
7
|
+
severity?: "high"
|
|
7
8
|
currency: isoly.Currency
|
|
8
9
|
}
|
|
9
10
|
export namespace MissingEmoney {
|
|
10
11
|
export const type = Base.type.extend<MissingEmoney>({
|
|
11
12
|
type: isly.string("missing-emoney"),
|
|
13
|
+
severity: isly.string("high").optional(),
|
|
12
14
|
currency: isly.string(),
|
|
13
15
|
})
|
|
14
16
|
}
|
|
@@ -4,11 +4,13 @@ import { Base } from "../Base"
|
|
|
4
4
|
|
|
5
5
|
export interface MissingFiat extends Base {
|
|
6
6
|
type: "missing-fiat"
|
|
7
|
+
severity?: "high"
|
|
7
8
|
currency: isoly.Currency
|
|
8
9
|
}
|
|
9
10
|
export namespace MissingFiat {
|
|
10
11
|
export const type = Base.type.extend<MissingFiat>({
|
|
11
12
|
type: isly.string("missing-fiat"),
|
|
13
|
+
severity: isly.string("high").optional(),
|
|
12
14
|
currency: isly.string(),
|
|
13
15
|
})
|
|
14
16
|
}
|
|
@@ -4,6 +4,7 @@ import { Base } from "../Base"
|
|
|
4
4
|
|
|
5
5
|
export interface Overdraft extends Base {
|
|
6
6
|
type: "overdraft"
|
|
7
|
+
severity?: "medium"
|
|
7
8
|
organization: string
|
|
8
9
|
currency: isoly.Currency
|
|
9
10
|
}
|
|
@@ -11,6 +12,7 @@ export interface Overdraft extends Base {
|
|
|
11
12
|
export namespace Overdraft {
|
|
12
13
|
export const type = Base.type.extend<Overdraft>({
|
|
13
14
|
type: isly.string("overdraft"),
|
|
15
|
+
severity: isly.string("medium").optional(),
|
|
14
16
|
organization: isly.string(),
|
|
15
17
|
currency: isly.fromIs("Currency", isoly.Currency.is),
|
|
16
18
|
})
|
|
@@ -6,12 +6,14 @@ import { Base } from "../Base"
|
|
|
6
6
|
|
|
7
7
|
export interface StaleFiat extends Base {
|
|
8
8
|
type: "stale-fiat"
|
|
9
|
+
severity?: "low"
|
|
9
10
|
currency: isoly.Currency
|
|
10
11
|
transaction: { id: string; created: isoly.DateTime }
|
|
11
12
|
}
|
|
12
13
|
export namespace StaleFiat {
|
|
13
14
|
export const type = Base.type.extend<StaleFiat>({
|
|
14
15
|
type: isly.string("stale-fiat"),
|
|
16
|
+
severity: isly.string("low").optional(),
|
|
15
17
|
currency: isly.string(),
|
|
16
18
|
transaction: isly.object<StaleFiat["transaction"]>({ id: isly.string(), created: isly.string() }),
|
|
17
19
|
})
|
package/dist/cjs/Identifier.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { cryptly } from "cryptly";
|
|
2
2
|
import { isoly } from "isoly";
|
|
3
3
|
import { isly } from "isly";
|
|
4
|
-
import
|
|
4
|
+
import { zod } from "./zod";
|
|
5
5
|
export type Identifier = cryptly.Identifier;
|
|
6
6
|
export declare namespace Identifier {
|
|
7
7
|
function generate(date?: isoly.DateTime, length?: cryptly.Identifier.Length, ordering?: "ordered" | "reversed"): string;
|
|
8
8
|
function timeOf(identifier: cryptly.Identifier, ordering?: "ordered" | "reversed"): isoly.DateTime;
|
|
9
9
|
const type: isly.Type<string>;
|
|
10
|
-
const
|
|
10
|
+
const typeZod: zod.ZodString;
|
|
11
11
|
}
|
package/dist/cjs/Identifier.js
CHANGED
|
@@ -1,43 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.Identifier = void 0;
|
|
37
4
|
const cryptly_1 = require("cryptly");
|
|
38
5
|
const isoly_1 = require("isoly");
|
|
39
6
|
const isly_1 = require("isly");
|
|
40
|
-
const
|
|
7
|
+
const zod_1 = require("./zod");
|
|
41
8
|
var Identifier;
|
|
42
9
|
(function (Identifier) {
|
|
43
10
|
function generate(date = isoly_1.isoly.DateTime.now(), length = 16, ordering = "reversed") {
|
|
@@ -50,6 +17,6 @@ var Identifier;
|
|
|
50
17
|
}
|
|
51
18
|
Identifier.timeOf = timeOf;
|
|
52
19
|
Identifier.type = isly_1.isly.fromIs("Identifier", cryptly_1.cryptly.Identifier.is);
|
|
53
|
-
Identifier.
|
|
20
|
+
Identifier.typeZod = zod_1.zod.string().refine(cryptly_1.cryptly.Identifier.is);
|
|
54
21
|
})(Identifier || (exports.Identifier = Identifier = {}));
|
|
55
22
|
//# sourceMappingURL=Identifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Identifier.js","sourceRoot":"","sources":["../../Identifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Identifier.js","sourceRoot":"","sources":["../../Identifier.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,iCAA6B;AAC7B,+BAA2B;AAC3B,+BAA2B;AAG3B,IAAiB,UAAU,CAiB1B;AAjBD,WAAiB,UAAU;IAC1B,SAAgB,QAAQ,CACvB,OAAuB,aAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,EAC3C,SAAoC,EAAE,EACtC,WAAmC,UAAU;QAE7C,OAAO,iBAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAA;IACjG,CAAC;IANe,mBAAQ,WAMvB,CAAA;IACD,SAAgB,MAAM,CACrB,UAA8B,EAC9B,WAAmC,UAAU;QAE7C,MAAM,OAAO,GAAG,iBAAO,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAC3D,OAAO,aAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;IACnH,CAAC;IANe,iBAAM,SAMrB,CAAA;IACY,eAAI,GAAG,WAAI,CAAC,MAAM,CAAC,YAAY,EAAE,iBAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IACvD,kBAAO,GAAG,SAAG,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,iBAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;AAClE,CAAC,EAjBgB,UAAU,0BAAV,UAAU,QAiB1B"}
|
package/dist/cjs/Log/Entry.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { zod } from "../zod";
|
|
2
2
|
export declare namespace Entry {
|
|
3
|
-
const type:
|
|
4
|
-
message:
|
|
5
|
-
data:
|
|
6
|
-
}, z.core.$strip>;
|
|
3
|
+
const type: zod.ZodObject<{
|
|
4
|
+
message: zod.ZodString;
|
|
5
|
+
data: zod.ZodOptional<zod.ZodAny>;
|
|
6
|
+
}, zod.z.core.$strip>;
|
|
7
7
|
namespace Message {
|
|
8
|
-
const type:
|
|
9
|
-
resource:
|
|
10
|
-
message:
|
|
11
|
-
data:
|
|
12
|
-
}, z.core.$strip>;
|
|
8
|
+
const type: zod.ZodObject<{
|
|
9
|
+
resource: zod.ZodOptional<zod.ZodString>;
|
|
10
|
+
message: zod.ZodString;
|
|
11
|
+
data: zod.ZodOptional<zod.ZodAny>;
|
|
12
|
+
}, zod.z.core.$strip>;
|
|
13
13
|
function to(message: string, data: any | undefined, resource: string | undefined): Entry.Message;
|
|
14
14
|
}
|
|
15
|
-
type Message =
|
|
15
|
+
type Message = zod.infer<typeof Message.type>;
|
|
16
16
|
}
|
|
17
|
-
export type Entry =
|
|
17
|
+
export type Entry = zod.infer<typeof Entry.type>;
|