# @oraichain/security-questions

> TKey Security Questions Module

Latest version **2.0.2-beta.0** (published 2023-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @oraichain/security-questions
pnpm add @oraichain/security-questions
yarn add @oraichain/security-questions
bun add @oraichain/security-questions
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2-beta.0 |
| Published | 2023-12-12 |
| First published | 2023-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 2.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Torus Labs |
| Maintainers | oraichain_official |

## Links

- npm: https://www.npmjs.com/package/@oraichain/security-questions
- Repository: https://github.com/@oraichain/web3-login
- Homepage: https://github.com/@oraichain/web3-login#readme
- Issues: https://github.com/@oraichain/web3-login/issues
- npm.io page: https://npm.io/package/@oraichain/security-questions

## Dependencies (3)

- [bn.js](https://npm.io/package/bn.js.md) ^5.2.1
- [web3-utils](https://npm.io/package/web3-utils.md) ^1.8.1
- [@oraichain/common-types](https://npm.io/package/@oraichain/common-types.md) ^2.0.2-beta.0

## Recent versions

- 2.0.2-beta.0 (latest) — 2023-12-12
- 2.2.2 (next) — 2024-11-11
- 2.0.1-beta.2 (beta) — 2023-12-08
- 2.2.1 — 2024-10-24
- 2.2.0 — 2024-10-24
- 2.1.6 — 2024-10-24
- 2.1.5 — 2024-10-24
- 2.1.4 — 2024-10-23
- 2.1.3 — 2024-10-23
- 2.1.2 — 2024-09-26
- 2.1.1 — 2024-09-26
- 2.1.0 — 2024-09-16
- 2.0.5 — 2024-08-06
- 2.0.4 — 2024-05-23
- 2.0.1 — 2023-12-12
- … 39 more at https://npm.io/package/@oraichain/security-questions/versions

## README

# tKey Security Questions Module

[![npm version](https://img.shields.io/npm/v/@oraichain/security-questions?label=%22%22)](https://www.npmjs.com/package/@oraichain/security-questions/v/latest) [![minzip](https://img.shields.io/bundlephobia/minzip/@oraichain/security-questions?label=%22%22)](https://bundlephobia.com/result?p=@oraichain/security-questions@latest)

The oKey Security Questions Module helps you add or remove the and password as a share for oKey. This module is the part of the [oKey SDK](https://github.com/@oraichain/web3-login/).

## Installation

```shell
npm install --save @oraichain/security-questions
```

## Initialization

#### Import the `SecurityQuestionsModule` class from `@oraichain/security-questions`

```javascript
import SecurityQuestionsModule from "@oraichain/security-questions";
```

#### Assign the `SecurityQuestionsModule` class to a variable

```javascript
const securityQuestionsModule = new SecurityQuestionsModule(params);
```

### Parameters

`params`

- `saveAnswers?`: `boolean`

### Returns

The `SecurityQuestionsModule` class returns an object with the following properties:

```ts
class SecurityQuestionsModule implements IModule {
  moduleName: string;
  tbSDK: ITKeyApi;
  saveAnswers: boolean;
  constructor(saveAnswers?: boolean);
  static refreshSecurityQuestionsMiddleware(generalStore: unknown, oldShareStores: ShareStoreMap, newShareStores: ShareStoreMap): unknown;
  setModuleReferences(tbSDK: ITKeyApi): void;
  initialize(): Promise<void>;
  generateNewShareWithSecurityQuestions(answerString: string, questions: string): Promise<GenerateNewShareResult>;
  getSecurityQuestions(): string;
  inputShareFromSecurityQuestions(answerString: string): Promise<void>;
  changeSecurityQuestionAndAnswer(newAnswerString: string, newQuestions: string): Promise<void>;
  saveAnswerOnTkeyStore(answerString: string): Promise<void>;
  getAnswer(): Promise<string>;
}
```

## Usage

With the `SecurityQuestionsModule`, you've access to the following functions:

### Generate new share with security questions

#### `generateNewShareWithSecurityQuestions(answerString: string, questions: string)`

- `answerString`: Answer corresponding to a security question
- `questions`: The secutity question

#### Return

- `Promise<GenerateNewShareResult>`: The `GenerateNewShareResult` object

##### GenerateNewShareResult

```ts
declare type GenerateNewShareResult = {
  newShareStores: ShareStoreMap;
  newShareIndex: BN;
};
export declare type ShareStoreMap = {
  [shareIndex: string]: ShareStore;
};
declare class ShareStore implements ISerializable {
  share: Share;
  polynomialID: PolynomialID;
  constructor(share: Share, polynomialID: PolynomialID);
  static fromJSON(value: StringifiedType): ShareStore;
  toJSON(): StringifiedType;
}
```

### Get Security Question

#### `getSecurityQuestions()`

#### Return

- `string`: The security question

### Input share from security question

#### `inputShareFromSecurityQuestions(answerString: string)`

- `answerString`: Answer corresponding to the security question

### Change Security Question and Answer

#### `changeSecurityQuestionAndAnswer(newAnswerString: string, newQuestions: string)`

- `newAnswerString`: Answer corresponding to the new security question
- `newQuestions`: The new secutity question

### Save answer on tkey store

#### `saveAnswerOnTkeyStore(answerString: string)`

- `answerString`: Answer corresponding to the security question

### Get answer

#### `getAnswer`

#### Return

- `string`: The answer corresponding to the security question

---
_Source: https://npm.io/package/@oraichain/security-questions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
