Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B2B Recovery codes SDK bump #292

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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.

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.

76 changes: 76 additions & 0 deletions types/lib/b2b/recovery_codes.d.ts

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

Loading