@benup/bensdk 1.9.0 → 1.9.1

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,6 +1,19 @@
1
1
  import z from 'zod';
2
+ import { AxiosInstance } from 'axios';
2
3
  import { BenefitDefinitionSchema } from '../schemas/benefit-definition.schema';
4
+ import { TokenHelper } from './lib/token-helper.lib.type';
3
5
  type Base = z.infer<typeof BenefitDefinitionSchema>;
6
+ export type AuthHandlerCtx = {
7
+ tokenHelper: TokenHelper;
8
+ };
9
+ export type AuthHandlerResult = {
10
+ outcome: 'FAILED';
11
+ reason?: string;
12
+ retry?: boolean;
13
+ } | {
14
+ outcome: 'SUCCEEDED';
15
+ instance?: AxiosInstance;
16
+ };
4
17
  export type BenefitDefinition = Omit<Base, 'stateMachine'> & {
5
18
  stateMachine: Base['stateMachine'] & {
6
19
  DEDUCTION_FILE_INGESTION?: {
@@ -14,5 +27,8 @@ export type BenefitDefinition = Omit<Base, 'stateMachine'> & {
14
27
  };
15
28
  } & any;
16
29
  };
30
+ auth?: {
31
+ handler: (credentials: any, ctx: AuthHandlerCtx) => Promise<AuthHandlerResult>;
32
+ };
17
33
  };
18
34
  export {};
@@ -0,0 +1,17 @@
1
+ type GetTokenParameters = {
2
+ accountID: string;
3
+ companyID: string;
4
+ benefitID: string;
5
+ };
6
+ type SetTokenParameters = {
7
+ accountID: string;
8
+ companyID: string;
9
+ benefitID: string;
10
+ valueToBeStored: string;
11
+ storeForSeconds: number;
12
+ };
13
+ export interface TokenHelper {
14
+ get: (params: GetTokenParameters) => Promise<string | null>;
15
+ set: (params: SetTokenParameters) => Promise<boolean>;
16
+ }
17
+ export {};
@@ -52,6 +52,10 @@ export interface StateHandlerCtx {
52
52
  * executionAPI Axios instance
53
53
  */
54
54
  executionAPI: AxiosInstance;
55
+ /**
56
+ * benefitPartnerAPI Axios instance
57
+ */
58
+ benefitPartnerAPI: AxiosInstance;
55
59
  /**
56
60
  * deductionFileIngestionHelper
57
61
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benup/bensdk",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {