Provides consistent identity creation, validation, and management APIs. An "identity" represents a user with separate NFC and RFID credentials. NFC cards are high-security (require physical tap), while RFID badges are lower-security (can be scanned at distance).
View on GitHub →-- In your extension:
function MyExtension.init(tac)
-- Create an identity with both NFC and RFID
local identity, err = tac.identityManager.createIdentity({
name = "John Doe",
tags = {"tenant.1", "vip"},
nfcEnabled = true,
rfidEnabled = true,
maxDistance = 3.0 -- Max RFID scan distance
})
-- Create a subscription identity
local subIdentity, err = tac.identityManager.createSubscriptionIdentity({
username = "player1",
duration = 30,
slot = "tenant.premium",
nfcEnabled = true,
rfidEnabled = false
})
-- Renew an identity
tac.identityManager.renewIdentity("tenant_1_player1", 30)
-- Get identity info
local info, err = tac.identityManager.getIdentityInfo("tenant_1_player1")
if info then
print("Identity expires in " .. (info.timeUntilExpiration / 86400000) .. " days")
end
-- Regenerate RFID data for an identity
tac.identityManager.regenerateRfid("tenant_1_player1")
end
identityManager.createIdentity(options)Create a new identity with standard validation and logging Creates an identity with separate NFC and RFID credentials. NFC data is the primary identifier, RFID data is a separate scannable token. - id (string, optional): Identity ID (auto-generated if not provided) - name (string, required): Display name for the identity - tags (table, required): Array of access tags - nfcEnabled (boolean, optional): Enable NFC access (default: true) - rfidEnabled (boolean, optional): Enable RFID access (default: true) - nfcData (string, optional): NFC card data (auto-generated if not provided) - rfidData (string, optional): RFID badge data (auto-generated if not provided) - maxDistance (number, optional): Max RFID scan distance (default: nil = use door setting) - expiration (number, optional): UTC epoch timestamp when identity expires - username (string, optional): Username associated with identity (used in ID generation) - prefix (string, optional): Prefix for auto-generated ID - createdBy (string, optional): Who/what created the identity (default: "system") - metadata (table, optional): Additional custom data - logMessage (string, optional): Custom log message
options (table): Identity creation options:identityManager.createSubscriptionIdentity(options)Create a subscription identity (with expiration) Specialized function for creating time-limited subscription identities. Commonly used by ShopK integration for selling temporary access. - username (string, required): Username of the subscriber - duration (number, required): Subscription duration in days - slot (string, required): Access level/slot (becomes the identity tag) - nfcEnabled (boolean, optional): Enable NFC access (default: true) - rfidEnabled (boolean, optional): Enable RFID access (default: true) - maxDistance (number, optional): Max RFID scan distance - createdBy (string, optional): Creator identifier (default: "shopk") - purchaseValue (number, optional): Purchase price for metadata - transactionId (string, optional): Transaction ID for metadata - logMessage (string, optional): Custom log message
options (table): Subscription identity options:identityManager.renewIdentity(identityId, additionalDuration, options)Renew an existing identity Extends the expiration date of an existing identity by the specified duration. Updates renewal metadata and logs the renewal event. - renewedBy (string, optional): Who renewed the identity (default: "system") - transactionId (string, optional): Transaction ID for metadata - logMessage (string, optional): Custom log message
identityId (string): ID of the identity to renewadditionalDuration (number): Days to add to current expirationoptions (table): Optional renewal options:identityManager.regenerateRfid(identityId)Regenerate RFID data for an identity Creates a new RFID token for the identity, invalidating the old one. Useful if an RFID badge is lost or compromised.
identityId (string): ID of the identityidentityManager.setNfcData(identityId, nfcData)Set NFC data for an identity Associates NFC card data with an identity. Called after writing an NFC card.
identityId (string): ID of the identitynfcData (string): The NFC card dataidentityManager.setRfidData(identityId, rfidData)Set RFID data for an identity Associates RFID badge data with an identity. Useful when reprogramming RFID cards using the server writer.
identityId (string): ID of the identityrfidData (string): The RFID badge dataidentityManager.findByNfc(nfcData)Look up identity by NFC data
nfcData (string): The NFC card dataidentityManager.findByRfid(rfidData)Look up identity by RFID data
rfidData (string): The RFID badge dataidentityManager.getIdentityInfo(identityId)Get identity status and info Retrieves comprehensive information about an identity including expiration status. Returns structured data with calculated fields like isExpired and timeUntilExpiration. - id (string): Identity ID - name (string): Identity display name - tags (table): Access tags array - nfcEnabled (boolean): Whether NFC is enabled - rfidEnabled (boolean): Whether RFID is enabled - hasNfcData (boolean): Whether NFC card data is set - hasRfidData (boolean): Whether RFID badge data is set - maxDistance (number|nil): Max RFID scan distance - created (number): Creation timestamp - createdBy (string): Creator identifier - isExpired (boolean): Whether identity is currently expired - timeUntilExpiration (number|nil): Milliseconds until expiration (nil if no expiration) - expiration (number|nil): Expiration timestamp if set - metadata (table): Custom metadata
identityId (string): ID of the identity to queryidentityManager.isValidIdentityId(identityId)Validate identity ID format Checks if an identity ID meets basic format requirements (non-empty string).
identityId (any): Value to validate as an identity IDidentityManager.canAccess(identityId, accessMethod)Check if identity is valid for a specific access method
identityId (string): Identity IDaccessMethod (string): "nfc" or "rfid"identityManager.updateIdentity(identityId, updates)Update identity settings (enable/disable access methods, distance, etc.)
identityId (string): Identity IDupdates (table): Fields to update (nfcEnabled, rfidEnabled, maxDistance, tags, name)identityManager.deleteIdentity(identityId)Delete an identity
identityId (string): Identity ID