Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
authentic-ts-client-temp
Advanced tools
TypeScript SDK for interacting with the Authentic API.
TypeScript SDK for interacting with the Authentic API.
npm install @authenticins/ts-client
Client
Most interaction with the SDK is done through the Client
class, which must be configured with a base API URL and your tenant's AuthConfig
on creation.
import * as Authentic from "@authenticins/ts-client";
const authentic = await Authentic.Client.create("{{API_BASE_URL}}", {
awsRegion: "{{YOUR_AWS_REGION}}",
awsIdentityPoolId: "{{YOUR_AWS_IDENTITY_POOL_ID}}",
awsUserPoolId: "{{YOUR_AWS_USER_POOL_ID}}",
awsUserPoolWebClientId: "{{YOUR_AWS_USER_POOL_WEB_CLIENT_ID}}",
});
Application
An insurance Application
with Authentic consists of three main parts: meta
, questions
(also referred to as fields
), and exposures
.
ApplicationMeta
is a lead that is submitted to create a new application.
// Find the customer's business class
const availableBusinessClasses = await authentic.getBusinessClasses();
const customerBusinessClass = availableBusinessClasses.find(
(businessClass) => businessClass.name === "Juice Bar"
);
// Set up the customer's states of operation
const customerStateCodes: Authentic.types.StateCode[] = ["OH", "NY"];
// Choose which insurance product the customer is applying for
const availableProducts = await authentic.getAvailableProducts(
applicationMeta.businessClassCode,
applicationMeta.stateCodes
);
const customerProduct = availableProducts.find(
(product) => product.name === "General Liability"
);
// Submit the customer's `ApplicationMeta` to create a new application
const applicationMeta: Authentic.types.ApplicationMeta = {
email: "customer@email.com",
businessClassCode: customerBusinessClass.code,
stateCodes: customerStateCodes,
productIds: customerProduct.id;
};
const application = await authentic.createApplication(applicationMeta);
An Application
's questions are broken up into sections. These sections are ordered, as are the questions within them. The SDK provides getters to track which sections have yet to be completed, updating these getters as new answers are submitted.
Note: If accepting user input, each ApplicationField
includes properties to validate input as well as display the question. (ex: type
, title
, description
, helperText
, minimum
, maximum
, etc.)
// Find the first question within the current section that has yet to be answered
const currentQuestion: Authentic.types.ApplicationField =
application.currentSection.fields.find(
(field) => !application.answers.questions[field.name]
);
// Submit an answer for the current question
const wasErrorSubmitting = await application.submitQuestionAnswer(
authentic.api,
{
fieldName: currentQuestion.name,
fieldValue: "Example answer",
}
);
Once all Application.sections
are complete, at least one answer for each ApplicationExposure
must be submitted. Exposures are the last piece of application information needed to generate policy quotes.
// Set up an exposure answer to submit
const exposureAnswer: Authentic.types.ApplicationExposureAnswer = {
id: "1",
exposureName: application.currentExposure.name,
fieldValues: {},
};
// Populate our exposure answer's `fieldValues` (question answers)
for (const exposureSection of application.currentExposure.sections) {
for (const exposureQuestion of exposureSection.fields) {
exposureAnswer.fieldValues[exposureQuestion.name] = "Example answer";
}
}
// Submit the exposure answer
const wasErrorSubmitting = await application.submitExposureAnswer(
authentic.api,
exposureAnswer
);
In order to generate policy quotes the user must be signed up and authenticated. This is done by a verification code sent to the customer's email.
// Send verification code (flagging `true` to sign up a new user if the email isn't registered)
const wasErrorSending = await authentic.auth.sendCode(
application.meta.email,
true
);
// Verify the code
const wasErrorVerifying = await authentic.auth.verifyCode(code);
With a completed Application
and an authenticated user, policy quotes can now be generated for the customer. These quotes can purchased by the customer through a generated payment link.
const wasErrorApplying = await application.apply(authentic.api);
const policyQuotes: Authentic.types.QuoteData[] = application.quotes;
const quotesPaymentLink = await application.getQuotesPaymentLink(authentic.api);
With an authenticated user, you can easily fetch all policies associated with that user.
const policies: Authentic.types.Policy[] = await authentic.getPolicies();
An important tool within the SDK is the ability to prefill applications by answering questions on behalf of the end customer. These prefilled answers serve to provide the customer with a "one-click" experience.
Prefilling can be done programmatically when creating an application within the SDK, or encoded into your custom application URL.
Note: You do not need to answer every question, or prefill every property on the application. Applications can be created with partial prefills, with the customer then providing the missing information.
const prefillData: ApplicationPrefillData = {
meta: {
email: "customer@email.com",
businessClassCode: "72311",
stateCodes: ["OH"],
productIds: ["aee80d5f-d110-4edb-8708-e5db2190a618"],
},
answers: {
CLASS_DESCRIPTION: "Barber Shops & Beauty Salons",
MARKET_GROUP_LONG: "Personal Services",
BUSINESS_LEGAL_NAME: "Customer Business Name",
NAME: "Customer Name",
FRANCHISE_SELECTED: "No",
GENERIC_BUSINESS_MGMT_PRACTICES_DECLINE: "None of the above",
},
exposures: [
{
id: "1",
name: "business_location",
fieldValues: {
ADDRESS: "100 street, UNIT 2, city, OH 33333, US",
SALES: "250000",
PAYROLL: "40000",
AREA: "3500",
},
},
],
};
// Prefilling programmatically
const application = await authentic.createApplication(
prefillData.meta,
prefillData
);
// Prefilling via encoded URL
const applicationUrl = getApplicationUrl({
baseUrl: "your-company.authenticinsurance.com/apply",
prefillData,
});
Authentic allows you to theme your insurance portal to your brand, giving the end customer a seamless and trustworthy experience.
Below is an example of redirecting your user to a partially prefilled, fully branded insurance application with a React component.
function InsuranceQuoteButton() {
const baseUrl = "your-company.authenticinsurance.com/apply";
const prefillData: ApplicationPrefillData = {
meta: {
email: "customer@email.com",
stateCodes: ["OH"],
},
};
const themeOverrides: ThemeOverrides = {
brandName: "Your company",
brandLogoUrl: "https://your-company.com/logo.png",
primaryColor: "#000000",
borderRadius: 4,
};
return (
<button
onClick={() =>
redirectToApplicationUrl({
baseUrl,
prefillData,
themeOverrides,
})
}
>
Get A Quote
</button>
);
}
If you'd like to trigger state changes in your frontend application upon Client
auth changes, or an changes in an insurance Application
, you can pass callback functions upon creation.
function App() {
const [authentic, setAuthentic] = useState<Authentic.Client | null>(null);
const [auth, setAuth] = useState<Authentic.types.Auth | null>(null);
const [application, setApplication] =
useState<Authentic.types.Application | null>(null);
function onAuthChange(auth: Authentic.types.Auth) {
setAuth(auth);
}
function onApplicationChange(application: Authentic.types.Application) {
setApplication(application);
}
useEffect(() => {
async function initAuthenticClient() {
const authentic = await Authentic.Client.create(
"{{API_BASE_URL}}",
{
awsRegion: "{{YOUR_AWS_REGION}}",
awsIdentityPoolId: "{{YOUR_AWS_IDENTITY_POOL_ID}}",
awsUserPoolId: "{{YOUR_AWS_USER_POOL_ID}}",
awsUserPoolWebClientId: "{{YOUR_AWS_USER_POOL_WEB_CLIENT_ID}}",
},
onAuthChange,
onApplicationChange
);
setAuthentic(authentic);
}
initAuthenticClient();
}, []);
}
FAQs
TypeScript SDK for interacting with the Authentic API.
The npm package authentic-ts-client-temp receives a total of 0 weekly downloads. As such, authentic-ts-client-temp popularity was classified as not popular.
We found that authentic-ts-client-temp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.