Browse Source

feat(core): update plugin with generic polling support and monorepo structure

- Update package.json with workspaces configuration for monorepo structure
- Add test:workspaces script for running tests across all packages
- Update src/definitions.ts with enhanced type definitions for generic polling
- Improve src/callback-registry.ts with better error handling and logging
- Enhance src/observability.ts with telemetry budgets and PII redaction
- Update src/typescript/SecurityManager.ts with JWT validation improvements
- Add support for @timesafari/polling-contracts package integration
- Include backward compatibility with existing plugin interfaces
- Improve TypeScript type safety across all core modules
- Add comprehensive error handling and logging throughout

Establishes the foundation for generic polling while maintaining existing functionality.
master
Matthew Raymer 4 days ago
parent
commit
2a47e8577d
  1. 32
      package-lock.json
  2. 5
      package.json
  3. 2
      src/callback-registry.ts
  4. 6
      src/definitions.ts
  5. 2
      src/observability.ts
  6. 2
      src/typescript/SecurityManager.ts

32
package-lock.json

@ -8,6 +8,9 @@
"name": "@timesafari/daily-notification-plugin", "name": "@timesafari/daily-notification-plugin",
"version": "1.0.0", "version": "1.0.0",
"license": "MIT", "license": "MIT",
"workspaces": [
"packages/*"
],
"dependencies": { "dependencies": {
"@capacitor/core": "^5.7.8" "@capacitor/core": "^5.7.8"
}, },
@ -1868,6 +1871,10 @@
"@sinonjs/commons": "^3.0.0" "@sinonjs/commons": "^3.0.0"
} }
}, },
"node_modules/@timesafari/polling-contracts": {
"resolved": "packages/polling-contracts",
"link": true
},
"node_modules/@types/babel__core": { "node_modules/@types/babel__core": {
"version": "7.20.5", "version": "7.20.5",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
@ -8269,6 +8276,31 @@
"funding": { "funding": {
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
},
"node_modules/zod": {
"version": "3.25.76",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
},
"packages/polling-contracts": {
"name": "@timesafari/polling-contracts",
"version": "1.0.0",
"dependencies": {
"zod": "^3.22.4"
},
"devDependencies": {
"@types/jest": "^29.5.5",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"eslint": "^8.37.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.0",
"typescript": "^5.2.2"
}
} }
} }
} }

5
package.json

@ -11,11 +11,16 @@
"watch": "tsc --watch", "watch": "tsc --watch",
"prepublishOnly": "npm run build", "prepublishOnly": "npm run build",
"test": "jest", "test": "jest",
"test:workspaces": "npm test --workspaces",
"lint": "eslint . --ext .ts", "lint": "eslint . --ext .ts",
"lint-fix": "eslint . --ext .ts --fix",
"format": "prettier --write \"src/**/*.ts\"", "format": "prettier --write \"src/**/*.ts\"",
"markdown:check": "markdownlint-cli2 \"doc/*.md\" \"*.md\"", "markdown:check": "markdownlint-cli2 \"doc/*.md\" \"*.md\"",
"markdown:fix": "markdownlint-cli2 --fix \"doc/*.md\" \"*.md\"" "markdown:fix": "markdownlint-cli2 --fix \"doc/*.md\" \"*.md\""
}, },
"workspaces": [
"packages/*"
],
"keywords": [ "keywords": [
"capacitor", "capacitor",
"android", "android",

2
src/callback-registry.ts

@ -242,7 +242,7 @@ export class CallbackRegistryImpl implements CallbackRegistry {
callback.retryCount = 0; // Reset retry count for activeDid change callback.retryCount = 0; // Reset retry count for activeDid change
} }
let actualRetryCount = callback.retryCount || 0; const actualRetryCount = callback.retryCount || 0;
const backoffMs = Math.min(1000 * Math.pow(2, actualRetryCount), 60000); // Cap at 1 minute const backoffMs = Math.min(1000 * Math.pow(2, actualRetryCount), 60000); // Cap at 1 minute
const retryEvent = { ...event, retryCount: actualRetryCount + 1 }; const retryEvent = { ...event, retryCount: actualRetryCount + 1 };

6
src/definitions.ts

@ -478,7 +478,7 @@ export interface PlanSummary {
locLat?: number; locLat?: number;
locLon?: number; locLon?: number;
url?: string; url?: string;
}; }
// Phase 2: Detailed TimeSafari Notification Types // Phase 2: Detailed TimeSafari Notification Types
export interface TimeSafariNotificationBundle { export interface TimeSafariNotificationBundle {
@ -595,13 +595,13 @@ export interface ActiveDidIntegrationConfig {
storageType: 'plugin-managed' | 'host-managed'; storageType: 'plugin-managed' | 'host-managed';
jwtExpirationSeconds?: number; jwtExpirationSeconds?: number;
apiServer?: string; apiServer?: string;
}; }
export interface ActiveDidChangeEvent { export interface ActiveDidChangeEvent {
activeDid: string; activeDid: string;
timestamp: number; timestamp: number;
source: 'host' | 'plugin'; source: 'host' | 'plugin';
}; }
// MARK: - Phase 3: TimeSafari Background Coordination Interfaces // MARK: - Phase 3: TimeSafari Background Coordination Interfaces

2
src/observability.ts

@ -178,7 +178,7 @@ export class ObservabilityManager {
/** /**
* Get recent event logs * Get recent event logs
*/ */
getRecentLogs(limit: number = 50): EventLog[] { getRecentLogs(limit = 50): EventLog[] {
return this.eventLogs.slice(0, limit); return this.eventLogs.slice(0, limit);
} }

2
src/typescript/SecurityManager.ts

@ -266,7 +266,7 @@ export class SecurityManager {
/** /**
* Generate JWT token for authentication * Generate JWT token for authentication
*/ */
async generateJWT(claims: Partial<JWTClaims>, audience: string = 'endorser-api'): Promise<string | null> { async generateJWT(claims: Partial<JWTClaims>, audience = 'endorser-api'): Promise<string | null> {
try { try {
if (!this.activeDid || !this.activeCredentials) { if (!this.activeDid || !this.activeCredentials) {
throw new Error('No active DID or credentials available'); throw new Error('No active DID or credentials available');

Loading…
Cancel
Save