@cdot65/prisma-airs-sdk 0.6.6 → 0.6.7

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/index.d.cts CHANGED
@@ -56697,8 +56697,8 @@ declare const MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
56697
56697
  declare const MAX_CONNECTION_POOL_SIZE = 100;
56698
56698
  declare const MAX_NUMBER_OF_RETRIES = 5;
56699
56699
  declare const HTTP_FORCE_RETRY_STATUS_CODES: number[];
56700
- declare const SDK_VERSION = "0.6.6";
56701
- declare const USER_AGENT = "PAN-AIRS/0.6.6-typescript-sdk";
56700
+ declare const SDK_VERSION = "0.6.7";
56701
+ declare const USER_AGENT = "PAN-AIRS/0.6.7-typescript-sdk";
56702
56702
  declare const DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
56703
56703
  declare const DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
56704
56704
  declare const MGMT_CLIENT_ID = "PANW_MGMT_CLIENT_ID";
package/dist/index.d.ts CHANGED
@@ -56697,8 +56697,8 @@ declare const MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
56697
56697
  declare const MAX_CONNECTION_POOL_SIZE = 100;
56698
56698
  declare const MAX_NUMBER_OF_RETRIES = 5;
56699
56699
  declare const HTTP_FORCE_RETRY_STATUS_CODES: number[];
56700
- declare const SDK_VERSION = "0.6.6";
56701
- declare const USER_AGENT = "PAN-AIRS/0.6.6-typescript-sdk";
56700
+ declare const SDK_VERSION = "0.6.7";
56701
+ declare const USER_AGENT = "PAN-AIRS/0.6.7-typescript-sdk";
56702
56702
  declare const DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
56703
56703
  declare const DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
56704
56704
  declare const MGMT_CLIENT_ID = "PANW_MGMT_CLIENT_ID";
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
29
29
  var MAX_CONNECTION_POOL_SIZE = 100;
30
30
  var MAX_NUMBER_OF_RETRIES = 5;
31
31
  var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
32
- var SDK_VERSION = "0.6.6";
32
+ var SDK_VERSION = "0.6.7";
33
33
  var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
34
34
  var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
35
35
  var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
@@ -2847,6 +2847,49 @@ var OAuthClient = class {
2847
2847
  }
2848
2848
  };
2849
2849
 
2850
+ // src/oauth-config.ts
2851
+ function resolveOAuthConfig(opts) {
2852
+ const { primaryEnvPrefix, fallbackEnvPrefix } = opts;
2853
+ const clientId = opts.clientId ?? process.env[`${primaryEnvPrefix}_CLIENT_ID`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_CLIENT_ID`] : void 0);
2854
+ const clientSecret = opts.clientSecret ?? process.env[`${primaryEnvPrefix}_CLIENT_SECRET`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_CLIENT_SECRET`] : void 0);
2855
+ const tsgId = opts.tsgId ?? process.env[`${primaryEnvPrefix}_TSG_ID`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_TSG_ID`] : void 0);
2856
+ const tokenEndpoint = opts.tokenEndpoint ?? process.env[`${primaryEnvPrefix}_TOKEN_ENDPOINT`] ?? (fallbackEnvPrefix ? process.env[`${fallbackEnvPrefix}_TOKEN_ENDPOINT`] : void 0);
2857
+ const numRetries = Math.min(
2858
+ Math.max(opts.numRetries ?? MAX_NUMBER_OF_RETRIES, 0),
2859
+ MAX_NUMBER_OF_RETRIES
2860
+ );
2861
+ const envHint = fallbackEnvPrefix ? `${primaryEnvPrefix}_CLIENT_ID / ${fallbackEnvPrefix}_CLIENT_ID` : `${primaryEnvPrefix}_CLIENT_ID`;
2862
+ if (!clientId) {
2863
+ throw new AISecSDKException(
2864
+ `clientId is required (option or ${envHint} env var)`,
2865
+ "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
2866
+ );
2867
+ }
2868
+ const secretHint = fallbackEnvPrefix ? `${primaryEnvPrefix}_CLIENT_SECRET / ${fallbackEnvPrefix}_CLIENT_SECRET` : `${primaryEnvPrefix}_CLIENT_SECRET`;
2869
+ if (!clientSecret) {
2870
+ throw new AISecSDKException(
2871
+ `clientSecret is required (option or ${secretHint} env var)`,
2872
+ "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
2873
+ );
2874
+ }
2875
+ const tsgHint = fallbackEnvPrefix ? `${primaryEnvPrefix}_TSG_ID / ${fallbackEnvPrefix}_TSG_ID` : `${primaryEnvPrefix}_TSG_ID`;
2876
+ if (!tsgId) {
2877
+ throw new AISecSDKException(
2878
+ `tsgId is required (option or ${tsgHint} env var)`,
2879
+ "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
2880
+ );
2881
+ }
2882
+ const oauthClient = new OAuthClient({
2883
+ clientId,
2884
+ clientSecret,
2885
+ tsgId,
2886
+ tokenEndpoint,
2887
+ tokenBufferMs: opts.tokenBufferMs,
2888
+ onTokenRefresh: opts.onTokenRefresh
2889
+ });
2890
+ return { baseUrl: opts.baseUrl, oauthClient, numRetries, tsgId };
2891
+ }
2892
+
2850
2893
  // src/management/management-http-client.ts
2851
2894
  async function managementHttpRequest(opts) {
2852
2895
  const { method, baseUrl, path, body, params, oauthClient, numRetries } = opts;
@@ -3452,80 +3495,57 @@ var ManagementClient = class {
3452
3495
  scanLogs;
3453
3496
  oauth;
3454
3497
  constructor(opts = {}) {
3455
- const clientId = opts.clientId ?? process.env[MGMT_CLIENT_ID];
3456
- const clientSecret = opts.clientSecret ?? process.env[MGMT_CLIENT_SECRET];
3457
- const tsgId = opts.tsgId ?? process.env[MGMT_TSG_ID];
3458
3498
  const apiEndpoint = opts.apiEndpoint ?? process.env[MGMT_ENDPOINT] ?? DEFAULT_MGMT_ENDPOINT;
3459
- const tokenEndpoint = opts.tokenEndpoint ?? process.env[MGMT_TOKEN_ENDPOINT];
3460
- const numRetries = Math.min(
3461
- Math.max(opts.numRetries ?? MAX_NUMBER_OF_RETRIES, 0),
3462
- MAX_NUMBER_OF_RETRIES
3463
- );
3464
- if (!clientId) {
3465
- throw new AISecSDKException(
3466
- "clientId is required (option or PANW_MGMT_CLIENT_ID env var)",
3467
- "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
3468
- );
3469
- }
3470
- if (!clientSecret) {
3471
- throw new AISecSDKException(
3472
- "clientSecret is required (option or PANW_MGMT_CLIENT_SECRET env var)",
3473
- "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
3474
- );
3475
- }
3476
- if (!tsgId) {
3477
- throw new AISecSDKException(
3478
- "tsgId is required (option or PANW_MGMT_TSG_ID env var)",
3479
- "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
3480
- );
3481
- }
3482
- const oauthClient = new OAuthClient({
3483
- clientId,
3484
- clientSecret,
3485
- tsgId,
3486
- tokenEndpoint
3499
+ const { baseUrl, oauthClient, numRetries, tsgId } = resolveOAuthConfig({
3500
+ clientId: opts.clientId,
3501
+ clientSecret: opts.clientSecret,
3502
+ tsgId: opts.tsgId,
3503
+ baseUrl: apiEndpoint,
3504
+ numRetries: opts.numRetries,
3505
+ tokenEndpoint: opts.tokenEndpoint,
3506
+ primaryEnvPrefix: "PANW_MGMT"
3487
3507
  });
3488
3508
  this.profiles = new ProfilesClient({
3489
- baseUrl: apiEndpoint,
3509
+ baseUrl,
3490
3510
  oauthClient,
3491
3511
  tsgId,
3492
3512
  numRetries
3493
3513
  });
3494
3514
  this.topics = new TopicsClient({
3495
- baseUrl: apiEndpoint,
3515
+ baseUrl,
3496
3516
  oauthClient,
3497
3517
  tsgId,
3498
3518
  numRetries
3499
3519
  });
3500
3520
  this.apiKeys = new ApiKeysClient({
3501
- baseUrl: apiEndpoint,
3521
+ baseUrl,
3502
3522
  oauthClient,
3503
3523
  tsgId,
3504
3524
  numRetries
3505
3525
  });
3506
3526
  this.customerApps = new CustomerAppsClient({
3507
- baseUrl: apiEndpoint,
3527
+ baseUrl,
3508
3528
  oauthClient,
3509
3529
  tsgId,
3510
3530
  numRetries
3511
3531
  });
3512
3532
  this.dlpProfiles = new DlpProfilesClient({
3513
- baseUrl: apiEndpoint,
3533
+ baseUrl,
3514
3534
  oauthClient,
3515
3535
  numRetries
3516
3536
  });
3517
3537
  this.deploymentProfiles = new DeploymentProfilesClient({
3518
- baseUrl: apiEndpoint,
3538
+ baseUrl,
3519
3539
  oauthClient,
3520
3540
  numRetries
3521
3541
  });
3522
3542
  this.scanLogs = new ScanLogsClient({
3523
- baseUrl: apiEndpoint,
3543
+ baseUrl,
3524
3544
  oauthClient,
3525
3545
  numRetries
3526
3546
  });
3527
3547
  this.oauth = new OAuthManagementClient({
3528
- baseUrl: apiEndpoint,
3548
+ baseUrl,
3529
3549
  oauthClient,
3530
3550
  numRetries
3531
3551
  });
@@ -4141,55 +4161,34 @@ var ModelSecurityClient = class {
4141
4161
  oauthClient;
4142
4162
  numRetries;
4143
4163
  constructor(opts = {}) {
4144
- const clientId = opts.clientId ?? process.env[MODEL_SEC_CLIENT_ID] ?? process.env[MGMT_CLIENT_ID];
4145
- const clientSecret = opts.clientSecret ?? process.env[MODEL_SEC_CLIENT_SECRET] ?? process.env[MGMT_CLIENT_SECRET];
4146
- const tsgId = opts.tsgId ?? process.env[MODEL_SEC_TSG_ID] ?? process.env[MGMT_TSG_ID];
4147
4164
  const dataEndpoint = opts.dataEndpoint ?? process.env[MODEL_SEC_DATA_ENDPOINT] ?? DEFAULT_MODEL_SEC_DATA_ENDPOINT;
4148
4165
  const mgmtEndpoint = opts.mgmtEndpoint ?? process.env[MODEL_SEC_MGMT_ENDPOINT] ?? DEFAULT_MODEL_SEC_MGMT_ENDPOINT;
4149
- const tokenEndpoint = opts.tokenEndpoint ?? process.env[MODEL_SEC_TOKEN_ENDPOINT] ?? process.env[MGMT_TOKEN_ENDPOINT];
4150
- const numRetries = Math.min(
4151
- Math.max(opts.numRetries ?? MAX_NUMBER_OF_RETRIES, 0),
4152
- MAX_NUMBER_OF_RETRIES
4153
- );
4154
- if (!clientId) {
4155
- throw new AISecSDKException(
4156
- "clientId is required (option or PANW_MODEL_SEC_CLIENT_ID / PANW_MGMT_CLIENT_ID env var)",
4157
- "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
4158
- );
4159
- }
4160
- if (!clientSecret) {
4161
- throw new AISecSDKException(
4162
- "clientSecret is required (option or PANW_MODEL_SEC_CLIENT_SECRET / PANW_MGMT_CLIENT_SECRET env var)",
4163
- "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
4164
- );
4165
- }
4166
- if (!tsgId) {
4167
- throw new AISecSDKException(
4168
- "tsgId is required (option or PANW_MODEL_SEC_TSG_ID / PANW_MGMT_TSG_ID env var)",
4169
- "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
4170
- );
4171
- }
4172
- this.oauthClient = new OAuthClient({
4173
- clientId,
4174
- clientSecret,
4175
- tsgId,
4176
- tokenEndpoint
4166
+ const { oauthClient, numRetries } = resolveOAuthConfig({
4167
+ clientId: opts.clientId,
4168
+ clientSecret: opts.clientSecret,
4169
+ tsgId: opts.tsgId,
4170
+ baseUrl: mgmtEndpoint,
4171
+ numRetries: opts.numRetries,
4172
+ tokenEndpoint: opts.tokenEndpoint,
4173
+ primaryEnvPrefix: "PANW_MODEL_SEC",
4174
+ fallbackEnvPrefix: "PANW_MGMT"
4177
4175
  });
4176
+ this.oauthClient = oauthClient;
4178
4177
  this.mgmtEndpoint = mgmtEndpoint;
4179
4178
  this.numRetries = numRetries;
4180
4179
  this.scans = new ModelSecurityScansClient({
4181
4180
  baseUrl: dataEndpoint,
4182
- oauthClient: this.oauthClient,
4181
+ oauthClient,
4183
4182
  numRetries
4184
4183
  });
4185
4184
  this.securityGroups = new ModelSecurityGroupsClient({
4186
4185
  baseUrl: mgmtEndpoint,
4187
- oauthClient: this.oauthClient,
4186
+ oauthClient,
4188
4187
  numRetries
4189
4188
  });
4190
4189
  this.securityRules = new ModelSecurityRulesClient({
4191
4190
  baseUrl: mgmtEndpoint,
4192
- oauthClient: this.oauthClient,
4191
+ oauthClient,
4193
4192
  numRetries
4194
4193
  });
4195
4194
  }
@@ -5341,61 +5340,45 @@ var RedTeamClient = class {
5341
5340
  oauthClient;
5342
5341
  numRetries;
5343
5342
  constructor(opts = {}) {
5344
- const clientId = opts.clientId ?? process.env[RED_TEAM_CLIENT_ID] ?? process.env[MGMT_CLIENT_ID];
5345
- const clientSecret = opts.clientSecret ?? process.env[RED_TEAM_CLIENT_SECRET] ?? process.env[MGMT_CLIENT_SECRET];
5346
- const tsgId = opts.tsgId ?? process.env[RED_TEAM_TSG_ID] ?? process.env[MGMT_TSG_ID];
5347
5343
  const dataEndpoint = opts.dataEndpoint ?? process.env[RED_TEAM_DATA_ENDPOINT] ?? DEFAULT_RED_TEAM_DATA_ENDPOINT;
5348
5344
  const mgmtEndpoint = opts.mgmtEndpoint ?? process.env[RED_TEAM_MGMT_ENDPOINT] ?? DEFAULT_RED_TEAM_MGMT_ENDPOINT;
5349
- const tokenEndpoint = opts.tokenEndpoint ?? process.env[RED_TEAM_TOKEN_ENDPOINT] ?? process.env[MGMT_TOKEN_ENDPOINT];
5350
- const numRetries = Math.min(
5351
- Math.max(opts.numRetries ?? MAX_NUMBER_OF_RETRIES, 0),
5352
- MAX_NUMBER_OF_RETRIES
5353
- );
5354
- if (!clientId) {
5355
- throw new AISecSDKException(
5356
- "clientId is required (option or PANW_RED_TEAM_CLIENT_ID / PANW_MGMT_CLIENT_ID env var)",
5357
- "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
5358
- );
5359
- }
5360
- if (!clientSecret) {
5361
- throw new AISecSDKException(
5362
- "clientSecret is required (option or PANW_RED_TEAM_CLIENT_SECRET / PANW_MGMT_CLIENT_SECRET env var)",
5363
- "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
5364
- );
5365
- }
5366
- if (!tsgId) {
5367
- throw new AISecSDKException(
5368
- "tsgId is required (option or PANW_RED_TEAM_TSG_ID / PANW_MGMT_TSG_ID env var)",
5369
- "AISEC_MISSING_VARIABLE" /* MISSING_VARIABLE */
5370
- );
5371
- }
5372
- this.oauthClient = new OAuthClient({ clientId, clientSecret, tsgId, tokenEndpoint });
5345
+ const { oauthClient, numRetries } = resolveOAuthConfig({
5346
+ clientId: opts.clientId,
5347
+ clientSecret: opts.clientSecret,
5348
+ tsgId: opts.tsgId,
5349
+ baseUrl: dataEndpoint,
5350
+ numRetries: opts.numRetries,
5351
+ tokenEndpoint: opts.tokenEndpoint,
5352
+ primaryEnvPrefix: "PANW_RED_TEAM",
5353
+ fallbackEnvPrefix: "PANW_MGMT"
5354
+ });
5355
+ this.oauthClient = oauthClient;
5373
5356
  this.dataEndpoint = dataEndpoint;
5374
5357
  this.mgmtEndpoint = mgmtEndpoint;
5375
5358
  this.numRetries = numRetries;
5376
5359
  this.scans = new RedTeamScansClient({
5377
5360
  baseUrl: dataEndpoint,
5378
- oauthClient: this.oauthClient,
5361
+ oauthClient,
5379
5362
  numRetries
5380
5363
  });
5381
5364
  this.reports = new RedTeamReportsClient({
5382
5365
  baseUrl: dataEndpoint,
5383
- oauthClient: this.oauthClient,
5366
+ oauthClient,
5384
5367
  numRetries
5385
5368
  });
5386
5369
  this.customAttackReports = new RedTeamCustomAttackReportsClient({
5387
5370
  baseUrl: dataEndpoint,
5388
- oauthClient: this.oauthClient,
5371
+ oauthClient,
5389
5372
  numRetries
5390
5373
  });
5391
5374
  this.targets = new RedTeamTargetsClient({
5392
5375
  baseUrl: mgmtEndpoint,
5393
- oauthClient: this.oauthClient,
5376
+ oauthClient,
5394
5377
  numRetries
5395
5378
  });
5396
5379
  this.customAttacks = new RedTeamCustomAttacksClient({
5397
5380
  baseUrl: mgmtEndpoint,
5398
- oauthClient: this.oauthClient,
5381
+ oauthClient,
5399
5382
  numRetries
5400
5383
  });
5401
5384
  }