Skip to content

Commit

Permalink
packages/js: MFA
Browse files Browse the repository at this point in the history
  • Loading branch information
merlindru committed May 9, 2024
1 parent 4aaf083 commit cd2a267
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 1 deletion.
Binary file modified packages/js/passkeys-sdk/bun.lockb
Binary file not shown.
22 changes: 21 additions & 1 deletion packages/js/passkeys-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ export function tenant(config: { baseUrl?: string; apiKey: string; tenantId: str
})
);
},
mfa: {
registration: {
initialize() {
return wrap(client.POST("/{tenant_id}/mfa/registration/initialize", { params }));
},
finalize(credential: PostRegistrationFinalizeBody) {
return wrap(
client.POST("/{tenant_id}/mfa/registration/finalize", { params, body: credential })
);
},
},
login: {
initialize() {
return wrap(client.POST("/{tenant_id}/mfa/login/initialize", { params }));
},
finalize(credential: PostLoginFinalizeBody) {
return wrap(client.POST("/{tenant_id}/mfa/login/finalize", { params, body: credential }));
},
},
},
};
},
jwks() {
Expand All @@ -93,7 +113,7 @@ export function tenant(config: { baseUrl?: string; apiKey: string; tenantId: str
},
},
registration: {
initialize(data: { userId: string; username: string; icon?: string | null; displayName?: string | null }) {
initialize(data: { userId: string; username: string; icon?: string; displayName?: string }) {
return wrap(
client.POST("/{tenant_id}/registration/initialize", {
params,
Expand Down
138 changes: 138 additions & 0 deletions packages/js/passkeys-sdk/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ export interface paths {
*/
post: operations["post-tenant_id-transaction-finalize"];
};
"/{tenant_id}/mfa/registration/initialize": {
/**
* Start MFA Registration
* @description Initialize a registration for mfa credentials
*/
post: operations["post-mfa-registration-initialize"];
};
"/{tenant_id}/mfa/registration/finalize": {
/**
* Finish MFA Registration
* @description Finish credential registration process
*/
post: operations["post-mfa-registration-finalize"];
};
"/{tenant_id}/mfa/login/initialize": {
/**
* Start MFA Login
* @description Initialize a login flow for MFA
*/
post: operations["post-mfa-login-initialize"];
};
"/{tenant_id}/mfa/login/finalize": {
/**
* Finish MFA Login
* @description Finalize the login operation
*/
post: operations["post-mfa-login-finalize"];
};
}

export type webhooks = Record<string, never>;
Expand Down Expand Up @@ -166,6 +194,8 @@ export interface components {
backup_eligible: boolean;
/** @default false */
backup_state: boolean;
/** @default false */
is_mfa: boolean;
}[];
};
};
Expand Down Expand Up @@ -345,6 +375,22 @@ export interface components {
};
};
};
/** @description Body for login/initialize */
"post-login-initialize"?: {
content: {
"application/json": {
/** @description optional - when provided the API Key needs to be sent to the server too. */
user_id?: string;
};
};
};
"post-mfa-login-initialize"?: {
content: {
"application/json": {
user_id: string;
};
};
};
};
headers: never;
pathItems: never;
Expand Down Expand Up @@ -485,6 +531,7 @@ export interface operations {
tenant_id: components["parameters"]["tenant_id"];
};
};
requestBody: components["requestBodies"]["post-login-initialize"];
responses: {
200: components["responses"]["post-login-initialize"];
400: components["responses"]["error"];
Expand Down Expand Up @@ -570,4 +617,95 @@ export interface operations {
500: components["responses"]["error"];
};
};
/**
* Start MFA Registration
* @description Initialize a registration for mfa credentials
*/
"post-mfa-registration-initialize": {
parameters: {
header: {
apiKey: components["parameters"]["X-API-KEY"];
};
path: {
/** @description Tenant ID */
tenant_id: string;
};
};
requestBody: components["requestBodies"]["post-registration-initialize"];
responses: {
200: components["responses"]["post-registration-initialize"];
400: components["responses"]["error"];
401: components["responses"]["error"];
500: components["responses"]["error"];
};
};
/**
* Finish MFA Registration
* @description Finish credential registration process
*/
"post-mfa-registration-finalize": {
parameters: {
header: {
apiKey: components["parameters"]["X-API-KEY"];
};
path: {
/** @description Tenant ID */
tenant_id: string;
};
};
requestBody: components["requestBodies"]["post-registration-finalize"];
responses: {
200: components["responses"]["token"];
400: components["responses"]["error"];
401: components["responses"]["error"];
404: components["responses"]["error"];
500: components["responses"]["error"];
};
};
/**
* Start MFA Login
* @description Initialize a login flow for MFA
*/
"post-mfa-login-initialize": {
parameters: {
header: {
apiKey: components["parameters"]["X-API-KEY"];
};
path: {
/** @description Tenant ID */
tenant_id: string;
};
};
requestBody: components["requestBodies"]["post-mfa-login-initialize"];
responses: {
200: components["responses"]["post-login-initialize"];
400: components["responses"]["error"];
401: components["responses"]["error"];
404: components["responses"]["error"];
500: components["responses"]["error"];
};
};
/**
* Finish MFA Login
* @description Finalize the login operation
*/
"post-mfa-login-finalize": {
parameters: {
header: {
apiKey: components["parameters"]["X-API-KEY"];
};
path: {
/** @description Tenant ID */
tenant_id: string;
};
};
requestBody: components["requestBodies"]["post-login-finalize"];
responses: {
200: components["responses"]["token"];
400: components["responses"]["error"];
401: components["responses"]["error"];
404: components["responses"]["error"];
500: components["responses"]["error"];
};
};
}

0 comments on commit cd2a267

Please sign in to comment.