# License File

For more info see:

* <https://docs.licensespring.com/sdks/tutorials/best-practices/local-license-file>
* <https://docs.licensespring.com/sdks/python/licensefile>

To load a local license file, create an instance of LicenseManager and call the method loadLicense:

{% code title="example.js" %}

```javascript
const licenseFile = licenseManager.loadLicense();
```

{% endcode %}

The License class provides an interface for working with the License File.

### Methods

#### Create Offline Request File

Creates an `activate_offline.req` or `deactivate_offline.req` file for offline activation/deactivation at the specified path:

{% code title="signature.ts" %}

```typescript
createRequestFile(request: OfflineActivation, offlinePath: string)
```

{% endcode %}

Type declaration for OfflineActivation:

{% code title="types.ts" %}

```typescript
interface OfflineActivation {
  isActivation: boolean; // true for activation, false for deactivation
  isGuardFileEnabled: boolean; // should a guard file be created
  guard: any // guard file data if required, created using: licenseAPI.createActivationGuard(licenseKey)
  data: { // license data
    product: string,
    hardware_id: string,
    license_key?: string,
    license_id?: number,
    username?: string,
    password?: string,
    app_ver?: string,
    os_ver?: string,
    hostname?: string,
    ip?: string,
    is_vm?: boolean,
    vm_info?: string,
    mac_address?: string,
    variables?: {
      [key: string]: boolean | number | string
    },
  };
}
```

{% endcode %}

#### Get Feature Data

{% code title="signature.ts" %}

```typescript
featureData(featureCode: string): ProductFeature
```

{% endcode %}

#### Check License Status

Throws an exception if the license is disabled, inactive or expired

{% code title="signature.ts" %}

```typescript
checkLicenseStatus(): void
```

{% endcode %}

#### Perform Full License Check

Checks License status and saves to local license file

{% code title="signature.ts" %}

```typescript
check(includeExpiredFeatures: boolean = false): Promise<LicenseResponse>
```

{% endcode %}

#### Air-Gap License Activation Code

For more info see: <https://docs.licensespring.com/license-entitlements/activation-types/air-gapped>

{% code title="signatures.ts" %}

```typescript
getDeactivationCode(initializationCode: string): string

deactivateAirGap(confirmationCode: string): void
```

{% endcode %}

#### Deactivate License

Deactivates a License, updates local license file. Optionally deletes license file

{% code title="signature.ts" %}

```typescript
deactivate(deleteLicense: boolean = false): Promise<boolean>
```

{% endcode %}

#### Local License Check

Performs a local check using the local license file. Throws an exception if license is not valid

{% code title="signature.ts" %}

```typescript
localCheck(): Promise<true>
```

{% endcode %}

#### Change Password

Performs password change for user associated to License

{% code title="signature.ts" %}

```typescript
changePassword(oldPassword: string, newPassword: string): Promise<boolean>
```

{% endcode %}

#### Add Local Consumption

Adds a License consumption to the local license data

{% code title="signature.ts" %}

```typescript
addLocalConsumption(consumptions: number = 1)
```

{% endcode %}

#### Add Local Feature Consumption

Adds a License feature consumption to the local license data

{% code title="signature.ts" %}

```typescript
addLocalFeatureConsumption(featureCode: string, consumptions: number = 1)
```

{% endcode %}

#### Sync License Feature Consumption

Sends a feature consumption request to the server and updates local data

{% code title="signature.ts" %}

```typescript
syncFeatureConsumption(feature: { code: string, local_consumption: number }): Promise<boolean>
```

{% endcode %}

#### Sync License Consumptions

Syncs local consumptions to server

{% code title="signature.ts" %}

```typescript
syncConsumption(overages: number = -1): Promise<boolean>
```

{% endcode %}

#### Borrow Floating License

{% code title="signature.ts" %}

```typescript
floatingBorrow(borrowUntil: string, password?: string): Promise<boolean>
```

{% endcode %}

#### Release Floating License

{% code title="signature.ts" %}

```typescript
floatingRelease(): Promise<boolean>
```

{% endcode %}

#### Check Feature

Checks License Feature status, throws exception if not active

{% code title="signature.ts" %}

```typescript
checkFeature(featureCode: string): Promise<void>
```

{% endcode %}

#### Release Borrowed Feature

{% code title="signature.ts" %}

```typescript
releaseFeature(featureCode: string): Promise<void>
```

{% endcode %}

#### Update Offline

Update local cache from Offline License File (at given `path`). Optionally reset local consumption value

{% code title="signature.ts" %}

```typescript
updateOffline(path: string, resetConsumption: boolean): boolean
```

{% endcode %}

#### Deactivate License Offline

{% code title="signature.ts" %}

```typescript
deactivateOffline(offlinePath: string): Promise<void>
```

{% endcode %}

#### Get Product Details

Retrieves Product Details from server:

{% code title="signature.ts" %}

```typescript
productDetails(includeLatestVersion: boolean = false, includeCustomFields: boolean = false, includeExpiredFeatures: boolean = false): Promise<ProductDetailsResponse>
```

{% endcode %}

Retrieve Product Details from local data:

{% code title="getter.ts" %}

```typescript
get productDetailsLocal()
```

{% endcode %}

#### Device Variables

Set custom variables to local data:

{% code title="signature.ts" %}

```typescript
setDeviceVariablesLocal(variables: { [key: string]: string|number }, save: boolean = true): void
```

{% endcode %}

Send locally stored variables to server, optionally save to license file:

{% code title="signature.ts" %}

```typescript
setDeviceVariables(save: boolean = false): Promise<void>
```

{% endcode %}

Get the value of a variable from local data:

{% code title="signature.ts" %}

```typescript
getDeviceVariableLocal(variable: string)
```

{% endcode %}

Get all variables from local data:

{% code title="signature.ts" %}

```typescript
getDeviceVariablesLocal()
```

{% endcode %}

Get all variables from server:

{% code title="signature.ts" %}

```typescript
getDeviceVariables(): Promise<DeviceVariable[]>
```

{% endcode %}

#### Getters

{% code title="getters.js" %}

```javascript
get allowGraceSubscriptionPeriod()
get allowOverages()
get allowUnlimitedActivations()
get allowUnlimitedConsumptions()
get borrowUntil()
get consumptionPeriod()
get consumptionReset()
get customerInformation()
get customFields()
get daysRemaining()
get daysSinceLastCheck()
get expiryDate()
get features()
get floatingClientId()
get floatingEndDate()
get floatingInUseDevices()
get floatingTimeout()
get gracePeriod()
get gracePeriodHoursRemaining()
get id()
get isAirGapped()
get isBorrowed()
get isControlledByFloatingServer()
get isDeviceTransferAllowed()
get isDeviceTransferLimited()
get isExpired()
get isFloating()
get isFloatingExpired()
get isGracePeriod()
get isGracePeriodStarted()
get isMaintenancePeriodExpired()
get isSubcriptionGracePeriodStarted()
get isTrial()
get isValid()
get isValidityPeriodExpired()
get lastCheck()
get lastUsage()
get licenseActive()
get licenseEnabled()
get licenseKey()
get licenseType()
get licenseUser()
get localConsumptions()
get maintenanceDaysRemaining()
get maintenancePeriod()
get maxActivations()
get maxConsumptions()
get maxFloatingUsers()
get maxOverages()
get maxTransfers()
get metadata()
get policyID()
get preventVm()
get startDate()
get subscriptionGracePeriod()
get totalConsumptions()
get transferCount()
get validityPeriod()
get validityWithGracePeriod()
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.licensespring.com/sdks/node.js-sdk/license-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
