@bubblewrap/core 1.16.0 → 1.17.2

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.
@@ -222,7 +222,7 @@ class TwaGenerator {
222
222
  `Responded with status ${response.status}`);
223
223
  }
224
224
  // We're writing as a string, but attempt to convert to check if it's a well-formed JSON.
225
- const webManifestJson = await response.json();
225
+ const webManifestJson = JSON.parse((await response.text()).trim());
226
226
  // We want to ensure that "start_url" is the same used to launch the Trusted Web Activity.
227
227
  webManifestJson['start_url'] = twaManifest.startUrl;
228
228
  const webManifestLocation = path.join(targetDirectory, WEB_MANIFEST_LOCATION);
@@ -273,7 +273,7 @@ class TwaManifest {
273
273
  */
274
274
  static async fromWebManifest(url) {
275
275
  const response = await FetchUtils_1.fetchUtils.fetch(url);
276
- const webManifest = await response.json();
276
+ const webManifest = JSON.parse((await response.text()).trim());
277
277
  const webManifestUrl = new URL(url);
278
278
  return TwaManifest.fromWebManifestJson(webManifestUrl, webManifest);
279
279
  }
@@ -20,7 +20,7 @@ const EmptyFeature_1 = require("./EmptyFeature");
20
20
  class PlayBillingFeature extends EmptyFeature_1.EmptyFeature {
21
21
  constructor() {
22
22
  super('playbilling');
23
- this.buildGradle.dependencies.push('com.google.androidbrowserhelper:billing:1.0.0-alpha08');
23
+ this.buildGradle.dependencies.push('com.google.androidbrowserhelper:billing:1.0.0-alpha09');
24
24
  this.androidManifest.components.push(`
25
25
  <activity
26
26
  android:name="com.google.androidbrowserhelper.playbilling.provider.PaymentActivity"
package/dist/lib/util.js CHANGED
@@ -30,6 +30,16 @@ const extractZipPromise = util_1.promisify(extractZip);
30
30
  // https://developer.android.com/guide/topics/manifest/manifest-element.html#package
31
31
  const DISALLOWED_ANDROID_PACKAGE_CHARS_REGEX = /[^a-zA-Z0-9_\.]/g;
32
32
  const VALID_PACKAGE_ID_SEGMENT_REGEX = /^[a-zA-Z][A-Za-z0-9_]*$/;
33
+ // List of keywords for Java 11, as listed at
34
+ // https://docs.oracle.com/javase/specs/jls/se11/html/jls-3.html#jls-3.9.
35
+ const JAVA_KEYWORDS = [
36
+ 'abstract', 'assert', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', 'const',
37
+ 'continue', 'default', 'do', 'double', 'else', 'enum', 'extends', 'final', 'finally', 'float',
38
+ 'for', 'goto', 'if', 'implements', 'import', 'instanceof', 'int', 'interface', 'long', 'native',
39
+ 'new', 'package', 'private', 'protected', 'public', 'return', 'short', 'static', 'strictfp',
40
+ 'super', 'switch', 'synchronized', 'this', 'throw', 'throws', 'transient', 'try', 'void',
41
+ 'volatile', 'while',
42
+ ];
33
43
  async function execute(cmd, env, log) {
34
44
  const joinedCmd = cmd.join(' ');
35
45
  if (log) {
@@ -132,6 +142,12 @@ function generatePackageId(host) {
132
142
  if (part.trim().length === 0) {
133
143
  continue;
134
144
  }
145
+ // Package names cannot contain Java keywords. The recommendation is adding an '_' before the
146
+ // keyword. See https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html.
147
+ if (JAVA_KEYWORDS.includes(part)) {
148
+ packageId.push('_' + part);
149
+ continue;
150
+ }
135
151
  packageId.push(part);
136
152
  }
137
153
  if (packageId.length === 0) {
@@ -176,6 +192,12 @@ function validatePackageId(input) {
176
192
  return 'packageId must have at least 2 sections separated by "."';
177
193
  }
178
194
  for (const part of parts) {
195
+ // Package names cannot contain Java keywords. The recommendation is adding an '_' before the
196
+ // keyword. See https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html.
197
+ if (JAVA_KEYWORDS.includes(part)) {
198
+ return `Invalid packageId section: "${part}". ${part} is a Java keyword and cannot be used` +
199
+ 'as a package section. Consider adding an "_" before the section name.';
200
+ }
179
201
  if (part.match(VALID_PACKAGE_ID_SEGMENT_REGEX) === null) {
180
202
  return `Invalid packageId section: "${part}". Only alphanumeric characters and ` +
181
203
  'underscore [a-zA-Z0-9_] are allowed in packageId sections. Each section must ' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bubblewrap/core",
3
- "version": "1.16.0",
3
+ "version": "1.17.2",
4
4
  "description": "Core Library to generate, build and sign TWA projects",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -56,5 +56,5 @@
56
56
  "optionalDependencies": {
57
57
  "svg2img": "^0.9.3"
58
58
  },
59
- "gitHead": "8936e332adbbc33b3a5d398cce14947cd6c290d5"
59
+ "gitHead": "1ec4b63a154ef41ebc8052abf2f7fc94bd61f11e"
60
60
  }
@@ -77,7 +77,7 @@ android {
77
77
 
78
78
  <% if (shareTarget) { %>
79
79
  // The data for the app to support web share target.
80
- resValue "string", "shareTarget", '<%= escapeJsonString(JSON.stringify(shareTarget)) %>'
80
+ resValue "string", "shareTarget", '<%= escapeJsonString(escapeGradleString(JSON.stringify(shareTarget))) %>'
81
81
  <% } %>
82
82
 
83
83
  // The hostname is used when building the intent-filter, so the TWA is able to