Installation identity API
configureInstallationIdentity Identity
Configures the installation identity's Storage business key at application startup.
Signature
ts
export function configureInstallationIdentity(options: InstallationIdentityConfiguration = {}): void;Example
ts
import { configureInstallationIdentity } from "@fast-china/utils";
configureInstallationIdentity({ cacheKey: "identity:device" });Input
| Input | Type | Required / default | Description |
|---|---|---|---|
options | InstallationIdentityConfiguration | Optional; defaults to {} | Installation identity settings; cacheKey defaults to identity:installation-id. |
Returns
| Value | Type | Description |
|---|---|---|
result | void | No return value. |
getOrCreateInstallationId Identity
Returns the existing installation identity or creates and persists a UUID v4.
Signature
ts
export function getOrCreateInstallationId(installationId?: string): string;Example
ts
import { getOrCreateInstallationId } from "@fast-china/utils";
const result = getOrCreateInstallationId();Input
| Input | Type | Required / default | Description |
|---|---|---|---|
installationId | string | Optional | Optional explicit installation identity; validated and persisted over the current value when supplied. |
Returns
| Value | Type | Description |
|---|---|---|
result | string | Final identity selected from explicit, in-memory, persisted, or newly generated values. |
installationIdentity.getOrCreate Identity
Gets the installation UUID in order: explicit value, memory, storage, random generation.
Signature
ts
getOrCreate(installationId?: string): string;Example
ts
import { installationIdentity } from "@fast-china/utils";
const result = installationIdentity.getOrCreate();Input
| Input | Type | Required / default | Description |
|---|---|---|---|
installationId | string | Optional | UUID v4 supplied to override the current identity. |
Returns
| Value | Type | Description |
|---|---|---|
result | string | Validated UUID v4 written to memory and Local Storage. |
installationIdentity.read Read
Reads and validates the persisted identity without changing the in-memory deviceId.
Signature
ts
read(): string | undefined;Example
ts
import { installationIdentity } from "@fast-china/utils";
const result = installationIdentity.read();Input
This method has no input parameters.
Returns
| Value | Type | Description |
|---|---|---|
result | string | undefined | Persisted UUID v4, or undefined when missing or expired. |
installationIdentity.clear Clear
Removes the persisted identity and clears the in-memory deviceId.
Signature
ts
clear(): void;Example
ts
import { installationIdentity } from "@fast-china/utils";
installationIdentity.clear();Input
This method has no input parameters.
Returns
| Value | Type | Description |
|---|---|---|
result | void | No return value. |
