Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/6.0.0 #94

Merged
merged 18 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 99 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Or ES modules:
import { IncogniaApi } from '@incognia/api'
```

Instantiate with your clientId and clientSecret:
Initialize the `IncogniaApi` with your `clientId` and `clientSecret`. This is a required step and must be done before calling any of the API methods.

```js
const incogniaApi = new IncogniaApi({
IncogniaApi.init({
clientId: 'clientId',
clientSecret: 'clientSecret'
})
Expand All @@ -47,12 +47,13 @@ const incogniaApi = new IncogniaApi({

### Registering a Mobile Signup

This method registers a new mobile signup for the given installation (or request token) and address, returning a signup assessment, containing the risk assessment and supporting evidence:
This method registers a new mobile signup for the given request token and address, returning a signup assessment, containing the risk assessment and supporting evidence:

```js
try {
const signup = await incogniaApi.registerSignup({
installationId: 'installation_id',
const signup = await IncogniaApi.registerSignup({
requestToken: 'request_token',
policyId: 'policy_id',
structuredAddress: {
locale: 'en-US',
countryName: 'United States of America',
Expand All @@ -74,12 +75,13 @@ try {

### Registering a Web Signup

This method registers a new web signup for the given session token (or request token), returning a signup assessment, containing the risk assessment and supporting evidence:
This method registers a new web signup for the given request token, returning a signup assessment, containing the risk assessment and supporting evidence:

```js
try {
const signup = await incogniaApi.registerWebSignup({
sessionToken: 'session_token'
const signup = await IncogniaApi.registerWebSignup({
requestToken: 'request_token',
policyId: 'policy_id'
})
} catch (error) {
console.log(error.message)
Expand All @@ -88,13 +90,14 @@ try {

### Registering a Mobile Login

This method registers a new mobile login for the given installation (or request token) and account, returning a transaction assessment, containing the risk assessment and supporting evidence.
This method registers a new mobile login for the given request token and account, returning a transaction assessment, containing the risk assessment and supporting evidence.

```js
try {
const login = await incogniaApi.registerLogin({
installationId: 'installation_id',
const login = await IncogniaApi.registerLogin({
requestToken: 'request_token',
accountId: 'account_id',
policyId: 'policy_id',
externalId: 'external_id' // optional field
})
} catch (error) {
Expand All @@ -104,13 +107,14 @@ try {

### Registering a Web Login

This method registers a new web login for the given session token (or request token) and account, returning a transaction assessment, containing the risk assessment and supporting evidence.
This method registers a new web login for the given request token and account, returning a transaction assessment, containing the risk assessment and supporting evidence.

```js
try {
const login = await incogniaApi.registerWebLogin({
sessionToken: 'session_token',
accountId: 'account_id'
const login = await IncogniaApi.registerWebLogin({
requestToken: 'request_token',
accountId: 'account_id',
policyId: 'policy_id'
})
} catch (error) {
console.log(error.message)
Expand All @@ -119,13 +123,14 @@ try {

### Registering a Payment

This method registers a new payment for the given installation (or request token) and account, returning a transaction assessment, containing the risk assessment and supporting evidence.
This method registers a new payment for the given request token and account, returning a transaction assessment, containing the risk assessment and supporting evidence.

```js
try {
const payment = await incogniaApi.registerPayment({
installationId: 'installation_id',
const payment = await IncogniaApi.registerPayment({
requestToken: 'request_token',
accountId: 'account_id',
policyId: 'policy_id',
addresses: [
{
structuredAddress: {
Expand Down Expand Up @@ -156,13 +161,14 @@ try {

### Registering a Web Payment

This method registers a new web payment for the given session token (or request token) and account, returning a transaction assessment, containing the risk assessment and supporting evidence.
This method registers a new web payment for the given request token and account, returning a transaction assessment, containing the risk assessment and supporting evidence.

```js
try {
const payment = await incogniaApi.registerWebPayment({
sessionToken: 'session_token',
accountId: 'account_id'
const payment = await IncogniaApi.registerWebPayment({
requestToken: 'request_token',
accountId: 'account_id',
policyId: 'policy_id'
})
} catch (error) {
console.log(error.message)
Expand All @@ -175,7 +181,7 @@ This method registers a feedback event for the given identifiers related to a si

```js
try {
incogniaApi.registerFeedback({
IncogniaApi.registerFeedback({
installationId: 'installation_id',
accountId: 'account_id',
event: FeedbackEvent.AccountTakeover,
Expand Down Expand Up @@ -218,8 +224,8 @@ Every method call can throw `IncogniaApiError` and `IncogniaError`.
const { IncogniaApi, IncogniaApiError } = require('@incognia/api')

try {
const loginAssessment = await incogniaApi.registerLogin({
installationId: 'installation_id',
const loginAssessment = await IncogniaApi.registerLogin({
requestToken: 'request_token',
accountId: 'account_id'
})
} catch (error) {
Expand All @@ -230,6 +236,74 @@ try {
}
```

## Migration to v6

The v6 changed the `IncogniaApi` interface, transforming the previous instance methods into static methods.

When migrating to v6, adjust the `IncogniaApi` usage as follows.

### Initialization

Instead of creating an instance of the `IncogniaApi` class using your API credentials, just initialize the `IncogniaApi` with your credentials using the `init()` method. Initializing the `IncogniaApi` is a required step and must be done before calling any of the other `IncogniaApi` methods.

```js
// Before
const incogniaApi = new IncogniaApi({
clientId: 'clientId',
clientSecret: 'clientSecret'
})

// After
IncogniaApi.init({
clientId: 'clientId',
clientSecret: 'clientSecret'
})
```

### Register methods

Every method of the `IncogniaApi` instance is now static, and should be called on the `IncogniaApi` class.

```js
// Before
const signup = await incogniaApi.registerSignup({...})
const login = await incogniaApi.registerLogin({...})
const payment = await incogniaApi.registerPayment({...})
incogniaApi.registerFeedback({...})

// After
const signup = await IncogniaApi.registerSignup({...})
const login = await IncogniaApi.registerLogin({...})
const payment = await IncogniaApi.registerPayment({...})
IncogniaApi.registerFeedback({...})
```

Furthermore, the `installationId` and `sessionToken` parameters were removed, and `requestToken` should be used instead. The `requestToken` field can receive the previous `installationId` and `sessionToken` values, as well as the new `requestToken` value from the Mobile and Web SDKs. Also, the `policyId` is now a required parameter and must be used on every assessment.

```js
// Before
const loginAssessment = await incogniaApi.registerLogin({
installationId: 'installation_id',
accountId: 'account_id'
})
const webPaymentAssessment = await incogniaApi.registerWebPayment({
sessionToken: 'session_token',
accountId: 'account_id'
})

// After
const loginAssessment = await IncogniaApi.registerLogin({
requestToken: 'installation_id',
accountId: 'account_id',
policyId: 'policy_id'
})
const webPaymentAssessment = await IncogniaApi.registerWebPayment({
requestToken: 'session_token',
accountId: 'account_id',
policyId: 'policy_id'
})
```

## More documentation

More documentation and code examples can be found at <https://developer.incognia.com/docs>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@incognia/api",
"author": "Incognia (https://incognia.com)",
"repository": "https://github.com/inloco/incognia-node",
"version": "5.2.0",
"version": "6.0.0",
"license": "MIT",
"type": "module",
"main": "dist/index.cjs",
Expand Down
15 changes: 15 additions & 0 deletions src/endpoints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type ApiEndpoints = {
TOKEN: string
SIGNUPS: string
TRANSACTIONS: string
FEEDBACKS: string
}

export const BASE_ENDPOINT = 'https://api.incognia.com/api'

export const apiEndpoints: ApiEndpoints = {
TOKEN: `${BASE_ENDPOINT}/v2/token`,
SIGNUPS: `${BASE_ENDPOINT}/v2/onboarding/signups`,
TRANSACTIONS: `${BASE_ENDPOINT}/v2/authentication/transactions`,
FEEDBACKS: `${BASE_ENDPOINT}/v2/feedbacks`
}
Loading
Loading