Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add DFP endpoints #348

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dist/b2b/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/b2c/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions dist/b2c/fraud.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions dist/b2c/fraud_fingerprint.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions dist/b2c/fraud_rules.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/shared/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions dist/shared/envs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dist/shared/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/b2b/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as jose from "jose";
import { BaseClient, ClientConfig } from "../shared/client";
import { Discovery } from "./discovery";
import { Fraud } from "../b2c/fraud";
import { JwtConfig } from "../shared/sessions";
import { M2M } from "../b2c/m2m";
import { MagicLinks } from "./magic_links";
Expand All @@ -20,6 +21,7 @@ import { TOTPs } from "./totps";
export class B2BClient extends BaseClient {
protected jwtConfig: JwtConfig;
discovery: Discovery;
fraud: Fraud;
m2m: M2M;
magicLinks: MagicLinks;
oauth: OAuth;
Expand Down Expand Up @@ -52,6 +54,7 @@ export class B2BClient extends BaseClient {
const policyCache = new PolicyCache(new RBAC(this.fetchConfig));

this.discovery = new Discovery(this.fetchConfig);
this.fraud = new Fraud(this.fetchConfig);
this.m2m = new M2M(this.fetchConfig, this.jwtConfig);
this.magicLinks = new MagicLinks(this.fetchConfig);
this.oauth = new OAuth(this.fetchConfig);
Expand Down
3 changes: 3 additions & 0 deletions lib/b2c/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as jose from "jose";
import { BaseClient, ClientConfig } from "../shared/client";
import { CryptoWallets } from "./crypto_wallets";
import { Fraud } from "./fraud";
import { JwtConfig } from "../shared/sessions";
import { M2M } from "./m2m";
import { MagicLinks } from "./magic_links";
Expand All @@ -16,6 +17,7 @@ import { WebAuthn } from "./webauthn";
export class Client extends BaseClient {
protected jwtConfig: JwtConfig;
cryptoWallets: CryptoWallets;
fraud: Fraud;
m2m: M2M;
magicLinks: MagicLinks;
oauth: OAuth;
Expand Down Expand Up @@ -43,6 +45,7 @@ export class Client extends BaseClient {
};

this.cryptoWallets = new CryptoWallets(this.fetchConfig);
this.fraud = new Fraud(this.fetchConfig);
this.m2m = new M2M(this.fetchConfig, this.jwtConfig);
this.magicLinks = new MagicLinks(this.fetchConfig);
this.oauth = new OAuth(this.fetchConfig);
Expand Down
115 changes: 115 additions & 0 deletions lib/b2c/fraud.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!

import {} from "../shared/method_options";
import { fetchConfig } from "../shared";
import { Fingerprint } from "./fraud_fingerprint";
import { Rules } from "./fraud_rules";

export interface ASNProperties {
// The Autonomous System Number of the user's network.
asn: string;
// Public name associated with the ASN.
name: string;
// The CIDR block associated with the ASN.
network: string;
}

export interface BrowserProperties {
// The user agent of the user's browser.
user_agent: string;
}

export interface Fingerprints {
// Combination of signals associated with a specific network commonly known as TLS fingerprinting.
network_fingerprint: string;
// Combinations of signals to identify an operating system and architecture.
hardware_fingerprint: string;
// Combination of signals to identify a browser and its specific version.
browser_fingerprint: string;
// Cookie-less way of identifying a unique user.
visitor_fingerprint: string;
// The cookie stored on the user's device that uniquely identifies them.
visitor_id?: string;
// Combination of VisitorID and NetworkFingerprint to create a clear identifier of a browser.
browser_id?: string;
}

export interface IPGeoProperties {
// The city where the IP is located.
city: string;
// The region where the IP is located.
region: string;
// The country where the IP is located.
country: string;
}

export interface Metadata {
// An external ID, such as a user ID, that you wish to associate with the telemetry ID.
external_id?: string;
// The organization ID you wish to associate with the telemetry ID.
organization_id?: string;
// The user action, such as 'login', that you wish to associate with the telemetry ID.
user_action?: string;
}

export interface NetworkProperties {
// The IP address of the user.
ip_address: string;
// Information about the network's ASN (Autonomous System Number).
asn: ASNProperties;
// Information about the geolocation of the user's IP address.
ip_geolocation: IPGeoProperties;
// Whether the user is using a proxy.
is_proxy: boolean;
// Whether the user is using a VPN.
is_vpn: boolean;
}

export interface Properties {
network_properties: NetworkProperties;
browser_properties: BrowserProperties;
}

export interface Verdict {
/**
* The suggested action based on the fingerprint review. The available actions are:
* * `ALLOW` - This is a known valid device grouping or device profile that is part of the default ALLOW
* listed set of known devices by Stytch. This grouping is made up of verified device profiles that match
* the characteristics of known/authentic traffic origins
* * `BLOCK` - This is a known bad or malicious device profile that is undesirable and should be blocked
* from completing the privileged action in question
* * `CHALLENGE` - This is an unknown or potentially malicious device that should be put through
* increased friction such as 2FA or other forms of extended user verification before allowing the
* privileged action to proceed
*
*/
action: "ALLOW" | "CHALLENGE" | "BLOCK" | string;
/**
* A set of contextual clues to inform why a `CHALLENGE` or `BLOCK` action was suggested. For a list of
* possible Reasons, please [contact support](mailto:[email protected]).
*/
reasons: string[];
// The operating system and architecture that took the fingerprint.
detected_device_type: string;
/**
* The assessment of whether this is an authentic device. It will be false if hardware or browser deception
* is detected.
*/
is_authentic_device: boolean;
}

export class Fraud {
private fetchConfig: fetchConfig;
fingerprint: Fingerprint;
rules: Rules;

constructor(fetchConfig: fetchConfig) {
this.fetchConfig = fetchConfig;
this.fingerprint = new Fingerprint(this.fetchConfig);
this.rules = new Rules(this.fetchConfig);
}
}
Loading
Loading