@aarthiklabs/credit-sdk 0.0.3 → 0.0.4-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.
- package/dist/components/layout/iframe.d.ts +2 -1
- package/dist/components/layout/shell.d.ts +1 -1
- package/dist/components/layout/types.d.ts +42 -14
- package/dist/components/layout/with-dialog.d.ts +1 -1
- package/dist/components/layout/with-drawer.d.ts +1 -1
- package/dist/core/auth/index.d.ts +1 -0
- package/dist/core/auth/token-manager.d.ts +51 -0
- package/dist/core/errors/errors.d.ts +9 -0
- package/dist/core/journey/index.d.ts +1 -0
- package/dist/core/journey/journey-manager.d.ts +39 -0
- package/dist/core/provisioning/borrower-provisioning-manager.d.ts +33 -0
- package/dist/core/provisioning/index.d.ts +1 -0
- package/dist/core/types/auth.d.ts +33 -0
- package/dist/core/types/errors.d.ts +1 -1
- package/dist/core/types/index.d.ts +3 -0
- package/dist/core/types/journey.d.ts +22 -0
- package/dist/core/types/provisioning.d.ts +18 -0
- package/dist/index.cjs +17 -17
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4677 -3185
- package/package.json +3 -2
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const IFrame: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>, "ref"> & React.RefAttributes<HTMLIFrameElement>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { TypeOfShellProperties } from "./types";
|
|
2
|
-
export declare function Shell({ triggerProperties, title, fullscreen, }: TypeOfShellProperties): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function Shell({ tenantID, applicationID, bootstrapToken, borrowerProviderID, borrowerContactNumber, baseURL, labURL, onReady, onError, onAuthStateChange, getBootstrapToken, onBootstrapExpired, onSessionEnd, persistSession, journeySelectionStrategy, triggerProperties, title, fullscreen, }: TypeOfShellProperties): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type { JSX } from "react";
|
|
1
|
+
import type { Dispatch, JSX, RefObject, SetStateAction } from "react";
|
|
2
|
+
import type { TypeOfAwaitable, TypeOfSDKProvisionJourney } from "../../core/types";
|
|
3
|
+
type TypeOfShellAuthState = "idle" | "exchanging" | "provisioning" | "selecting" | "ready" | "refreshing" | "error" | "awaiting-bootstrap";
|
|
4
|
+
type TypeOfJourneySelectionStrategy = "latest-active" | "most-recent" | "first" | ((journeys: TypeOfSDKProvisionJourney[]) => TypeOfSDKProvisionJourney | undefined);
|
|
2
5
|
type TypeOfShellTriggerProperties = {
|
|
3
6
|
label: string;
|
|
4
7
|
component?: never;
|
|
@@ -7,24 +10,49 @@ type TypeOfShellTriggerProperties = {
|
|
|
7
10
|
component: JSX.Element;
|
|
8
11
|
};
|
|
9
12
|
type TypeOfShellProperties = {
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
tenantID: string;
|
|
14
|
+
applicationID: string;
|
|
15
|
+
bootstrapToken: string;
|
|
16
|
+
borrowerProviderID: string;
|
|
17
|
+
borrowerContactNumber: string;
|
|
18
|
+
baseURL?: string;
|
|
19
|
+
labURL?: string;
|
|
20
|
+
onReady?: () => void;
|
|
21
|
+
onError?: (error: unknown) => void;
|
|
22
|
+
onAuthStateChange?: (state: TypeOfShellAuthState) => void;
|
|
23
|
+
getBootstrapToken?: () => TypeOfAwaitable<string>;
|
|
24
|
+
onBootstrapExpired?: () => void;
|
|
25
|
+
onSessionEnd?: () => void;
|
|
26
|
+
persistSession?: boolean;
|
|
27
|
+
journeySelectionStrategy?: TypeOfJourneySelectionStrategy;
|
|
28
|
+
triggerProperties?: TypeOfShellTriggerProperties;
|
|
29
|
+
title?: string;
|
|
12
30
|
fullscreen?: "all" | "mobile-only" | "desktop-only" | "none";
|
|
13
31
|
};
|
|
14
|
-
type TypeOfWithDialogProperties =
|
|
32
|
+
type TypeOfWithDialogProperties = {
|
|
15
33
|
open: boolean;
|
|
16
|
-
setOpen:
|
|
17
|
-
|
|
18
|
-
|
|
34
|
+
setOpen: Dispatch<SetStateAction<boolean>>;
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
error: Error | null;
|
|
37
|
+
onRetry: () => void;
|
|
38
|
+
iframeURL: string;
|
|
39
|
+
iframeRef: RefObject<HTMLIFrameElement | null>;
|
|
19
40
|
isFullScreen: boolean;
|
|
20
|
-
setIsFullScreen:
|
|
41
|
+
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
42
|
+
title: string;
|
|
43
|
+
triggerProperties: TypeOfShellTriggerProperties;
|
|
21
44
|
};
|
|
22
|
-
type TypeOfWithDrawerProperties =
|
|
45
|
+
type TypeOfWithDrawerProperties = {
|
|
23
46
|
open: boolean;
|
|
24
|
-
setOpen:
|
|
25
|
-
|
|
26
|
-
|
|
47
|
+
setOpen: Dispatch<SetStateAction<boolean>>;
|
|
48
|
+
isLoading: boolean;
|
|
49
|
+
error: Error | null;
|
|
50
|
+
onRetry: () => void;
|
|
51
|
+
iframeURL: string;
|
|
52
|
+
iframeRef: RefObject<HTMLIFrameElement | null>;
|
|
27
53
|
isFullScreen: boolean;
|
|
28
|
-
setIsFullScreen:
|
|
54
|
+
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
55
|
+
title: string;
|
|
56
|
+
triggerProperties: TypeOfShellTriggerProperties;
|
|
29
57
|
};
|
|
30
|
-
export type { TypeOfShellProperties, TypeOfShellTriggerProperties, TypeOfWithDialogProperties, TypeOfWithDrawerProperties, };
|
|
58
|
+
export type { TypeOfJourneySelectionStrategy, TypeOfShellAuthState, TypeOfShellProperties, TypeOfShellTriggerProperties, TypeOfWithDialogProperties, TypeOfWithDrawerProperties, };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { TypeOfWithDialogProperties } from "./types";
|
|
2
|
-
export declare function WithDialog({ open, setOpen,
|
|
2
|
+
export declare function WithDialog({ open, setOpen, isLoading, error, onRetry, iframeURL, iframeRef, isFullScreen, setIsFullScreen, triggerProperties: { label: triggerLabel, component: triggerComponent, }, title, }: TypeOfWithDialogProperties): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { TypeOfWithDrawerProperties } from "./types";
|
|
2
|
-
export declare function WithDrawer({ open, setOpen,
|
|
2
|
+
export declare function WithDrawer({ open, setOpen, isLoading, error, onRetry, iframeURL, iframeRef, isFullScreen, setIsFullScreen, triggerProperties: { label: triggerLabel, component: triggerComponent, }, title, }: TypeOfWithDrawerProperties): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./token-manager";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ILogger, TypeOfSDKAuthSession, TypeOfAwaitable, TypeOfFetchLike } from "../types";
|
|
2
|
+
export type TypeOfBootstrapTokenProvider = string | (() => TypeOfAwaitable<string>);
|
|
3
|
+
export interface ISDKTokenManagerOptions {
|
|
4
|
+
baseURL: string;
|
|
5
|
+
bootstrapToken: TypeOfBootstrapTokenProvider;
|
|
6
|
+
parentOrigin?: string;
|
|
7
|
+
fetch?: TypeOfFetchLike;
|
|
8
|
+
logger?: ILogger;
|
|
9
|
+
accessTokenLeewaySeconds?: number;
|
|
10
|
+
now?: () => number;
|
|
11
|
+
}
|
|
12
|
+
type TypeOfSDKTokenState = {
|
|
13
|
+
tokenType: string;
|
|
14
|
+
accessToken: string;
|
|
15
|
+
scope: string;
|
|
16
|
+
expiresIn: number;
|
|
17
|
+
accessTokenExpiresAt: number;
|
|
18
|
+
refreshToken: string;
|
|
19
|
+
refreshTokenExpiresAt: number;
|
|
20
|
+
sessionID: string;
|
|
21
|
+
};
|
|
22
|
+
export declare class SDKTokenManager {
|
|
23
|
+
private readonly client;
|
|
24
|
+
private readonly bootstrapTokenProvider;
|
|
25
|
+
private readonly parentOrigin?;
|
|
26
|
+
private readonly accessTokenLeewayMs;
|
|
27
|
+
private readonly now;
|
|
28
|
+
private readonly logger?;
|
|
29
|
+
private tokenState?;
|
|
30
|
+
private exchangePromise?;
|
|
31
|
+
private refreshPromise?;
|
|
32
|
+
constructor(options: ISDKTokenManagerOptions);
|
|
33
|
+
getState(): TypeOfSDKTokenState | null;
|
|
34
|
+
clear(): void;
|
|
35
|
+
getSession(): Promise<TypeOfSDKAuthSession>;
|
|
36
|
+
getAccessToken(): Promise<string>;
|
|
37
|
+
exchange(): Promise<TypeOfSDKTokenState>;
|
|
38
|
+
refresh(): Promise<TypeOfSDKTokenState>;
|
|
39
|
+
private ensureValidSession;
|
|
40
|
+
private resolveBootstrapProvider;
|
|
41
|
+
private performExchange;
|
|
42
|
+
private performRefresh;
|
|
43
|
+
private buildTokenStateFromExchange;
|
|
44
|
+
private buildTokenStateFromRefresh;
|
|
45
|
+
private parseExpiresAt;
|
|
46
|
+
private isAccessTokenExpiring;
|
|
47
|
+
private isRefreshTokenExpired;
|
|
48
|
+
private toAuthSession;
|
|
49
|
+
private requiresRebootstrap;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -16,6 +16,15 @@ export declare class AarthikError extends Error {
|
|
|
16
16
|
export declare class AarthikConfigurationError extends AarthikError {
|
|
17
17
|
constructor(message: string, meta?: TypeOfErrorMeta);
|
|
18
18
|
}
|
|
19
|
+
export declare class AarthikAuthError extends AarthikError {
|
|
20
|
+
constructor(message: string, meta?: TypeOfErrorMeta);
|
|
21
|
+
}
|
|
22
|
+
export declare class AarthikRebootstrapRequiredError extends AarthikError {
|
|
23
|
+
constructor(message: string, options?: {
|
|
24
|
+
cause?: unknown;
|
|
25
|
+
meta?: TypeOfErrorMeta;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
19
28
|
export declare class AarthikNetworkError extends AarthikError {
|
|
20
29
|
constructor(message: string, cause?: unknown, meta?: TypeOfErrorMeta);
|
|
21
30
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./journey-manager";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ILogger, TypeOfAwaitable, TypeOfFetchLike, TypeOfSDKJourney } from "../types";
|
|
2
|
+
export interface ISDKJourneyManagerOptions {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
getAccessToken: () => TypeOfAwaitable<string>;
|
|
5
|
+
fetch?: TypeOfFetchLike;
|
|
6
|
+
logger?: ILogger;
|
|
7
|
+
}
|
|
8
|
+
export type TypeOfSDKJourneySelectionInput = {
|
|
9
|
+
journeyID?: string;
|
|
10
|
+
journeyIDs?: string[];
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export type TypeOfSDKJourneyState = {
|
|
14
|
+
journey?: TypeOfSDKJourney;
|
|
15
|
+
journeyID: string;
|
|
16
|
+
tokenType: string;
|
|
17
|
+
accessToken: string;
|
|
18
|
+
scope: string;
|
|
19
|
+
expiresIn: number;
|
|
20
|
+
created: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare class SDKJourneyManager {
|
|
23
|
+
private readonly client;
|
|
24
|
+
private readonly getAccessToken;
|
|
25
|
+
private state?;
|
|
26
|
+
private attachPromise?;
|
|
27
|
+
constructor(options: ISDKJourneyManagerOptions);
|
|
28
|
+
getState(): TypeOfSDKJourneyState | null;
|
|
29
|
+
clear(): void;
|
|
30
|
+
selectOrCreateJourney(input?: TypeOfSDKJourneySelectionInput): Promise<TypeOfSDKJourneyState>;
|
|
31
|
+
selectJourney(journeyID: string): Promise<TypeOfSDKJourneyState>;
|
|
32
|
+
createJourney(metadata?: Record<string, unknown>): Promise<TypeOfSDKJourneyState>;
|
|
33
|
+
private performSelectOrCreate;
|
|
34
|
+
private resolveJourneyID;
|
|
35
|
+
private performSelect;
|
|
36
|
+
private performCreate;
|
|
37
|
+
private toStateFromSelect;
|
|
38
|
+
private toStateFromCreate;
|
|
39
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ILogger, TypeOfAwaitable, TypeOfFetchLike, TypeOfSDKProvisionBorrower, TypeOfSDKProvisionJourney } from "../types";
|
|
2
|
+
export interface ISDKBorrowerProvisioningManagerOptions {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
getAccessToken: () => TypeOfAwaitable<string>;
|
|
5
|
+
fetch?: TypeOfFetchLike;
|
|
6
|
+
logger?: ILogger;
|
|
7
|
+
}
|
|
8
|
+
export type TypeOfSDKBorrowerProvisioningInput = {
|
|
9
|
+
borrowerProviderID: string;
|
|
10
|
+
contactNumber: string;
|
|
11
|
+
};
|
|
12
|
+
export type TypeOfSDKBorrowerProvisioningState = {
|
|
13
|
+
borrower: TypeOfSDKProvisionBorrower;
|
|
14
|
+
borrowerID: string;
|
|
15
|
+
journeys: TypeOfSDKProvisionJourney[];
|
|
16
|
+
journeyIDs: string[];
|
|
17
|
+
attached: boolean;
|
|
18
|
+
accessToken: string;
|
|
19
|
+
scope: string;
|
|
20
|
+
expiresIn: number;
|
|
21
|
+
};
|
|
22
|
+
export declare class SDKBorrowerProvisioningManager {
|
|
23
|
+
private readonly client;
|
|
24
|
+
private readonly getAccessToken;
|
|
25
|
+
private state?;
|
|
26
|
+
private provisionPromise?;
|
|
27
|
+
constructor(options: ISDKBorrowerProvisioningManagerOptions);
|
|
28
|
+
getState(): TypeOfSDKBorrowerProvisioningState | null;
|
|
29
|
+
clear(): void;
|
|
30
|
+
provisionBorrower(input: TypeOfSDKBorrowerProvisioningInput): Promise<TypeOfSDKBorrowerProvisioningState>;
|
|
31
|
+
private performProvision;
|
|
32
|
+
private toProvisioningState;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./borrower-provisioning-manager";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface TypeOfAuthExchangeRequest {
|
|
2
|
+
bootstrap_token: string;
|
|
3
|
+
parent_origin?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TypeOfAuthExchangeResponse {
|
|
6
|
+
token_type: string;
|
|
7
|
+
access_token: string;
|
|
8
|
+
scope: string;
|
|
9
|
+
expires_in: number;
|
|
10
|
+
refresh_token: string;
|
|
11
|
+
refresh_expires_at: string;
|
|
12
|
+
session_id: string;
|
|
13
|
+
}
|
|
14
|
+
export interface TypeOfAuthRefreshRequest {
|
|
15
|
+
refresh_token: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TypeOfAuthRefreshResponse {
|
|
18
|
+
token_type: string;
|
|
19
|
+
access_token: string;
|
|
20
|
+
scope: string;
|
|
21
|
+
expires_in: number;
|
|
22
|
+
refresh_token: string;
|
|
23
|
+
refresh_expires_at: string;
|
|
24
|
+
}
|
|
25
|
+
export interface TypeOfSDKAuthSession {
|
|
26
|
+
tokenType: string;
|
|
27
|
+
accessToken: string;
|
|
28
|
+
scope: string;
|
|
29
|
+
expiresIn: number;
|
|
30
|
+
sessionID: string;
|
|
31
|
+
accessTokenExpiresAt: number;
|
|
32
|
+
refreshTokenExpiresAt: number;
|
|
33
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type TypeOfErrorCode = "CONFIG_ERROR" | "NETWORK_ERROR" | "TIMEOUT" | "ABORTED" | "HTTP_ERROR" | "PARSE_ERROR" | "UNKNOWN_ERROR";
|
|
1
|
+
export type TypeOfErrorCode = "CONFIG_ERROR" | "AUTH_ERROR" | "AUTH_REQUIRES_BOOTSTRAP" | "NETWORK_ERROR" | "TIMEOUT" | "ABORTED" | "HTTP_ERROR" | "PARSE_ERROR" | "UNKNOWN_ERROR";
|
|
2
2
|
export type TypeOfErrorMeta = Readonly<Record<string, unknown>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface TypeOfSDKJourneySelectRequest {
|
|
2
|
+
journey_id: string;
|
|
3
|
+
}
|
|
4
|
+
export interface TypeOfSDKJourneySelectResponse {
|
|
5
|
+
token_type: string;
|
|
6
|
+
access_token: string;
|
|
7
|
+
scope: string;
|
|
8
|
+
expires_in: number;
|
|
9
|
+
}
|
|
10
|
+
export interface TypeOfSDKJourneyCreateRequest {
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export type TypeOfSDKJourney = Record<string, unknown> & {
|
|
14
|
+
journey_id?: string;
|
|
15
|
+
};
|
|
16
|
+
export interface TypeOfSDKJourneyCreateResponse {
|
|
17
|
+
journey: TypeOfSDKJourney;
|
|
18
|
+
token_type: string;
|
|
19
|
+
access_token: string;
|
|
20
|
+
scope: string;
|
|
21
|
+
expires_in: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface TypeOfSDKProvisionRequest {
|
|
2
|
+
borrower_provider_id: string;
|
|
3
|
+
contact_number: string;
|
|
4
|
+
}
|
|
5
|
+
export type TypeOfSDKProvisionBorrower = Record<string, unknown> & {
|
|
6
|
+
borrower_id?: string;
|
|
7
|
+
};
|
|
8
|
+
export type TypeOfSDKProvisionJourney = Record<string, unknown> & {
|
|
9
|
+
journey_id?: string;
|
|
10
|
+
};
|
|
11
|
+
export interface TypeOfSDKProvisionResponse {
|
|
12
|
+
borrower: TypeOfSDKProvisionBorrower;
|
|
13
|
+
journeys: TypeOfSDKProvisionJourney[];
|
|
14
|
+
attached: boolean;
|
|
15
|
+
access_token: string;
|
|
16
|
+
scope: string;
|
|
17
|
+
expires_in: number;
|
|
18
|
+
}
|