UNPKG

wallet-pass

Version:
292 lines (291 loc) 8.07 kB
export interface GoogleGenericPassObject { id: string; classId: string; genericType: string; hexBackgroundColor?: string; logo?: ImageObject; cardTitle?: LocalizedObject; header?: LocalizedObject; subheader?: LocalizedObject; textModulesData?: TextModuleObject[]; linksModuleData?: LinksModuleObject; imageModulesData?: ImageModuleObject[]; barcode?: BarcodeObject; heroImage?: ImageObject; validTimeInterval?: TimeInterval; locations?: LatLongPoint[]; customInfoModules?: InfoModuleData[]; additionalInfo?: InfoModuleData[]; appLinkData?: AppLinkData; groupingInfo?: GroupingInfo; [key: string]: unknown; } export interface GoogleGenericPassClass { id: string; issuerName: string; reviewStatus?: string; logoImage?: ImageObject; heroImage?: ImageObject; hexBackgroundColor?: string; classTemplateInfo?: ClassTemplateInfo; [key: string]: unknown; } export interface ClassTemplateInfo { cardTemplateOverride?: CardTemplateOverride; } export interface CardTemplateOverride { cardRowTemplateInfos?: CardRowTemplateInfo[]; } export interface CardRowTemplateInfo { twoItems?: TwoItemsInfo; threeItems?: ThreeItemsInfo; oneItem?: OneItemInfo; } export interface TwoItemsInfo { startItem?: TemplateItem; endItem?: TemplateItem; } export interface ThreeItemsInfo { startItem?: TemplateItem; middleItem?: TemplateItem; endItem?: TemplateItem; } export interface OneItemInfo { item?: TemplateItem; } export interface TemplateItem { firstValue?: TemplateItemValue; secondValue?: TemplateItemValue; } export interface TemplateItemValue { fields?: FieldReference[]; } export interface FieldReference { fieldPath: string; } export interface LocalizedObject { defaultValue: { language: string; value: string; }; } export interface TextModuleObject { id: string; header?: string; body: string; } export interface ImageObject { sourceUri: { uri: string; }; contentDescription?: { defaultValue: { language: string; value: string; }; }; } export interface ImageModuleObject { id: string; mainImage: ImageObject; } export interface BarcodeObject { type: string; value: string; alternateText?: string; } export interface LinksModuleObject { uris: { uri: string; description: string; id: string; }[]; } export interface LatLongPoint { latitude: number; longitude: number; } export interface TimeInterval { start: { date: string; }; end?: { date: string; }; } export interface InfoModuleData { id: string; labelValue: { label: string; value: string; }; } export interface AppLinkData { androidAppLinkInfo?: AppLinkInfo; iosAppLinkInfo?: AppLinkInfo; webAppLinkInfo?: AppLinkInfo; } export interface AppLinkInfo { appLogoImage?: ImageObject; title: string; description?: string; appTarget: AppTarget; } export interface AppTarget { targetUri: string; } export interface GroupingInfo { groupingId: string; sortIndex?: number; } export interface JwtPayload { iss: string; aud: string; typ: string; iat: number; origins: string[]; payload: { genericObjects: GoogleGenericPassObject[]; genericClasses?: GoogleGenericPassClass[]; }; } export declare class GoogleGenericPass { private passObject; private passClass?; private serviceAccountEmail; private privateKey; constructor(issuerId: string, passId: string, classId: string); /** * Load service account credentials for JWT signing */ setServiceAccountCredentials(serviceAccountEmail: string, privateKeyPathOrJson: string): this; /** * Set service account credentials directly with key content */ setServiceAccountCredentialsFromKeyData(serviceAccountEmail: string, privateKey: string): this; /** * Define the pass class (template) */ setPassClass(issuerName: string): this; /** * Set pass class (template) with additional properties */ setPassClassWithDetails(issuerName: string, reviewStatus?: string, logoImageUrl?: string, logoDescription?: string, heroImageUrl?: string, heroDescription?: string, hexBackgroundColor?: string): this; /** * Add class template info to the pass class */ setClassTemplateInfo(cardRowTemplates: CardRowTemplateInfo[]): this; /** * Helper to create a two-item row template */ createTwoItemsRow(startFieldPath?: string, endFieldPath?: string): CardRowTemplateInfo; /** * Set basic pass properties */ setBasicInfo(genericType: string, hexBackgroundColor?: string): this; /** * Set card title */ setCardTitle(title: string): this; /** * Set header and subheader */ setHeaderInfo(header: string, subheader?: string): this; /** * Add a text module */ addTextModule(id: string, body: string, header?: string): this; /** * Add logo to pass */ setLogo(imageUrl: string, description?: string): this; /** * Add hero image to pass */ setHeroImage(imageUrl: string, description?: string): this; /** * Add an image module */ addImageModule(id: string, imageUrl: string, description?: string): this; /** * Add an item to the additionalInfo section */ addAdditionalInfo(id: string, label: string, value: string): this; /** * Add Android app link */ addAndroidAppLink(title: string, targetUri: string, description?: string, logoImageUrl?: string, logoDescription?: string): this; /** * Add iOS app link */ addIosAppLink(title: string, targetUri: string, description?: string, logoImageUrl?: string, logoDescription?: string): this; /** * Add web app link */ addWebAppLink(title: string, targetUri: string, description?: string, logoImageUrl?: string, logoDescription?: string): this; /** * Set grouping info */ setGroupingInfo(groupingId: string, sortIndex?: number): this; /** * Helper to create image objects */ private createImageObject; /** * Helper to ensure localized string values are never empty */ private ensureNonEmptyString; /** * Validate the entire pass object before generating JWT * This ensures no empty localized strings exist */ private validatePassObject; /** * Add barcode to pass */ setBarcode(value: string, type?: string, alternateText?: string): this; /** * Add links module */ addLinks(links: { uri: string; description: string; id: string; }[]): this; /** * Add locations */ addLocations(locations: LatLongPoint[]): this; /** * Set validity time interval */ setValidTimeInterval(start: string, end?: string): this; /** * Add custom info module */ addCustomInfoModule(id: string, label: string, value: string): this; /** * Add any custom field to the pass object */ addCustomField(key: string, value: unknown): this; /** * Generate signed JWT */ generateJwt(origins?: string[]): string; /** * Generate "Add to Google Wallet" link */ generateAddToWalletLink(origins?: string[]): string; /** * Debug function to log generated payload */ debugPayload(): void; /** * Get the pass object */ getPassObject(): GoogleGenericPassObject; /** * Get the pass class */ getPassClass(): GoogleGenericPassClass | undefined; }