@consentera/consent-sdk 2.0.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +245 -0
  2. package/LICENSE +21 -0
  3. package/README.md +489 -0
  4. package/dist/consentera-consent.cjs +4919 -0
  5. package/dist/consentera-consent.cjs.map +1 -0
  6. package/dist/consentera-consent.min.js +2 -0
  7. package/dist/consentera-consent.min.js.map +1 -0
  8. package/dist/consentera-consent.mjs +4864 -0
  9. package/dist/consentera-consent.mjs.map +1 -0
  10. package/dist/react/index.cjs +2731 -0
  11. package/dist/react/index.cjs.map +1 -0
  12. package/dist/react/index.mjs +2724 -0
  13. package/dist/react/index.mjs.map +1 -0
  14. package/dist/types/consent/CallbackHandler.d.ts +246 -0
  15. package/dist/types/consent/ConsentManager.d.ts +128 -0
  16. package/dist/types/consent/ConsentSession.d.ts +127 -0
  17. package/dist/types/consent/ConsentValidator.d.ts +63 -0
  18. package/dist/types/consent/artifactRead.d.ts +48 -0
  19. package/dist/types/consent/consentPopup.d.ts +115 -0
  20. package/dist/types/core/ConsentEraClient.d.ts +106 -0
  21. package/dist/types/core/ConsenteraConsent.d.ts +163 -0
  22. package/dist/types/core/errors.d.ts +108 -0
  23. package/dist/types/core/http.d.ts +176 -0
  24. package/dist/types/core/version.d.ts +36 -0
  25. package/dist/types/df/DFConfigClient.d.ts +59 -0
  26. package/dist/types/gcm/ConsentModeBridge.d.ts +54 -0
  27. package/dist/types/gpp/GPPManager.d.ts +62 -0
  28. package/dist/types/index.d.mts +5 -0
  29. package/dist/types/index.d.ts +28 -0
  30. package/dist/types/principal/PrincipalClient.d.ts +34 -0
  31. package/dist/types/react/ConsentEraProvider.d.ts +58 -0
  32. package/dist/types/react/ConsentGate.d.ts +40 -0
  33. package/dist/types/react/index.d.mts +4 -0
  34. package/dist/types/react/index.d.ts +10 -0
  35. package/dist/types/react/useConsentEra.d.ts +65 -0
  36. package/dist/types/react/useConsentValidation.d.ts +23 -0
  37. package/dist/types/storage/ConsentStorage.d.ts +39 -0
  38. package/dist/types/tcf/TCFManager.d.ts +46 -0
  39. package/dist/types/types/consent-lifecycle.d.ts +804 -0
  40. package/dist/types/types/index.d.ts +311 -0
  41. package/dist/types/ui/ConsentBanner.d.ts +22 -0
  42. package/dist/types/ui/PreferenceCenter.d.ts +24 -0
  43. package/dist/types/utils/EventEmitter.d.ts +32 -0
  44. package/dist/types/utils/Logger.d.ts +16 -0
  45. package/dist/types/utils/browserStorage.d.ts +35 -0
  46. package/dist/types/utils/context.d.ts +81 -0
  47. package/dist/types/utils/helpers.d.ts +48 -0
  48. package/package.json +132 -0
@@ -0,0 +1,4 @@
1
+ // GENERATED by scripts/emit-esm-types.mjs — do not edit.
2
+ // The ESM-flavoured door into the shared declaration tree; that script says
3
+ // why a .d.mts entry is needed at all.
4
+ export * from './index.js';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * ConsentEra Consent SDK — React Integration
3
+ * Provider, hooks, and components for React applications
4
+ */
5
+ export { ConsentEraProvider, useConsentEraClient, useConsentEraContext, type ConsentEraContextValue, type ConsentEraProviderProps, } from './ConsentEraProvider';
6
+ export { useConsentEra } from './useConsentEra';
7
+ export { useConsentValidation, type UseConsentValidationReturn, type UseConsentValidationOptions, } from './useConsentValidation';
8
+ export { ConsentGate } from './ConsentGate';
9
+ export type { UseConsentEraReturn } from './useConsentEra';
10
+ export type { ConsentGateProps } from './ConsentGate';
@@ -0,0 +1,65 @@
1
+ import { ConsentEraClient } from '../core/ConsentEraClient';
2
+ import { ConsentSession } from '../consent/ConsentSession';
3
+ import { ConsentValidator } from '../consent/ConsentValidator';
4
+ import { ConsentManager } from '../consent/ConsentManager';
5
+ import { CallbackHandler } from '../consent/CallbackHandler';
6
+ import { DFConfigClient } from '../df/DFConfigClient';
7
+ import { PrincipalClient } from '../principal/PrincipalClient';
8
+ /**
9
+ * Every namespace is `null` when there is no client: the provider's
10
+ * configuration was refused, or there is no provider. `error` then says which.
11
+ * The hook never throws during render (WEB-038), so check `ready` (or the
12
+ * namespace) before you call it.
13
+ */
14
+ export interface UseConsentEraReturn {
15
+ /** true when a client exists and the namespaces below are non-null. */
16
+ ready: boolean;
17
+ /** Unified consent namespace — sessions, validation, management, callbacks */
18
+ consent: ConsentEraClient['consent'] | null;
19
+ /** Consent session creation and artifact retrieval */
20
+ session: ConsentSession | null;
21
+ /** Consent validation (single + bulk) */
22
+ validate: ConsentValidator | null;
23
+ /** Consent update, withdrawal, and renewal */
24
+ manage: ConsentManager | null;
25
+ /** Callback handler for redirect flows */
26
+ callback: CallbackHandler | null;
27
+ /** DF configuration and notice purposes */
28
+ df: DFConfigClient | null;
29
+ /** Data principal rights and portal SSO */
30
+ principal: PrincipalClient | null;
31
+ /** Whether the SDK is still initializing */
32
+ loading: boolean;
33
+ /** Why there is no client, or the client's last error. */
34
+ error: Error | null;
35
+ }
36
+ /**
37
+ * Main hook for accessing all Consentera consent operations.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * function LoanPage() {
42
+ * const { consent, error } = useConsentEra();
43
+ * if (!consent) return <p>Consent is unavailable: {error?.message}</p>;
44
+ *
45
+ * const handleApply = async () => {
46
+ * const check = await consent.validate(
47
+ * { data_principal_identifiers: { email: 'user@example.com' } },
48
+ * 'credit_assessment'
49
+ * );
50
+ * if (check.decision === 'DENY') {
51
+ * const s = await consent.createSession({
52
+ * // keyed by THIS organisation's locked integration key — the SAME
53
+ * // open map the validate call above passes, one vocabulary on both
54
+ * // roads (F015). Only the wire KEY differs: `data_principal` here
55
+ * // may mint a person, `data_principal_identifiers` only resolves.
56
+ * data_principal: { email: 'user@example.com' },
57
+ * notice_internal_name: 'loan_notice',
58
+ * });
59
+ * consent.redirectToConsent(s);
60
+ * }
61
+ * };
62
+ * }
63
+ * ```
64
+ */
65
+ export declare function useConsentEra(): UseConsentEraReturn;
@@ -0,0 +1,23 @@
1
+ import { ValidateResponse } from '../types/consent-lifecycle';
2
+ import type { PrincipalRef } from '../utils/context';
3
+ export interface UseConsentValidationReturn {
4
+ /** true = ALLOW. false = DENY. null = not yet known, or the check failed. */
5
+ allowed: boolean | null;
6
+ /** Full validation response from the API */
7
+ result: ValidateResponse | null;
8
+ /** Whether a validation is in progress */
9
+ loading: boolean;
10
+ /** Error if validation failed */
11
+ error: Error | null;
12
+ /** Re-run the validation check */
13
+ recheck: () => Promise<void>;
14
+ }
15
+ export interface UseConsentValidationOptions {
16
+ autoCheck?: boolean;
17
+ /**
18
+ * Re-check when the SDK reports a consent change for this person. Default
19
+ * true — this is what closes a gate on withdrawal without a remount.
20
+ */
21
+ watchChanges?: boolean;
22
+ }
23
+ export declare function useConsentValidation(who: PrincipalRef | undefined, purposeCode: string | undefined, options?: UseConsentValidationOptions): UseConsentValidationReturn;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Consent Storage Module
3
+ * Handles persistence of consent data
4
+ */
5
+ import { StorageConfig, ConsentData } from '../types';
6
+ export declare class ConsentStorage {
7
+ private config;
8
+ private key;
9
+ constructor(config?: StorageConfig);
10
+ /**
11
+ * Save consent data
12
+ */
13
+ save(consent: ConsentData): boolean;
14
+ /**
15
+ * Get consent data
16
+ */
17
+ get(): ConsentData | null;
18
+ /**
19
+ * Check if consent exists
20
+ */
21
+ exists(): boolean;
22
+ /**
23
+ * Clear consent data
24
+ */
25
+ clear(): void;
26
+ /**
27
+ * Set cookie
28
+ */
29
+ /** @returns false when the value could not be stored (and says why). */
30
+ private setCookie;
31
+ /**
32
+ * Get cookie value
33
+ */
34
+ private getCookie;
35
+ /**
36
+ * Delete cookie
37
+ */
38
+ private deleteCookie;
39
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * TCF 2.2 Manager
3
+ * IAB Transparency & Consent Framework implementation
4
+ */
5
+ import { TCFConfig, TCFData, ConsentPreferences } from '../types';
6
+ export declare class TCFManager {
7
+ private config;
8
+ private tcfData;
9
+ constructor(config: TCFConfig);
10
+ /**
11
+ * Initialize TCF API
12
+ */
13
+ init(): Promise<void>;
14
+ /**
15
+ * Create __tcfapi stub
16
+ */
17
+ private createTCFApiStub;
18
+ /**
19
+ * Get default TCF data
20
+ */
21
+ private getDefaultTCFData;
22
+ /**
23
+ * Update consent in TCF format
24
+ */
25
+ updateConsent(preferences: ConsentPreferences): Promise<void>;
26
+ /**
27
+ * Generate TC String (simplified version)
28
+ */
29
+ private generateTCString;
30
+ /**
31
+ * Dispatch TCF event
32
+ */
33
+ private dispatchTCFEvent;
34
+ /**
35
+ * Get current TCF data
36
+ */
37
+ getTCFData(): TCFData | null;
38
+ /**
39
+ * Get TC String
40
+ */
41
+ getTCString(): string;
42
+ /**
43
+ * Destroy TCF manager
44
+ */
45
+ destroy(): void;
46
+ }