@contentpass/react-native-contentpass 0.2.5

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 (110) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +134 -0
  3. package/contentpass-react-native-contentpass.podspec +41 -0
  4. package/lib/commonjs/Contentpass.js +173 -0
  5. package/lib/commonjs/Contentpass.js.map +1 -0
  6. package/lib/commonjs/OidcAuthStateStorage.js +26 -0
  7. package/lib/commonjs/OidcAuthStateStorage.js.map +1 -0
  8. package/lib/commonjs/consts/oidcConsts.js +10 -0
  9. package/lib/commonjs/consts/oidcConsts.js.map +1 -0
  10. package/lib/commonjs/index.js +28 -0
  11. package/lib/commonjs/index.js.map +1 -0
  12. package/lib/commonjs/sdkContext/ContentpassSdkProvider.js +32 -0
  13. package/lib/commonjs/sdkContext/ContentpassSdkProvider.js.map +1 -0
  14. package/lib/commonjs/sdkContext/useContentpassSdk.js +17 -0
  15. package/lib/commonjs/sdkContext/useContentpassSdk.js.map +1 -0
  16. package/lib/commonjs/sentryIntegration.js +61 -0
  17. package/lib/commonjs/sentryIntegration.js.map +1 -0
  18. package/lib/commonjs/types/ContentpassConfig.js +2 -0
  19. package/lib/commonjs/types/ContentpassConfig.js.map +1 -0
  20. package/lib/commonjs/types/ContentpassState.js +15 -0
  21. package/lib/commonjs/types/ContentpassState.js.map +1 -0
  22. package/lib/commonjs/types/RefreshTokenStrategy.js +14 -0
  23. package/lib/commonjs/types/RefreshTokenStrategy.js.map +1 -0
  24. package/lib/commonjs/utils/fetchContentpassToken.js +29 -0
  25. package/lib/commonjs/utils/fetchContentpassToken.js.map +1 -0
  26. package/lib/commonjs/utils/parseContentpassToken.js +19 -0
  27. package/lib/commonjs/utils/parseContentpassToken.js.map +1 -0
  28. package/lib/commonjs/utils/validateSubscription.js +23 -0
  29. package/lib/commonjs/utils/validateSubscription.js.map +1 -0
  30. package/lib/module/Contentpass.js +167 -0
  31. package/lib/module/Contentpass.js.map +1 -0
  32. package/lib/module/OidcAuthStateStorage.js +20 -0
  33. package/lib/module/OidcAuthStateStorage.js.map +1 -0
  34. package/lib/module/consts/oidcConsts.js +6 -0
  35. package/lib/module/consts/oidcConsts.js.map +1 -0
  36. package/lib/module/index.js +6 -0
  37. package/lib/module/index.js.map +1 -0
  38. package/lib/module/sdkContext/ContentpassSdkProvider.js +24 -0
  39. package/lib/module/sdkContext/ContentpassSdkProvider.js.map +1 -0
  40. package/lib/module/sdkContext/useContentpassSdk.js +13 -0
  41. package/lib/module/sdkContext/useContentpassSdk.js.map +1 -0
  42. package/lib/module/sentryIntegration.js +54 -0
  43. package/lib/module/sentryIntegration.js.map +1 -0
  44. package/lib/module/types/ContentpassConfig.js +2 -0
  45. package/lib/module/types/ContentpassConfig.js.map +1 -0
  46. package/lib/module/types/ContentpassState.js +12 -0
  47. package/lib/module/types/ContentpassState.js.map +1 -0
  48. package/lib/module/types/RefreshTokenStrategy.js +11 -0
  49. package/lib/module/types/RefreshTokenStrategy.js.map +1 -0
  50. package/lib/module/utils/fetchContentpassToken.js +25 -0
  51. package/lib/module/utils/fetchContentpassToken.js.map +1 -0
  52. package/lib/module/utils/parseContentpassToken.js +15 -0
  53. package/lib/module/utils/parseContentpassToken.js.map +1 -0
  54. package/lib/module/utils/validateSubscription.js +18 -0
  55. package/lib/module/utils/validateSubscription.js.map +1 -0
  56. package/lib/typescript/commonjs/package.json +1 -0
  57. package/lib/typescript/commonjs/src/Contentpass.d.ts +24 -0
  58. package/lib/typescript/commonjs/src/Contentpass.d.ts.map +1 -0
  59. package/lib/typescript/commonjs/src/OidcAuthStateStorage.d.ts +15 -0
  60. package/lib/typescript/commonjs/src/OidcAuthStateStorage.d.ts.map +1 -0
  61. package/lib/typescript/commonjs/src/consts/oidcConsts.d.ts +4 -0
  62. package/lib/typescript/commonjs/src/consts/oidcConsts.d.ts.map +1 -0
  63. package/lib/typescript/commonjs/src/index.d.ts +7 -0
  64. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  65. package/lib/typescript/commonjs/src/sdkContext/ContentpassSdkProvider.d.ts +9 -0
  66. package/lib/typescript/commonjs/src/sdkContext/ContentpassSdkProvider.d.ts.map +1 -0
  67. package/lib/typescript/commonjs/src/sdkContext/useContentpassSdk.d.ts +3 -0
  68. package/lib/typescript/commonjs/src/sdkContext/useContentpassSdk.d.ts.map +1 -0
  69. package/lib/typescript/commonjs/src/sentryIntegration.d.ts +7 -0
  70. package/lib/typescript/commonjs/src/sentryIntegration.d.ts.map +1 -0
  71. package/lib/typescript/commonjs/src/types/ContentpassConfig.d.ts +6 -0
  72. package/lib/typescript/commonjs/src/types/ContentpassConfig.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/src/types/ContentpassState.d.ts +28 -0
  74. package/lib/typescript/commonjs/src/types/ContentpassState.d.ts.map +1 -0
  75. package/lib/typescript/commonjs/src/types/RefreshTokenStrategy.d.ts +6 -0
  76. package/lib/typescript/commonjs/src/types/RefreshTokenStrategy.d.ts.map +1 -0
  77. package/lib/typescript/commonjs/src/utils/fetchContentpassToken.d.ts +6 -0
  78. package/lib/typescript/commonjs/src/utils/fetchContentpassToken.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/src/utils/parseContentpassToken.d.ts +17 -0
  80. package/lib/typescript/commonjs/src/utils/parseContentpassToken.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/src/utils/validateSubscription.d.ts +2 -0
  82. package/lib/typescript/commonjs/src/utils/validateSubscription.d.ts.map +1 -0
  83. package/lib/typescript/module/package.json +1 -0
  84. package/lib/typescript/module/src/Contentpass.d.ts +24 -0
  85. package/lib/typescript/module/src/Contentpass.d.ts.map +1 -0
  86. package/lib/typescript/module/src/OidcAuthStateStorage.d.ts +15 -0
  87. package/lib/typescript/module/src/OidcAuthStateStorage.d.ts.map +1 -0
  88. package/lib/typescript/module/src/consts/oidcConsts.d.ts +4 -0
  89. package/lib/typescript/module/src/consts/oidcConsts.d.ts.map +1 -0
  90. package/lib/typescript/module/src/index.d.ts +7 -0
  91. package/lib/typescript/module/src/index.d.ts.map +1 -0
  92. package/lib/typescript/module/src/sdkContext/ContentpassSdkProvider.d.ts +9 -0
  93. package/lib/typescript/module/src/sdkContext/ContentpassSdkProvider.d.ts.map +1 -0
  94. package/lib/typescript/module/src/sdkContext/useContentpassSdk.d.ts +3 -0
  95. package/lib/typescript/module/src/sdkContext/useContentpassSdk.d.ts.map +1 -0
  96. package/lib/typescript/module/src/sentryIntegration.d.ts +7 -0
  97. package/lib/typescript/module/src/sentryIntegration.d.ts.map +1 -0
  98. package/lib/typescript/module/src/types/ContentpassConfig.d.ts +6 -0
  99. package/lib/typescript/module/src/types/ContentpassConfig.d.ts.map +1 -0
  100. package/lib/typescript/module/src/types/ContentpassState.d.ts +28 -0
  101. package/lib/typescript/module/src/types/ContentpassState.d.ts.map +1 -0
  102. package/lib/typescript/module/src/types/RefreshTokenStrategy.d.ts +6 -0
  103. package/lib/typescript/module/src/types/RefreshTokenStrategy.d.ts.map +1 -0
  104. package/lib/typescript/module/src/utils/fetchContentpassToken.d.ts +6 -0
  105. package/lib/typescript/module/src/utils/fetchContentpassToken.d.ts.map +1 -0
  106. package/lib/typescript/module/src/utils/parseContentpassToken.d.ts +17 -0
  107. package/lib/typescript/module/src/utils/parseContentpassToken.d.ts.map +1 -0
  108. package/lib/typescript/module/src/utils/validateSubscription.d.ts +2 -0
  109. package/lib/typescript/module/src/utils/validateSubscription.d.ts.map +1 -0
  110. package/package.json +154 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
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 ADDED
@@ -0,0 +1,134 @@
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
41
+ - `issuer` - The OAuth 2.0 server URL (e.g. `https://my.contentpass.net`)
42
+ - `redirectUrl` - the redirect URL of your app to which the OAuth2 server will redirect after the authentication
43
+
44
+
45
+ ```jsx
46
+ import React from 'react';
47
+ import { ContentpassSdkProvider } from '@contentpass/react-native-contentpass';
48
+
49
+ const contentpassConfig = {
50
+ propertyId: 'your-property-id',
51
+ issuer: 'https://my.contentpass.net',
52
+ redirectUrl: 'com.yourapp://oauthredirect',
53
+ };
54
+
55
+ const App = () => {
56
+ return (
57
+ <ContentpassSdkProvider contentpassConfig={contentpassConfig}>
58
+ <YourApp />
59
+ </ContentpassSdkProvider>
60
+ );
61
+ };
62
+
63
+ export default App;
64
+ ```
65
+
66
+ ### SDK Methods
67
+ The SDK exposes the following methods through the `useContentpassSdk` hook:
68
+
69
+ ### authenticate
70
+ Initiates the OAuth 2.0 authentication process via a modal interface. It validates the user’s active Contentpass subscriptions
71
+ upon successful authentication.
72
+
73
+ ### registerObserver
74
+ Registers a callback function to listen for changes in the user’s authentication and subscription status. The observer function
75
+ receives a state object describing the current status (see the exported [ContentpassState](./src/types/ContentpassState.ts) type).
76
+
77
+ ### unregisterObserver
78
+ Unregisters a previously registered observer. The observer will no longer receive updates.
79
+
80
+ ### logout
81
+ Logs the user out by clearing all stored authentication tokens.
82
+
83
+ ### recoverFromError
84
+ During background token refresh, an error state may occur due to poor or no internet connection. This is indicated by the
85
+ `state` switching to `ERROR`. The state object includes a reference to the original exception that was thrown. As the SDK
86
+ does not monitor the device's connection state, you must notify the SDK when the network connection has been reestablished
87
+ or improved. The SDK will then refresh and revalidate the user's authentication tokens.
88
+
89
+ ```jsx
90
+ import React, { useEffect } from 'react';
91
+ import { useContentpassSdk } from '@contentpass/react-native-contentpass';
92
+ import { Button, View } from 'react-native';
93
+
94
+ const YourApp = () => {
95
+ const {
96
+ authenticate,
97
+ registerObserver,
98
+ unregisterObserver,
99
+ logout,
100
+ recoverFromError
101
+ } = useContentpassSdk();
102
+
103
+ useEffect(() => {
104
+ const observer = (state) => {
105
+ console.log('Contentpass state changed:', state);
106
+ };
107
+
108
+ registerObserver(observer);
109
+
110
+ return () => {
111
+ unregisterObserver(observer);
112
+ };
113
+ }, []);
114
+
115
+ return (
116
+ <View>
117
+ <Button onPress={authenticate} title={'Authenticate'} />
118
+ </View>
119
+ );
120
+ };
121
+ ```
122
+
123
+
124
+ ## Contributing
125
+
126
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
127
+
128
+ ## License
129
+
130
+ MIT
131
+
132
+ ---
133
+
134
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,41 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "contentpass-react-native-contentpass"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => min_ios_version_supported }
15
+ s.source = { :git => "https://github.com/contentpass/react-native-contentpass.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm}"
18
+
19
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
+ if respond_to?(:install_modules_dependencies, true)
22
+ install_modules_dependencies(s)
23
+ else
24
+ s.dependency "React-Core"
25
+
26
+ # Don't install the dependencies when we run `pod install` in the old architecture.
27
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
28
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
29
+ s.pod_target_xcconfig = {
30
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
31
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
32
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
33
+ }
34
+ s.dependency "React-Codegen"
35
+ s.dependency "RCT-Folly"
36
+ s.dependency "RCTRequired"
37
+ s.dependency "RCTTypeSafety"
38
+ s.dependency "ReactCommon/turbomodule/core"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _OidcAuthStateStorage = _interopRequireDefault(require("./OidcAuthStateStorage.js"));
8
+ var _ContentpassState = require("./types/ContentpassState.js");
9
+ var _reactNativeAppAuth = require("react-native-app-auth");
10
+ var _oidcConsts = require("./consts/oidcConsts.js");
11
+ var _RefreshTokenStrategy = require("./types/RefreshTokenStrategy.js");
12
+ var _fetchContentpassToken = _interopRequireDefault(require("./utils/fetchContentpassToken.js"));
13
+ var _validateSubscription = _interopRequireDefault(require("./utils/validateSubscription.js"));
14
+ var _sentryIntegration = require("./sentryIntegration.js");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ class Contentpass {
17
+ contentpassState = {
18
+ state: _ContentpassState.ContentpassStateType.INITIALISING
19
+ };
20
+ contentpassStateObservers = [];
21
+ oidcAuthState = null;
22
+ refreshTimer = null;
23
+ constructor(config) {
24
+ this.authStateStorage = new _OidcAuthStateStorage.default(config.propertyId);
25
+ this.config = config;
26
+ (0, _sentryIntegration.setSentryExtraAttribute)('propertyId', config.propertyId);
27
+ this.initialiseAuthState();
28
+ }
29
+ authenticate = async () => {
30
+ let result;
31
+ try {
32
+ result = await (0, _reactNativeAppAuth.authorize)({
33
+ clientId: this.config.propertyId,
34
+ redirectUrl: this.config.redirectUrl,
35
+ issuer: this.config.issuer,
36
+ scopes: _oidcConsts.SCOPES,
37
+ additionalParameters: {
38
+ cp_route: 'login',
39
+ prompt: 'consent',
40
+ cp_property: this.config.propertyId
41
+ }
42
+ });
43
+ } catch (err) {
44
+ (0, _sentryIntegration.reportError)(err, {
45
+ msg: 'Failed to authorize'
46
+ });
47
+ this.changeContentpassState({
48
+ state: _ContentpassState.ContentpassStateType.ERROR,
49
+ error: err
50
+ });
51
+ throw err;
52
+ }
53
+ await this.onNewAuthState(result);
54
+ };
55
+ registerObserver(observer) {
56
+ if (this.contentpassStateObservers.includes(observer)) {
57
+ return;
58
+ }
59
+ observer(this.contentpassState);
60
+ this.contentpassStateObservers.push(observer);
61
+ }
62
+ unregisterObserver(observer) {
63
+ this.contentpassStateObservers = this.contentpassStateObservers.filter(o => o !== observer);
64
+ }
65
+ logout = async () => {
66
+ await this.authStateStorage.clearOidcAuthState();
67
+ this.changeContentpassState({
68
+ state: _ContentpassState.ContentpassStateType.UNAUTHENTICATED,
69
+ hasValidSubscription: false
70
+ });
71
+ };
72
+ recoverFromError = async () => {
73
+ this.changeContentpassState({
74
+ state: _ContentpassState.ContentpassStateType.INITIALISING
75
+ });
76
+ await this.initialiseAuthState();
77
+ };
78
+ initialiseAuthState = async () => {
79
+ const authState = await this.authStateStorage.getOidcAuthState();
80
+ if (authState) {
81
+ await this.onNewAuthState(authState);
82
+ return;
83
+ }
84
+ this.changeContentpassState({
85
+ state: _ContentpassState.ContentpassStateType.UNAUTHENTICATED,
86
+ hasValidSubscription: false
87
+ });
88
+ };
89
+ onNewAuthState = async authState => {
90
+ this.oidcAuthState = authState;
91
+ await this.authStateStorage.storeOidcAuthState(authState);
92
+ const strategy = this.setupRefreshTimer();
93
+ // if instant refresh, no need to check subscription as it will happen in the refresh
94
+ if (strategy === _RefreshTokenStrategy.RefreshTokenStrategy.INSTANTLY) {
95
+ return;
96
+ }
97
+ try {
98
+ const contentpassToken = await (0, _fetchContentpassToken.default)({
99
+ issuer: this.config.issuer,
100
+ propertyId: this.config.propertyId,
101
+ idToken: this.oidcAuthState.idToken
102
+ });
103
+ const hasValidSubscription = (0, _validateSubscription.default)(contentpassToken);
104
+ this.changeContentpassState({
105
+ state: _ContentpassState.ContentpassStateType.AUTHENTICATED,
106
+ hasValidSubscription
107
+ });
108
+ } catch (err) {
109
+ this.changeContentpassState({
110
+ state: _ContentpassState.ContentpassStateType.ERROR,
111
+ error: err
112
+ });
113
+ }
114
+ };
115
+ setupRefreshTimer = () => {
116
+ const accessTokenExpirationDate = this.oidcAuthState?.accessTokenExpirationDate;
117
+ if (!accessTokenExpirationDate) {
118
+ return _RefreshTokenStrategy.RefreshTokenStrategy.NO_REFRESH;
119
+ }
120
+ const now = new Date();
121
+ const expirationDate = new Date(accessTokenExpirationDate);
122
+ const timeDiff = expirationDate.getTime() - now.getTime();
123
+ if (timeDiff <= 0) {
124
+ this.refreshToken(0);
125
+ return _RefreshTokenStrategy.RefreshTokenStrategy.INSTANTLY;
126
+ }
127
+ if (this.refreshTimer) {
128
+ clearTimeout(this.refreshTimer);
129
+ }
130
+ this.refreshTimer = setTimeout(async () => {
131
+ await this.refreshToken(0);
132
+ }, timeDiff);
133
+ return _RefreshTokenStrategy.RefreshTokenStrategy.TIMER_SET;
134
+ };
135
+ refreshToken = async counter => {
136
+ if (!this.oidcAuthState?.refreshToken) {
137
+ (0, _sentryIntegration.reportError)(new Error('No Refresh Token in oidcAuthState provided'));
138
+ return;
139
+ }
140
+ try {
141
+ const refreshResult = await (0, _reactNativeAppAuth.refresh)({
142
+ clientId: this.config.propertyId,
143
+ redirectUrl: this.config.redirectUrl,
144
+ issuer: this.config.issuer,
145
+ scopes: _oidcConsts.SCOPES
146
+ }, {
147
+ refreshToken: this.oidcAuthState.refreshToken
148
+ });
149
+ await this.onNewAuthState(refreshResult);
150
+ } catch (err) {
151
+ await this.onRefreshTokenError(counter, err);
152
+ }
153
+ };
154
+ onRefreshTokenError = async (counter, err) => {
155
+ (0, _sentryIntegration.reportError)(err, {
156
+ msg: `Failed to refresh token after ${counter} retries`
157
+ });
158
+ // FIXME: add handling for specific error to not retry in every case
159
+ if (counter < _oidcConsts.REFRESH_TOKEN_RETRIES) {
160
+ const delay = counter * 1000 * 10;
161
+ await new Promise(resolve => setTimeout(resolve, delay));
162
+ await this.refreshToken(counter + 1);
163
+ return;
164
+ }
165
+ await this.logout();
166
+ };
167
+ changeContentpassState = state => {
168
+ this.contentpassState = state;
169
+ this.contentpassStateObservers.forEach(observer => observer(state));
170
+ };
171
+ }
172
+ exports.default = Contentpass;
173
+ //# sourceMappingURL=Contentpass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_OidcAuthStateStorage","_interopRequireDefault","require","_ContentpassState","_reactNativeAppAuth","_oidcConsts","_RefreshTokenStrategy","_fetchContentpassToken","_validateSubscription","_sentryIntegration","e","__esModule","default","Contentpass","contentpassState","state","ContentpassStateType","INITIALISING","contentpassStateObservers","oidcAuthState","refreshTimer","constructor","config","authStateStorage","OidcAuthStateStorage","propertyId","setSentryExtraAttribute","initialiseAuthState","authenticate","result","authorize","clientId","redirectUrl","issuer","scopes","SCOPES","additionalParameters","cp_route","prompt","cp_property","err","reportError","msg","changeContentpassState","ERROR","error","onNewAuthState","registerObserver","observer","includes","push","unregisterObserver","filter","o","logout","clearOidcAuthState","UNAUTHENTICATED","hasValidSubscription","recoverFromError","authState","getOidcAuthState","storeOidcAuthState","strategy","setupRefreshTimer","RefreshTokenStrategy","INSTANTLY","contentpassToken","fetchContentpassToken","idToken","validateSubscription","AUTHENTICATED","accessTokenExpirationDate","NO_REFRESH","now","Date","expirationDate","timeDiff","getTime","refreshToken","clearTimeout","setTimeout","TIMER_SET","counter","Error","refreshResult","refresh","onRefreshTokenError","REFRESH_TOKEN_RETRIES","delay","Promise","res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CACF,CAAC;MACD,MAAM,IAAI,CAAChC,cAAc,CAACsC,aAAa,CAAC;IAC1C,CAAC,CAAC,OAAO5C,GAAQ,EAAE;MACjB,MAAM,IAAI,CAAC8C,mBAAmB,CAACJ,OAAO,EAAE1C,GAAG,CAAC;IAC9C;EACF,CAAC;EAEO8C,mBAAmB,GAAG,MAAAA,CAAOJ,OAAe,EAAE1C,GAAU,KAAK;IACnE,IAAAC,8BAAW,EAACD,GAAG,EAAE;MACfE,GAAG,EAAE,iCAAiCwC,OAAO;IAC/C,CAAC,CAAC;IACF;IACA,IAAIA,OAAO,GAAGK,iCAAqB,EAAE;MACnC,MAAMC,KAAK,GAAGN,OAAO,GAAG,IAAI,GAAG,EAAE;MACjC,MAAM,IAAIO,OAAO,CAAEC,OAAO,IAAKV,UAAU,CAACU,OAAO,EAAEF,KAAK,CAAC,CAAC;MAC1D,MAAM,IAAI,CAACV,YAAY,CAACI,OAAO,GAAG,CAAC,CAAC;MACpC;IACF;IAEA,MAAM,IAAI,CAAC5B,MAAM,CAAC,CAAC;EACrB,CAAC;EAEOX,sBAAsB,GAAI5B,KAAuB,IAAK;IAC5D,IAAI,CAACD,gBAAgB,GAAGC,KAAK;IAC7B,IAAI,CAACG,yBAAyB,CAACyE,OAAO,CAAE3C,QAAQ,IAAKA,QAAQ,CAACjC,KAAK,CAAC,CAAC;EACvE,CAAC;AACH;AAAC6E,OAAA,CAAAhF,OAAA,GAAAC,WAAA","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNativeEncryptedStorage = _interopRequireDefault(require("react-native-encrypted-storage"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const AUTH_STATE_KEY = 'OIDCAuthState';
10
+ class OidcAuthStateStorage {
11
+ constructor(clientId) {
12
+ this.key = `de.contentpass.${clientId}-${AUTH_STATE_KEY}`;
13
+ }
14
+ async storeOidcAuthState(authState) {
15
+ await _reactNativeEncryptedStorage.default.setItem(this.key, JSON.stringify(authState));
16
+ }
17
+ async getOidcAuthState() {
18
+ const oidcAuthStateString = await _reactNativeEncryptedStorage.default.getItem(this.key);
19
+ return oidcAuthStateString ? JSON.parse(oidcAuthStateString) : undefined;
20
+ }
21
+ async clearOidcAuthState() {
22
+ await _reactNativeEncryptedStorage.default.removeItem(this.key);
23
+ }
24
+ }
25
+ exports.default = OidcAuthStateStorage;
26
+ //# sourceMappingURL=OidcAuthStateStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeEncryptedStorage","_interopRequireDefault","require","e","__esModule","default","AUTH_STATE_KEY","OidcAuthStateStorage","constructor","clientId","key","storeOidcAuthState","authState","EncryptedStorage","setItem","JSON","stringify","getOidcAuthState","oidcAuthStateString","getItem","parse","undefined","clearOidcAuthState","removeItem","exports"],"sourceRoot":"../../src","sources":["OidcAuthStateStorage.ts"],"mappings":";;;;;;AAAA,IAAAA,4BAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9D,MAAMG,cAAc,GAAG,eAAe;AAUvB,MAAMC,oBAAoB,CAAC;EAGxCC,WAAWA,CAACC,QAAgB,EAAE;IAC5B,IAAI,CAACC,GAAG,GAAG,kBAAkBD,QAAQ,IAAIH,cAAc,EAAE;EAC3D;EAEA,MAAaK,kBAAkBA,CAACC,SAAwB,EAAE;IACxD,MAAMC,oCAAgB,CAACC,OAAO,CAAC,IAAI,CAACJ,GAAG,EAAEK,IAAI,CAACC,SAAS,CAACJ,SAAS,CAAC,CAAC;EACrE;EAEA,MAAaK,gBAAgBA,CAAA,EAAuC;IAClE,MAAMC,mBAAmB,GAAG,MAAML,oCAAgB,CAACM,OAAO,CAAC,IAAI,CAACT,GAAG,CAAC;IAEpE,OAAOQ,mBAAmB,GAAGH,IAAI,CAACK,KAAK,CAACF,mBAAmB,CAAC,GAAGG,SAAS;EAC1E;EAEA,MAAaC,kBAAkBA,CAAA,EAAG;IAChC,MAAMT,oCAAgB,CAACU,UAAU,CAAC,IAAI,CAACb,GAAG,CAAC;EAC7C;AACF;AAACc,OAAA,CAAAnB,OAAA,GAAAE,oBAAA","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TOKEN_ENDPOINT = exports.SCOPES = exports.REFRESH_TOKEN_RETRIES = void 0;
7
+ const SCOPES = exports.SCOPES = ['openid', 'offline_access', 'contentpass'];
8
+ const TOKEN_ENDPOINT = exports.TOKEN_ENDPOINT = `/auth/oidc/token`;
9
+ const REFRESH_TOKEN_RETRIES = exports.REFRESH_TOKEN_RETRIES = 6;
10
+ //# sourceMappingURL=oidcConsts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SCOPES","exports","TOKEN_ENDPOINT","REFRESH_TOKEN_RETRIES"],"sourceRoot":"../../../src","sources":["consts/oidcConsts.ts"],"mappings":";;;;;;AAAO,MAAMA,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG,CAAC,QAAQ,EAAE,gBAAgB,EAAE,aAAa,CAAC;AAC1D,MAAME,cAAc,GAAAD,OAAA,CAAAC,cAAA,GAAG,kBAAkB;AACzC,MAAMC,qBAAqB,GAAAF,OAAA,CAAAE,qBAAA,GAAG,CAAC","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ContentpassSdkProvider", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _ContentpassSdkProvider.ContentpassSdkProvider;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ContentpassStateType", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _ContentpassState.ContentpassStateType;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "useContentpassSdk", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _useContentpassSdk.default;
22
+ }
23
+ });
24
+ var _ContentpassState = require("./types/ContentpassState.js");
25
+ var _ContentpassSdkProvider = require("./sdkContext/ContentpassSdkProvider.js");
26
+ var _useContentpassSdk = _interopRequireDefault(require("./sdkContext/useContentpassSdk.js"));
27
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ContentpassState","require","_ContentpassSdkProvider","_useContentpassSdk","_interopRequireDefault","e","__esModule","default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAAA,iBAAA,GAAAC,OAAA;AASA,IAAAC,uBAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA8E,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.contentpassSdkContext = exports.ContentpassSdkProvider = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _Contentpass = _interopRequireDefault(require("../Contentpass.js"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ const contentpassSdkContext = exports.contentpassSdkContext = /*#__PURE__*/(0, _react.createContext)(undefined);
14
+ const ContentpassSdkProvider = ({
15
+ children,
16
+ contentpassConfig
17
+ }) => {
18
+ const [contentpassSdk, setContentpassSdk] = (0, _react.useState)();
19
+ (0, _react.useEffect)(() => {
20
+ const contentpass = new _Contentpass.default(contentpassConfig);
21
+ setContentpassSdk(contentpass);
22
+ }, [contentpassConfig]);
23
+ if (!contentpassSdk) {
24
+ return null;
25
+ }
26
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(contentpassSdkContext.Provider, {
27
+ value: contentpassSdk,
28
+ children: children
29
+ });
30
+ };
31
+ exports.ContentpassSdkProvider = ContentpassSdkProvider;
32
+ //# sourceMappingURL=ContentpassSdkProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_Contentpass","_interopRequireDefault","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","contentpassSdkContext","exports","createContext","undefined","ContentpassSdkProvider","children","contentpassConfig","contentpassSdk","setContentpassSdk","useState","useEffect","contentpass","Contentpass","jsx","Provider","value"],"sourceRoot":"../../../src","sources":["sdkContext/ContentpassSdkProvider.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAyC,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAA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sB,GAAGA,CAAC;EACrCC,QAAQ;EACRC;AAIF,CAAC,KAAK;EACJ,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAG,IAAAC,eAAQ,EAElD,CAAC;EAEH,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,WAAW,GAAG,IAAIC,oBAAW,CAACN,iBAAiB,CAAC;IAEtDE,iBAAiB,CAACG,WAAW,CAAC;EAChC,CAAC,EAAE,CAACL,iBAAiB,CAAC,CAAC;EAEvB,IAAI,CAACC,cAAc,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,oBACE,IAAA5B,WAAA,CAAAkC,GAAA,EAACb,qBAAqB,CAACc,QAAQ;IAACC,KAAK,EAAER,cAAe;IAAAF,QAAA,EACnDA;EAAQ,CACqB,CAAC;AAErC,CAAC;AAACJ,OAAA,CAAAG,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _ContentpassSdkProvider = require("./ContentpassSdkProvider.js");
9
+ const useContentpassSdk = () => {
10
+ const contentpassSdk = (0, _react.useContext)(_ContentpassSdkProvider.contentpassSdkContext);
11
+ if (!contentpassSdk) {
12
+ throw new Error('useContentpassSdk must be used within a ContentpassSdkProvider');
13
+ }
14
+ return contentpassSdk;
15
+ };
16
+ var _default = exports.default = useContentpassSdk;
17
+ //# sourceMappingURL=useContentpassSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_ContentpassSdkProvider","useContentpassSdk","contentpassSdk","useContext","contentpassSdkContext","Error","_default","exports","default"],"sourceRoot":"../../../src","sources":["sdkContext/useContentpassSdk.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AAEA,MAAME,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,MAAMC,cAAc,GAAG,IAAAC,iBAAU,EAACC,6CAAqB,CAAC;EAExD,IAAI,CAACF,cAAc,EAAE;IACnB,MAAM,IAAIG,KAAK,CACb,gEACF,CAAC;EACH;EAEA,OAAOH,cAAc;AACvB,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaP,iBAAiB","ignoreList":[]}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setSentryExtraAttribute = exports.reportError = void 0;
7
+ var Sentry = _interopRequireWildcard(require("@sentry/react-native"));
8
+ var _react = require("@sentry/react");
9
+ var _default = require("@sentry/react-native/dist/js/integrations/default");
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ // as it's only the open source package, we want to have minimal sentry configuration here to not override sentry instance,
13
+ // which can be used in the application
14
+ const options = {
15
+ attachStacktrace: true,
16
+ autoInitializeNativeSdk: false,
17
+ dsn: 'https://74ab84b55b30a3800255a25eac4d089c@sentry.tools.contentpass.dev/8',
18
+ enableAppStartTracking: false,
19
+ enableAutoPerformanceTracing: false,
20
+ enableCaptureFailedRequests: false,
21
+ enableNative: false,
22
+ enableNativeCrashHandling: false,
23
+ enableNativeFramesTracking: false,
24
+ enableNativeNagger: false,
25
+ enableNdk: false,
26
+ enableStallTracking: true,
27
+ enableUserInteractionTracing: false,
28
+ enableWatchdogTerminationTracking: false,
29
+ maxQueueSize: 30,
30
+ parentSpanIsAlwaysRootSpan: true,
31
+ patchGlobalPromise: true,
32
+ sendClientReports: true,
33
+ stackParser: _react.defaultStackParser,
34
+ transport: _react.makeFetchTransport,
35
+ integrations: []
36
+ };
37
+ const sentryClient = new Sentry.ReactNativeClient({
38
+ ...options,
39
+ integrations: (0, _default.getDefaultIntegrations)(options)
40
+ });
41
+ const sentryScope = new Sentry.Scope();
42
+ sentryScope.setClient(sentryClient);
43
+ sentryClient.init();
44
+ const reportError = (err, {
45
+ msg
46
+ } = {}) => {
47
+ if (msg) {
48
+ sentryScope.addBreadcrumb({
49
+ category: 'Error',
50
+ message: msg,
51
+ level: 'log'
52
+ });
53
+ }
54
+ sentryScope.captureException(err);
55
+ };
56
+ exports.reportError = reportError;
57
+ const setSentryExtraAttribute = (key, value) => {
58
+ sentryScope.setExtra(key, value);
59
+ };
60
+ exports.setSentryExtraAttribute = setSentryExtraAttribute;
61
+ //# sourceMappingURL=sentryIntegration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Sentry","_interopRequireWildcard","require","_react","_default","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","options","attachStacktrace","autoInitializeNativeSdk","dsn","enableAppStartTracking","enableAutoPerformanceTracing","enableCaptureFailedRequests","enableNative","enableNativeCrashHandling","enableNativeFramesTracking","enableNativeNagger","enableNdk","enableStallTracking","enableUserInteractionTracing","enableWatchdogTerminationTracking","maxQueueSize","parentSpanIsAlwaysRootSpan","patchGlobalPromise","sendClientReports","stackParser","defaultStackParser","transport","makeFetchTransport","integrations","sentryClient","ReactNativeClient","getDefaultIntegrations","sentryScope","Scope","setClient","init","reportError","err","msg","addBreadcrumb","category","message","level","captureException","exports","setSentryExtraAttribute","key","value","setExtra"],"sourceRoot":"../../src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AA,WAAA;AAEK,MAAMS,uBAAuB,GAAGA,CAACC,GAAW,EAAEC,KAAa,KAAK;EACrEf,WAAW,CAACgB,QAAQ,CAACF,GAAG,EAAEC,KAAK,CAAC;AAClC,CAAC;AAACH,OAAA,CAAAC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=ContentpassConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/ContentpassConfig.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ContentpassStateType = void 0;
7
+ /* istanbul ignore file */
8
+ let ContentpassStateType = exports.ContentpassStateType = /*#__PURE__*/function (ContentpassStateType) {
9
+ ContentpassStateType["INITIALISING"] = "INITIALISING";
10
+ ContentpassStateType["UNAUTHENTICATED"] = "UNAUTHENTICATED";
11
+ ContentpassStateType["AUTHENTICATED"] = "AUTHENTICATED";
12
+ ContentpassStateType["ERROR"] = "ERROR";
13
+ return ContentpassStateType;
14
+ }({});
15
+ //# sourceMappingURL=ContentpassState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ContentpassStateType","exports"],"sourceRoot":"../../../src","sources":["types/ContentpassState.ts"],"mappings":";;;;;;AAAA;AAAA,IAEYA,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RefreshTokenStrategy = void 0;
7
+ /* istanbul ignore file */
8
+ let RefreshTokenStrategy = exports.RefreshTokenStrategy = /*#__PURE__*/function (RefreshTokenStrategy) {
9
+ RefreshTokenStrategy["INSTANTLY"] = "INSTANTLY";
10
+ RefreshTokenStrategy["TIMER_SET"] = "TIMER_SET";
11
+ RefreshTokenStrategy["NO_REFRESH"] = "NO_REFRESH";
12
+ return RefreshTokenStrategy;
13
+ }({});
14
+ //# sourceMappingURL=RefreshTokenStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["RefreshTokenStrategy","exports"],"sourceRoot":"../../../src","sources":["types/RefreshTokenStrategy.ts"],"mappings":";;;;;;AAAA;AAAA,IAEYA,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}