@superfan-app/spotify-auth 0.1.69 → 0.1.70

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.
@@ -85,10 +85,11 @@ def resolvedKotlinVersion() {
85
85
  dependencies {
86
86
  implementation project(':expo-modules-core')
87
87
 
88
- // Spotify Auth Library (local .aar)
89
- implementation files('Frameworks/spotify-auth-release-2.1.0.aar')
88
+ // Spotify Auth Library - per Spotify docs: https://developer.spotify.com/documentation/android/tutorials/authorization
89
+ // 3.1.0: Kotlin, 3.0.0: mandatory redirectPathPattern, 2.2.0: PKCE support
90
+ implementation 'com.spotify.android:auth:3.1.0'
90
91
 
91
- // Required for Spotify Auth Library's browser-based fallback
92
+ // Required for Spotify Auth Library's Custom Tabs / browser fallback
92
93
  implementation 'androidx.browser:browser:1.8.0'
93
94
  implementation 'androidx.appcompat:appcompat:1.7.0'
94
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superfan-app/spotify-auth",
3
- "version": "0.1.69",
3
+ "version": "0.1.70",
4
4
  "description": "Spotify OAuth module for Expo",
5
5
  "main": "src/index.tsx",
6
6
  "types": "build/index.d.ts",
@@ -67,6 +67,43 @@ const withSpotifyConfiguration = (config, props) => {
67
67
  });
68
68
  };
69
69
  // region Android config plugins
70
+ /**
71
+ * Injects manifestPlaceholders into the app's build.gradle.
72
+ * Spotify auth lib 3.0.0+ requires redirectSchemeName, redirectHostName, and redirectPathPattern.
73
+ * See: https://github.com/spotify/android-auth
74
+ */
75
+ const withSpotifyManifestPlaceholders = (config, props) => {
76
+ return (0, config_plugins_1.withAppBuildGradle)(config, (config) => {
77
+ let buildGradle = config.modResults.contents;
78
+ // Escape values for Gradle string literals (escape backslashes and quotes)
79
+ const scheme = String(props.scheme).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
80
+ const host = String(props.callback).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
81
+ // ".*" accepts any path - retains previous behavior per Spotify changelog (auth lib 3.0.0)
82
+ const pathPattern = '.*';
83
+ const placeholdersBlock = ` manifestPlaceholders = [
84
+ redirectSchemeName: "${scheme}",
85
+ redirectHostName: "${host}",
86
+ redirectPathPattern: "${pathPattern}"
87
+ ]`;
88
+ // Already has all three placeholders (auth lib 3.0.0+ compliant)
89
+ if (buildGradle.includes('redirectPathPattern')) {
90
+ return config;
91
+ }
92
+ // Upgrade: have scheme/host but missing redirectPathPattern (auth lib 3.0.0 breaking change)
93
+ if (buildGradle.includes('redirectSchemeName') && buildGradle.includes('redirectHostName')) {
94
+ buildGradle = buildGradle.replace(/(redirectHostName:\s*"[^"]*")(\s*\n\s*\])/, `$1,\n redirectPathPattern: "${pathPattern}"$2`);
95
+ config.modResults.contents = buildGradle;
96
+ return config;
97
+ }
98
+ // Add manifestPlaceholders to defaultConfig block.
99
+ const defaultConfigRegex = /(defaultConfig\s*\{)/;
100
+ if (defaultConfigRegex.test(buildGradle)) {
101
+ buildGradle = buildGradle.replace(defaultConfigRegex, `$1\n${placeholdersBlock}`);
102
+ }
103
+ config.modResults.contents = buildGradle;
104
+ return config;
105
+ });
106
+ };
70
107
  const withSpotifyAndroidManifest = (config, props) => {
71
108
  return (0, config_plugins_1.withAndroidManifest)(config, (config) => {
72
109
  const mainApplication = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
@@ -132,6 +169,7 @@ const withSpotifyAuth = (config, props) => {
132
169
  config = withSpotifyConfiguration(config, props);
133
170
  config = withSpotifyURLSchemes(config, props);
134
171
  // Apply Android configurations
172
+ config = withSpotifyManifestPlaceholders(config, props);
135
173
  config = withSpotifyAndroidManifest(config, props);
136
174
  return config;
137
175
  };
@@ -1,6 +1,6 @@
1
1
  // plugin/src/index.ts
2
2
 
3
- import { type ConfigPlugin, createRunOncePlugin, withInfoPlist, withAndroidManifest, AndroidConfig } from '@expo/config-plugins'
3
+ import { type ConfigPlugin, createRunOncePlugin, withInfoPlist, withAndroidManifest, withAppBuildGradle, AndroidConfig } from '@expo/config-plugins'
4
4
  import { SpotifyConfig } from './types.js'
5
5
 
6
6
  const pkg = require('../../package.json');
@@ -75,6 +75,56 @@ const withSpotifyConfiguration: ConfigPlugin<SpotifyConfig> = (config, props) =>
75
75
 
76
76
  // region Android config plugins
77
77
 
78
+ /**
79
+ * Injects manifestPlaceholders into the app's build.gradle.
80
+ * Spotify auth lib 3.0.0+ requires redirectSchemeName, redirectHostName, and redirectPathPattern.
81
+ * See: https://github.com/spotify/android-auth
82
+ */
83
+ const withSpotifyManifestPlaceholders: ConfigPlugin<SpotifyConfig> = (config, props) => {
84
+ return withAppBuildGradle(config, (config) => {
85
+ let buildGradle = config.modResults.contents;
86
+
87
+ // Escape values for Gradle string literals (escape backslashes and quotes)
88
+ const scheme = String(props.scheme).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
89
+ const host = String(props.callback).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
90
+ // ".*" accepts any path - retains previous behavior per Spotify changelog (auth lib 3.0.0)
91
+ const pathPattern = '.*';
92
+
93
+ const placeholdersBlock = ` manifestPlaceholders = [
94
+ redirectSchemeName: "${scheme}",
95
+ redirectHostName: "${host}",
96
+ redirectPathPattern: "${pathPattern}"
97
+ ]`;
98
+
99
+ // Already has all three placeholders (auth lib 3.0.0+ compliant)
100
+ if (buildGradle.includes('redirectPathPattern')) {
101
+ return config;
102
+ }
103
+
104
+ // Upgrade: have scheme/host but missing redirectPathPattern (auth lib 3.0.0 breaking change)
105
+ if (buildGradle.includes('redirectSchemeName') && buildGradle.includes('redirectHostName')) {
106
+ buildGradle = buildGradle.replace(
107
+ /(redirectHostName:\s*"[^"]*")(\s*\n\s*\])/,
108
+ `$1,\n redirectPathPattern: "${pathPattern}"$2`
109
+ );
110
+ config.modResults.contents = buildGradle;
111
+ return config;
112
+ }
113
+
114
+ // Add manifestPlaceholders to defaultConfig block.
115
+ const defaultConfigRegex = /(defaultConfig\s*\{)/;
116
+ if (defaultConfigRegex.test(buildGradle)) {
117
+ buildGradle = buildGradle.replace(
118
+ defaultConfigRegex,
119
+ `$1\n${placeholdersBlock}`
120
+ );
121
+ }
122
+
123
+ config.modResults.contents = buildGradle;
124
+ return config;
125
+ });
126
+ };
127
+
78
128
  const withSpotifyAndroidManifest: ConfigPlugin<SpotifyConfig> = (config, props) => {
79
129
  return withAndroidManifest(config, (config) => {
80
130
  const mainApplication = AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
@@ -163,6 +213,7 @@ const withSpotifyAuth: ConfigPlugin<SpotifyConfig> = (config, props) => {
163
213
  config = withSpotifyURLSchemes(config, props);
164
214
 
165
215
  // Apply Android configurations
216
+ config = withSpotifyManifestPlaceholders(config, props);
166
217
  config = withSpotifyAndroidManifest(config, props);
167
218
 
168
219
  return config;