bharosa 0.3.0 → 0.3.2
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/CHANGELOG.md +12 -4
- package/README.md +13 -16
- package/dist/client-types.d.cts +2 -1
- package/dist/client-types.d.ts +2 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/transport.cjs +1 -1
- package/docs/getting-started.md +6 -17
- package/docs/portfolios.md +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 0.3.2 — 30 October 2026
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Default omitted or undefined `baseUrl` to `https://app.bharosa.finance` in Bharosa and BharosaMarket. Preserve explicit overrides, origin validation, redirect rejection and credential boundaries. Remove required origin setup from beginner examples. No analytics additions or API changes.
|
|
6
|
+
|
|
7
|
+
## 0.3.1 — 30 October 2026
|
|
8
|
+
|
|
9
|
+
Correct stale publication and activation wording in the README and portfolio guide. Runtime code, API contracts, exports and dependencies are byte-identical to 0.3.0.
|
|
10
|
+
|
|
11
|
+
## 0.3.0 — published 30 October 2026
|
|
12
|
+
|
|
13
|
+
Adds server-side BharosaMarket for four authenticated registered-app monthly market operations without an investor token or account argument. Production market-key support is active at app.bharosa.finance in the production environment. Includes the portfolio lifecycle changes below; no analytics additions or general OAuth provisioning.
|
|
6
14
|
|
|
7
|
-
## 0.2.0
|
|
15
|
+
## Lifecycle changes — included in 0.3.0 (0.2.0 was not published)
|
|
8
16
|
|
|
9
17
|
- Add `portfolios.update(id, { name, expected_name }, { idempotencyKey })` for account-scoped, name-only updates, with optimistic name comparison and validated response identity. Holdings and snapshots remain unchanged.
|
|
10
18
|
- Accept `positions: []` when creating a saved portfolio. Empty portfolio analysis remains unavailable until holdings exist.
|
package/README.md
CHANGED
|
@@ -2,25 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
A TypeScript client for Bharosa accounts, investors, portfolios, and mutual funds. Use one resource interface from TypeScript, ESM, or CommonJS, with no runtime dependencies.
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**SDK version:** `bharosa@0.3.2`. Both clients use the production API at `https://app.bharosa.finance` by default. Account access and credentials are still required; installing the SDK does not grant access.
|
|
6
6
|
|
|
7
7
|
## Start here
|
|
8
8
|
|
|
9
|
-
Use Node.js 22.12+ in a supported LTS release.
|
|
9
|
+
Use Node.js 22.12+ in a supported LTS release. Install the published SDK in your backend application:
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm
|
|
13
|
-
npm run build
|
|
14
|
-
npm pack --pack-destination /absolute/path/to/artifacts
|
|
12
|
+
npm install bharosa@0.3.2 --ignore-scripts
|
|
15
13
|
```
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
Source contributors can build and pack a local archive using the commands in CONTRIBUTING.md.
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
npm install /absolute/path/to/artifacts/bharosa-0.1.0.tgz
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Configure your application's API origin, account ID, and account key through its secret manager. Then:
|
|
17
|
+
Configure your application's account ID and account key through its secret manager. Then:
|
|
24
18
|
|
|
25
19
|
```ts
|
|
26
20
|
import { Bharosa } from "bharosa";
|
|
@@ -31,7 +25,6 @@ function required(name: string): string {
|
|
|
31
25
|
return value;
|
|
32
26
|
}
|
|
33
27
|
const bharosa = new Bharosa({
|
|
34
|
-
baseUrl: required("BHAROSA_API_BASE_URL"),
|
|
35
28
|
account: required("BHAROSA_ACCOUNT_ID"),
|
|
36
29
|
auth: { type: "account_key", apiKey: required("BHAROSA_SECRET_KEY") },
|
|
37
30
|
});
|
|
@@ -116,14 +109,18 @@ The license covers this SDK. The Bharosa API service, analytics implementation,
|
|
|
116
109
|
|
|
117
110
|
### Monthly market history and synthetic samples
|
|
118
111
|
|
|
119
|
-
`client.marketSnapshots` exposes month-start historical market observations and latest NAV valuation without a separate market-data approval step, using authenticated credentials with the required account-read scope. All external credentials, including direct account keys, use monthly historical market dates; investor transaction and position history retains its full dates. See [monthly snapshots](docs/monthly-market-data.md) for actual observation dates, missing data and availability.
|
|
112
|
+
`client.marketSnapshots` exposes month-start historical market observations and latest NAV valuation without a separate market-data approval step, using authenticated credentials with the required account-read scope. All external credentials, including direct account keys, use monthly historical market dates; investor transaction and position history retains its full dates. See [monthly snapshots](docs/monthly-market-data.md) for actual observation dates, missing data and availability. Installing the SDK does not grant account access.
|
|
120
113
|
|
|
121
114
|
The optional `bharosa/testing` entrypoint supplies fresh, deterministic synthetic portfolios and fictional fund compositions without credentials or network requests. Its seed helper writes only when explicitly called with an authenticated client, confirmed test account, stable run ID and resolved instrument mapping. See [testing samples](docs/testing.md).
|
|
122
115
|
|
|
123
|
-
Unit precision
|
|
116
|
+
Unit precision: supplied units accept at most four fractional digits; additional digits are rejected, never truncated. Dated amount conversion rounds once to four places using decimal half-even arithmetic; a positive amount rounding to zero returns `units_below_precision`. Currency and NAV precision are unchanged. Exact historical quantities and provenance remain in stored evidence and read responses; the web marks rounded displays with ≈, shows tiny positive values as <0.0001, and makes a rounded edit draft an explicit correction. Existing zero-unit closure remains supported; initial quantities must be positive. No portfolio reset or data rewrite is required.
|
|
124
117
|
|
|
125
118
|
After installing the archive, run `node node_modules/bharosa/examples/offline-smoke.mjs` for a credential-free synthetic read. This checks installed imports and the transport path without contacting Bharosa or creating data. It does not prove live access. Source-checkout verification commands require contributor files that are intentionally excluded from the runtime archive.
|
|
126
119
|
|
|
127
|
-
###
|
|
120
|
+
### Registered-app monthly data
|
|
121
|
+
|
|
122
|
+
Available in SDK 0.3.0 and activated at `https://app.bharosa.finance`. Server applications can use `new BharosaMarket({apiKey})` with an owner-issued `market_key` scoped only to `market:read`. `client.schemes.nav(id,{asOf:'2026-08-01'})`, `schemes.expenseRatio`, `funds.portfolio` and `funds.holdings` use account-independent monthly snapshot routes. These keys cannot read private accounts or portfolios and require no investor OAuth token. Keep secrets server-side; never bundle them into browser code. Existing account-key and delegated-user clients remain unchanged. The production control-plane environment is `production`. General third-party OAuth provisioning is separate and is not enabled by this feature.
|
|
123
|
+
|
|
124
|
+
### Optional API origin override
|
|
128
125
|
|
|
129
|
-
|
|
126
|
+
Set `baseUrl` only for another deployment or tests. Omitted or `undefined` uses `https://app.bharosa.finance`; invalid explicit values fail validation and never fall back. Overrides must be HTTPS origins without credentials, paths, queries or fragments. Local HTTP also requires `allowLocalhostHttp: true`. The SDK does not read `BHAROSA_API_BASE_URL` automatically.
|
package/dist/client-types.d.cts
CHANGED
|
@@ -17,7 +17,8 @@ export interface BharosaTransport {
|
|
|
17
17
|
send(url: string, request: RequestInit): Promise<Response>;
|
|
18
18
|
}
|
|
19
19
|
interface BharosaBaseConfig {
|
|
20
|
-
|
|
20
|
+
/** Defaults to https://app.bharosa.finance. Explicit overrides must be valid origins. */
|
|
21
|
+
readonly baseUrl?: string;
|
|
21
22
|
readonly account: string;
|
|
22
23
|
readonly allowLocalhostHttp?: boolean;
|
|
23
24
|
readonly maxResponseBytes?: number;
|
package/dist/client-types.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export interface BharosaTransport {
|
|
|
17
17
|
send(url: string, request: RequestInit): Promise<Response>;
|
|
18
18
|
}
|
|
19
19
|
interface BharosaBaseConfig {
|
|
20
|
-
|
|
20
|
+
/** Defaults to https://app.bharosa.finance. Explicit overrides must be valid origins. */
|
|
21
|
+
readonly baseUrl?: string;
|
|
21
22
|
readonly account: string;
|
|
22
23
|
readonly allowLocalhostHttp?: boolean;
|
|
23
24
|
readonly maxResponseBytes?: number;
|
package/dist/index.d.cts
CHANGED
|
@@ -16,7 +16,8 @@ export declare class Bharosa implements T.ClientSurface {
|
|
|
16
16
|
constructor(config: T.BharosaConfig);
|
|
17
17
|
}
|
|
18
18
|
export interface BharosaMarketConfig {
|
|
19
|
-
|
|
19
|
+
/** Defaults to https://app.bharosa.finance. */
|
|
20
|
+
baseUrl?: string;
|
|
20
21
|
apiKey: string;
|
|
21
22
|
allowLocalhostHttp?: boolean;
|
|
22
23
|
maxResponseBytes?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export declare class Bharosa implements T.ClientSurface {
|
|
|
16
16
|
constructor(config: T.BharosaConfig);
|
|
17
17
|
}
|
|
18
18
|
export interface BharosaMarketConfig {
|
|
19
|
-
|
|
19
|
+
/** Defaults to https://app.bharosa.finance. */
|
|
20
|
+
baseUrl?: string;
|
|
20
21
|
apiKey: string;
|
|
21
22
|
allowLocalhostHttp?: boolean;
|
|
22
23
|
maxResponseBytes?: number;
|
package/dist/transport.cjs
CHANGED
|
@@ -156,7 +156,7 @@ function createTransport(config, marketOnly = false) {
|
|
|
156
156
|
]);
|
|
157
157
|
check(config.allowLocalhostHttp === undefined ||
|
|
158
158
|
typeof config.allowLocalhostHttp === "boolean");
|
|
159
|
-
const base = origin(config.baseUrl, config.allowLocalhostHttp);
|
|
159
|
+
const base = origin(config.baseUrl === undefined ? "https://app.bharosa.finance" : config.baseUrl, config.allowLocalhostHttp);
|
|
160
160
|
check((0, validate_cjs_1.valid)(operations.retrieve_account.parameters[0].schema, config.account));
|
|
161
161
|
const account = config.account;
|
|
162
162
|
let headers, secrets;
|
package/docs/getting-started.md
CHANGED
|
@@ -4,25 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
Use Node.js 22.12 or later in a supported LTS release. The SDK supports ESM and CommonJS. Key-based authentication is server-only; keep credentials in your backend or server that handles browser sessions. Browser applications can supply a generic transport whose private host implementation manages sessions, origin restrictions and CSRF. Bun and Deno are unsupported.
|
|
6
6
|
|
|
7
|
-
Obtain
|
|
7
|
+
Obtain your authorized account ID and account key. Bharosa and BharosaMarket default to the production origin `https://app.bharosa.finance`; no API URL environment variable is required. The SDK neither provisions accounts nor runs an OAuth consent flow.
|
|
8
8
|
|
|
9
|
-
## Install
|
|
10
|
-
|
|
11
|
-
From the SDK directory:
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
npm --prefix tooling ci --ignore-scripts
|
|
15
|
-
npm run build
|
|
16
|
-
npm pack --pack-destination /absolute/path/to/artifacts
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Then, from your application directory:
|
|
9
|
+
## Install
|
|
20
10
|
|
|
21
11
|
```sh
|
|
22
|
-
npm install
|
|
12
|
+
npm install bharosa@0.3.2 --ignore-scripts
|
|
23
13
|
```
|
|
24
14
|
|
|
25
|
-
|
|
15
|
+
Source contributors can build and pack a local archive as described in CONTRIBUTING.md.
|
|
26
16
|
|
|
27
17
|
## Read your account
|
|
28
18
|
|
|
@@ -38,7 +28,6 @@ function required(name) {
|
|
|
38
28
|
}
|
|
39
29
|
|
|
40
30
|
const bharosa = new Bharosa({
|
|
41
|
-
baseUrl: required("BHAROSA_API_BASE_URL"),
|
|
42
31
|
account: required("BHAROSA_ACCOUNT_ID"),
|
|
43
32
|
auth: { type: "account_key", apiKey: required("BHAROSA_SECRET_KEY") },
|
|
44
33
|
});
|
|
@@ -46,7 +35,7 @@ const account = await bharosa.accounts.retrieve();
|
|
|
46
35
|
console.log(account.id);
|
|
47
36
|
```
|
|
48
37
|
|
|
49
|
-
Supply those variables through your application's secret management, then run `node account.mjs`. Do not commit their values.
|
|
38
|
+
Supply those variables through your application's secret management, then run `node account.mjs`. Do not commit their values. For another deployment or tests, explicitly supply `baseUrl`. It must use HTTPS and contain no path, query, user information, or fragment; local HTTP additionally requires `allowLocalhostHttp: true`. Invalid explicit origins fail before sending a request.
|
|
50
39
|
|
|
51
40
|
CommonJS applications use `const { Bharosa } = require("bharosa")` inside an async function. TypeScript applications import types from the same root package; do not import files from `dist/`.
|
|
52
41
|
|
|
@@ -65,7 +54,7 @@ To try the interface without an API or credentials, use the [synthetic examples]
|
|
|
65
54
|
## Caller-owned transport and first-party market data
|
|
66
55
|
|
|
67
56
|
`BharosaTransport.send(url: string, request: RequestInit): Promise<Response>`
|
|
68
|
-
can replace credential configuration. Construct with `
|
|
57
|
+
can replace credential configuration. Construct with `account`, an optional `baseUrl`, and
|
|
69
58
|
`transport`; do not also pass `auth` or `fetch`. The host application owns its
|
|
70
59
|
private session adapter, URL/origin restrictions, per-write CSRF, cookie policy
|
|
71
60
|
and cancellation on account changes. SDK requests default to omitted credentials,
|
package/docs/portfolios.md
CHANGED
|
@@ -87,9 +87,9 @@ The earlier singular `client` option remains supported, but cannot be combined w
|
|
|
87
87
|
|
|
88
88
|
`await client.accounts.retrieve()` uses the account configured on the SDK; no repeated account ID is needed. Its nullable `personal_client_id` identifies the authenticated human's linked household, not a new family resource or an access grant. Machine account keys receive null because they do not identify a signed-in person. A null link must not be replaced by guessing from a client name or account owner. The prelaunch public account response no longer exposes the internal `owner` user ID; ownership remains enforced on the server.
|
|
89
89
|
|
|
90
|
-
Units-first portfolio creation
|
|
90
|
+
Units-first portfolio creation: `portfolios.create` accepts an initial position with either `current_value` or positive `quantity`, never both, using the supplied `as_of` date. Existing amount requests and amount-only responses remain unchanged. Supplied units are stored atomically without requiring a NAV. Snapshot `quantity` can now be a decimal string and `valuation` can be null; `total_current_value` is null when any snapshot position lacks a reported amount, and `valuation_basis` is `supplied_quantity`. Consumers of general snapshot reads must handle these new nullable values; this is an intentional prelaunch type widening. Older SDKs cannot read units-only snapshots. Snapshot replacement and in-memory analytics remain amount-only. These shapes are included in the published SDK.
|
|
91
91
|
|
|
92
|
-
## Empty creation and name updates (SDK 0.
|
|
92
|
+
## Empty creation and name updates (SDK 0.3.0)
|
|
93
93
|
|
|
94
94
|
The companion API accepts `positions: []` in `portfolios.create`. It persists a portfolio, investment account and zero-position snapshot immediately. Add the first holding afterward through the returned portfolio's `holdings.setCurrent` method. Cancellation before creation sends no request.
|
|
95
95
|
|