@kard-financial/sdk 0.1.4 → 0.2.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.
Files changed (36) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/api/resources/users/client/Client.d.ts +3 -0
  3. package/dist/cjs/api/resources/users/client/Client.js +9 -4
  4. package/dist/cjs/api/resources/users/resources/auth/client/Client.d.ts +29 -0
  5. package/dist/cjs/api/resources/users/resources/auth/client/Client.js +129 -0
  6. package/dist/cjs/api/resources/users/resources/auth/client/index.d.ts +1 -0
  7. package/dist/cjs/api/resources/users/resources/auth/client/index.js +2 -0
  8. package/dist/cjs/api/resources/users/resources/auth/index.d.ts +2 -0
  9. package/dist/cjs/api/resources/users/resources/auth/index.js +18 -0
  10. package/dist/cjs/api/resources/users/resources/auth/types/WebviewTokenResponse.d.ts +15 -0
  11. package/dist/cjs/api/resources/users/resources/auth/types/WebviewTokenResponse.js +3 -0
  12. package/dist/cjs/api/resources/users/resources/auth/types/index.d.ts +1 -0
  13. package/dist/cjs/api/resources/users/resources/auth/types/index.js +17 -0
  14. package/dist/cjs/api/resources/users/resources/index.d.ts +2 -0
  15. package/dist/cjs/api/resources/users/resources/index.js +3 -1
  16. package/dist/cjs/version.d.ts +1 -1
  17. package/dist/cjs/version.js +1 -1
  18. package/dist/esm/BaseClient.mjs +2 -2
  19. package/dist/esm/api/resources/users/client/Client.d.mts +3 -0
  20. package/dist/esm/api/resources/users/client/Client.mjs +5 -0
  21. package/dist/esm/api/resources/users/resources/auth/client/Client.d.mts +29 -0
  22. package/dist/esm/api/resources/users/resources/auth/client/Client.mjs +92 -0
  23. package/dist/esm/api/resources/users/resources/auth/client/index.d.mts +1 -0
  24. package/dist/esm/api/resources/users/resources/auth/client/index.mjs +1 -0
  25. package/dist/esm/api/resources/users/resources/auth/index.d.mts +2 -0
  26. package/dist/esm/api/resources/users/resources/auth/index.mjs +2 -0
  27. package/dist/esm/api/resources/users/resources/auth/types/WebviewTokenResponse.d.mts +15 -0
  28. package/dist/esm/api/resources/users/resources/auth/types/WebviewTokenResponse.mjs +2 -0
  29. package/dist/esm/api/resources/users/resources/auth/types/index.d.mts +1 -0
  30. package/dist/esm/api/resources/users/resources/auth/types/index.mjs +1 -0
  31. package/dist/esm/api/resources/users/resources/index.d.mts +2 -0
  32. package/dist/esm/api/resources/users/resources/index.mjs +2 -0
  33. package/dist/esm/version.d.mts +1 -1
  34. package/dist/esm/version.mjs +1 -1
  35. package/package.json +1 -1
  36. package/reference.md +72 -0
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "@kard-financial/sdk",
46
- "X-Fern-SDK-Version": "0.1.4",
47
- "User-Agent": "@kard-financial/sdk/0.1.4",
46
+ "X-Fern-SDK-Version": "0.2.0",
47
+ "User-Agent": "@kard-financial/sdk/0.2.0",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -3,6 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"
3
3
  import * as core from "../../../../core/index.js";
4
4
  import * as KardApi from "../../../index.js";
5
5
  import { AttributionsClient } from "../resources/attributions/client/Client.js";
6
+ import { AuthClient } from "../resources/auth/client/Client.js";
6
7
  import { RewardsClient } from "../resources/rewards/client/Client.js";
7
8
  import { UploadsClient } from "../resources/uploads/client/Client.js";
8
9
  export declare namespace UsersClient {
@@ -14,10 +15,12 @@ export declare namespace UsersClient {
14
15
  export declare class UsersClient {
15
16
  protected readonly _options: NormalizedClientOptionsWithAuth<UsersClient.Options>;
16
17
  protected _attributions: AttributionsClient | undefined;
18
+ protected _auth: AuthClient | undefined;
17
19
  protected _rewards: RewardsClient | undefined;
18
20
  protected _uploads: UploadsClient | undefined;
19
21
  constructor(options?: UsersClient.Options);
20
22
  get attributions(): AttributionsClient;
23
+ get auth(): AuthClient;
21
24
  get rewards(): RewardsClient;
22
25
  get uploads(): UploadsClient;
23
26
  /**
@@ -51,8 +51,9 @@ const environments = __importStar(require("../../../../environments.js"));
51
51
  const errors = __importStar(require("../../../../errors/index.js"));
52
52
  const KardApi = __importStar(require("../../../index.js"));
53
53
  const Client_js_1 = require("../resources/attributions/client/Client.js");
54
- const Client_js_2 = require("../resources/rewards/client/Client.js");
55
- const Client_js_3 = require("../resources/uploads/client/Client.js");
54
+ const Client_js_2 = require("../resources/auth/client/Client.js");
55
+ const Client_js_3 = require("../resources/rewards/client/Client.js");
56
+ const Client_js_4 = require("../resources/uploads/client/Client.js");
56
57
  class UsersClient {
57
58
  constructor(options = {}) {
58
59
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
@@ -61,13 +62,17 @@ class UsersClient {
61
62
  var _a;
62
63
  return ((_a = this._attributions) !== null && _a !== void 0 ? _a : (this._attributions = new Client_js_1.AttributionsClient(this._options)));
63
64
  }
65
+ get auth() {
66
+ var _a;
67
+ return ((_a = this._auth) !== null && _a !== void 0 ? _a : (this._auth = new Client_js_2.AuthClient(this._options)));
68
+ }
64
69
  get rewards() {
65
70
  var _a;
66
- return ((_a = this._rewards) !== null && _a !== void 0 ? _a : (this._rewards = new Client_js_2.RewardsClient(this._options)));
71
+ return ((_a = this._rewards) !== null && _a !== void 0 ? _a : (this._rewards = new Client_js_3.RewardsClient(this._options)));
67
72
  }
68
73
  get uploads() {
69
74
  var _a;
70
- return ((_a = this._uploads) !== null && _a !== void 0 ? _a : (this._uploads = new Client_js_3.UploadsClient(this._options)));
75
+ return ((_a = this._uploads) !== null && _a !== void 0 ? _a : (this._uploads = new Client_js_4.UploadsClient(this._options)));
71
76
  }
72
77
  /**
73
78
  * Call this endpoint to enroll a specified user into your rewards program.<br/>
@@ -0,0 +1,29 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js";
3
+ import * as core from "../../../../../../core/index.js";
4
+ import * as KardApi from "../../../../../index.js";
5
+ export declare namespace AuthClient {
6
+ interface Options extends BaseClientOptions {
7
+ }
8
+ interface RequestOptions extends BaseRequestOptions {
9
+ }
10
+ }
11
+ export declare class AuthClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<AuthClient.Options>;
13
+ constructor(options?: AuthClient.Options);
14
+ /**
15
+ * Retrieves an OAuth token for webview authentication.
16
+ *
17
+ * @param {KardApi.OrganizationId} organizationId
18
+ * @param {KardApi.UserId} userId
19
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
20
+ *
21
+ * @throws {@link KardApi.InternalServerError}
22
+ * @throws {@link KardApi.UnauthorizedError}
23
+ *
24
+ * @example
25
+ * await client.users.auth.getWebviewToken("organization-123", "user-123")
26
+ */
27
+ getWebviewToken(organizationId: KardApi.OrganizationId, userId: KardApi.UserId, requestOptions?: AuthClient.RequestOptions): core.HttpResponsePromise<KardApi.users.WebviewTokenResponse>;
28
+ private __getWebviewToken;
29
+ }
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.AuthClient = void 0;
47
+ const BaseClient_js_1 = require("../../../../../../BaseClient.js");
48
+ const headers_js_1 = require("../../../../../../core/headers.js");
49
+ const core = __importStar(require("../../../../../../core/index.js"));
50
+ const environments = __importStar(require("../../../../../../environments.js"));
51
+ const errors = __importStar(require("../../../../../../errors/index.js"));
52
+ const KardApi = __importStar(require("../../../../../index.js"));
53
+ class AuthClient {
54
+ constructor(options = {}) {
55
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
56
+ }
57
+ /**
58
+ * Retrieves an OAuth token for webview authentication.
59
+ *
60
+ * @param {KardApi.OrganizationId} organizationId
61
+ * @param {KardApi.UserId} userId
62
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
63
+ *
64
+ * @throws {@link KardApi.InternalServerError}
65
+ * @throws {@link KardApi.UnauthorizedError}
66
+ *
67
+ * @example
68
+ * await client.users.auth.getWebviewToken("organization-123", "user-123")
69
+ */
70
+ getWebviewToken(organizationId, userId, requestOptions) {
71
+ return core.HttpResponsePromise.fromPromise(this.__getWebviewToken(organizationId, userId, requestOptions));
72
+ }
73
+ __getWebviewToken(organizationId, userId, requestOptions) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
76
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
77
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
78
+ const _response = yield core.fetcher({
79
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.KardApiEnvironment.Production, `/v2/auth/issuers/${core.url.encodePathParam(organizationId)}/users/${core.url.encodePathParam(userId)}/token`),
80
+ method: "POST",
81
+ headers: _headers,
82
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
83
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
84
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
85
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
86
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
87
+ logging: this._options.logging,
88
+ });
89
+ if (_response.ok) {
90
+ return { data: _response.body, rawResponse: _response.rawResponse };
91
+ }
92
+ if (_response.error.reason === "status-code") {
93
+ switch (_response.error.statusCode) {
94
+ case 500:
95
+ throw new KardApi.InternalServerError(_response.error.body, _response.rawResponse);
96
+ case 401:
97
+ throw new KardApi.UnauthorizedError(_response.error.body, _response.rawResponse);
98
+ default:
99
+ throw new errors.KardApiError({
100
+ statusCode: _response.error.statusCode,
101
+ body: _response.error.body,
102
+ rawResponse: _response.rawResponse,
103
+ });
104
+ }
105
+ }
106
+ switch (_response.error.reason) {
107
+ case "non-json":
108
+ throw new errors.KardApiError({
109
+ statusCode: _response.error.statusCode,
110
+ body: _response.error.rawBody,
111
+ rawResponse: _response.rawResponse,
112
+ });
113
+ case "body-is-null":
114
+ throw new errors.KardApiError({
115
+ statusCode: _response.error.statusCode,
116
+ rawResponse: _response.rawResponse,
117
+ });
118
+ case "timeout":
119
+ throw new errors.KardApiTimeoutError("Timeout exceeded when calling POST /v2/auth/issuers/{organizationId}/users/{userId}/token.");
120
+ case "unknown":
121
+ throw new errors.KardApiError({
122
+ message: _response.error.errorMessage,
123
+ rawResponse: _response.rawResponse,
124
+ });
125
+ }
126
+ });
127
+ }
128
+ }
129
+ exports.AuthClient = AuthClient;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.js";
2
+ export * from "./types/index.js";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client/index.js"), exports);
18
+ __exportStar(require("./types/index.js"), exports);
@@ -0,0 +1,15 @@
1
+ /**
2
+ * An OAuth token response.
3
+ *
4
+ * @example
5
+ * {
6
+ * access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
7
+ * expires_in: 3600,
8
+ * token_type: "Bearer"
9
+ * }
10
+ */
11
+ export interface WebviewTokenResponse {
12
+ access_token: string;
13
+ expires_in: number;
14
+ token_type: string;
15
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./WebviewTokenResponse.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./WebviewTokenResponse.js"), exports);
@@ -1,5 +1,7 @@
1
1
  export * as attributions from "./attributions/index.js";
2
2
  export * from "./attributions/types/index.js";
3
+ export * as auth from "./auth/index.js";
4
+ export * from "./auth/types/index.js";
3
5
  export * from "./rewards/client/requests/index.js";
4
6
  export * as rewards from "./rewards/index.js";
5
7
  export * from "./rewards/types/index.js";
@@ -36,9 +36,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.uploads = exports.rewards = exports.attributions = void 0;
39
+ exports.uploads = exports.rewards = exports.auth = exports.attributions = void 0;
40
40
  exports.attributions = __importStar(require("./attributions/index.js"));
41
41
  __exportStar(require("./attributions/types/index.js"), exports);
42
+ exports.auth = __importStar(require("./auth/index.js"));
43
+ __exportStar(require("./auth/types/index.js"), exports);
42
44
  __exportStar(require("./rewards/client/requests/index.js"), exports);
43
45
  exports.rewards = __importStar(require("./rewards/index.js"));
44
46
  __exportStar(require("./rewards/types/index.js"), exports);
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.1.4";
1
+ export declare const SDK_VERSION = "0.2.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.1.4";
4
+ exports.SDK_VERSION = "0.2.0";
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
6
6
  const headers = mergeHeaders({
7
7
  "X-Fern-Language": "JavaScript",
8
8
  "X-Fern-SDK-Name": "@kard-financial/sdk",
9
- "X-Fern-SDK-Version": "0.1.4",
10
- "User-Agent": "@kard-financial/sdk/0.1.4",
9
+ "X-Fern-SDK-Version": "0.2.0",
10
+ "User-Agent": "@kard-financial/sdk/0.2.0",
11
11
  "X-Fern-Runtime": core.RUNTIME.type,
12
12
  "X-Fern-Runtime-Version": core.RUNTIME.version,
13
13
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -3,6 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs
3
3
  import * as core from "../../../../core/index.mjs";
4
4
  import * as KardApi from "../../../index.mjs";
5
5
  import { AttributionsClient } from "../resources/attributions/client/Client.mjs";
6
+ import { AuthClient } from "../resources/auth/client/Client.mjs";
6
7
  import { RewardsClient } from "../resources/rewards/client/Client.mjs";
7
8
  import { UploadsClient } from "../resources/uploads/client/Client.mjs";
8
9
  export declare namespace UsersClient {
@@ -14,10 +15,12 @@ export declare namespace UsersClient {
14
15
  export declare class UsersClient {
15
16
  protected readonly _options: NormalizedClientOptionsWithAuth<UsersClient.Options>;
16
17
  protected _attributions: AttributionsClient | undefined;
18
+ protected _auth: AuthClient | undefined;
17
19
  protected _rewards: RewardsClient | undefined;
18
20
  protected _uploads: UploadsClient | undefined;
19
21
  constructor(options?: UsersClient.Options);
20
22
  get attributions(): AttributionsClient;
23
+ get auth(): AuthClient;
21
24
  get rewards(): RewardsClient;
22
25
  get uploads(): UploadsClient;
23
26
  /**
@@ -15,6 +15,7 @@ import * as environments from "../../../../environments.mjs";
15
15
  import * as errors from "../../../../errors/index.mjs";
16
16
  import * as KardApi from "../../../index.mjs";
17
17
  import { AttributionsClient } from "../resources/attributions/client/Client.mjs";
18
+ import { AuthClient } from "../resources/auth/client/Client.mjs";
18
19
  import { RewardsClient } from "../resources/rewards/client/Client.mjs";
19
20
  import { UploadsClient } from "../resources/uploads/client/Client.mjs";
20
21
  export class UsersClient {
@@ -25,6 +26,10 @@ export class UsersClient {
25
26
  var _a;
26
27
  return ((_a = this._attributions) !== null && _a !== void 0 ? _a : (this._attributions = new AttributionsClient(this._options)));
27
28
  }
29
+ get auth() {
30
+ var _a;
31
+ return ((_a = this._auth) !== null && _a !== void 0 ? _a : (this._auth = new AuthClient(this._options)));
32
+ }
28
33
  get rewards() {
29
34
  var _a;
30
35
  return ((_a = this._rewards) !== null && _a !== void 0 ? _a : (this._rewards = new RewardsClient(this._options)));
@@ -0,0 +1,29 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.mjs";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.mjs";
3
+ import * as core from "../../../../../../core/index.mjs";
4
+ import * as KardApi from "../../../../../index.mjs";
5
+ export declare namespace AuthClient {
6
+ interface Options extends BaseClientOptions {
7
+ }
8
+ interface RequestOptions extends BaseRequestOptions {
9
+ }
10
+ }
11
+ export declare class AuthClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<AuthClient.Options>;
13
+ constructor(options?: AuthClient.Options);
14
+ /**
15
+ * Retrieves an OAuth token for webview authentication.
16
+ *
17
+ * @param {KardApi.OrganizationId} organizationId
18
+ * @param {KardApi.UserId} userId
19
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
20
+ *
21
+ * @throws {@link KardApi.InternalServerError}
22
+ * @throws {@link KardApi.UnauthorizedError}
23
+ *
24
+ * @example
25
+ * await client.users.auth.getWebviewToken("organization-123", "user-123")
26
+ */
27
+ getWebviewToken(organizationId: KardApi.OrganizationId, userId: KardApi.UserId, requestOptions?: AuthClient.RequestOptions): core.HttpResponsePromise<KardApi.users.WebviewTokenResponse>;
28
+ private __getWebviewToken;
29
+ }
@@ -0,0 +1,92 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import { normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.mjs";
12
+ import { mergeHeaders } from "../../../../../../core/headers.mjs";
13
+ import * as core from "../../../../../../core/index.mjs";
14
+ import * as environments from "../../../../../../environments.mjs";
15
+ import * as errors from "../../../../../../errors/index.mjs";
16
+ import * as KardApi from "../../../../../index.mjs";
17
+ export class AuthClient {
18
+ constructor(options = {}) {
19
+ this._options = normalizeClientOptionsWithAuth(options);
20
+ }
21
+ /**
22
+ * Retrieves an OAuth token for webview authentication.
23
+ *
24
+ * @param {KardApi.OrganizationId} organizationId
25
+ * @param {KardApi.UserId} userId
26
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
27
+ *
28
+ * @throws {@link KardApi.InternalServerError}
29
+ * @throws {@link KardApi.UnauthorizedError}
30
+ *
31
+ * @example
32
+ * await client.users.auth.getWebviewToken("organization-123", "user-123")
33
+ */
34
+ getWebviewToken(organizationId, userId, requestOptions) {
35
+ return core.HttpResponsePromise.fromPromise(this.__getWebviewToken(organizationId, userId, requestOptions));
36
+ }
37
+ __getWebviewToken(organizationId, userId, requestOptions) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
40
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
41
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
42
+ const _response = yield core.fetcher({
43
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.KardApiEnvironment.Production, `/v2/auth/issuers/${core.url.encodePathParam(organizationId)}/users/${core.url.encodePathParam(userId)}/token`),
44
+ method: "POST",
45
+ headers: _headers,
46
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
47
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
48
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
49
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
50
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
51
+ logging: this._options.logging,
52
+ });
53
+ if (_response.ok) {
54
+ return { data: _response.body, rawResponse: _response.rawResponse };
55
+ }
56
+ if (_response.error.reason === "status-code") {
57
+ switch (_response.error.statusCode) {
58
+ case 500:
59
+ throw new KardApi.InternalServerError(_response.error.body, _response.rawResponse);
60
+ case 401:
61
+ throw new KardApi.UnauthorizedError(_response.error.body, _response.rawResponse);
62
+ default:
63
+ throw new errors.KardApiError({
64
+ statusCode: _response.error.statusCode,
65
+ body: _response.error.body,
66
+ rawResponse: _response.rawResponse,
67
+ });
68
+ }
69
+ }
70
+ switch (_response.error.reason) {
71
+ case "non-json":
72
+ throw new errors.KardApiError({
73
+ statusCode: _response.error.statusCode,
74
+ body: _response.error.rawBody,
75
+ rawResponse: _response.rawResponse,
76
+ });
77
+ case "body-is-null":
78
+ throw new errors.KardApiError({
79
+ statusCode: _response.error.statusCode,
80
+ rawResponse: _response.rawResponse,
81
+ });
82
+ case "timeout":
83
+ throw new errors.KardApiTimeoutError("Timeout exceeded when calling POST /v2/auth/issuers/{organizationId}/users/{userId}/token.");
84
+ case "unknown":
85
+ throw new errors.KardApiError({
86
+ message: _response.error.errorMessage,
87
+ rawResponse: _response.rawResponse,
88
+ });
89
+ }
90
+ });
91
+ }
92
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.mjs";
2
+ export * from "./types/index.mjs";
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.mjs";
2
+ export * from "./types/index.mjs";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * An OAuth token response.
3
+ *
4
+ * @example
5
+ * {
6
+ * access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
7
+ * expires_in: 3600,
8
+ * token_type: "Bearer"
9
+ * }
10
+ */
11
+ export interface WebviewTokenResponse {
12
+ access_token: string;
13
+ expires_in: number;
14
+ token_type: string;
15
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./WebviewTokenResponse.mjs";
@@ -0,0 +1 @@
1
+ export * from "./WebviewTokenResponse.mjs";
@@ -1,5 +1,7 @@
1
1
  export * as attributions from "./attributions/index.mjs";
2
2
  export * from "./attributions/types/index.mjs";
3
+ export * as auth from "./auth/index.mjs";
4
+ export * from "./auth/types/index.mjs";
3
5
  export * from "./rewards/client/requests/index.mjs";
4
6
  export * as rewards from "./rewards/index.mjs";
5
7
  export * from "./rewards/types/index.mjs";
@@ -1,5 +1,7 @@
1
1
  export * as attributions from "./attributions/index.mjs";
2
2
  export * from "./attributions/types/index.mjs";
3
+ export * as auth from "./auth/index.mjs";
4
+ export * from "./auth/types/index.mjs";
3
5
  export * from "./rewards/client/requests/index.mjs";
4
6
  export * as rewards from "./rewards/index.mjs";
5
7
  export * from "./rewards/types/index.mjs";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.1.4";
1
+ export declare const SDK_VERSION = "0.2.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.1.4";
1
+ export const SDK_VERSION = "0.2.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kard-financial/sdk",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "repository": "github:KardFinancial/kard-node-sdk",
6
6
  "type": "commonjs",
package/reference.md CHANGED
@@ -1236,6 +1236,78 @@ await client.users.attributions.create("organization-123", "user-123", {
1236
1236
  </dl>
1237
1237
 
1238
1238
 
1239
+ </dd>
1240
+ </dl>
1241
+ </details>
1242
+
1243
+ ## Webview Authentication
1244
+ <details><summary><code>client.users.auth.<a href="/src/api/resources/users/resources/auth/client/Client.ts">getWebviewToken</a>(organizationId, userId) -> KardApi.WebviewTokenResponse</code></summary>
1245
+ <dl>
1246
+ <dd>
1247
+
1248
+ #### 📝 Description
1249
+
1250
+ <dl>
1251
+ <dd>
1252
+
1253
+ <dl>
1254
+ <dd>
1255
+
1256
+ Retrieves an OAuth token for webview authentication.
1257
+ </dd>
1258
+ </dl>
1259
+ </dd>
1260
+ </dl>
1261
+
1262
+ #### 🔌 Usage
1263
+
1264
+ <dl>
1265
+ <dd>
1266
+
1267
+ <dl>
1268
+ <dd>
1269
+
1270
+ ```typescript
1271
+ await client.users.auth.getWebviewToken("organization-123", "user-123");
1272
+
1273
+ ```
1274
+ </dd>
1275
+ </dl>
1276
+ </dd>
1277
+ </dl>
1278
+
1279
+ #### ⚙️ Parameters
1280
+
1281
+ <dl>
1282
+ <dd>
1283
+
1284
+ <dl>
1285
+ <dd>
1286
+
1287
+ **organizationId:** `KardApi.OrganizationId`
1288
+
1289
+ </dd>
1290
+ </dl>
1291
+
1292
+ <dl>
1293
+ <dd>
1294
+
1295
+ **userId:** `KardApi.UserId`
1296
+
1297
+ </dd>
1298
+ </dl>
1299
+
1300
+ <dl>
1301
+ <dd>
1302
+
1303
+ **requestOptions:** `AuthClient.RequestOptions`
1304
+
1305
+ </dd>
1306
+ </dl>
1307
+ </dd>
1308
+ </dl>
1309
+
1310
+
1239
1311
  </dd>
1240
1312
  </dl>
1241
1313
  </details>