cas-parser-node 1.8.0 → 1.10.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/CHANGELOG.md +34 -0
- package/README.md +1 -3
- package/client.d.mts +83 -18
- package/client.d.mts.map +1 -1
- package/client.d.ts +83 -18
- package/client.d.ts.map +1 -1
- package/client.js +88 -28
- package/client.js.map +1 -1
- package/client.mjs +88 -28
- package/client.mjs.map +1 -1
- package/internal/utils/query.d.mts +5 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +5 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +23 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +20 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils.d.mts +1 -0
- package/internal/utils.d.ts +1 -0
- package/internal/utils.js +1 -0
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +1 -0
- package/package.json +1 -1
- package/resources/access-token.d.mts +5 -0
- package/resources/access-token.d.mts.map +1 -1
- package/resources/access-token.d.ts +5 -0
- package/resources/access-token.d.ts.map +1 -1
- package/resources/access-token.js +5 -0
- package/resources/access-token.js.map +1 -1
- package/resources/access-token.mjs +5 -0
- package/resources/access-token.mjs.map +1 -1
- package/resources/cams-kfintech.d.mts +3 -0
- package/resources/cams-kfintech.d.mts.map +1 -1
- package/resources/cams-kfintech.d.ts +3 -0
- package/resources/cams-kfintech.d.ts.map +1 -1
- package/resources/cams-kfintech.js +3 -0
- package/resources/cams-kfintech.js.map +1 -1
- package/resources/cams-kfintech.mjs +3 -0
- package/resources/cams-kfintech.mjs.map +1 -1
- package/resources/cdsl/cdsl.d.mts +3 -0
- package/resources/cdsl/cdsl.d.mts.map +1 -1
- package/resources/cdsl/cdsl.d.ts +3 -0
- package/resources/cdsl/cdsl.d.ts.map +1 -1
- package/resources/cdsl/cdsl.js +3 -0
- package/resources/cdsl/cdsl.js.map +1 -1
- package/resources/cdsl/cdsl.mjs +3 -0
- package/resources/cdsl/cdsl.mjs.map +1 -1
- package/resources/cdsl/fetch.d.mts +4 -0
- package/resources/cdsl/fetch.d.mts.map +1 -1
- package/resources/cdsl/fetch.d.ts +4 -0
- package/resources/cdsl/fetch.d.ts.map +1 -1
- package/resources/cdsl/fetch.js +4 -0
- package/resources/cdsl/fetch.js.map +1 -1
- package/resources/cdsl/fetch.mjs +4 -0
- package/resources/cdsl/fetch.mjs.map +1 -1
- package/resources/contract-note.d.mts +3 -0
- package/resources/contract-note.d.mts.map +1 -1
- package/resources/contract-note.d.ts +3 -0
- package/resources/contract-note.d.ts.map +1 -1
- package/resources/contract-note.js +3 -0
- package/resources/contract-note.js.map +1 -1
- package/resources/contract-note.mjs +3 -0
- package/resources/contract-note.mjs.map +1 -1
- package/resources/credits.d.mts +4 -0
- package/resources/credits.d.mts.map +1 -1
- package/resources/credits.d.ts +4 -0
- package/resources/credits.d.ts.map +1 -1
- package/resources/credits.js +4 -0
- package/resources/credits.js.map +1 -1
- package/resources/credits.mjs +4 -0
- package/resources/credits.mjs.map +1 -1
- package/resources/inbound-email.d.mts +22 -0
- package/resources/inbound-email.d.mts.map +1 -1
- package/resources/inbound-email.d.ts +22 -0
- package/resources/inbound-email.d.ts.map +1 -1
- package/resources/inbound-email.js +22 -0
- package/resources/inbound-email.js.map +1 -1
- package/resources/inbound-email.mjs +22 -0
- package/resources/inbound-email.mjs.map +1 -1
- package/resources/inbox.d.mts +17 -0
- package/resources/inbox.d.mts.map +1 -1
- package/resources/inbox.d.ts +17 -0
- package/resources/inbox.d.ts.map +1 -1
- package/resources/inbox.js +17 -0
- package/resources/inbox.js.map +1 -1
- package/resources/inbox.mjs +17 -0
- package/resources/inbox.mjs.map +1 -1
- package/resources/kfintech.d.mts +3 -0
- package/resources/kfintech.d.mts.map +1 -1
- package/resources/kfintech.d.ts +3 -0
- package/resources/kfintech.d.ts.map +1 -1
- package/resources/kfintech.js +3 -0
- package/resources/kfintech.js.map +1 -1
- package/resources/kfintech.mjs +3 -0
- package/resources/kfintech.mjs.map +1 -1
- package/resources/logs.d.mts +4 -0
- package/resources/logs.d.mts.map +1 -1
- package/resources/logs.d.ts +4 -0
- package/resources/logs.d.ts.map +1 -1
- package/resources/logs.js +4 -0
- package/resources/logs.js.map +1 -1
- package/resources/logs.mjs +4 -0
- package/resources/logs.mjs.map +1 -1
- package/resources/nsdl.d.mts +3 -0
- package/resources/nsdl.d.mts.map +1 -1
- package/resources/nsdl.d.ts +3 -0
- package/resources/nsdl.d.ts.map +1 -1
- package/resources/nsdl.js +3 -0
- package/resources/nsdl.js.map +1 -1
- package/resources/nsdl.mjs +3 -0
- package/resources/nsdl.mjs.map +1 -1
- package/resources/smart.d.mts +3 -0
- package/resources/smart.d.mts.map +1 -1
- package/resources/smart.d.ts +3 -0
- package/resources/smart.d.ts.map +1 -1
- package/resources/smart.js +3 -0
- package/resources/smart.js.map +1 -1
- package/resources/smart.mjs +3 -0
- package/resources/smart.mjs.map +1 -1
- package/resources/verify-token.d.mts +5 -0
- package/resources/verify-token.d.mts.map +1 -1
- package/resources/verify-token.d.ts +5 -0
- package/resources/verify-token.d.ts.map +1 -1
- package/resources/verify-token.js +5 -0
- package/resources/verify-token.js.map +1 -1
- package/resources/verify-token.mjs +5 -0
- package/resources/verify-token.mjs.map +1 -1
- package/src/client.ts +91 -48
- package/src/internal/utils/query.ts +23 -0
- package/src/internal/utils.ts +1 -0
- package/src/resources/access-token.ts +5 -0
- package/src/resources/cams-kfintech.ts +3 -0
- package/src/resources/cdsl/cdsl.ts +3 -0
- package/src/resources/cdsl/fetch.ts +4 -0
- package/src/resources/contract-note.ts +3 -0
- package/src/resources/credits.ts +4 -0
- package/src/resources/inbound-email.ts +22 -0
- package/src/resources/inbox.ts +17 -0
- package/src/resources/kfintech.ts +3 -0
- package/src/resources/logs.ts +4 -0
- package/src/resources/nsdl.ts +3 -0
- package/src/resources/smart.ts +3 -0
- package/src/resources/verify-token.ts +5 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.10.0 (2026-03-03)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.9.0...v1.10.0](https://github.com/CASParser/cas-parser-node/compare/v1.9.0...v1.10.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **mcp:** add an option to disable code tool ([1165824](https://github.com/CASParser/cas-parser-node/commit/11658245be3d4578a6d22fc5c9a88cb466f92818))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **docs/contributing:** correct pnpm link command ([bebfdc3](https://github.com/CASParser/cas-parser-node/commit/bebfdc36309d111760b974d2edbc1a4119cdf98d))
|
|
15
|
+
* **mcp:** update prompt ([5edb3a0](https://github.com/CASParser/cas-parser-node/commit/5edb3a0114fc591318fdbe56f91ba030d330fdaf))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Chores
|
|
19
|
+
|
|
20
|
+
* **internal:** codegen related update ([75fc710](https://github.com/CASParser/cas-parser-node/commit/75fc710f26be8f812d0eac1d5135dc55f0dce865))
|
|
21
|
+
* **internal:** codegen related update ([f58a313](https://github.com/CASParser/cas-parser-node/commit/f58a3133b6db1eb3646979d451dc8c1effb4a0db))
|
|
22
|
+
* **internal:** fix MCP Dockerfiles so they can be built without buildkit ([257f07b](https://github.com/CASParser/cas-parser-node/commit/257f07b1064815e62c07a1208646bc14b4c43319))
|
|
23
|
+
* **internal:** fix MCP Dockerfiles so they can be built without buildkit ([a6fd091](https://github.com/CASParser/cas-parser-node/commit/a6fd0912c1dbeb077f4c232d3a382d19ad6f3164))
|
|
24
|
+
* **internal:** make MCP code execution location configurable via a flag ([231dc58](https://github.com/CASParser/cas-parser-node/commit/231dc58a7c5593b87d91f8e9d2ba6012aabf55a5))
|
|
25
|
+
* **internal:** move stringifyQuery implementation to internal function ([7048aa6](https://github.com/CASParser/cas-parser-node/commit/7048aa6345edf172e3e162f9492175dd3bbe75cb))
|
|
26
|
+
* **internal:** upgrade @modelcontextprotocol/sdk and hono ([a2d2c9b](https://github.com/CASParser/cas-parser-node/commit/a2d2c9b82e991f3f5df7df42379f2a49aec798ad))
|
|
27
|
+
* **internal:** upgrade pnpm version ([57c291d](https://github.com/CASParser/cas-parser-node/commit/57c291d980615daf189e09e2e4949b1e9ac2c0c8))
|
|
28
|
+
|
|
29
|
+
## 1.9.0 (2026-02-23)
|
|
30
|
+
|
|
31
|
+
Full Changelog: [v1.8.0...v1.9.0](https://github.com/CASParser/cas-parser-node/compare/v1.8.0...v1.9.0)
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **api:** manual updates ([75ec0c8](https://github.com/CASParser/cas-parser-node/commit/75ec0c8875f5ac06ef72fff853114efd020e20e0))
|
|
36
|
+
|
|
3
37
|
## 1.8.0 (2026-02-23)
|
|
4
38
|
|
|
5
39
|
Full Changelog: [v1.7.2...v1.8.0](https://github.com/CASParser/cas-parser-node/compare/v1.7.2...v1.8.0)
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
This library provides convenient access to the Cas Parser REST API from server-side TypeScript or JavaScript.
|
|
6
6
|
|
|
7
|
-
The REST API documentation can be found on [
|
|
7
|
+
The REST API documentation can be found on [casparser.in](https://casparser.in/docs). The full API of this library can be found in [api.md](api.md).
|
|
8
8
|
|
|
9
9
|
It is generated with [Stainless](https://www.stainless.com/).
|
|
10
10
|
|
|
@@ -33,7 +33,6 @@ import CasParser from 'cas-parser-node';
|
|
|
33
33
|
|
|
34
34
|
const client = new CasParser({
|
|
35
35
|
apiKey: process.env['CAS_PARSER_API_KEY'], // This is the default and can be omitted
|
|
36
|
-
environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production'
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
const response = await client.credits.check();
|
|
@@ -51,7 +50,6 @@ import CasParser from 'cas-parser-node';
|
|
|
51
50
|
|
|
52
51
|
const client = new CasParser({
|
|
53
52
|
apiKey: process.env['CAS_PARSER_API_KEY'], // This is the default and can be omitted
|
|
54
|
-
environment: 'environment_1', // or 'production' | 'environment_2'; defaults to 'production'
|
|
55
53
|
});
|
|
56
54
|
|
|
57
55
|
const response: CasParser.CreditCheckResponse = await client.credits.check();
|
package/client.d.mts
CHANGED
|
@@ -22,12 +22,6 @@ import { type Fetch } from "./internal/builtin-types.mjs";
|
|
|
22
22
|
import { HeadersLike, NullableHeaders } from "./internal/headers.mjs";
|
|
23
23
|
import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs";
|
|
24
24
|
import { type LogLevel, type Logger } from "./internal/utils/log.mjs";
|
|
25
|
-
declare const environments: {
|
|
26
|
-
production: string;
|
|
27
|
-
environment_1: string;
|
|
28
|
-
environment_2: string;
|
|
29
|
-
};
|
|
30
|
-
type Environment = keyof typeof environments;
|
|
31
25
|
export interface ClientOptions {
|
|
32
26
|
/**
|
|
33
27
|
* Your API key for authentication.
|
|
@@ -35,15 +29,6 @@ export interface ClientOptions {
|
|
|
35
29
|
*
|
|
36
30
|
*/
|
|
37
31
|
apiKey?: string | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Specifies the environment to use for the API.
|
|
40
|
-
*
|
|
41
|
-
* Each environment maps to a different base URL:
|
|
42
|
-
* - `production` corresponds to `https://portfolio-parser.api.casparser.in`
|
|
43
|
-
* - `environment_1` corresponds to `https://client-apis.casparser.in`
|
|
44
|
-
* - `environment_2` corresponds to `http://localhost:5000`
|
|
45
|
-
*/
|
|
46
|
-
environment?: Environment | undefined;
|
|
47
32
|
/**
|
|
48
33
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
49
34
|
*
|
|
@@ -124,8 +109,7 @@ export declare class CasParser {
|
|
|
124
109
|
* API Client for interfacing with the Cas Parser API.
|
|
125
110
|
*
|
|
126
111
|
* @param {string | undefined} [opts.apiKey=process.env['CAS_PARSER_API_KEY'] ?? undefined]
|
|
127
|
-
* @param {
|
|
128
|
-
* @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://portfolio-parser.api.casparser.in] - Override the default base URL for the API.
|
|
112
|
+
* @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://api.casparser.in] - Override the default base URL for the API.
|
|
129
113
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
130
114
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
131
115
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -144,7 +128,7 @@ export declare class CasParser {
|
|
|
144
128
|
/**
|
|
145
129
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
146
130
|
*/
|
|
147
|
-
protected stringifyQuery(query: Record<string, unknown>): string;
|
|
131
|
+
protected stringifyQuery(query: object | Record<string, unknown>): string;
|
|
148
132
|
private getUserAgent;
|
|
149
133
|
protected defaultIdempotencyKey(): string;
|
|
150
134
|
protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
|
|
@@ -201,17 +185,98 @@ export declare class CasParser {
|
|
|
201
185
|
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
202
186
|
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
203
187
|
static toFile: typeof Uploads.toFile;
|
|
188
|
+
/**
|
|
189
|
+
* Endpoints for checking API quota and credits usage.
|
|
190
|
+
* These endpoints help you monitor your API usage and remaining quota.
|
|
191
|
+
*
|
|
192
|
+
*/
|
|
204
193
|
credits: API.Credits;
|
|
194
|
+
/**
|
|
195
|
+
* Endpoints for checking API quota and credits usage.
|
|
196
|
+
* These endpoints help you monitor your API usage and remaining quota.
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
205
199
|
logs: API.Logs;
|
|
200
|
+
/**
|
|
201
|
+
* Endpoints for managing access tokens for the Portfolio Connect SDK.
|
|
202
|
+
* Use these to generate short-lived `at_` prefixed tokens that can be safely passed to frontend applications.
|
|
203
|
+
* Access tokens can be used in place of API keys on all v4 endpoints.
|
|
204
|
+
*
|
|
205
|
+
*/
|
|
206
206
|
accessToken: API.AccessToken;
|
|
207
|
+
/**
|
|
208
|
+
* Endpoints for managing access tokens for the Portfolio Connect SDK.
|
|
209
|
+
* Use these to generate short-lived `at_` prefixed tokens that can be safely passed to frontend applications.
|
|
210
|
+
* Access tokens can be used in place of API keys on all v4 endpoints.
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
207
213
|
verifyToken: API.VerifyToken;
|
|
214
|
+
/**
|
|
215
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
216
|
+
*/
|
|
208
217
|
camsKfintech: API.CamsKfintech;
|
|
218
|
+
/**
|
|
219
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
220
|
+
*/
|
|
209
221
|
cdsl: API.Cdsl;
|
|
222
|
+
/**
|
|
223
|
+
* Endpoints for parsing Contract Note PDF files from various SEBI brokers like Zerodha, Groww, Upstox, ICICI etc.
|
|
224
|
+
*/
|
|
210
225
|
contractNote: API.ContractNote;
|
|
226
|
+
/**
|
|
227
|
+
* Endpoints for importing CAS files directly from user email inboxes.
|
|
228
|
+
*
|
|
229
|
+
* **Supported Providers:** Gmail (more coming soon)
|
|
230
|
+
*
|
|
231
|
+
* **How it works:**
|
|
232
|
+
* 1. Call `POST /v4/inbox/connect` to get an OAuth URL
|
|
233
|
+
* 2. Redirect user to the OAuth URL for consent
|
|
234
|
+
* 3. User is redirected back to your `redirect_uri` with an encrypted `inbox_token`
|
|
235
|
+
* 4. Use the token to list/fetch CAS files from their inbox (`/v4/inbox/cas`)
|
|
236
|
+
* 5. Files are uploaded to temporary cloud storage (URLs expire in 24 hours)
|
|
237
|
+
*
|
|
238
|
+
* **Security:**
|
|
239
|
+
* - Read-only access (we cannot send emails)
|
|
240
|
+
* - Tokens are encrypted with server-side secret
|
|
241
|
+
* - User can revoke access anytime via `/v4/inbox/disconnect`
|
|
242
|
+
*
|
|
243
|
+
*/
|
|
211
244
|
inbox: API.Inbox;
|
|
245
|
+
/**
|
|
246
|
+
* Endpoints for generating new CAS documents via email mailback (KFintech).
|
|
247
|
+
*/
|
|
212
248
|
kfintech: API.Kfintech;
|
|
249
|
+
/**
|
|
250
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
251
|
+
*/
|
|
213
252
|
nsdl: API.Nsdl;
|
|
253
|
+
/**
|
|
254
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
255
|
+
*/
|
|
214
256
|
smart: API.Smart;
|
|
257
|
+
/**
|
|
258
|
+
* Create dedicated inbound email addresses for investors to forward their CAS statements.
|
|
259
|
+
*
|
|
260
|
+
* **Use Case:** Your app wants to collect CAS statements from users without requiring OAuth or file upload.
|
|
261
|
+
*
|
|
262
|
+
* **How it works:**
|
|
263
|
+
* 1. Call `POST /v4/inbound-email` to create a unique inbound email address
|
|
264
|
+
* 2. Display this email to your user: "Forward your CAS statement to ie_xxx@import.casparser.in"
|
|
265
|
+
* 3. When user forwards a CAS email, we verify sender authenticity (SPF/DKIM) and call your webhook
|
|
266
|
+
* 4. Your webhook receives email metadata + attachment download URLs
|
|
267
|
+
*
|
|
268
|
+
* **Sender Validation:**
|
|
269
|
+
* - Only emails from verified CAS authorities are processed:
|
|
270
|
+
* - CDSL: `eCAS@cdslstatement.com`
|
|
271
|
+
* - NSDL: `NSDL-CAS@nsdl.co.in`
|
|
272
|
+
* - CAMS: `donotreply@camsonline.com`
|
|
273
|
+
* - KFintech: `samfS@kfintech.com`
|
|
274
|
+
* - Emails failing SPF/DKIM/DMARC are rejected
|
|
275
|
+
* - Forwarded emails must contain the original sender in headers
|
|
276
|
+
*
|
|
277
|
+
* **Billing:** 0.2 credits per successfully processed valid email
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
215
280
|
inboundEmail: API.InboundEmail;
|
|
216
281
|
}
|
|
217
282
|
export declare namespace CasParser {
|
package/client.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;YAIvE,EAAE,MAAM,EAAE,QAAQ,EAAE;OAKzB,KAAK,IAAI;
|
|
1
|
+
{"version":3,"file":"client.d.mts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;YAIvE,EAAE,MAAM,EAAE,QAAQ,EAAE;OAKzB,KAAK,IAAI;OAGT,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,KAAK,GAAG;OACR,EAAE,UAAU,EAAE;OACd,EAAE,WAAW,EAAE,uBAAuB,EAAE,yBAAyB,EAAE;OACnE,EACL,YAAY,EACZ,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,eAAe,EAChB;OACM,EAAE,YAAY,EAAE,uBAAuB,EAAE,yBAAyB,EAAE;OACpE,EAAE,mBAAmB,EAAE,OAAO,EAAE;OAChC,EACL,YAAY,EACZ,wBAAwB,EACxB,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC7B;OACM,EACL,KAAK,EACL,gCAAgC,EAChC,kCAAkC,EAClC,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,uBAAuB,E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AAI,IAAI,EAAE,KAAK,kBAAkB,IAAI,kBAAkB,EAAE,CAAC;IAEvE,OAAO,EACL,YAAY,IAAI,YAAY,EAC5B,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,uBAAuB,IAAI,uBAAuB,GACxD,CAAC;IAEF,OAAO,EACL,KAAK,IAAI,KAAK,EACd,KAAK,kCAAkC,IAAI,kCAAkC,EAC7E,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,gCAAgC,IAAI,gCAAgC,EACzE,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,uBAAuB,IAAI,uBAAuB,GACxD,CAAC;IAEF,OAAO,EACL,QAAQ,IAAI,QAAQ,EACpB,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,yBAAyB,IAAI,yBAAyB,GAC5D,CAAC;IAEF,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,KAAK,eAAe,IAAI,eAAe,EAAE,CAAC;IAEjE,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,KAAK,sBAAsB,IAAI,sBAAsB,EAAE,CAAC;IAEjF,OAAO,EACL,YAAY,IAAI,YAAY,EAC5B,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;CACH"}
|
package/client.d.ts
CHANGED
|
@@ -22,12 +22,6 @@ import { type Fetch } from "./internal/builtin-types.js";
|
|
|
22
22
|
import { HeadersLike, NullableHeaders } from "./internal/headers.js";
|
|
23
23
|
import { FinalRequestOptions, RequestOptions } from "./internal/request-options.js";
|
|
24
24
|
import { type LogLevel, type Logger } from "./internal/utils/log.js";
|
|
25
|
-
declare const environments: {
|
|
26
|
-
production: string;
|
|
27
|
-
environment_1: string;
|
|
28
|
-
environment_2: string;
|
|
29
|
-
};
|
|
30
|
-
type Environment = keyof typeof environments;
|
|
31
25
|
export interface ClientOptions {
|
|
32
26
|
/**
|
|
33
27
|
* Your API key for authentication.
|
|
@@ -35,15 +29,6 @@ export interface ClientOptions {
|
|
|
35
29
|
*
|
|
36
30
|
*/
|
|
37
31
|
apiKey?: string | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Specifies the environment to use for the API.
|
|
40
|
-
*
|
|
41
|
-
* Each environment maps to a different base URL:
|
|
42
|
-
* - `production` corresponds to `https://portfolio-parser.api.casparser.in`
|
|
43
|
-
* - `environment_1` corresponds to `https://client-apis.casparser.in`
|
|
44
|
-
* - `environment_2` corresponds to `http://localhost:5000`
|
|
45
|
-
*/
|
|
46
|
-
environment?: Environment | undefined;
|
|
47
32
|
/**
|
|
48
33
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
49
34
|
*
|
|
@@ -124,8 +109,7 @@ export declare class CasParser {
|
|
|
124
109
|
* API Client for interfacing with the Cas Parser API.
|
|
125
110
|
*
|
|
126
111
|
* @param {string | undefined} [opts.apiKey=process.env['CAS_PARSER_API_KEY'] ?? undefined]
|
|
127
|
-
* @param {
|
|
128
|
-
* @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://portfolio-parser.api.casparser.in] - Override the default base URL for the API.
|
|
112
|
+
* @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://api.casparser.in] - Override the default base URL for the API.
|
|
129
113
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
130
114
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
131
115
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -144,7 +128,7 @@ export declare class CasParser {
|
|
|
144
128
|
/**
|
|
145
129
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
146
130
|
*/
|
|
147
|
-
protected stringifyQuery(query: Record<string, unknown>): string;
|
|
131
|
+
protected stringifyQuery(query: object | Record<string, unknown>): string;
|
|
148
132
|
private getUserAgent;
|
|
149
133
|
protected defaultIdempotencyKey(): string;
|
|
150
134
|
protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
|
|
@@ -201,17 +185,98 @@ export declare class CasParser {
|
|
|
201
185
|
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
202
186
|
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
203
187
|
static toFile: typeof Uploads.toFile;
|
|
188
|
+
/**
|
|
189
|
+
* Endpoints for checking API quota and credits usage.
|
|
190
|
+
* These endpoints help you monitor your API usage and remaining quota.
|
|
191
|
+
*
|
|
192
|
+
*/
|
|
204
193
|
credits: API.Credits;
|
|
194
|
+
/**
|
|
195
|
+
* Endpoints for checking API quota and credits usage.
|
|
196
|
+
* These endpoints help you monitor your API usage and remaining quota.
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
205
199
|
logs: API.Logs;
|
|
200
|
+
/**
|
|
201
|
+
* Endpoints for managing access tokens for the Portfolio Connect SDK.
|
|
202
|
+
* Use these to generate short-lived `at_` prefixed tokens that can be safely passed to frontend applications.
|
|
203
|
+
* Access tokens can be used in place of API keys on all v4 endpoints.
|
|
204
|
+
*
|
|
205
|
+
*/
|
|
206
206
|
accessToken: API.AccessToken;
|
|
207
|
+
/**
|
|
208
|
+
* Endpoints for managing access tokens for the Portfolio Connect SDK.
|
|
209
|
+
* Use these to generate short-lived `at_` prefixed tokens that can be safely passed to frontend applications.
|
|
210
|
+
* Access tokens can be used in place of API keys on all v4 endpoints.
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
207
213
|
verifyToken: API.VerifyToken;
|
|
214
|
+
/**
|
|
215
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
216
|
+
*/
|
|
208
217
|
camsKfintech: API.CamsKfintech;
|
|
218
|
+
/**
|
|
219
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
220
|
+
*/
|
|
209
221
|
cdsl: API.Cdsl;
|
|
222
|
+
/**
|
|
223
|
+
* Endpoints for parsing Contract Note PDF files from various SEBI brokers like Zerodha, Groww, Upstox, ICICI etc.
|
|
224
|
+
*/
|
|
210
225
|
contractNote: API.ContractNote;
|
|
226
|
+
/**
|
|
227
|
+
* Endpoints for importing CAS files directly from user email inboxes.
|
|
228
|
+
*
|
|
229
|
+
* **Supported Providers:** Gmail (more coming soon)
|
|
230
|
+
*
|
|
231
|
+
* **How it works:**
|
|
232
|
+
* 1. Call `POST /v4/inbox/connect` to get an OAuth URL
|
|
233
|
+
* 2. Redirect user to the OAuth URL for consent
|
|
234
|
+
* 3. User is redirected back to your `redirect_uri` with an encrypted `inbox_token`
|
|
235
|
+
* 4. Use the token to list/fetch CAS files from their inbox (`/v4/inbox/cas`)
|
|
236
|
+
* 5. Files are uploaded to temporary cloud storage (URLs expire in 24 hours)
|
|
237
|
+
*
|
|
238
|
+
* **Security:**
|
|
239
|
+
* - Read-only access (we cannot send emails)
|
|
240
|
+
* - Tokens are encrypted with server-side secret
|
|
241
|
+
* - User can revoke access anytime via `/v4/inbox/disconnect`
|
|
242
|
+
*
|
|
243
|
+
*/
|
|
211
244
|
inbox: API.Inbox;
|
|
245
|
+
/**
|
|
246
|
+
* Endpoints for generating new CAS documents via email mailback (KFintech).
|
|
247
|
+
*/
|
|
212
248
|
kfintech: API.Kfintech;
|
|
249
|
+
/**
|
|
250
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
251
|
+
*/
|
|
213
252
|
nsdl: API.Nsdl;
|
|
253
|
+
/**
|
|
254
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
255
|
+
*/
|
|
214
256
|
smart: API.Smart;
|
|
257
|
+
/**
|
|
258
|
+
* Create dedicated inbound email addresses for investors to forward their CAS statements.
|
|
259
|
+
*
|
|
260
|
+
* **Use Case:** Your app wants to collect CAS statements from users without requiring OAuth or file upload.
|
|
261
|
+
*
|
|
262
|
+
* **How it works:**
|
|
263
|
+
* 1. Call `POST /v4/inbound-email` to create a unique inbound email address
|
|
264
|
+
* 2. Display this email to your user: "Forward your CAS statement to ie_xxx@import.casparser.in"
|
|
265
|
+
* 3. When user forwards a CAS email, we verify sender authenticity (SPF/DKIM) and call your webhook
|
|
266
|
+
* 4. Your webhook receives email metadata + attachment download URLs
|
|
267
|
+
*
|
|
268
|
+
* **Sender Validation:**
|
|
269
|
+
* - Only emails from verified CAS authorities are processed:
|
|
270
|
+
* - CDSL: `eCAS@cdslstatement.com`
|
|
271
|
+
* - NSDL: `NSDL-CAS@nsdl.co.in`
|
|
272
|
+
* - CAMS: `donotreply@camsonline.com`
|
|
273
|
+
* - KFintech: `samfS@kfintech.com`
|
|
274
|
+
* - Emails failing SPF/DKIM/DMARC are rejected
|
|
275
|
+
* - Forwarded emails must contain the original sender in headers
|
|
276
|
+
*
|
|
277
|
+
* **Billing:** 0.2 credits per successfully processed valid email
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
215
280
|
inboundEmail: API.InboundEmail;
|
|
216
281
|
}
|
|
217
282
|
export declare namespace CasParser {
|
package/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;YAIvE,EAAE,MAAM,EAAE,QAAQ,EAAE;OAKzB,KAAK,IAAI;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;O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yBAAyB,IAAI,yBAAyB,GAC5D,CAAC;IAEF,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,KAAK,eAAe,IAAI,eAAe,EAAE,CAAC;IAEjE,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,KAAK,sBAAsB,IAAI,sBAAsB,EAAE,CAAC;IAEjF,OAAO,EACL,YAAY,IAAI,YAAY,EAC5B,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;CACH"}
|
package/client.js
CHANGED
|
@@ -11,6 +11,7 @@ const errors_1 = require("./internal/errors.js");
|
|
|
11
11
|
const detect_platform_1 = require("./internal/detect-platform.js");
|
|
12
12
|
const Shims = tslib_1.__importStar(require("./internal/shims.js"));
|
|
13
13
|
const Opts = tslib_1.__importStar(require("./internal/request-options.js"));
|
|
14
|
+
const query_1 = require("./internal/utils/query.js");
|
|
14
15
|
const version_1 = require("./version.js");
|
|
15
16
|
const Errors = tslib_1.__importStar(require("./core/error.js"));
|
|
16
17
|
const Uploads = tslib_1.__importStar(require("./core/uploads.js"));
|
|
@@ -32,11 +33,6 @@ const headers_1 = require("./internal/headers.js");
|
|
|
32
33
|
const env_1 = require("./internal/utils/env.js");
|
|
33
34
|
const log_1 = require("./internal/utils/log.js");
|
|
34
35
|
const values_2 = require("./internal/utils/values.js");
|
|
35
|
-
const environments = {
|
|
36
|
-
production: 'https://portfolio-parser.api.casparser.in',
|
|
37
|
-
environment_1: 'https://client-apis.casparser.in',
|
|
38
|
-
environment_2: 'http://localhost:5000',
|
|
39
|
-
};
|
|
40
36
|
/**
|
|
41
37
|
* API Client for interfacing with the Cas Parser API.
|
|
42
38
|
*/
|
|
@@ -45,8 +41,7 @@ class CasParser {
|
|
|
45
41
|
* API Client for interfacing with the Cas Parser API.
|
|
46
42
|
*
|
|
47
43
|
* @param {string | undefined} [opts.apiKey=process.env['CAS_PARSER_API_KEY'] ?? undefined]
|
|
48
|
-
* @param {
|
|
49
|
-
* @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://portfolio-parser.api.casparser.in] - Override the default base URL for the API.
|
|
44
|
+
* @param {string} [opts.baseURL=process.env['CAS_PARSER_BASE_URL'] ?? https://api.casparser.in] - Override the default base URL for the API.
|
|
50
45
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
51
46
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
52
47
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -57,17 +52,98 @@ class CasParser {
|
|
|
57
52
|
constructor({ baseURL = (0, env_1.readEnv)('CAS_PARSER_BASE_URL'), apiKey = (0, env_1.readEnv)('CAS_PARSER_API_KEY'), ...opts } = {}) {
|
|
58
53
|
_CasParser_instances.add(this);
|
|
59
54
|
_CasParser_encoder.set(this, void 0);
|
|
55
|
+
/**
|
|
56
|
+
* Endpoints for checking API quota and credits usage.
|
|
57
|
+
* These endpoints help you monitor your API usage and remaining quota.
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
60
|
this.credits = new API.Credits(this);
|
|
61
|
+
/**
|
|
62
|
+
* Endpoints for checking API quota and credits usage.
|
|
63
|
+
* These endpoints help you monitor your API usage and remaining quota.
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
61
66
|
this.logs = new API.Logs(this);
|
|
67
|
+
/**
|
|
68
|
+
* Endpoints for managing access tokens for the Portfolio Connect SDK.
|
|
69
|
+
* Use these to generate short-lived `at_` prefixed tokens that can be safely passed to frontend applications.
|
|
70
|
+
* Access tokens can be used in place of API keys on all v4 endpoints.
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
62
73
|
this.accessToken = new API.AccessToken(this);
|
|
74
|
+
/**
|
|
75
|
+
* Endpoints for managing access tokens for the Portfolio Connect SDK.
|
|
76
|
+
* Use these to generate short-lived `at_` prefixed tokens that can be safely passed to frontend applications.
|
|
77
|
+
* Access tokens can be used in place of API keys on all v4 endpoints.
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
63
80
|
this.verifyToken = new API.VerifyToken(this);
|
|
81
|
+
/**
|
|
82
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
83
|
+
*/
|
|
64
84
|
this.camsKfintech = new API.CamsKfintech(this);
|
|
85
|
+
/**
|
|
86
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
87
|
+
*/
|
|
65
88
|
this.cdsl = new API.Cdsl(this);
|
|
89
|
+
/**
|
|
90
|
+
* Endpoints for parsing Contract Note PDF files from various SEBI brokers like Zerodha, Groww, Upstox, ICICI etc.
|
|
91
|
+
*/
|
|
66
92
|
this.contractNote = new API.ContractNote(this);
|
|
93
|
+
/**
|
|
94
|
+
* Endpoints for importing CAS files directly from user email inboxes.
|
|
95
|
+
*
|
|
96
|
+
* **Supported Providers:** Gmail (more coming soon)
|
|
97
|
+
*
|
|
98
|
+
* **How it works:**
|
|
99
|
+
* 1. Call `POST /v4/inbox/connect` to get an OAuth URL
|
|
100
|
+
* 2. Redirect user to the OAuth URL for consent
|
|
101
|
+
* 3. User is redirected back to your `redirect_uri` with an encrypted `inbox_token`
|
|
102
|
+
* 4. Use the token to list/fetch CAS files from their inbox (`/v4/inbox/cas`)
|
|
103
|
+
* 5. Files are uploaded to temporary cloud storage (URLs expire in 24 hours)
|
|
104
|
+
*
|
|
105
|
+
* **Security:**
|
|
106
|
+
* - Read-only access (we cannot send emails)
|
|
107
|
+
* - Tokens are encrypted with server-side secret
|
|
108
|
+
* - User can revoke access anytime via `/v4/inbox/disconnect`
|
|
109
|
+
*
|
|
110
|
+
*/
|
|
67
111
|
this.inbox = new API.Inbox(this);
|
|
112
|
+
/**
|
|
113
|
+
* Endpoints for generating new CAS documents via email mailback (KFintech).
|
|
114
|
+
*/
|
|
68
115
|
this.kfintech = new API.Kfintech(this);
|
|
116
|
+
/**
|
|
117
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
118
|
+
*/
|
|
69
119
|
this.nsdl = new API.Nsdl(this);
|
|
120
|
+
/**
|
|
121
|
+
* Endpoints for parsing CAS PDF files from different sources.
|
|
122
|
+
*/
|
|
70
123
|
this.smart = new API.Smart(this);
|
|
124
|
+
/**
|
|
125
|
+
* Create dedicated inbound email addresses for investors to forward their CAS statements.
|
|
126
|
+
*
|
|
127
|
+
* **Use Case:** Your app wants to collect CAS statements from users without requiring OAuth or file upload.
|
|
128
|
+
*
|
|
129
|
+
* **How it works:**
|
|
130
|
+
* 1. Call `POST /v4/inbound-email` to create a unique inbound email address
|
|
131
|
+
* 2. Display this email to your user: "Forward your CAS statement to ie_xxx@import.casparser.in"
|
|
132
|
+
* 3. When user forwards a CAS email, we verify sender authenticity (SPF/DKIM) and call your webhook
|
|
133
|
+
* 4. Your webhook receives email metadata + attachment download URLs
|
|
134
|
+
*
|
|
135
|
+
* **Sender Validation:**
|
|
136
|
+
* - Only emails from verified CAS authorities are processed:
|
|
137
|
+
* - CDSL: `eCAS@cdslstatement.com`
|
|
138
|
+
* - NSDL: `NSDL-CAS@nsdl.co.in`
|
|
139
|
+
* - CAMS: `donotreply@camsonline.com`
|
|
140
|
+
* - KFintech: `samfS@kfintech.com`
|
|
141
|
+
* - Emails failing SPF/DKIM/DMARC are rejected
|
|
142
|
+
* - Forwarded emails must contain the original sender in headers
|
|
143
|
+
*
|
|
144
|
+
* **Billing:** 0.2 credits per successfully processed valid email
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
71
147
|
this.inboundEmail = new API.InboundEmail(this);
|
|
72
148
|
if (apiKey === undefined) {
|
|
73
149
|
throw new Errors.CasParserError("The CAS_PARSER_API_KEY environment variable is missing or empty; either provide it, or instantiate the CasParser client with an apiKey option, like new CasParser({ apiKey: 'My API Key' }).");
|
|
@@ -75,13 +151,9 @@ class CasParser {
|
|
|
75
151
|
const options = {
|
|
76
152
|
apiKey,
|
|
77
153
|
...opts,
|
|
78
|
-
baseURL
|
|
79
|
-
environment: opts.environment ?? 'production',
|
|
154
|
+
baseURL: baseURL || `https://api.casparser.in`,
|
|
80
155
|
};
|
|
81
|
-
|
|
82
|
-
throw new Errors.CasParserError('Ambiguous URL; The `baseURL` option (or CAS_PARSER_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null');
|
|
83
|
-
}
|
|
84
|
-
this.baseURL = options.baseURL || environments[options.environment || 'production'];
|
|
156
|
+
this.baseURL = options.baseURL;
|
|
85
157
|
this.timeout = options.timeout ?? _a.DEFAULT_TIMEOUT /* 1 minute */;
|
|
86
158
|
this.logger = options.logger ?? console;
|
|
87
159
|
const defaultLogLevel = 'warn';
|
|
@@ -104,8 +176,7 @@ class CasParser {
|
|
|
104
176
|
withOptions(options) {
|
|
105
177
|
const client = new this.constructor({
|
|
106
178
|
...this._options,
|
|
107
|
-
|
|
108
|
-
baseURL: options.environment ? undefined : this.baseURL,
|
|
179
|
+
baseURL: this.baseURL,
|
|
109
180
|
maxRetries: this.maxRetries,
|
|
110
181
|
timeout: this.timeout,
|
|
111
182
|
logger: this.logger,
|
|
@@ -130,18 +201,7 @@ class CasParser {
|
|
|
130
201
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
131
202
|
*/
|
|
132
203
|
stringifyQuery(query) {
|
|
133
|
-
return
|
|
134
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
135
|
-
.map(([key, value]) => {
|
|
136
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
137
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
138
|
-
}
|
|
139
|
-
if (value === null) {
|
|
140
|
-
return `${encodeURIComponent(key)}=`;
|
|
141
|
-
}
|
|
142
|
-
throw new Errors.CasParserError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
143
|
-
})
|
|
144
|
-
.join('&');
|
|
204
|
+
return (0, query_1.stringifyQuery)(query);
|
|
145
205
|
}
|
|
146
206
|
getUserAgent() {
|
|
147
207
|
return `${this.constructor.name}/JS ${version_1.VERSION}`;
|
|
@@ -485,7 +545,7 @@ class CasParser {
|
|
|
485
545
|
}
|
|
486
546
|
exports.CasParser = CasParser;
|
|
487
547
|
_a = CasParser, _CasParser_encoder = new WeakMap(), _CasParser_instances = new WeakSet(), _CasParser_baseURLOverridden = function _CasParser_baseURLOverridden() {
|
|
488
|
-
return this.baseURL !==
|
|
548
|
+
return this.baseURL !== 'https://api.casparser.in';
|
|
489
549
|
};
|
|
490
550
|
CasParser.CasParser = _a;
|
|
491
551
|
CasParser.DEFAULT_TIMEOUT = 60000; // 1 minute
|