vaenow / cordova-plugin-app-update

App updater for Cordova/PhoneGap
MIT License
299 stars 146 forks source link

Add Basic Auth option #62

Closed arthursp closed 6 years ago

arthursp commented 6 years ago

Add an option to use basic auth for config.xml and apk URI.

usage :

appUpdate.checkAppUpdate(onSuccess, onFail, updateUrl, {
    'authType' : 'basic',
    'username' : 'test',
    'password' : 'test'
})

Also need to update IONIC native wrapper ( work in progress )

vaenow commented 6 years ago

Hi @arthursp , If the Auth merged, what should the server side do?

arthursp commented 6 years ago

Hi @vaenow,

on the server side, just need to add basic auth.

I tested with a simple htaccess and htpasswd with an apache server :

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /var/www/apkmanager/.htpasswd
Require valid-user

and the htpasswd :

test:$apr1$XQ6wTvJB$rgTrtnB06BGyI3JXJlFjE.

test:test as user:password

arthursp commented 6 years ago

For the ionic native plugin ( in case of ) :

export class AppUpdate extends IonicNativePlugin {
  /**
   * Check and update
   * @param updateUrl {string} update api url
   * @param options {json} options object
   * @return {Promise<any>} Returns a promise that resolves when something happens
   */
  @Cordova({
    callbackOrder: 'reverse'
  })
  checkAppUpdate(updateUrl: string, options?: any): Promise<any> { return; }
}
johnhtet691 commented 6 years ago

I want to do like the following but i can't because appUpdate.checkAppUpdate in my code have one parameter.What do i need to do?please someone answer me........

appUpdate.checkAppUpdate(onSuccess, onFail, updateUrl, { 'authType' : 'basic', 'username' : 'test', 'password' : 'test' })

arthursp commented 6 years ago

@johnhtet691

in the ionic native plugin :


export class AppUpdate extends IonicNativePlugin {
  /**
   * Check and update
   * @param updateUrl {string} update api url
   * @param options {json} options object
   * @return {Promise<any>} Returns a promise that resolves when something happens
   */
  @Cordova({
    callbackOrder: 'reverse'
  })
  checkAppUpdate(updateUrl: string, options?: any): Promise<any> { return; }
}
johnhtet691 commented 6 years ago

Thank you for replying.You mean that you want to change AppUpdate class(index.d.ts) in my code situated node-modules as showing you.But I change the code as you show, I got the error like this 'An Implementation cannot be declared in ambient contexts ". I think that i need to do something .Please show the way. :) :)

My original code is the following like that.

export declare class AppUpdate extends IonicNativePlugin { /**

arthursp commented 6 years ago

in /node_modules/@ionic-native/app-update/index.d.ts

Which version of typescript do you have ?

You may use : npm install --save typescript@latest

TizioFittizio commented 6 years ago

This hasn't been included in the ionic native plugin yet?

arthursp commented 6 years ago

Nope, not yet :S

danielsogl commented 6 years ago

Hey all, I created a PR to add this feature. Wait for our next release