@transmitsecurity/platform-web-sdk 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/drs.d.ts CHANGED
@@ -13,27 +13,35 @@ type EventResponse = {
13
13
  type Recommendation = {
14
14
  type: RecommendationType;
15
15
  };
16
- type LightweightPayload = {
17
- clientId: string;
18
- deviceId: string;
19
- userId: string | null;
20
- sdkPlatform: 'mobile_web' | 'desktop_web';
21
- events: Array<Record<string, unknown>>;
22
- };
23
16
 
24
17
  interface ActionResponse {
18
+ /** The token return by the SDK when the action was reported */
25
19
  actionToken?: string;
26
20
  }
27
21
  interface InitOptions {
22
+ /** Opaque identifier of the user in your system */
28
23
  userId?: string;
29
24
  }
25
+ /**
26
+ * Initial parameters for SDK
27
+ */
30
28
  interface ConstructorOptions {
29
+ /** Print logs to console */
31
30
  verbose?: boolean;
31
+ /** Your server URL
32
+ * @required */
32
33
  serverPath: string;
34
+ /** Enable session token fetching
35
+ *
36
+ * Default value is false */
33
37
  enableSessionToken?: boolean;
38
+ /** First party server url for the identifiers migration
39
+ *
40
+ * Default value is undefined */
34
41
  firstPartyMigrationUrl?: string;
42
+ /** @internal
43
+ * Internal flag indicating this web_sdk instance has its own clientId separate from the Platform SDK root-level clientId */
35
44
  hasOwnClientId?: boolean;
36
- tier?: 'standard' | 'lightweight';
37
45
  }
38
46
  interface TransactionData {
39
47
  amount: number;
@@ -54,12 +62,27 @@ interface TransactionData {
54
62
  };
55
63
  }
56
64
  interface ActionEventOptions {
65
+ /** Any ID that could help relate the action with external context or session */
57
66
  correlationId?: string;
67
+ /** User ID of the not yet authenticated user, used to enhance risk and
68
+ * trust assessments. Once the user is authenticated,
69
+ * {@link TSAccountProtection.setAuthenticatedUser} should be called. */
58
70
  claimedUserId?: string;
71
+ /**
72
+ * The reported claimedUserId type (if provided), should not contain PII unless it is hashed.
73
+ * Supported values: email, phone_number, account_id, ssn, national_id, passport_number, drivers_license_number, other.
74
+ */
59
75
  claimedUserIdType?: string;
76
+ /**
77
+ * A transaction data-points object for transaction-monitoring
78
+ */
60
79
  transactionData?: TransactionData;
80
+ /**
81
+ * Custom attributes matching the schema previously defined in the Admin Portal
82
+ */
61
83
  customAttributes?: Record<string, string | number | boolean>;
62
84
  /**
85
+ * The fields below are supported for Enterprise-IAM sdk usage actions, added `ignore` for avoiding preseting this attribute in the docs
63
86
  * @ignore
64
87
  */
65
88
  publicKey?: string;
@@ -96,7 +119,6 @@ declare class TSAccountProtection {
96
119
  private identifiersMigrationEnabled;
97
120
  private firstPartyMigrationUrl;
98
121
  private hasOwnClientId;
99
- private tier;
100
122
  private validationManager;
101
123
  private storageManager;
102
124
  private eventsManager;
@@ -109,33 +131,58 @@ declare class TSAccountProtection {
109
131
  private logsReporter;
110
132
  private options;
111
133
  private clientId;
134
+ /**
135
+ *
136
+ Creates a new Account Protection SDK instance with your client context
137
+ @param clientId Your AccountProtection client identifier
138
+ @param options SDK configuration options
139
+ */
112
140
  constructor(clientId: string, options: ConstructorOptions);
113
141
  /** @ignore */
114
142
  constructor(serverPath: string, clientId: string);
115
143
  private generateDisabledToken;
116
144
  /**
117
145
  * @ignore
146
+ * @returns List of loaded actions that can be invoked
118
147
  */
119
148
  get actions(): string[];
120
149
  /** @ignore */
121
150
  getActions(): Promise<string[]>;
122
151
  getSessionToken(): Promise<any>;
123
- getPayload(): Promise<LightweightPayload>;
124
- clearQueue(): void;
152
+ /**
153
+ * Initializes the AccountProtection SDK, which starts automatically tracking and submitting info of the user journey
154
+ * @param options Init options
155
+ * @returns Indicates if the call succeeded
156
+ */
125
157
  init(options?: InitOptions | string): Promise<boolean>;
126
158
  private isInitialized;
127
- triggerActionEvent(actionType: string, options?: ActionEventOptions): Promise<ActionResponse>;
128
159
  /**
129
- * @ignore
160
+ * Reports a user action event to the SDK
161
+ * @param actionType Type of user action event that was predefined in the Transmit Security server
162
+ * @returns Indicates if the call succeeded
130
163
  */
131
- identifyUser(userId: string): Promise<boolean>;
164
+ triggerActionEvent(actionType: string, options?: ActionEventOptions): Promise<ActionResponse>;
132
165
  private updateUserId;
166
+ /**
167
+ * Sets the user context for all subsequent events in the browser session (or until the user is explicitly cleared)
168
+ * It should be set only after you've fully authenticated the user (including, for example, any 2FA that was required)
169
+ * @param userId Opaque identifier of the user in your system
170
+ * @param options Reserved for future use
171
+ * @returns Indicates if the call succeeded
172
+ */
133
173
  setAuthenticatedUser(userId: string, options?: {}): Promise<boolean>;
174
+ /**
175
+ * Clears the user context for all subsequent events in the browser session
176
+ * @param options Reserved for future use
177
+ * @returns Indicates if the call succeeded
178
+ */
134
179
  clearUser(options?: {}): Promise<boolean>;
135
180
  /**
136
- * @ignore
181
+ * Gets a secure session token that is signed with the device's private key
182
+ * @param actionType Optional action type to include in the token payload (default: null)
183
+ * @param expirationSeconds Optional expiration time in seconds (default: 300 seconds / 5 minutes)
184
+ * @returns A JWT-like token containing the backend session token and device information, signed with the device's private key
137
185
  */
138
- unidentifiedUser(): Promise<boolean>;
139
186
  getSecureSessionToken(actionType?: string | null, expirationSeconds?: number): Promise<string>;
140
187
  }
141
188
 
@@ -180,8 +227,6 @@ declare const getSessionToken: TSAccountProtection['getSessionToken'];
180
227
  */
181
228
  declare const getSecureSessionToken: TSAccountProtection['getSecureSessionToken'];
182
229
  /** @ignore */
183
- declare const getPayload: TSAccountProtection['getPayload'];
184
- /** @ignore */
185
230
  declare const __internal: {
186
231
  getDeviceId(): string;
187
232
  getClientId(): string;
@@ -191,4 +236,4 @@ declare const __internal: {
191
236
  declare const PACKAGE_VERSION: string;
192
237
  declare function initialize(config: any): void;
193
238
 
194
- export { ActionEventOptions, ActionResponse, LightweightPayload, PACKAGE_VERSION, __internal, clearUser, getActions, getPayload, getSecureSessionToken, getSessionToken, initialize, setAuthenticatedUser, triggerActionEvent };
239
+ export { ActionEventOptions, ActionResponse, PACKAGE_VERSION, __internal, clearUser, getActions, getSecureSessionToken, getSessionToken, initialize, setAuthenticatedUser, triggerActionEvent };