Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG Defining cryptfiles.include encrypts files but does not decrypt them #20

Open
sc0ttdav3y opened this issue Oct 4, 2021 · 1 comment · May be fixed by #21
Open

BUG Defining cryptfiles.include encrypts files but does not decrypt them #20

sc0ttdav3y opened this issue Oct 4, 2021 · 1 comment · May be fixed by #21
Assignees
Labels
bug Something isn't working

Comments

@sc0ttdav3y
Copy link

sc0ttdav3y commented Oct 4, 2021

Describe the bug

Following the README, I've added the following to plugin.xml so I can support json files being encrypted.

    <cryptfiles>
        <include>
            <file regex="\.(htm|html|js|css|json)$" />
        </include>
        <exclude>
        </exclude>
    </cryptfiles>

During build-time I see the files here are encrypted, but at run-time they are not decrypted. The reason is the DecryptResource.java class is not getting updated with the file regex, and it still has the default list:

  private static final String[] CRYPT_FILES = {
    ".htm",
    ".html",
    ".js",
    ".css",
  };

I see code in after_prepare.js that intends to change the class, but it is targeting INCLUDE_FILES and EXCLUDE_FILES properties in the Java source, rather than CRYPT_FILES which is in the source here:

private static final String[] CRYPT_FILES = {
.

My workaround is to manually edit the Java class to add the extension.

To Reproduce

Steps to reproduce the behavior:

  1. add a custom extension into plugin.xml as above
  2. compile an app that requires a file of that type

Expected behavior

The app should decrypt the read when it is called.

Additional information

I notice that the original plugin cordova-plugin-crypt-file does have INCLUDE_FILES and EXCLUDE_FILES, so it's possibly just a back-porting issue:

https://github.com/tkyaji/cordova-plugin-crypt-file/blob/ddee9dfcbf082c417a41b8480f7a9d2b7884ed87/src/android/com/tkyaji/cordova/DecryptResource.java#L29

@sc0ttdav3y sc0ttdav3y added the bug Something isn't working label Oct 4, 2021
@sc0ttdav3y sc0ttdav3y linked a pull request Oct 4, 2021 that will close this issue
@sc0ttdav3y
Copy link
Author

Here's a PR that fixes this: #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants