Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hmscore/cordova-plugin-hms-account

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hmscore/cordova-plugin-hms-account

Cordova HMS Account Kit

  • 5.0.1-301
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

CORDOVA PLUGIN HMS ACCOUNT

  1. Introduction

  2. Installation Guide

  3. Cordova SDK API Method Definition

  4. Configure Description

  5. Licensing and Terms

1. Introduction

The Cordova SDK code encapsulates the Huawei Account Kit interface. It provides many APIs for your reference or use.

The Cordova SDK code package is described as follows:

src/main/java/com/huawei/hms/cordova/account: Core layer that exposes AccountSDK functionality to JS side.

www: Public interfaces for interacting AccountSDK through Cordova.

2. Installation Guide

Cordova

  1. Download the Cordova Account SDK Plugin.

  2. Add Platform To Project.

    cordova platform add android

  3. You can either install the plugin thorough npm or by downloading from downloads page, Cordova Account Plugin.

    a. Run the following command in the root directory of your Cordova project to install it through npm.
    cordova plugin add @hms-core/cordova-plugin-hms-account
    b. Run the following command in the root directory of your Cordova project to install it manually after downloading the plugin.
    cordova plugin add <CORDOVA_ACCOUNT_PLUGIN_PATH>

  4. Check whether the Cordova Account SDK is successfully added to Plugin folder in the root directory of the Cordova project.

  5. Add agconnect-services.json and jks file to root directory.

  6. Add build.json file to your project's root.

  7. Then run the Cordova app.

    cordova run android

Ionic

  1. Download the Cordova Account Plugin through npm or by downloading from downloads page, Cordova Account Plugin.

    a. Run the following command in the root directory of your Cordova project to install it through npm.

    npm install @hmscore/cordova-plugin-hms-account

    b. Run the following command in the root directory of your Cordova project to install it manually after downloading the plugin.

    npm install <CORDOVA_ACCOUNT_PLUGIN_PATH>

  2. Check whether the Cordova Account SDK is successfully added to the node_modules directory.

  3. If you want full Ionic support with code completion etc, install"@ionic-native/core" in your project.

    npm install @ionic-native/core --save

  4. Copy the "ionic/dist/hms-account" folder from library to "node_modules/@ionic-native" folder under your Ionic project.

  5. Compile ionic project.

    a. ionic build

    b. npx cap init [appName] [appId]

    NOTE
    where appName is the name of your app, and appId is package_name in your agconnect-services.json file (ex: com.example.app).

  6. Add a native platform to your project.

    ionic capacitor add android

  7. Make sure your project has a build.gradle file with a maven repository address and Account service dependencies.

  8. Add agconnect-services.json and jks file to the app directory in your Android project.

  9. To update dependencies, and copy any web assets to your project, add following code.

    npx capacitor sync

  10. Then run the Ionic app.

    ionic capacitor run android

3. Cordova SDK API Method And Constant Definition

Module Overview

ModuleDefinition
CommonTypesA module for providing common data types and constants.
HMSAccountA module for interacting with the Huawei Sign In API.
HMSHuaweiIdAuthManagerA module is used to entry point for the Huawei Sign In API.
HMSHuaweiIdAuthToolA module for obtaining and clearing authorization information.
HMSNetworkToolA module is used to construct a cookie and a url with specific parameters.
HMSReadSMSManagerA module for Huawei ID SMS Service.
HMSHuaweiIdAuthButtonA module is used to processing the the visual elements of the button for sign in.

HMSAccount

Functions
Return TypeMethodsDefinition
Promise<AuthHuaweiId>signInThis API is called to sign in to the apps with HUAWEI IDs securely.
Promise<void>signOutThis API is called to sign out of a HUAWEI ID from an app.
Promise<void>cancelAuthorizationThis API is called to cancel HUAWEI sign-in authorization.
Promise<AuthHuaweiId>silentSignInThis API is called to silent authorization. The API will not display the related page.
signIn (scope, param, scopeList)

This API is called for HUAWEI sign-in.

ParameterTypeDescription
scopeScopeConstants[]ScopeConstants array to customize the authorization.
paramHuaweiIdAuthParamsAuthorization scope parameter to customize the authorization.
scopeListScopeURI[]ScopeURI array to customize the authorization. If this value not passed to API, an empty array will be send.

ReturnDescription
Promise<AuthHuaweiId>If the operation is successful, promise resolves to a AuthHuaweiId object. Otherwise it throws an error.
signOut()

This API is called to sign out of a HUAWEI ID from an app. After sign-out, the HMS SDK deletes the cached HUAWEI ID information.

ReturnDescription
Promise<void>If the operation is successful, promise will resolve successfully. Otherwise it throws an error.
cancelAuthorization()

This API is called to cancel HUAWEI sign-in authorization.

ReturnDescription
Promise<void>If the operation is successful, promise will resolve successfully. Otherwise it throws an error.
silentSignIn()

This API is called to return the information (or error information) about the HUAWEI ID used by a user who has signed in to an app. During this process, no user page will be displayed to the HUAWEI ID user.

ReturnDescription
Promise<AuthHuaweiId>If the operation is successful, promise resolves to a AuthHuaweiId object. Otherwise it throws an error.

HMSHuaweiIdAuthManager

Functions
Return TypeMethodsDefinition
Promise<void>addAuthScopesThis API is called to request the permission specified by scopeList from a HUAWEI ID.
Promise<ContainScopesResult>containScopesThis API is called to check whether the user with the designated HUAWEI ID has been assigned all permissions specified by scopeList.
Promise<AuthHuaweiId>getAuthResultWithScopeThis API is called to obtain the AuthHuaweiId instance.
Promise<AuthHuaweiId>getAuthResultThis API is called to obtain the latest authorization information.
addAuthScopes(requestCode, scopeList)

This API is called to request the permission specified by scopeList from a HUAWEI ID.

ParameterTypeDescription
requestCodeIntegerRequest Id.
scopeListScopeURI[]Authorization scope list.

Return TypeDescription
Promise<void>If the operation is successful, promise will resolve successfully. Otherwise it throws an error.
containScopes(authHuaweiId, scopeList)

This API is called to checks whether the designated HUAWEI ID has been assigned all permissions specified by scopeList.

ParameterTypeDescription
authHuaweiIdAuthHuaweiIdBuilderAuthorized HUAWEI ID information.
scopeListScopeURI[]Authorization scope list.

ReturnDescription
Promise<ContainScopesResult>If the operation is successful, promise resolves to an object that contains boolean result, like {"containScopes": false }. Otherwise it throws an error.
getAuthResultWithScope(scopeList)

This API is called to obtain the AuthHuaweiId.

ParameterTypeDescription
scopeListScopeList[]Authorization scope list.

ReturnDescription
Promise<AuthHuaweiId>If the operation is successful, promise resolves to a AuthHuaweiId object. Otherwise it throws an error.
getAuthResult()

This API is called to obtain information about the HUAWEI ID used for the previous sign-in and authorization.

ReturnDescription
Promise<AuthHuaweiId>If the operation is successful, promise resolves to a AuthHuaweiId object. Otherwise it throws an error.

HMSHuaweiIdAuthTool

Functions
Return TypeMethodsDefinition
Promise<String>requestUnionIdThis API is called to obtain a unionId.
Promise<String>requestAccessTokenThis API is called to obtain a token.
Promise<void>deleteAuthInfoThis API is called to clear the local cache.
requestUnionId(huaweiAccountName)

Obtains a unionId.

ParameterTypeDescription
huaweiAccountNameStringHUAWEI ID Name.

ReturnDescription
Promise<String>If the operation is successful, promise resolves to a String that contains union id. Otherwise it throws an error.
requestAccessToken(account, scopeList)

Obtains a token.

ParameterTypeDescription
accountAccountHUAWEI ID for which you need to obtain a token. It contains name and type properties.
scopeListScopeURI[]HUAWEI ID authorization scope.

ReturnDescription
Promise<String>If the operation is successful, promise resolves to a String that contains a access token. Otherwise it throws an error.
deleteAuthInfo(accessToken)

Clears the local cache.

ParameterTypeDescription
accessTokenStringToken to be clear.

ReturnDescription
Promise<void>If the operation is successful, promise will resolve successfully. Otherwise it throws an error.

HMSNetworkTool

Functions
Return TypeMethodsDefinition
Promise<String>buildNetworkCookieThis API is called to construct a cookie by combining input values.
Promise<String>buildNetworkURLThis API is called to cookie url based on the domain name and isUseHttps.
buildNetworkCookie(cookie)

Constructs a cookie by combining input values.

ParameterTypeDescription
cookieCookieIt is an object that contains cookieName, cookieValue, domain, path, isHttpOnly, isSecure, maxAge.

ReturnDescription
Promise<String>If the operation is successful, promise resolves to a String that contains a cookie. Otherwise it throws an error.
buildNetworkURL(domainInfo)

Returns cookie url based on the domain name and isUseHttps.

ParameterTypeDescription
domainInfoDomainInfoThe parameter that contains a domain name and isUseHttps info.

ReturnDescription
Promise<String>If the operation is successful, promise resolves to a String that contains a cookie url. Otherwise it throws an error.

HMSReadSMSManager

Functions
Return TypeMethodsDefinition
Promise<String>smsVerificationCodeThis API is called to enable the service of reading SMS messages until the SMS messages that meet the rules (Timeout five minutes).
Promise<String>obtainHashCodeThis API is called to obtain hash code.
smsVerificationCode()

With this function,app can automatically retrieve SMS verification codes without requesting the permission of reading SMS messages. In case of get SMS Message, returned the SMS Message.

ReturnDescription
Promise<String>If the operation is successful, promise resolves to a String that contains a content of SMS. Otherwise it throws an error.
obtainHashCode()

Obtains hash code which indicates the hash value generated by the HMS SDK based on app package name to uniquely identify app.

ReturnDescription
Promise<String>If the operation is successful, promise resolves to a String that contains a hash value. Otherwise it throws an error.

HMSHuaweiIdAuthButton

Functions
Return TypeMethodsDefinition
voidgetHuaweiIdAuthButtonThis API is called to creating a specific button for login.
getHuaweiIdAuthButton(buttonId, theme, colorPolicy, cornerRadius)

Authenticates user identities. Note that this class only processes the the visual elements of the button.

ParameterTypeDescription
buttonIdStringId of div that is used for HuaweiIdAuthButton.
themeThemeButton theme
colorPolicyColorPolicyValues indicates button colors
cornerRadiusCornerRadiusValues indicates button corner types

Constants

NameDefinition
CommonTypes.ScopeConstantsProvides scopes to request a Huawei ID user.
CommonTypes.HuaweiIdAuthParamsProvides default HuaweiID authorization parameters.
CommonTypes.ScopeURIProvides authorization scopes.
CommonTypes.GenderProvides gender information.
HMSHuaweiIdAuthButton.ThemeProvides themes to set theme of the button.
HMSHuaweiIdAuthButton.ColorPolicyProvides colors to set color of the button.
HMSHuaweiIdAuthButton.CornerRadiusProvides corner radiueses to set corner radius size of the button.
ScopeConstants
Constant FieldsValueDefinition
SCOPE_PROFILE"profile"Requests a HUAWEI ID user to authorize profile information to an app.
SCOPE_ID_TOKEN"idToken"Requests a HUAWEI ID user to authorize ID token to an app.
SCOPE_ACCESS_TOKEN"accessToken"Requests a HUAWEI ID user to authorize access token to an app.
SCOPE_MOBILE_NUMBER"mobileNumber"Requests a HUAWEI ID user to authorize mobile number to an app.
SCOPE_EMAIL"email"Requests a HUAWEI ID user to authorize email address to an app.
SCOPE_SHIPPING_ADDRESS"shippingAddress"Requests a HUAWEI ID user to authorize shipping address to an app.
SCOPE_UID"uid"Requests a HUAWEI ID user to authorize uid token to an app.
SCOPE_ID"id"Requests a HUAWEI ID user to authorize ID to an app.
SCOPE_AUTHORIZATION_CODE"authorizationCode"Requests a HUAWEI ID user to authorize authorization code to an app.
HuaweiIdAuthParams
Constant FieldsValueDefinition
DEFAULT_AUTH_REQUEST_PARAM"param"Exposes HuaweiIdAuthParam.DEFAULT_AUTH_REQUEST_PARAM. Default authorization parameter of an AppTouch ID.
DEFAULT_AUTH_REQUEST_PARAM_GAME"game"Exposes HuaweiIdAuthParam.DEFAULT_AUTH_REQUEST_PARAM_GAME. Default authorization parameter of a game.
ScopeURI
Constant FieldsValueDefinition
GAME"https://www.huawei.com/auth/games"Value to specify game scope.
OPENID"openid"Value to specify openid scope.
EMAIL"email"Value to specify email scope.
PROFILE"profile"Value to specify profile scope.
Gender
Constant FieldsValueDefinition
UNKNOWN-1Unkown
MALE0Male
FEMALE1Female
CONFIDENTIAL2Confidential
Theme
Constant FieldsValueDefinition
THEME_NO_TITLE0Button without any title.
THEME_FULL_TITLE1Button with an icon and a title.
ColorPolicy
Constant FieldsValueDefinition
COLOR_POLICY_BLUE0Blue button.
COLOR_POLICY_RED1Red button.
COLOR_POLICY_WHITE2White button.
COLOR_POLICY_WHITE_WITH_BORDER3White button with strokes.
COLOR_POLICY_BLACK4Black button.
COLOR_POLICY_GRAY5Gray button.
CornerRadius
Constant FieldsValueDefinition
CORNER_RADIUS_LARGE-1Button with large rounded corners.
CORNER_RADIUS_MEDIUM-2Button with medium-sized rounded corners.
CORNER_RADIUS_SMALL-3Button with small rounded corners

Data Types

AuthHuaweiIdBuilder
Field NameTypeDescription
openIdStringopenId.
uidStringuid.
displayNameStringNickname.
photoUrlStringObtains the picture url.
accessTokenStringAccess token.
serviceCountryCodeStringService country code.
statusIntegerUser status. 1: Normal; 2: Dbank suspended; 3: Deregistered, 4: All services are suspended.
genderGenderUser Gender.
scopesScopeURI[]Authorized scopes.
serverAuthCodeStringserverAuthCode.
unionIdStringunionId.
countryCodeStringRegistration country code.
AuthHuaweiId
FieldTypeDescription
accessTokenStringAccess token.
displayNameStringNickname.
emailStringEmail adress.
familyNameStringFamily name.
givenNameStringGiven name.
idTokenStringID Token
unionIdStringunionId
avatarUriStringStringProfile picture URI
expressionTimeSecsNumberexpressionTimeSecs
openIdStringopenId
uidStringuid
countryCodeStringRegistration country code.
serviceCountryCodeStringService country code.
statusNumberUser status. 1: Normal; 2: Dbank suspended; 3: Deregistered, 4: All services are suspended.
genderGenderUser Gender.
describeContentsInAuthHuaweiIdNumberdescribeContentsInAuthHuaweiId
authorizedScopesString[]Authorized Scopes
extensionScopesString[]extensionScopes
authorizationCodeStringauthorizationCode
huaweiAccountAccounthuaweiAccount
Account
Field NameTypeDescription
typeStringType of HUAWEI ID Account.
nameStringName of the HUAWEI ID Account.
Field NameTypeDescription
cookieNameStringCookie name.
cookieValueStringCookie value.
domainStringCookie domain name.
pathStringPage path for accessing the cookie.
isHttpOnlyBooleanValue true indicates that the cookie information is contained only in the HTTP request header and cannot be accessed through document.cookie.
isSecureBooleanValue true indicates that the cookie can be transmitted only through HTTPS, and value false indicates that the cookie can be transmitted through HTTP.
maxAgeLongCookie lifetime, in seconds.
DomainInfo
Field NameTypeDescription
domainStringDomain name.
isUseHttpsBooleanValue true indicates HTTPS, and value false indicates HTTP.
ContainScopesResult
Field NameTypeDescription
containScopesBooleantrue: The HUAWEI ID has all the permissions specified by scopeArr. false: The HUAWEI ID does not have all the permissions specified by scopeArr.

4. Configure Description

No.

5. Licensing and Terms

Apache 2.0 license.

Keywords

FAQs

Package last updated on 07 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc