gov-finance-authorization-sdk 1.0.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 +102 -0
- package/dist/client.d.ts +82 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +178 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +28 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +41 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +215 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# @mof-jamaica/gov-finance-authorization-sdk
|
|
2
|
+
|
|
3
|
+
**TypeScript SDK** for the Ministry of Finance Jamaica — Government Financial Authorization & Governance Platform.
|
|
4
|
+
|
|
5
|
+
**Semantic Freeze: v1.0.0** | **API Compatibility: v1.0.0+**
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Pin to an exact version — SDKF-09 forbids wildcard version constraints
|
|
11
|
+
npm install @mof-jamaica/gov-finance-authorization-sdk@1.0.0
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
> **CRITICAL**: SDK version must be pinned exactly (`1.0.0`), not loosely (`^1.0.0`, `~1.0.0`, or `latest`).
|
|
15
|
+
> Wildcard constraints are **unconditionally forbidden** per SDK_SEMANTIC_CONFORMANCE.md SDKF-09
|
|
16
|
+
> and will cause GATE-3 failure in consumer onboarding.
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { GovFinanceAuthorizationClient } from '@mof-jamaica/gov-finance-authorization-sdk';
|
|
22
|
+
|
|
23
|
+
const client = new GovFinanceAuthorizationClient({
|
|
24
|
+
baseUrl: 'https://auth.mof.gov.jm',
|
|
25
|
+
consumingSystemId: 'my-registered-system-id', // Must be registered with the platform
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Single authorization
|
|
29
|
+
const result = await client.authorize({
|
|
30
|
+
actorId: 'real-actor-uuid-here', // OBL-02: real actor identity required
|
|
31
|
+
action: 'debt.approve',
|
|
32
|
+
resource: 'debt_instrument',
|
|
33
|
+
correlationId: 'caller-uuid-here', // OBL-01: must be caller-provided, unique per request
|
|
34
|
+
amount: '5000000.00', // SDKF-02: MUST be a string, not a number
|
|
35
|
+
currency: 'JMD',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// SDKF-01: decision is 'ALLOW' | 'DENY' — never use boolean helpers
|
|
39
|
+
if (result.decision === 'ALLOW') {
|
|
40
|
+
// OBL-04: store explainability for every decision
|
|
41
|
+
await myAuditStore.save({ correlationId, explainability: result.explainability });
|
|
42
|
+
// proceed
|
|
43
|
+
}
|
|
44
|
+
// OBL-05: do NOT retry a DENY as an ALLOW
|
|
45
|
+
// OBL-08: do NOT cache this result — every call requires a live authorization check
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Mandatory Consuming System Obligations
|
|
49
|
+
|
|
50
|
+
Before going to production, your system must satisfy all 4 onboarding gates.
|
|
51
|
+
See `CONSUMER_ONBOARDING_REQUIREMENTS.md` for the full gate sequence.
|
|
52
|
+
|
|
53
|
+
| Obligation | Rule |
|
|
54
|
+
|-----------|------|
|
|
55
|
+
| OBL-01 | Always pass a real `correlationId` — do not auto-generate silently |
|
|
56
|
+
| OBL-02 | Always pass a real `actorId` — not `'system'`, `'anonymous'`, etc. |
|
|
57
|
+
| OBL-03 | Send `amount` as a decimal string, never a number |
|
|
58
|
+
| OBL-04 | Store the full `explainability` block for every decision |
|
|
59
|
+
| OBL-05 | Never retry a DENY as an ALLOW |
|
|
60
|
+
| OBL-06 | If this SDK throws, treat the request as **DENY** (fail-closed) |
|
|
61
|
+
| OBL-07 | Pin SDK to an exact version — no wildcards |
|
|
62
|
+
| OBL-08 | Never cache authorization decisions |
|
|
63
|
+
|
|
64
|
+
## Forbidden Patterns (SDKF-01 through SDKF-10)
|
|
65
|
+
|
|
66
|
+
| Code | Pattern | Consequence |
|
|
67
|
+
|------|---------|-------------|
|
|
68
|
+
| SDKF-01 | Boolean-only helpers (`isAllowed()`) | Hides decision context; audit gap |
|
|
69
|
+
| SDKF-02 | Float/number for financial amounts | Decimal precision failure (INC-DEC SEV-1) |
|
|
70
|
+
| SDKF-03 | Caching decisions | Stale authorization; access retained after revocation |
|
|
71
|
+
| SDKF-04 | Silent correlationId generation | Breaks replay; audit tracing failure |
|
|
72
|
+
| SDKF-05 | Stripping `explainabilityComplete` | Permanent explainability loss |
|
|
73
|
+
| SDKF-06 | Retry masking (DENY→ALLOW) | Unauthorized access; FAA Act violation |
|
|
74
|
+
| SDKF-07 | Hardcoded role checks alongside API | Policy bypass; security incident |
|
|
75
|
+
| SDKF-08 | Placeholder `actorId` values | Actor identity loss; audit integrity failure |
|
|
76
|
+
| SDKF-09 | Wildcard version constraints | Breaking change propagation without control |
|
|
77
|
+
| SDKF-10 | Silent compatibility downgrade | Semantic drift; undetected breaking changes |
|
|
78
|
+
|
|
79
|
+
## Replay API
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// Verify a historical decision
|
|
83
|
+
const replay = await client.replayByCorrelation({
|
|
84
|
+
correlationId: 'original-decision-correlation-id',
|
|
85
|
+
mode: 'VERIFY',
|
|
86
|
+
});
|
|
87
|
+
// replay.result: 'MATCH' | 'DIVERGENCE' | 'INTEGRITY_VIOLATION' | 'AUDIT_RECORD_MISSING'
|
|
88
|
+
|
|
89
|
+
// Get a human-readable explanation for auditors
|
|
90
|
+
const explain = await client.replayByCorrelation({
|
|
91
|
+
correlationId: 'original-decision-correlation-id',
|
|
92
|
+
mode: 'EXPLAIN',
|
|
93
|
+
});
|
|
94
|
+
console.log(explain.explanation);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Version Contract
|
|
98
|
+
|
|
99
|
+
This SDK is governed by `GOVERNANCE_COMPATIBILITY_MATRIX.md`. Breaking changes
|
|
100
|
+
require a Governance Change Review Board (GCRB) vote and a 90-day deprecation notice.
|
|
101
|
+
|
|
102
|
+
Current status: **CURRENT** (v1.0.0, Semantic Freeze v1.0.0)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client.ts — SDK HTTP Client
|
|
3
|
+
*
|
|
4
|
+
* A minimal, governance-conformant HTTP client for the Ministry of Finance
|
|
5
|
+
* Government Financial Authorization & Governance Platform API.
|
|
6
|
+
*
|
|
7
|
+
* GOVERNANCE RULES ENFORCED BY THIS CLIENT:
|
|
8
|
+
* SDK-CT-04: Correlation ID propagated through all requests — caller MUST provide it.
|
|
9
|
+
* SDK-CT-02: Decimal amounts preserved as strings — never coerced to numbers.
|
|
10
|
+
* SDK-CT-01: All response objects are frozen (Object.freeze) after deserialization.
|
|
11
|
+
* SDKF-01: No boolean-only authorization helpers.
|
|
12
|
+
* SDKF-03: No decision caching — every call makes a live request.
|
|
13
|
+
* SDKF-04: correlationId is never auto-generated silently.
|
|
14
|
+
* SDKF-06: No retry masking — failed requests propagate the error.
|
|
15
|
+
* SDKF-09: Client version is pinned, never a wildcard.
|
|
16
|
+
*
|
|
17
|
+
* CONSUMING SYSTEM OBLIGATIONS (CONSUMER_ONBOARDING_REQUIREMENTS.md §2):
|
|
18
|
+
* OBL-01: Always pass a real correlationId.
|
|
19
|
+
* OBL-02: Always pass a real actorId — not 'system', 'anonymous', etc.
|
|
20
|
+
* OBL-04: Store the full explainability block for every decision.
|
|
21
|
+
* OBL-05: Never retry a DENY as an ALLOW.
|
|
22
|
+
* OBL-06: If this client throws, treat as DENY (fail-closed).
|
|
23
|
+
* OBL-07: Pin this SDK to an exact version — no wildcards.
|
|
24
|
+
* OBL-08: Never cache the returned decision.
|
|
25
|
+
*/
|
|
26
|
+
import type { AuthorizationRequest, AuthorizationResponse, BulkAuthorizationRequest, BulkAuthorizationResponse, ReplayByCorrelationRequest, ReplayByTimestampRequest, ReplayResponse } from './types';
|
|
27
|
+
export interface GovFinanceClientConfig {
|
|
28
|
+
/** Base URL of the authorization platform API (e.g. https://auth.mof.gov.jm). */
|
|
29
|
+
baseUrl: string;
|
|
30
|
+
/** Registered consuming system ID — required for telemetry labeling. */
|
|
31
|
+
consumingSystemId: string;
|
|
32
|
+
/**
|
|
33
|
+
* HTTP fetch implementation.
|
|
34
|
+
* Defaults to the global `fetch` (Node 18+, all modern browsers).
|
|
35
|
+
* Inject a custom implementation for testing or environments without global fetch.
|
|
36
|
+
*/
|
|
37
|
+
fetch?: typeof globalThis.fetch;
|
|
38
|
+
/** Request timeout in milliseconds. Defaults to 10000 (10s). */
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
}
|
|
41
|
+
export declare class GovFinanceAuthorizationClient {
|
|
42
|
+
private readonly baseUrl;
|
|
43
|
+
private readonly consumingSystemId;
|
|
44
|
+
private readonly fetchImpl;
|
|
45
|
+
private readonly timeoutMs;
|
|
46
|
+
constructor(config: GovFinanceClientConfig);
|
|
47
|
+
/**
|
|
48
|
+
* Authorize a single request.
|
|
49
|
+
*
|
|
50
|
+
* OBL-01: correlationId must be supplied by caller — this method will throw
|
|
51
|
+
* SdkConformanceError if it is missing (SDKF-04 enforcement).
|
|
52
|
+
* OBL-02: actorId must be a real identity — 'system' and 'anonymous' are rejected.
|
|
53
|
+
* OBL-08: Decision is NOT cached — every call hits the live API.
|
|
54
|
+
*/
|
|
55
|
+
authorize(request: AuthorizationRequest): Promise<AuthorizationResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Authorize a batch of sub-requests in a single call.
|
|
58
|
+
*
|
|
59
|
+
* Per BULK_AUTHORIZATION_SEMANTICS §7.3: policy set is loaded once server-side
|
|
60
|
+
* for the entire batch. The consuming system must not split one logical batch
|
|
61
|
+
* into separate calls to achieve different policy evaluation (SDKF-06).
|
|
62
|
+
*/
|
|
63
|
+
bulkAuthorize(request: BulkAuthorizationRequest): Promise<BulkAuthorizationResponse>;
|
|
64
|
+
/**
|
|
65
|
+
* Replay a historical decision by correlationId.
|
|
66
|
+
*
|
|
67
|
+
* VERIFY mode: re-runs evaluation, returns MATCH or DIVERGENCE.
|
|
68
|
+
* RECONSTRUCT mode: returns reconstructed context and hash-verified policies.
|
|
69
|
+
* EXPLAIN mode: returns all RECONSTRUCT data plus a plain-language narrative.
|
|
70
|
+
*
|
|
71
|
+
* All replay operations are READ-ONLY — no events are emitted, no writes occur.
|
|
72
|
+
*/
|
|
73
|
+
replayByCorrelation(request: ReplayByCorrelationRequest): Promise<ReplayResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Replay the most recent decision for actor+action+resource at or before a timestamp.
|
|
76
|
+
*/
|
|
77
|
+
replayByTimestamp(request: ReplayByTimestampRequest): Promise<ReplayResponse>;
|
|
78
|
+
private validateAuthorizationRequest;
|
|
79
|
+
private validateBulkAuthorizationRequest;
|
|
80
|
+
private post;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,cAAc,EACf,MAAM,SAAS,CAAC;AAQjB,MAAM,WAAW,sBAAsB;IACrC,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,MAAM,EAAE,sBAAsB;IAc1C;;;;;;;OAOG;IACG,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAM9E;;;;;;OAMG;IACG,aAAa,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAU1F;;;;;;;;OAQG;IACG,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,cAAc,CAAC;IAMvF;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC;IAUnF,OAAO,CAAC,4BAA4B;IA0BpC,OAAO,CAAC,gCAAgC;YAsB1B,IAAI;CA4CnB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* client.ts — SDK HTTP Client
|
|
4
|
+
*
|
|
5
|
+
* A minimal, governance-conformant HTTP client for the Ministry of Finance
|
|
6
|
+
* Government Financial Authorization & Governance Platform API.
|
|
7
|
+
*
|
|
8
|
+
* GOVERNANCE RULES ENFORCED BY THIS CLIENT:
|
|
9
|
+
* SDK-CT-04: Correlation ID propagated through all requests — caller MUST provide it.
|
|
10
|
+
* SDK-CT-02: Decimal amounts preserved as strings — never coerced to numbers.
|
|
11
|
+
* SDK-CT-01: All response objects are frozen (Object.freeze) after deserialization.
|
|
12
|
+
* SDKF-01: No boolean-only authorization helpers.
|
|
13
|
+
* SDKF-03: No decision caching — every call makes a live request.
|
|
14
|
+
* SDKF-04: correlationId is never auto-generated silently.
|
|
15
|
+
* SDKF-06: No retry masking — failed requests propagate the error.
|
|
16
|
+
* SDKF-09: Client version is pinned, never a wildcard.
|
|
17
|
+
*
|
|
18
|
+
* CONSUMING SYSTEM OBLIGATIONS (CONSUMER_ONBOARDING_REQUIREMENTS.md §2):
|
|
19
|
+
* OBL-01: Always pass a real correlationId.
|
|
20
|
+
* OBL-02: Always pass a real actorId — not 'system', 'anonymous', etc.
|
|
21
|
+
* OBL-04: Store the full explainability block for every decision.
|
|
22
|
+
* OBL-05: Never retry a DENY as an ALLOW.
|
|
23
|
+
* OBL-06: If this client throws, treat as DENY (fail-closed).
|
|
24
|
+
* OBL-07: Pin this SDK to an exact version — no wildcards.
|
|
25
|
+
* OBL-08: Never cache the returned decision.
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.GovFinanceAuthorizationClient = void 0;
|
|
29
|
+
const types_1 = require("./types");
|
|
30
|
+
const errors_1 = require("./errors");
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Client
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
class GovFinanceAuthorizationClient {
|
|
35
|
+
constructor(config) {
|
|
36
|
+
if (!config.baseUrl)
|
|
37
|
+
throw new errors_1.SdkConformanceError('baseUrl is required');
|
|
38
|
+
if (!config.consumingSystemId)
|
|
39
|
+
throw new errors_1.SdkConformanceError('consumingSystemId is required');
|
|
40
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
41
|
+
this.consumingSystemId = config.consumingSystemId;
|
|
42
|
+
this.fetchImpl = config.fetch ?? globalThis.fetch;
|
|
43
|
+
this.timeoutMs = config.timeoutMs ?? 10000;
|
|
44
|
+
}
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Authorization
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
/**
|
|
49
|
+
* Authorize a single request.
|
|
50
|
+
*
|
|
51
|
+
* OBL-01: correlationId must be supplied by caller — this method will throw
|
|
52
|
+
* SdkConformanceError if it is missing (SDKF-04 enforcement).
|
|
53
|
+
* OBL-02: actorId must be a real identity — 'system' and 'anonymous' are rejected.
|
|
54
|
+
* OBL-08: Decision is NOT cached — every call hits the live API.
|
|
55
|
+
*/
|
|
56
|
+
async authorize(request) {
|
|
57
|
+
this.validateAuthorizationRequest(request);
|
|
58
|
+
const response = await this.post('/api/v1/authorize', request);
|
|
59
|
+
return Object.freeze(response);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Authorize a batch of sub-requests in a single call.
|
|
63
|
+
*
|
|
64
|
+
* Per BULK_AUTHORIZATION_SEMANTICS §7.3: policy set is loaded once server-side
|
|
65
|
+
* for the entire batch. The consuming system must not split one logical batch
|
|
66
|
+
* into separate calls to achieve different policy evaluation (SDKF-06).
|
|
67
|
+
*/
|
|
68
|
+
async bulkAuthorize(request) {
|
|
69
|
+
this.validateBulkAuthorizationRequest(request);
|
|
70
|
+
const response = await this.post('/api/v1/authorize/bulk', request);
|
|
71
|
+
return Object.freeze(response);
|
|
72
|
+
}
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// Historical replay
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
/**
|
|
77
|
+
* Replay a historical decision by correlationId.
|
|
78
|
+
*
|
|
79
|
+
* VERIFY mode: re-runs evaluation, returns MATCH or DIVERGENCE.
|
|
80
|
+
* RECONSTRUCT mode: returns reconstructed context and hash-verified policies.
|
|
81
|
+
* EXPLAIN mode: returns all RECONSTRUCT data plus a plain-language narrative.
|
|
82
|
+
*
|
|
83
|
+
* All replay operations are READ-ONLY — no events are emitted, no writes occur.
|
|
84
|
+
*/
|
|
85
|
+
async replayByCorrelation(request) {
|
|
86
|
+
if (!request.correlationId)
|
|
87
|
+
throw new errors_1.SdkConformanceError('correlationId is required for replay');
|
|
88
|
+
const response = await this.post('/api/v1/replay/by-correlation', request);
|
|
89
|
+
return Object.freeze(response);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Replay the most recent decision for actor+action+resource at or before a timestamp.
|
|
93
|
+
*/
|
|
94
|
+
async replayByTimestamp(request) {
|
|
95
|
+
if (!request.actorId)
|
|
96
|
+
throw new errors_1.SdkConformanceError('actorId is required for timestamp replay');
|
|
97
|
+
const response = await this.post('/api/v1/replay/by-timestamp', request);
|
|
98
|
+
return Object.freeze(response);
|
|
99
|
+
}
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
// Validation helpers — SDKF enforcement
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
validateAuthorizationRequest(req) {
|
|
104
|
+
// SDKF-04: correlationId must not be auto-generated silently
|
|
105
|
+
if (!req.correlationId) {
|
|
106
|
+
throw new errors_1.SdkConformanceError('SDKF-04 VIOLATION: correlationId is required and must be provided by the caller. ' +
|
|
107
|
+
'The SDK does not generate correlationIds silently.');
|
|
108
|
+
}
|
|
109
|
+
// SDKF-08: actorId must not be a placeholder
|
|
110
|
+
if (!req.actorId || req.actorId === 'system' || req.actorId === 'anonymous' || req.actorId === 'unknown') {
|
|
111
|
+
throw new errors_1.SdkConformanceError(`SDKF-08 VIOLATION: actorId='${req.actorId}' is a forbidden placeholder. ` +
|
|
112
|
+
'Consuming system must assert real actor identity.');
|
|
113
|
+
}
|
|
114
|
+
// SDKF-02: amount must be a string if provided
|
|
115
|
+
if (req.amount !== undefined && typeof req.amount !== 'string') {
|
|
116
|
+
throw new errors_1.SdkConformanceError(`SDKF-02 VIOLATION: amount must be a decimal string (e.g. "5000000.00"), not a ${typeof req.amount}. ` +
|
|
117
|
+
'Float and number types are prohibited for financial amounts.');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
validateBulkAuthorizationRequest(req) {
|
|
121
|
+
if (!req.correlationId) {
|
|
122
|
+
throw new errors_1.SdkConformanceError('SDKF-04 VIOLATION: correlationId is required for bulk authorization.');
|
|
123
|
+
}
|
|
124
|
+
if (!req.actorId || req.actorId === 'system' || req.actorId === 'anonymous') {
|
|
125
|
+
throw new errors_1.SdkConformanceError(`SDKF-08 VIOLATION: actorId='${req.actorId}' is a forbidden placeholder in bulk authorization.`);
|
|
126
|
+
}
|
|
127
|
+
for (const sub of req.requests) {
|
|
128
|
+
if (sub.amount !== undefined && typeof sub.amount !== 'string') {
|
|
129
|
+
throw new errors_1.SdkConformanceError(`SDKF-02 VIOLATION: sub-request amount must be a decimal string, not a ${typeof sub.amount}.`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
// HTTP helpers
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
async post(path, body) {
|
|
137
|
+
const url = `${this.baseUrl}${path}`;
|
|
138
|
+
const controller = new AbortController();
|
|
139
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
140
|
+
let response;
|
|
141
|
+
try {
|
|
142
|
+
response = await this.fetchImpl(url, {
|
|
143
|
+
method: 'POST',
|
|
144
|
+
headers: {
|
|
145
|
+
'Content-Type': 'application/json',
|
|
146
|
+
'X-Consuming-System': this.consumingSystemId,
|
|
147
|
+
'X-SDK-Version': types_1.SDK_VERSION_INFO.version,
|
|
148
|
+
},
|
|
149
|
+
body: JSON.stringify(body),
|
|
150
|
+
signal: controller.signal,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
clearTimeout(timer);
|
|
155
|
+
// OBL-06: If network fails, the consumer must treat as DENY (fail-closed).
|
|
156
|
+
// The client throws rather than returning a synthetic ALLOW.
|
|
157
|
+
throw new Error(`GovernanceClient: network error for ${path} — OBL-06: treat as DENY (fail-closed). ` +
|
|
158
|
+
`Underlying: ${err instanceof Error ? err.message : String(err)}`);
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
clearTimeout(timer);
|
|
162
|
+
}
|
|
163
|
+
if (!response.ok) {
|
|
164
|
+
let detail = '';
|
|
165
|
+
try {
|
|
166
|
+
const errorBody = (await response.json());
|
|
167
|
+
detail = JSON.stringify(errorBody);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// ignore JSON parse errors on error bodies
|
|
171
|
+
}
|
|
172
|
+
throw new Error(`GovernanceClient: HTTP ${response.status} from ${path}. Detail: ${detail}`);
|
|
173
|
+
}
|
|
174
|
+
return response.json();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.GovFinanceAuthorizationClient = GovFinanceAuthorizationClient;
|
|
178
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAWH,mCAA2C;AAC3C,qCAA+C;AAqB/C,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,MAAa,6BAA6B;IAMxC,YAAY,MAA8B;QACxC,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,MAAM,IAAI,4BAAmB,CAAC,qBAAqB,CAAC,CAAC;QAC1E,IAAI,CAAC,MAAM,CAAC,iBAAiB;YAAE,MAAM,IAAI,4BAAmB,CAAC,+BAA+B,CAAC,CAAC;QAE9F,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAClD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;QAClD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,KAAM,CAAC;IAC9C,CAAC;IAED,8EAA8E;IAC9E,gBAAgB;IAChB,8EAA8E;IAE9E;;;;;;;OAOG;IACH,KAAK,CAAC,SAAS,CAAC,OAA6B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Q,CAAC,IAAI,EAAE,CAA4B,CAAC;gBACrE,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YACrC,CAAC;YAAC,MAAM,CAAC;gBACP,2CAA2C;YAC7C,CAAC;YACD,MAAM,IAAI,KAAK,CACb,0BAA0B,QAAQ,CAAC,MAAM,SAAS,IAAI,aAAa,MAAM,EAAE,CAC5E,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;IACvC,CAAC;CACF;AA3KD,sEA2KC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* errors.ts — SDK Error Types
|
|
3
|
+
*
|
|
4
|
+
* Per SDK_SEMANTIC_CONFORMANCE.md §4.1: SDK must throw structured errors,
|
|
5
|
+
* never suppress governance failures silently.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* SdkConformanceError — thrown when the consuming system violates an SDK
|
|
9
|
+
* conformance rule (SDKF-01 through SDKF-10).
|
|
10
|
+
*
|
|
11
|
+
* These errors are programmer errors — they indicate the consuming system
|
|
12
|
+
* is using the SDK incorrectly. They must not be caught and suppressed.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SdkConformanceError extends Error {
|
|
15
|
+
readonly code: "SDK_CONFORMANCE_ERROR";
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* GovernanceApiError — thrown when the authorization API returns a non-2xx
|
|
20
|
+
* response that is not a validation error.
|
|
21
|
+
*/
|
|
22
|
+
export declare class GovernanceApiError extends Error {
|
|
23
|
+
readonly statusCode: number;
|
|
24
|
+
readonly detail?: string | undefined;
|
|
25
|
+
readonly code: "GOVERNANCE_API_ERROR";
|
|
26
|
+
constructor(message: string, statusCode: number, detail?: string | undefined);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAG,uBAAuB,CAAU;gBAErC,OAAO,EAAE,MAAM;CAK5B;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;aAKzB,UAAU,EAAE,MAAM;aAClB,MAAM,CAAC,EAAE,MAAM;IALjC,QAAQ,CAAC,IAAI,EAAG,sBAAsB,CAAU;gBAG9C,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,YAAA;CAMlC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* errors.ts — SDK Error Types
|
|
4
|
+
*
|
|
5
|
+
* Per SDK_SEMANTIC_CONFORMANCE.md §4.1: SDK must throw structured errors,
|
|
6
|
+
* never suppress governance failures silently.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.GovernanceApiError = exports.SdkConformanceError = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* SdkConformanceError — thrown when the consuming system violates an SDK
|
|
12
|
+
* conformance rule (SDKF-01 through SDKF-10).
|
|
13
|
+
*
|
|
14
|
+
* These errors are programmer errors — they indicate the consuming system
|
|
15
|
+
* is using the SDK incorrectly. They must not be caught and suppressed.
|
|
16
|
+
*/
|
|
17
|
+
class SdkConformanceError extends Error {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.code = 'SDK_CONFORMANCE_ERROR';
|
|
21
|
+
this.name = 'SdkConformanceError';
|
|
22
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.SdkConformanceError = SdkConformanceError;
|
|
26
|
+
/**
|
|
27
|
+
* GovernanceApiError — thrown when the authorization API returns a non-2xx
|
|
28
|
+
* response that is not a validation error.
|
|
29
|
+
*/
|
|
30
|
+
class GovernanceApiError extends Error {
|
|
31
|
+
constructor(message, statusCode, detail) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.statusCode = statusCode;
|
|
34
|
+
this.detail = detail;
|
|
35
|
+
this.code = 'GOVERNANCE_API_ERROR';
|
|
36
|
+
this.name = 'GovernanceApiError';
|
|
37
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.GovernanceApiError = GovernanceApiError;
|
|
41
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;;GAMG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAG5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAG,uBAAgC,CAAC;QAI/C,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AARD,kDAQC;AAED;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAG3C,YACE,OAAe,EACC,UAAkB,EAClB,MAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,eAAU,GAAV,UAAU,CAAQ;QAClB,WAAM,GAAN,MAAM,CAAS;QALxB,SAAI,GAAG,sBAA+B,CAAC;QAQ9C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAZD,gDAYC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mof-jamaica/gov-finance-authorization-sdk
|
|
3
|
+
*
|
|
4
|
+
* TypeScript SDK for the Ministry of Finance Jamaica Government Financial Authorization
|
|
5
|
+
* & Governance Platform.
|
|
6
|
+
*
|
|
7
|
+
* SEMANTIC FREEZE v1.0.0
|
|
8
|
+
* Compatible with API v1.0.0+
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* import { GovFinanceAuthorizationClient } from '@mof-jamaica/gov-finance-authorization-sdk';
|
|
12
|
+
*
|
|
13
|
+
* const client = new GovFinanceAuthorizationClient({
|
|
14
|
+
* baseUrl: 'https://auth.mof.gov.jm',
|
|
15
|
+
* consumingSystemId: 'my-registered-system',
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* const result = await client.authorize({
|
|
19
|
+
* actorId: 'real-actor-uuid', // OBL-02: must be a real actor identity
|
|
20
|
+
* action: 'debt.approve',
|
|
21
|
+
* resource: 'debt_instrument',
|
|
22
|
+
* correlationId: 'caller-provided-uuid', // OBL-01: must be caller-provided
|
|
23
|
+
* amount: '5000000.00', // SDKF-02: decimal string, never a number
|
|
24
|
+
* currency: 'JMD',
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // SDKF-01: use result.decision === 'ALLOW', never a boolean helper
|
|
28
|
+
* if (result.decision === 'ALLOW') {
|
|
29
|
+
* // OBL-04: store result.explainability for audit records
|
|
30
|
+
* await storeExplainability(result.explainability);
|
|
31
|
+
* // proceed with the operation
|
|
32
|
+
* }
|
|
33
|
+
* // OBL-05: do NOT retry a DENY as an ALLOW
|
|
34
|
+
* // OBL-08: do NOT cache this result — every call requires a live check
|
|
35
|
+
*/
|
|
36
|
+
export { GovFinanceAuthorizationClient } from './client';
|
|
37
|
+
export { SdkConformanceError, GovernanceApiError } from './errors';
|
|
38
|
+
export { SDK_VERSION_INFO } from './types';
|
|
39
|
+
export type { GovFinanceClientConfig } from './client';
|
|
40
|
+
export type { AuthorizationRequest, AuthorizationResponse, ExplainabilityMetadata, BulkAuthorizationRequest, BulkAuthorizationSubRequest, BulkAuthorizationResponse, BulkSubResult, BulkAuthorizationSummary, ReplayByCorrelationRequest, ReplayByTimestampRequest, ReplayResponse, ReplayPolicyVersion, ReplayMetadata, AuthorizationDecision, WorkflowState, ReplayMode, ReplayResult, DecimalString, SdkVersionInfo, } from './types';
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,YAAY,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,aAAa,EACb,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @mof-jamaica/gov-finance-authorization-sdk
|
|
4
|
+
*
|
|
5
|
+
* TypeScript SDK for the Ministry of Finance Jamaica Government Financial Authorization
|
|
6
|
+
* & Governance Platform.
|
|
7
|
+
*
|
|
8
|
+
* SEMANTIC FREEZE v1.0.0
|
|
9
|
+
* Compatible with API v1.0.0+
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* import { GovFinanceAuthorizationClient } from '@mof-jamaica/gov-finance-authorization-sdk';
|
|
13
|
+
*
|
|
14
|
+
* const client = new GovFinanceAuthorizationClient({
|
|
15
|
+
* baseUrl: 'https://auth.mof.gov.jm',
|
|
16
|
+
* consumingSystemId: 'my-registered-system',
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* const result = await client.authorize({
|
|
20
|
+
* actorId: 'real-actor-uuid', // OBL-02: must be a real actor identity
|
|
21
|
+
* action: 'debt.approve',
|
|
22
|
+
* resource: 'debt_instrument',
|
|
23
|
+
* correlationId: 'caller-provided-uuid', // OBL-01: must be caller-provided
|
|
24
|
+
* amount: '5000000.00', // SDKF-02: decimal string, never a number
|
|
25
|
+
* currency: 'JMD',
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // SDKF-01: use result.decision === 'ALLOW', never a boolean helper
|
|
29
|
+
* if (result.decision === 'ALLOW') {
|
|
30
|
+
* // OBL-04: store result.explainability for audit records
|
|
31
|
+
* await storeExplainability(result.explainability);
|
|
32
|
+
* // proceed with the operation
|
|
33
|
+
* }
|
|
34
|
+
* // OBL-05: do NOT retry a DENY as an ALLOW
|
|
35
|
+
* // OBL-08: do NOT cache this result — every call requires a live check
|
|
36
|
+
*/
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.SDK_VERSION_INFO = exports.GovernanceApiError = exports.SdkConformanceError = exports.GovFinanceAuthorizationClient = void 0;
|
|
39
|
+
var client_1 = require("./client");
|
|
40
|
+
Object.defineProperty(exports, "GovFinanceAuthorizationClient", { enumerable: true, get: function () { return client_1.GovFinanceAuthorizationClient; } });
|
|
41
|
+
var errors_1 = require("./errors");
|
|
42
|
+
Object.defineProperty(exports, "SdkConformanceError", { enumerable: true, get: function () { return errors_1.SdkConformanceError; } });
|
|
43
|
+
Object.defineProperty(exports, "GovernanceApiError", { enumerable: true, get: function () { return errors_1.GovernanceApiError; } });
|
|
44
|
+
var types_1 = require("./types");
|
|
45
|
+
Object.defineProperty(exports, "SDK_VERSION_INFO", { enumerable: true, get: function () { return types_1.SDK_VERSION_INFO; } });
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AAEH,mCAAyD;AAAhD,uHAAA,6BAA6B,OAAA;AACtC,mCAAmE;AAA1D,6GAAA,mBAAmB,OAAA;AAAE,4GAAA,kBAAkB,OAAA;AAChD,iCAA2C;AAAlC,yGAAA,gBAAgB,OAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* types.ts — SDK Canonical Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Per SDK_SEMANTIC_CONFORMANCE.md §2: all SDK types are immutable after construction.
|
|
5
|
+
* Per SYSTEM_CONSTITUTION §22: all financial amounts are decimal strings, NEVER numbers.
|
|
6
|
+
*
|
|
7
|
+
* SEMANTIC FREEZE v1.0.0 — these types must not change without a GCRB vote.
|
|
8
|
+
*
|
|
9
|
+
* SDKF-01: No boolean-only authorization helpers (isAllowed(), canApprove(), etc.)
|
|
10
|
+
* SDKF-02: No float or number types for financial amounts
|
|
11
|
+
* SDKF-03: No decision caching at SDK layer
|
|
12
|
+
* SDKF-04: No silent correlation ID generation
|
|
13
|
+
* SDKF-05: No stripping of explainabilityComplete field
|
|
14
|
+
* SDKF-06: No retry masking (retrying a DENY as ALLOW)
|
|
15
|
+
* SDKF-07: No hardcoded role checks
|
|
16
|
+
* SDKF-08: No default actorId values
|
|
17
|
+
* SDKF-09: No wildcard SDK version pinning
|
|
18
|
+
* SDKF-10: No silent compatibility downgrade
|
|
19
|
+
*/
|
|
20
|
+
/** Authorization decision — string enum per SDKF-01 (no boolean-only helpers). */
|
|
21
|
+
export type AuthorizationDecision = 'ALLOW' | 'DENY';
|
|
22
|
+
/** Canonical workflow states per WORKFLOW_STATE_REGISTRY v1.0-semantic-freeze. */
|
|
23
|
+
export type WorkflowState = 'DRAFT' | 'REVIEW' | 'APPROVED' | 'REJECTED' | 'REVOKED' | 'ARCHIVED';
|
|
24
|
+
/** Replay modes per HISTORICAL_REPLAY_ARCHITECTURE §4.1. */
|
|
25
|
+
export type ReplayMode = 'VERIFY' | 'RECONSTRUCT' | 'EXPLAIN';
|
|
26
|
+
/** Replay result per HISTORICAL_REPLAY_ARCHITECTURE §5.1. */
|
|
27
|
+
export type ReplayResult = 'MATCH' | 'DIVERGENCE' | 'INTEGRITY_VIOLATION' | 'AUDIT_RECORD_MISSING';
|
|
28
|
+
/**
|
|
29
|
+
* DecimalString — a financial amount encoded as a string.
|
|
30
|
+
*
|
|
31
|
+
* GOVERNANCE RULE: amounts MUST be transmitted as strings, never as numbers.
|
|
32
|
+
* Examples: "5000000.00", "123456.78", "0.01"
|
|
33
|
+
*
|
|
34
|
+
* This type alias serves as a semantic marker. Values assigned to this type
|
|
35
|
+
* must satisfy /^\d+(\.\d+)?$/. Validation is performed server-side per
|
|
36
|
+
* SDK_SEMANTIC_CONFORMANCE.md SDK-CT-02.
|
|
37
|
+
*
|
|
38
|
+
* SDKF-02: Do NOT use number or float for financial amounts.
|
|
39
|
+
*/
|
|
40
|
+
export type DecimalString = string;
|
|
41
|
+
/**
|
|
42
|
+
* AuthorizationRequest — request body for POST /api/v1/authorize.
|
|
43
|
+
*
|
|
44
|
+
* All fields are readonly — immutable after construction per SDK-CT-01.
|
|
45
|
+
* correlationId MUST be supplied by the caller — never auto-generated (SDKF-04).
|
|
46
|
+
* actorId MUST be a real actor identity — never a placeholder (SDKF-08).
|
|
47
|
+
*/
|
|
48
|
+
export interface AuthorizationRequest {
|
|
49
|
+
readonly actorId: string;
|
|
50
|
+
readonly action: string;
|
|
51
|
+
readonly resource: string;
|
|
52
|
+
readonly correlationId: string;
|
|
53
|
+
readonly resourceId?: string;
|
|
54
|
+
readonly workflowState?: WorkflowState;
|
|
55
|
+
readonly organizationId?: string;
|
|
56
|
+
/** Financial amount — MUST be a DecimalString, never a number (SDKF-02). */
|
|
57
|
+
readonly amount?: DecimalString;
|
|
58
|
+
readonly currency?: string;
|
|
59
|
+
readonly resourceOwnerId?: string;
|
|
60
|
+
readonly delegationId?: string;
|
|
61
|
+
readonly additionalClaims?: Readonly<Record<string, unknown>>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* ExplainabilityMetadata — mandatory in every authorization response.
|
|
65
|
+
*
|
|
66
|
+
* Per EXPLAINABILITY_COMPLETENESS_RULES.md EC-01: present in every response.
|
|
67
|
+
* SDKF-05: explainabilityComplete MUST NOT be stripped by consuming systems.
|
|
68
|
+
*/
|
|
69
|
+
export interface ExplainabilityMetadata {
|
|
70
|
+
readonly matchedPolicies: readonly string[];
|
|
71
|
+
readonly failedConditions: readonly string[];
|
|
72
|
+
readonly evaluationPhaseReached: number;
|
|
73
|
+
/** SDKF-05: this field is mandatory — do not omit when storing or forwarding. */
|
|
74
|
+
readonly explainabilityComplete: boolean;
|
|
75
|
+
readonly explainabilityVersion?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* AuthorizationResponse — response from POST /api/v1/authorize.
|
|
79
|
+
*
|
|
80
|
+
* SDKF-01: decision is 'ALLOW' | 'DENY' — not a boolean.
|
|
81
|
+
* explainability is always present — never undefined (EC-01).
|
|
82
|
+
*/
|
|
83
|
+
export interface AuthorizationResponse {
|
|
84
|
+
readonly decision: AuthorizationDecision;
|
|
85
|
+
readonly errorCode?: string;
|
|
86
|
+
readonly message?: string;
|
|
87
|
+
/** Always present — SDKF-05 forbids stripping this. */
|
|
88
|
+
readonly explainability: ExplainabilityMetadata;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* BulkAuthorizationSubRequest — one item in a bulk batch.
|
|
92
|
+
*/
|
|
93
|
+
export interface BulkAuthorizationSubRequest {
|
|
94
|
+
readonly actorId?: string;
|
|
95
|
+
readonly action: string;
|
|
96
|
+
readonly resource: string;
|
|
97
|
+
readonly resourceId?: string;
|
|
98
|
+
readonly workflowState?: WorkflowState;
|
|
99
|
+
readonly amount?: DecimalString;
|
|
100
|
+
readonly currency?: string;
|
|
101
|
+
readonly delegationId?: string;
|
|
102
|
+
readonly additionalClaims?: Readonly<Record<string, unknown>>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* BulkAuthorizationRequest — request body for POST /api/v1/authorize/bulk.
|
|
106
|
+
*
|
|
107
|
+
* actorId is asserted once for the batch (SDKF-08: no placeholder defaults).
|
|
108
|
+
* correlationId is mandatory per SDK-CT-04.
|
|
109
|
+
*/
|
|
110
|
+
export interface BulkAuthorizationRequest {
|
|
111
|
+
readonly actorId: string;
|
|
112
|
+
readonly correlationId: string;
|
|
113
|
+
readonly requests: readonly BulkAuthorizationSubRequest[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* BulkSubResult — result for a single item in a bulk batch.
|
|
117
|
+
* explainability is always present per EC-01.
|
|
118
|
+
*/
|
|
119
|
+
export interface BulkSubResult {
|
|
120
|
+
readonly index: number;
|
|
121
|
+
readonly decision: AuthorizationDecision;
|
|
122
|
+
readonly errorCode?: string;
|
|
123
|
+
readonly reason?: string;
|
|
124
|
+
readonly explainability?: ExplainabilityMetadata;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* BulkAuthorizationSummary — aggregate counts for the batch.
|
|
128
|
+
*/
|
|
129
|
+
export interface BulkAuthorizationSummary {
|
|
130
|
+
readonly requestCount: number;
|
|
131
|
+
readonly grantedCount: number;
|
|
132
|
+
readonly deniedCount: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* BulkAuthorizationResponse — response from POST /api/v1/authorize/bulk.
|
|
136
|
+
*/
|
|
137
|
+
export interface BulkAuthorizationResponse {
|
|
138
|
+
readonly results: readonly BulkSubResult[];
|
|
139
|
+
readonly summary: BulkAuthorizationSummary;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* ReplayByCorrelationRequest — request body for POST /api/v1/replay/by-correlation.
|
|
143
|
+
*/
|
|
144
|
+
export interface ReplayByCorrelationRequest {
|
|
145
|
+
readonly correlationId: string;
|
|
146
|
+
readonly mode: ReplayMode;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* ReplayByTimestampRequest — request body for POST /api/v1/replay/by-timestamp.
|
|
150
|
+
*/
|
|
151
|
+
export interface ReplayByTimestampRequest {
|
|
152
|
+
readonly actorId: string;
|
|
153
|
+
readonly action: string;
|
|
154
|
+
readonly resource: string;
|
|
155
|
+
/** ISO8601 timestamp string. */
|
|
156
|
+
readonly atOrBefore: string;
|
|
157
|
+
readonly mode?: ReplayMode;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* ReplayPolicyVersion — one policy version record in a replay response.
|
|
161
|
+
* hashVerified=true means SHA-256(content) === contentHash was verified.
|
|
162
|
+
*/
|
|
163
|
+
export interface ReplayPolicyVersion {
|
|
164
|
+
readonly policyId: string;
|
|
165
|
+
readonly versionNumber: number;
|
|
166
|
+
readonly policyKey: string;
|
|
167
|
+
readonly contentHash: string;
|
|
168
|
+
readonly hashVerified: boolean;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* ReplayMetadata — execution metadata for a replay operation.
|
|
172
|
+
*/
|
|
173
|
+
export interface ReplayMetadata {
|
|
174
|
+
readonly policiesReconstructed: number;
|
|
175
|
+
readonly integrityViolations: readonly string[];
|
|
176
|
+
readonly delegationSnapshotUsed: boolean;
|
|
177
|
+
readonly auditRecordFound: boolean;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* ReplayResponse — response from all /api/v1/replay/* endpoints.
|
|
181
|
+
*
|
|
182
|
+
* VERIFY mode: result + replayedDecision are populated.
|
|
183
|
+
* RECONSTRUCT mode: reconstructedContext + reconstructedPolicies are populated.
|
|
184
|
+
* EXPLAIN mode: all RECONSTRUCT fields + explanation are populated.
|
|
185
|
+
*/
|
|
186
|
+
export interface ReplayResponse {
|
|
187
|
+
readonly correlationId: string;
|
|
188
|
+
readonly mode: ReplayMode;
|
|
189
|
+
readonly storedDecision: AuthorizationDecision;
|
|
190
|
+
readonly replayedDecision?: AuthorizationDecision;
|
|
191
|
+
readonly result?: ReplayResult;
|
|
192
|
+
readonly originalDecisionAt: string;
|
|
193
|
+
readonly replayedAt: string;
|
|
194
|
+
readonly reconstructedContext?: Readonly<Record<string, unknown>>;
|
|
195
|
+
readonly reconstructedPolicies?: readonly ReplayPolicyVersion[];
|
|
196
|
+
readonly explanation?: string;
|
|
197
|
+
readonly evaluationOntologyVersion: string;
|
|
198
|
+
readonly explainabilitySchemaVersion: string;
|
|
199
|
+
readonly replayMetadata: ReplayMetadata;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* SdkVersionInfo — version contract information.
|
|
203
|
+
* Per GOVERNANCE_COMPATIBILITY_MATRIX.md — consuming systems must pin this version.
|
|
204
|
+
* SDKF-09: Wildcard version constraints are forbidden.
|
|
205
|
+
*/
|
|
206
|
+
export interface SdkVersionInfo {
|
|
207
|
+
readonly version: string;
|
|
208
|
+
readonly semanticFreezeVersion: string;
|
|
209
|
+
readonly apiCompatibilityMinVersion: string;
|
|
210
|
+
readonly status: 'CURRENT' | 'MAINTENANCE' | 'LEGACY' | 'RETIRED' | 'EXPERIMENTAL';
|
|
211
|
+
readonly deprecationNotice?: string;
|
|
212
|
+
readonly retirementDate?: string;
|
|
213
|
+
}
|
|
214
|
+
export declare const SDK_VERSION_INFO: SdkVersionInfo;
|
|
215
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","source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AAE,MAAM,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,cAAc,CAAC;IACnF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,eAAO,MAAM,gBAAgB,EAAE,cAK9B,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* types.ts — SDK Canonical Type Definitions
|
|
4
|
+
*
|
|
5
|
+
* Per SDK_SEMANTIC_CONFORMANCE.md §2: all SDK types are immutable after construction.
|
|
6
|
+
* Per SYSTEM_CONSTITUTION §22: all financial amounts are decimal strings, NEVER numbers.
|
|
7
|
+
*
|
|
8
|
+
* SEMANTIC FREEZE v1.0.0 — these types must not change without a GCRB vote.
|
|
9
|
+
*
|
|
10
|
+
* SDKF-01: No boolean-only authorization helpers (isAllowed(), canApprove(), etc.)
|
|
11
|
+
* SDKF-02: No float or number types for financial amounts
|
|
12
|
+
* SDKF-03: No decision caching at SDK layer
|
|
13
|
+
* SDKF-04: No silent correlation ID generation
|
|
14
|
+
* SDKF-05: No stripping of explainabilityComplete field
|
|
15
|
+
* SDKF-06: No retry masking (retrying a DENY as ALLOW)
|
|
16
|
+
* SDKF-07: No hardcoded role checks
|
|
17
|
+
* SDKF-08: No default actorId values
|
|
18
|
+
* SDKF-09: No wildcard SDK version pinning
|
|
19
|
+
* SDKF-10: No silent compatibility downgrade
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.SDK_VERSION_INFO = void 0;
|
|
23
|
+
exports.SDK_VERSION_INFO = {
|
|
24
|
+
version: '1.0.0',
|
|
25
|
+
semanticFreezeVersion: '1.0.0',
|
|
26
|
+
apiCompatibilityMinVersion: '1.0.0',
|
|
27
|
+
status: 'CURRENT',
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAsPU,QAAA,gBAAgB,GAAmB;IAC9C,OAAO,EAAE,OAAO;IAChB,qBAAqB,EAAE,OAAO;IAC9B,0BAA0B,EAAE,OAAO;IACnC,MAAM,EAAE,SAAS;CAClB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gov-finance-authorization-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript SDK for the Ministry of Finance Jamaica — Government Financial Authorization & Governance Platform. Provides type-safe, immutable DTOs and semantic-conformance helpers for consuming systems.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc --build",
|
|
15
|
+
"typecheck": "tsc --noEmit",
|
|
16
|
+
"clean": "rm -rf dist"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18.0.0"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"authorization",
|
|
23
|
+
"governance",
|
|
24
|
+
"ministry-of-finance",
|
|
25
|
+
"jamaica",
|
|
26
|
+
"fintech"
|
|
27
|
+
],
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^5.9.0"
|
|
30
|
+
},
|
|
31
|
+
"governanceMetadata": {
|
|
32
|
+
"semanticFreezeVersion": "1.0.0",
|
|
33
|
+
"openApiHashFile": "../../docs/snapshots/openapi-snapshot-hash.txt",
|
|
34
|
+
"sdkConformanceSpec": "../../attached_assets/SDK_SEMANTIC_CONFORMANCE.md",
|
|
35
|
+
"forbiddenPatterns": "SDKF-01 through SDKF-10 — see SDK_SEMANTIC_CONFORMANCE.md §5",
|
|
36
|
+
"versionPinningRequired": true,
|
|
37
|
+
"wildcardVersionsForbidden": true
|
|
38
|
+
}
|
|
39
|
+
}
|