@narrative.io/data-collaboration-sdk-ts 2.98.0 → 2.99.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.
@@ -1,5 +1,5 @@
1
1
  import { BaseApi } from "../base-api";
2
- import type { ApiToken, LoggedInUser, LoginRequest, LoginResponse, RegisterRequest, RegisterResponse, RegistrationStatus, RegistrationStatusB2bRequest, RegistrationStatusRequest, RegistrationStatusResponse, StytchToken, UserRole } from "./types";
2
+ import type { ApiToken, ExchangeTokenRequest, LoggedInUser, LoginRequest, LoginResponse, RegisterRequest, RegisterResponse, RegistrationStatus, RegistrationStatusB2bRequest, RegistrationStatusRequest, RegistrationStatusResponse, StytchToken, UserRole } from "./types";
3
3
  /**
4
4
  * A class for accessing the Authentication API
5
5
  * @extends BaseApi
@@ -59,5 +59,13 @@ declare class AuthenticationApi extends BaseApi {
59
59
  * @returns {Promise<RegistrationStatusResponse>} - A promise that resolves to the response.
60
60
  */
61
61
  checkRegistrationStatusB2b(statusRequest: RegistrationStatusB2bRequest): Promise<RegistrationStatusResponse>;
62
+ /**
63
+ * Exchange the current user access token for a new token scoped to a different company.
64
+ * The user can only exchange their token to be scoped to another company to which they belong, unless they are a global admin.
65
+ *
66
+ * @param {ExchangeTokenRequest} exchangeTokenRequest - The exchange token request containing the target company ID.
67
+ * @returns {Promise<LoginResponse>} - A promise that resolves to the login response with the new token.
68
+ */
69
+ exchangeToken(exchangeTokenRequest: ExchangeTokenRequest): Promise<LoginResponse>;
62
70
  }
63
- export { type ApiToken, AuthenticationApi, type LoggedInUser, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type RegistrationStatus, type RegistrationStatusB2bRequest, type RegistrationStatusRequest, type RegistrationStatusResponse, type StytchToken, type UserRole, };
71
+ export { type ApiToken, AuthenticationApi, type ExchangeTokenRequest, type LoggedInUser, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type RegistrationStatus, type RegistrationStatusB2bRequest, type RegistrationStatusRequest, type RegistrationStatusResponse, type StytchToken, type UserRole, };
@@ -77,5 +77,15 @@ class AuthenticationApi extends BaseApi {
77
77
  async checkRegistrationStatusB2b(statusRequest) {
78
78
  return await this.post(`${resourceName}/b2b/registration-status`, statusRequest);
79
79
  }
80
+ /**
81
+ * Exchange the current user access token for a new token scoped to a different company.
82
+ * The user can only exchange their token to be scoped to another company to which they belong, unless they are a global admin.
83
+ *
84
+ * @param {ExchangeTokenRequest} exchangeTokenRequest - The exchange token request containing the target company ID.
85
+ * @returns {Promise<LoginResponse>} - A promise that resolves to the login response with the new token.
86
+ */
87
+ async exchangeToken(exchangeTokenRequest) {
88
+ return await this.post(`${resourceName}/exchange-token`, exchangeTokenRequest);
89
+ }
80
90
  }
81
91
  export { AuthenticationApi, };
@@ -55,3 +55,6 @@ export interface RegistrationStatusResponse {
55
55
  stytch_session_jwt: string;
56
56
  }
57
57
  export type RegistrationStatus = "complete" | "pending";
58
+ export interface ExchangeTokenRequest {
59
+ company_id: number;
60
+ }
@@ -5,6 +5,7 @@ export interface User {
5
5
  email: string;
6
6
  role: UserRole;
7
7
  company_access_list: number[];
8
+ accessible_companies?: CompanyScope[];
8
9
  current_company_scope: CompanyScope;
9
10
  permissions: Permission[];
10
11
  created_at: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "2.98.0",
3
+ "version": "2.99.0",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",
@@ -28,7 +28,7 @@
28
28
  "@babel/core": "7.29.0",
29
29
  "@babel/preset-env": "7.29.2",
30
30
  "@babel/preset-typescript": "7.28.5",
31
- "@biomejs/biome": "2.4.10",
31
+ "@biomejs/biome": "2.4.11",
32
32
  "@commitlint/cli": "20.5.0",
33
33
  "@commitlint/config-conventional": "20.5.0",
34
34
  "@types/jest": "30.0.0",