@contentpass/react-native-contentpass 0.3.16 → 0.4.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 (96) hide show
  1. package/docs/CONTRIBUTING.md +7 -7
  2. package/lib/commonjs/Contentpass.js +38 -25
  3. package/lib/commonjs/Contentpass.js.map +1 -1
  4. package/lib/commonjs/Contentpass.test.js +455 -0
  5. package/lib/commonjs/Contentpass.test.js.map +1 -0
  6. package/lib/commonjs/OidcAuthStateStorage.test.js +59 -0
  7. package/lib/commonjs/OidcAuthStateStorage.test.js.map +1 -0
  8. package/lib/commonjs/contentpassTokenUtils/fetchContentpassToken.test.js +45 -0
  9. package/lib/commonjs/contentpassTokenUtils/fetchContentpassToken.test.js.map +1 -0
  10. package/lib/commonjs/contentpassTokenUtils/parseContentpassToken.test.js +31 -0
  11. package/lib/commonjs/contentpassTokenUtils/parseContentpassToken.test.js.map +1 -0
  12. package/lib/commonjs/contentpassTokenUtils/validateSubscription.test.js +73 -0
  13. package/lib/commonjs/contentpassTokenUtils/validateSubscription.test.js.map +1 -0
  14. package/lib/commonjs/countImpressionUtils/sendPageViewEvent.test.js +35 -0
  15. package/lib/commonjs/countImpressionUtils/sendPageViewEvent.test.js.map +1 -0
  16. package/lib/commonjs/countImpressionUtils/sendStats.js +1 -1
  17. package/lib/commonjs/countImpressionUtils/sendStats.js.map +1 -1
  18. package/lib/commonjs/countImpressionUtils/sendStats.test.js +39 -0
  19. package/lib/commonjs/countImpressionUtils/sendStats.test.js.map +1 -0
  20. package/lib/commonjs/index.js +2 -0
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/logger.test.js +42 -0
  23. package/lib/commonjs/logger.test.js.map +1 -0
  24. package/lib/commonjs/package.json +1 -0
  25. package/lib/commonjs/sdkContext/ContentpassSdkProvder.test.js +33 -0
  26. package/lib/commonjs/sdkContext/ContentpassSdkProvder.test.js.map +1 -0
  27. package/lib/commonjs/sdkContext/useContentpassSdk.test.js +37 -0
  28. package/lib/commonjs/sdkContext/useContentpassSdk.test.js.map +1 -0
  29. package/lib/commonjs/sdkContext/useContentpassState.js +26 -0
  30. package/lib/commonjs/sdkContext/useContentpassState.js.map +1 -0
  31. package/lib/commonjs/sentryIntegration.test.js +131 -0
  32. package/lib/commonjs/sentryIntegration.test.js.map +1 -0
  33. package/lib/commonjs/types/CmpAdapter.js +2 -0
  34. package/lib/commonjs/types/CmpAdapter.js.map +1 -0
  35. package/lib/module/Contentpass.js +38 -25
  36. package/lib/module/Contentpass.js.map +1 -1
  37. package/lib/module/Contentpass.test.js +448 -0
  38. package/lib/module/Contentpass.test.js.map +1 -0
  39. package/lib/module/OidcAuthStateStorage.test.js +56 -0
  40. package/lib/module/OidcAuthStateStorage.test.js.map +1 -0
  41. package/lib/module/contentpassTokenUtils/fetchContentpassToken.test.js +44 -0
  42. package/lib/module/contentpassTokenUtils/fetchContentpassToken.test.js.map +1 -0
  43. package/lib/module/contentpassTokenUtils/parseContentpassToken.test.js +30 -0
  44. package/lib/module/contentpassTokenUtils/parseContentpassToken.test.js.map +1 -0
  45. package/lib/module/contentpassTokenUtils/validateSubscription.test.js +70 -0
  46. package/lib/module/contentpassTokenUtils/validateSubscription.test.js.map +1 -0
  47. package/lib/module/countImpressionUtils/sendPageViewEvent.test.js +34 -0
  48. package/lib/module/countImpressionUtils/sendPageViewEvent.test.js.map +1 -0
  49. package/lib/module/countImpressionUtils/sendStats.js +1 -1
  50. package/lib/module/countImpressionUtils/sendStats.js.map +1 -1
  51. package/lib/module/countImpressionUtils/sendStats.test.js +38 -0
  52. package/lib/module/countImpressionUtils/sendStats.test.js.map +1 -0
  53. package/lib/module/index.js +6 -3
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/logger.test.js +40 -0
  56. package/lib/module/logger.test.js.map +1 -0
  57. package/lib/module/package.json +1 -0
  58. package/lib/module/sdkContext/ContentpassSdkProvder.test.js +32 -0
  59. package/lib/module/sdkContext/ContentpassSdkProvder.test.js.map +1 -0
  60. package/lib/module/sdkContext/useContentpassSdk.test.js +36 -0
  61. package/lib/module/sdkContext/useContentpassSdk.test.js.map +1 -0
  62. package/lib/module/sdkContext/useContentpassState.js +21 -0
  63. package/lib/module/sdkContext/useContentpassState.js.map +1 -0
  64. package/lib/module/sentryIntegration.test.js +128 -0
  65. package/lib/module/sentryIntegration.test.js.map +1 -0
  66. package/lib/module/types/CmpAdapter.js +2 -0
  67. package/lib/module/types/CmpAdapter.js.map +1 -0
  68. package/lib/typescript/commonjs/src/Contentpass.d.ts +8 -5
  69. package/lib/typescript/commonjs/src/Contentpass.d.ts.map +1 -1
  70. package/lib/typescript/commonjs/src/countImpressionUtils/sendStats.d.ts +1 -0
  71. package/lib/typescript/commonjs/src/countImpressionUtils/sendStats.d.ts.map +1 -1
  72. package/lib/typescript/commonjs/src/index.d.ts +11 -6
  73. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  74. package/lib/typescript/commonjs/src/logger.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/src/sdkContext/ContentpassSdkProvider.d.ts.map +1 -1
  76. package/lib/typescript/commonjs/src/sdkContext/useContentpassState.d.ts +4 -0
  77. package/lib/typescript/commonjs/src/sdkContext/useContentpassState.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/src/sentryIntegration.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/src/types/CmpAdapter.d.ts +14 -0
  80. package/lib/typescript/commonjs/src/types/CmpAdapter.d.ts.map +1 -0
  81. package/lib/typescript/module/src/Contentpass.d.ts +8 -5
  82. package/lib/typescript/module/src/Contentpass.d.ts.map +1 -1
  83. package/lib/typescript/module/src/countImpressionUtils/sendStats.d.ts +1 -0
  84. package/lib/typescript/module/src/countImpressionUtils/sendStats.d.ts.map +1 -1
  85. package/lib/typescript/module/src/index.d.ts +11 -6
  86. package/lib/typescript/module/src/index.d.ts.map +1 -1
  87. package/lib/typescript/module/src/logger.d.ts.map +1 -1
  88. package/lib/typescript/module/src/sdkContext/ContentpassSdkProvider.d.ts.map +1 -1
  89. package/lib/typescript/module/src/sdkContext/useContentpassState.d.ts +4 -0
  90. package/lib/typescript/module/src/sdkContext/useContentpassState.d.ts.map +1 -0
  91. package/lib/typescript/module/src/sentryIntegration.d.ts.map +1 -1
  92. package/lib/typescript/module/src/types/CmpAdapter.d.ts +14 -0
  93. package/lib/typescript/module/src/types/CmpAdapter.d.ts.map +1 -0
  94. package/package.json +24 -59
  95. package/LICENSE +0 -20
  96. package/README.md +0 -150
@@ -0,0 +1,14 @@
1
+ export type CmpAdapter = {
2
+ acceptAll: () => Promise<void>;
3
+ denyAll: () => Promise<void>;
4
+ getCustomPurposes?: (supportedLanguages: string[]) => Promise<Map<string, string>>;
5
+ getNumberOfVendors: () => Promise<number>;
6
+ getRequiredPurposes: () => Promise<string[]>;
7
+ hasFullConsent: () => Promise<boolean>;
8
+ onConsentStatusChange: (callback: (fullConsent: boolean) => void) => void;
9
+ onAdapterEvent?: (eventName: string, callback: (data?: any) => void) => () => void;
10
+ onEvent?: (callback: (eventName: string, data?: any) => void) => () => void;
11
+ showSecondLayer: (view: 'vendor' | 'purpose') => Promise<void>;
12
+ waitForInit: () => Promise<void>;
13
+ };
14
+ //# sourceMappingURL=CmpAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CmpAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/types/CmpAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,iBAAiB,CAAC,EAAE,CAClB,kBAAkB,EAAE,MAAM,EAAE,KACzB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClC,kBAAkB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,mBAAmB,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,cAAc,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,qBAAqB,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;IAC1E,cAAc,CAAC,EAAE,CACf,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,KAC3B,MAAM,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IAC5E,eAAe,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,CAAC"}
@@ -2,23 +2,26 @@ import { type ContentpassState } from './types/ContentpassState';
2
2
  import type { ContentpassConfig } from './types/ContentpassConfig';
3
3
  export type ContentpassObserver = (state: ContentpassState) => void;
4
4
  interface ContentpassInterface {
5
- authenticate: () => Promise<void>;
6
- registerObserver: (observer: ContentpassObserver) => void;
7
- unregisterObserver: (observer: ContentpassObserver) => void;
5
+ authenticate: (route?: 'login' | 'signup') => Promise<void>;
6
+ countImpression: () => Promise<void>;
7
+ event: (eventCategory: string, eventAction: string, eventLabel?: string, samplingRate?: number) => Promise<void>;
8
8
  logout: () => Promise<void>;
9
+ registerObserver: (observer: ContentpassObserver) => void;
9
10
  recoverFromError: () => Promise<void>;
10
- countImpression: () => Promise<void>;
11
+ unregisterObserver: (observer: ContentpassObserver) => void;
11
12
  }
12
13
  export default class Contentpass implements ContentpassInterface {
13
14
  private authStateStorage;
14
15
  private readonly config;
15
16
  private readonly samplingRate;
17
+ private instanceId;
16
18
  private contentpassState;
17
19
  private contentpassStateObservers;
18
20
  private oidcAuthState;
19
21
  private refreshTimer;
20
22
  constructor(config: ContentpassConfig);
21
- authenticate: () => Promise<void>;
23
+ authenticate: (route?: "login" | "signup") => Promise<void>;
24
+ event: (eventCategory: string, eventAction: string, eventLabel?: string, samplingRate?: number) => Promise<void>;
22
25
  registerObserver(observer: ContentpassObserver): void;
23
26
  unregisterObserver(observer: ContentpassObserver): void;
24
27
  logout: () => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"Contentpass.d.ts","sourceRoot":"","sources":["../../../../src/Contentpass.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,0BAA0B,CAAC;AAUlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAQnE,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAEpE,UAAU,oBAAoB;IAC5B,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC1D,kBAAkB,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,YAAW,oBAAoB;IAC9D,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC,OAAO,CAAC,gBAAgB,CAEtB;IACF,OAAO,CAAC,yBAAyB,CAA6B;IAC9D,OAAO,CAAC,aAAa,CAA8B;IACnD,O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{
2
2
  ea: string;
3
3
  ec: string;
4
+ el?: string;
4
5
  cpabid: string;
5
6
  cppid: string;
6
7
  cpsr: number;
@@ -1 +1 @@
1
- {"version":3,"file":"sendStats.d.ts","sourceRoot":"","sources":["../../../../../src/countImpressionUtils/sendStats.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAA8B,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,qBAc5E"}
1
+ {"version":3,"file":"sendStats.d.ts","sourceRoot":"","sources":["../../../../../src/countImpressionUtils/sendStats.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAA8B,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,qBAc5E"}
@@ -1,7 +1,12 @@
1
- export type { ContentpassState, ErrorState, AuthenticatedState, InitialisingState, UnauthenticatedState, } from './types/ContentpassState';
2
- export { ContentpassStateType } from './types/ContentpassState';
3
- export type { ContentpassConfig } from './types/ContentpassConfig';
4
- export { type default as Contentpass, type ContentpassObserver, } from './Contentpass';
5
- export { ContentpassSdkProvider } from './sdkContext/ContentpassSdkProvider';
6
- export { default as useContentpassSdk } from './sdkContext/useContentpassSdk';
1
+ import type { ContentpassState, ErrorState, AuthenticatedState, InitialisingState, UnauthenticatedState } from './types/ContentpassState';
2
+ import { ContentpassStateType } from './types/ContentpassState';
3
+ import type { ContentpassConfig } from './types/ContentpassConfig';
4
+ import type { CmpAdapter } from './types/CmpAdapter';
5
+ declare const FOOBAR = 123;
6
+ export { FOOBAR };
7
+ import { type default as Contentpass, type ContentpassObserver } from './Contentpass';
8
+ import { ContentpassSdkProvider } from './sdkContext/ContentpassSdkProvider';
9
+ import { default as useContentpassSdk } from './sdkContext/useContentpassSdk';
10
+ export { ContentpassStateType, ContentpassSdkProvider, useContentpassSdk };
11
+ export type { Contentpass, ContentpassState, ErrorState, AuthenticatedState, InitialisingState, UnauthenticatedState, ContentpassConfig, CmpAdapter, ContentpassObserver, };
7
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EACL,KAAK,OAAO,IAAI,WAAW,EAC3B,KAAK,mBAAmB,GACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,QAAA,MAAM,MAAM,MAAM,CAAC;AAEnB,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,EACL,KAAK,OAAO,IAAI,WAAW,EAC3B,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,CAAC;AAC3E,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,UAAU,EACV,mBAAmB,GACpB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oDAAoD,CAAC;AAElG,KAAK,MAAM,GAAG,UAAU,CACtB,OAAO,MAAM,CAAC,YAAY,CAAC,qBAAqB,CAAC,uBAAuB,CAAC,CAAC,CAC3E,CAAC;AAEF,QAAA,MAAM,GAAG,EAAE,MAWT,CAAC;AAEH,eAAO,MAAM,YAAY,aAAc,QAAQ,SAK9C,CAAC;AAEF,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oDAAoD,CAAC;AAElG,KAAK,MAAM,GAAG,UAAU,CACtB,OAAO,MAAM,CAAC,YAAY,CAAC,qBAAqB,CAAC,uBAAuB,CAAC,CAAC,CAC3E,CAAC;AAEF,QAAA,MAAM,GAAG,EAAE,MAWT,CAAC;AAEH,eAAO,MAAM,YAAY,GAAI,UAAU,QAAQ,SAK9C,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentpassSdkProvider.d.ts","sourceRoot":"","sources":["../../../../../src/sdkContext/ContentpassSdkProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,eAAO,MAAM,qBAAqB,wCAEjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,qCAGhC;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC;CACtC,mDAoBA,CAAC"}
1
+ {"version":3,"file":"ContentpassSdkProvider.d.ts","sourceRoot":"","sources":["../../../../../src/sdkContext/ContentpassSdkProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,eAAO,MAAM,qBAAqB,wCAEjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,kCAGpC;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC;CACtC,mDAoBA,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type ContentpassState } from '../types/ContentpassState';
2
+ declare const useContentpassState: () => ContentpassState;
3
+ export default useContentpassState;
4
+ //# sourceMappingURL=useContentpassState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContentpassState.d.ts","sourceRoot":"","sources":["../../../../../src/sdkContext/useContentpassState.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,2BAA2B,CAAC;AAEnC,QAAA,MAAM,mBAAmB,wBAgBxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sentryIntegration.d.ts","sourceRoot":"","sources":["../../../../src/sentryIntegration.ts"],"names":[],"mappings":"AAiCA,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,UAAU,SAAU,cAAc,SAqB9C,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,WAAW,QAAS,KAAK,YAAW,kBAAkB,SAelE,CAAC;AAEF,eAAO,MAAM,6BAA6B,YAEzC,CAAC"}
1
+ {"version":3,"file":"sentryIntegration.d.ts","sourceRoot":"","sources":["../../../../src/sentryIntegration.ts"],"names":[],"mappings":"AAiCA,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,UAAU,GAAI,MAAM,cAAc,SAqB9C,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,KAAK,KAAK,EAAE,UAAS,kBAAuB,SAevE,CAAC;AAEF,eAAO,MAAM,6BAA6B,YAEzC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export type CmpAdapter = {
2
+ acceptAll: () => Promise<void>;
3
+ denyAll: () => Promise<void>;
4
+ getCustomPurposes?: (supportedLanguages: string[]) => Promise<Map<string, string>>;
5
+ getNumberOfVendors: () => Promise<number>;
6
+ getRequiredPurposes: () => Promise<string[]>;
7
+ hasFullConsent: () => Promise<boolean>;
8
+ onConsentStatusChange: (callback: (fullConsent: boolean) => void) => void;
9
+ onAdapterEvent?: (eventName: string, callback: (data?: any) => void) => () => void;
10
+ onEvent?: (callback: (eventName: string, data?: any) => void) => () => void;
11
+ showSecondLayer: (view: 'vendor' | 'purpose') => Promise<void>;
12
+ waitForInit: () => Promise<void>;
13
+ };
14
+ //# sourceMappingURL=CmpAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CmpAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/types/CmpAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,iBAAiB,CAAC,EAAE,CAClB,kBAAkB,EAAE,MAAM,EAAE,KACzB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClC,kBAAkB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,mBAAmB,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,cAAc,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,qBAAqB,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;IAC1E,cAAc,CAAC,EAAE,CACf,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,KAC3B,MAAM,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IAC5E,eAAe,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentpass/react-native-contentpass",
3
- "version": "0.3.16",
3
+ "version": "0.4.0",
4
4
  "description": "Contentpass React Native SDK",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -39,15 +39,9 @@
39
39
  "!**/.*"
40
40
  ],
41
41
  "scripts": {
42
- "example": "yarn workspace react-native-contentpass-example",
43
- "expo-example": "yarn workspace react-native-contentpass-expo-example",
44
- "test": "jest",
42
+ "test": "jest --coverage",
45
43
  "typecheck": "tsc",
46
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
47
- "prettier:check": "prettier --check \"**/*.{js,ts,tsx}\"",
48
- "clean": "del-cli android/build example/android/build expoExample/android/build example/android/app/build expoExample/android/app/build example/ios/build exampleExample/ios/build lib",
49
- "prepare": "bob build",
50
- "release": "release-it"
44
+ "prepare": "bob build"
51
45
  },
52
46
  "keywords": [
53
47
  "contentpass",
@@ -69,57 +63,34 @@
69
63
  "registry": "https://registry.npmjs.org/",
70
64
  "access": "public"
71
65
  },
72
- "devDependencies": {
73
- "@commitlint/config-conventional": "^17.0.2",
74
- "@evilmartians/lefthook": "^1.5.0",
75
- "@react-native-community/cli": "15.0.1",
76
- "@react-native/babel-preset": "0.76.3",
77
- "@react-native/eslint-config": "^0.73.1",
78
- "@release-it/conventional-changelog": "^9.0.2",
79
- "@testing-library/react-native": "^12.9.0",
80
- "@types/jest": "^29.5.5",
81
- "@types/lodash": "^4.17.13",
82
- "@types/react": "^18.2.44",
83
- "commitlint": "^17.0.2",
84
- "conventional-changelog-angular": "^8.0.0",
85
- "del-cli": "^5.1.0",
86
- "eslint": "^8.51.0",
87
- "eslint-config-prettier": "^9.0.0",
88
- "eslint-plugin-prettier": "^5.0.1",
89
- "jest": "^29.7.0",
90
- "prettier": "^3.4.2",
91
- "react": "18.3.1",
92
- "react-native": "0.76.2",
93
- "react-native-app-auth": "^8.0.0",
94
- "react-native-builder-bob": "^0.32.1",
95
- "react-native-encrypted-storage": "^4.0.3",
96
- "react-test-renderer": "18.3.1",
97
- "release-it": "^17.10.0",
98
- "turbo": "^1.10.7",
99
- "typescript": "^5.2.2"
100
- },
101
- "resolutions": {
102
- "@types/react": "^18.2.44"
103
- },
104
66
  "peerDependencies": {
105
67
  "react": "*",
106
68
  "react-native": "*",
107
69
  "react-native-app-auth": "*",
108
70
  "react-native-encrypted-storage": "*"
109
71
  },
110
- "workspaces": [
111
- "example",
112
- "expoExample",
113
- "sharedExample"
114
- ],
115
- "packageManager": "yarn@3.6.1",
72
+ "dependencies": {
73
+ "@sentry/react-native": "^7.11.0",
74
+ "react-native-logs": "^5.5.0",
75
+ "react-native-uuid": "^2.0.3"
76
+ },
77
+ "devDependencies": {
78
+ "@react-native-community/cli": "20.1.1",
79
+ "@react-native/babel-preset": "0.83.1",
80
+ "@types/jest": "^30.0.0",
81
+ "@types/lodash": "^4.17.23",
82
+ "@types/react": "^19.2.10",
83
+ "jest": "^30.2.0",
84
+ "react": "19.2.4",
85
+ "react-native": "0.83.1",
86
+ "react-native-app-auth": "^8.1.0",
87
+ "react-native-builder-bob": "^0.40.17",
88
+ "react-native-encrypted-storage": "^4.0.3",
89
+ "react-test-renderer": "19.2.4",
90
+ "typescript": "^5.9.3"
91
+ },
116
92
  "react-native-builder-bob": {
117
93
  "source": "src",
118
- "exclude": [
119
- "**/{__tests__,__fixtures__,__mocks__}/**",
120
- "**/*.test.ts",
121
- "**/*.test.tsx"
122
- ],
123
94
  "output": "lib",
124
95
  "targets": [
125
96
  [
@@ -137,8 +108,7 @@
137
108
  [
138
109
  "typescript",
139
110
  {
140
- "project": "tsconfig.build.json",
141
- "esm": true
111
+ "project": "tsconfig.build.json"
142
112
  }
143
113
  ]
144
114
  ]
@@ -147,10 +117,5 @@
147
117
  "type": "module-legacy",
148
118
  "languages": "kotlin-objc",
149
119
  "version": "0.44.1"
150
- },
151
- "dependencies": {
152
- "@sentry/react-native": "^6.3.0",
153
- "react-native-logs": "^5.3.0",
154
- "react-native-uuid": "^2.0.3"
155
120
  }
156
121
  }
package/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 contentpass
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- SOFTWARE.
package/README.md DELETED
@@ -1,150 +0,0 @@
1
- # @contentpass/react-native-contentpass
2
-
3
- Contentpass React Native SDK enables easy integration of Contentpass functionality into your React Native applications.
4
-
5
- ## Installation
6
- Install the package using npm or Yarn:
7
-
8
- ```sh
9
- npm install @contentpass/react-native-contentpass
10
- ```
11
-
12
- or
13
-
14
- ```sh
15
- yarn add @contentpass/react-native-contentpass
16
- ```
17
-
18
- ### Peer Dependencies
19
- The following peer dependencies must also be installed:
20
- - [react](https://github.com/facebook/react) (Required for React Native projects.)
21
- - [react-native](https://github.com/facebook/react-native) (Core React Native framework)
22
- - [react-native-app-auth](https://github.com/FormidableLabs/react-native-app-auth) (Used for OAuth 2.0 authentication)
23
- - [react-native-encrypted-storage](https://github.com/emeraldsanto/react-native-encrypted-storage) (Ensures secure storage of authentication tokens)
24
-
25
- Some dependencies require additional setup in the native code. Refer to their official guides:
26
- - [react-native-app-auth setup](https://commerce.nearform.com/open-source/react-native-app-auth/docs#setup)
27
- - [react-native-encrypted-storage setup](https://github.com/emeraldsanto/react-native-encrypted-storage?tab=readme-ov-file#installation)
28
-
29
- ### Expo support
30
- If you are using Expo, you need to run the following command to enable modifications to the `ios` and `android` directories:
31
-
32
- ```sh
33
- npx expo prebuild
34
- ```
35
-
36
- ## Usage
37
-
38
- ### Initialization
39
- Wrap your app's root component with ContentpassSdkProvider. The provider requires a configuration object (contentpassConfig) with the following properties:
40
- - `propertyId` - Your unique property ID (ask Contentpass team for details)
41
- - `planId` - The ID of the plan you want to check the user's subscription status against (ask Contentpass team for details)
42
- - `issuer` - The OAuth 2.0 server URL (e.g. `https://my.contentpass.net`)
43
- - `redirectUrl` - the redirect URL of your app to which the OAuth2 server will redirect after the authentication
44
- - `samplingRate` - Optional: The rate at which the SDK will send impression events for unauthenticated users. Default is 0.05 (5%)
45
- - `logLevel` - Optional: The log level for the SDK. By default logger is disabled. Possible values are 'info', 'warn', 'error' and 'debug'
46
-
47
-
48
- ```jsx
49
- import React from 'react';
50
- import { ContentpassSdkProvider } from '@contentpass/react-native-contentpass';
51
-
52
- const contentpassConfig = {
53
- propertyId: 'property-id',
54
- planId: 'plan-id',
55
- issuer: 'https://my.contentpass.net',
56
- redirectUrl: 'com.yourapp://oauthredirect',
57
- samplingRate: 0.1,
58
- logLevel: 'info'
59
- };
60
-
61
- const App = () => {
62
- return (
63
- <ContentpassSdkProvider contentpassConfig={contentpassConfig}>
64
- <YourApp />
65
- </ContentpassSdkProvider>
66
- );
67
- };
68
-
69
- export default App;
70
- ```
71
-
72
- ### SDK Methods
73
- The SDK exposes the following methods through the `useContentpassSdk` hook:
74
-
75
- ### authenticate
76
- Initiates the OAuth 2.0 authentication process via a modal interface. It validates the user’s active Contentpass subscriptions
77
- upon successful authentication.
78
-
79
- ### countImpression
80
- Tracks and increments the impression count for the current user. This method should be invoked whenever a user views a
81
- piece of content. It applies to all users, whether authenticated or unauthenticated.
82
-
83
- ### registerObserver
84
- Registers a callback function to listen for changes in the user’s authentication and subscription status. The observer function
85
- receives a state object describing the current status (see the exported [ContentpassState](./src/types/ContentpassState.ts) type).
86
-
87
- ### unregisterObserver
88
- Unregisters a previously registered observer. The observer will no longer receive updates.
89
-
90
- ### logout
91
- Logs the user out by clearing all stored authentication tokens.
92
-
93
- ### recoverFromError
94
- During background token refresh, an error state may occur due to poor or no internet connection. This is indicated by the
95
- `state` switching to `ERROR`. The state object includes a reference to the original exception that was thrown. As the SDK
96
- does not monitor the device's connection state, you must notify the SDK when the network connection has been reestablished
97
- or improved. The SDK will then refresh and revalidate the user's authentication tokens.
98
-
99
- ```jsx
100
- import React, { useEffect } from 'react';
101
- import { useContentpassSdk } from '@contentpass/react-native-contentpass';
102
- import { Button, View } from 'react-native';
103
-
104
- const YourApp = () => {
105
- const {
106
- authenticate,
107
- countImpression,
108
- registerObserver,
109
- unregisterObserver,
110
- logout,
111
- recoverFromError
112
- } = useContentpassSdk();
113
-
114
- useEffect(() => {
115
- const observer = (state) => {
116
- console.log('Contentpass state changed:', state);
117
- };
118
-
119
- registerObserver(observer);
120
-
121
- return () => {
122
- unregisterObserver(observer);
123
- };
124
- }, []);
125
-
126
- return (
127
- <View>
128
- <Button onPress={authenticate} title={'Authenticate'} />
129
- <Button onPress={countImpression} title={'Count Impression'} />
130
- </View>
131
- );
132
- };
133
- ```
134
-
135
- ## Integration with Sourcepoint SDK
136
-
137
- See the [Sourcepoint SDK documentation](docs/SOURCEPOINT_SDK_INTEGRATION.md) for information on integrating the Contentpass SDK with the Sourcepoint SDK.
138
-
139
- ## Contributing
140
-
141
- See the [contributing guide](docs/CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
142
-
143
-
144
- ## License
145
-
146
- MIT
147
-
148
- ---
149
-
150
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)