@cdot65/prisma-airs-sdk 0.6.6 → 0.6.8

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.8";
56701
+ declare const USER_AGENT = "PAN-AIRS/0.6.8-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";
@@ -56867,6 +56867,20 @@ declare class ProfilesClient {
56867
56867
  * @returns Paginated list of security profiles.
56868
56868
  */
56869
56869
  list(opts?: PaginationOptions): Promise<SecurityProfileListResponse>;
56870
+ /**
56871
+ * Get a security profile by UUID.
56872
+ * Fetches all profiles and filters — no dedicated API endpoint exists.
56873
+ * @param profileId - UUID of the profile to retrieve.
56874
+ * @returns The matching security profile.
56875
+ */
56876
+ get(profileId: string): Promise<SecurityProfile>;
56877
+ /**
56878
+ * Get a security profile by name.
56879
+ * Returns the highest-revision match (latest version).
56880
+ * @param profileName - Name of the profile to retrieve.
56881
+ * @returns The matching security profile with the highest revision.
56882
+ */
56883
+ getByName(profileName: string): Promise<SecurityProfile>;
56870
56884
  /**
56871
56885
  * Update an existing security profile.
56872
56886
  * @param profileId - UUID of the profile to update.
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.8";
56701
+ declare const USER_AGENT = "PAN-AIRS/0.6.8-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";
@@ -56867,6 +56867,20 @@ declare class ProfilesClient {
56867
56867
  * @returns Paginated list of security profiles.
56868
56868
  */
56869
56869
  list(opts?: PaginationOptions): Promise<SecurityProfileListResponse>;
56870
+ /**
56871
+ * Get a security profile by UUID.
56872
+ * Fetches all profiles and filters — no dedicated API endpoint exists.
56873
+ * @param profileId - UUID of the profile to retrieve.
56874
+ * @returns The matching security profile.
56875
+ */
56876
+ get(profileId: string): Promise<SecurityProfile>;
56877
+ /**
56878
+ * Get a security profile by name.
56879
+ * Returns the highest-revision match (latest version).
56880
+ * @param profileName - Name of the profile to retrieve.
56881
+ * @returns The matching security profile with the highest revision.
56882
+ */
56883
+ getByName(profileName: string): Promise<SecurityProfile>;
56870
56884
  /**
56871
56885
  * Update an existing security profile.
56872
56886
  * @param profileId - UUID of the profile to update.
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.8";
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;
@@ -2941,6 +2984,40 @@ var ProfilesClient = class {
2941
2984
  });
2942
2985
  return res.data;
2943
2986
  }
2987
+ /**
2988
+ * Get a security profile by UUID.
2989
+ * Fetches all profiles and filters — no dedicated API endpoint exists.
2990
+ * @param profileId - UUID of the profile to retrieve.
2991
+ * @returns The matching security profile.
2992
+ */
2993
+ async get(profileId) {
2994
+ const { ai_profiles } = await this.list();
2995
+ const profile = ai_profiles.find((p) => p.profile_id === profileId);
2996
+ if (!profile) {
2997
+ throw new AISecSDKException(
2998
+ `Profile not found: ${profileId}`,
2999
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3000
+ );
3001
+ }
3002
+ return profile;
3003
+ }
3004
+ /**
3005
+ * Get a security profile by name.
3006
+ * Returns the highest-revision match (latest version).
3007
+ * @param profileName - Name of the profile to retrieve.
3008
+ * @returns The matching security profile with the highest revision.
3009
+ */
3010
+ async getByName(profileName) {
3011
+ const { ai_profiles } = await this.list();
3012
+ const matches = ai_profiles.filter((p) => p.profile_name === profileName);
3013
+ if (matches.length === 0) {
3014
+ throw new AISecSDKException(
3015
+ `Profile not found: ${profileName}`,
3016
+ "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
3017
+ );
3018
+ }
3019
+ return matches.reduce((best, p) => (p.revision ?? 0) > (best.revision ?? 0) ? p : best);
3020
+ }
2944
3021
  /**
2945
3022
  * Update an existing security profile.
2946
3023
  * @param profileId - UUID of the profile to update.
@@ -3452,80 +3529,57 @@ var ManagementClient = class {
3452
3529
  scanLogs;
3453
3530
  oauth;
3454
3531
  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
3532
  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
3533
+ const { baseUrl, oauthClient, numRetries, tsgId } = resolveOAuthConfig({
3534
+ clientId: opts.clientId,
3535
+ clientSecret: opts.clientSecret,
3536
+ tsgId: opts.tsgId,
3537
+ baseUrl: apiEndpoint,
3538
+ numRetries: opts.numRetries,
3539
+ tokenEndpoint: opts.tokenEndpoint,
3540
+ primaryEnvPrefix: "PANW_MGMT"
3487
3541
  });
3488
3542
  this.profiles = new ProfilesClient({
3489
- baseUrl: apiEndpoint,
3543
+ baseUrl,
3490
3544
  oauthClient,
3491
3545
  tsgId,
3492
3546
  numRetries
3493
3547
  });
3494
3548
  this.topics = new TopicsClient({
3495
- baseUrl: apiEndpoint,
3549
+ baseUrl,
3496
3550
  oauthClient,
3497
3551
  tsgId,
3498
3552
  numRetries
3499
3553
  });
3500
3554
  this.apiKeys = new ApiKeysClient({
3501
- baseUrl: apiEndpoint,
3555
+ baseUrl,
3502
3556
  oauthClient,
3503
3557
  tsgId,
3504
3558
  numRetries
3505
3559
  });
3506
3560
  this.customerApps = new CustomerAppsClient({
3507
- baseUrl: apiEndpoint,
3561
+ baseUrl,
3508
3562
  oauthClient,
3509
3563
  tsgId,
3510
3564
  numRetries
3511
3565
  });
3512
3566
  this.dlpProfiles = new DlpProfilesClient({
3513
- baseUrl: apiEndpoint,
3567
+ baseUrl,
3514
3568
  oauthClient,
3515
3569
  numRetries
3516
3570
  });
3517
3571
  this.deploymentProfiles = new DeploymentProfilesClient({
3518
- baseUrl: apiEndpoint,
3572
+ baseUrl,
3519
3573
  oauthClient,
3520
3574
  numRetries
3521
3575
  });
3522
3576
  this.scanLogs = new ScanLogsClient({
3523
- baseUrl: apiEndpoint,
3577
+ baseUrl,
3524
3578
  oauthClient,
3525
3579
  numRetries
3526
3580
  });
3527
3581
  this.oauth = new OAuthManagementClient({
3528
- baseUrl: apiEndpoint,
3582
+ baseUrl,
3529
3583
  oauthClient,
3530
3584
  numRetries
3531
3585
  });
@@ -4141,55 +4195,34 @@ var ModelSecurityClient = class {
4141
4195
  oauthClient;
4142
4196
  numRetries;
4143
4197
  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
4198
  const dataEndpoint = opts.dataEndpoint ?? process.env[MODEL_SEC_DATA_ENDPOINT] ?? DEFAULT_MODEL_SEC_DATA_ENDPOINT;
4148
4199
  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
4200
+ const { oauthClient, numRetries } = resolveOAuthConfig({
4201
+ clientId: opts.clientId,
4202
+ clientSecret: opts.clientSecret,
4203
+ tsgId: opts.tsgId,
4204
+ baseUrl: mgmtEndpoint,
4205
+ numRetries: opts.numRetries,
4206
+ tokenEndpoint: opts.tokenEndpoint,
4207
+ primaryEnvPrefix: "PANW_MODEL_SEC",
4208
+ fallbackEnvPrefix: "PANW_MGMT"
4177
4209
  });
4210
+ this.oauthClient = oauthClient;
4178
4211
  this.mgmtEndpoint = mgmtEndpoint;
4179
4212
  this.numRetries = numRetries;
4180
4213
  this.scans = new ModelSecurityScansClient({
4181
4214
  baseUrl: dataEndpoint,
4182
- oauthClient: this.oauthClient,
4215
+ oauthClient,
4183
4216
  numRetries
4184
4217
  });
4185
4218
  this.securityGroups = new ModelSecurityGroupsClient({
4186
4219
  baseUrl: mgmtEndpoint,
4187
- oauthClient: this.oauthClient,
4220
+ oauthClient,
4188
4221
  numRetries
4189
4222
  });
4190
4223
  this.securityRules = new ModelSecurityRulesClient({
4191
4224
  baseUrl: mgmtEndpoint,
4192
- oauthClient: this.oauthClient,
4225
+ oauthClient,
4193
4226
  numRetries
4194
4227
  });
4195
4228
  }
@@ -5341,61 +5374,45 @@ var RedTeamClient = class {
5341
5374
  oauthClient;
5342
5375
  numRetries;
5343
5376
  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
5377
  const dataEndpoint = opts.dataEndpoint ?? process.env[RED_TEAM_DATA_ENDPOINT] ?? DEFAULT_RED_TEAM_DATA_ENDPOINT;
5348
5378
  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 });
5379
+ const { oauthClient, numRetries } = resolveOAuthConfig({
5380
+ clientId: opts.clientId,
5381
+ clientSecret: opts.clientSecret,
5382
+ tsgId: opts.tsgId,
5383
+ baseUrl: dataEndpoint,
5384
+ numRetries: opts.numRetries,
5385
+ tokenEndpoint: opts.tokenEndpoint,
5386
+ primaryEnvPrefix: "PANW_RED_TEAM",
5387
+ fallbackEnvPrefix: "PANW_MGMT"
5388
+ });
5389
+ this.oauthClient = oauthClient;
5373
5390
  this.dataEndpoint = dataEndpoint;
5374
5391
  this.mgmtEndpoint = mgmtEndpoint;
5375
5392
  this.numRetries = numRetries;
5376
5393
  this.scans = new RedTeamScansClient({
5377
5394
  baseUrl: dataEndpoint,
5378
- oauthClient: this.oauthClient,
5395
+ oauthClient,
5379
5396
  numRetries
5380
5397
  });
5381
5398
  this.reports = new RedTeamReportsClient({
5382
5399
  baseUrl: dataEndpoint,
5383
- oauthClient: this.oauthClient,
5400
+ oauthClient,
5384
5401
  numRetries
5385
5402
  });
5386
5403
  this.customAttackReports = new RedTeamCustomAttackReportsClient({
5387
5404
  baseUrl: dataEndpoint,
5388
- oauthClient: this.oauthClient,
5405
+ oauthClient,
5389
5406
  numRetries
5390
5407
  });
5391
5408
  this.targets = new RedTeamTargetsClient({
5392
5409
  baseUrl: mgmtEndpoint,
5393
- oauthClient: this.oauthClient,
5410
+ oauthClient,
5394
5411
  numRetries
5395
5412
  });
5396
5413
  this.customAttacks = new RedTeamCustomAttacksClient({
5397
5414
  baseUrl: mgmtEndpoint,
5398
- oauthClient: this.oauthClient,
5415
+ oauthClient,
5399
5416
  numRetries
5400
5417
  });
5401
5418
  }