@cdot65/prisma-airs-sdk 0.4.0 → 0.5.0
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.cjs +50 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/index.js +49 -4
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.d.cts
CHANGED
|
@@ -32816,8 +32816,8 @@ declare const MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
|
|
|
32816
32816
|
declare const MAX_CONNECTION_POOL_SIZE = 100;
|
|
32817
32817
|
declare const MAX_NUMBER_OF_RETRIES = 5;
|
|
32818
32818
|
declare const HTTP_FORCE_RETRY_STATUS_CODES: number[];
|
|
32819
|
-
declare const SDK_VERSION = "0.
|
|
32820
|
-
declare const USER_AGENT = "PAN-AIRS/0.
|
|
32819
|
+
declare const SDK_VERSION = "0.5.0";
|
|
32820
|
+
declare const USER_AGENT = "PAN-AIRS/0.5.0-typescript-sdk";
|
|
32821
32821
|
declare const DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
32822
32822
|
declare const DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
32823
32823
|
declare const MGMT_CLIENT_ID = "PANW_MGMT_CLIENT_ID";
|
|
@@ -32870,6 +32870,21 @@ declare const RED_TEAM_TARGET_PATH = "/v1/target";
|
|
|
32870
32870
|
declare const RED_TEAM_CUSTOM_ATTACK_PATH = "/v1/custom-attack";
|
|
32871
32871
|
declare const RED_TEAM_MGMT_DASHBOARD_PATH = "/v1/dashboard/overview";
|
|
32872
32872
|
|
|
32873
|
+
/** Snapshot of the current token state (never exposes the actual token). */
|
|
32874
|
+
interface TokenInfo {
|
|
32875
|
+
/** Whether a token has been fetched. */
|
|
32876
|
+
hasToken: boolean;
|
|
32877
|
+
/** Whether the token is valid (not expired and outside the pre-expiry buffer). */
|
|
32878
|
+
isValid: boolean;
|
|
32879
|
+
/** Whether the token has passed its expiry time. */
|
|
32880
|
+
isExpired: boolean;
|
|
32881
|
+
/** Whether the token is within the pre-expiry buffer window. */
|
|
32882
|
+
isExpiringSoon: boolean;
|
|
32883
|
+
/** Milliseconds until the token expires (0 if expired or no token). */
|
|
32884
|
+
expiresInMs: number;
|
|
32885
|
+
/** Unix timestamp (ms) when the token expires (0 if no token). */
|
|
32886
|
+
expiresAt: number;
|
|
32887
|
+
}
|
|
32873
32888
|
/** Options for constructing an {@link OAuthClient}. */
|
|
32874
32889
|
interface OAuthClientOptions {
|
|
32875
32890
|
/** OAuth2 client ID. */
|
|
@@ -32880,6 +32895,10 @@ interface OAuthClientOptions {
|
|
|
32880
32895
|
tsgId: string;
|
|
32881
32896
|
/** OAuth2 token endpoint URL. Defaults to Palo Alto Networks auth endpoint. */
|
|
32882
32897
|
tokenEndpoint?: string;
|
|
32898
|
+
/** Pre-expiry buffer in ms. Token refreshes this many ms before expiry. Defaults to 30000 (30s). */
|
|
32899
|
+
tokenBufferMs?: number;
|
|
32900
|
+
/** Callback invoked after each successful token refresh with current {@link TokenInfo}. */
|
|
32901
|
+
onTokenRefresh?: (info: TokenInfo) => void;
|
|
32883
32902
|
}
|
|
32884
32903
|
/**
|
|
32885
32904
|
* OAuth2 client_credentials token manager.
|
|
@@ -32890,6 +32909,8 @@ declare class OAuthClient {
|
|
|
32890
32909
|
private readonly clientId;
|
|
32891
32910
|
private readonly clientSecret;
|
|
32892
32911
|
private readonly tsgId;
|
|
32912
|
+
private readonly tokenBufferMs;
|
|
32913
|
+
private readonly onTokenRefresh?;
|
|
32893
32914
|
private accessToken;
|
|
32894
32915
|
private expiresAt;
|
|
32895
32916
|
private pendingFetch;
|
|
@@ -32901,6 +32922,19 @@ declare class OAuthClient {
|
|
|
32901
32922
|
getToken(): Promise<string>;
|
|
32902
32923
|
/** Clear the cached token, forcing a fresh fetch on next call. */
|
|
32903
32924
|
clearToken(): void;
|
|
32925
|
+
/** Check if the current token has passed its expiry time. Returns true if no token exists. */
|
|
32926
|
+
isTokenExpired(): boolean;
|
|
32927
|
+
/**
|
|
32928
|
+
* Check if the token is within the pre-expiry buffer window.
|
|
32929
|
+
* Returns true if no token exists.
|
|
32930
|
+
* @param bufferMs - Custom buffer in ms. Defaults to the configured `tokenBufferMs`.
|
|
32931
|
+
*/
|
|
32932
|
+
isTokenExpiringSoon(bufferMs?: number): boolean;
|
|
32933
|
+
/**
|
|
32934
|
+
* Get a snapshot of the current token state without exposing the actual token value.
|
|
32935
|
+
* @returns Current {@link TokenInfo}.
|
|
32936
|
+
*/
|
|
32937
|
+
getTokenInfo(): TokenInfo;
|
|
32904
32938
|
private fetchToken;
|
|
32905
32939
|
}
|
|
32906
32940
|
|
|
@@ -33555,4 +33589,4 @@ declare class RedTeamClient {
|
|
|
33555
33589
|
getDashboardOverview(): Promise<DashboardOverviewResponse>;
|
|
33556
33590
|
}
|
|
33557
33591
|
|
|
33558
|
-
export { AISecSDKException, AI_SEC_API_ENDPOINT, AI_SEC_API_KEY, AI_SEC_API_TOKEN, ASYNC_SCAN_PATH, Action, Action as ActionType, type AgentMeta, AgentMetaSchema, type AiProfile, AiProfileSchema, ApiEndpointType, type AsyncScanObject, AsyncScanObjectSchema, type AsyncScanResponse, AsyncScanResponseSchema, type AttackDetailResponse, AttackDetailResponseSchema, type AttackListItem, AttackListItemSchema, type AttackListOptions, type AttackListResponse, AttackListResponseSchema, type AttackMultiTurnDetailResponse, AttackMultiTurnDetailResponseSchema, type AttackMultiTurnOutput, AttackMultiTurnOutputSchema, type AttackOutput, AttackOutputSchema, AttackStatus, AttackType, AuthType, BEARER, type BaseResponse, BaseResponseSchema, BrandSubCategory, Category, type CategoryModel, CategoryModelSchema, type CategoryReport, CategoryReportSchema, Category as CategoryType, type ComplianceReport, ComplianceReportSchema, ComplianceSubCategory, type ComplianceTechnique, ComplianceTechniqueSchema, Content, type ContentOptions, type CountByName, CountByNameSchema, CountedQuotaEnum, type CreateCustomTopicRequest, CreateCustomTopicRequestSchema, type CreateSecurityProfileRequest, CreateSecurityProfileRequestSchema, type CustomAttackOutput, CustomAttackOutputSchema, type CustomAttackReportResponse, CustomAttackReportResponseSchema, type CustomAttacksListResponse, CustomAttacksListResponseSchema, type CustomJobMetadata, CustomJobMetadataSchema, type CustomPromptCreateRequest, CustomPromptCreateRequestSchema, type CustomPromptList, type CustomPromptListItem, CustomPromptListItemSchema, CustomPromptListSchema, type CustomPromptResponse, CustomPromptResponseSchema, type CustomPromptSetArchiveRequest, CustomPromptSetArchiveRequestSchema, type CustomPromptSetCreateRequest, CustomPromptSetCreateRequestSchema, type CustomPromptSetList, type CustomPromptSetListActive, CustomPromptSetListActiveSchema, type CustomPromptSetListItem, CustomPromptSetListItemSchema, CustomPromptSetListSchema, type CustomPromptSetReference, CustomPromptSetReferenceSchema, type CustomPromptSetResponse, CustomPromptSetResponseSchema, type CustomPromptSetUpdateRequest, CustomPromptSetUpdateRequestSchema, type CustomPromptSetVersionInfo, CustomPromptSetVersionInfoSchema, type CustomPromptUpdateRequest, CustomPromptUpdateRequestSchema, type CustomTopic, type CustomTopicListResponse, CustomTopicListResponseSchema, CustomTopicSchema, DEFAULT_ENDPOINT, DEFAULT_MGMT_ENDPOINT, DEFAULT_MODEL_SEC_DATA_ENDPOINT, DEFAULT_MODEL_SEC_MGMT_ENDPOINT, DEFAULT_RED_TEAM_DATA_ENDPOINT, DEFAULT_RED_TEAM_MGMT_ENDPOINT, DEFAULT_TOKEN_ENDPOINT, type DSDetailResult, DSDetailResultSchema, type DSResultMetadata, DSResultMetadataSchema, type DashboardOverviewResponse, DashboardOverviewResponseSchema, DateRangeFilter, type DeleteProfileConflict, DeleteProfileConflictSchema, type DeleteProfileResponse, DeleteProfileResponseSchema, type DeleteTopicConflict, DeleteTopicConflictSchema, type DeleteTopicResponse, DeleteTopicResponseSchema, type DetectionServiceResult, DetectionServiceResultSchema, type DlpReport, DlpReportSchema, type DynamicJobMetadata, DynamicJobMetadataSchema, type DynamicJobReport, DynamicJobReportSchema, type DynamicJobReportStats, DynamicJobReportStatsSchema, ErrorCodes, type ErrorLog, type ErrorLogListResponse, ErrorLogListResponseSchema, ErrorLogSchema, type ErrorResponse, ErrorResponseSchema, ErrorSource, ErrorType, EvalOutcome, type EvalSummary, EvalSummarySchema, FileFormat, type FileList, FileListSchema, type FileResponse, FileResponseSchema, type FileScanData, FileScanDataSchema, FileScanResult, FileType, type Goal, type GoalListOptions, type GoalListResponse, GoalListResponseSchema, GoalSchema, GoalType, GoalTypeQueryParam, GuardrailAction, HEADER_API_KEY, HEADER_AUTH_TOKEN, type HTTPValidationError, HTTPValidationErrorSchema, HTTP_FORCE_RETRY_STATUS_CODES, type IODetected, IODetectedSchema, type InitOptions, type JobAbortResponse, JobAbortResponseSchema, type JobCreateRequest, JobCreateRequestSchema, type JobListResponse, JobListResponseSchema, type JobResponse, JobResponseSchema, JobStatus, JobStatusFilter, type JobTimeRecord, JobTimeRecordSchema, JobType, type Label, type LabelKeyList, LabelKeyListSchema, LabelSchema, type LabelValueList, LabelValueListSchema, type LabelsCreateRequest, LabelsCreateRequestSchema, type LabelsResponse, LabelsResponseSchema, type ListModelSecurityGroupsResponse, ListModelSecurityGroupsResponseSchema, type ListModelSecurityRuleInstancesResponse, ListModelSecurityRuleInstancesResponseSchema, type ListModelSecurityRulesResponse, ListModelSecurityRulesResponseSchema, MAX_AI_PROFILE_NAME_LENGTH, MAX_API_KEY_LENGTH, MAX_CONNECTION_POOL_SIZE, MAX_CONTENT_CONTEXT_LENGTH, MAX_CONTENT_PROMPT_LENGTH, MAX_CONTENT_RESPONSE_LENGTH, MAX_NUMBER_OF_BATCH_SCAN_OBJECTS, MAX_NUMBER_OF_REPORT_IDS, MAX_NUMBER_OF_RETRIES, MAX_NUMBER_OF_SCAN_IDS, MAX_REPORT_ID_STR_LENGTH, MAX_SCAN_ID_STR_LENGTH, MAX_SESSION_ID_STR_LENGTH, MAX_TOKEN_LENGTH, MAX_TRANSACTION_ID_STR_LENGTH, MGMT_CLIENT_ID, MGMT_CLIENT_SECRET, MGMT_ENDPOINT, MGMT_PROFILES_TSG_PATH, MGMT_PROFILE_PATH, MGMT_TOKEN_ENDPOINT, MGMT_TOPICS_TSG_PATH, MGMT_TOPIC_FORCE_PATH, MGMT_TOPIC_PATH, MGMT_TSG_ID, MODEL_SEC_CLIENT_ID, MODEL_SEC_CLIENT_SECRET, MODEL_SEC_DATA_ENDPOINT, MODEL_SEC_EVALUATIONS_PATH, MODEL_SEC_MGMT_ENDPOINT, MODEL_SEC_PYPI_AUTH_PATH, MODEL_SEC_SCANS_PATH, MODEL_SEC_SECURITY_GROUPS_PATH, MODEL_SEC_SECURITY_RULES_PATH, MODEL_SEC_TOKEN_ENDPOINT, MODEL_SEC_TSG_ID, MODEL_SEC_VIOLATIONS_PATH, ManagementClient, type ManagementClientOptions, type MaskedData, MaskedDataSchema, type Metadata, MetadataSchema, type ModelScanIssue, ModelScanIssueSchema, ModelScanStatus, ModelSecurityClient, type ModelSecurityClientOptions, type ModelSecurityFileListOptions, type ModelSecurityGroupCreateRequest, ModelSecurityGroupCreateRequestSchema, type ModelSecurityGroupResponse, ModelSecurityGroupResponseSchema, ModelSecurityGroupState, type ModelSecurityGroupUpdateRequest, ModelSecurityGroupUpdateRequestSchema, ModelSecurityGroupsClient, type ModelSecurityListOptions, type ModelSecurityPagination, ModelSecurityPaginationSchema, type ModelSecurityRuleInstanceResponse, ModelSecurityRuleInstanceResponseSchema, type ModelSecurityRuleInstanceUpdateRequest, ModelSecurityRuleInstanceUpdateRequestSchema, type ModelSecurityRuleResponse, ModelSecurityRuleResponseSchema, ModelSecurityRulesClient, type ModelSecurityScanListOptions, ModelSecurityScansClient, PAYLOAD_HASH, type PaginationOptions, type Policy, PolicySchema, PolicyType, type PrerequisiteModel, PrerequisiteModelSchema, ProfilesClient, ProfilingStatus, type PromptDetailResponse, PromptDetailResponseSchema, type PromptDetected, PromptDetectedSchema, type PromptDetectionDetails, PromptDetectionDetailsSchema, type PromptListOptions, type PromptSetListOptions, type PromptSetStats, PromptSetStatsSchema, type PromptSetSummary, PromptSetSummarySchema, type PromptSetsReportResponse, PromptSetsReportResponseSchema, type PropertyAssignment, PropertyAssignmentSchema, type PropertyDefinition, PropertyDefinitionSchema, type PropertyNameCreateRequest, PropertyNameCreateRequestSchema, type PropertyNamesListResponse, PropertyNamesListResponseSchema, type PropertyStatistic, PropertyStatisticSchema, type PropertyValueCreateRequest, PropertyValueCreateRequestSchema, type PropertyValueStatistic, PropertyValueStatisticSchema, type PropertyValuesMultipleResponse, PropertyValuesMultipleResponseSchema, type PropertyValuesResponse, PropertyValuesResponseSchema, type PyPIAuthResponse, PyPIAuthResponseSchema, type QuotaDetails, QuotaDetailsSchema, type QuotaSummary, QuotaSummarySchema, RED_TEAM_CATEGORIES_PATH, RED_TEAM_CLIENT_ID, RED_TEAM_CLIENT_SECRET, RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH, RED_TEAM_CUSTOM_ATTACK_PATH, RED_TEAM_DASHBOARD_PATH, RED_TEAM_DATA_ENDPOINT, RED_TEAM_ERROR_LOG_PATH, RED_TEAM_MGMT_DASHBOARD_PATH, RED_TEAM_MGMT_ENDPOINT, RED_TEAM_QUOTA_PATH, RED_TEAM_REPORT_DYNAMIC_PATH, RED_TEAM_REPORT_PATH, RED_TEAM_REPORT_STATIC_PATH, RED_TEAM_SCAN_PATH, RED_TEAM_SENTIMENT_PATH, RED_TEAM_TARGET_PATH, RED_TEAM_TOKEN_ENDPOINT, RED_TEAM_TSG_ID, RedTeamCategory, RedTeamClient, type RedTeamClientOptions, RedTeamCustomAttackReportsClient, RedTeamCustomAttacksClient, RedTeamErrorType, type RedTeamListOptions, type RedTeamPagination, RedTeamPaginationSchema, RedTeamReportsClient, type RedTeamScanListOptions, RedTeamScansClient, RedTeamTargetsClient, type RemediationDetail, RemediationDetailSchema, type RemediationResponse, RemediationResponseSchema, type ResponseDetected, ResponseDetectedSchema, type ResponseDetectionDetails, ResponseDetectionDetailsSchema, ResponseMode, type RiskLevel, RiskLevelSchema, RiskRating, type RuleConfiguration, RuleConfigurationSchema, type RuleEditableField, type RuleEditableFieldDropdown, RuleEditableFieldDropdownSchema, RuleEditableFieldSchema, RuleEditableFieldType, type RuleEvaluationList, RuleEvaluationListSchema, type RuleEvaluationResponse, RuleEvaluationResponseSchema, RuleEvaluationResult, RuleFieldValueKey, type RuleRemediation, RuleRemediationSchema, RuleState, RuleType, type RuntimeSecurityPolicy, RuntimeSecurityPolicySchema, type RuntimeSecurityProfileResponse, RuntimeSecurityProfileResponseSchema, SCAN_REPORTS_PATH, SCAN_RESULTS_PATH, SDK_VERSION, SYNC_SCAN_PATH, SafetySubCategory, type ScanBaseResponse, ScanBaseResponseSchema, type ScanCreateRequest, ScanCreateRequestSchema, type ScanDetails, ScanDetailsSchema, type ScanIdResult, ScanIdResultSchema, type ScanList, ScanListSchema, ScanOrigin, type ScanRequest, type ScanRequestContentsInner, ScanRequestContentsInnerSchema, ScanRequestSchema, type ScanResponse, ScanResponseSchema, type ScanStatisticsResponse, ScanStatisticsResponseSchema, type ScanSummary, ScanSummarySchema, Scanner, type ScoreTrendResponse, ScoreTrendResponseSchema, type ScoreTrendSeries, ScoreTrendSeriesSchema, type SecurityProfile, type SecurityProfileListResponse, SecurityProfileListResponseSchema, SecurityProfileSchema, SecuritySubCategory, type SentimentRequest, SentimentRequestSchema, type SentimentResponse, SentimentResponseSchema, SeverityFilter, type SeverityReport, SeverityReportSchema, type SeverityStats, SeverityStatsSchema, SortByDateField, SortByFileField, SortDirection, SourceType, type StaticJobMetadata, StaticJobMetadataSchema, type StaticJobRemediation, type StaticJobRemediationRecommendation, StaticJobRemediationRecommendationSchema, StaticJobRemediationSchema, type StaticJobReport, StaticJobReportSchema, type StaticJobReportStats, StaticJobReportStatsSchema, StatusQueryParam, type StreamDetailResponse, StreamDetailResponseSchema, type StreamIterationData, StreamIterationDataSchema, type StreamListResponse, StreamListResponseSchema, StreamType, type SubCategoryModel, SubCategoryModelSchema, type SubCategoryStats, SubCategoryStatsSchema, type SyncScanOptions, type TargetAdditionalContext, TargetAdditionalContextSchema, type TargetBackground, TargetBackgroundSchema, TargetConnectionType, type TargetContextUpdate, TargetContextUpdateSchema, type TargetCreateRequest, TargetCreateRequestSchema, type TargetJobRequest, TargetJobRequestSchema, type TargetList, type TargetListItem, TargetListItemSchema, type TargetListOptions, TargetListSchema, type TargetMetadata, TargetMetadataSchema, type TargetProbeRequest, TargetProbeRequestSchema, type TargetProfileResponse, TargetProfileResponseSchema, type TargetReference, TargetReferenceSchema, type TargetResponse, TargetResponseSchema, TargetStatus, TargetType, type TargetUpdateRequest, TargetUpdateRequestSchema, ThreatCategory, type ThreatScanReport, ThreatScanReportSchema, type ToolDetected, ToolDetectedSchema, type ToolEvent, type ToolEventMetadata, ToolEventMetadataSchema, ToolEventSchema, TopicsClient, USER_AGENT, type UrlfEntry, UrlfEntrySchema, type ValidationError, ValidationErrorSchema, Verdict, Verdict as VerdictType, type ViolationList, ViolationListSchema, type ViolationResponse, ViolationResponseSchema, globalConfiguration, init };
|
|
33592
|
+
export { AISecSDKException, AI_SEC_API_ENDPOINT, AI_SEC_API_KEY, AI_SEC_API_TOKEN, ASYNC_SCAN_PATH, Action, Action as ActionType, type AgentMeta, AgentMetaSchema, type AiProfile, AiProfileSchema, ApiEndpointType, type AsyncScanObject, AsyncScanObjectSchema, type AsyncScanResponse, AsyncScanResponseSchema, type AttackDetailResponse, AttackDetailResponseSchema, type AttackListItem, AttackListItemSchema, type AttackListOptions, type AttackListResponse, AttackListResponseSchema, type AttackMultiTurnDetailResponse, AttackMultiTurnDetailResponseSchema, type AttackMultiTurnOutput, AttackMultiTurnOutputSchema, type AttackOutput, AttackOutputSchema, AttackStatus, AttackType, AuthType, BEARER, type BaseResponse, BaseResponseSchema, BrandSubCategory, Category, type CategoryModel, CategoryModelSchema, type CategoryReport, CategoryReportSchema, Category as CategoryType, type ComplianceReport, ComplianceReportSchema, ComplianceSubCategory, type ComplianceTechnique, ComplianceTechniqueSchema, Content, type ContentOptions, type CountByName, CountByNameSchema, CountedQuotaEnum, type CreateCustomTopicRequest, CreateCustomTopicRequestSchema, type CreateSecurityProfileRequest, CreateSecurityProfileRequestSchema, type CustomAttackOutput, CustomAttackOutputSchema, type CustomAttackReportResponse, CustomAttackReportResponseSchema, type CustomAttacksListResponse, CustomAttacksListResponseSchema, type CustomJobMetadata, CustomJobMetadataSchema, type CustomPromptCreateRequest, CustomPromptCreateRequestSchema, type CustomPromptList, type CustomPromptListItem, CustomPromptListItemSchema, CustomPromptListSchema, type CustomPromptResponse, CustomPromptResponseSchema, type CustomPromptSetArchiveRequest, CustomPromptSetArchiveRequestSchema, type CustomPromptSetCreateRequest, CustomPromptSetCreateRequestSchema, type CustomPromptSetList, type CustomPromptSetListActive, CustomPromptSetListActiveSchema, type CustomPromptSetListItem, CustomPromptSetListItemSchema, CustomPromptSetListSchema, type CustomPromptSetReference, CustomPromptSetReferenceSchema, type CustomPromptSetResponse, CustomPromptSetResponseSchema, type CustomPromptSetUpdateRequest, CustomPromptSetUpdateRequestSchema, type CustomPromptSetVersionInfo, CustomPromptSetVersionInfoSchema, type CustomPromptUpdateRequest, CustomPromptUpdateRequestSchema, type CustomTopic, type CustomTopicListResponse, CustomTopicListResponseSchema, CustomTopicSchema, DEFAULT_ENDPOINT, DEFAULT_MGMT_ENDPOINT, DEFAULT_MODEL_SEC_DATA_ENDPOINT, DEFAULT_MODEL_SEC_MGMT_ENDPOINT, DEFAULT_RED_TEAM_DATA_ENDPOINT, DEFAULT_RED_TEAM_MGMT_ENDPOINT, DEFAULT_TOKEN_ENDPOINT, type DSDetailResult, DSDetailResultSchema, type DSResultMetadata, DSResultMetadataSchema, type DashboardOverviewResponse, DashboardOverviewResponseSchema, DateRangeFilter, type DeleteProfileConflict, DeleteProfileConflictSchema, type DeleteProfileResponse, DeleteProfileResponseSchema, type DeleteTopicConflict, DeleteTopicConflictSchema, type DeleteTopicResponse, DeleteTopicResponseSchema, type DetectionServiceResult, DetectionServiceResultSchema, type DlpReport, DlpReportSchema, type DynamicJobMetadata, DynamicJobMetadataSchema, type DynamicJobReport, DynamicJobReportSchema, type DynamicJobReportStats, DynamicJobReportStatsSchema, ErrorCodes, type ErrorLog, type ErrorLogListResponse, ErrorLogListResponseSchema, ErrorLogSchema, type ErrorResponse, ErrorResponseSchema, ErrorSource, ErrorType, EvalOutcome, type EvalSummary, EvalSummarySchema, FileFormat, type FileList, FileListSchema, type FileResponse, FileResponseSchema, type FileScanData, FileScanDataSchema, FileScanResult, FileType, type Goal, type GoalListOptions, type GoalListResponse, GoalListResponseSchema, GoalSchema, GoalType, GoalTypeQueryParam, GuardrailAction, HEADER_API_KEY, HEADER_AUTH_TOKEN, type HTTPValidationError, HTTPValidationErrorSchema, HTTP_FORCE_RETRY_STATUS_CODES, type IODetected, IODetectedSchema, type InitOptions, type JobAbortResponse, JobAbortResponseSchema, type JobCreateRequest, JobCreateRequestSchema, type JobListResponse, JobListResponseSchema, type JobResponse, JobResponseSchema, JobStatus, JobStatusFilter, type JobTimeRecord, JobTimeRecordSchema, JobType, type Label, type LabelKeyList, LabelKeyListSchema, LabelSchema, type LabelValueList, LabelValueListSchema, type LabelsCreateRequest, LabelsCreateRequestSchema, type LabelsResponse, LabelsResponseSchema, type ListModelSecurityGroupsResponse, ListModelSecurityGroupsResponseSchema, type ListModelSecurityRuleInstancesResponse, ListModelSecurityRuleInstancesResponseSchema, type ListModelSecurityRulesResponse, ListModelSecurityRulesResponseSchema, MAX_AI_PROFILE_NAME_LENGTH, MAX_API_KEY_LENGTH, MAX_CONNECTION_POOL_SIZE, MAX_CONTENT_CONTEXT_LENGTH, MAX_CONTENT_PROMPT_LENGTH, MAX_CONTENT_RESPONSE_LENGTH, MAX_NUMBER_OF_BATCH_SCAN_OBJECTS, MAX_NUMBER_OF_REPORT_IDS, MAX_NUMBER_OF_RETRIES, MAX_NUMBER_OF_SCAN_IDS, MAX_REPORT_ID_STR_LENGTH, MAX_SCAN_ID_STR_LENGTH, MAX_SESSION_ID_STR_LENGTH, MAX_TOKEN_LENGTH, MAX_TRANSACTION_ID_STR_LENGTH, MGMT_CLIENT_ID, MGMT_CLIENT_SECRET, MGMT_ENDPOINT, MGMT_PROFILES_TSG_PATH, MGMT_PROFILE_PATH, MGMT_TOKEN_ENDPOINT, MGMT_TOPICS_TSG_PATH, MGMT_TOPIC_FORCE_PATH, MGMT_TOPIC_PATH, MGMT_TSG_ID, MODEL_SEC_CLIENT_ID, MODEL_SEC_CLIENT_SECRET, MODEL_SEC_DATA_ENDPOINT, MODEL_SEC_EVALUATIONS_PATH, MODEL_SEC_MGMT_ENDPOINT, MODEL_SEC_PYPI_AUTH_PATH, MODEL_SEC_SCANS_PATH, MODEL_SEC_SECURITY_GROUPS_PATH, MODEL_SEC_SECURITY_RULES_PATH, MODEL_SEC_TOKEN_ENDPOINT, MODEL_SEC_TSG_ID, MODEL_SEC_VIOLATIONS_PATH, ManagementClient, type ManagementClientOptions, type MaskedData, MaskedDataSchema, type Metadata, MetadataSchema, type ModelScanIssue, ModelScanIssueSchema, ModelScanStatus, ModelSecurityClient, type ModelSecurityClientOptions, type ModelSecurityFileListOptions, type ModelSecurityGroupCreateRequest, ModelSecurityGroupCreateRequestSchema, type ModelSecurityGroupResponse, ModelSecurityGroupResponseSchema, ModelSecurityGroupState, type ModelSecurityGroupUpdateRequest, ModelSecurityGroupUpdateRequestSchema, ModelSecurityGroupsClient, type ModelSecurityListOptions, type ModelSecurityPagination, ModelSecurityPaginationSchema, type ModelSecurityRuleInstanceResponse, ModelSecurityRuleInstanceResponseSchema, type ModelSecurityRuleInstanceUpdateRequest, ModelSecurityRuleInstanceUpdateRequestSchema, type ModelSecurityRuleResponse, ModelSecurityRuleResponseSchema, ModelSecurityRulesClient, type ModelSecurityScanListOptions, ModelSecurityScansClient, OAuthClient, type OAuthClientOptions, PAYLOAD_HASH, type PaginationOptions, type Policy, PolicySchema, PolicyType, type PrerequisiteModel, PrerequisiteModelSchema, ProfilesClient, ProfilingStatus, type PromptDetailResponse, PromptDetailResponseSchema, type PromptDetected, PromptDetectedSchema, type PromptDetectionDetails, PromptDetectionDetailsSchema, type PromptListOptions, type PromptSetListOptions, type PromptSetStats, PromptSetStatsSchema, type PromptSetSummary, PromptSetSummarySchema, type PromptSetsReportResponse, PromptSetsReportResponseSchema, type PropertyAssignment, PropertyAssignmentSchema, type PropertyDefinition, PropertyDefinitionSchema, type PropertyNameCreateRequest, PropertyNameCreateRequestSchema, type PropertyNamesListResponse, PropertyNamesListResponseSchema, type PropertyStatistic, PropertyStatisticSchema, type PropertyValueCreateRequest, PropertyValueCreateRequestSchema, type PropertyValueStatistic, PropertyValueStatisticSchema, type PropertyValuesMultipleResponse, PropertyValuesMultipleResponseSchema, type PropertyValuesResponse, PropertyValuesResponseSchema, type PyPIAuthResponse, PyPIAuthResponseSchema, type QuotaDetails, QuotaDetailsSchema, type QuotaSummary, QuotaSummarySchema, RED_TEAM_CATEGORIES_PATH, RED_TEAM_CLIENT_ID, RED_TEAM_CLIENT_SECRET, RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH, RED_TEAM_CUSTOM_ATTACK_PATH, RED_TEAM_DASHBOARD_PATH, RED_TEAM_DATA_ENDPOINT, RED_TEAM_ERROR_LOG_PATH, RED_TEAM_MGMT_DASHBOARD_PATH, RED_TEAM_MGMT_ENDPOINT, RED_TEAM_QUOTA_PATH, RED_TEAM_REPORT_DYNAMIC_PATH, RED_TEAM_REPORT_PATH, RED_TEAM_REPORT_STATIC_PATH, RED_TEAM_SCAN_PATH, RED_TEAM_SENTIMENT_PATH, RED_TEAM_TARGET_PATH, RED_TEAM_TOKEN_ENDPOINT, RED_TEAM_TSG_ID, RedTeamCategory, RedTeamClient, type RedTeamClientOptions, RedTeamCustomAttackReportsClient, RedTeamCustomAttacksClient, RedTeamErrorType, type RedTeamListOptions, type RedTeamPagination, RedTeamPaginationSchema, RedTeamReportsClient, type RedTeamScanListOptions, RedTeamScansClient, RedTeamTargetsClient, type RemediationDetail, RemediationDetailSchema, type RemediationResponse, RemediationResponseSchema, type ResponseDetected, ResponseDetectedSchema, type ResponseDetectionDetails, ResponseDetectionDetailsSchema, ResponseMode, type RiskLevel, RiskLevelSchema, RiskRating, type RuleConfiguration, RuleConfigurationSchema, type RuleEditableField, type RuleEditableFieldDropdown, RuleEditableFieldDropdownSchema, RuleEditableFieldSchema, RuleEditableFieldType, type RuleEvaluationList, RuleEvaluationListSchema, type RuleEvaluationResponse, RuleEvaluationResponseSchema, RuleEvaluationResult, RuleFieldValueKey, type RuleRemediation, RuleRemediationSchema, RuleState, RuleType, type RuntimeSecurityPolicy, RuntimeSecurityPolicySchema, type RuntimeSecurityProfileResponse, RuntimeSecurityProfileResponseSchema, SCAN_REPORTS_PATH, SCAN_RESULTS_PATH, SDK_VERSION, SYNC_SCAN_PATH, SafetySubCategory, type ScanBaseResponse, ScanBaseResponseSchema, type ScanCreateRequest, ScanCreateRequestSchema, type ScanDetails, ScanDetailsSchema, type ScanIdResult, ScanIdResultSchema, type ScanList, ScanListSchema, ScanOrigin, type ScanRequest, type ScanRequestContentsInner, ScanRequestContentsInnerSchema, ScanRequestSchema, type ScanResponse, ScanResponseSchema, type ScanStatisticsResponse, ScanStatisticsResponseSchema, type ScanSummary, ScanSummarySchema, Scanner, type ScoreTrendResponse, ScoreTrendResponseSchema, type ScoreTrendSeries, ScoreTrendSeriesSchema, type SecurityProfile, type SecurityProfileListResponse, SecurityProfileListResponseSchema, SecurityProfileSchema, SecuritySubCategory, type SentimentRequest, SentimentRequestSchema, type SentimentResponse, SentimentResponseSchema, SeverityFilter, type SeverityReport, SeverityReportSchema, type SeverityStats, SeverityStatsSchema, SortByDateField, SortByFileField, SortDirection, SourceType, type StaticJobMetadata, StaticJobMetadataSchema, type StaticJobRemediation, type StaticJobRemediationRecommendation, StaticJobRemediationRecommendationSchema, StaticJobRemediationSchema, type StaticJobReport, StaticJobReportSchema, type StaticJobReportStats, StaticJobReportStatsSchema, StatusQueryParam, type StreamDetailResponse, StreamDetailResponseSchema, type StreamIterationData, StreamIterationDataSchema, type StreamListResponse, StreamListResponseSchema, StreamType, type SubCategoryModel, SubCategoryModelSchema, type SubCategoryStats, SubCategoryStatsSchema, type SyncScanOptions, type TargetAdditionalContext, TargetAdditionalContextSchema, type TargetBackground, TargetBackgroundSchema, TargetConnectionType, type TargetContextUpdate, TargetContextUpdateSchema, type TargetCreateRequest, TargetCreateRequestSchema, type TargetJobRequest, TargetJobRequestSchema, type TargetList, type TargetListItem, TargetListItemSchema, type TargetListOptions, TargetListSchema, type TargetMetadata, TargetMetadataSchema, type TargetProbeRequest, TargetProbeRequestSchema, type TargetProfileResponse, TargetProfileResponseSchema, type TargetReference, TargetReferenceSchema, type TargetResponse, TargetResponseSchema, TargetStatus, TargetType, type TargetUpdateRequest, TargetUpdateRequestSchema, ThreatCategory, type ThreatScanReport, ThreatScanReportSchema, type TokenInfo, type ToolDetected, ToolDetectedSchema, type ToolEvent, type ToolEventMetadata, ToolEventMetadataSchema, ToolEventSchema, TopicsClient, USER_AGENT, type UrlfEntry, UrlfEntrySchema, type ValidationError, ValidationErrorSchema, Verdict, Verdict as VerdictType, type ViolationList, ViolationListSchema, type ViolationResponse, ViolationResponseSchema, globalConfiguration, init };
|
package/dist/index.d.ts
CHANGED
|
@@ -32816,8 +32816,8 @@ declare const MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
|
|
|
32816
32816
|
declare const MAX_CONNECTION_POOL_SIZE = 100;
|
|
32817
32817
|
declare const MAX_NUMBER_OF_RETRIES = 5;
|
|
32818
32818
|
declare const HTTP_FORCE_RETRY_STATUS_CODES: number[];
|
|
32819
|
-
declare const SDK_VERSION = "0.
|
|
32820
|
-
declare const USER_AGENT = "PAN-AIRS/0.
|
|
32819
|
+
declare const SDK_VERSION = "0.5.0";
|
|
32820
|
+
declare const USER_AGENT = "PAN-AIRS/0.5.0-typescript-sdk";
|
|
32821
32821
|
declare const DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
32822
32822
|
declare const DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
32823
32823
|
declare const MGMT_CLIENT_ID = "PANW_MGMT_CLIENT_ID";
|
|
@@ -32870,6 +32870,21 @@ declare const RED_TEAM_TARGET_PATH = "/v1/target";
|
|
|
32870
32870
|
declare const RED_TEAM_CUSTOM_ATTACK_PATH = "/v1/custom-attack";
|
|
32871
32871
|
declare const RED_TEAM_MGMT_DASHBOARD_PATH = "/v1/dashboard/overview";
|
|
32872
32872
|
|
|
32873
|
+
/** Snapshot of the current token state (never exposes the actual token). */
|
|
32874
|
+
interface TokenInfo {
|
|
32875
|
+
/** Whether a token has been fetched. */
|
|
32876
|
+
hasToken: boolean;
|
|
32877
|
+
/** Whether the token is valid (not expired and outside the pre-expiry buffer). */
|
|
32878
|
+
isValid: boolean;
|
|
32879
|
+
/** Whether the token has passed its expiry time. */
|
|
32880
|
+
isExpired: boolean;
|
|
32881
|
+
/** Whether the token is within the pre-expiry buffer window. */
|
|
32882
|
+
isExpiringSoon: boolean;
|
|
32883
|
+
/** Milliseconds until the token expires (0 if expired or no token). */
|
|
32884
|
+
expiresInMs: number;
|
|
32885
|
+
/** Unix timestamp (ms) when the token expires (0 if no token). */
|
|
32886
|
+
expiresAt: number;
|
|
32887
|
+
}
|
|
32873
32888
|
/** Options for constructing an {@link OAuthClient}. */
|
|
32874
32889
|
interface OAuthClientOptions {
|
|
32875
32890
|
/** OAuth2 client ID. */
|
|
@@ -32880,6 +32895,10 @@ interface OAuthClientOptions {
|
|
|
32880
32895
|
tsgId: string;
|
|
32881
32896
|
/** OAuth2 token endpoint URL. Defaults to Palo Alto Networks auth endpoint. */
|
|
32882
32897
|
tokenEndpoint?: string;
|
|
32898
|
+
/** Pre-expiry buffer in ms. Token refreshes this many ms before expiry. Defaults to 30000 (30s). */
|
|
32899
|
+
tokenBufferMs?: number;
|
|
32900
|
+
/** Callback invoked after each successful token refresh with current {@link TokenInfo}. */
|
|
32901
|
+
onTokenRefresh?: (info: TokenInfo) => void;
|
|
32883
32902
|
}
|
|
32884
32903
|
/**
|
|
32885
32904
|
* OAuth2 client_credentials token manager.
|
|
@@ -32890,6 +32909,8 @@ declare class OAuthClient {
|
|
|
32890
32909
|
private readonly clientId;
|
|
32891
32910
|
private readonly clientSecret;
|
|
32892
32911
|
private readonly tsgId;
|
|
32912
|
+
private readonly tokenBufferMs;
|
|
32913
|
+
private readonly onTokenRefresh?;
|
|
32893
32914
|
private accessToken;
|
|
32894
32915
|
private expiresAt;
|
|
32895
32916
|
private pendingFetch;
|
|
@@ -32901,6 +32922,19 @@ declare class OAuthClient {
|
|
|
32901
32922
|
getToken(): Promise<string>;
|
|
32902
32923
|
/** Clear the cached token, forcing a fresh fetch on next call. */
|
|
32903
32924
|
clearToken(): void;
|
|
32925
|
+
/** Check if the current token has passed its expiry time. Returns true if no token exists. */
|
|
32926
|
+
isTokenExpired(): boolean;
|
|
32927
|
+
/**
|
|
32928
|
+
* Check if the token is within the pre-expiry buffer window.
|
|
32929
|
+
* Returns true if no token exists.
|
|
32930
|
+
* @param bufferMs - Custom buffer in ms. Defaults to the configured `tokenBufferMs`.
|
|
32931
|
+
*/
|
|
32932
|
+
isTokenExpiringSoon(bufferMs?: number): boolean;
|
|
32933
|
+
/**
|
|
32934
|
+
* Get a snapshot of the current token state without exposing the actual token value.
|
|
32935
|
+
* @returns Current {@link TokenInfo}.
|
|
32936
|
+
*/
|
|
32937
|
+
getTokenInfo(): TokenInfo;
|
|
32904
32938
|
private fetchToken;
|
|
32905
32939
|
}
|
|
32906
32940
|
|
|
@@ -33555,4 +33589,4 @@ declare class RedTeamClient {
|
|
|
33555
33589
|
getDashboardOverview(): Promise<DashboardOverviewResponse>;
|
|
33556
33590
|
}
|
|
33557
33591
|
|
|
33558
|
-
export { AISecSDKException, AI_SEC_API_ENDPOINT, AI_SEC_API_KEY, AI_SEC_API_TOKEN, ASYNC_SCAN_PATH, Action, Action as ActionType, type AgentMeta, AgentMetaSchema, type AiProfile, AiProfileSchema, ApiEndpointType, type AsyncScanObject, AsyncScanObjectSchema, type AsyncScanResponse, AsyncScanResponseSchema, type AttackDetailResponse, AttackDetailResponseSchema, type AttackListItem, AttackListItemSchema, type AttackListOptions, type AttackListResponse, AttackListResponseSchema, type AttackMultiTurnDetailResponse, AttackMultiTurnDetailResponseSchema, type AttackMultiTurnOutput, AttackMultiTurnOutputSchema, type AttackOutput, AttackOutputSchema, AttackStatus, AttackType, AuthType, BEARER, type BaseResponse, BaseResponseSchema, BrandSubCategory, Category, type CategoryModel, CategoryModelSchema, type CategoryReport, CategoryReportSchema, Category as CategoryType, type ComplianceReport, ComplianceReportSchema, ComplianceSubCategory, type ComplianceTechnique, ComplianceTechniqueSchema, Content, type ContentOptions, type CountByName, CountByNameSchema, CountedQuotaEnum, type CreateCustomTopicRequest, CreateCustomTopicRequestSchema, type CreateSecurityProfileRequest, CreateSecurityProfileRequestSchema, type CustomAttackOutput, CustomAttackOutputSchema, type CustomAttackReportResponse, CustomAttackReportResponseSchema, type CustomAttacksListResponse, CustomAttacksListResponseSchema, type CustomJobMetadata, CustomJobMetadataSchema, type CustomPromptCreateRequest, CustomPromptCreateRequestSchema, type CustomPromptList, type CustomPromptListItem, CustomPromptListItemSchema, CustomPromptListSchema, type CustomPromptResponse, CustomPromptResponseSchema, type CustomPromptSetArchiveRequest, CustomPromptSetArchiveRequestSchema, type CustomPromptSetCreateRequest, CustomPromptSetCreateRequestSchema, type CustomPromptSetList, type CustomPromptSetListActive, CustomPromptSetListActiveSchema, type CustomPromptSetListItem, CustomPromptSetListItemSchema, CustomPromptSetListSchema, type CustomPromptSetReference, CustomPromptSetReferenceSchema, type CustomPromptSetResponse, CustomPromptSetResponseSchema, type CustomPromptSetUpdateRequest, CustomPromptSetUpdateRequestSchema, type CustomPromptSetVersionInfo, CustomPromptSetVersionInfoSchema, type CustomPromptUpdateRequest, CustomPromptUpdateRequestSchema, type CustomTopic, type CustomTopicListResponse, CustomTopicListResponseSchema, CustomTopicSchema, DEFAULT_ENDPOINT, DEFAULT_MGMT_ENDPOINT, DEFAULT_MODEL_SEC_DATA_ENDPOINT, DEFAULT_MODEL_SEC_MGMT_ENDPOINT, DEFAULT_RED_TEAM_DATA_ENDPOINT, DEFAULT_RED_TEAM_MGMT_ENDPOINT, DEFAULT_TOKEN_ENDPOINT, type DSDetailResult, DSDetailResultSchema, type DSResultMetadata, DSResultMetadataSchema, type DashboardOverviewResponse, DashboardOverviewResponseSchema, DateRangeFilter, type DeleteProfileConflict, DeleteProfileConflictSchema, type DeleteProfileResponse, DeleteProfileResponseSchema, type DeleteTopicConflict, DeleteTopicConflictSchema, type DeleteTopicResponse, DeleteTopicResponseSchema, type DetectionServiceResult, DetectionServiceResultSchema, type DlpReport, DlpReportSchema, type DynamicJobMetadata, DynamicJobMetadataSchema, type DynamicJobReport, DynamicJobReportSchema, type DynamicJobReportStats, DynamicJobReportStatsSchema, ErrorCodes, type ErrorLog, type ErrorLogListResponse, ErrorLogListResponseSchema, ErrorLogSchema, type ErrorResponse, ErrorResponseSchema, ErrorSource, ErrorType, EvalOutcome, type EvalSummary, EvalSummarySchema, FileFormat, type FileList, FileListSchema, type FileResponse, FileResponseSchema, type FileScanData, FileScanDataSchema, FileScanResult, FileType, type Goal, type GoalListOptions, type GoalListResponse, GoalListResponseSchema, GoalSchema, GoalType, GoalTypeQueryParam, GuardrailAction, HEADER_API_KEY, HEADER_AUTH_TOKEN, type HTTPValidationError, HTTPValidationErrorSchema, HTTP_FORCE_RETRY_STATUS_CODES, type IODetected, IODetectedSchema, type InitOptions, type JobAbortResponse, JobAbortResponseSchema, type JobCreateRequest, JobCreateRequestSchema, type JobListResponse, JobListResponseSchema, type JobResponse, JobResponseSchema, JobStatus, JobStatusFilter, type JobTimeRecord, JobTimeRecordSchema, JobType, type Label, type LabelKeyList, LabelKeyListSchema, LabelSchema, type LabelValueList, LabelValueListSchema, type LabelsCreateRequest, LabelsCreateRequestSchema, type LabelsResponse, LabelsResponseSchema, type ListModelSecurityGroupsResponse, ListModelSecurityGroupsResponseSchema, type ListModelSecurityRuleInstancesResponse, ListModelSecurityRuleInstancesResponseSchema, type ListModelSecurityRulesResponse, ListModelSecurityRulesResponseSchema, MAX_AI_PROFILE_NAME_LENGTH, MAX_API_KEY_LENGTH, MAX_CONNECTION_POOL_SIZE, MAX_CONTENT_CONTEXT_LENGTH, MAX_CONTENT_PROMPT_LENGTH, MAX_CONTENT_RESPONSE_LENGTH, MAX_NUMBER_OF_BATCH_SCAN_OBJECTS, MAX_NUMBER_OF_REPORT_IDS, MAX_NUMBER_OF_RETRIES, MAX_NUMBER_OF_SCAN_IDS, MAX_REPORT_ID_STR_LENGTH, MAX_SCAN_ID_STR_LENGTH, MAX_SESSION_ID_STR_LENGTH, MAX_TOKEN_LENGTH, MAX_TRANSACTION_ID_STR_LENGTH, MGMT_CLIENT_ID, MGMT_CLIENT_SECRET, MGMT_ENDPOINT, MGMT_PROFILES_TSG_PATH, MGMT_PROFILE_PATH, MGMT_TOKEN_ENDPOINT, MGMT_TOPICS_TSG_PATH, MGMT_TOPIC_FORCE_PATH, MGMT_TOPIC_PATH, MGMT_TSG_ID, MODEL_SEC_CLIENT_ID, MODEL_SEC_CLIENT_SECRET, MODEL_SEC_DATA_ENDPOINT, MODEL_SEC_EVALUATIONS_PATH, MODEL_SEC_MGMT_ENDPOINT, MODEL_SEC_PYPI_AUTH_PATH, MODEL_SEC_SCANS_PATH, MODEL_SEC_SECURITY_GROUPS_PATH, MODEL_SEC_SECURITY_RULES_PATH, MODEL_SEC_TOKEN_ENDPOINT, MODEL_SEC_TSG_ID, MODEL_SEC_VIOLATIONS_PATH, ManagementClient, type ManagementClientOptions, type MaskedData, MaskedDataSchema, type Metadata, MetadataSchema, type ModelScanIssue, ModelScanIssueSchema, ModelScanStatus, ModelSecurityClient, type ModelSecurityClientOptions, type ModelSecurityFileListOptions, type ModelSecurityGroupCreateRequest, ModelSecurityGroupCreateRequestSchema, type ModelSecurityGroupResponse, ModelSecurityGroupResponseSchema, ModelSecurityGroupState, type ModelSecurityGroupUpdateRequest, ModelSecurityGroupUpdateRequestSchema, ModelSecurityGroupsClient, type ModelSecurityListOptions, type ModelSecurityPagination, ModelSecurityPaginationSchema, type ModelSecurityRuleInstanceResponse, ModelSecurityRuleInstanceResponseSchema, type ModelSecurityRuleInstanceUpdateRequest, ModelSecurityRuleInstanceUpdateRequestSchema, type ModelSecurityRuleResponse, ModelSecurityRuleResponseSchema, ModelSecurityRulesClient, type ModelSecurityScanListOptions, ModelSecurityScansClient, PAYLOAD_HASH, type PaginationOptions, type Policy, PolicySchema, PolicyType, type PrerequisiteModel, PrerequisiteModelSchema, ProfilesClient, ProfilingStatus, type PromptDetailResponse, PromptDetailResponseSchema, type PromptDetected, PromptDetectedSchema, type PromptDetectionDetails, PromptDetectionDetailsSchema, type PromptListOptions, type PromptSetListOptions, type PromptSetStats, PromptSetStatsSchema, type PromptSetSummary, PromptSetSummarySchema, type PromptSetsReportResponse, PromptSetsReportResponseSchema, type PropertyAssignment, PropertyAssignmentSchema, type PropertyDefinition, PropertyDefinitionSchema, type PropertyNameCreateRequest, PropertyNameCreateRequestSchema, type PropertyNamesListResponse, PropertyNamesListResponseSchema, type PropertyStatistic, PropertyStatisticSchema, type PropertyValueCreateRequest, PropertyValueCreateRequestSchema, type PropertyValueStatistic, PropertyValueStatisticSchema, type PropertyValuesMultipleResponse, PropertyValuesMultipleResponseSchema, type PropertyValuesResponse, PropertyValuesResponseSchema, type PyPIAuthResponse, PyPIAuthResponseSchema, type QuotaDetails, QuotaDetailsSchema, type QuotaSummary, QuotaSummarySchema, RED_TEAM_CATEGORIES_PATH, RED_TEAM_CLIENT_ID, RED_TEAM_CLIENT_SECRET, RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH, RED_TEAM_CUSTOM_ATTACK_PATH, RED_TEAM_DASHBOARD_PATH, RED_TEAM_DATA_ENDPOINT, RED_TEAM_ERROR_LOG_PATH, RED_TEAM_MGMT_DASHBOARD_PATH, RED_TEAM_MGMT_ENDPOINT, RED_TEAM_QUOTA_PATH, RED_TEAM_REPORT_DYNAMIC_PATH, RED_TEAM_REPORT_PATH, RED_TEAM_REPORT_STATIC_PATH, RED_TEAM_SCAN_PATH, RED_TEAM_SENTIMENT_PATH, RED_TEAM_TARGET_PATH, RED_TEAM_TOKEN_ENDPOINT, RED_TEAM_TSG_ID, RedTeamCategory, RedTeamClient, type RedTeamClientOptions, RedTeamCustomAttackReportsClient, RedTeamCustomAttacksClient, RedTeamErrorType, type RedTeamListOptions, type RedTeamPagination, RedTeamPaginationSchema, RedTeamReportsClient, type RedTeamScanListOptions, RedTeamScansClient, RedTeamTargetsClient, type RemediationDetail, RemediationDetailSchema, type RemediationResponse, RemediationResponseSchema, type ResponseDetected, ResponseDetectedSchema, type ResponseDetectionDetails, ResponseDetectionDetailsSchema, ResponseMode, type RiskLevel, RiskLevelSchema, RiskRating, type RuleConfiguration, RuleConfigurationSchema, type RuleEditableField, type RuleEditableFieldDropdown, RuleEditableFieldDropdownSchema, RuleEditableFieldSchema, RuleEditableFieldType, type RuleEvaluationList, RuleEvaluationListSchema, type RuleEvaluationResponse, RuleEvaluationResponseSchema, RuleEvaluationResult, RuleFieldValueKey, type RuleRemediation, RuleRemediationSchema, RuleState, RuleType, type RuntimeSecurityPolicy, RuntimeSecurityPolicySchema, type RuntimeSecurityProfileResponse, RuntimeSecurityProfileResponseSchema, SCAN_REPORTS_PATH, SCAN_RESULTS_PATH, SDK_VERSION, SYNC_SCAN_PATH, SafetySubCategory, type ScanBaseResponse, ScanBaseResponseSchema, type ScanCreateRequest, ScanCreateRequestSchema, type ScanDetails, ScanDetailsSchema, type ScanIdResult, ScanIdResultSchema, type ScanList, ScanListSchema, ScanOrigin, type ScanRequest, type ScanRequestContentsInner, ScanRequestContentsInnerSchema, ScanRequestSchema, type ScanResponse, ScanResponseSchema, type ScanStatisticsResponse, ScanStatisticsResponseSchema, type ScanSummary, ScanSummarySchema, Scanner, type ScoreTrendResponse, ScoreTrendResponseSchema, type ScoreTrendSeries, ScoreTrendSeriesSchema, type SecurityProfile, type SecurityProfileListResponse, SecurityProfileListResponseSchema, SecurityProfileSchema, SecuritySubCategory, type SentimentRequest, SentimentRequestSchema, type SentimentResponse, SentimentResponseSchema, SeverityFilter, type SeverityReport, SeverityReportSchema, type SeverityStats, SeverityStatsSchema, SortByDateField, SortByFileField, SortDirection, SourceType, type StaticJobMetadata, StaticJobMetadataSchema, type StaticJobRemediation, type StaticJobRemediationRecommendation, StaticJobRemediationRecommendationSchema, StaticJobRemediationSchema, type StaticJobReport, StaticJobReportSchema, type StaticJobReportStats, StaticJobReportStatsSchema, StatusQueryParam, type StreamDetailResponse, StreamDetailResponseSchema, type StreamIterationData, StreamIterationDataSchema, type StreamListResponse, StreamListResponseSchema, StreamType, type SubCategoryModel, SubCategoryModelSchema, type SubCategoryStats, SubCategoryStatsSchema, type SyncScanOptions, type TargetAdditionalContext, TargetAdditionalContextSchema, type TargetBackground, TargetBackgroundSchema, TargetConnectionType, type TargetContextUpdate, TargetContextUpdateSchema, type TargetCreateRequest, TargetCreateRequestSchema, type TargetJobRequest, TargetJobRequestSchema, type TargetList, type TargetListItem, TargetListItemSchema, type TargetListOptions, TargetListSchema, type TargetMetadata, TargetMetadataSchema, type TargetProbeRequest, TargetProbeRequestSchema, type TargetProfileResponse, TargetProfileResponseSchema, type TargetReference, TargetReferenceSchema, type TargetResponse, TargetResponseSchema, TargetStatus, TargetType, type TargetUpdateRequest, TargetUpdateRequestSchema, ThreatCategory, type ThreatScanReport, ThreatScanReportSchema, type ToolDetected, ToolDetectedSchema, type ToolEvent, type ToolEventMetadata, ToolEventMetadataSchema, ToolEventSchema, TopicsClient, USER_AGENT, type UrlfEntry, UrlfEntrySchema, type ValidationError, ValidationErrorSchema, Verdict, Verdict as VerdictType, type ViolationList, ViolationListSchema, type ViolationResponse, ViolationResponseSchema, globalConfiguration, init };
|
|
33592
|
+
export { AISecSDKException, AI_SEC_API_ENDPOINT, AI_SEC_API_KEY, AI_SEC_API_TOKEN, ASYNC_SCAN_PATH, Action, Action as ActionType, type AgentMeta, AgentMetaSchema, type AiProfile, AiProfileSchema, ApiEndpointType, type AsyncScanObject, AsyncScanObjectSchema, type AsyncScanResponse, AsyncScanResponseSchema, type AttackDetailResponse, AttackDetailResponseSchema, type AttackListItem, AttackListItemSchema, type AttackListOptions, type AttackListResponse, AttackListResponseSchema, type AttackMultiTurnDetailResponse, AttackMultiTurnDetailResponseSchema, type AttackMultiTurnOutput, AttackMultiTurnOutputSchema, type AttackOutput, AttackOutputSchema, AttackStatus, AttackType, AuthType, BEARER, type BaseResponse, BaseResponseSchema, BrandSubCategory, Category, type CategoryModel, CategoryModelSchema, type CategoryReport, CategoryReportSchema, Category as CategoryType, type ComplianceReport, ComplianceReportSchema, ComplianceSubCategory, type ComplianceTechnique, ComplianceTechniqueSchema, Content, type ContentOptions, type CountByName, CountByNameSchema, CountedQuotaEnum, type CreateCustomTopicRequest, CreateCustomTopicRequestSchema, type CreateSecurityProfileRequest, CreateSecurityProfileRequestSchema, type CustomAttackOutput, CustomAttackOutputSchema, type CustomAttackReportResponse, CustomAttackReportResponseSchema, type CustomAttacksListResponse, CustomAttacksListResponseSchema, type CustomJobMetadata, CustomJobMetadataSchema, type CustomPromptCreateRequest, CustomPromptCreateRequestSchema, type CustomPromptList, type CustomPromptListItem, CustomPromptListItemSchema, CustomPromptListSchema, type CustomPromptResponse, CustomPromptResponseSchema, type CustomPromptSetArchiveRequest, CustomPromptSetArchiveRequestSchema, type CustomPromptSetCreateRequest, CustomPromptSetCreateRequestSchema, type CustomPromptSetList, type CustomPromptSetListActive, CustomPromptSetListActiveSchema, type CustomPromptSetListItem, CustomPromptSetListItemSchema, CustomPromptSetListSchema, type CustomPromptSetReference, CustomPromptSetReferenceSchema, type CustomPromptSetResponse, CustomPromptSetResponseSchema, type CustomPromptSetUpdateRequest, CustomPromptSetUpdateRequestSchema, type CustomPromptSetVersionInfo, CustomPromptSetVersionInfoSchema, type CustomPromptUpdateRequest, CustomPromptUpdateRequestSchema, type CustomTopic, type CustomTopicListResponse, CustomTopicListResponseSchema, CustomTopicSchema, DEFAULT_ENDPOINT, DEFAULT_MGMT_ENDPOINT, DEFAULT_MODEL_SEC_DATA_ENDPOINT, DEFAULT_MODEL_SEC_MGMT_ENDPOINT, DEFAULT_RED_TEAM_DATA_ENDPOINT, DEFAULT_RED_TEAM_MGMT_ENDPOINT, DEFAULT_TOKEN_ENDPOINT, type DSDetailResult, DSDetailResultSchema, type DSResultMetadata, DSResultMetadataSchema, type DashboardOverviewResponse, DashboardOverviewResponseSchema, DateRangeFilter, type DeleteProfileConflict, DeleteProfileConflictSchema, type DeleteProfileResponse, DeleteProfileResponseSchema, type DeleteTopicConflict, DeleteTopicConflictSchema, type DeleteTopicResponse, DeleteTopicResponseSchema, type DetectionServiceResult, DetectionServiceResultSchema, type DlpReport, DlpReportSchema, type DynamicJobMetadata, DynamicJobMetadataSchema, type DynamicJobReport, DynamicJobReportSchema, type DynamicJobReportStats, DynamicJobReportStatsSchema, ErrorCodes, type ErrorLog, type ErrorLogListResponse, ErrorLogListResponseSchema, ErrorLogSchema, type ErrorResponse, ErrorResponseSchema, ErrorSource, ErrorType, EvalOutcome, type EvalSummary, EvalSummarySchema, FileFormat, type FileList, FileListSchema, type FileResponse, FileResponseSchema, type FileScanData, FileScanDataSchema, FileScanResult, FileType, type Goal, type GoalListOptions, type GoalListResponse, GoalListResponseSchema, GoalSchema, GoalType, GoalTypeQueryParam, GuardrailAction, HEADER_API_KEY, HEADER_AUTH_TOKEN, type HTTPValidationError, HTTPValidationErrorSchema, HTTP_FORCE_RETRY_STATUS_CODES, type IODetected, IODetectedSchema, type InitOptions, type JobAbortResponse, JobAbortResponseSchema, type JobCreateRequest, JobCreateRequestSchema, type JobListResponse, JobListResponseSchema, type JobResponse, JobResponseSchema, JobStatus, JobStatusFilter, type JobTimeRecord, JobTimeRecordSchema, JobType, type Label, type LabelKeyList, LabelKeyListSchema, LabelSchema, type LabelValueList, LabelValueListSchema, type LabelsCreateRequest, LabelsCreateRequestSchema, type LabelsResponse, LabelsResponseSchema, type ListModelSecurityGroupsResponse, ListModelSecurityGroupsResponseSchema, type ListModelSecurityRuleInstancesResponse, ListModelSecurityRuleInstancesResponseSchema, type ListModelSecurityRulesResponse, ListModelSecurityRulesResponseSchema, MAX_AI_PROFILE_NAME_LENGTH, MAX_API_KEY_LENGTH, MAX_CONNECTION_POOL_SIZE, MAX_CONTENT_CONTEXT_LENGTH, MAX_CONTENT_PROMPT_LENGTH, MAX_CONTENT_RESPONSE_LENGTH, MAX_NUMBER_OF_BATCH_SCAN_OBJECTS, MAX_NUMBER_OF_REPORT_IDS, MAX_NUMBER_OF_RETRIES, MAX_NUMBER_OF_SCAN_IDS, MAX_REPORT_ID_STR_LENGTH, MAX_SCAN_ID_STR_LENGTH, MAX_SESSION_ID_STR_LENGTH, MAX_TOKEN_LENGTH, MAX_TRANSACTION_ID_STR_LENGTH, MGMT_CLIENT_ID, MGMT_CLIENT_SECRET, MGMT_ENDPOINT, MGMT_PROFILES_TSG_PATH, MGMT_PROFILE_PATH, MGMT_TOKEN_ENDPOINT, MGMT_TOPICS_TSG_PATH, MGMT_TOPIC_FORCE_PATH, MGMT_TOPIC_PATH, MGMT_TSG_ID, MODEL_SEC_CLIENT_ID, MODEL_SEC_CLIENT_SECRET, MODEL_SEC_DATA_ENDPOINT, MODEL_SEC_EVALUATIONS_PATH, MODEL_SEC_MGMT_ENDPOINT, MODEL_SEC_PYPI_AUTH_PATH, MODEL_SEC_SCANS_PATH, MODEL_SEC_SECURITY_GROUPS_PATH, MODEL_SEC_SECURITY_RULES_PATH, MODEL_SEC_TOKEN_ENDPOINT, MODEL_SEC_TSG_ID, MODEL_SEC_VIOLATIONS_PATH, ManagementClient, type ManagementClientOptions, type MaskedData, MaskedDataSchema, type Metadata, MetadataSchema, type ModelScanIssue, ModelScanIssueSchema, ModelScanStatus, ModelSecurityClient, type ModelSecurityClientOptions, type ModelSecurityFileListOptions, type ModelSecurityGroupCreateRequest, ModelSecurityGroupCreateRequestSchema, type ModelSecurityGroupResponse, ModelSecurityGroupResponseSchema, ModelSecurityGroupState, type ModelSecurityGroupUpdateRequest, ModelSecurityGroupUpdateRequestSchema, ModelSecurityGroupsClient, type ModelSecurityListOptions, type ModelSecurityPagination, ModelSecurityPaginationSchema, type ModelSecurityRuleInstanceResponse, ModelSecurityRuleInstanceResponseSchema, type ModelSecurityRuleInstanceUpdateRequest, ModelSecurityRuleInstanceUpdateRequestSchema, type ModelSecurityRuleResponse, ModelSecurityRuleResponseSchema, ModelSecurityRulesClient, type ModelSecurityScanListOptions, ModelSecurityScansClient, OAuthClient, type OAuthClientOptions, PAYLOAD_HASH, type PaginationOptions, type Policy, PolicySchema, PolicyType, type PrerequisiteModel, PrerequisiteModelSchema, ProfilesClient, ProfilingStatus, type PromptDetailResponse, PromptDetailResponseSchema, type PromptDetected, PromptDetectedSchema, type PromptDetectionDetails, PromptDetectionDetailsSchema, type PromptListOptions, type PromptSetListOptions, type PromptSetStats, PromptSetStatsSchema, type PromptSetSummary, PromptSetSummarySchema, type PromptSetsReportResponse, PromptSetsReportResponseSchema, type PropertyAssignment, PropertyAssignmentSchema, type PropertyDefinition, PropertyDefinitionSchema, type PropertyNameCreateRequest, PropertyNameCreateRequestSchema, type PropertyNamesListResponse, PropertyNamesListResponseSchema, type PropertyStatistic, PropertyStatisticSchema, type PropertyValueCreateRequest, PropertyValueCreateRequestSchema, type PropertyValueStatistic, PropertyValueStatisticSchema, type PropertyValuesMultipleResponse, PropertyValuesMultipleResponseSchema, type PropertyValuesResponse, PropertyValuesResponseSchema, type PyPIAuthResponse, PyPIAuthResponseSchema, type QuotaDetails, QuotaDetailsSchema, type QuotaSummary, QuotaSummarySchema, RED_TEAM_CATEGORIES_PATH, RED_TEAM_CLIENT_ID, RED_TEAM_CLIENT_SECRET, RED_TEAM_CUSTOM_ATTACKS_REPORT_PATH, RED_TEAM_CUSTOM_ATTACK_PATH, RED_TEAM_DASHBOARD_PATH, RED_TEAM_DATA_ENDPOINT, RED_TEAM_ERROR_LOG_PATH, RED_TEAM_MGMT_DASHBOARD_PATH, RED_TEAM_MGMT_ENDPOINT, RED_TEAM_QUOTA_PATH, RED_TEAM_REPORT_DYNAMIC_PATH, RED_TEAM_REPORT_PATH, RED_TEAM_REPORT_STATIC_PATH, RED_TEAM_SCAN_PATH, RED_TEAM_SENTIMENT_PATH, RED_TEAM_TARGET_PATH, RED_TEAM_TOKEN_ENDPOINT, RED_TEAM_TSG_ID, RedTeamCategory, RedTeamClient, type RedTeamClientOptions, RedTeamCustomAttackReportsClient, RedTeamCustomAttacksClient, RedTeamErrorType, type RedTeamListOptions, type RedTeamPagination, RedTeamPaginationSchema, RedTeamReportsClient, type RedTeamScanListOptions, RedTeamScansClient, RedTeamTargetsClient, type RemediationDetail, RemediationDetailSchema, type RemediationResponse, RemediationResponseSchema, type ResponseDetected, ResponseDetectedSchema, type ResponseDetectionDetails, ResponseDetectionDetailsSchema, ResponseMode, type RiskLevel, RiskLevelSchema, RiskRating, type RuleConfiguration, RuleConfigurationSchema, type RuleEditableField, type RuleEditableFieldDropdown, RuleEditableFieldDropdownSchema, RuleEditableFieldSchema, RuleEditableFieldType, type RuleEvaluationList, RuleEvaluationListSchema, type RuleEvaluationResponse, RuleEvaluationResponseSchema, RuleEvaluationResult, RuleFieldValueKey, type RuleRemediation, RuleRemediationSchema, RuleState, RuleType, type RuntimeSecurityPolicy, RuntimeSecurityPolicySchema, type RuntimeSecurityProfileResponse, RuntimeSecurityProfileResponseSchema, SCAN_REPORTS_PATH, SCAN_RESULTS_PATH, SDK_VERSION, SYNC_SCAN_PATH, SafetySubCategory, type ScanBaseResponse, ScanBaseResponseSchema, type ScanCreateRequest, ScanCreateRequestSchema, type ScanDetails, ScanDetailsSchema, type ScanIdResult, ScanIdResultSchema, type ScanList, ScanListSchema, ScanOrigin, type ScanRequest, type ScanRequestContentsInner, ScanRequestContentsInnerSchema, ScanRequestSchema, type ScanResponse, ScanResponseSchema, type ScanStatisticsResponse, ScanStatisticsResponseSchema, type ScanSummary, ScanSummarySchema, Scanner, type ScoreTrendResponse, ScoreTrendResponseSchema, type ScoreTrendSeries, ScoreTrendSeriesSchema, type SecurityProfile, type SecurityProfileListResponse, SecurityProfileListResponseSchema, SecurityProfileSchema, SecuritySubCategory, type SentimentRequest, SentimentRequestSchema, type SentimentResponse, SentimentResponseSchema, SeverityFilter, type SeverityReport, SeverityReportSchema, type SeverityStats, SeverityStatsSchema, SortByDateField, SortByFileField, SortDirection, SourceType, type StaticJobMetadata, StaticJobMetadataSchema, type StaticJobRemediation, type StaticJobRemediationRecommendation, StaticJobRemediationRecommendationSchema, StaticJobRemediationSchema, type StaticJobReport, StaticJobReportSchema, type StaticJobReportStats, StaticJobReportStatsSchema, StatusQueryParam, type StreamDetailResponse, StreamDetailResponseSchema, type StreamIterationData, StreamIterationDataSchema, type StreamListResponse, StreamListResponseSchema, StreamType, type SubCategoryModel, SubCategoryModelSchema, type SubCategoryStats, SubCategoryStatsSchema, type SyncScanOptions, type TargetAdditionalContext, TargetAdditionalContextSchema, type TargetBackground, TargetBackgroundSchema, TargetConnectionType, type TargetContextUpdate, TargetContextUpdateSchema, type TargetCreateRequest, TargetCreateRequestSchema, type TargetJobRequest, TargetJobRequestSchema, type TargetList, type TargetListItem, TargetListItemSchema, type TargetListOptions, TargetListSchema, type TargetMetadata, TargetMetadataSchema, type TargetProbeRequest, TargetProbeRequestSchema, type TargetProfileResponse, TargetProfileResponseSchema, type TargetReference, TargetReferenceSchema, type TargetResponse, TargetResponseSchema, TargetStatus, TargetType, type TargetUpdateRequest, TargetUpdateRequestSchema, ThreatCategory, type ThreatScanReport, ThreatScanReportSchema, type TokenInfo, type ToolDetected, ToolDetectedSchema, type ToolEvent, type ToolEventMetadata, ToolEventMetadataSchema, ToolEventSchema, TopicsClient, USER_AGENT, type UrlfEntry, UrlfEntrySchema, type ValidationError, ValidationErrorSchema, Verdict, Verdict as VerdictType, type ViolationList, ViolationListSchema, type ViolationResponse, ViolationResponseSchema, globalConfiguration, init };
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
|
|
|
23
23
|
var MAX_CONNECTION_POOL_SIZE = 100;
|
|
24
24
|
var MAX_NUMBER_OF_RETRIES = 5;
|
|
25
25
|
var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
|
|
26
|
-
var SDK_VERSION = "0.
|
|
26
|
+
var SDK_VERSION = "0.5.0";
|
|
27
27
|
var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
|
|
28
28
|
var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
29
29
|
var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
@@ -2309,12 +2309,14 @@ var OAuthTokenResponseSchema = z19.object({
|
|
|
2309
2309
|
});
|
|
2310
2310
|
|
|
2311
2311
|
// src/management/oauth-client.ts
|
|
2312
|
-
var
|
|
2312
|
+
var DEFAULT_TOKEN_BUFFER_MS = 3e4;
|
|
2313
2313
|
var OAuthClient = class {
|
|
2314
2314
|
tokenEndpoint;
|
|
2315
2315
|
clientId;
|
|
2316
2316
|
clientSecret;
|
|
2317
2317
|
tsgId;
|
|
2318
|
+
tokenBufferMs;
|
|
2319
|
+
onTokenRefresh;
|
|
2318
2320
|
accessToken = null;
|
|
2319
2321
|
expiresAt = 0;
|
|
2320
2322
|
pendingFetch = null;
|
|
@@ -2323,13 +2325,15 @@ var OAuthClient = class {
|
|
|
2323
2325
|
this.clientSecret = opts.clientSecret;
|
|
2324
2326
|
this.tsgId = opts.tsgId;
|
|
2325
2327
|
this.tokenEndpoint = opts.tokenEndpoint ?? DEFAULT_TOKEN_ENDPOINT;
|
|
2328
|
+
this.tokenBufferMs = opts.tokenBufferMs ?? DEFAULT_TOKEN_BUFFER_MS;
|
|
2329
|
+
this.onTokenRefresh = opts.onTokenRefresh;
|
|
2326
2330
|
}
|
|
2327
2331
|
/**
|
|
2328
2332
|
* Get a valid access token, refreshing if needed.
|
|
2329
2333
|
* @returns Bearer access token string.
|
|
2330
2334
|
*/
|
|
2331
2335
|
async getToken() {
|
|
2332
|
-
if (this.accessToken && Date.now() < this.expiresAt -
|
|
2336
|
+
if (this.accessToken && Date.now() < this.expiresAt - this.tokenBufferMs) {
|
|
2333
2337
|
return this.accessToken;
|
|
2334
2338
|
}
|
|
2335
2339
|
if (this.pendingFetch) {
|
|
@@ -2345,6 +2349,40 @@ var OAuthClient = class {
|
|
|
2345
2349
|
this.accessToken = null;
|
|
2346
2350
|
this.expiresAt = 0;
|
|
2347
2351
|
}
|
|
2352
|
+
/** Check if the current token has passed its expiry time. Returns true if no token exists. */
|
|
2353
|
+
isTokenExpired() {
|
|
2354
|
+
if (!this.accessToken) return true;
|
|
2355
|
+
return Date.now() >= this.expiresAt;
|
|
2356
|
+
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Check if the token is within the pre-expiry buffer window.
|
|
2359
|
+
* Returns true if no token exists.
|
|
2360
|
+
* @param bufferMs - Custom buffer in ms. Defaults to the configured `tokenBufferMs`.
|
|
2361
|
+
*/
|
|
2362
|
+
isTokenExpiringSoon(bufferMs) {
|
|
2363
|
+
if (!this.accessToken) return true;
|
|
2364
|
+
const buffer = bufferMs ?? this.tokenBufferMs;
|
|
2365
|
+
return Date.now() >= this.expiresAt - buffer;
|
|
2366
|
+
}
|
|
2367
|
+
/**
|
|
2368
|
+
* Get a snapshot of the current token state without exposing the actual token value.
|
|
2369
|
+
* @returns Current {@link TokenInfo}.
|
|
2370
|
+
*/
|
|
2371
|
+
getTokenInfo() {
|
|
2372
|
+
const now = Date.now();
|
|
2373
|
+
const hasToken = this.accessToken !== null;
|
|
2374
|
+
const isExpired = !hasToken || now >= this.expiresAt;
|
|
2375
|
+
const isExpiringSoon = !hasToken || now >= this.expiresAt - this.tokenBufferMs;
|
|
2376
|
+
const expiresInMs = hasToken ? Math.max(0, this.expiresAt - now) : 0;
|
|
2377
|
+
return {
|
|
2378
|
+
hasToken,
|
|
2379
|
+
isValid: hasToken && !isExpiringSoon,
|
|
2380
|
+
isExpired,
|
|
2381
|
+
isExpiringSoon,
|
|
2382
|
+
expiresInMs,
|
|
2383
|
+
expiresAt: hasToken ? this.expiresAt : 0
|
|
2384
|
+
};
|
|
2385
|
+
}
|
|
2348
2386
|
async fetchToken() {
|
|
2349
2387
|
const credentials = btoa(`${this.clientId}:${this.clientSecret}`);
|
|
2350
2388
|
const body = new URLSearchParams({
|
|
@@ -2380,6 +2418,12 @@ var OAuthClient = class {
|
|
|
2380
2418
|
const data = OAuthTokenResponseSchema.parse(await response.json());
|
|
2381
2419
|
this.accessToken = data.access_token;
|
|
2382
2420
|
this.expiresAt = Date.now() + data.expires_in * 1e3;
|
|
2421
|
+
if (this.onTokenRefresh) {
|
|
2422
|
+
try {
|
|
2423
|
+
this.onTokenRefresh(this.getTokenInfo());
|
|
2424
|
+
} catch {
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2383
2427
|
return this.accessToken;
|
|
2384
2428
|
}
|
|
2385
2429
|
};
|
|
@@ -2411,7 +2455,7 @@ async function managementHttpRequest(opts) {
|
|
|
2411
2455
|
return fetch(url.toString(), { method, headers, body: bodyStr });
|
|
2412
2456
|
},
|
|
2413
2457
|
onRetryableFailure: async (response2) => {
|
|
2414
|
-
if (response2.status === 401 && !hadTokenRefresh) {
|
|
2458
|
+
if ((response2.status === 401 || response2.status === 403) && !hadTokenRefresh) {
|
|
2415
2459
|
hadTokenRefresh = true;
|
|
2416
2460
|
oauthClient.clearToken();
|
|
2417
2461
|
return true;
|
|
@@ -4556,6 +4600,7 @@ export {
|
|
|
4556
4600
|
ModelSecurityRuleResponseSchema,
|
|
4557
4601
|
ModelSecurityRulesClient,
|
|
4558
4602
|
ModelSecurityScansClient,
|
|
4603
|
+
OAuthClient,
|
|
4559
4604
|
PAYLOAD_HASH,
|
|
4560
4605
|
PolicySchema,
|
|
4561
4606
|
PolicyType,
|