Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 92x 92x 92x 92x 5x 5x 5x 1x 1x 1x 1x 1x 1x | import { profile } from '@affinidi/tools-common' import { SignedCredential, SdkOptions } from '../dto/shared.dto' import { ParametersValidator } from '../shared/ParametersValidator' import { getOptionsFromEnvironment, ParsedOptions } from '../shared/getOptionsFromEnvironment' import WalletStorageService from '../services/WalletStorageService' import { PhoneIssuerService, InitiateResponse as PhoneIssuerInitiateResponse, VerifyResponse as PhoneIssuerVerifyResponse, } from '../services/PhoneIssuerService' import { EmailIssuerService, InitiateResponse as EmailIssuerInitiateResponse, VerifyResponse as EmailIssuerVerifyResponse, } from '../services/EmailIssuerService' import { BaseNetworkMember, StaticDependencies, ConstructorUserData } from './BaseNetworkMember' import { Util } from './Util' /** * @deprecated, will be removed in SDK v7 */ @profile() export abstract class LegacyNetworkMember extends BaseNetworkMember { private readonly _phoneIssuer: PhoneIssuerService private readonly _emailIssuer: EmailIssuerService constructor(userData: ConstructorUserData, dependencies: StaticDependencies, options: ParsedOptions) { super(userData, dependencies, options) const { basicOptions: { phoneIssuerBasePath, emailIssuerBasePath }, } = this._options this._phoneIssuer = new PhoneIssuerService({ basePath: phoneIssuerBasePath }) this._emailIssuer = new EmailIssuerService({ basePath: emailIssuerBasePath }) } /** * @description Initiates the phone number verification flow * @deprecated * @param config - Configuration options * @param config.apiKey - They api access key to the issuer service * @param config.phoneNumber - The phone number to send the confirmation code to * @param config.isWhatsAppNumber - Whether the phone number is a WhatsApp number * @param config.id - The id of the request, this is for the caller to be able to identify the credential in the verify step * @param config.holder - The DID of the user who will recieve the VC (owner of the phone number) * @returns intitiate response data, including the status of the request */ async initiatePhoneCredential({ apiKey, phoneNumber, isWhatsAppNumber, id, holder, }: { apiKey: string phoneNumber: string isWhatsAppNumber?: boolean id: string holder: string }): Promise<PhoneIssuerInitiateResponse> { await ParametersValidator.validate([ { isArray: false, type: 'string', isRequired: true, value: apiKey }, { isArray: false, type: 'string', isRequired: true, value: phoneNumber }, { isArray: false, type: 'boolean', isRequired: false, value: isWhatsAppNumber }, { isArray: false, type: 'string', isRequired: true, value: id }, { isArray: false, type: 'string', isRequired: true, value: holder }, ]) return this._phoneIssuer.initiate({ apiKey, phoneNumber, isWhatsAppNumber, id, holder }) } /** * @description Finishes the phone number verification flow * @deprecated * @param config - Configuration options * @param config.apiKey - They api access key to the issuer service * @param config.code - The code the user recieved * @param config.id - The id of the request, must match the ID given in the initiate step * @param config.holder - The DID of the user who will recieve the VC (owner of the phone number) * @returns verify response data, including the issued VC(s) */ async verifyPhoneCredential({ apiKey, code, id, holder, }: { apiKey: string code: string id: string holder: string }): Promise<PhoneIssuerVerifyResponse> { await ParametersValidator.validate([ { isArray: false, type: 'string', isRequired: true, value: apiKey }, { isArray: false, type: 'string', isRequired: true, value: code }, { isArray: false, type: 'string', isRequired: true, value: id }, { isArray: false, type: 'string', isRequired: true, value: holder }, ]) return this._phoneIssuer.verify({ apiKey, code, id, holder }) } /** * @description Initiates the email address verification flow * @deprecated * @param config - Configuration options * @param config.apiKey - They api access key to the issuer service * @param config.emailAddress - The email address to send the confirmation code to * @param config.id - The id of the request, this is for the caller to be able to identify the credential in the verify step * @param config.holder - The DID of the user who will recieve the VC (owner of the email address) * @returns intitiate response data, including the status of the request */ async initiateEmailCredential({ apiKey, emailAddress, id, holder, }: { apiKey: string emailAddress: string id: string holder: string }): Promise<EmailIssuerInitiateResponse> { await ParametersValidator.validate([ { isArray: false, type: 'string', isRequired: true, value: apiKey }, { isArray: false, type: 'string', isRequired: true, value: emailAddress }, { isArray: false, type: 'string', isRequired: true, value: id }, { isArray: false, type: 'string', isRequired: true, value: holder }, ]) return this._emailIssuer.initiate({ apiKey, emailAddress, id, holder }) } /** * @description Finishes the email address verification flow * @deprecated * @param config - Configuration options * @param config.apiKey - They api access key to the issuer service * @param config.code - The code the user recieved * @param config.id - The id of the request, must match the ID given in the initiate step * @param config.holder - The DID of the user who will recieve the VC (owner of the email address) * @returns verify response data, including the issued VC(s) */ async verifyEmailCredential({ apiKey, code, id, holder, }: { apiKey: string code: string id: string holder: string }): Promise<EmailIssuerVerifyResponse> { await ParametersValidator.validate([ { isArray: false, type: 'string', isRequired: true, value: apiKey }, { isArray: false, type: 'string', isRequired: true, value: code }, { isArray: false, type: 'string', isRequired: true, value: id }, { isArray: false, type: 'string', isRequired: true, value: holder }, ]) return this._emailIssuer.verify({ apiKey, code, id, holder }) } getPublicKeyHexFromDidDocument(didDocument: any) { return Util.getPublicKeyHexFromDidDocument(didDocument) } /** * @description Creates DID and anchors it * 1. generate seed/keys * 2. build DID document * 3. sign DID document * 4. store DID document in IPFS * 5. anchor DID with DID document ID from IPFS * @param password - encryption key which will be used to encrypt randomly created seed/keys pair * @param inputOptions - optional parameter { registryUrl: 'https://affinity-registry.apse1.dev.affinidi.io' } * @returns * * did - hash from public key (your decentralized ID) * * encryptedSeed - seed is encrypted by provided password. Seed - it's a source to derive your keys */ static async register( dependencies: StaticDependencies, inputOptions: SdkOptions, password: string, ): Promise<{ did: string; encryptedSeed: string }> { await ParametersValidator.validate([ { isArray: false, type: 'string', isRequired: true, value: password }, { isArray: false, type: SdkOptions, isRequired: true, value: inputOptions }, ]) const options = getOptionsFromEnvironment(inputOptions) return LegacyNetworkMember._register(dependencies, options, password) } static async anchorDid( encryptedSeed: string, password: string, didDocument: any, nonce: number, inputOptions: SdkOptions, ) { const options = getOptionsFromEnvironment(inputOptions) return LegacyNetworkMember._anchorDid(encryptedSeed, password, didDocument, nonce, options) } /** * @description Retrieves a VC based on signup information * @param idToken - idToken received from cognito * @returns an object with a flag, identifying whether new account was created, and initialized instance of SDK */ async getSignupCredentials(idToken: string, inputOptions: SdkOptions): Promise<SignedCredential[]> { await ParametersValidator.validate([ { isArray: false, type: 'string', isRequired: true, value: idToken }, { isArray: false, type: SdkOptions, isRequired: true, value: inputOptions }, ]) const options = getOptionsFromEnvironment(inputOptions) return this._getSignupCredentials(idToken, options) } /** * @description Retrieves a VC based on signup information * @param idToken - idToken received from cognito * @returns an object with a flag, identifying whether new account was created, and initialized instance of SDK */ protected async _getSignupCredentials( idToken: string, { basicOptions: { env, keyStorageUrl, issuerUrl }, accessApiKey }: ParsedOptions, ): Promise<SignedCredential[]> { const credentialOfferToken = await WalletStorageService.getCredentialOffer(idToken, keyStorageUrl, { env, accessApiKey, }) const credentialOfferResponseToken = await this.createCredentialOfferResponseToken(credentialOfferToken) return WalletStorageService.getSignedCredentials(idToken, credentialOfferResponseToken, { accessApiKey, issuerUrl, keyStorageUrl, }) } } |