Skip to content

Commit

Permalink
B2B Recovery codes SDK bump
Browse files Browse the repository at this point in the history
  • Loading branch information
taronish-stytch committed Jan 10, 2024
1 parent 2eca9e3 commit 9a1044c
Show file tree
Hide file tree
Showing 12 changed files with 296 additions and 39 deletions.
2 changes: 2 additions & 0 deletions dist/b2b/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions dist/b2b/recovery_codes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/b2b/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { OTPs } from "./otp";
import { Passwords } from "./passwords";
import { PolicyCache } from "./rbac_local";
import { RBAC } from "./rbac";
import { RecoveryCodes } from "./recovery_codes";
import { Sessions } from "./sessions";
import { SSO } from "./sso";
import { TOTPs } from "./totps";
Expand All @@ -24,6 +25,7 @@ export class B2BClient extends BaseClient {
organizations: Organizations;
passwords: Passwords;
rbac: RBAC;
recoveryCodes: RecoveryCodes;
sso: SSO;
sessions: Sessions;
totps: TOTPs;
Expand Down Expand Up @@ -53,6 +55,7 @@ export class B2BClient extends BaseClient {
this.organizations = new Organizations(this.fetchConfig);
this.passwords = new Passwords(this.fetchConfig);
this.rbac = new RBAC(this.fetchConfig);
this.recoveryCodes = new RecoveryCodes(this.fetchConfig);
this.sso = new SSO(this.fetchConfig);
this.sessions = new Sessions(this.fetchConfig, this.jwtConfig, policyCache);
this.totps = new TOTPs(this.fetchConfig);
Expand Down
18 changes: 0 additions & 18 deletions lib/b2b/discovery_organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,6 @@ export interface B2BDiscoveryOrganizationsCreateRequest {
* for more information about role assignment.
*/
rbac_email_implicit_role_assignments?: EmailImplicitRoleAssignment[];
/**
* The setting that controls which mfa methods can be used by Members of an Organization. The accepted
* values are:
*
* `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
*
* `RESTRICTED` – only methods that comply with `allowed_auth_methods` can be used for authentication.
* This setting does not apply to Members with `is_breakglass` set to `true`.
*
*/
mfa_methods?: string;
/**
* An array of allowed mfa authentication methods. This list is enforced when `mfa_methods` is set to
* `RESTRICTED`.
* The list's accepted values are: `sms_otp` and `totp`.
*
*/
allowed_mfa_methods?: string[];
}

// Response type for `discovery.organizations.create`.
Expand Down
9 changes: 9 additions & 0 deletions lib/b2b/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ export type {
B2BSessionsRevokeResponse,
} from "./sessions";

export type {
B2BRecoveryCodesGetRequest,
B2BRecoveryCodesGetResponse,
B2BRecoveryCodesRecoverRequest,
B2BRecoveryCodesRecoverResponse,
B2BRecoveryCodesRotateRequest,
B2BRecoveryCodesRotateResponse,
} from "./recovery_codes";

export type {
B2BTOTPsAuthenticateRequest,
B2BTOTPsAuthenticateResponse,
Expand Down
127 changes: 127 additions & 0 deletions lib/b2b/recovery_codes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!

import {} from "../shared/method_options";
import { fetchConfig } from "../shared";
import { Member, Organization } from "./organizations";
import { MemberSession } from "./sessions";
import { request } from "../shared";

export interface B2BRecoveryCodesGetRequest {
organization_id: string;
member_id: string;
}

export interface B2BRecoveryCodesGetResponse {
request_id: string;
member_id: string;
member: Member;
organization: Organization;
recovery_codes: string[];
status_code: number;
}

export interface B2BRecoveryCodesRecoverRequest {
organization_id: string;
member_id: string;
recovery_code: string;
intermediate_session_token?: string;
session_token?: string;
session_jwt?: string;
session_duration_minutes?: number;
session_custom_claims?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any
}

export interface B2BRecoveryCodesRecoverResponse {
request_id: string;
member_id: string;
member: Member;
organization: Organization;
session_token: string;
session_jwt: string;
recovery_codes_remaining: number;
status_code: number;
member_session?: MemberSession;
}

export interface B2BRecoveryCodesRotateRequest {
organization_id: string;
member_id: string;
}

export interface B2BRecoveryCodesRotateResponse {
request_id: string;
member_id: string;
member: Member;
organization: Organization;
recovery_codes: string[];
status_code: number;
}

export class RecoveryCodes {
private fetchConfig: fetchConfig;

constructor(fetchConfig: fetchConfig) {
this.fetchConfig = fetchConfig;
}

/**
* @param data {@link B2BRecoveryCodesRecoverRequest}
* @returns {@link B2BRecoveryCodesRecoverResponse}
* @async
* @throws A {@link StytchError} on a non-2xx response from the Stytch API
* @throws A {@link RequestError} when the Stytch API cannot be reached
*/
recover(
data: B2BRecoveryCodesRecoverRequest
): Promise<B2BRecoveryCodesRecoverResponse> {
const headers: Record<string, string> = {};
return request<B2BRecoveryCodesRecoverResponse>(this.fetchConfig, {
method: "POST",
url: `/v1/b2b/recovery_codes/recover`,
headers,
data,
});
}

/**
* @param params {@link B2BRecoveryCodesGetRequest}
* @returns {@link B2BRecoveryCodesGetResponse}
* @async
* @throws A {@link StytchError} on a non-2xx response from the Stytch API
* @throws A {@link RequestError} when the Stytch API cannot be reached
*/
get(
params: B2BRecoveryCodesGetRequest
): Promise<B2BRecoveryCodesGetResponse> {
const headers: Record<string, string> = {};
return request<B2BRecoveryCodesGetResponse>(this.fetchConfig, {
method: "GET",
url: `/v1/b2b/recovery_codes`,
headers,
params: { ...params },
});
}

/**
* @param data {@link B2BRecoveryCodesRotateRequest}
* @returns {@link B2BRecoveryCodesRotateResponse}
* @async
* @throws A {@link StytchError} on a non-2xx response from the Stytch API
* @throws A {@link RequestError} when the Stytch API cannot be reached
*/
rotate(
data: B2BRecoveryCodesRotateRequest
): Promise<B2BRecoveryCodesRotateResponse> {
const headers: Record<string, string> = {};
return request<B2BRecoveryCodesRotateResponse>(this.fetchConfig, {
method: "POST",
url: `/v1/b2b/recovery_codes/rotate`,
headers,
data,
});
}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stytch",
"version": "10.1.0",
"version": "10.2.0",
"description": "A wrapper for the Stytch API",
"types": "./types/lib/index.d.ts",
"main": "./dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions types/lib/b2b/client.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions types/lib/b2b/discovery_organizations.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions types/lib/b2b/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9a1044c

Please sign in to comment.