Aller au contenu

Construire une intégration complète

Ce guide construit une intégration complète dans votre propre logiciel, dans l’ordre où un partenaire la construit : connecter un membre, lier vos fiches à des clients LexOpti, lancer des analyses, embarquer les écrans de LexOpti, recevoir les webhooks et déconnecter. Il suppose que vous avez suivi le démarrage rapide. Le CRM de référence de LexOpti joue ce parcours dans ses tests ; les pièges signalés ci-dessous sont ceux qu’il a révélés.

Votre logiciel peut montrer LexOpti de deux façons, et les combiner. Les deux commencent de la même manière, par la connexion du membre (étape 2) et vos fiches liées à des clients LexOpti (étape 3) ; elles diffèrent par qui dessine les écrans.

  • L’API seule. Votre serveur lit LexOpti par /v1 avec le jeton du membre, et vos propres écrans le montrent : le niveau de vigilance de chaque client, sa dernière analyse, ses dossiers, ses alertes à examiner, l’état de sa classification, le rapport à télécharger (vos propres écrans, par l’API seule). Aucun iframe, aucun script LexOpti dans vos pages.
  • Les composants embarqués. Les vrais écrans de LexOpti (client, dossier, nouveau client, nouveau dossier, l’application entière) dans vos pages, par des éléments personnalisés qui pilotent un iframe (étape 5, composants embarqués). Le membre travaille dans LexOpti sans quitter votre logiciel.
  • Les deux. Vos écrans pour la synthèse à côté de votre fiche (niveau, alertes, rapport), et les écrans embarqués pour ce que seul le membre peut faire.
API seule Composants embarqués Les deux
Effort de votre côté Plus élevé : vous concevez, construisez et maintenez chaque écran, ses états et ses traductions Moindre : une balise, le script et un fournisseur de session ; les écrans de LexOpti évoluent sans vous La somme, mais chaque écran là où il convient le mieux
Qui possède l’interface Vous, entièrement : votre charte, vos mots, votre mise en page LexOpti, dans un cadre de votre page ; vous choisissez son affichage (en ligne, panneau, plein écran) et quelques variables de thème Vous pour la synthèse, LexOpti pour le travail de conformité
Écrans de conformité que seul le membre remplit Indisponibles : la classification TRACFIN est en lecture seule par l’API, jamais répondue ni validée, et l’axe soupçon n’est jamais renvoyé. Le membre les remplit dans LexOpti même (lien profond) Dans votre page : le questionnaire de classification, sa validation, l’axe soupçon que le membre voit comme dans LexOpti Dans votre page, par les composants
Mobile Vos écrans natifs sur tout appareil ; votre serveur garde les jetons Écrans adaptatifs, dans une webview pour une application native (applications mobiles et natives) Synthèse native, webview pour les écrans de conformité
Marque blanche Complète : LexOpti n’apparaît jamais, sauf là où vous le nommez Les écrans de LexOpti, encadrés dans votre page Votre marque sur vos écrans, celle de LexOpti dans les composants

Préférez l’API seule quand il vous faut votre propre interface partout (un produit en marque blanche, une application mobile native, une charte existante) et que vos membres peuvent compléter la classification dans LexOpti. Préférez les composants embarqués pour livrer vite, ou quand le membre doit faire le travail de conformité (classification, validation, examen en contexte) sans quitter votre logiciel.

LexOpti enregistre votre application : un client confidentiel (son secret reste sur votre serveur), ses URI de redirection exactes et, pour les composants embarqués, les origines des pages qui les affichent. Vous recevez une organisation bac à sable pour développer, créée pour votre compte LexOpti : analyses déterministes, aucune facturation. Les comptes développeur et professionnel sont distincts : si vous utilisez déjà LexOpti en tant que professionnel, donnez à LexOpti une autre adresse e-mail pour le développement.

Une URI de redirection est en HTTPS, y compris en développement : http://localhost est refusé pour une application web. Servez votre application locale sur un nom *.localhost avec un certificat de confiance locale (par exemple https://crm.localhost:4400 avec mkcert), ou par un tunnel HTTPS, et faites enregistrer cette URI.

OAuth 2.1, code d’autorisation avec PKCE (S256). Votre serveur garde le vérificateur, lie le state au navigateur (un cookie) et envoie le membre chez LexOpti :

import {
function createHash(algorithm: string, options?: HashOptions): Hash

Creates and returns a Hash object that can be used to generate hash digests using the given algorithm. Optional options argument controls stream behavior. For XOF hash functions such as 'shake256', the outputLength option can be used to specify the desired output length in bytes.

The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha256', 'sha512', etc. On recent releases of OpenSSL, openssl list -digest-algorithms will display the available digest algorithms.

Example: generating the sha256 sum of a file

import {
createReadStream,
} from 'node:fs';
import { argv } from 'node:process';
const {
createHash,
} = await import('node:crypto');
const filename = argv[2];
const hash = createHash('sha256');
const input = createReadStream(filename);
input.on('readable', () => {
// Only one element is going to be produced by the
// hash stream.
const data = input.read();
if (data)
hash.update(data);
else {
console.log(`${hash.digest('hex')} ${filename}`);
}
});

@since ― v0.1.92

@param ― options stream.transform options

createHash
,
function randomBytes(size: number): NonSharedBuffer (+1 overload)

Generates cryptographically strong pseudorandom data. The size argument is a number indicating the number of bytes to generate.

If a callback function is provided, the bytes are generated asynchronously and the callback function is invoked with two arguments: err and buf. If an error occurs, err will be an Error object; otherwise it is null. The buf argument is a Buffer containing the generated bytes.

// Asynchronous
const {
randomBytes,
} = await import('node:crypto');
randomBytes(256, (err, buf) => {
if (err) throw err;
console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);
});

If the callback function is not provided, the random bytes are generated synchronously and returned as a Buffer. An error will be thrown if there is a problem generating the bytes.

// Synchronous
const {
randomBytes,
} = await import('node:crypto');
const buf = randomBytes(256);
console.log(
`${buf.length} bytes of random data: ${buf.toString('hex')}`);

The crypto.randomBytes() method will not complete until there is sufficient entropy available. This should normally never take longer than a few milliseconds. The only time when generating the random bytes may conceivably block for a longer period of time is right after boot, when the whole system is still low on entropy.

This API uses libuv's threadpool, which can have surprising and negative performance implications for some applications; see the UV_THREADPOOL_SIZE documentation for more information.

The asynchronous version of crypto.randomBytes() is carried out in a single threadpool request. To minimize threadpool task length variation, partition large randomBytes requests when doing so as part of fulfilling a client request.

@since ― v0.5.8

@param ― size The number of bytes to generate. The size must not be larger than 2**31 - 1.

@return ― if the callback function is not provided.

randomBytes
} from "node:crypto";
const
const verifier: string
verifier
=
function randomBytes(size: number): NonSharedBuffer (+1 overload)

Generates cryptographically strong pseudorandom data. The size argument is a number indicating the number of bytes to generate.

If a callback function is provided, the bytes are generated asynchronously and the callback function is invoked with two arguments: err and buf. If an error occurs, err will be an Error object; otherwise it is null. The buf argument is a Buffer containing the generated bytes.

// Asynchronous
const {
randomBytes,
} = await import('node:crypto');
randomBytes(256, (err, buf) => {
if (err) throw err;
console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);
});

If the callback function is not provided, the random bytes are generated synchronously and returned as a Buffer. An error will be thrown if there is a problem generating the bytes.

// Synchronous
const {
randomBytes,
} = await import('node:crypto');
const buf = randomBytes(256);
console.log(
`${buf.length} bytes of random data: ${buf.toString('hex')}`);

The crypto.randomBytes() method will not complete until there is sufficient entropy available. This should normally never take longer than a few milliseconds. The only time when generating the random bytes may conceivably block for a longer period of time is right after boot, when the whole system is still low on entropy.

This API uses libuv's threadpool, which can have surprising and negative performance implications for some applications; see the UV_THREADPOOL_SIZE documentation for more information.

The asynchronous version of crypto.randomBytes() is carried out in a single threadpool request. To minimize threadpool task length variation, partition large randomBytes requests when doing so as part of fulfilling a client request.

@since ― v0.5.8

@param ― size The number of bytes to generate. The size must not be larger than 2**31 - 1.

@return ― if the callback function is not provided.

randomBytes
(32).
Buffer<ArrayBuffer>.toString(encoding?: BufferEncoding, start?: number, end?: number): string

Decodes buf to a string according to the specified character encoding inencoding. start and end may be passed to decode only a subset of buf.

If encoding is 'utf8' and a byte sequence in the input is not valid UTF-8, then each invalid byte is replaced with the replacement character U+FFFD.

The maximum length of a string instance (in UTF-16 code units) is available as

constants.MAX_STRING_LENGTH

.

import { Buffer } from 'node:buffer';
const buf1 = Buffer.allocUnsafe(26);
for (let i = 0; i < 26; i++) {
// 97 is the decimal ASCII value for 'a'.
buf1[i] = i + 97;
}
console.log(buf1.toString('utf8'));
// Prints: abcdefghijklmnopqrstuvwxyz
console.log(buf1.toString('utf8', 0, 5));
// Prints: abcde
const buf2 = Buffer.from('tést');
console.log(buf2.toString('hex'));
// Prints: 74c3a97374
console.log(buf2.toString('utf8', 0, 3));
// Prints: té
console.log(buf2.toString(undefined, 0, 3));
// Prints: té

@since ― v0.1.90

@param ― encoding The character encoding to use.

@param ― start The byte offset to start decoding at.

@param ― end The byte offset to stop decoding at (not inclusive).

toString
("base64url");
const
const state: string
state
=
function randomBytes(size: number): NonSharedBuffer (+1 overload)

Generates cryptographically strong pseudorandom data. The size argument is a number indicating the number of bytes to generate.

If a callback function is provided, the bytes are generated asynchronously and the callback function is invoked with two arguments: err and buf. If an error occurs, err will be an Error object; otherwise it is null. The buf argument is a Buffer containing the generated bytes.

// Asynchronous
const {
randomBytes,
} = await import('node:crypto');
randomBytes(256, (err, buf) => {
if (err) throw err;
console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);
});

If the callback function is not provided, the random bytes are generated synchronously and returned as a Buffer. An error will be thrown if there is a problem generating the bytes.

// Synchronous
const {
randomBytes,
} = await import('node:crypto');
const buf = randomBytes(256);
console.log(
`${buf.length} bytes of random data: ${buf.toString('hex')}`);

The crypto.randomBytes() method will not complete until there is sufficient entropy available. This should normally never take longer than a few milliseconds. The only time when generating the random bytes may conceivably block for a longer period of time is right after boot, when the whole system is still low on entropy.

This API uses libuv's threadpool, which can have surprising and negative performance implications for some applications; see the UV_THREADPOOL_SIZE documentation for more information.

The asynchronous version of crypto.randomBytes() is carried out in a single threadpool request. To minimize threadpool task length variation, partition large randomBytes requests when doing so as part of fulfilling a client request.

@since ― v0.5.8

@param ― size The number of bytes to generate. The size must not be larger than 2**31 - 1.

@return ― if the callback function is not provided.

randomBytes
(16).
Buffer<ArrayBuffer>.toString(encoding?: BufferEncoding, start?: number, end?: number): string

Decodes buf to a string according to the specified character encoding inencoding. start and end may be passed to decode only a subset of buf.

If encoding is 'utf8' and a byte sequence in the input is not valid UTF-8, then each invalid byte is replaced with the replacement character U+FFFD.

The maximum length of a string instance (in UTF-16 code units) is available as

constants.MAX_STRING_LENGTH

.

import { Buffer } from 'node:buffer';
const buf1 = Buffer.allocUnsafe(26);
for (let i = 0; i < 26; i++) {
// 97 is the decimal ASCII value for 'a'.
buf1[i] = i + 97;
}
console.log(buf1.toString('utf8'));
// Prints: abcdefghijklmnopqrstuvwxyz
console.log(buf1.toString('utf8', 0, 5));
// Prints: abcde
const buf2 = Buffer.from('tést');
console.log(buf2.toString('hex'));
// Prints: 74c3a97374
console.log(buf2.toString('utf8', 0, 3));
// Prints: té
console.log(buf2.toString(undefined, 0, 3));
// Prints: té

@since ― v0.1.90

@param ― encoding The character encoding to use.

@param ― start The byte offset to start decoding at.

@param ― end The byte offset to stop decoding at (not inclusive).

toString
("base64url");
const
const authorize: URL
authorize
= new
var URL: new (url: string | URL, base?: string | URL) => URL

The URL interface is used to parse, construct, normalize, and encode URL.

MDN Reference

URL class is a global reference for import { URL } from 'url' https://nodejs.org/api/url.html#the-whatwg-url-api

@since ― v10.0.0

URL
("https://app.lexopti.com/api/auth/oauth2/authorize");
const authorize: URL
authorize
.
URL.search: string

The search property of the URL interface is a search string, also called a query string, that is a string containing a '?' followed by the parameters of the URL.

MDN Reference

search
= new
var URLSearchParams: new (init?: string[][] | Record<string, string> | string | URLSearchParams) => URLSearchParams

The URLSearchParams interface defines utility methods to work with the query string of a URL.

MDN Reference

URLSearchParams class is a global reference for import { URLSearchParams } from 'node:url' https://nodejs.org/api/url.html#class-urlsearchparams

@since ― v10.0.0

URLSearchParams
({
client_id: string
client_id
:
const clientId: string
clientId
,
code_challenge: string
code_challenge
:
function createHash(algorithm: string, options?: HashOptions): Hash

Creates and returns a Hash object that can be used to generate hash digests using the given algorithm. Optional options argument controls stream behavior. For XOF hash functions such as 'shake256', the outputLength option can be used to specify the desired output length in bytes.

The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha256', 'sha512', etc. On recent releases of OpenSSL, openssl list -digest-algorithms will display the available digest algorithms.

Example: generating the sha256 sum of a file

import {
createReadStream,
} from 'node:fs';
import { argv } from 'node:process';
const {
createHash,
} = await import('node:crypto');
const filename = argv[2];
const hash = createHash('sha256');
const input = createReadStream(filename);
input.on('readable', () => {
// Only one element is going to be produced by the
// hash stream.
const data = input.read();
if (data)
hash.update(data);
else {
console.log(`${hash.digest('hex')} ${filename}`);
}
});

@since ― v0.1.92

@param ― options stream.transform options

createHash
("sha256").
Hash.update(data: BinaryLike): Hash (+1 overload)

Updates the hash content with the given data, the encoding of which is given in inputEncoding. If encoding is not provided, and the data is a string, an encoding of 'utf8' is enforced. If data is a Buffer, TypedArray, orDataView, then inputEncoding is ignored.

This can be called many times with new data as it is streamed.

@since ― v0.1.92

@param ― inputEncoding The encoding of the data string.

update
(
const verifier: string
verifier
).
Hash.digest(encoding: BinaryToTextEncoding): string (+1 overload)

Calculates the digest of all of the data passed to be hashed (using the hash.update() method). If encoding is provided a string will be returned; otherwise a Buffer is returned.

The Hash object can not be used again after hash.digest() method has been called. Multiple calls will cause an error to be thrown.

@since ― v0.1.92

@param ― encoding The encoding of the return value.

digest
("base64url"),
code_challenge_method: string
code_challenge_method
: "S256",
redirect_uri: string
redirect_uri
: "https://crm.example.com/oauth/callback",
resource: string
resource
: "https://app.lexopti.com/v1",
response_type: string
response_type
: "code",
scope: string
scope
: "openid email offline_access lexopti:read lexopti:write",
state: string
state
,
}).
URLSearchParams.toString(): string
toString
();
// Rangez `verifier` sous `state`, posez `state` dans un cookie, redirigez vers `authorize`.

Votre logiciel connaît déjà le membre et sa structure : donnez-les à LexOpti dans le paramètre lexopti_hint de la demande d’autorisation, et la connexion démarre avec son adresse, l’inscription avec son nom, sa structure et son SIREN. Ce sont des indications, jamais des faits : chaque champ reste modifiable par le membre, qui atteste lui-même sa structure, et l’adresse est toujours vérifiée par le code envoyé. Le SIREN est prérempli mais jamais verrouillé ; s’il en choisit un autre, LexOpti l’avertit et lui propose de rejoindre la structure existante quand ce SIREN est déjà client.

const authorize: URL
authorize
.
URL.searchParams: URLSearchParams

The searchParams read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL.

MDN Reference

searchParams
.
URLSearchParams.set(name: string, value: string): void

The set() method of the URLSearchParams interface sets the value associated with a given search parameter to the given value.

MDN Reference

set
(
"lexopti_hint",
function encodePartnerHint(hint: PartnerHintInput): string

The lexopti_hint value for an authorization request: the hint as JSON, base64url. Throws when the hint is not valid or too large, so a partner finds out while developing, not the member while signing up.

encodePartnerHint
({
email?: string | undefined
email
: "camille.durand@durand-conseil.fr",
given_name?: string | undefined
given_name
: "Camille",
family_name?: string | undefined
family_name
: "Durand",
firm?: {
address?: {
city?: string | undefined;
line1?: string | undefined;
postal_code?: string | undefined;
} | undefined;
name?: string | undefined;
phone?: string | undefined;
profession?: "accountant" | "lawyer" | "notary" | "other_regulated" | "real_estate" | undefined;
siren?: string | undefined;
} | undefined
firm
: {
name?: string | undefined
name
: "Durand Conseil",
siren?: string | undefined
siren
: "552100554",
profession?: "accountant" | "lawyer" | "notary" | "other_regulated" | "real_estate" | undefined
profession
: "accountant",
phone?: string | undefined
phone
: "+33140000000",
},
})
);

Champs acceptés : email, given_name, family_name, firm.name, firm.siren (neuf chiffres), firm.profession (lawyer, notary, accountant, real_estate, other_regulated), firm.phone (E.164), firm.address.{line1, postal_code, city} ; 2 Ko au plus une fois encodé. Un champ invalide fait ignorer l’indication entière (un firm.profession inconnu est seulement omis), sans jamais bloquer la connexion. Avec lexopti_claim (section 14), la structure préparée l’emporte sur l’indication.

Le membre se connecte, choisit l’organisation (son bac à sable pendant le développement) et consent. Votre rappel vérifie que le state renvoyé est celui du navigateur, puis échange le code en authentification HTTP Basic :

const
const basic: string
basic
=
var Buffer: BufferConstructor
Buffer
.
BufferConstructor.from(string: WithImplicitCoercion<string>, encoding?: BufferEncoding): Buffer<ArrayBuffer> (+3 overloads)

Creates a new Buffer containing string. The encoding parameter identifies the character encoding to be used when converting string into bytes.

import { Buffer } from 'node:buffer';
const buf1 = Buffer.from('this is a tést');
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
console.log(buf1.toString());
// Prints: this is a tést
console.log(buf2.toString());
// Prints: this is a tést
console.log(buf1.toString('latin1'));
// Prints: this is a tést

A TypeError will be thrown if string is not a string or another type appropriate for Buffer.from() variants.

Buffer.from(string) may also use the internal Buffer pool like Buffer.allocUnsafe() does.

@since ― v5.10.0

@param ― string A string to encode.

@param ― encoding The encoding of string. Default: 'utf8'.

from
(
`${
function encodeURIComponent(uriComponent: string | number | boolean): string

Encodes a text string as a valid component of a Uniform Resource Identifier (URI).

@param ― uriComponent A value representing an unencoded URI component.

encodeURIComponent
(
const clientId: string
clientId
)}:${
function encodeURIComponent(uriComponent: string | number | boolean): string

Encodes a text string as a valid component of a Uniform Resource Identifier (URI).

@param ― uriComponent A value representing an unencoded URI component.

encodeURIComponent
(
const clientSecret: string
clientSecret
)}`
).
Buffer<ArrayBuffer>.toString(encoding?: BufferEncoding, start?: number, end?: number): string

Decodes buf to a string according to the specified character encoding inencoding. start and end may be passed to decode only a subset of buf.

If encoding is 'utf8' and a byte sequence in the input is not valid UTF-8, then each invalid byte is replaced with the replacement character U+FFFD.

The maximum length of a string instance (in UTF-16 code units) is available as

constants.MAX_STRING_LENGTH

.

import { Buffer } from 'node:buffer';
const buf1 = Buffer.allocUnsafe(26);
for (let i = 0; i < 26; i++) {
// 97 is the decimal ASCII value for 'a'.
buf1[i] = i + 97;
}
console.log(buf1.toString('utf8'));
// Prints: abcdefghijklmnopqrstuvwxyz
console.log(buf1.toString('utf8', 0, 5));
// Prints: abcde
const buf2 = Buffer.from('tést');
console.log(buf2.toString('hex'));
// Prints: 74c3a97374
console.log(buf2.toString('utf8', 0, 3));
// Prints: té
console.log(buf2.toString(undefined, 0, 3));
// Prints: té

@since ― v0.1.90

@param ― encoding The character encoding to use.

@param ― start The byte offset to start decoding at.

@param ― end The byte offset to stop decoding at (not inclusive).

toString
("base64");
const
const response: Response
response
= await
function fetch(input: string | URL | Request, init?: RequestInit): Promise<Response> (+1 overload)
fetch
("https://app.lexopti.com/api/auth/oauth2/token", {
RequestInit.body?: BodyInit | null | undefined

A BodyInit object or null to set request's body.

body
: new
var URLSearchParams: new (init?: string[][] | Record<string, string> | string | URLSearchParams) => URLSearchParams

The URLSearchParams interface defines utility methods to work with the query string of a URL.

MDN Reference

URLSearchParams class is a global reference for import { URLSearchParams } from 'node:url' https://nodejs.org/api/url.html#class-urlsearchparams

@since ― v10.0.0

URLSearchParams
({
code: string
code
,
code_verifier: string
code_verifier
:
const verifier: string
verifier
,
grant_type: string
grant_type
: "authorization_code",
redirect_uri: string
redirect_uri
: "https://crm.example.com/oauth/callback",
resource: string
resource
: "https://app.lexopti.com/v1",
}),
RequestInit.headers?: HeadersInit | undefined

A Headers object, an object literal, or an array of two-item arrays to set request's headers.

headers
: {
authorization: string
authorization
: `Basic ${
const basic: string
basic
}` },
RequestInit.method?: string | undefined

A string to set request's method.

method
: "POST",
});
const
const tokens: {
access_token: string;
refresh_token: string;
expires_in: number;
}
tokens
: {
access_token: string
access_token
: string;
refresh_token: string
refresh_token
: string;
expires_in: number
expires_in
: number;
} = await
const response: Response
response
.
Body.json(): Promise<any>
json
();

Rendez le rappel idempotent : un navigateur peut le demander deux fois (une navigation rejouée pendant que vous échangez le code). La seconde requête doit attendre le résultat de la première, ne jamais échanger le code une seconde fois ni afficher d’erreur. Les jetons d’accès vivent 15 minutes : avant leur expiration, appelez le point de jeton avec grant_type=refresh_token, le jeton de rafraîchissement et la ressource, et enregistrez le nouveau jeton de rafraîchissement qu’il répond, qui remplace l’ancien (authentification ; avec le SDK, fournir et rafraîchir le jeton). Rafraîchissez une requête à la fois, pour que deux n’utilisent jamais le même jeton de rafraîchissement : une promesse partagée dans un serveur Node.js, un verrou exclusif entre processus PHP.

let
let current: {
token: string;
expiresAt: number;
} | null
current
: {
token: string
token
: string;
expiresAt: number
expiresAt
: number } | null = null;
let
let refreshing: Promise<string> | null
refreshing
:
interface Promise<T>

Represents the completion of an asynchronous operation

Promise
<string> | null = null;
/** Un jeton d’accès valide : un rafraîchissement à la fois, les jetons de rafraîchissement tournent. */
function
function accessToken(): Promise<string>

Un jeton d’accès valide : un rafraîchissement à la fois, les jetons de rafraîchissement tournent.

accessToken
():
interface Promise<T>

Represents the completion of an asynchronous operation

Promise
<string> {
if (
let current: {
token: string;
expiresAt: number;
} | null
current
&&
let current: {
token: string;
expiresAt: number;
}
current
.
expiresAt: number
expiresAt
- 60_000 >
var Date: DateConstructor

Enables basic storage and retrieval of dates and times.

Date
.
DateConstructor.now(): number

Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).

now
()) {
return
var Promise: PromiseConstructor

Represents the completion of an asynchronous operation

Promise
.
PromiseConstructor.resolve<string>(value: string): Promise<string> (+2 overloads)

Creates a new resolved promise for the provided value.

@param ― value A promise.

@returns ― A promise whose internal state matches the provided promise.

resolve
(
let current: {
token: string;
expiresAt: number;
}
current
.
token: string
token
);
}
let refreshing: Promise<string> | null
refreshing
??=
function refreshTokens(refreshToken: string): Promise<{
access_token: string;
expires_in: number;
refresh_token: string;
}>
refreshTokens
(
const stored: {
refreshToken: string;
}
stored
.
refreshToken: string
refreshToken
)
.
Promise<{ access_token: string; expires_in: number; refresh_token: string; }>.then<string, never>(onfulfilled?: ((value: {
access_token: string;
expires_in: number;
refresh_token: string;
}) => string | PromiseLike<string>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<never>) | null | undefined): Promise<string>

Attaches callbacks for the resolution and/or rejection of the Promise.

@param ― onfulfilled The callback to execute when the Promise is resolved.

@param ― onrejected The callback to execute when the Promise is rejected.

@returns ― A Promise for the completion of which ever callback is executed.

then
((
tokens: {
access_token: string;
expires_in: number;
refresh_token: string;
}
tokens
) => {
// Enregistrez le nouveau jeton de rafraîchissement avant tout usage du jeton d’accès.
const stored: {
refreshToken: string;
}
stored
.
refreshToken: string
refreshToken
=
tokens: {
access_token: string;
expires_in: number;
refresh_token: string;
}
tokens
.
refresh_token: string
refresh_token
;
let current: {
token: string;
expiresAt: number;
} | null
current
= {
expiresAt: number
expiresAt
:
var Date: DateConstructor

Enables basic storage and retrieval of dates and times.

Date
.
DateConstructor.now(): number

Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).

now
() +
tokens: {
access_token: string;
expires_in: number;
refresh_token: string;
}
tokens
.
expires_in: number
expires_in
* 1000,
token: string
token
:
tokens: {
access_token: string;
expires_in: number;
refresh_token: string;
}
tokens
.
access_token: string
access_token
,
};
return
tokens: {
access_token: string;
expires_in: number;
refresh_token: string;
}
tokens
.
access_token: string
access_token
;
})
.
Promise<string>.finally(onfinally?: (() => void) | null | undefined): Promise<string>

Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

@param ― onfinally The callback to execute when the Promise is settled (fulfilled or rejected).

@returns ― A Promise for the completion of the callback.

finally
(() => {
let refreshing: Promise<string> | null
refreshing
= null;
});
return
let refreshing: Promise<string>
refreshing
;
}

Liez chaque fiche de façon idempotente, par votre propre identifiant : donnez au client LexOpti l’external_ref de votre fiche, un identifiant technique opaque comme crm:contact:1042 (jamais un nom, une date de naissance ni une adresse e-mail). Cherchez d’abord le client par cette référence, créez-le avec la référence seulement si aucun ne la porte, et réutilisez le client qu’elle désigne à chaque liaison suivante. Une requête rejouée, un second clic, un redémarrage de votre serveur ou un lien local perdu ne créent alors jamais un second client pour la même fiche.

const
const lexopti: LexOptiClient
lexopti
=
function createLexOptiClient(options: LexOptiClientOptions): LexOptiClient

A typed client of the LexOpti API. Every idempotent POST gets an Idempotency-Key (kept across its retries); only requests safe to repeat are retried after a failure, with jittered backoff or Retry-After. Errors are oRPC errors: problemOf(error) reads the problem details.

createLexOptiClient
({
LexOptiClientOptions.accessToken: () => Promise<string> | string

Returns the OAuth access token for each request: refresh it there when it expires (access tokens live 15 minutes).

accessToken
,
LexOptiClientOptions.locale?: "fr" | "en" | undefined

fr for French service messages; English otherwise.

locale
: "fr" });
/** Le client LexOpti de votre contact : celui que désigne sa référence, ou un nouveau. */
async function
function linkContact(contactId: string): Promise<string>

Le client LexOpti de votre contact : celui que désigne sa référence, ou un nouveau.

linkContact
(
contactId: string
contactId
: string):
interface Promise<T>

Represents the completion of an asynchronous operation

Promise
<string> {
const
const external_ref: string
external_ref
= `crm:contact:${
contactId: string
contactId
}`;
const
const found: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
found
= await
const lexopti: LexOptiClient
lexopti
.
clients: {
setExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
}, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}, Error>;
... 7 more ...;
requestPreliminaryScreening: Client<...>;
}
clients
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
external_ref?: string | undefined;
ids?: string | undefined;
expand?: ("cases" | "classification_state" | "last_check" | "open_alerts_count")[] | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
... 12 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
({
external_ref?: string | undefined
external_ref
});
if (
const found: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
found
.
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[]
data
[0]) {
return
const found: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
found
.
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[]
data
[0].
id: string
id
;
}
try {
const
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
= await
const lexopti: LexOptiClient
lexopti
.
clients: {
setExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
}, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}, Error>;
... 7 more ...;
requestPreliminaryScreening: Client<...>;
}
clients
.
create: Client
(input: {
type: "person";
person: {
first_name: string;
last_name: string;
usage_name?: string | undefined;
birth_date?: string | undefined;
birth_city?: string | undefined;
birth_country?: string | undefined;
nationalities?: string[] | undefined;
};
address?: {
line?: string | undefined;
postal_code?: string | undefined;
city?: string | undefined;
country?: string | undefined;
} | undefined;
external_ref?: string | undefined;
} | {
type: "company";
company: {
name: string;
siren?: string | undefined;
siret?: string | undefined;
legal_form?: string | undefined;
registration_country?: string | undefined;
rcs?: string | undefined;
};
address?: {
line?: string | undefined;
postal_code?: string | undefined;
city?: string | undefined;
country?: string | undefined;
} | undefined;
external_ref?: string | undefined;
}, options?: FriendlyClientOptions<...> | undefined) => ClientPromiseResult<...>
create
({
type: "person"
type
: "person",
person: {
first_name: string;
last_name: string;
usage_name?: string | undefined;
birth_date?: string | undefined;
birth_city?: string | undefined;
birth_country?: string | undefined;
nationalities?: string[] | undefined;
}
person
: {
first_name: string
first_name
: "Camille",
last_name: string
last_name
: "Durand",
birth_date?: string | undefined
birth_date
: "1984-03-12",
nationalities?: string[] | undefined
nationalities
: ["FR"],
},
external_ref?: string | undefined
external_ref
,
});
return
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
.
id: string
id
;
} catch (
function (local var) err: unknown
err
) {
// Une autre requête a lié la référence entre-temps : rien n’a été créé.
if (
function problemOf(error: unknown): ProblemDetails | null

The problem details (RFC 9457) of a failed call: code is stable, branch on it; request_id names the request for LexOpti support; null for an error that did not come from the API.

problemOf
(
function (local var) err: unknown
err
)?.
code: string | undefined
code
!== "external_ref_conflict") {
throw
function (local var) err: unknown
err
;
}
const
const winner: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
winner
= await
const lexopti: LexOptiClient
lexopti
.
clients: {
setExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
}, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}, Error>;
... 7 more ...;
requestPreliminaryScreening: Client<...>;
}
clients
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
external_ref?: string | undefined;
ids?: string | undefined;
expand?: ("cases" | "classification_state" | "last_check" | "open_alerts_count")[] | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
... 12 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
({
external_ref?: string | undefined
external_ref
});
if (!
const winner: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
winner
.
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[]
data
[0]) {
throw
function (local var) err: unknown
err
;
}
return
const winner: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
winner
.
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[]
data
[0].
id: string
id
;
}
}

La recherche répond au plus un client de votre application (une référence inconnue donne une page vide). Une création dont la référence désigne déjà un client, par exemple quand deux requêtes lient la même fiche en même temps, est refusée en bloc : 409, un problème dont le code est external_ref_conflict. Le client n’est pas créé, et le problème ne porte pas l’identifiant du client existant : lisez-le avec GET /v1/clients?external_ref=…, comme le fait le catch ci-dessus.

Vous pouvez garder l’identifiant LexOpti à côté de votre fiche comme cache, mais LexOpti reste la référence : un client supprimé emporte sa référence, et réinitialiser le bac à sable efface toutes les références ; un lien que la recherche ne retrouve plus est donc abandonné, et la liaison suivante crée de nouveau le client. Le CRM de référence de LexOpti lie ses contacts ainsi et les retrouve après un redémarrage.

Envoyez une identité assez complète pour analyser : date de naissance et nationalité d’une personne, SIREN et pays d’une société française. Sans elles, lancer une analyse répond incomplete_identity avec les champs à compléter.

Chaque client que votre application crée par l’API (POST /v1/clients) est analysé aussitôt et gratuitement sur les listes officielles de gels d’avoirs et de sanctions : le registre national des gels (DG Trésor), la liste des sanctions financières de l’UE et la liste SDN de l’OFAC américain. Il est analysé de nouveau, gratuitement, quand votre application modifie son identité (PATCH /v1/clients/{id}) et à chaque nouvelle publication de ces listes. Tout autre client que votre jeton atteint est analysé quand votre application le demande : POST /v1/clients/{id}/preliminary-screening (202). Lisez le résultat sur le client, ou par GET /v1/clients/{id}/preliminary-screening ; client.preliminary_screening_completed vous prévient quand il change. Les membres de l’organisation n’en voient aucune trace dans LexOpti : le résultat n’atteint que votre application.

status vaut pending (réponse en général en quelques secondes), completed (lisez outcome : no_match ou possible_match), failed ou unavailable (jamais présentés comme un résultat sans correspondance). Une correspondance dont la date de naissance contredit le client est un homonyme probable (homonym: true) et ne compte pas dans outcome. Les champs sont dans la référence de l’API ; un bac à sable répond à ses entrées magiques aussitôt.

Le professionnel qui utilise votre logiciel reste responsable de l’obligation de gel (art. L. 562-4 CMF). Vos écrans ne doivent pas dire plus que l’analyse :

  • Aucune correspondance : écrivez « Aucune correspondance dans les listes consultées », avec les listes, leurs dates de publication (lists[].published_at) et la date de vérification (checked_at). Jamais « client conforme » ni « pas de gel ».
  • Correspondance possible sur une liste contraignante (le registre français, la liste de l’UE) : invitez le membre à vérifier l’identité. S’il s’agit de la personne désignée, les avoirs sont gelés sans délai, rien ne lui est mis à disposition (art. L. 562-5 CMF), et le gel est déclaré à la DG Trésor.
  • Correspondance OFAC : « information sur un risque de sanctions américaines, à évaluer », jamais un gel en France ; le règlement de blocage de l’UE (règlement (CE) n° 2271/96) interdit d’appliquer certaines mesures américaines.
  • Périmètre : gels et sanctions seulement. L’analyse complète (personnes politiquement exposées, presse défavorable, registres, analyse web, classification) se fait dans un dossier : proposez d’en créer un.
  • Attribution : affichez l’attribution de chaque liste consultée (current.lists[].attribution, la source et sa date de publication), comme les conditions de réutilisation des listes l’exigent.
const
const check: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}
check
= await
const lexopti: LexOptiClient
lexopti
.
checks: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
}, {
data: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
get: Client<...>;
create: Client<...>;
}
checks
.
create: Client
(input: {
client_id: string;
case_id?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}, Error>
create
({
client_id: string
client_id
:
const clientId: string
clientId
});
// Un lien qui ouvre le client dans LexOpti, pour le membre connecté.
const
const link: {
url: string;
expires_at: string;
}
link
= await
const lexopti: LexOptiClient
lexopti
.
deepLinks: {
create: Client<Record<never, never>, {
client_id?: string | undefined;
case_id?: string | undefined;
}, {
url: string;
expires_at: string;
}, Error>;
}
deepLinks
.
create: Client
(input: {
client_id?: string | undefined;
case_id?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
url: string;
expires_at: string;
}, Error>
create
({
client_id?: string | undefined
client_id
:
const clientId: string
clientId
});
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const check: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}
check
.
status: "running" | "completed" | "failed"
status
,
const link: {
url: string;
expires_at: string;
}
link
.
url: string
url
);

Une analyse tourne en arrière-plan : suivez-la par ses webhooks plutôt qu’en l’interrogeant.

Chargez le script en module, placez les composants et donnez-leur un fournisseur de session qui demande un code à usage unique à votre serveur (composants embarqués). Votre serveur le crée avec le jeton du membre, l’origine exacte de la page, ainsi que le challenge PKCE et le composant que l’élément a remis à son fournisseur de session (une session par composant) :

// codeChallenge et component : ceux que l’élément a passés à sessionProvider, tels quels.
const
const session: {
code: string;
expires_at: string;
integration: string;
}
session
= await
const lexopti: LexOptiClient
lexopti
.
embedSessions: {
create: Client<Record<never, never>, {
code_challenge: string;
code_challenge_method: "S256";
component: "app" | "client" | "case" | "clients" | "cases" | "new-client" | "new-case" | "classification";
origin: string;
features?: string[] | undefined;
}, {
code: string;
expires_at: string;
integration: string;
}, Error>;
}
embedSessions
.
create: Client
(input: {
code_challenge: string;
code_challenge_method: "S256";
component: "app" | "client" | "case" | "clients" | "cases" | "new-client" | "new-case" | "classification";
origin: string;
features?: string[] | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
code: string;
expires_at: string;
integration: string;
}, Error>
create
({
code_challenge: string
code_challenge
:
const codeChallenge: string
codeChallenge
,
code_challenge_method: "S256"
code_challenge_method
: "S256",
component: "app" | "client" | "case" | "clients" | "cases" | "new-client" | "new-case" | "classification"
component
,
origin: string
origin
: "https://crm.example.com",
});
// Répondez { code: session.code } à la page ; ne le gardez jamais (60 secondes, usage unique).

Abonnez votre point de réception une fois par connexion et gardez son secret, répondu une seule fois, dans votre coffre de secrets. Vérifiez chaque envoi sur son corps brut avec webhooks.verify, répondez vite un 2xx et dédoublonnez sur l’identifiant de l’événement : nouvelles tentatives et rejeux le conservent (recevoir les webhooks).

async function
function receive(request: Request): Promise<Response>
receive
(
request: Request
request
:
interface Request

The Request interface of the Fetch API represents a resource request.

MDN Reference

Request
):
interface Promise<T>

Represents the completion of an asynchronous operation

Promise
<
interface Response

The Response interface of the Fetch API represents the response to a request.

MDN Reference

Response
> {
try {
const
const event: WebhookEvent
event
=
const webhooks: {
verify: (payload: string, headers: Headers | Record<string, string>, secret: string) => WebhookEvent;
}
webhooks
.
verify: (payload: string, headers: Headers | Record<string, string>, secret: string) => WebhookEvent

Verifies a LexOpti webhook (Standard Webhooks) and returns its event: pass the raw body, the request headers and the endpoint secret (whsec_…). Throws when the signature or the timestamp is wrong. The event's id is the webhook-id header: deduplicate on it.

verify
(
await
request: Request
request
.
Body.text(): Promise<string>
text
(),
request: Request
request
.
Request.headers: Headers

The headers read-only property of the with the request.

MDN Reference

headers
,
const secret: string
secret
);
if (
const event: WebhookEvent
event
.
type: WebhookEventType
type
!== "webhook.test") {
await
function handle(type: string, data: Record<string, string>): Promise<void>
handle
(
const event: WebhookEvent
event
.
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined" | (string & Record<never, never>)
type
,
const event: WebhookEvent
event
.
data: Record<string, string>
data
);
}
return new
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response

The Response interface of the Fetch API represents the response to a request.

MDN Reference

Response
(null, {
ResponseInit.status?: number | undefined
status
: 204 });
} catch {
return new
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response

The Response interface of the Fetch API represents the response to a request.

MDN Reference

Response
("invalid signature", {
ResponseInit.status?: number | undefined
status
: 400 });
}
}

webhook.test est ce qu’envoie webhookEndpoints.test : acceptez-le, pour que le test réussisse. Dans le bac à sable, les envois portent livemode: false.

La classification TRACFIN d’un client, et celle de chaque dossier, appartient au membre : il y répond et la valide dans LexOpti ou dans les composants embarqués, jamais votre application. Lisez-la pour montrer où elle en est : son state (to_complete, in_progress, validated, revalidate), son score et son niveau, sa dernière validation, ses réponses et les questions encore sans réponse (missing_answers), comptées comme le formulaire les compte.

const
const classification: {
subject: "client" | "case";
client_id: string | null;
case_id: string | null;
state: "to_complete" | "in_progress" | "validated" | "revalidate";
policy: {
id: string;
version: number;
};
score: number | null;
level: "simplified" | "standard" | "enhanced" | null;
validated_at: string | null;
validated_by: {
user_id: string | null;
channel: "app" | "embed" | "api" | "mcp" | null;
} | null;
answers: {
question_id: string;
axis: string;
value: string | null;
linked_entity_ids: string[];
per_entity: {
entity_id: string;
value: string;
}[];
}[];
excluded_axes: "axe5"[];
missing_answers: {
...;
};
}
classification
= await
const lexopti: LexOptiClient
lexopti
.
clients: {
setExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
}, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
...;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}, Error>;
... 7 more ...;
requestPreliminaryScreening: Client<...>;
}
clients
.
getClassification: Client
(input: {
id: string;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
subject: "client" | "case";
client_id: string | null;
case_id: string | null;
state: "to_complete" | "in_progress" | "validated" | "revalidate";
policy: {
id: string;
version: number;
};
score: number | null;
level: "simplified" | "standard" | "enhanced" | null;
validated_at: string | null;
validated_by: {
user_id: string | null;
channel: "app" | "embed" | "api" | "mcp" | null;
} | null;
answers: {
question_id: string;
axis: string;
value: string | null;
linked_entity_ids: string[];
per_entity: {
...;
}[];
}[];
excluded_axes: "axe5"[];
missing_answers: {
...;
};
}, Error>
getClassification
({
id: string
id
:
const clientId: string
clientId
,
});
if (
const classification: {
subject: "client" | "case";
client_id: string | null;
case_id: string | null;
state: "to_complete" | "in_progress" | "validated" | "revalidate";
policy: {
id: string;
version: number;
};
score: number | null;
level: "simplified" | "standard" | "enhanced" | null;
validated_at: string | null;
validated_by: {
user_id: string | null;
channel: "app" | "embed" | "api" | "mcp" | null;
} | null;
answers: {
question_id: string;
axis: string;
value: string | null;
linked_entity_ids: string[];
per_entity: {
entity_id: string;
value: string;
}[];
}[];
excluded_axes: "axe5"[];
missing_answers: {
...;
};
}
classification
.
state: "to_complete" | "in_progress" | "validated" | "revalidate"
state
=== "validated") {
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const classification: {
subject: "client" | "case";
client_id: string | null;
case_id: string | null;
state: "to_complete" | "in_progress" | "validated" | "revalidate";
policy: {
id: string;
version: number;
};
score: number | null;
level: "simplified" | "standard" | "enhanced" | null;
validated_at: string | null;
validated_by: {
user_id: string | null;
channel: "app" | "embed" | "api" | "mcp" | null;
} | null;
answers: {
question_id: string;
axis: string;
value: string | null;
linked_entity_ids: string[];
per_entity: {
entity_id: string;
value: string;
}[];
}[];
excluded_axes: "axe5"[];
missing_answers: {
...;
};
}
classification
.
level: "simplified" | "standard" | "enhanced" | null
level
,
const classification: {
subject: "client" | "case";
client_id: string | null;
case_id: string | null;
state: "to_complete" | "in_progress" | "validated" | "revalidate";
policy: {
id: string;
version: number;
};
score: number | null;
level: "simplified" | "standard" | "enhanced" | null;
validated_at: string | null;
validated_by: {
user_id: string | null;
channel: "app" | "embed" | "api" | "mcp" | null;
} | null;
answers: {
question_id: string;
axis: string;
value: string | null;
linked_entity_ids: string[];
per_entity: {
entity_id: string;
value: string;
}[];
}[];
excluded_axes: "axe5"[];
missing_answers: {
...;
};
}
classification
.
validated_at: string | null
validated_at
);
} else {
// Ce qu'il reste au membre à répondre, dans LexOpti.
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const classification: {
subject: "client" | "case";
client_id: string | null;
case_id: string | null;
state: "to_complete" | "in_progress" | "validated" | "revalidate";
policy: {
id: string;
version: number;
};
score: number | null;
level: "simplified" | "standard" | "enhanced" | null;
validated_at: string | null;
validated_by: {
user_id: string | null;
channel: "app" | "embed" | "api" | "mcp" | null;
} | null;
answers: {
question_id: string;
axis: string;
value: string | null;
linked_entity_ids: string[];
per_entity: {
entity_id: string;
value: string;
}[];
}[];
excluded_axes: "axe5"[];
missing_answers: {
...;
};
}
classification
.
missing_answers: {
count: number;
question_ids: string[];
}
missing_answers
.
question_ids: string[]
question_ids
);
}

GET /v1/cases/{id}/classification lit de la même façon celle d’un dossier, tous les axes sauf un : l’axe du soupçon n’est jamais renvoyé par l’API (excluded_axes: ["axe5"]). Ce que le professionnel sait ou soupçonne ne doit atteindre aucun autre système (art. L. 561-18 CMF) : ni ses réponses ni leur effet sur le score et le niveau ne sortent de LexOpti, par l’API, le serveur MCP ou les événements ; missing_answers ne le compte pas non plus. Le membre le voit toujours dans LexOpti et dans les composants embarqués. La lecture ne modifie rien, et un client jamais classifié répond to_complete sans réponses. Pour être averti de chaque validation, abonnez-vous à classification.validated (événements).

Le membre crée les dossiers d’un client et les classifie dans LexOpti. Lisez-les pour les montrer à côté de votre fiche : GET /v1/cases?client_id= liste les dossiers d’un client, principal ou non, du plus récent au plus ancien.

const
const page: {
data: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}[];
has_more: boolean;
next_cursor: string | null;
}
page
= await
const lexopti: LexOptiClient
lexopti
.
cases: {
setPartyExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
party_id: string;
}, {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}, Error>;
... 10 more ...;
listDocuments: Client<...>;
}
cases
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
external_ref?: string | undefined;
ids?: string | undefined;
client_id?: string | undefined;
party_external_ref?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
data: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
...;
}[];
... 9 more ...;
updated_at: string;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
({
client_id?: string | undefined
client_id
:
const clientId: string
clientId
});
for (const
const dossier: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}
dossier
of
const page: {
data: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}[];
has_more: boolean;
next_cursor: string | null;
}
page
.
data: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}[]
data
) {
const
const parties: string[]
parties
=
const dossier: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}
dossier
.
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | "constituant" | "fiduciaire" | "beneficiaire" | "tiers" | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[]
parties
.
Array<{ id: string; entity_id: string; external_ref: string | null; role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | ... 21 more ... | "autre"; type: "person" | "company"; name: string; monitoring_enabled: boolean; }>.map<string>(callbackfn: (value: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | "constituant" | "fiduciaire" | "beneficiaire" | "tiers" | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}, index: number, array: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | "constituant" | "fiduciaire" | "beneficiaire" | "tiers" | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[]) => string, thisArg?: any): string[]

Calls a defined callback function on each element of an array, and returns an array that contains the results.

@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

map
(
(
party: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | "constituant" | "fiduciaire" | "beneficiaire" | "tiers" | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}
party
) => `${
party: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | "constituant" | "fiduciaire" | "beneficiaire" | "tiers" | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}
party
.
name: string
name
} (${
party: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | "constituant" | "fiduciaire" | "beneficiaire" | "tiers" | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}
party
.
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | "constituant" | "fiduciaire" | "beneficiaire" | "tiers" | "autre"
role
})`
);
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const dossier: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}
dossier
.
label: string | null
label
,
const dossier: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}
dossier
.
risk_level: "simplified" | "standard" | "enhanced" | null
risk_level
,
const dossier: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}
dossier
.
classification_state: "to_complete" | "in_progress" | "validated" | "revalidate"
classification_state
);
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const parties: string[]
parties
,
const dossier: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}
dossier
.
pending_alert_count: number
pending_alert_count
);
}

Chaque dossier porte ses clients avec vos références (clients, le principal en premier), ses autres parties et leurs rôles, son niveau de vigilance, le niveau de risque validé par un membre (risk_level, null jusqu’à la première validation), l’état de sa classification (classification_state, le détail avec GET /v1/cases/{id}/classification) et ses alertes en attente (pending_alert_count). Pour être averti d’un nouveau dossier et de chaque changement de son niveau de risque, abonnez-vous à case.created et case.risk_level_changed (événements).

Sans composants embarqués, votre serveur lit ce dont le membre a besoin à côté de vos fiches, et vos écrans le montrent, dans votre style. Lisez-le sur votre serveur, avec le jeton du membre, jamais depuis le navigateur, et jamais à chaque page affichée : des centaines de fiches montrées, ce sont des centaines de requêtes, répétées à chaque visite. La façon de faire recommandée :

  1. Une requête groupée remplit une copie de votre côté, à la connexion et quand le membre demande d’actualiser : GET /v1/clients avec jusqu’à 100 de vos fiches (ids, ou vos références dans external_ref, séparés par des virgules) et expand[] pour ce que vos écrans montrent (lire plusieurs fiches à la fois) : le vigilance_level et le risk_level validé du client y sont toujours, last_check, open_alerts_count, classification_state et cases quand vous les demandez.
  2. Les webhooks la tiennent à jour : un événement qui nomme un client (client_id) ou l’un de ses dossiers (case_id), comme check.completed, alert.created, client.vigilance_level_changed, classification.validated ou case.updated, fait relire à votre serveur cette seule fiche, puis vos pages ouvertes la redessinent (événements). Répondez d’abord 2xx à la livraison, puis lisez : la lecture ne la retarde jamais. Un case_id désigne votre fiche par votre référence du dossier, que l’événement porte en case_external_ref quand vous l’avez définie, ou par GET /v1/cases/{id}, dont external_ref et client_ids nomment votre dossier et ses clients. Une fiche que la lecture ne renvoie plus (supprimée, ou déliée de votre application) quitte votre copie.
  3. Vos pages ne lisent que la copie.
const
const expand: readonly ["last_check", "open_alerts_count", "classification_state", "cases"]
expand
= [
"last_check",
"open_alerts_count",
"classification_state",
"cases",
] as
type const = readonly ["last_check", "open_alerts_count", "classification_state", "cases"]
const
;
// Une fois, à la connexion : toutes les fiches de la page en une requête.
const
const page: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
page
= await
const lexopti: LexOptiClient
lexopti
.
clients: {
setExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
}, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}, Error>;
... 7 more ...;
requestPreliminaryScreening: Client<...>;
}
clients
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
external_ref?: string | undefined;
ids?: string | undefined;
expand?: ("last_check" | "open_alerts_count" | "classification_state" | "cases")[] | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
... 12 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
({
expand?: ("last_check" | "open_alerts_count" | "classification_state" | "cases")[] | undefined
expand
: [...
const expand: readonly ["last_check", "open_alerts_count", "classification_state", "cases"]
expand
],
ids?: string | undefined
ids
:
const clientIds: string[]
clientIds
.
Array<string>.join(separator?: string): string

Adds all the elements of an array into a string, separated by the specified separator string.

@param ― separator A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.

join
(","),
limit?: number | undefined
limit
: 100,
});
const
const cache: Map<string, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}>
cache
= new
var Map: MapConstructor
new <string, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}>(iterable?: Iterable<...> | ... 1 more ... | undefined) => Map<...> (+3 overloads)
Map
(
const page: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
page
.
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[]
data
.
Array<{ id: string; external_ref: string | null; type: "person" | "company"; name: string; person: { first_name: string | null; last_name: string | null; usage_name: string | null; birth_date: string | null; birth_city: string | null; birth_country: string | null; nationalities: string[]; } | null; ... 12 more ...; cases?: { ...; } | undefined; }>.map<[string, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}]>(callbackfn: (value: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}, index: number, array: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[]) => [...], thisArg?: any): [...][]

Calls a defined callback function on each element of an array, and returns an array that contains the results.

@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

map
((
client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
) => [
client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
.
id: string
id
,
client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
]));
// À un webhook qui nomme un client : cette seule fiche, puis la redessiner.
async function
function refresh(clientId: string): Promise<void>
refresh
(
clientId: string
clientId
: string):
interface Promise<T>

Represents the completion of an asynchronous operation

Promise
<void> {
const
const one: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
one
= await
const lexopti: LexOptiClient
lexopti
.
clients: {
setExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
}, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}, Error>;
... 7 more ...;
requestPreliminaryScreening: Client<...>;
}
clients
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
external_ref?: string | undefined;
ids?: string | undefined;
expand?: ("last_check" | "open_alerts_count" | "classification_state" | "cases")[] | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
... 12 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
({
expand?: ("last_check" | "open_alerts_count" | "classification_state" | "cases")[] | undefined
expand
: [...
const expand: readonly ["last_check", "open_alerts_count", "classification_state", "cases"]
expand
],
ids?: string | undefined
ids
:
clientId: string
clientId
,
});
const [
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
] =
const one: {
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[];
has_more: boolean;
next_cursor: string | null;
}
one
.
data: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}[]
data
;
if (
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
) {
const cache: Map<string, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}>
cache
.
Map<string, { id: string; external_ref: string | null; type: "person" | "company"; name: string; person: { first_name: string | null; last_name: string | null; usage_name: string | null; birth_date: string | null; birth_city: string | null; birth_country: string | null; nationalities: string[]; } | null; ... 12 more ...; cases?: { ...; } | undefined; }>.set(key: string, value: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}): Map<...>

Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.

set
(
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
.
id: string
id
,
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
);
} else {
// Supprimée, ou plus de cette organisation : hors de la copie.
const cache: Map<string, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}>
cache
.
Map<string, { id: string; external_ref: string | null; type: "person" | "company"; name: string; person: { first_name: string | null; last_name: string | null; usage_name: string | null; birth_date: string | null; birth_city: string | null; birth_country: string | null; nationalities: string[]; } | null; ... 12 more ...; cases?: { ...; } | undefined; }>.delete(key: string): boolean

@returns ― true if an element in the Map existed and has been removed, or false if the element does not exist.

delete
(
clientId: string
clientId
);
}
}

Le CRM de référence de LexOpti travaille ainsi : à la connexion, son panneau « Appels API » montre, pour chaque page de 100 fiches liées, les clients avec leurs expansions, leurs alertes en attente (GET /v1/alerts?client_ids=…&status=pending, chaque page) et les dossiers liés à ses fiches (GET /v1/cases?ids=…) ; puis deux requêtes pour chaque webhook qui nomme un contact lié, une de plus pour le dossier lié ; et aucune quand une page est dessinée.

Une alerte attend l’examen d’un membre. Votre écran peut l’enregistrer : le membre choisit la décision et écrit la note, votre serveur l’envoie par PATCH /v1/alerts/{id}. La décision reste celle du membre, l’API n’examine jamais d’elle-même :

const
const pending: {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}
pending
= await
const lexopti: LexOptiClient
lexopti
.
alerts: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}, {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
get: Client<...>;
update: Client<...>;
}
alerts
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
... 9 more ...;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
({
client_id?: string | undefined
client_id
:
const clientId: string
clientId
,
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined
status
: "pending",
});
for (const
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
of
const pending: {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}
pending
.
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[]
data
) {
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
.
source_name: string
source_name
,
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
.
subject: string | null
subject
,
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
.
level: "simplified" | "standard" | "enhanced"
level
,
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
.
created_at: string
created_at
);
}
// La décision du membre, saisie dans votre écran.
const
const reviewed: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
reviewed
= await
const lexopti: LexOptiClient
lexopti
.
alerts: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}, {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
get: Client<...>;
update: Client<...>;
}
alerts
.
update: Client
(input: {
id: string;
status: "reviewed" | "dismissed" | "confirmed";
notes?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
... 8 more ...;
review_notes: string | null;
}, Error>
update
({
id: string
id
:
const alertId: string
alertId
,
notes?: string | undefined
notes
: "Homonyme : date de naissance différente.",
status: "reviewed" | "dismissed" | "confirmed"
status
: "dismissed",
});
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const reviewed: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
reviewed
.
status: "pending" | "reviewed" | "dismissed" | "confirmed"
status
,
const reviewed: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
reviewed
.
reviewed_at: string | null
reviewed_at
);

Le rapport d’un dossier est celui de LexOpti, dans sa version pour les partenaires : il ne comporte jamais l’axe soupçon (excluded_axes: ["axe5"]) et calcule ses scores sans lui. GET /v1/cases/{id}/report répond ses métadonnées et une URL signée pour 5 minutes, dans la langue d’Accept-Language (la locale du SDK). Téléchargez-le depuis votre serveur, vérifiez-le avec son sha256, puis servez-le au membre : l’URL signée n’atteint jamais le navigateur, et la même version est le même fichier.

const
const report: {
case_id: string;
version: string;
sha256: string;
language: "fr" | "en";
generated_at: string;
excluded_axes: "axe5"[];
content_type: "application/pdf";
download_url: string;
expires_at: string;
}
report
= await
const lexopti: LexOptiClient
lexopti
.
cases: {
setPartyExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
party_id: string;
}, {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | ... 23 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}, Error>;
... 10 more ...;
listDocuments: Client<...>;
}
cases
.
getReport: Client
(input: {
id: string;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
case_id: string;
version: string;
sha256: string;
language: "fr" | "en";
generated_at: string;
excluded_axes: "axe5"[];
content_type: "application/pdf";
download_url: string;
expires_at: string;
}, Error>
getReport
({
id: string
id
:
const caseId: string
caseId
});
// Aucun jeton pour l’URL signée : c’est elle l’accès, pendant 5 minutes.
const
const download: Response
download
= await
function fetch(input: string | URL | Request, init?: RequestInit): Promise<Response> (+1 overload)
fetch
(
const report: {
case_id: string;
version: string;
sha256: string;
language: "fr" | "en";
generated_at: string;
excluded_axes: "axe5"[];
content_type: "application/pdf";
download_url: string;
expires_at: string;
}
report
.
download_url: string
download_url
);
const
const file: Uint8Array<ArrayBuffer>
file
= new
var Uint8Array: Uint8ArrayConstructor
new <ArrayBuffer>(buffer: ArrayBuffer, byteOffset?: number, length?: number) => Uint8Array<ArrayBuffer> (+6 overloads)
Uint8Array
(await
const download: Response
download
.
Body.arrayBuffer(): Promise<ArrayBuffer>
arrayBuffer
());
if (
function createHash(algorithm: string, options?: HashOptions): Hash

Creates and returns a Hash object that can be used to generate hash digests using the given algorithm. Optional options argument controls stream behavior. For XOF hash functions such as 'shake256', the outputLength option can be used to specify the desired output length in bytes.

The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha256', 'sha512', etc. On recent releases of OpenSSL, openssl list -digest-algorithms will display the available digest algorithms.

Example: generating the sha256 sum of a file

import {
createReadStream,
} from 'node:fs';
import { argv } from 'node:process';
const {
createHash,
} = await import('node:crypto');
const filename = argv[2];
const hash = createHash('sha256');
const input = createReadStream(filename);
input.on('readable', () => {
// Only one element is going to be produced by the
// hash stream.
const data = input.read();
if (data)
hash.update(data);
else {
console.log(`${hash.digest('hex')} ${filename}`);
}
});

@since ― v0.1.92

@param ― options stream.transform options

createHash
("sha256").
Hash.update(data: BinaryLike): Hash (+1 overload)

Updates the hash content with the given data, the encoding of which is given in inputEncoding. If encoding is not provided, and the data is a string, an encoding of 'utf8' is enforced. If data is a Buffer, TypedArray, orDataView, then inputEncoding is ignored.

This can be called many times with new data as it is streamed.

@since ― v0.1.92

@param ― inputEncoding The encoding of the data string.

update
(
const file: Uint8Array<ArrayBuffer>
file
).
Hash.digest(encoding: BinaryToTextEncoding): string (+1 overload)

Calculates the digest of all of the data passed to be hashed (using the hash.update() method). If encoding is provided a string will be returned; otherwise a Buffer is returned.

The Hash object can not be used again after hash.digest() method has been called. Multiple calls will cause an error to be thrown.

@since ― v0.1.92

@param ― encoding The encoding of the return value.

digest
("hex") !==
const report: {
case_id: string;
version: string;
sha256: string;
language: "fr" | "en";
generated_at: string;
excluded_axes: "axe5"[];
content_type: "application/pdf";
download_url: string;
expires_at: string;
}
report
.
sha256: string
sha256
) {
throw new
var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+1 overload)
Error
("Le rapport n’est pas le fichier annoncé par LexOpti.");
}
// Répondez `file` au membre en application/pdf.

Ce que vos écrans ne peuvent pas faire par l’API : répondre ou valider une classification, ou voir l’axe soupçon (pour créer un dossier, voir plus bas). Envoyez le membre dans LexOpti pour cela (liens profonds), ou montrez-lui les composants embarqués. Pour rafraîchir vos écrans sans interroger l’API en boucle, suivez les événements : client.vigilance_level_changed, check.completed, alert.created, classification.validated, report.generated.

Journalisez chaque appel de votre serveur avec son en-tête Request-Id, à donner au support de LexOpti, et ne journalisez jamais un jeton, le secret client, un code ni une URL signée. Le CRM de référence de LexOpti montre ce journal dans son panneau « Appels API ».

Autorisez votre application sur votre bac à sable et parcourez chaque chemin avec ses entrées magiques : un nom ou une raison sociale contenant SANCTION, EXPOSE ou PRESSE donne une correspondance de sanctions, une personne politiquement exposée ou de la presse défavorable, et ERREUR fait échouer l’analyse (bac à sable).

Quand un membre délie LexOpti dans votre logiciel, révoquez ses jetons sur POST https://app.lexopti.com/api/auth/oauth2/revoke en HTTP Basic : d’abord le jeton de rafraîchissement (token_type_hint=refresh_token), qui met fin à l’autorisation, puis le jeton d’accès (token_type_hint=access_token). Abandonnez les jetons même si une révocation échoue. Le code, en TypeScript, PHP et curl : révoquer les jetons.

12. Toute une structure : installer une fois, chaque membre se connecte

Section intitulée « 12. Toute une structure : installer une fois, chaque membre se connecte »

Une structure de 20 personnes utilise votre logiciel. Plutôt que chaque membre lise et accepte le même écran d’autorisation, votre application peut être installée une fois pour toute la structure, comme un administrateur le fait avec le consentement administrateur de Microsoft Entra ou une application de confiance de Google Workspace. Dans LexOpti, la structure le demande et LexOpti l’installe : les réglages d’une structure ne font que lister, en lecture seule, les applications qui lui sont connectées.

  1. LexOpti l’installe, à la demande de la structure. Le propriétaire ou un administrateur de la structure le demande à LexOpti par le formulaire de contact (l’onglet « Applications connectées » de ses réglages l’indique) ; LexOpti installe votre application pour la structure, avec un motif enregistré. Les accès avec lesquels votre application est enregistrée sont installés pour chaque membre. Dans vos bacs à sable aussi, LexOpti l’installe sur demande.
  2. Chaque membre se connecte, sans plus. Votre demande d’autorisation ne change pas. Un membre qui se connecte à LexOpti n’a aucun écran d’autorisation pour les accès installés et revient directement sur votre adresse de retour, avec prompt=none aussi. Chaque membre obtient toujours ses propres jetons, en son nom et avec son rôle (un membre en lecture seule le reste) : la trace de LexOpti dit quel membre a fait quoi, comme l’exigent les règles de lutte contre le blanchiment. Ne partagez jamais le jeton d’un membre avec un autre. Une personne sans compte LexOpti le crée depuis la page de connexion, ou accepte l’invitation de son responsable, puis revient de la même façon sur votre adresse de retour (un membre sans compte).
  3. Faire correspondre vos utilisateurs aux membres. Une fois votre application installée pour la structure, GET /v1/members liste les membres de la structure (id, name, email, role, rien d’autre, paginé comme toute liste) ; avant, ou pour une application qu’un seul membre a connectée, il répond 403 installation_required. Associez-leur vos utilisateurs par adresse e-mail, et vérifiez avec GET /v1/organization pour quel membre agit un jeton (member.user_id).
const
const memberIdByEmail: Map<string, string>
memberIdByEmail
= new
var Map: MapConstructor
new <string, string>(iterable?: Iterable<readonly [string, string]> | null | undefined) => Map<string, string> (+3 overloads)
Map
<string, string>();
let
let cursor: string | undefined
cursor
: string | undefined;
do {
const
const page: {
data: {
id: string;
name: string;
email: string;
role: string;
}[];
has_more: boolean;
next_cursor: string | null;
}
page
= await
const lexopti: LexOptiClient
lexopti
.
members: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
}, {
data: {
id: string;
name: string;
email: string;
role: string;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
}
members
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
data: {
id: string;
name: string;
email: string;
role: string;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
({
limit?: number | undefined
limit
: 100,
cursor?: string | undefined
cursor
});
for (const
const member: {
id: string;
name: string;
email: string;
role: string;
}
member
of
const page: {
data: {
id: string;
name: string;
email: string;
role: string;
}[];
has_more: boolean;
next_cursor: string | null;
}
page
.
data: {
id: string;
name: string;
email: string;
role: string;
}[]
data
) {
const memberIdByEmail: Map<string, string>
memberIdByEmail
.
Map<string, string>.set(key: string, value: string): Map<string, string>

Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.

set
(
const member: {
id: string;
name: string;
email: string;
role: string;
}
member
.
email: string
email
.
String.toLowerCase(): string

Converts all the alphabetic characters in a string to lowercase.

toLowerCase
(),
const member: {
id: string;
name: string;
email: string;
role: string;
}
member
.
id: string
id
);
}
let cursor: string | undefined
cursor
=
const page: {
data: {
id: string;
name: string;
email: string;
role: string;
}[];
has_more: boolean;
next_cursor: string | null;
}
page
.
next_cursor: string | null
next_cursor
??
var undefined
undefined
;
} while (
let cursor: string | undefined
cursor
!==
var undefined
undefined
);
  1. Demander davantage. Une demande d’accès au-delà de ceux installés affiche de nouveau l’écran d’autorisation : le membre consent lui-même, ou LexOpti l’installe de nouveau, à la demande de la structure, pour l’étendre.
  2. Retrait. Quand LexOpti retire l’installation à la demande de la structure (ou y révoque ou bloque votre application), l’accès de chaque membre prend fin aussitôt : le rafraîchissement de leurs jetons échoue en invalid_grant, leurs jetons d’accès reçoivent 401 invalid_token de l’API, des composants embarqués et du MCP de LexOpti dès la requête suivante (l’introspection et les informations utilisateur du serveur d’autorisation les lisent encore jusqu’à leur expiration, 15 minutes au plus), vos sessions embarquées se ferment, et chacun de vos webhooks de la structure reçoit un dernier access.revoked puis est désactivé (webhooks). À la connexion suivante, chaque membre est de nouveau sollicité.

Une installation demeure, quel que soit le membre qui quitte la structure, comme le consentement administrateur de Microsoft Entra : c’est une décision de la structure, que seule une nouvelle demande à LexOpti retire. Si LexOpti désactive votre application, l’installation cesse d’agir et reprend quand elle est réactivée.

Une application installée sur le poste du membre et redirigée vers http://127.0.0.1 ou un schéma privé ne peut pas être installée pour une structure : rien ne prouve quel programme la demande, chaque membre confirme donc chaque autorisation. Une application limitée aux bacs à sable, ou dont l’accès en production n’est pas encore approuvé, ne s’installe que dans ses propres bacs à sable.

Une fois l’application installée pour la structure, le propriétaire ou un administrateur connecté à votre logiciel peut enrôler les personnes de la structure qui utilisent votre logiciel et travailleront dans LexOpti : POST /v1/members/enrolments, avec son jeton, une personne par appel (email, first_name, last_name, role member ou readonly, votre external_ref). LexOpti crée aussitôt le compte de la personne, décide son appartenance à la structure, et lui envoie un e-mail d’information (rien à cliquer). La réponse contient connect_hint : placez-le dans lexopti_hint sur le bouton « Connecter LexOpti » de cette personne.

Deux modes, choisis par la structure ; LexOpti passe de l’un à l’autre sur sa demande :

  • Mode nominatif : la personne enrôlée clique « Connecter LexOpti », son adresse est préremplie, elle saisit le code reçu, et c’est tout : son appartenance s’active, aucun écran de consentement (l’application est installée), elle revient avec son jeton. member.joined vous le dit.
  • Mode délégué (par défaut pour une application installée) : l’appartenance est active dès l’enrôlement (status: activated, member_id). Votre logiciel garde une seule connexion, celle du propriétaire ou d’un administrateur, et nomme le membre qui agit sur chaque requête avec l’en-tête X-LexOpti-Acting-User: <member_id>. LexOpti exécute la requête comme ce membre, avec son rôle (un membre en lecture seule n’écrit pas), et chaque ligne du journal porte « identité affirmée par <votre application> » : c’est votre logiciel qui dit qui agit, LexOpti ne l’a pas vérifié. POST /v1/embed-sessions avec cet en-tête ouvre les écrans embarqués pour le membre, sans connexion. Refus : delegated_mode_required (la structure a désactivé le mode), owner_or_admin_required (la connexion porteuse n’est pas celle d’un propriétaire ou d’un administrateur), unknown_acting_user (pas une personne que votre application a enrôlée dans cette structure, ou plus membre).
const
const lexopti: LexOptiClient
lexopti
=
function createLexOptiClient(options: LexOptiClientOptions): LexOptiClient

A typed client of the LexOpti API. Every idempotent POST gets an Idempotency-Key (kept across its retries); only requests safe to repeat are retried after a failure, with jittered backoff or Retry-After. Errors are oRPC errors: problemOf(error) reads the problem details.

createLexOptiClient
({
LexOptiClientOptions.accessToken: () => Promise<string> | string

Returns the OAuth access token for each request: refresh it there when it expires (access tokens live 15 minutes).

accessToken
});
const
const enrolment: {
id: string;
email: string;
first_name: string | null;
last_name: string | null;
role: "readonly" | "member";
external_ref: string | null;
status: "pending" | "expired" | "activated" | "cancelled";
member_id: string | null;
enrolled_by: string | null;
created_at: string;
expires_at: string;
activated_at: string | null;
connect_hint: string;
}
enrolment
= await
const lexopti: LexOptiClient
lexopti
.
enrolments: {
create: Client<Record<never, never>, {
email: string;
first_name?: string | undefined;
last_name?: string | undefined;
role?: "readonly" | "member" | undefined;
external_ref?: string | undefined;
locale?: "fr" | "en" | undefined;
}, {
id: string;
email: string;
first_name: string | null;
last_name: string | null;
role: "readonly" | "member";
external_ref: string | null;
status: "pending" | "expired" | "activated" | "cancelled";
member_id: string | null;
enrolled_by: string | null;
created_at: string;
expires_at: string;
activated_at: string | null;
connect_hint: string;
}, Error>;
list: Client<...>;
cancel: Client<...>;
}
enrolments
.
create: Client
(input: {
email: string;
first_name?: string | undefined;
last_name?: string | undefined;
role?: "readonly" | "member" | undefined;
external_ref?: string | undefined;
locale?: "fr" | "en" | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
email: string;
first_name: string | null;
last_name: string | null;
role: "readonly" | "member";
external_ref: string | null;
status: "pending" | "expired" | "activated" | "cancelled";
member_id: string | null;
enrolled_by: string | null;
created_at: string;
expires_at: string;
activated_at: string | null;
connect_hint: string;
}, Error>
create
({
email: string
email
: "camille.durand@durand-conseil.fr",
first_name?: string | undefined
first_name
: "Camille",
last_name?: string | undefined
last_name
: "Durand",
role?: "readonly" | "member" | undefined
role
: "member",
external_ref?: string | undefined
external_ref
: "crm:user:42",
});
// enrolment.status: "pending" (nominatif) ou "activated" (délégué, avec member_id)
// enrolment.connect_hint → lexopti_hint du bouton « Connecter LexOpti » de Camille

GET /v1/members/enrolments liste vos enrôlements et leur état (pending, activated, expired après trente jours, cancelled) ; DELETE /v1/members/enrolments/{id} annule un enrôlement encore en attente. Les événements member.enrolled et member.joined vous tiennent au courant. Refus : owner_or_admin_required, installation_required, already_member, enrolment_pending, seat_limit_reached (402).

Une fiche de votre logiciel (affaire, mandat, mission…) devient un dossier LexOpti avec POST /v1/cases : ses clients, des clients existants de la structure (par leur identifiant LexOpti, ou par votre référence : liez d’abord un contact), le principal en premier ; ses natures, parmi celles que propose la profession de la structure ; ses autres parties, personnes ou sociétés avec leur rôle et votre référence de chacune ; votre référence de la fiche. LexOpti le crée comme son écran « Nouveau dossier », le membre qui a autorisé votre application y étant affecté, et le facture comme l’écran le facture : un crédit par tranche de cinq personnes ou sociétés, un au moins, pour douze mois de vigilance. Rien n’est analysé : lancez les analyses ensuite (analyses), ou envoyez launch_checks: true pour lancer les analyses du dossier avec sa création quand cela ne coûte rien de plus.

Montrez d’abord le coût. POST /v1/cases/preview prend le même corps, le vérifie comme la création et n’écrit rien : credits.needed face à credits.balance, et sufficient_credits. Créez une fois que le membre a confirmé, sous une clé de votre fiche : une nouvelle tentative, ou un second clic, répond le même dossier. La création vérifie de nouveau le solde : quand les crédits ne la couvrent plus, elle répond 403 quota_exceeded et ne crée rien (subscription_inactive quand la structure n’a pas d’offre en cours). Une référence qui nomme déjà un dossier répond 409 external_ref_conflict : lisez ce dossier avec GET /v1/cases?external_ref=…. Une nature ou un rôle que la profession ne propose pas répond validation_failed, chaque champ nommé. Dans un bac à sable, les crédits sont calculés comme en production et jamais prélevés (livemode: false).

L’exemple crée le dossier d’une affaire : une vente immobilière (vente_immobiliere, une nature que proposent les avocats et les agents immobiliers) avec la société venderesse pour partie (vendeur). Envoyez plutôt les natures et les rôles de la profession de votre structure : une mission d’expert-comptable peut être tenue_comptable sans autre partie, un dossier de notaire une nature custom avec son intitulé (natures des dossiers, rôles des parties).

const
const matter: {
clients: {
id?: string | undefined;
external_ref?: string | undefined;
}[];
types: string[];
type_label?: string | undefined;
label?: string | undefined;
parties?: ({
type: "person";
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | ... 4 more ... | "autre";
person: {
...;
};
address?: {
...;
} | undefined;
external_ref?: string | undefined;
} | {
...;
})[] | undefined;
external_ref?: string | undefined;
launch_checks?: boolean | undefined;
}
matter
:
type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never

Obtain the parameters of a function type in a tuple

Parameters
<typeof
const lexopti: LexOptiClient
lexopti
.
cases: {
setPartyExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
party_id: string;
}, {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | ... 23 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}, Error>;
... 10 more ...;
listDocuments: Client<...>;
}
cases
.
create: Client<Record<never, never>, {
clients: {
id?: string | undefined;
external_ref?: string | undefined;
}[];
types: string[];
type_label?: string | undefined;
label?: string | undefined;
parties?: ({
type: "person";
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | ... 4 more ... | "autre";
person: {
...;
};
address?: {
...;
} | undefined;
external_ref?: string | undefined;
} | {
...;
})[] | undefined;
external_ref?: string | undefined;
launch_checks?: boolean | undefined;
}, {
...;
}, Error>
create
>[0] = {
clients: {
id?: string | undefined;
external_ref?: string | undefined;
}[]
clients
: [{
id?: string | undefined
id
:
const clientId: string
clientId
}],
types: string[]
types
: ["vente_immobiliere"],
parties?: ({
type: "person";
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | "constituant" | "fiduciaire" | "beneficiaire" | "tiers" | "autre";
person: {
...;
};
address?: {
...;
} | undefined;
external_ref?: string | undefined;
} | {
...;
})[] | undefined
parties
: [
{
type: "company"
type
: "company",
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | "constituant" | "fiduciaire" | "beneficiaire" | "tiers" | "autre"
role
: "vendeur",
company: {
name: string;
siren?: string | undefined;
siret?: string | undefined;
legal_form?: string | undefined;
registration_country?: string | undefined;
rcs?: string | undefined;
}
company
: {
name: string
name
: "SCI Horizon",
siren?: string | undefined
siren
: "552100554" },
},
],
external_ref?: string | undefined
external_ref
: "crm:matter:7",
};
const
const preview: {
credits: {
needed: number;
balance: number;
};
sufficient_credits: boolean;
tranches: number;
entities: number;
livemode: boolean;
}
preview
= await
const lexopti: LexOptiClient
lexopti
.
cases: {
setPartyExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
party_id: string;
}, {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | ... 23 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}, Error>;
... 10 more ...;
listDocuments: Client<...>;
}
cases
.
preview: Client
(input: {
clients: {
id?: string | undefined;
external_ref?: string | undefined;
}[];
types: string[];
type_label?: string | undefined;
label?: string | undefined;
parties?: ({
type: "person";
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | ... 4 more ... | "autre";
person: {
...;
};
address?: {
...;
} | undefined;
external_ref?: string | undefined;
} | {
...;
})[] | undefined;
external_ref?: string | undefined;
launch_checks?: boolean | undefined;
}, options?: FriendlyClientOptions<...> | undefined) => ClientPromiseResult<...>
preview
(
const matter: {
clients: {
id?: string | undefined;
external_ref?: string | undefined;
}[];
types: string[];
type_label?: string | undefined;
label?: string | undefined;
parties?: ({
type: "person";
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | ... 4 more ... | "autre";
person: {
...;
};
address?: {
...;
} | undefined;
external_ref?: string | undefined;
} | {
...;
})[] | undefined;
external_ref?: string | undefined;
launch_checks?: boolean | undefined;
}
matter
);
const
const confirmed: boolean
confirmed
=
const preview: {
credits: {
needed: number;
balance: number;
};
sufficient_credits: boolean;
tranches: number;
entities: number;
livemode: boolean;
}
preview
.
sufficient_credits: boolean
sufficient_credits
&&
(await
function confirmCost(needed: number, balance: number): Promise<boolean>
confirmCost
(
const preview: {
credits: {
needed: number;
balance: number;
};
sufficient_credits: boolean;
tranches: number;
entities: number;
livemode: boolean;
}
preview
.
credits: {
needed: number;
balance: number;
}
credits
.
needed: number
needed
,
const preview: {
credits: {
needed: number;
balance: number;
};
sufficient_credits: boolean;
tranches: number;
entities: number;
livemode: boolean;
}
preview
.
credits: {
needed: number;
balance: number;
}
credits
.
balance: number
balance
));
// Le SDK envoie la même Idempotency-Key à chaque nouvelle tentative de cet appel.
const
const created: {
...;
} | null
created
=
const confirmed: boolean
confirmed
? await
const lexopti: LexOptiClient
lexopti
.
cases: {
setPartyExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
party_id: string;
}, {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | ... 23 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}, Error>;
... 10 more ...;
listDocuments: Client<...>;
}
cases
.
create: Client
(input: {
clients: {
id?: string | undefined;
external_ref?: string | undefined;
}[];
types: string[];
type_label?: string | undefined;
label?: string | undefined;
parties?: ({
type: "person";
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | ... 4 more ... | "autre";
person: {
...;
};
address?: {
...;
} | undefined;
external_ref?: string | undefined;
} | {
...;
})[] | undefined;
external_ref?: string | undefined;
launch_checks?: boolean | undefined;
}, options?: FriendlyClientOptions<...> | undefined) => ClientPromiseResult<...>
create
(
const matter: {
clients: {
id?: string | undefined;
external_ref?: string | undefined;
}[];
types: string[];
type_label?: string | undefined;
label?: string | undefined;
parties?: ({
type: "person";
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | "preteur" | "emprunteur" | "caution" | "tiers_payeur" | "donateur" | "donataire" | "heritier_legataire" | "mandant" | "mandataire" | "representant_legal" | "intermediaire" | "associe" | ... 4 more ... | "autre";
person: {
...;
};
address?: {
...;
} | undefined;
external_ref?: string | undefined;
} | {
...;
})[] | undefined;
external_ref?: string | undefined;
launch_checks?: boolean | undefined;
}
matter
) : null;

La réponse est le dossier (201), avec credits_charged et analyses_launched. Vos points de réception reçoivent case.created, puis case.updated (changed_fields: parties) à mesure que ses parties la rejoignent, comme quand un membre la crée dans LexOpti. Le membre peut aussi créer le dossier lui-même dans votre page, dans le formulaire même de LexOpti : <lexopti-new-case>.

Quand une structure qui utilise votre logiciel (cabinet d’avocats, agence immobilière, cabinet d’expertise comptable…) n’est pas encore cliente de LexOpti, votre serveur peut la préparer dans LexOpti pour que son responsable la réclame : l’API appelle cette structure préparée une firm (/v1/firms). Rien n’existe dans LexOpti avant : LexOpti lui envoie par e-mail un lien d’activation, qui ouvre son inscription normale avec les informations de la structure déjà remplies. Le responsable les vérifie, ainsi que sa profession, accepte les conditions, démarre son essai ou paie, et prouve son e-mail par un code, comme toute personne qui s’inscrit ; LexOpti vérifie la profession comme pour toute structure. Alors seulement la structure devient une organisation, dont le responsable est propriétaire. Jusque-là, rien ne peut y être écrit, rien ne la liste ni ne la compte, et elle ne bloque rien.

Votre application demande son propre jeton : client credentials avec votre secret client, resource l’API, scope lexopti:firms. Aucun membre n’est derrière, et il ne sert que /v1/firms : le jeton d’un membre y est refusé, et celui-ci partout ailleurs. Seule une application autorisée en production l’obtient (unauthorized_client sinon), et une autorisation retirée l’arrête à son appel suivant (production_access_required). Il dure 15 minutes, sans jeton de rafraîchissement : demandez-en un autre.

const
const basic: string
basic
=
var Buffer: BufferConstructor
Buffer
.
BufferConstructor.from(string: WithImplicitCoercion<string>, encoding?: BufferEncoding): Buffer<ArrayBuffer> (+3 overloads)

Creates a new Buffer containing string. The encoding parameter identifies the character encoding to be used when converting string into bytes.

import { Buffer } from 'node:buffer';
const buf1 = Buffer.from('this is a tést');
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
console.log(buf1.toString());
// Prints: this is a tést
console.log(buf2.toString());
// Prints: this is a tést
console.log(buf1.toString('latin1'));
// Prints: this is a tést

A TypeError will be thrown if string is not a string or another type appropriate for Buffer.from() variants.

Buffer.from(string) may also use the internal Buffer pool like Buffer.allocUnsafe() does.

@since ― v5.10.0

@param ― string A string to encode.

@param ― encoding The encoding of string. Default: 'utf8'.

from
(
`${
function encodeURIComponent(uriComponent: string | number | boolean): string

Encodes a text string as a valid component of a Uniform Resource Identifier (URI).

@param ― uriComponent A value representing an unencoded URI component.

encodeURIComponent
(
const clientId: string
clientId
)}:${
function encodeURIComponent(uriComponent: string | number | boolean): string

Encodes a text string as a valid component of a Uniform Resource Identifier (URI).

@param ― uriComponent A value representing an unencoded URI component.

encodeURIComponent
(
const clientSecret: string
clientSecret
)}`
).
Buffer<ArrayBuffer>.toString(encoding?: BufferEncoding, start?: number, end?: number): string

Decodes buf to a string according to the specified character encoding inencoding. start and end may be passed to decode only a subset of buf.

If encoding is 'utf8' and a byte sequence in the input is not valid UTF-8, then each invalid byte is replaced with the replacement character U+FFFD.

The maximum length of a string instance (in UTF-16 code units) is available as

constants.MAX_STRING_LENGTH

.

import { Buffer } from 'node:buffer';
const buf1 = Buffer.allocUnsafe(26);
for (let i = 0; i < 26; i++) {
// 97 is the decimal ASCII value for 'a'.
buf1[i] = i + 97;
}
console.log(buf1.toString('utf8'));
// Prints: abcdefghijklmnopqrstuvwxyz
console.log(buf1.toString('utf8', 0, 5));
// Prints: abcde
const buf2 = Buffer.from('tést');
console.log(buf2.toString('hex'));
// Prints: 74c3a97374
console.log(buf2.toString('utf8', 0, 3));
// Prints: té
console.log(buf2.toString(undefined, 0, 3));
// Prints: té

@since ― v0.1.90

@param ― encoding The character encoding to use.

@param ― start The byte offset to start decoding at.

@param ― end The byte offset to stop decoding at (not inclusive).

toString
("base64");
const
const response: Response
response
= await
function fetch(input: string | URL | Request, init?: RequestInit): Promise<Response> (+1 overload)
fetch
("https://app.lexopti.com/api/auth/oauth2/token", {
RequestInit.body?: BodyInit | null | undefined

A BodyInit object or null to set request's body.

body
: new
var URLSearchParams: new (init?: string[][] | Record<string, string> | string | URLSearchParams) => URLSearchParams

The URLSearchParams interface defines utility methods to work with the query string of a URL.

MDN Reference

URLSearchParams class is a global reference for import { URLSearchParams } from 'node:url' https://nodejs.org/api/url.html#class-urlsearchparams

@since ― v10.0.0

URLSearchParams
({
grant_type: string
grant_type
: "client_credentials",
resource: string
resource
: "https://app.lexopti.com/v1",
scope: string
scope
: "lexopti:firms",
}),
RequestInit.headers?: HeadersInit | undefined

A Headers object, an object literal, or an array of two-item arrays to set request's headers.

headers
: {
authorization: string
authorization
: `Basic ${
const basic: string
basic
}` },
RequestInit.method?: string | undefined

A string to set request's method.

method
: "POST",
});
const
const application: {
access_token: string;
expires_in: number;
}
application
: {
access_token: string
access_token
: string;
expires_in: number
expires_in
: number } =
await
const response: Response
response
.
Body.json(): Promise<any>
json
();

Puis POST /v1/firms : le nom de la structure, son SIREN, sa profession, l’e-mail de son responsable (et son nom, si vous l’avez) et votre référence de cette structure, sous une clé de la structure : une nouvelle tentative répond la même structure, sans son lien. La réponse est la structure, pending, avec son claim_url, donné cette seule fois. L’exemple prépare une agence immobilière ; toute profession prise en charge fonctionne de la même façon. LexOpti envoie le lien au responsable par e-mail, dans la locale que vous donnez (fr par défaut). Vous pouvez aussi le montrer au responsable connecté à votre logiciel ; ne l’envoyez jamais vous-même, ni à personne d’autre. Seul un compte à l’adresse invitée peut réclamer la structure (une autre adresse est refusée), le lien ne sert qu’une fois, 7 jours au plus, et un compte développeur ne réclame jamais une structure.

const
const lexopti: LexOptiClient
lexopti
=
function createLexOptiClient(options: LexOptiClientOptions): LexOptiClient

A typed client of the LexOpti API. Every idempotent POST gets an Idempotency-Key (kept across its retries); only requests safe to repeat are retried after a failure, with jittered backoff or Retry-After. Errors are oRPC errors: problemOf(error) reads the problem details.

createLexOptiClient
({
LexOptiClientOptions.accessToken: () => Promise<string> | string

Returns the OAuth access token for each request: refresh it there when it expires (access tokens live 15 minutes).

accessToken
: () =>
function getAccessToken(): Promise<string>
getAccessToken
() });
// LexOpti envoie firm.claim_url au responsable : donné cette seule fois.
const
const firm: {
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
external_ref: string | null;
claim_url: string | null;
claim_url_expires_at: string | null;
expires_at: string;
created_at: string;
claimed_at: string | null;
activated_at: string | null;
organization_id: string | null;
}
firm
= await
const lexopti: LexOptiClient
lexopti
.
firms: {
create: Client<Record<never, never>, {
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
manager: {
email: string;
first_name?: string | undefined;
last_name?: string | undefined;
};
external_ref?: string | undefined;
locale?: "fr" | "en" | undefined;
}, {
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
external_ref: string | null;
claim_url: string | null;
claim_url_expires_at: string | null;
... 4 more ...;
organization_id: string | null;
}, Error>;
get: Client<...>;
createClaimLink: Client<...>;
}
firms
.
create: Client
(input: {
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
manager: {
email: string;
first_name?: string | undefined;
last_name?: string | undefined;
};
external_ref?: string | undefined;
locale?: "fr" | "en" | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
... 7 more ...;
organization_id: string | null;
}, Error>
create
({
name: string
name
: "Agence du Port",
siren: string
siren
: "732829320",
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated"
profession
: "real_estate",
manager: {
email: string;
first_name?: string | undefined;
last_name?: string | undefined;
}
manager
: {
email: string
email
: "gerante@agence-du-port.example",
first_name?: string | undefined
first_name
: "Claire" },
external_ref?: string | undefined
external_ref
: "crm:customer:12",
locale?: "fr" | "en" | undefined
locale
: "fr",
});

Un SIREN déjà client de LexOpti répond 409 firm_exists : la structure utilise déjà LexOpti, demandez donc à son responsable d’inviter votre utilisateur (« Demandez à votre responsable de vous inviter ») et connectez-le comme d’habitude (étape 2). Votre application garde une structure en attente par SIREN (firm_pending) et par référence (external_ref_conflict), 50 au plus à la fois (too_many_pending_firms). Une structure en attente ne bloque rien : si la structure s’inscrit d’elle-même avant, ou si la structure d’un autre partenaire au même SIREN est réclamée avant, la vôtre est voided. Jamais réclamée en 30 jours, elle est expired : l’e-mail du responsable est effacé.

Pour ramener le responsable connecté à votre logiciel à la fin de son inscription, lancez votre autorisation habituelle (étape 2) avec un paramètre de plus, lexopti_claim, le paramètre claim de claim_url : LexOpti ouvre directement l’inscription de la structure, puis l’autorisation reprend et votre callback reçoit le code, pour la nouvelle structure.

GET /v1/firms/{id} dit où en est la structure : pending, claimed (avec organization_id, l’id de GET /v1/organization dès que le responsable a autorisé votre application, et activated_at dès que son offre démarre), expired ou voided. Aucun webhook ne le dit : une structure en attente n’a pas encore de point de réception, interrogez-la donc, ou attendez votre callback. POST /v1/firms/{id}/claim-link émet un nouveau lien pour une structure en attente et l’envoie de nouveau par e-mail, une fois par minute au plus (rate_limited) ; le précédent cesse aussitôt de fonctionner.

const
const lexopti: LexOptiClient
lexopti
=
function createLexOptiClient(options: LexOptiClientOptions): LexOptiClient

A typed client of the LexOpti API. Every idempotent POST gets an Idempotency-Key (kept across its retries); only requests safe to repeat are retried after a failure, with jittered backoff or Retry-After. Errors are oRPC errors: problemOf(error) reads the problem details.

createLexOptiClient
({
LexOptiClientOptions.accessToken: () => Promise<string> | string

Returns the OAuth access token for each request: refresh it there when it expires (access tokens live 15 minutes).

accessToken
: () =>
function getAccessToken(): Promise<string>
getAccessToken
() });
const
const firm: {
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
external_ref: string | null;
claim_url: string | null;
claim_url_expires_at: string | null;
expires_at: string;
created_at: string;
claimed_at: string | null;
activated_at: string | null;
organization_id: string | null;
}
firm
= await
const lexopti: LexOptiClient
lexopti
.
firms: {
create: Client<Record<never, never>, {
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
manager: {
email: string;
first_name?: string | undefined;
last_name?: string | undefined;
};
external_ref?: string | undefined;
locale?: "fr" | "en" | undefined;
}, {
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
external_ref: string | null;
claim_url: string | null;
claim_url_expires_at: string | null;
... 4 more ...;
organization_id: string | null;
}, Error>;
get: Client<...>;
createClaimLink: Client<...>;
}
firms
.
get: Client
(input: {
id: string;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
external_ref: string | null;
claim_url: string | null;
claim_url_expires_at: string | null;
expires_at: string;
created_at: string;
claimed_at: string | null;
activated_at: string | null;
organization_id: string | null;
}, Error>
get
({
id: string
id
:
const firmId: string
firmId
});
// Un lien perdu ou expiré : un nouveau, de nouveau envoyé par e-mail.
const
const renewed: {
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
external_ref: string | null;
claim_url: string | null;
claim_url_expires_at: string | null;
expires_at: string;
created_at: string;
claimed_at: string | null;
activated_at: string | null;
organization_id: string | null;
} | null
renewed
=
const firm: {
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
external_ref: string | null;
claim_url: string | null;
claim_url_expires_at: string | null;
expires_at: string;
created_at: string;
claimed_at: string | null;
activated_at: string | null;
organization_id: string | null;
}
firm
.
status: "pending" | "claimed" | "expired" | "voided"
status
=== "pending"
? await
const lexopti: LexOptiClient
lexopti
.
firms: {
create: Client<Record<never, never>, {
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
manager: {
email: string;
first_name?: string | undefined;
last_name?: string | undefined;
};
external_ref?: string | undefined;
locale?: "fr" | "en" | undefined;
}, {
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
external_ref: string | null;
claim_url: string | null;
claim_url_expires_at: string | null;
... 4 more ...;
organization_id: string | null;
}, Error>;
get: Client<...>;
createClaimLink: Client<...>;
}
firms
.
createClaimLink: Client
(input: {
id: string;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
status: "pending" | "claimed" | "expired" | "voided";
name: string;
siren: string;
profession: "lawyer" | "real_estate" | "notary" | "accountant" | "other_regulated";
external_ref: string | null;
claim_url: string | null;
claim_url_expires_at: string | null;
expires_at: string;
created_at: string;
claimed_at: string | null;
activated_at: string | null;
organization_id: string | null;
}, Error>
createClaimLink
({
id: string
id
:
const firmId: string
firmId
})
: null;

La structure est attribuée à votre application (programme partenaires) dès que son offre démarre, son essai ou son premier paiement, jamais à sa création.