@octane-rgs/fairness 1.0.9
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 +65 -0
- package/dist/client.d.ts +23 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +47 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @octane-rgs/fairness
|
|
2
|
+
|
|
3
|
+
SDK for provably fair RNG generation, seed reveal, and audit tooling for Octane RGS. It also keeps the lightweight round-operation helpers used by live or external services that need explicit settlement.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @octane-rgs/fairness
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start — Live Games
|
|
12
|
+
|
|
13
|
+
For live games where the external game server controls the round lifecycle:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { OctaneFairnessClient } from "@octane-rgs/fairness";
|
|
17
|
+
|
|
18
|
+
const rgs = new OctaneFairnessClient({
|
|
19
|
+
baseUrl: "https://staging.octanestudios.ai",
|
|
20
|
+
apiKey: "your-api-key",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Fetch floats from the RGS
|
|
24
|
+
const { values } = await rgs.fetchRng({ roundId, count: 6 });
|
|
25
|
+
|
|
26
|
+
// Update round data with game results
|
|
27
|
+
await rgs.updateRoundOutcome(roundId, { grid: [[1, 2, 3]], winLines: [0] });
|
|
28
|
+
|
|
29
|
+
// Settle the round explicitly
|
|
30
|
+
await rgs.settle({
|
|
31
|
+
roundId,
|
|
32
|
+
gameType: "roulette",
|
|
33
|
+
closeRound: true,
|
|
34
|
+
multipliers: [{ betOption: "red", multiplier: 2 }],
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
### OctaneFairnessClient
|
|
41
|
+
|
|
42
|
+
| Method | Description |
|
|
43
|
+
|--------|-------------|
|
|
44
|
+
| `settle(params)` | Settle a round explicitly (live games) |
|
|
45
|
+
| `updateRoundOutcome(roundId, data)` | Store game outcome data on a round |
|
|
46
|
+
| `fetchRng(params)` | Fetch provably fair random numbers from the RGS (live games) |
|
|
47
|
+
| `revealSeed(params)` | Reveal server seed for verification |
|
|
48
|
+
|
|
49
|
+
### RNG (re-exported from `@octane-rgs/rng`)
|
|
50
|
+
|
|
51
|
+
| Function | Description |
|
|
52
|
+
|----------|-------------|
|
|
53
|
+
| `createFloatGenerator(serverSeed, clientSeed, nonce)` | Create a stateful generator yielding floats in `[0, 1)` |
|
|
54
|
+
| `createFloatGenerator(seed)` | Same, accepts a `Seed` object |
|
|
55
|
+
| `verify(serverSeed, clientSeed, nonce, count)` | Reproduce N floats + server seed hash for verification |
|
|
56
|
+
| `hashSeed(serverSeed)` | SHA-256 hash of a server seed |
|
|
57
|
+
|
|
58
|
+
### Types (re-exported from `@octane-rgs/rng`)
|
|
59
|
+
|
|
60
|
+
| Type | Description |
|
|
61
|
+
|------|-------------|
|
|
62
|
+
| `Seed` | `{ serverSeed, clientSeed, nonce }` |
|
|
63
|
+
| `FloatGenerator` | `{ generateFloat(), generateFloats(count) }` |
|
|
64
|
+
| `VerifyResult` | `{ values, serverSeedHash }` |
|
|
65
|
+
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RgsClientOptions, SettleParams, SettleResult, RoundRecord, RngParams, RngResult, RevealSeedParams } from "./types.js";
|
|
2
|
+
export declare class RgsError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
constructor(message: string, status: number);
|
|
5
|
+
}
|
|
6
|
+
export declare class OctaneFairnessClient {
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
private readonly apiKey;
|
|
9
|
+
private readonly fetchInit;
|
|
10
|
+
constructor(options: RgsClientOptions);
|
|
11
|
+
private post;
|
|
12
|
+
settle(params: SettleParams): Promise<SettleResult>;
|
|
13
|
+
updateRoundOutcome(roundId: string, gameRoundData: Record<string, unknown>): Promise<{
|
|
14
|
+
round: RoundRecord;
|
|
15
|
+
}>;
|
|
16
|
+
fetchRng(params: RngParams): Promise<RngResult>;
|
|
17
|
+
revealSeed(params: RevealSeedParams): Promise<{
|
|
18
|
+
serverSeed: string;
|
|
19
|
+
clientSeed: string;
|
|
20
|
+
nonce: number;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAChB,YAAY,EAAE,YAAY,EAAE,WAAW,EACvC,SAAS,EAAE,SAAS,EAAE,gBAAgB,EACzC,MAAM,YAAY,CAAC;AAEpB,qBAAa,QAAS,SAAQ,KAAK;aAEc,MAAM,EAAE,MAAM;gBAA/C,OAAO,EAAE,MAAM,EAAkB,MAAM,EAAE,MAAM;CAC9D;AAED,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;gBAE5B,OAAO,EAAE,gBAAgB;YAOvB,IAAI;IAqBlB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAOnD,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,WAAW,CAAA;KAAE,CAAC;IAO5G,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAK/C,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAI3G"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export class RgsError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
constructor(message, status) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.status = status;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class OctaneFairnessClient {
|
|
9
|
+
baseUrl;
|
|
10
|
+
apiKey;
|
|
11
|
+
fetchInit;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
14
|
+
this.apiKey = options.apiKey;
|
|
15
|
+
this.fetchInit = options.fetchInit ?? {};
|
|
16
|
+
}
|
|
17
|
+
async post(path, body) {
|
|
18
|
+
const res = await fetch(`${this.baseUrl}/api/v1${path}`, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: { "Content-Type": "application/json", "X-Api-Key": this.apiKey },
|
|
21
|
+
body: JSON.stringify(body),
|
|
22
|
+
...this.fetchInit,
|
|
23
|
+
});
|
|
24
|
+
if (!res.ok) {
|
|
25
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
26
|
+
const msg = typeof err.error === "string" ? err.error : JSON.stringify(err.error ?? `RGS ${res.status}`);
|
|
27
|
+
throw new RgsError(msg, res.status);
|
|
28
|
+
}
|
|
29
|
+
return res.json();
|
|
30
|
+
}
|
|
31
|
+
// ── Settlement ──────────────────────────────────────────────
|
|
32
|
+
settle(params) {
|
|
33
|
+
return this.post("/bets/settle", params);
|
|
34
|
+
}
|
|
35
|
+
// ── Round Data ──────────────────────────────────────────────
|
|
36
|
+
updateRoundOutcome(roundId, gameRoundData) {
|
|
37
|
+
return this.post("/sessions/update-round-outcome", { roundId, gameRoundData });
|
|
38
|
+
}
|
|
39
|
+
// ── RNG ─────────────────────────────────────────────────────
|
|
40
|
+
fetchRng(params) {
|
|
41
|
+
return this.post("/rng/generate", params);
|
|
42
|
+
}
|
|
43
|
+
revealSeed(params) {
|
|
44
|
+
return this.post("/rng/reveal", params);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEc;IAA7C,YAAY,OAAe,EAAkB,MAAc;QAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAAjC,WAAM,GAAN,MAAM,CAAQ;IAAoB,CAAC;CACnF;AAED,MAAM,OAAO,oBAAoB;IAEZ,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,SAAS,CAAc;IAExC,YAAY,OAAyB;QAEjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;IAC7C,CAAC;IAEO,KAAK,CAAC,IAAI,CAAI,IAAY,EAAE,IAAa;QAE7C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,UAAU,IAAI,EAAE,EAAE;YACrD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE;YACzE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAA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Options, SettleParams, SettleResult, SettlementMultiplier, RoundRecord, RngParams, RngResult, RevealSeedParams, } from "./types.js";
|
|
3
|
+
export { hashSeed, createFloatGenerator, verify } from "@octane-rgs/rng";
|
|
4
|
+
export type { Seed, FloatGenerator, VerifyResult } from "@octane-rgs/rng";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EACR,gBAAgB,EAChB,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAChD,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,GACtD,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAM7D,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface RgsClientOptions {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
fetchInit?: RequestInit;
|
|
5
|
+
}
|
|
6
|
+
export interface SettlementMultiplier {
|
|
7
|
+
betOption: string;
|
|
8
|
+
multiplier: number;
|
|
9
|
+
scale?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SettleParams {
|
|
12
|
+
roundId: string;
|
|
13
|
+
gameType: string;
|
|
14
|
+
closeRound?: boolean;
|
|
15
|
+
multipliers: SettlementMultiplier[];
|
|
16
|
+
}
|
|
17
|
+
export interface SettleResult {
|
|
18
|
+
settled: boolean;
|
|
19
|
+
status: "settled" | "already_settled" | "not_found" | "no_bets";
|
|
20
|
+
playerCount?: number;
|
|
21
|
+
payoutsSucceeded?: number;
|
|
22
|
+
payoutsFailed?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface RoundRecord {
|
|
25
|
+
id: string;
|
|
26
|
+
tableSession: string;
|
|
27
|
+
roundNumber: number;
|
|
28
|
+
bettingOpenAt: string;
|
|
29
|
+
bettingClosedAt: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
gameRoundData: Record<string, unknown> | null;
|
|
32
|
+
status: string;
|
|
33
|
+
}
|
|
34
|
+
export interface RngParams {
|
|
35
|
+
sessionToken?: string;
|
|
36
|
+
roundId?: string;
|
|
37
|
+
count?: number;
|
|
38
|
+
clientSeed?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface RngResult {
|
|
41
|
+
values: number[];
|
|
42
|
+
serverSeedHash: string;
|
|
43
|
+
clientSeed: string;
|
|
44
|
+
nonce: number;
|
|
45
|
+
}
|
|
46
|
+
export interface RevealSeedParams {
|
|
47
|
+
sessionToken?: string;
|
|
48
|
+
roundId?: string;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAE7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IAEjC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM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":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octane-rgs/fairness",
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"description": "Provably fair RNG and audit tooling for Octane RGS",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@octane-rgs/rng": "1.0.4"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.7.3"
|
|
23
|
+
},
|
|
24
|
+
"license": "UNLICENSED"
|
|
25
|
+
}
|