payid-types 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # types
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run index.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.2.21. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src";
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "payid-types",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "bun build src/index.ts --outdir dist --target node"
10
+ },
11
+ "devDependencies": {
12
+ "@types/bun": "latest"
13
+ },
14
+ "peerDependencies": {
15
+ "typescript": "^5"
16
+ }
17
+ }
@@ -0,0 +1,31 @@
1
+ export interface RuleContext {
2
+ tx: {
3
+ sender?: string;
4
+ asset: string;
5
+ amount: string;
6
+ chainId: number;
7
+ receiver?: string;
8
+ };
9
+ payId?: {
10
+ id: string;
11
+ owner: string;
12
+ };
13
+ }
14
+ export interface TxContext {
15
+ sender: string;
16
+ receiver: string;
17
+ asset: string;
18
+ amount: string;
19
+ chainId: number;
20
+ memo?: string;
21
+ }
22
+
23
+ export interface PayIdContext {
24
+ id: string;
25
+ owner: string;
26
+ }
27
+
28
+ export interface ContextV1 {
29
+ tx: TxContext;
30
+ payId: PayIdContext;
31
+ }
@@ -0,0 +1,43 @@
1
+ import type { ContextV1 } from "./context.v1";
2
+
3
+ export interface Attestation {
4
+ issuer: string;
5
+ issuedAt: number;
6
+ expiresAt: number;
7
+ signature: string;
8
+ }
9
+
10
+ /* ---- Extensions ---- */
11
+
12
+ export interface EnvContext {
13
+ timestamp: number;
14
+ proof: Attestation;
15
+ }
16
+
17
+ export interface StateContext {
18
+ spentToday: string;
19
+ period: string;
20
+ proof: Attestation;
21
+ }
22
+
23
+ export interface OracleContext {
24
+ [key: string]: string | number | Attestation;
25
+ proof: Attestation;
26
+ }
27
+
28
+ export interface RiskContext {
29
+ score: number;
30
+ category: string;
31
+ proof: Attestation & {
32
+ modelHash: string;
33
+ };
34
+ }
35
+
36
+ /* ---- Final Context ---- */
37
+
38
+ export interface ContextV2 extends ContextV1 {
39
+ env?: EnvContext;
40
+ state?: StateContext;
41
+ oracle?: OracleContext;
42
+ risk?: RiskContext;
43
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./context.v1";
2
+ export * from "./context.v2";
3
+ export * from "./result";
4
+ export * from "./rule";
package/src/result.ts ADDED
@@ -0,0 +1,5 @@
1
+ export interface RuleResult {
2
+ decision: "ALLOW" | "REJECT";
3
+ code: string;
4
+ reason?: string;
5
+ }
package/src/rule.ts ADDED
@@ -0,0 +1,17 @@
1
+ export interface RuleCondition {
2
+ field: string;
3
+ op: string;
4
+ value: any;
5
+ }
6
+
7
+ export interface Rule {
8
+ id: string;
9
+ if: RuleCondition;
10
+ }
11
+
12
+ export interface RuleConfig {
13
+ version?: string;
14
+ logic: "AND" | "OR";
15
+ rules: Rule[];
16
+ requires?: string[];
17
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Environment setup & latest features
4
+ "lib": ["ESNext"],
5
+ "target": "ESNext",
6
+ "module": "Preserve",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noUncheckedIndexedAccess": true,
22
+ "noImplicitOverride": true,
23
+
24
+ // Some stricter flags (disabled by default)
25
+ "noUnusedLocals": false,
26
+ "noUnusedParameters": false,
27
+ "noPropertyAccessFromIndexSignature": false
28
+ }
29
+ }