1.5.4-alpha.22 • Published 3 months ago

@portkey-v1/did v1.5.4-alpha.22

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

ES Version Node Version NPM Package Version

Prerequisites

Package.json Scripts

ScriptDescription
cleanUses rm to remove dist/
buildUses tsc to build package and dependent packages
lintUses eslint to lint package
lint:fixUses eslint to check and fix any warnings
formatUses prettier to format the code

Getting Started

The @portkey-v1/did library is a collection of modules that contain functionality for the did ecosystem.

  • @portkey-v1/accounts is for the portkey account.
  • @portkey-v1/utils is for the portkey utils.
  • @portkey-v1/contracts is for the portkey contracts.
  • @portkey-v1/graphql is for the portkey graphql.
  • @portkey-v1/request is for the portkey request.
  • @portkey-v1/types is for the portkey types.
  • @portkey-v1/utils is for the portkey utils.
  • @portkey-v1/validator is for the portkey validator.

Installation

Using NPM

npm install @portkey-v1/did

Using Yarn

yarn add @portkey-v1/did

After that you need configure did server node、graphQL node、storage suite.

class Store implements IStorageSuite {
  async getItem(key: string) {
    return localStorage.getItem(key);
  }
  async setItem(key: string, value: string) {
    return localStorage.setItem(key, value);
  }
  async removeItem(key: string) {
    return localStorage.removeItem(key);
  }
}
did.setConfig({
  requestDefaults: {
    baseURL: 'your did server node',
    timeout: 'timeout', // optional default 8000ms
  },
  graphQLUrl: 'your graphQL node',
  storageMethod: new Store(),
});

That’s it! now you can use the did object.

@portkey-v1/did API Reference

did.setConfig

Where you configure did server node, graphQL node, storage suite.

did.setConfig({
  requestDefaults: {
    baseURL: 'you did server node',
    timeout: 'timeout', // optional default 8000ms
  },
  graphQLUrl: 'your graphQL node',
  storageMethod: 'your storage suite',
});

did.login

type: loginAccount

Email or mobile phone number or Google or Apple login.

did.login(type: 'loginAccount', params: AccountLoginParams): Promise<LoginResult>;

Example

did.login('loginAccount', {
  chainId: 'chainId',
  loginGuardianIdentifier: 'loginGuardianIdentifier',
  guardiansApproved: [
    {
      type: 'Email',
      identifier: 'identifier',
      verifierId: 'verifierId',
      verificationDoc: 'verificationDoc',
      signature: 'signature',
    },
  ],
  extraData: 'extraData',
  context: {
    requestId: 'requestId',
    clientId: 'clientId',
  },
});

type: scan

Logged in management to add management.

login(type: 'scan', params: ScanLoginParams): Promise<true>;

Example

did.login('scan',{
  chainId: 'chainId',
  caHash: 'caHash',
  managerInfo: {
    address: 'address',
    extraData: 'extraData'
  };
})

getLoginStatus

getLoginStatus(params: { chainId: ChainId; sessionId: string }): Promise<RecoverStatusResult>;

Example

did.getLoginStatus({
  chainId: 'chainId',
  sessionId: 'sessionId',
});

logout

logout(params: EditManagerParams): Promise<boolean>;

Example

did.logout({ chainId: 'chainId' });

register

register(params: Omit<RegisterParams, 'manager'>): Promise<RegisterResult>;

Example

did.register({
  type: 'Email',
  loginGuardianIdentifier: 'loginGuardianIdentifier',
  extraData: 'extraData',
  chainId: 'chainId',
  verifierId: 'verifierId',
  verificationDoc: 'verificationDoc',
  signature: 'signature',
  context: {
    requestId: 'requestId',
    clientId: 'clientId',
  },
});

getRegisterStatus

getRegisterStatus(params: { chainId: ChainId; sessionId: string }): Promise<RegisterStatusResult>;

Example

did.getRegisterStatus({
  chainId: 'chainId',
  sessionId: 'sessionId',
});

getHolderInfo

getHolderInfo by graphQL.

getHolderInfo(params: Pick<GetHolderInfoParams, 'manager' | 'chainId'>): Promise<GetCAHolderByManagerResult>;

Example

did.getHolderInfo({
  manager: 'manager', // optional
  chainId: 'chainId',
});

getHolderInfo by server.

getHolderInfo(params: Omit<GetHolderInfoParams, 'manager'>): Promise<IHolderInfo>;

Example

did.getHolderInfo({
  caHash: 'caHash', // loginGuardianIdentifier and caHash choose one
  loginGuardianIdentifier: 'loginGuardianIdentifier', // loginGuardianIdentifier and caHash choose one
  chainId: 'chainId',
});

getVerifierServers

Get the VerifierServer information of the corresponding chain.

getVerifierServers(chainId: ChainId): Promise<VerifierItem[]>;

Example

did.getVerifierServers({
  chainId: 'chainId',
});

check manager is exist

Check whether the manager has management permissions for the account.

checkManagerIsExist(params:{chainId: ChainId, caHash:string, manager:string}): Promise<boolean>;

Example

did.checkManagerIsExist({
  chainId: 'chainId',
  caHash: 'caHash',
  manager: 'manager'
});

services

services.getVerificationCode

send verification code.

getVerificationCode(params: SendVerificationCodeRequestParams): Promise<SendVerificationCodeResult>;

Example

did.services.getVerificationCode({
  params: {
    chainId: 'chainId',
    guardianIdentifier: 'guardianIdentifier',
    type: 'Email',
    verifierId: 'verifierId',
    operationType: 'operationType',
  },
  headers: {
    reCaptchaToken: 'reCaptchaToken',
  },
});

operationType types

services.verifyVerificationCode

verify verification code.

verifyVerificationCode(params: VerifyVerificationCodeParams): Promise<VerifyVerificationCodeResult>;

Example

did.services.verifyVerificationCode({
  verifierSessionId: 'verifierSessionId',
  chainId: 'chainId',
  guardianIdentifier: 'guardianIdentifier',
  verifierId: 'verifierId',
  verificationCode: 'verificationCode',
  operationType: 'operationType',
});

services.verifyGoogleToken

verify Google token.

verifyGoogleToken(params: VerifyGoogleTokenParams): Promise<VerifyVerificationCodeResult>;

Example

did.services.verifyGoogleToken({
  chainId: 'chainId',
  accessToken: 'accessToken',
  verifierId: 'verifierId',
  operationType: 'operationType',
});

services.verifyAppleToken

verify Apple token.

verifyAppleToken(params: VerifyAppleTokenParams): Promise<VerifyVerificationCodeResult>;

Example

did.services.verifyAppleToken({
  chainId: 'chainId',
  verifierId: 'verifierId',
  identityToken: 'identityToken',
  operationType: 'operationType',
});

services.sendAppleUserExtraInfo

send Apple user extra info.

sendAppleUserExtraInfo(params: SendAppleUserExtraInfoParams): Promise<SendAppleUserExtraInfoResult>;

Example

did.services.sendAppleUserExtraInfo({
  identityToken: 'identityToken',
  userInfo: {
    name: {
      firstName: 'firstName',
      lastName: 'lastName',
    },
    email: 'email',
  },
});
1.5.4-alpha.22

3 months ago

1.5.4-alpha.21

4 months ago

1.5.4-alpha.20

4 months ago

1.5.4-alpha.19

4 months ago

1.5.4-alpha.18

4 months ago

1.5.4-alpha.17

4 months ago

1.5.4-alpha.16

4 months ago

1.5.4-alpha.15

4 months ago

1.5.4-alpha.14

4 months ago

1.5.4-alpha.11

4 months ago

1.5.4-alpha.13

4 months ago

1.5.4-alpha.12

4 months ago

1.5.4-alpha.10

4 months ago

1.5.4-alpha.9

4 months ago

1.5.4-alpha.8

4 months ago

1.5.4-alpha.7

4 months ago

1.5.4-alpha.6

4 months ago

1.5.4-alpha.4

5 months ago

1.5.4-alpha.3

5 months ago

1.5.4-alpha.2

5 months ago