@stamprally/core 0.7.0 → 0.8.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 +368 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +134 -1
- package/dist/index.d.ts +134 -1
- package/dist/index.js +368 -61
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -246,6 +246,7 @@ interface ThemePreset<TLocale extends string = SupportedLocale> {
|
|
|
246
246
|
readonly theme: SheetTheme;
|
|
247
247
|
}
|
|
248
248
|
declare const DEFAULT_SHEET_THEME: SheetTheme;
|
|
249
|
+
/** @deprecated Use UniversalSpotItem from the universal model. */
|
|
249
250
|
interface SpotItem<TLocale extends string = SupportedLocale, TMeta extends Record<string, unknown> = Record<string, unknown>> {
|
|
250
251
|
readonly id: string;
|
|
251
252
|
readonly name: LocalizedText$1<TLocale>;
|
|
@@ -325,6 +326,7 @@ interface StampRallyState {
|
|
|
325
326
|
readonly rewards?: ReadonlyArray<RewardState>;
|
|
326
327
|
readonly updatedAt: string;
|
|
327
328
|
}
|
|
329
|
+
/** @deprecated Use AdminRallyConfig or PublicRallyConfig from the universal model. */
|
|
328
330
|
interface RallyConfig<TLocale extends string = SupportedLocale, TMeta extends Record<string, unknown> = Record<string, unknown>> {
|
|
329
331
|
readonly id: string;
|
|
330
332
|
readonly title?: LocalizedText$1<TLocale>;
|
|
@@ -588,6 +590,137 @@ declare class StampRallyClient {
|
|
|
588
590
|
restore(state: StampRallyState): Promise<StampRallyState>;
|
|
589
591
|
}
|
|
590
592
|
|
|
593
|
+
type UserRallyState = StampRallyState;
|
|
594
|
+
type CustomValidator = (context: {
|
|
595
|
+
readonly spotId: string;
|
|
596
|
+
readonly proofData: unknown;
|
|
597
|
+
readonly config: PublicRallyConfig;
|
|
598
|
+
readonly userState: UserRallyState;
|
|
599
|
+
}) => Promise<{
|
|
600
|
+
readonly success: boolean;
|
|
601
|
+
readonly error?: string;
|
|
602
|
+
}>;
|
|
603
|
+
interface CheckInOptions {
|
|
604
|
+
readonly now?: string;
|
|
605
|
+
readonly idempotencyKey?: string;
|
|
606
|
+
readonly sync?: boolean;
|
|
607
|
+
}
|
|
608
|
+
interface ClaimOptions {
|
|
609
|
+
readonly now?: string;
|
|
610
|
+
readonly idempotencyKey?: string;
|
|
611
|
+
readonly staffPasscode?: string;
|
|
612
|
+
readonly staffId?: string;
|
|
613
|
+
readonly sync?: boolean;
|
|
614
|
+
}
|
|
615
|
+
interface UniversalClientRequest {
|
|
616
|
+
readonly rallyId: string;
|
|
617
|
+
readonly spotId: string;
|
|
618
|
+
readonly proofData: unknown;
|
|
619
|
+
readonly idempotencyKey: string;
|
|
620
|
+
readonly now: string;
|
|
621
|
+
readonly state: UserRallyState;
|
|
622
|
+
}
|
|
623
|
+
interface UniversalClaimRequest {
|
|
624
|
+
readonly rallyId: string;
|
|
625
|
+
readonly rewardId: string;
|
|
626
|
+
readonly idempotencyKey: string;
|
|
627
|
+
readonly now: string;
|
|
628
|
+
readonly options: ClaimOptions;
|
|
629
|
+
readonly state: UserRallyState;
|
|
630
|
+
}
|
|
631
|
+
type UniversalClientError = {
|
|
632
|
+
readonly code: "SPOT_NOT_FOUND";
|
|
633
|
+
readonly spotId: string;
|
|
634
|
+
readonly message: string;
|
|
635
|
+
} | {
|
|
636
|
+
readonly code: "STAMP_ALREADY_ACQUIRED";
|
|
637
|
+
readonly spotId: string;
|
|
638
|
+
readonly message: string;
|
|
639
|
+
} | {
|
|
640
|
+
readonly code: "PREREQUISITES_NOT_MET";
|
|
641
|
+
readonly spotId: string;
|
|
642
|
+
readonly message: string;
|
|
643
|
+
} | {
|
|
644
|
+
readonly code: "INVALID_PROOF";
|
|
645
|
+
readonly spotId: string;
|
|
646
|
+
readonly message: string;
|
|
647
|
+
} | {
|
|
648
|
+
readonly code: "CUSTOM_VALIDATION_FAILED";
|
|
649
|
+
readonly spotId: string;
|
|
650
|
+
readonly message: string;
|
|
651
|
+
} | {
|
|
652
|
+
readonly code: "REWARD_NOT_FOUND";
|
|
653
|
+
readonly rewardId: string;
|
|
654
|
+
readonly message: string;
|
|
655
|
+
} | {
|
|
656
|
+
readonly code: "SYNC_FAILED";
|
|
657
|
+
readonly message: string;
|
|
658
|
+
} | {
|
|
659
|
+
readonly code: "REMOTE_ERROR";
|
|
660
|
+
readonly message: string;
|
|
661
|
+
} | RewardConsumeError;
|
|
662
|
+
interface CheckInSuccess {
|
|
663
|
+
readonly state: UserRallyState;
|
|
664
|
+
readonly record: StampRecord$1;
|
|
665
|
+
}
|
|
666
|
+
type UniversalCheckInResult = Result<CheckInSuccess, UniversalClientError>;
|
|
667
|
+
type ClientCheckInResult = UniversalCheckInResult;
|
|
668
|
+
interface ClaimSuccess {
|
|
669
|
+
readonly state: UserRallyState;
|
|
670
|
+
readonly reward: RewardState;
|
|
671
|
+
}
|
|
672
|
+
type UniversalClaimResult = Result<ClaimSuccess, UniversalClientError>;
|
|
673
|
+
type ClaimResult = UniversalClaimResult;
|
|
674
|
+
type ClientClaimResult = UniversalClaimResult;
|
|
675
|
+
type UniversalClientEvent = {
|
|
676
|
+
readonly type: "checkIn";
|
|
677
|
+
readonly result: UniversalCheckInResult;
|
|
678
|
+
} | {
|
|
679
|
+
readonly type: "rewardClaimed";
|
|
680
|
+
readonly result: UniversalClaimResult;
|
|
681
|
+
} | {
|
|
682
|
+
readonly type: "sync";
|
|
683
|
+
readonly state: UserRallyState;
|
|
684
|
+
} | {
|
|
685
|
+
readonly type: "error";
|
|
686
|
+
readonly error: UniversalClientError;
|
|
687
|
+
};
|
|
688
|
+
type UniversalClientListener = (state: UserRallyState) => void;
|
|
689
|
+
type UniversalClientEventListener = (event: UniversalClientEvent) => void;
|
|
690
|
+
interface UniversalClientSyncAdapter {
|
|
691
|
+
readonly checkIn?: (request: UniversalClientRequest) => Promise<UniversalCheckInResult>;
|
|
692
|
+
readonly claimReward?: (request: UniversalClaimRequest) => Promise<UniversalClaimResult>;
|
|
693
|
+
readonly sync?: (request: {
|
|
694
|
+
readonly rallyId: string;
|
|
695
|
+
readonly state: UserRallyState;
|
|
696
|
+
}) => Promise<UserRallyState>;
|
|
697
|
+
}
|
|
698
|
+
interface UniversalStampRallyClientOptions {
|
|
699
|
+
readonly storage?: StampStorage;
|
|
700
|
+
readonly syncAdapter?: UniversalClientSyncAdapter;
|
|
701
|
+
readonly customValidator?: CustomValidator;
|
|
702
|
+
readonly customValidators?: Readonly<Record<string, CustomValidator>>;
|
|
703
|
+
readonly clock?: () => string;
|
|
704
|
+
}
|
|
705
|
+
type UniversalClientOptionsOrStorage = UniversalStampRallyClientOptions | StampStorage;
|
|
706
|
+
/**
|
|
707
|
+
* Storage- and framework-independent client state machine for a public rally.
|
|
708
|
+
* All operations create new state snapshots and notify subscribers after persistence.
|
|
709
|
+
*/
|
|
710
|
+
declare class UniversalStampRallyClient {
|
|
711
|
+
#private;
|
|
712
|
+
constructor(config: PublicRallyConfig, storageOrOptions?: UniversalClientOptionsOrStorage, clock?: () => string);
|
|
713
|
+
getConfig(): PublicRallyConfig;
|
|
714
|
+
getState(): UserRallyState | null;
|
|
715
|
+
subscribe(listener: UniversalClientListener): () => void;
|
|
716
|
+
subscribeEvents(listener: UniversalClientEventListener): () => void;
|
|
717
|
+
init(): Promise<UserRallyState>;
|
|
718
|
+
initialize(): Promise<UserRallyState>;
|
|
719
|
+
checkIn(spotId: string, proofData: unknown, options?: CheckInOptions): Promise<UniversalCheckInResult>;
|
|
720
|
+
claimReward(rewardId: string, options?: ClaimOptions): Promise<UniversalClaimResult>;
|
|
721
|
+
sync(adapter?: UniversalClientSyncAdapter): Promise<void>;
|
|
722
|
+
}
|
|
723
|
+
|
|
591
724
|
type SecureTokenSecretKey = string | Uint8Array;
|
|
592
725
|
interface SecureTokenOptions {
|
|
593
726
|
readonly encrypt?: boolean;
|
|
@@ -870,4 +1003,4 @@ type SnapshotTokenVerification<T extends SnapshotTokenPayload = SnapshotTokenPay
|
|
|
870
1003
|
declare function createSignedSnapshotToken<T extends SnapshotTokenPayload>(payload: T, secretKey: SnapshotSecretKey): Promise<string>;
|
|
871
1004
|
declare function verifySnapshotToken<T extends SnapshotTokenPayload = SnapshotTokenPayload>(token: string, secretKey: SnapshotSecretKey, now?: number): Promise<SnapshotTokenVerification<T>>;
|
|
872
1005
|
|
|
873
|
-
export { type AdminRallyConfig, type AdminReward, type AuditLoggerAdapter, type AuthContextAdapter, CURRENT_RALLY_CONFIG_VERSION, type CheckInAttemptAuditEntry, type CheckInContext, type CheckInErrorCode, type CheckInInput, type CheckInResult$1 as CheckInResult, type ClaimTicketOptions, type Clock, type CompositeConditionFailure, type ConditionMatch, type ConditionMismatch, type ConditionVerifierPlugin, type ConsumeResult, type ConsumeRewardParams, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type EventPublisherAdapter, type ExternalReference$1 as ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, type LocalizedText as HeadlessLocalizedText, type IdGeneratorAdapter, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type LegacyPublicRallyConfig, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText$1 as LocalizedText, type Metadata, type NfcDetectorOptions, type PasscodeCondition, type ProcessStampValue, type PublicCheckInCondition, type PublicRallyConfig, type PublicReward, type PublicRewardItem, type QrDetectorOptions, type RallyCompletedEvent, type RallyConfig, type RallyConfigValidationResult, type RallyDefinition, type RallyEvent, type RallyId, type RallyProgress, type RallySnapshot, type RedemptionMethod, type Result, type RewardConsumeError, type RewardItem, type RewardState, type RewardStatus, type RewardType, type RewardUnlockCondition, type SchemaVersion, type SecureTokenError, type SecureTokenErrorCode, type SecureTokenOptions, type SecureTokenPayload, type SecureTokenSecretKey, type SecureTokenVerification, type ServerRallyConfig, type SheetTheme, type SlotShape, type SnapshotSecretKey, type SnapshotTokenError, type SnapshotTokenErrorCode, type SnapshotTokenPayload, type SnapshotTokenVerification, type SpotDefinition, type SpotId, type SpotItem, type SpotVerificationSecret, type StampAcquiredEvent, type StampCondition, type StampDefinition, type StampError, StampRallyClient, type StampRallyClientEvent, type StampRallyEvent, type StampRallyEventListener, type StampRallyListener, type StampRallyProgress, type StampRallyState, type StampRecord$1 as StampRecord, type StampStorage, type StateMigrator, type StorageAdapter, StorageAdapterError, type StorageAdapterErrorCode, type StorageLike, type StorageOperation, type StorageSaveOutcome, type StorageSaveRequest, type StorageWarningHandler, type SupportedLocale, type SystemClockAdapter, THEME_PRESETS, type ThemePreset, type ThemePresetId, type TokenVerificationContext, type UniversalLocalizedText, type UniversalSpotItem, type UniversalValidationError, type UniversalValidationResult, type UserId, type ValidationError, type ValidationInput, type ValidationOutcome, type VerificationCondition, type VerificationContext, type VerificationCoordinates, type VerificationRequirement, calculateDistanceMeters, calculateProgress, consumeReward, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCheckIn, evaluateCondition, evaluateConditionDetailed, exportProgressToken, getCurrentGeoContext, importProgressToken, isAdminRallyConfig, isGeolocationSupported, isNfcSupported, isPublicRallyConfig, isPublicRallyConfigShape, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, migrateRallyConfig, normalizePasscode, processStamp, readNfcContext, readQrContext, reconcileRewardStates, resolveLocalizedText, stripSensitiveConfig, toLocalizedString, toPublicRallyConfig, validateAdminRallyConfig, validatePublicRallyConfig, validateRallyConfig, verifyPasscode, verifySecureToken, verifySnapshotToken };
|
|
1006
|
+
export { type AdminRallyConfig, type AdminReward, type AuditLoggerAdapter, type AuthContextAdapter, CURRENT_RALLY_CONFIG_VERSION, type CheckInAttemptAuditEntry, type CheckInContext, type CheckInErrorCode, type CheckInInput, type CheckInOptions, type CheckInResult$1 as CheckInResult, type CheckInSuccess, type ClaimOptions, type ClaimResult, type ClaimSuccess, type ClaimTicketOptions, type ClientCheckInResult, type ClientClaimResult, type Clock, type CompositeConditionFailure, type ConditionMatch, type ConditionMismatch, type ConditionVerifierPlugin, type ConsumeResult, type ConsumeRewardParams, type CustomValidator, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type EventPublisherAdapter, type ExternalReference$1 as ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, type LocalizedText as HeadlessLocalizedText, type IdGeneratorAdapter, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type LegacyPublicRallyConfig, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText$1 as LocalizedText, type Metadata, type NfcDetectorOptions, type PasscodeCondition, type ProcessStampValue, type PublicCheckInCondition, type PublicRallyConfig, type PublicReward, type PublicRewardItem, type QrDetectorOptions, type RallyCompletedEvent, type RallyConfig, type RallyConfigValidationResult, type RallyDefinition, type RallyEvent, type RallyId, type RallyProgress, type RallySnapshot, type RedemptionMethod, type Result, type RewardConsumeError, type RewardItem, type RewardState, type RewardStatus, type RewardType, type RewardUnlockCondition, type SchemaVersion, type SecureTokenError, type SecureTokenErrorCode, type SecureTokenOptions, type SecureTokenPayload, type SecureTokenSecretKey, type SecureTokenVerification, type ServerRallyConfig, type SheetTheme, type SlotShape, type SnapshotSecretKey, type SnapshotTokenError, type SnapshotTokenErrorCode, type SnapshotTokenPayload, type SnapshotTokenVerification, type SpotDefinition, type SpotId, type SpotItem, type SpotVerificationSecret, type StampAcquiredEvent, type StampCondition, type StampDefinition, type StampError, StampRallyClient, type StampRallyClientEvent, type StampRallyEvent, type StampRallyEventListener, type StampRallyListener, type StampRallyProgress, type StampRallyState, type StampRecord$1 as StampRecord, type StampStorage, type StateMigrator, type StorageAdapter, StorageAdapterError, type StorageAdapterErrorCode, type StorageLike, type StorageOperation, type StorageSaveOutcome, type StorageSaveRequest, type StorageWarningHandler, type SupportedLocale, type SystemClockAdapter, THEME_PRESETS, type ThemePreset, type ThemePresetId, type TokenVerificationContext, type UniversalCheckInResult, type UniversalClaimRequest, type UniversalClaimResult, type UniversalClientError, type UniversalClientEvent, type UniversalClientEventListener, type UniversalClientListener, type UniversalClientRequest, type UniversalClientSyncAdapter, type UniversalLocalizedText, type UniversalSpotItem, UniversalStampRallyClient, type UniversalStampRallyClientOptions, type UniversalValidationError, type UniversalValidationResult, type UserId, type UserRallyState, type ValidationError, type ValidationInput, type ValidationOutcome, type VerificationCondition, type VerificationContext, type VerificationCoordinates, type VerificationRequirement, calculateDistanceMeters, calculateProgress, consumeReward, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCheckIn, evaluateCondition, evaluateConditionDetailed, exportProgressToken, getCurrentGeoContext, importProgressToken, isAdminRallyConfig, isGeolocationSupported, isNfcSupported, isPublicRallyConfig, isPublicRallyConfigShape, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, migrateRallyConfig, normalizePasscode, processStamp, readNfcContext, readQrContext, reconcileRewardStates, resolveLocalizedText, stripSensitiveConfig, toLocalizedString, toPublicRallyConfig, validateAdminRallyConfig, validatePublicRallyConfig, validateRallyConfig, verifyPasscode, verifySecureToken, verifySnapshotToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -246,6 +246,7 @@ interface ThemePreset<TLocale extends string = SupportedLocale> {
|
|
|
246
246
|
readonly theme: SheetTheme;
|
|
247
247
|
}
|
|
248
248
|
declare const DEFAULT_SHEET_THEME: SheetTheme;
|
|
249
|
+
/** @deprecated Use UniversalSpotItem from the universal model. */
|
|
249
250
|
interface SpotItem<TLocale extends string = SupportedLocale, TMeta extends Record<string, unknown> = Record<string, unknown>> {
|
|
250
251
|
readonly id: string;
|
|
251
252
|
readonly name: LocalizedText$1<TLocale>;
|
|
@@ -325,6 +326,7 @@ interface StampRallyState {
|
|
|
325
326
|
readonly rewards?: ReadonlyArray<RewardState>;
|
|
326
327
|
readonly updatedAt: string;
|
|
327
328
|
}
|
|
329
|
+
/** @deprecated Use AdminRallyConfig or PublicRallyConfig from the universal model. */
|
|
328
330
|
interface RallyConfig<TLocale extends string = SupportedLocale, TMeta extends Record<string, unknown> = Record<string, unknown>> {
|
|
329
331
|
readonly id: string;
|
|
330
332
|
readonly title?: LocalizedText$1<TLocale>;
|
|
@@ -588,6 +590,137 @@ declare class StampRallyClient {
|
|
|
588
590
|
restore(state: StampRallyState): Promise<StampRallyState>;
|
|
589
591
|
}
|
|
590
592
|
|
|
593
|
+
type UserRallyState = StampRallyState;
|
|
594
|
+
type CustomValidator = (context: {
|
|
595
|
+
readonly spotId: string;
|
|
596
|
+
readonly proofData: unknown;
|
|
597
|
+
readonly config: PublicRallyConfig;
|
|
598
|
+
readonly userState: UserRallyState;
|
|
599
|
+
}) => Promise<{
|
|
600
|
+
readonly success: boolean;
|
|
601
|
+
readonly error?: string;
|
|
602
|
+
}>;
|
|
603
|
+
interface CheckInOptions {
|
|
604
|
+
readonly now?: string;
|
|
605
|
+
readonly idempotencyKey?: string;
|
|
606
|
+
readonly sync?: boolean;
|
|
607
|
+
}
|
|
608
|
+
interface ClaimOptions {
|
|
609
|
+
readonly now?: string;
|
|
610
|
+
readonly idempotencyKey?: string;
|
|
611
|
+
readonly staffPasscode?: string;
|
|
612
|
+
readonly staffId?: string;
|
|
613
|
+
readonly sync?: boolean;
|
|
614
|
+
}
|
|
615
|
+
interface UniversalClientRequest {
|
|
616
|
+
readonly rallyId: string;
|
|
617
|
+
readonly spotId: string;
|
|
618
|
+
readonly proofData: unknown;
|
|
619
|
+
readonly idempotencyKey: string;
|
|
620
|
+
readonly now: string;
|
|
621
|
+
readonly state: UserRallyState;
|
|
622
|
+
}
|
|
623
|
+
interface UniversalClaimRequest {
|
|
624
|
+
readonly rallyId: string;
|
|
625
|
+
readonly rewardId: string;
|
|
626
|
+
readonly idempotencyKey: string;
|
|
627
|
+
readonly now: string;
|
|
628
|
+
readonly options: ClaimOptions;
|
|
629
|
+
readonly state: UserRallyState;
|
|
630
|
+
}
|
|
631
|
+
type UniversalClientError = {
|
|
632
|
+
readonly code: "SPOT_NOT_FOUND";
|
|
633
|
+
readonly spotId: string;
|
|
634
|
+
readonly message: string;
|
|
635
|
+
} | {
|
|
636
|
+
readonly code: "STAMP_ALREADY_ACQUIRED";
|
|
637
|
+
readonly spotId: string;
|
|
638
|
+
readonly message: string;
|
|
639
|
+
} | {
|
|
640
|
+
readonly code: "PREREQUISITES_NOT_MET";
|
|
641
|
+
readonly spotId: string;
|
|
642
|
+
readonly message: string;
|
|
643
|
+
} | {
|
|
644
|
+
readonly code: "INVALID_PROOF";
|
|
645
|
+
readonly spotId: string;
|
|
646
|
+
readonly message: string;
|
|
647
|
+
} | {
|
|
648
|
+
readonly code: "CUSTOM_VALIDATION_FAILED";
|
|
649
|
+
readonly spotId: string;
|
|
650
|
+
readonly message: string;
|
|
651
|
+
} | {
|
|
652
|
+
readonly code: "REWARD_NOT_FOUND";
|
|
653
|
+
readonly rewardId: string;
|
|
654
|
+
readonly message: string;
|
|
655
|
+
} | {
|
|
656
|
+
readonly code: "SYNC_FAILED";
|
|
657
|
+
readonly message: string;
|
|
658
|
+
} | {
|
|
659
|
+
readonly code: "REMOTE_ERROR";
|
|
660
|
+
readonly message: string;
|
|
661
|
+
} | RewardConsumeError;
|
|
662
|
+
interface CheckInSuccess {
|
|
663
|
+
readonly state: UserRallyState;
|
|
664
|
+
readonly record: StampRecord$1;
|
|
665
|
+
}
|
|
666
|
+
type UniversalCheckInResult = Result<CheckInSuccess, UniversalClientError>;
|
|
667
|
+
type ClientCheckInResult = UniversalCheckInResult;
|
|
668
|
+
interface ClaimSuccess {
|
|
669
|
+
readonly state: UserRallyState;
|
|
670
|
+
readonly reward: RewardState;
|
|
671
|
+
}
|
|
672
|
+
type UniversalClaimResult = Result<ClaimSuccess, UniversalClientError>;
|
|
673
|
+
type ClaimResult = UniversalClaimResult;
|
|
674
|
+
type ClientClaimResult = UniversalClaimResult;
|
|
675
|
+
type UniversalClientEvent = {
|
|
676
|
+
readonly type: "checkIn";
|
|
677
|
+
readonly result: UniversalCheckInResult;
|
|
678
|
+
} | {
|
|
679
|
+
readonly type: "rewardClaimed";
|
|
680
|
+
readonly result: UniversalClaimResult;
|
|
681
|
+
} | {
|
|
682
|
+
readonly type: "sync";
|
|
683
|
+
readonly state: UserRallyState;
|
|
684
|
+
} | {
|
|
685
|
+
readonly type: "error";
|
|
686
|
+
readonly error: UniversalClientError;
|
|
687
|
+
};
|
|
688
|
+
type UniversalClientListener = (state: UserRallyState) => void;
|
|
689
|
+
type UniversalClientEventListener = (event: UniversalClientEvent) => void;
|
|
690
|
+
interface UniversalClientSyncAdapter {
|
|
691
|
+
readonly checkIn?: (request: UniversalClientRequest) => Promise<UniversalCheckInResult>;
|
|
692
|
+
readonly claimReward?: (request: UniversalClaimRequest) => Promise<UniversalClaimResult>;
|
|
693
|
+
readonly sync?: (request: {
|
|
694
|
+
readonly rallyId: string;
|
|
695
|
+
readonly state: UserRallyState;
|
|
696
|
+
}) => Promise<UserRallyState>;
|
|
697
|
+
}
|
|
698
|
+
interface UniversalStampRallyClientOptions {
|
|
699
|
+
readonly storage?: StampStorage;
|
|
700
|
+
readonly syncAdapter?: UniversalClientSyncAdapter;
|
|
701
|
+
readonly customValidator?: CustomValidator;
|
|
702
|
+
readonly customValidators?: Readonly<Record<string, CustomValidator>>;
|
|
703
|
+
readonly clock?: () => string;
|
|
704
|
+
}
|
|
705
|
+
type UniversalClientOptionsOrStorage = UniversalStampRallyClientOptions | StampStorage;
|
|
706
|
+
/**
|
|
707
|
+
* Storage- and framework-independent client state machine for a public rally.
|
|
708
|
+
* All operations create new state snapshots and notify subscribers after persistence.
|
|
709
|
+
*/
|
|
710
|
+
declare class UniversalStampRallyClient {
|
|
711
|
+
#private;
|
|
712
|
+
constructor(config: PublicRallyConfig, storageOrOptions?: UniversalClientOptionsOrStorage, clock?: () => string);
|
|
713
|
+
getConfig(): PublicRallyConfig;
|
|
714
|
+
getState(): UserRallyState | null;
|
|
715
|
+
subscribe(listener: UniversalClientListener): () => void;
|
|
716
|
+
subscribeEvents(listener: UniversalClientEventListener): () => void;
|
|
717
|
+
init(): Promise<UserRallyState>;
|
|
718
|
+
initialize(): Promise<UserRallyState>;
|
|
719
|
+
checkIn(spotId: string, proofData: unknown, options?: CheckInOptions): Promise<UniversalCheckInResult>;
|
|
720
|
+
claimReward(rewardId: string, options?: ClaimOptions): Promise<UniversalClaimResult>;
|
|
721
|
+
sync(adapter?: UniversalClientSyncAdapter): Promise<void>;
|
|
722
|
+
}
|
|
723
|
+
|
|
591
724
|
type SecureTokenSecretKey = string | Uint8Array;
|
|
592
725
|
interface SecureTokenOptions {
|
|
593
726
|
readonly encrypt?: boolean;
|
|
@@ -870,4 +1003,4 @@ type SnapshotTokenVerification<T extends SnapshotTokenPayload = SnapshotTokenPay
|
|
|
870
1003
|
declare function createSignedSnapshotToken<T extends SnapshotTokenPayload>(payload: T, secretKey: SnapshotSecretKey): Promise<string>;
|
|
871
1004
|
declare function verifySnapshotToken<T extends SnapshotTokenPayload = SnapshotTokenPayload>(token: string, secretKey: SnapshotSecretKey, now?: number): Promise<SnapshotTokenVerification<T>>;
|
|
872
1005
|
|
|
873
|
-
export { type AdminRallyConfig, type AdminReward, type AuditLoggerAdapter, type AuthContextAdapter, CURRENT_RALLY_CONFIG_VERSION, type CheckInAttemptAuditEntry, type CheckInContext, type CheckInErrorCode, type CheckInInput, type CheckInResult$1 as CheckInResult, type ClaimTicketOptions, type Clock, type CompositeConditionFailure, type ConditionMatch, type ConditionMismatch, type ConditionVerifierPlugin, type ConsumeResult, type ConsumeRewardParams, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type EventPublisherAdapter, type ExternalReference$1 as ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, type LocalizedText as HeadlessLocalizedText, type IdGeneratorAdapter, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type LegacyPublicRallyConfig, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText$1 as LocalizedText, type Metadata, type NfcDetectorOptions, type PasscodeCondition, type ProcessStampValue, type PublicCheckInCondition, type PublicRallyConfig, type PublicReward, type PublicRewardItem, type QrDetectorOptions, type RallyCompletedEvent, type RallyConfig, type RallyConfigValidationResult, type RallyDefinition, type RallyEvent, type RallyId, type RallyProgress, type RallySnapshot, type RedemptionMethod, type Result, type RewardConsumeError, type RewardItem, type RewardState, type RewardStatus, type RewardType, type RewardUnlockCondition, type SchemaVersion, type SecureTokenError, type SecureTokenErrorCode, type SecureTokenOptions, type SecureTokenPayload, type SecureTokenSecretKey, type SecureTokenVerification, type ServerRallyConfig, type SheetTheme, type SlotShape, type SnapshotSecretKey, type SnapshotTokenError, type SnapshotTokenErrorCode, type SnapshotTokenPayload, type SnapshotTokenVerification, type SpotDefinition, type SpotId, type SpotItem, type SpotVerificationSecret, type StampAcquiredEvent, type StampCondition, type StampDefinition, type StampError, StampRallyClient, type StampRallyClientEvent, type StampRallyEvent, type StampRallyEventListener, type StampRallyListener, type StampRallyProgress, type StampRallyState, type StampRecord$1 as StampRecord, type StampStorage, type StateMigrator, type StorageAdapter, StorageAdapterError, type StorageAdapterErrorCode, type StorageLike, type StorageOperation, type StorageSaveOutcome, type StorageSaveRequest, type StorageWarningHandler, type SupportedLocale, type SystemClockAdapter, THEME_PRESETS, type ThemePreset, type ThemePresetId, type TokenVerificationContext, type UniversalLocalizedText, type UniversalSpotItem, type UniversalValidationError, type UniversalValidationResult, type UserId, type ValidationError, type ValidationInput, type ValidationOutcome, type VerificationCondition, type VerificationContext, type VerificationCoordinates, type VerificationRequirement, calculateDistanceMeters, calculateProgress, consumeReward, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCheckIn, evaluateCondition, evaluateConditionDetailed, exportProgressToken, getCurrentGeoContext, importProgressToken, isAdminRallyConfig, isGeolocationSupported, isNfcSupported, isPublicRallyConfig, isPublicRallyConfigShape, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, migrateRallyConfig, normalizePasscode, processStamp, readNfcContext, readQrContext, reconcileRewardStates, resolveLocalizedText, stripSensitiveConfig, toLocalizedString, toPublicRallyConfig, validateAdminRallyConfig, validatePublicRallyConfig, validateRallyConfig, verifyPasscode, verifySecureToken, verifySnapshotToken };
|
|
1006
|
+
export { type AdminRallyConfig, type AdminReward, type AuditLoggerAdapter, type AuthContextAdapter, CURRENT_RALLY_CONFIG_VERSION, type CheckInAttemptAuditEntry, type CheckInContext, type CheckInErrorCode, type CheckInInput, type CheckInOptions, type CheckInResult$1 as CheckInResult, type CheckInSuccess, type ClaimOptions, type ClaimResult, type ClaimSuccess, type ClaimTicketOptions, type ClientCheckInResult, type ClientClaimResult, type Clock, type CompositeConditionFailure, type ConditionMatch, type ConditionMismatch, type ConditionVerifierPlugin, type ConsumeResult, type ConsumeRewardParams, type CustomValidator, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type EventPublisherAdapter, type ExternalReference$1 as ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, type LocalizedText as HeadlessLocalizedText, type IdGeneratorAdapter, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type LegacyPublicRallyConfig, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText$1 as LocalizedText, type Metadata, type NfcDetectorOptions, type PasscodeCondition, type ProcessStampValue, type PublicCheckInCondition, type PublicRallyConfig, type PublicReward, type PublicRewardItem, type QrDetectorOptions, type RallyCompletedEvent, type RallyConfig, type RallyConfigValidationResult, type RallyDefinition, type RallyEvent, type RallyId, type RallyProgress, type RallySnapshot, type RedemptionMethod, type Result, type RewardConsumeError, type RewardItem, type RewardState, type RewardStatus, type RewardType, type RewardUnlockCondition, type SchemaVersion, type SecureTokenError, type SecureTokenErrorCode, type SecureTokenOptions, type SecureTokenPayload, type SecureTokenSecretKey, type SecureTokenVerification, type ServerRallyConfig, type SheetTheme, type SlotShape, type SnapshotSecretKey, type SnapshotTokenError, type SnapshotTokenErrorCode, type SnapshotTokenPayload, type SnapshotTokenVerification, type SpotDefinition, type SpotId, type SpotItem, type SpotVerificationSecret, type StampAcquiredEvent, type StampCondition, type StampDefinition, type StampError, StampRallyClient, type StampRallyClientEvent, type StampRallyEvent, type StampRallyEventListener, type StampRallyListener, type StampRallyProgress, type StampRallyState, type StampRecord$1 as StampRecord, type StampStorage, type StateMigrator, type StorageAdapter, StorageAdapterError, type StorageAdapterErrorCode, type StorageLike, type StorageOperation, type StorageSaveOutcome, type StorageSaveRequest, type StorageWarningHandler, type SupportedLocale, type SystemClockAdapter, THEME_PRESETS, type ThemePreset, type ThemePresetId, type TokenVerificationContext, type UniversalCheckInResult, type UniversalClaimRequest, type UniversalClaimResult, type UniversalClientError, type UniversalClientEvent, type UniversalClientEventListener, type UniversalClientListener, type UniversalClientRequest, type UniversalClientSyncAdapter, type UniversalLocalizedText, type UniversalSpotItem, UniversalStampRallyClient, type UniversalStampRallyClientOptions, type UniversalValidationError, type UniversalValidationResult, type UserId, type UserRallyState, type ValidationError, type ValidationInput, type ValidationOutcome, type VerificationCondition, type VerificationContext, type VerificationCoordinates, type VerificationRequirement, calculateDistanceMeters, calculateProgress, consumeReward, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCheckIn, evaluateCondition, evaluateConditionDetailed, exportProgressToken, getCurrentGeoContext, importProgressToken, isAdminRallyConfig, isGeolocationSupported, isNfcSupported, isPublicRallyConfig, isPublicRallyConfigShape, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, migrateRallyConfig, normalizePasscode, processStamp, readNfcContext, readQrContext, reconcileRewardStates, resolveLocalizedText, stripSensitiveConfig, toLocalizedString, toPublicRallyConfig, validateAdminRallyConfig, validatePublicRallyConfig, validateRallyConfig, verifyPasscode, verifySecureToken, verifySnapshotToken };
|