@uveysservetoglu/kobil-core 2.0.0 → 3.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 +78 -20
- package/dist/api.d.ts +43 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +38 -0
- package/dist/api.js.map +1 -0
- package/dist/credentials.d.ts +11 -4
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +20 -5
- package/dist/credentials.js.map +1 -1
- package/dist/endpoints.d.ts +9 -12
- package/dist/endpoints.d.ts.map +1 -1
- package/dist/endpoints.js +30 -9
- package/dist/endpoints.js.map +1 -1
- package/dist/error.d.ts +21 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +42 -0
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/multipart.d.ts +22 -0
- package/dist/multipart.d.ts.map +1 -0
- package/dist/multipart.js +37 -0
- package/dist/multipart.js.map +1 -0
- package/dist/push.d.ts +37 -0
- package/dist/push.d.ts.map +1 -0
- package/dist/push.js +3 -0
- package/dist/push.js.map +1 -0
- package/dist/service-client.d.ts +15 -2
- package/dist/service-client.d.ts.map +1 -1
- package/dist/service-client.js +53 -6
- package/dist/service-client.js.map +1 -1
- package/dist/token-provider.d.ts +16 -0
- package/dist/token-provider.d.ts.map +1 -1
- package/dist/token-provider.js +29 -4
- package/dist/token-provider.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,48 +1,106 @@
|
|
|
1
1
|
# @uveysservetoglu/kobil-core
|
|
2
2
|
|
|
3
|
-
Shared foundation for the KOBIL SDK family (`@uveysservetoglu/kobil-payment`, `@uveysservetoglu/kobil-chat`, `@uveysservetoglu/kobil-sign`, …).
|
|
3
|
+
Shared foundation for the KOBIL SDK family (`@uveysservetoglu/kobil-payment`, `@uveysservetoglu/kobil-chat`, `@uveysservetoglu/kobil-sign`, `@uveysservetoglu/kobil-tms`, …).
|
|
4
4
|
|
|
5
5
|
You normally don't use this directly — the module packages depend on it. It provides:
|
|
6
6
|
|
|
7
|
+
- **API mode** — `resolveApiMode`, `KobilApiOptions`: which KOBIL backend every client talks to (below).
|
|
7
8
|
- **`DefaultTokenProvider`** — OAuth2 `client_credentials` token acquisition with in-memory
|
|
8
9
|
caching (single in-flight request, honours `expires_in`). Modes: `post` (form body,
|
|
9
10
|
default) or `basic` (HTTP Basic header).
|
|
10
|
-
- **`
|
|
11
|
+
- **`StaticTokenProvider`** — hands a token you already have (e.g. a signed-in user's) to any client.
|
|
12
|
+
- **`KobilError`** — base error all module errors extend (`statusCode`, `responseBody`, and the
|
|
13
|
+
MiniApp API's `errorCode`, `subsystem`, `traceId`).
|
|
11
14
|
- **`KobilServiceClient`** — HTTP base for typed clients (bearer + send + error wrapping,
|
|
12
|
-
JSON /
|
|
15
|
+
JSON / multipart / binary-download / redirect-download helpers).
|
|
13
16
|
- **`credentialsFromEnv`** — builds credentials from the environment (below).
|
|
14
|
-
- **Endpoint helpers** — `tokenEndpointFor`, `authorizationEndpointFor`, `
|
|
15
|
-
`
|
|
16
|
-
|
|
17
|
+
- **Endpoint helpers** — `tokenEndpointFor`, `authorizationEndpointFor`, `defaultTokenEndpoint`,
|
|
18
|
+
`miniappApiBase`, `miniappTokenEndpoint`, `mpowerUserEndpoint`, `mpowerMediaDownloadEndpoint`,
|
|
19
|
+
`paymentTransactionEndpoint`, `tmsEndpoint`: the fixed paths each service sits at under its base
|
|
20
|
+
URL, so the environment names a base and the SDK builds the rest.
|
|
21
|
+
- **Push types** — `PushContent`, `PushResponse`, shared by chat and sign.
|
|
17
22
|
|
|
18
23
|
Works from both TypeScript and JavaScript (ships compiled JS + `.d.ts`). Requires Node 18+
|
|
19
24
|
(global `fetch`).
|
|
20
25
|
|
|
26
|
+
## API mode
|
|
27
|
+
|
|
28
|
+
KOBIL exposes the same services through two APIs, and every client can talk to either:
|
|
29
|
+
|
|
30
|
+
| Mode | Backend | Notes |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `"miniapp"` (**default**) | The unified [MiniApp API](https://documentation.cloud.kobil.com/api/miniapp-api/#/): one host, one token, `/v1/...` | Tenant comes from the token; one error envelope; push notifications. |
|
|
33
|
+
| `"legacy"` | The per-service [Legacy API](https://documentation.cloud.kobil.com/api/legacy/#/): Keycloak, mPower, mpay-merchant, TMS | Deprecated by KOBIL. Wire format identical to 2.x. |
|
|
34
|
+
|
|
35
|
+
Choose it per client with the `apiMode` option, or for the whole process with `KOBIL_API_MODE`.
|
|
36
|
+
Leaving both unset means `"miniapp"`. Method names and inputs are the same in both modes — amounts in
|
|
37
|
+
minor units, signature boxes in either coordinate style — and each client converts them to the
|
|
38
|
+
selected API's shape.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
new ChatClient(); // MiniApp API
|
|
42
|
+
new ChatClient({ apiMode: "legacy" }); // Legacy API
|
|
43
|
+
```
|
|
44
|
+
|
|
21
45
|
## Environment
|
|
22
46
|
|
|
23
47
|
These are the names the SuperApp emulator publishes at `/__superapp/control/env`, so an app
|
|
24
48
|
configured for the emulator needs no separate mapping — only the values change between the emulator
|
|
25
49
|
and production.
|
|
26
50
|
|
|
27
|
-
| Variable | Used by | Meaning |
|
|
28
|
-
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
51
|
+
| Variable | Mode | Used by | Meaning |
|
|
52
|
+
|---|---|---|---|
|
|
53
|
+
| `KOBIL_API_MODE` | both | all | `miniapp` (default) or `legacy`. |
|
|
54
|
+
| `MINIAPP_API_BASE` | miniapp | all | MiniApp API origin. Default `https://miniapp-api.cloud.kobil.com`; set `https://miniapp-api.cloud.test.kobil.com` for the test environment. |
|
|
55
|
+
| `OIDC_ISSUER` | both | all | Realm issuer URL. The login page and the token endpoint are derived from it — in miniapp mode, `{MINIAPP_API_BASE}/v1/auth/tokens/{realm}` with the realm read from the issuer. |
|
|
56
|
+
| `OIDC_CLIENT_ID` | both | all | MiniApp client id (also the legacy default `serviceUuid`). |
|
|
57
|
+
| `OIDC_CLIENT_SECRET` | both | all | MiniApp client secret. |
|
|
58
|
+
| `OIDC_TOKEN_AUTH_MODE` | both | all | `post` (default) or `basic`. The MiniApp API documents `post` only. |
|
|
59
|
+
| `MPOWER_BASE` | legacy | chat, sign | mPower origin. The per-user and media paths are derived from it. |
|
|
60
|
+
| `MPOWER_TENANT` | legacy | chat, sign | Tenant/realm substituted for `{TENANT}` (also the realm fallback when the issuer names none). |
|
|
61
|
+
| `PAYMENT_BASE` | legacy | payment | Payment origin. The transaction path is derived from it. |
|
|
62
|
+
| `PAYMENT_MERCHANT_ID` | both | payment | The `merchantId` on the wire. Legacy: also the client the payment token is fetched for. |
|
|
63
|
+
| `PAYMENT_MERCHANT_SECRET` | legacy | payment | Merchant client secret. |
|
|
64
|
+
| `PAYMENT_TENANT_ID` | legacy | payment | Payment tenant — a different tenant from mPower's. |
|
|
65
|
+
| `PAYMENT_MERCHANT_NAME` | legacy | payment | Merchant name shown to the payer. |
|
|
66
|
+
| `TMS_BASE` | legacy | tms | TMS origin (e.g. `https://asts.cloud.kobil.com`). |
|
|
40
67
|
|
|
41
68
|
Endpoints are derived rather than configured because the issuer is the one fact a deployment
|
|
42
69
|
actually has: the previous scheme asked for a full token URL here and a second one in the auth
|
|
43
70
|
module, which is the same server described twice under two names. `OIDC_TOKEN_ENDPOINT` and
|
|
44
71
|
`OIDC_AUTHORIZATION_ENDPOINT` remain as explicit overrides for deployments whose paths are not the
|
|
45
|
-
standard ones.
|
|
72
|
+
standard ones; `OIDC_TOKEN_ENDPOINT` wins in both modes.
|
|
73
|
+
|
|
74
|
+
## Which token?
|
|
75
|
+
|
|
76
|
+
By default each client fetches a `client_credentials` token for the MiniApp. The MiniApp API
|
|
77
|
+
recommends a **user** token (from the authorization-code login) for calls that target a specific
|
|
78
|
+
`userId` — messages, payments, transactions. To act as the signed-in user, hand that token over:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { StaticTokenProvider } from "@uveysservetoglu/kobil-core";
|
|
82
|
+
|
|
83
|
+
const chat = new ChatClient({ tokenProvider: new StaticTokenProvider(session.accessToken) });
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Errors
|
|
87
|
+
|
|
88
|
+
Every MiniApp API failure carries `{code, subsystem, message, traceId}`. `KobilError` exposes them as
|
|
89
|
+
`errorCode` (KOBIL's application code, not the HTTP status), `subsystem` (790 is the MiniApp API
|
|
90
|
+
itself) and `traceId` — quote the trace id when reporting a problem to KOBIL. Legacy services answer
|
|
91
|
+
with other shapes; those fields are then `undefined` and `responseBody` holds the raw text.
|
|
92
|
+
|
|
93
|
+
## Upgrading from 2.x
|
|
94
|
+
|
|
95
|
+
3.0 changes the default backend. Everything else is additive.
|
|
96
|
+
|
|
97
|
+
- **Nothing set → MiniApp API.** 2.x always called the legacy services. To keep that, set
|
|
98
|
+
`KOBIL_API_MODE=legacy` (or pass `apiMode: "legacy"`): legacy mode sends byte-for-byte the requests
|
|
99
|
+
2.x sent.
|
|
100
|
+
- In miniapp mode `MPOWER_BASE`, `PAYMENT_BASE`, `PAYMENT_MERCHANT_SECRET`, `PAYMENT_TENANT_ID` and
|
|
101
|
+
`PAYMENT_MERCHANT_NAME` are not needed; `OIDC_*` (and `MINIAPP_API_BASE` outside production) are.
|
|
102
|
+
- Client methods now always return a rejected promise on invalid input instead of throwing
|
|
103
|
+
synchronously — `await` code is unaffected.
|
|
46
104
|
|
|
47
105
|
## License
|
|
48
106
|
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which KOBIL backend a client talks to.
|
|
3
|
+
*
|
|
4
|
+
* - `"miniapp"` — the unified MiniApp API: one host, one token, `/v1/...` paths. The default.
|
|
5
|
+
* - `"legacy"` — the original per-service APIs (Keycloak, mPower, mpay-merchant, TMS), which KOBIL has
|
|
6
|
+
* deprecated. Choose it explicitly for a deployment that still runs against them.
|
|
7
|
+
*/
|
|
8
|
+
export type ApiMode = "miniapp" | "legacy";
|
|
9
|
+
/** Where the MiniApp API lives in production. */
|
|
10
|
+
export declare const DEFAULT_MINIAPP_API_BASE = "https://miniapp-api.cloud.kobil.com";
|
|
11
|
+
/** Options every module client accepts for choosing and locating the backend. */
|
|
12
|
+
export interface KobilApiOptions {
|
|
13
|
+
/** Backend to call. Falls back to `KOBIL_API_MODE`, then `"miniapp"`. */
|
|
14
|
+
apiMode?: ApiMode;
|
|
15
|
+
/**
|
|
16
|
+
* MiniApp API base URL. Falls back to `MINIAPP_API_BASE`, then {@link DEFAULT_MINIAPP_API_BASE}.
|
|
17
|
+
* Only used in `"miniapp"` mode.
|
|
18
|
+
*/
|
|
19
|
+
apiBaseUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Realm (tenant) the MiniApp API mints tokens for — the `{tenantId}` of `/v1/auth/tokens/{tenantId}`.
|
|
22
|
+
* Falls back to the realm in `OIDC_ISSUER`, then `MPOWER_TENANT`. Only used in `"miniapp"` mode, and
|
|
23
|
+
* only when the token endpoint is not given some other way.
|
|
24
|
+
*/
|
|
25
|
+
realm?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The mode to use: the explicit value, else `KOBIL_API_MODE`, else `"miniapp"`. An unknown value is an
|
|
29
|
+
* error rather than a silent fallback — a typo would otherwise send traffic to the other backend.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveApiMode(mode?: string): ApiMode;
|
|
32
|
+
/**
|
|
33
|
+
* The realm named in a Keycloak issuer URL (`…/realms/{realm}`), or `""` when there is none. Works for
|
|
34
|
+
* both a full URL and the path-only issuers the emulator hands out.
|
|
35
|
+
*/
|
|
36
|
+
export declare function realmFromIssuer(issuer: string | undefined): string;
|
|
37
|
+
/**
|
|
38
|
+
* The realm for the MiniApp token endpoint: the explicit value, else the one in the issuer (default
|
|
39
|
+
* `OIDC_ISSUER` — the issuer is the one fact every deployment configures), else `MPOWER_TENANT`, which
|
|
40
|
+
* names the same realm.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveRealm(realm?: string, issuer?: string | undefined): string;
|
|
43
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3C,iDAAiD;AACjD,eAAO,MAAM,wBAAwB,wCAAwC,CAAC;AAE9E,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAKrD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGlE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,GAAG,SAAmC,GAAG,MAAM,CAEzG"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_MINIAPP_API_BASE = void 0;
|
|
4
|
+
exports.resolveApiMode = resolveApiMode;
|
|
5
|
+
exports.realmFromIssuer = realmFromIssuer;
|
|
6
|
+
exports.resolveRealm = resolveRealm;
|
|
7
|
+
const error_1 = require("./error");
|
|
8
|
+
/** Where the MiniApp API lives in production. */
|
|
9
|
+
exports.DEFAULT_MINIAPP_API_BASE = "https://miniapp-api.cloud.kobil.com";
|
|
10
|
+
/**
|
|
11
|
+
* The mode to use: the explicit value, else `KOBIL_API_MODE`, else `"miniapp"`. An unknown value is an
|
|
12
|
+
* error rather than a silent fallback — a typo would otherwise send traffic to the other backend.
|
|
13
|
+
*/
|
|
14
|
+
function resolveApiMode(mode) {
|
|
15
|
+
const raw = (mode || process.env.KOBIL_API_MODE || "").trim().toLowerCase();
|
|
16
|
+
if (raw === "" || raw === "miniapp")
|
|
17
|
+
return "miniapp";
|
|
18
|
+
if (raw === "legacy")
|
|
19
|
+
return "legacy";
|
|
20
|
+
throw new error_1.KobilError(`Unknown API mode "${mode || process.env.KOBIL_API_MODE}": use "miniapp" or "legacy".`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The realm named in a Keycloak issuer URL (`…/realms/{realm}`), or `""` when there is none. Works for
|
|
24
|
+
* both a full URL and the path-only issuers the emulator hands out.
|
|
25
|
+
*/
|
|
26
|
+
function realmFromIssuer(issuer) {
|
|
27
|
+
const match = /\/realms\/([^/?#]+)\/*$/.exec((issuer ?? "").trim());
|
|
28
|
+
return match ? decodeURIComponent(match[1]) : "";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The realm for the MiniApp token endpoint: the explicit value, else the one in the issuer (default
|
|
32
|
+
* `OIDC_ISSUER` — the issuer is the one fact every deployment configures), else `MPOWER_TENANT`, which
|
|
33
|
+
* names the same realm.
|
|
34
|
+
*/
|
|
35
|
+
function resolveRealm(realm, issuer = process.env.OIDC_ISSUER) {
|
|
36
|
+
return realm || realmFromIssuer(issuer) || process.env.MPOWER_TENANT || "";
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;AAmCA,wCAKC;AAMD,0CAGC;AAOD,oCAEC;AA1DD,mCAAqC;AAWrC,iDAAiD;AACpC,QAAA,wBAAwB,GAAG,qCAAqC,CAAC;AAmB9E;;;GAGG;AACH,SAAgB,cAAc,CAAC,IAAa;IAC1C,MAAM,GAAG,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5E,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACtD,IAAI,GAAG,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACtC,MAAM,IAAI,kBAAU,CAAC,qBAAqB,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,+BAA+B,CAAC,CAAC;AAC/G,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,MAA0B;IACxD,MAAM,KAAK,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACpE,OAAO,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,KAAc,EAAE,SAA6B,OAAO,CAAC,GAAG,CAAC,WAAW;IAC/F,OAAO,KAAK,IAAI,eAAe,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;AAC7E,CAAC"}
|
package/dist/credentials.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KobilApiOptions } from "./api";
|
|
1
2
|
/** How client credentials are presented to the OAuth2 token endpoint. */
|
|
2
3
|
export type TokenAuthMode = "post" | "basic";
|
|
3
4
|
/**
|
|
@@ -19,17 +20,23 @@ export interface KobilCredentials {
|
|
|
19
20
|
export declare function tokenEndpointFor(issuer: string): string;
|
|
20
21
|
/** The authorization endpoint of an OIDC issuer — where a person is sent to log in. */
|
|
21
22
|
export declare function authorizationEndpointFor(issuer: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* The token endpoint a client uses when none is given explicitly: `OIDC_TOKEN_ENDPOINT` if set, else
|
|
25
|
+
* — in `"miniapp"` mode — the MiniApp API's `/v1/auth/tokens/{realm}`, or — in `"legacy"` mode — the
|
|
26
|
+
* issuer's standard Keycloak path. `issuer` defaults to `OIDC_ISSUER`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function defaultTokenEndpoint(api?: KobilApiOptions, issuer?: string): string;
|
|
22
29
|
/**
|
|
23
30
|
* Builds credentials from the environment, with optional overrides (undefined/empty override values
|
|
24
31
|
* are ignored, so the environment still supplies those).
|
|
25
32
|
*
|
|
26
33
|
* | Variable | Meaning |
|
|
27
34
|
* |---|---|
|
|
28
|
-
* | `OIDC_ISSUER` | Realm issuer URL. The token endpoint is derived from it. |
|
|
35
|
+
* | `OIDC_ISSUER` | Realm issuer URL. The token endpoint (and, in miniapp mode, the realm) is derived from it. |
|
|
29
36
|
* | `OIDC_CLIENT_ID` | Client id. |
|
|
30
37
|
* | `OIDC_CLIENT_SECRET` | Client secret. |
|
|
31
38
|
* | `OIDC_TOKEN_AUTH_MODE` | `post` (default) or `basic`. |
|
|
32
|
-
* | `OIDC_TOKEN_ENDPOINT` | Full token URL.
|
|
39
|
+
* | `OIDC_TOKEN_ENDPOINT` | Full token URL. Overrides the derived one in both modes. |
|
|
33
40
|
*
|
|
34
41
|
* These are the names the SuperApp emulator publishes at `/__superapp/control/env`, so an app
|
|
35
42
|
* configured for the emulator needs no separate mapping — and the values are the only thing that
|
|
@@ -38,7 +45,7 @@ export declare function authorizationEndpointFor(issuer: string): string;
|
|
|
38
45
|
* The endpoint is derived rather than configured because the issuer is the one fact a deployment
|
|
39
46
|
* actually has: the previous scheme asked for `KOBIL_TOKEN_ENDPOINT` here and `OTOKEN_URL` in the auth
|
|
40
47
|
* module, which is the same server described twice under two names, and they could disagree.
|
|
41
|
-
* `
|
|
48
|
+
* `api` selects which derivation applies — see {@link defaultTokenEndpoint}.
|
|
42
49
|
*/
|
|
43
|
-
export declare function credentialsFromEnv(overrides?: Partial<KobilCredentials
|
|
50
|
+
export declare function credentialsFromEnv(overrides?: Partial<KobilCredentials>, api?: KobilApiOptions): KobilCredentials;
|
|
44
51
|
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,8FAA8F;IAC9F,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,0FAA0F;IAC1F,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAkBD,mDAAmD;AACnD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgC,MAAM,OAAO,CAAC;AAGtE,yEAAyE;AACzE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,8FAA8F;IAC9F,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,0FAA0F;IAC1F,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAkBD,mDAAmD;AACnD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,eAAoB,EACzB,MAAM,GAAE,MAAsC,GAC7C,MAAM,CAKR;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,GAAE,OAAO,CAAC,gBAAgB,CAAM,EACzC,GAAG,GAAE,eAAoB,GACxB,gBAAgB,CAclB"}
|
package/dist/credentials.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tokenEndpointFor = tokenEndpointFor;
|
|
4
4
|
exports.authorizationEndpointFor = authorizationEndpointFor;
|
|
5
|
+
exports.defaultTokenEndpoint = defaultTokenEndpoint;
|
|
5
6
|
exports.credentialsFromEnv = credentialsFromEnv;
|
|
7
|
+
const api_1 = require("./api");
|
|
8
|
+
const endpoints_1 = require("./endpoints");
|
|
6
9
|
/**
|
|
7
10
|
* Keycloak's standard endpoint paths under a realm issuer.
|
|
8
11
|
*
|
|
@@ -25,17 +28,29 @@ function tokenEndpointFor(issuer) {
|
|
|
25
28
|
function authorizationEndpointFor(issuer) {
|
|
26
29
|
return underIssuer(issuer, AUTHORIZE_PATH);
|
|
27
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* The token endpoint a client uses when none is given explicitly: `OIDC_TOKEN_ENDPOINT` if set, else
|
|
33
|
+
* — in `"miniapp"` mode — the MiniApp API's `/v1/auth/tokens/{realm}`, or — in `"legacy"` mode — the
|
|
34
|
+
* issuer's standard Keycloak path. `issuer` defaults to `OIDC_ISSUER`.
|
|
35
|
+
*/
|
|
36
|
+
function defaultTokenEndpoint(api = {}, issuer = process.env.OIDC_ISSUER ?? "") {
|
|
37
|
+
if (process.env.OIDC_TOKEN_ENDPOINT)
|
|
38
|
+
return process.env.OIDC_TOKEN_ENDPOINT;
|
|
39
|
+
return (0, api_1.resolveApiMode)(api.apiMode) === "legacy"
|
|
40
|
+
? tokenEndpointFor(issuer)
|
|
41
|
+
: (0, endpoints_1.miniappTokenEndpoint)(api.apiBaseUrl, (0, api_1.resolveRealm)(api.realm, issuer));
|
|
42
|
+
}
|
|
28
43
|
/**
|
|
29
44
|
* Builds credentials from the environment, with optional overrides (undefined/empty override values
|
|
30
45
|
* are ignored, so the environment still supplies those).
|
|
31
46
|
*
|
|
32
47
|
* | Variable | Meaning |
|
|
33
48
|
* |---|---|
|
|
34
|
-
* | `OIDC_ISSUER` | Realm issuer URL. The token endpoint is derived from it. |
|
|
49
|
+
* | `OIDC_ISSUER` | Realm issuer URL. The token endpoint (and, in miniapp mode, the realm) is derived from it. |
|
|
35
50
|
* | `OIDC_CLIENT_ID` | Client id. |
|
|
36
51
|
* | `OIDC_CLIENT_SECRET` | Client secret. |
|
|
37
52
|
* | `OIDC_TOKEN_AUTH_MODE` | `post` (default) or `basic`. |
|
|
38
|
-
* | `OIDC_TOKEN_ENDPOINT` | Full token URL.
|
|
53
|
+
* | `OIDC_TOKEN_ENDPOINT` | Full token URL. Overrides the derived one in both modes. |
|
|
39
54
|
*
|
|
40
55
|
* These are the names the SuperApp emulator publishes at `/__superapp/control/env`, so an app
|
|
41
56
|
* configured for the emulator needs no separate mapping — and the values are the only thing that
|
|
@@ -44,12 +59,12 @@ function authorizationEndpointFor(issuer) {
|
|
|
44
59
|
* The endpoint is derived rather than configured because the issuer is the one fact a deployment
|
|
45
60
|
* actually has: the previous scheme asked for `KOBIL_TOKEN_ENDPOINT` here and `OTOKEN_URL` in the auth
|
|
46
61
|
* module, which is the same server described twice under two names, and they could disagree.
|
|
47
|
-
* `
|
|
62
|
+
* `api` selects which derivation applies — see {@link defaultTokenEndpoint}.
|
|
48
63
|
*/
|
|
49
|
-
function credentialsFromEnv(overrides = {}) {
|
|
64
|
+
function credentialsFromEnv(overrides = {}, api = {}) {
|
|
50
65
|
const mode = process.env.OIDC_TOKEN_AUTH_MODE?.toLowerCase();
|
|
51
66
|
const base = {
|
|
52
|
-
tokenEndpoint:
|
|
67
|
+
tokenEndpoint: defaultTokenEndpoint(api),
|
|
53
68
|
clientId: process.env.OIDC_CLIENT_ID ?? "",
|
|
54
69
|
clientSecret: process.env.OIDC_CLIENT_SECRET ?? "",
|
|
55
70
|
tokenAuthMode: mode === "basic" || mode === "client_secret_basic" ? "basic" : "post",
|
package/dist/credentials.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":";;AAuCA,4CAEC;AAGD,4DAEC;AAOD,oDAQC;AAuBD,gDAiBC;AArGD,+BAAsE;AACtE,2CAAmD;AAqBnD;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,gCAAgC,CAAC;AACpD,MAAM,cAAc,GAAG,+BAA+B,CAAC;AAEvD,mEAAmE;AACnE,SAAS,WAAW,CAAC,MAA0B,EAAE,IAAY;IAC3D,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MA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E,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,qBAAqB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;KACrF,CAAC;IACF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAwC,EAAE,CAAC;QAC5F,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;YACvC,IAA2C,CAAC,GAAa,CAAC,GAAG,KAAK,CAAC;QACtE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* for payment — and the paths beneath them are fixed. So the environment names a base and these build
|
|
6
|
-
* the rest, which is why `MPOWER_BASE` and `PAYMENT_BASE` are enough to configure every module.
|
|
7
|
-
*
|
|
8
|
-
* The SuperApp emulator mounts the same paths under its own origin on purpose, so the only thing that
|
|
9
|
-
* changes between the emulator and production is the base.
|
|
10
|
-
*
|
|
11
|
-
* `{TENANT}`, `{USER_ID}` and `{MEDIA_ID}` are left in place: each client substitutes them per call.
|
|
12
|
-
*/
|
|
1
|
+
/** The MiniApp API base: the explicit value, else `MINIAPP_API_BASE`, else production. No trailing slash. */
|
|
2
|
+
export declare function miniappApiBase(base?: string): string;
|
|
3
|
+
/** The MiniApp API's token endpoint for a realm, or `""` when the realm is unknown. */
|
|
4
|
+
export declare function miniappTokenEndpoint(base: string | undefined, realm: string | undefined): string;
|
|
13
5
|
/**
|
|
14
6
|
* The per-user mPower endpoint, which both chat and signing hang off — chat appends `/message` or
|
|
15
7
|
* `/media`, signing appends `/signature`.
|
|
@@ -22,4 +14,9 @@ export declare function mpowerMediaDownloadEndpoint(mpowerBase: string | undefin
|
|
|
22
14
|
* payment client.
|
|
23
15
|
*/
|
|
24
16
|
export declare function paymentTransactionEndpoint(paymentBase: string | undefined): string;
|
|
17
|
+
/**
|
|
18
|
+
* Legacy TMS: the per-tenant transaction endpoint under the TMS host (`TMS_BASE`); `/{id}/status` and
|
|
19
|
+
* `/{id}/result` are derived from it by the TMS client.
|
|
20
|
+
*/
|
|
21
|
+
export declare function tmsEndpoint(tmsBase: string | undefined): string;
|
|
25
22
|
//# sourceMappingURL=endpoints.d.ts.map
|
package/dist/endpoints.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../src/endpoints.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../src/endpoints.ts"],"names":[],"mappings":"AAqBA,6GAA6G;AAC7G,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEhG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGzE;AAED,iEAAiE;AACjE,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGlF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGlF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG/D"}
|
package/dist/endpoints.js
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.miniappApiBase = miniappApiBase;
|
|
4
|
+
exports.miniappTokenEndpoint = miniappTokenEndpoint;
|
|
5
|
+
exports.mpowerUserEndpoint = mpowerUserEndpoint;
|
|
6
|
+
exports.mpowerMediaDownloadEndpoint = mpowerMediaDownloadEndpoint;
|
|
7
|
+
exports.paymentTransactionEndpoint = paymentTransactionEndpoint;
|
|
8
|
+
exports.tmsEndpoint = tmsEndpoint;
|
|
9
|
+
const api_1 = require("./api");
|
|
2
10
|
/**
|
|
3
11
|
* Where each service sits under its base URL.
|
|
4
12
|
*
|
|
5
|
-
*
|
|
6
|
-
* for payment — and the paths beneath them are fixed. So the environment names a base and
|
|
7
|
-
* the rest, which is why `MPOWER_BASE` and `PAYMENT_BASE` are enough to configure every
|
|
13
|
+
* Legacy mode: a deployment gives you two origins — one for mPower (chat and signing, on the identity
|
|
14
|
+
* host) and one for payment — and the paths beneath them are fixed. So the environment names a base and
|
|
15
|
+
* these build the rest, which is why `MPOWER_BASE` and `PAYMENT_BASE` are enough to configure every
|
|
16
|
+
* module. The SuperApp emulator mounts the same paths under its own origin on purpose, so the only thing
|
|
17
|
+
* that changes between the emulator and production is the base.
|
|
8
18
|
*
|
|
9
|
-
*
|
|
10
|
-
* changes between the emulator and production is the base.
|
|
19
|
+
* MiniApp mode: one origin for everything (`MINIAPP_API_BASE`), with `/v1/...` paths beneath it.
|
|
11
20
|
*
|
|
12
21
|
* `{TENANT}`, `{USER_ID}` and `{MEDIA_ID}` are left in place: each client substitutes them per call.
|
|
13
22
|
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.mpowerUserEndpoint = mpowerUserEndpoint;
|
|
16
|
-
exports.mpowerMediaDownloadEndpoint = mpowerMediaDownloadEndpoint;
|
|
17
|
-
exports.paymentTransactionEndpoint = paymentTransactionEndpoint;
|
|
18
23
|
/** `{base}` with any trailing slashes removed; empty stays empty. */
|
|
19
24
|
function origin(base) {
|
|
20
25
|
return (base ?? "").trim().replace(/\/+$/, "");
|
|
21
26
|
}
|
|
27
|
+
/** The MiniApp API base: the explicit value, else `MINIAPP_API_BASE`, else production. No trailing slash. */
|
|
28
|
+
function miniappApiBase(base) {
|
|
29
|
+
return origin(base || process.env.MINIAPP_API_BASE || api_1.DEFAULT_MINIAPP_API_BASE);
|
|
30
|
+
}
|
|
31
|
+
/** The MiniApp API's token endpoint for a realm, or `""` when the realm is unknown. */
|
|
32
|
+
function miniappTokenEndpoint(base, realm) {
|
|
33
|
+
return realm ? `${miniappApiBase(base)}/v1/auth/tokens/${encodeURIComponent(realm)}` : "";
|
|
34
|
+
}
|
|
22
35
|
/**
|
|
23
36
|
* The per-user mPower endpoint, which both chat and signing hang off — chat appends `/message` or
|
|
24
37
|
* `/media`, signing appends `/signature`.
|
|
@@ -40,4 +53,12 @@ function paymentTransactionEndpoint(paymentBase) {
|
|
|
40
53
|
const base = origin(paymentBase);
|
|
41
54
|
return base === "" ? "" : `${base}/mpay-merchant/create/transaction`;
|
|
42
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Legacy TMS: the per-tenant transaction endpoint under the TMS host (`TMS_BASE`); `/{id}/status` and
|
|
58
|
+
* `/{id}/result` are derived from it by the TMS client.
|
|
59
|
+
*/
|
|
60
|
+
function tmsEndpoint(tmsBase) {
|
|
61
|
+
const base = origin(tmsBase);
|
|
62
|
+
return base === "" ? "" : `${base}/v1/tenants/{TENANT}/tms`;
|
|
63
|
+
}
|
|
43
64
|
//# sourceMappingURL=endpoints.js.map
|
package/dist/endpoints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../src/endpoints.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../src/endpoints.ts"],"names":[],"mappings":";;AAsBA,wCAEC;AAGD,oDAEC;AAMD,gDAGC;AAGD,kEAGC;AAMD,gEAGC;AAMD,kCAGC;AA9DD,+BAAiD;AAEjD;;;;;;;;;;;;GAYG;AAEH,qEAAqE;AACrE,SAAS,MAAM,CAAC,IAAwB;IACtC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IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,0BAA0B,CAAC;AAC9D,CAAC"}
|
package/dist/error.d.ts
CHANGED
|
@@ -3,14 +3,35 @@ export interface KobilErrorOptions {
|
|
|
3
3
|
responseBody?: string;
|
|
4
4
|
cause?: unknown;
|
|
5
5
|
}
|
|
6
|
+
/** The MiniApp API's error body: `{code, subsystem, message, traceId}` on every non-2xx response. */
|
|
7
|
+
export interface KobilErrorEnvelope {
|
|
8
|
+
code: number;
|
|
9
|
+
subsystem: number;
|
|
10
|
+
message: string;
|
|
11
|
+
traceId?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The envelope in a response body, or `undefined` when the body is not one. Legacy services answer with
|
|
15
|
+
* other shapes (`{error}`, a string array, …), which simply yield nothing here.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseErrorEnvelope(body: string | undefined): KobilErrorEnvelope | undefined;
|
|
6
18
|
/**
|
|
7
19
|
* Base error for all KOBIL SDK modules. Module-specific errors
|
|
8
20
|
* (KobilPaymentError, KobilChatError, …) extend this, so callers can catch
|
|
9
21
|
* `KobilError` to handle any KOBIL failure uniformly.
|
|
22
|
+
*
|
|
23
|
+
* When the response body is a MiniApp API error envelope, its fields are exposed as `errorCode`,
|
|
24
|
+
* `subsystem` and `traceId` — `errorCode` is KOBIL's application code, distinct from `statusCode`.
|
|
10
25
|
*/
|
|
11
26
|
export declare class KobilError extends Error {
|
|
12
27
|
readonly statusCode?: number;
|
|
13
28
|
readonly responseBody?: string;
|
|
29
|
+
/** KOBIL application error code from the MiniApp API envelope (not the HTTP status). */
|
|
30
|
+
readonly errorCode?: number;
|
|
31
|
+
/** Subsystem that raised the error (790 is the MiniApp API itself). */
|
|
32
|
+
readonly subsystem?: number;
|
|
33
|
+
/** Trace id to quote when reporting the failure to KOBIL. */
|
|
34
|
+
readonly traceId?: string;
|
|
14
35
|
constructor(message: string, options?: KobilErrorOptions);
|
|
15
36
|
}
|
|
16
37
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,kBAAkB,GAAG,SAAS,CAiB3F;AAED;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,wFAAwF;IACxF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB;CAa7D"}
|
package/dist/error.js
CHANGED
|
@@ -1,19 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KobilError = void 0;
|
|
4
|
+
exports.parseErrorEnvelope = parseErrorEnvelope;
|
|
5
|
+
/**
|
|
6
|
+
* The envelope in a response body, or `undefined` when the body is not one. Legacy services answer with
|
|
7
|
+
* other shapes (`{error}`, a string array, …), which simply yield nothing here.
|
|
8
|
+
*/
|
|
9
|
+
function parseErrorEnvelope(body) {
|
|
10
|
+
if (!body)
|
|
11
|
+
return undefined;
|
|
12
|
+
let json;
|
|
13
|
+
try {
|
|
14
|
+
json = JSON.parse(body);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
if (typeof json !== "object" || json === null)
|
|
20
|
+
return undefined;
|
|
21
|
+
const e = json;
|
|
22
|
+
if (typeof e.code !== "number" || typeof e.subsystem !== "number")
|
|
23
|
+
return undefined;
|
|
24
|
+
return {
|
|
25
|
+
code: e.code,
|
|
26
|
+
subsystem: e.subsystem,
|
|
27
|
+
message: typeof e.message === "string" ? e.message : "",
|
|
28
|
+
traceId: typeof e.traceId === "string" ? e.traceId : undefined,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
4
31
|
/**
|
|
5
32
|
* Base error for all KOBIL SDK modules. Module-specific errors
|
|
6
33
|
* (KobilPaymentError, KobilChatError, …) extend this, so callers can catch
|
|
7
34
|
* `KobilError` to handle any KOBIL failure uniformly.
|
|
35
|
+
*
|
|
36
|
+
* When the response body is a MiniApp API error envelope, its fields are exposed as `errorCode`,
|
|
37
|
+
* `subsystem` and `traceId` — `errorCode` is KOBIL's application code, distinct from `statusCode`.
|
|
8
38
|
*/
|
|
9
39
|
class KobilError extends Error {
|
|
10
40
|
statusCode;
|
|
11
41
|
responseBody;
|
|
42
|
+
/** KOBIL application error code from the MiniApp API envelope (not the HTTP status). */
|
|
43
|
+
errorCode;
|
|
44
|
+
/** Subsystem that raised the error (790 is the MiniApp API itself). */
|
|
45
|
+
subsystem;
|
|
46
|
+
/** Trace id to quote when reporting the failure to KOBIL. */
|
|
47
|
+
traceId;
|
|
12
48
|
constructor(message, options = {}) {
|
|
13
49
|
super(message, options.cause !== undefined ? { cause: options.cause } : undefined);
|
|
14
50
|
this.name = new.target.name;
|
|
15
51
|
this.statusCode = options.statusCode;
|
|
16
52
|
this.responseBody = options.responseBody;
|
|
53
|
+
const envelope = parseErrorEnvelope(options.responseBody);
|
|
54
|
+
if (envelope) {
|
|
55
|
+
this.errorCode = envelope.code;
|
|
56
|
+
this.subsystem = envelope.subsystem;
|
|
57
|
+
this.traceId = envelope.traceId;
|
|
58
|
+
}
|
|
17
59
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
18
60
|
}
|
|
19
61
|
}
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAkBA,gDAiBC;AArBD;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,IAAwB;IACzD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAChE,MAAM,CAAC,GAAG,IAA+B,CAAC;IAC1C,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACpF,OAAO;QACL,I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,CAAC,CAAC;IACpD,CAAC;CACF;AAvBD,gCAuBC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
export { KobilError } from "./error";
|
|
2
|
-
export type { KobilErrorOptions } from "./error";
|
|
3
|
-
export {
|
|
1
|
+
export { KobilError, parseErrorEnvelope } from "./error";
|
|
2
|
+
export type { KobilErrorEnvelope, KobilErrorOptions } from "./error";
|
|
3
|
+
export { DEFAULT_MINIAPP_API_BASE, realmFromIssuer, resolveApiMode, resolveRealm } from "./api";
|
|
4
|
+
export type { ApiMode, KobilApiOptions } from "./api";
|
|
5
|
+
export { authorizationEndpointFor, credentialsFromEnv, defaultTokenEndpoint, tokenEndpointFor, } from "./credentials";
|
|
4
6
|
export type { KobilCredentials, TokenAuthMode } from "./credentials";
|
|
5
|
-
export { mpowerMediaDownloadEndpoint, mpowerUserEndpoint, paymentTransactionEndpoint, } from "./endpoints";
|
|
6
|
-
export {
|
|
7
|
+
export { miniappApiBase, miniappTokenEndpoint, mpowerMediaDownloadEndpoint, mpowerUserEndpoint, paymentTransactionEndpoint, tmsEndpoint, } from "./endpoints";
|
|
8
|
+
export { buildMultipart } from "./multipart";
|
|
9
|
+
export type { MultipartPart } from "./multipart";
|
|
10
|
+
export type { PushContent, PushDeviceResult, PushResponse } from "./push";
|
|
11
|
+
export { DefaultTokenProvider, StaticTokenProvider } from "./token-provider";
|
|
7
12
|
export type { TokenProvider } from "./token-provider";
|
|
8
13
|
export { KobilServiceClient } from "./service-client";
|
|
9
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAChG,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,0BAA0B,EAC1B,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KobilServiceClient = exports.DefaultTokenProvider = exports.paymentTransactionEndpoint = exports.mpowerUserEndpoint = exports.mpowerMediaDownloadEndpoint = exports.tokenEndpointFor = exports.credentialsFromEnv = exports.authorizationEndpointFor = exports.KobilError = void 0;
|
|
3
|
+
exports.KobilServiceClient = exports.StaticTokenProvider = exports.DefaultTokenProvider = exports.buildMultipart = exports.tmsEndpoint = exports.paymentTransactionEndpoint = exports.mpowerUserEndpoint = exports.mpowerMediaDownloadEndpoint = exports.miniappTokenEndpoint = exports.miniappApiBase = exports.tokenEndpointFor = exports.defaultTokenEndpoint = exports.credentialsFromEnv = exports.authorizationEndpointFor = exports.resolveRealm = exports.resolveApiMode = exports.realmFromIssuer = exports.DEFAULT_MINIAPP_API_BASE = exports.parseErrorEnvelope = exports.KobilError = void 0;
|
|
4
4
|
var error_1 = require("./error");
|
|
5
5
|
Object.defineProperty(exports, "KobilError", { enumerable: true, get: function () { return error_1.KobilError; } });
|
|
6
|
+
Object.defineProperty(exports, "parseErrorEnvelope", { enumerable: true, get: function () { return error_1.parseErrorEnvelope; } });
|
|
7
|
+
var api_1 = require("./api");
|
|
8
|
+
Object.defineProperty(exports, "DEFAULT_MINIAPP_API_BASE", { enumerable: true, get: function () { return api_1.DEFAULT_MINIAPP_API_BASE; } });
|
|
9
|
+
Object.defineProperty(exports, "realmFromIssuer", { enumerable: true, get: function () { return api_1.realmFromIssuer; } });
|
|
10
|
+
Object.defineProperty(exports, "resolveApiMode", { enumerable: true, get: function () { return api_1.resolveApiMode; } });
|
|
11
|
+
Object.defineProperty(exports, "resolveRealm", { enumerable: true, get: function () { return api_1.resolveRealm; } });
|
|
6
12
|
var credentials_1 = require("./credentials");
|
|
7
13
|
Object.defineProperty(exports, "authorizationEndpointFor", { enumerable: true, get: function () { return credentials_1.authorizationEndpointFor; } });
|
|
8
14
|
Object.defineProperty(exports, "credentialsFromEnv", { enumerable: true, get: function () { return credentials_1.credentialsFromEnv; } });
|
|
15
|
+
Object.defineProperty(exports, "defaultTokenEndpoint", { enumerable: true, get: function () { return credentials_1.defaultTokenEndpoint; } });
|
|
9
16
|
Object.defineProperty(exports, "tokenEndpointFor", { enumerable: true, get: function () { return credentials_1.tokenEndpointFor; } });
|
|
10
17
|
var endpoints_1 = require("./endpoints");
|
|
18
|
+
Object.defineProperty(exports, "miniappApiBase", { enumerable: true, get: function () { return endpoints_1.miniappApiBase; } });
|
|
19
|
+
Object.defineProperty(exports, "miniappTokenEndpoint", { enumerable: true, get: function () { return endpoints_1.miniappTokenEndpoint; } });
|
|
11
20
|
Object.defineProperty(exports, "mpowerMediaDownloadEndpoint", { enumerable: true, get: function () { return endpoints_1.mpowerMediaDownloadEndpoint; } });
|
|
12
21
|
Object.defineProperty(exports, "mpowerUserEndpoint", { enumerable: true, get: function () { return endpoints_1.mpowerUserEndpoint; } });
|
|
13
22
|
Object.defineProperty(exports, "paymentTransactionEndpoint", { enumerable: true, get: function () { return endpoints_1.paymentTransactionEndpoint; } });
|
|
23
|
+
Object.defineProperty(exports, "tmsEndpoint", { enumerable: true, get: function () { return endpoints_1.tmsEndpoint; } });
|
|
24
|
+
var multipart_1 = require("./multipart");
|
|
25
|
+
Object.defineProperty(exports, "buildMultipart", { enumerable: true, get: function () { return multipart_1.buildMultipart; } });
|
|
14
26
|
var token_provider_1 = require("./token-provider");
|
|
15
27
|
Object.defineProperty(exports, "DefaultTokenProvider", { enumerable: true, get: function () { return token_provider_1.DefaultTokenProvider; } });
|
|
28
|
+
Object.defineProperty(exports, "StaticTokenProvider", { enumerable: true, get: function () { return token_provider_1.StaticTokenProvider; } });
|
|
16
29
|
var service_client_1 = require("./service-client");
|
|
17
30
|
Object.defineProperty(exports, "KobilServiceClient", { enumerable: true, get: function () { return service_client_1.KobilServiceClient; } });
|
|
18
31
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAyD;AAAhD,mGAAA,UAAU,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAEvC,6BAAgG;AAAvF,+GAAA,wBAAwB,OAAA;AAAE,sGAAA,eAAe,OAAA;AAAE,qGAAA,cAAc,OAAA;AAAE,mGAAA,YAAY,OAAA;AAEhF,6CAKuB;AAJrB,uHAAA,wBAAwB,OAAA;AACxB,iHAAA,kBAAkB,OAAA;AAClB,mHAAA,oBAAoB,OAAA;AACpB,+GAAA,gBAAgB,OAAA;AAGlB,yCAOqB;AANnB,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA;AACpB,wHAAA,2BAA2B,OAAA;AAC3B,+GAAA,kBAAkB,OAAA;AAClB,uHAAA,0BAA0B,OAAA;AAC1B,wGAAA,WAAW,OAAA;AAEb,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AAGvB,mDAA6E;AAApE,sHAAA,oBAAoB,OAAA;AAAE,qHAAA,mBAAmB,OAAA;AAElD,mDAAsD;AAA7C,oHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** One part of a `multipart/form-data` body. */
|
|
2
|
+
export interface MultipartPart {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string | Uint8Array;
|
|
5
|
+
/** Sent as the part's `Content-Type`. Omitted when not given. */
|
|
6
|
+
contentType?: string;
|
|
7
|
+
/** Makes the part a file upload. */
|
|
8
|
+
fileName?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Encodes a `multipart/form-data` body by hand.
|
|
12
|
+
*
|
|
13
|
+
* `FormData` cannot give a text field its own `Content-Type`, and the MiniApp API declares its `message`
|
|
14
|
+
* part as `application/json`. Wrapping the JSON in a `Blob` would set the type but also turn the field
|
|
15
|
+
* into a file upload named "blob", which servers then file under uploads instead of fields. So the body
|
|
16
|
+
* is built here, with names escaped the way the WHATWG `FormData` serialiser escapes them.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildMultipart(parts: MultipartPart[]): {
|
|
19
|
+
body: Uint8Array;
|
|
20
|
+
contentType: string;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=multipart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../src/multipart.ts"],"names":[],"mappings":"AAEA,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAC3B,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAkBhG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildMultipart = buildMultipart;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
/**
|
|
6
|
+
* Encodes a `multipart/form-data` body by hand.
|
|
7
|
+
*
|
|
8
|
+
* `FormData` cannot give a text field its own `Content-Type`, and the MiniApp API declares its `message`
|
|
9
|
+
* part as `application/json`. Wrapping the JSON in a `Blob` would set the type but also turn the field
|
|
10
|
+
* into a file upload named "blob", which servers then file under uploads instead of fields. So the body
|
|
11
|
+
* is built here, with names escaped the way the WHATWG `FormData` serialiser escapes them.
|
|
12
|
+
*/
|
|
13
|
+
function buildMultipart(parts) {
|
|
14
|
+
const boundary = `----KobilFormBoundary${(0, crypto_1.randomBytes)(12).toString("hex")}`;
|
|
15
|
+
const chunks = [];
|
|
16
|
+
for (const part of parts) {
|
|
17
|
+
let head = `--${boundary}\r\nContent-Disposition: form-data; name="${escapeName(part.name)}"`;
|
|
18
|
+
if (part.fileName !== undefined)
|
|
19
|
+
head += `; filename="${escapeName(part.fileName)}"`;
|
|
20
|
+
head += "\r\n";
|
|
21
|
+
if (part.contentType)
|
|
22
|
+
head += `Content-Type: ${part.contentType}\r\n`;
|
|
23
|
+
head += "\r\n";
|
|
24
|
+
chunks.push(Buffer.from(head, "utf8"));
|
|
25
|
+
chunks.push(typeof part.value === "string" ? Buffer.from(part.value, "utf8") : Buffer.from(part.value));
|
|
26
|
+
chunks.push(Buffer.from("\r\n", "utf8"));
|
|
27
|
+
}
|
|
28
|
+
chunks.push(Buffer.from(`--${boundary}--\r\n`, "utf8"));
|
|
29
|
+
return {
|
|
30
|
+
body: new Uint8Array(Buffer.concat(chunks)),
|
|
31
|
+
contentType: `multipart/form-data; boundary=${boundary}`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function escapeName(value) {
|
|
35
|
+
return value.replace(/"/g, "%22").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=multipart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multipart.js","sourceRoot":"","sources":["../src/multipart.ts"],"names":[],"mappings":";;AAoBA,wCAkBC;AAtCD,mCAAqC;AAYrC;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,KAAsB;IACnD,MAAM,QAAQ,GAAG,wBAAwB,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IAC3E,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,GAAG,KAAK,QAAQ,6CAA6C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAC9F,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS;YAAE,IAAI,IAAI,eAAe,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QACrF,IAAI,IAAI,MAAM,CAAC;QACf,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,IAAI,iBAAiB,IAAI,CAAC,WAAW,MAAM,CAAC;QACtE,IAAI,IAAI,MAAM,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACxG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,QAAQ,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,OAAO;QACL,IAAI,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3C,WAAW,EAAE,iCAAiC,QAAQ,EAAE;KACzD,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAChF,CAAC"}
|
package/dist/push.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Push notification content (MiniApp API). The same shape is bundled as `push` on any message and sent
|
|
3
|
+
* on its own through `ChatClient.sendPush`; the recipient is the message's or request's `userId`.
|
|
4
|
+
*/
|
|
5
|
+
export interface PushContent {
|
|
6
|
+
/** Max 256 characters. */
|
|
7
|
+
title: string;
|
|
8
|
+
/** Max 1024 characters. */
|
|
9
|
+
body: string;
|
|
10
|
+
/** Custom payload forwarded to the devices as-is. */
|
|
11
|
+
data?: Record<string, unknown>;
|
|
12
|
+
priority?: "high" | "normal" | "low";
|
|
13
|
+
/** Deliver without alerting the user. */
|
|
14
|
+
silent?: boolean;
|
|
15
|
+
/** Seconds the provider keeps the push for an offline device. */
|
|
16
|
+
ttl?: number;
|
|
17
|
+
/** Pushes with the same key replace each other on the device. Max 128 characters. */
|
|
18
|
+
collapseKey?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Per-device outcome of a push. */
|
|
21
|
+
export interface PushDeviceResult {
|
|
22
|
+
deviceId?: string;
|
|
23
|
+
success: boolean;
|
|
24
|
+
error?: {
|
|
25
|
+
code: number;
|
|
26
|
+
subsystem: number;
|
|
27
|
+
message: string;
|
|
28
|
+
traceId?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Gateway acceptance of a push — returned by `sendPush`, and as `push` on a message that bundled one. */
|
|
32
|
+
export interface PushResponse {
|
|
33
|
+
status: "accepted" | "failed";
|
|
34
|
+
notificationId?: string;
|
|
35
|
+
devices: PushDeviceResult[];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=push.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../src/push.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACrC,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChF;AAED,0GAA0G;AAC1G,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B"}
|
package/dist/push.js
ADDED
package/dist/push.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../src/push.ts"],"names":[],"mappings":""}
|
package/dist/service-client.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { KobilError } from "./error";
|
|
2
|
+
import { MultipartPart } from "./multipart";
|
|
2
3
|
import { TokenProvider } from "./token-provider";
|
|
4
|
+
type RequestBody = string | FormData | Uint8Array;
|
|
3
5
|
/**
|
|
4
6
|
* Base class for typed KOBIL service clients. Attaches the shared bearer token,
|
|
5
7
|
* sends the request, and turns non-2xx/transport failures into an error (override
|
|
@@ -11,11 +13,22 @@ export declare abstract class KobilServiceClient {
|
|
|
11
13
|
/** Override to wrap failures in a module-specific error type. */
|
|
12
14
|
protected makeError(message: string, statusCode?: number, responseBody?: string, cause?: unknown): KobilError;
|
|
13
15
|
/** Sends a request with a JSON body (or none) and parses the JSON response. */
|
|
14
|
-
protected sendJson<T>(method: string, url: string, body?: unknown, signal?: AbortSignal): Promise<T>;
|
|
16
|
+
protected sendJson<T>(method: string, url: string, body?: unknown, signal?: AbortSignal, extraHeaders?: Record<string, string>): Promise<T>;
|
|
15
17
|
/** Sends a request with an arbitrary body (e.g. FormData) and parses the JSON response. */
|
|
16
|
-
protected send<T>(method: string, url: string, body:
|
|
18
|
+
protected send<T>(method: string, url: string, body: RequestBody, signal?: AbortSignal, extraHeaders?: Record<string, string>): Promise<T>;
|
|
19
|
+
/** Sends a hand-built `multipart/form-data` body (see {@link buildMultipart}) and parses the JSON response. */
|
|
20
|
+
protected sendMultipart<T>(method: string, url: string, parts: MultipartPart[], signal?: AbortSignal): Promise<T>;
|
|
17
21
|
/** Sends a request and returns the raw response bytes (e.g. a file download). */
|
|
18
22
|
protected sendForBytes(method: string, url: string, signal?: AbortSignal): Promise<Uint8Array>;
|
|
23
|
+
/**
|
|
24
|
+
* GETs a resource that answers with a redirect to a presigned URL, and returns the bytes behind it.
|
|
25
|
+
*
|
|
26
|
+
* The redirect is followed by hand so the bearer token is never sent to the presigned host: the
|
|
27
|
+
* MiniApp API says not to forward it, and storage services reject a request carrying two credentials.
|
|
28
|
+
* A server that answers 200 directly (no redirect) is accepted as well.
|
|
29
|
+
*/
|
|
30
|
+
protected downloadViaRedirect(url: string, signal?: AbortSignal): Promise<Uint8Array>;
|
|
19
31
|
private request;
|
|
20
32
|
}
|
|
33
|
+
export {};
|
|
21
34
|
//# sourceMappingURL=service-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-client.d.ts","sourceRoot":"","sources":["../src/service-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"service-client.d.ts","sourceRoot":"","sources":["../src/service-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,KAAK,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;AAElD;;;;GAIG;AACH,8BAAsB,kBAAkB;IAChB,SAAS,CAAC,QAAQ,CA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.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KobilServiceClient = void 0;
|
|
4
4
|
const error_1 = require("./error");
|
|
5
|
+
const multipart_1 = require("./multipart");
|
|
5
6
|
/**
|
|
6
7
|
* Base class for typed KOBIL service clients. Attaches the shared bearer token,
|
|
7
8
|
* sends the request, and turns non-2xx/transport failures into an error (override
|
|
@@ -17,8 +18,8 @@ class KobilServiceClient {
|
|
|
17
18
|
return new error_1.KobilError(message, { statusCode, responseBody, cause });
|
|
18
19
|
}
|
|
19
20
|
/** Sends a request with a JSON body (or none) and parses the JSON response. */
|
|
20
|
-
sendJson(method, url, body, signal) {
|
|
21
|
-
const headers = { accept: "application/json" };
|
|
21
|
+
sendJson(method, url, body, signal, extraHeaders = {}) {
|
|
22
|
+
const headers = { ...extraHeaders, accept: "application/json" };
|
|
22
23
|
let payload;
|
|
23
24
|
if (body !== undefined && body !== null) {
|
|
24
25
|
headers["content-type"] = "application/json";
|
|
@@ -27,8 +28,13 @@ class KobilServiceClient {
|
|
|
27
28
|
return this.request(method, url, headers, payload, signal);
|
|
28
29
|
}
|
|
29
30
|
/** Sends a request with an arbitrary body (e.g. FormData) and parses the JSON response. */
|
|
30
|
-
send(method, url, body, signal) {
|
|
31
|
-
return this.request(method, url, { accept: "application/json" }, body, signal);
|
|
31
|
+
send(method, url, body, signal, extraHeaders = {}) {
|
|
32
|
+
return this.request(method, url, { ...extraHeaders, accept: "application/json" }, body, signal);
|
|
33
|
+
}
|
|
34
|
+
/** Sends a hand-built `multipart/form-data` body (see {@link buildMultipart}) and parses the JSON response. */
|
|
35
|
+
sendMultipart(method, url, parts, signal) {
|
|
36
|
+
const { body, contentType } = (0, multipart_1.buildMultipart)(parts);
|
|
37
|
+
return this.send(method, url, body, signal, { "content-type": contentType });
|
|
32
38
|
}
|
|
33
39
|
/** Sends a request and returns the raw response bytes (e.g. a file download). */
|
|
34
40
|
async sendForBytes(method, url, signal) {
|
|
@@ -42,7 +48,42 @@ class KobilServiceClient {
|
|
|
42
48
|
}
|
|
43
49
|
if (!response.ok) {
|
|
44
50
|
const text = await response.text().catch(() => undefined);
|
|
45
|
-
throw this.makeError(
|
|
51
|
+
throw this.makeError(failureMessage(method, url, response.status, text), response.status, text);
|
|
52
|
+
}
|
|
53
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* GETs a resource that answers with a redirect to a presigned URL, and returns the bytes behind it.
|
|
57
|
+
*
|
|
58
|
+
* The redirect is followed by hand so the bearer token is never sent to the presigned host: the
|
|
59
|
+
* MiniApp API says not to forward it, and storage services reject a request carrying two credentials.
|
|
60
|
+
* A server that answers 200 directly (no redirect) is accepted as well.
|
|
61
|
+
*/
|
|
62
|
+
async downloadViaRedirect(url, signal) {
|
|
63
|
+
const token = await this.tokens.getToken(signal);
|
|
64
|
+
let response;
|
|
65
|
+
try {
|
|
66
|
+
response = await fetch(url, { method: "GET", headers: { authorization: `Bearer ${token}` }, redirect: "manual", signal });
|
|
67
|
+
}
|
|
68
|
+
catch (cause) {
|
|
69
|
+
throw this.makeError(`An error occurred while calling GET ${url}.`, undefined, undefined, cause);
|
|
70
|
+
}
|
|
71
|
+
if (response.status >= 300 && response.status < 400) {
|
|
72
|
+
const location = response.headers.get("location");
|
|
73
|
+
if (!location) {
|
|
74
|
+
throw this.makeError(`KOBIL API redirected GET ${url} without a Location header.`, response.status);
|
|
75
|
+
}
|
|
76
|
+
const target = new URL(location, url).toString();
|
|
77
|
+
try {
|
|
78
|
+
response = await fetch(target, { method: "GET", signal });
|
|
79
|
+
}
|
|
80
|
+
catch (cause) {
|
|
81
|
+
throw this.makeError(`An error occurred while downloading ${target}.`, undefined, undefined, cause);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
const text = await response.text().catch(() => undefined);
|
|
86
|
+
throw this.makeError(failureMessage("GET", url, response.status, text), response.status, text);
|
|
46
87
|
}
|
|
47
88
|
return new Uint8Array(await response.arrayBuffer());
|
|
48
89
|
}
|
|
@@ -62,7 +103,7 @@ class KobilServiceClient {
|
|
|
62
103
|
}
|
|
63
104
|
const text = await response.text();
|
|
64
105
|
if (!response.ok) {
|
|
65
|
-
throw this.makeError(
|
|
106
|
+
throw this.makeError(failureMessage(method, url, response.status, text), response.status, text);
|
|
66
107
|
}
|
|
67
108
|
if (!text) {
|
|
68
109
|
return {};
|
|
@@ -76,4 +117,10 @@ class KobilServiceClient {
|
|
|
76
117
|
}
|
|
77
118
|
}
|
|
78
119
|
exports.KobilServiceClient = KobilServiceClient;
|
|
120
|
+
/** The error message for a non-2xx response, carrying the MiniApp API's own message when there is one. */
|
|
121
|
+
function failureMessage(method, url, status, body) {
|
|
122
|
+
const envelope = (0, error_1.parseErrorEnvelope)(body);
|
|
123
|
+
const detail = envelope?.message ? `: ${envelope.message}` : "";
|
|
124
|
+
return `KOBIL API returned ${status} for ${method} ${url}${detail}.`;
|
|
125
|
+
}
|
|
79
126
|
//# sourceMappingURL=service-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-client.js","sourceRoot":"","sources":["../src/service-client.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"service-client.js","sourceRoot":"","sources":["../src/service-client.ts"],"names":[],"mappings":";;;AAAA,mCAAyD;AACzD,2CAA4D;AAK5D;;;;GAIG;AACH,MAAsB,kBAAkB;IACG;IAAzC,YAAyC,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAElE,iEAAiE;IACvD,SAAS,CAAC,OAAe,EAAE,UAAmB,EAAE,YAAqB,EAAE,KAAe;QAC9F,OAAO,IAAI,kBAAU,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,+EAA+E;IACrE,QAAQ,CAChB,MAAc,EACd,GAAW,EACX,IAAc,EACd,MAAoB,EACpB,eAAuC,EAAE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MAAM,GAAG,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,OAAO,sBAAsB,MAAM,QAAQ,MAAM,IAAI,GAAG,GAAG,MAAM,GAAG,CAAC;AACvE,CAAC"}
|
package/dist/token-provider.d.ts
CHANGED
|
@@ -3,6 +3,22 @@ import { KobilCredentials } from "./credentials";
|
|
|
3
3
|
export interface TokenProvider {
|
|
4
4
|
getToken(signal?: AbortSignal): Promise<string>;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Hands out a token obtained elsewhere — typically a signed-in user's access token from
|
|
8
|
+
* `AuthClient.exchangeCodeForToken`. The MiniApp API recommends a user token for calls that target that
|
|
9
|
+
* user (messages, payments, transactions); pass one per request:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* new ChatClient({ tokenProvider: new StaticTokenProvider(session.accessToken) })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* It never refreshes: an expired token fails with 401, and refreshing it is the caller's job.
|
|
16
|
+
*/
|
|
17
|
+
export declare class StaticTokenProvider implements TokenProvider {
|
|
18
|
+
private readonly token;
|
|
19
|
+
constructor(token: string);
|
|
20
|
+
getToken(): Promise<string>;
|
|
21
|
+
}
|
|
6
22
|
/**
|
|
7
23
|
* Acquires OAuth2 tokens via the `client_credentials` grant — using either the form
|
|
8
24
|
* body (`post`) or an HTTP Basic header (`basic`) — and caches them in memory until
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-provider.d.ts","sourceRoot":"","sources":["../src/token-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,kFAAkF;AAClF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACjD;AAOD;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IAI5C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAHxC,OAAO,CAAC,KAAK,CAAC,CAAc;IAC5B,OAAO,CAAC,QAAQ,CAAC,CAAkB;gBAEN,WAAW,EAAE,gBAAgB;IAEpD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;YAavC,OAAO;
|
|
1
|
+
{"version":3,"file":"token-provider.d.ts","sourceRoot":"","sources":["../src/token-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,kFAAkF;AAClF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACjD;AAED;;;;;;;;;;GAUG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IAC3C,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IAI1C,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAG5B;AAOD;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IAI5C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAHxC,OAAO,CAAC,KAAK,CAAC,CAAc;IAC5B,OAAO,CAAC,QAAQ,CAAC,CAAkB;gBAEN,WAAW,EAAE,gBAAgB;IAEpD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;YAavC,OAAO;CA4DtB"}
|
package/dist/token-provider.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultTokenProvider = void 0;
|
|
3
|
+
exports.DefaultTokenProvider = exports.StaticTokenProvider = void 0;
|
|
4
4
|
const error_1 = require("./error");
|
|
5
|
+
/**
|
|
6
|
+
* Hands out a token obtained elsewhere — typically a signed-in user's access token from
|
|
7
|
+
* `AuthClient.exchangeCodeForToken`. The MiniApp API recommends a user token for calls that target that
|
|
8
|
+
* user (messages, payments, transactions); pass one per request:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* new ChatClient({ tokenProvider: new StaticTokenProvider(session.accessToken) })
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* It never refreshes: an expired token fails with 401, and refreshing it is the caller's job.
|
|
15
|
+
*/
|
|
16
|
+
class StaticTokenProvider {
|
|
17
|
+
token;
|
|
18
|
+
constructor(token) {
|
|
19
|
+
this.token = token;
|
|
20
|
+
if (!token)
|
|
21
|
+
throw new error_1.KobilError("StaticTokenProvider needs a non-empty token.");
|
|
22
|
+
}
|
|
23
|
+
getToken() {
|
|
24
|
+
return Promise.resolve(this.token);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.StaticTokenProvider = StaticTokenProvider;
|
|
5
28
|
/**
|
|
6
29
|
* Acquires OAuth2 tokens via the `client_credentials` grant — using either the form
|
|
7
30
|
* body (`post`) or an HTTP Basic header (`basic`) — and caches them in memory until
|
|
@@ -28,12 +51,14 @@ class DefaultTokenProvider {
|
|
|
28
51
|
}
|
|
29
52
|
async request(signal) {
|
|
30
53
|
const c = this.credentials;
|
|
54
|
+
// Named after the environment variables, because the environment is how this is configured in
|
|
55
|
+
// practice. In miniapp mode the endpoint needs a realm, which OIDC_ISSUER also supplies.
|
|
31
56
|
if (!c.tokenEndpoint)
|
|
32
|
-
throw new error_1.KobilError("
|
|
57
|
+
throw new error_1.KobilError("No token endpoint: set OIDC_ISSUER (or pass tokenEndpoint, or realm in miniapp mode).");
|
|
33
58
|
if (!c.clientId)
|
|
34
|
-
throw new error_1.KobilError("
|
|
59
|
+
throw new error_1.KobilError("No client id: set OIDC_CLIENT_ID (PAYMENT_MERCHANT_ID for legacy payment), or pass clientId.");
|
|
35
60
|
if (!c.clientSecret)
|
|
36
|
-
throw new error_1.KobilError("
|
|
61
|
+
throw new error_1.KobilError("No client secret: set OIDC_CLIENT_SECRET (PAYMENT_MERCHANT_SECRET for legacy payment), or pass clientSecret.");
|
|
37
62
|
const body = new URLSearchParams({ grant_type: "client_credentials" });
|
|
38
63
|
const headers = {
|
|
39
64
|
"content-type": "application/x-www-form-urlencoded",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-provider.js","sourceRoot":"","sources":["../src/token-provider.ts"],"names":[],"mappings":";;;AACA,mCAAqC;
|
|
1
|
+
{"version":3,"file":"token-provider.js","sourceRoot":"","sources":["../src/token-provider.ts"],"names":[],"mappings":";;;AACA,mCAAqC;AAOrC;;;;;;;;;;GAUG;AACH,MAAa,mBAAmB;IACD;IAA7B,YAA6B,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QACxC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,kBAAU,CAAC,8CAA8C,CAAC,CAAC;IACnF,CAAC;IAED,QAAQ;QACN,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACF;AARD,kDAQC;AAOD;;;;GAIG;AACH,MAAa,oBAAoB;IAIF;IAHrB,KAAK,CAAe;IACpB,QAAQ,CAAmB;IAEnC,YAA6B,WAA6B;QAA7B,gBAAW,GAAX,WAAW,CAAkB;IAAG,CAAC;IAE9D,KAAK,CAAC,QAAQ,CAAC,MAAoB;QACjC,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QAC1B,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC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I,EAAE,CAAC;QAC/E,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA/ED,oDA+EC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uveysservetoglu/kobil-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Shared foundation for the KOBIL SDK family: OAuth token acquisition/caching (post & basic), a common error type, and an HTTP base for typed clients.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|