Socket
Socket
Sign inDemoInstall

@unumid/server-sdk

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unumid/server-sdk - npm Package Compare versions

Comparing version 3.19.0 to 3.20.0

2

build/issuer/registerIssuer.d.ts

@@ -8,3 +8,3 @@ import { RegisteredIssuer, UnumDto } from '../types';

*/
export declare const registerIssuer: (customerUuid: string, apiKey: string, url: string, versionInfo?: VersionInfo[]) => Promise<UnumDto<RegisteredIssuer>>;
export declare const registerIssuer: (apiKey: string, url: string, versionInfo?: VersionInfo[]) => Promise<UnumDto<RegisteredIssuer>>;
//# sourceMappingURL=registerIssuer.d.ts.map

@@ -81,6 +81,3 @@ "use strict";

*/
var validateInParams = function (customerUuid, apiKey, url, versionInfo) {
if (!customerUuid) {
throw new error_1.CustError(400, 'Invalid Issuer: customerUuid is required.');
}
var validateInParams = function (apiKey, url, versionInfo) {
if (!apiKey) {

@@ -99,3 +96,3 @@ throw new error_1.CustError(401, 'Not authenticated: apiKey is required');

*/
exports.registerIssuer = function (customerUuid, apiKey, url, versionInfo) {
exports.registerIssuer = function (apiKey, url, versionInfo) {
if (versionInfo === void 0) { versionInfo = [{ target: { version: '1.0.0' }, sdkVersion: '3.0.0' }]; }

@@ -108,3 +105,3 @@ return __awaiter(void 0, void 0, void 0, function () {

_a.trys.push([0, 3, , 4]);
validateInParams(customerUuid, apiKey, url, versionInfo);
validateInParams(apiKey, url, versionInfo);
return [4 /*yield*/, createKeyPairs_1.createKeyPairSet()];

@@ -114,3 +111,2 @@ case 1:

issuerOpt = {
customerUuid: customerUuid,
publicKeyInfo: constructKeyObjs(kpSet),

@@ -117,0 +113,0 @@ url: url,

@@ -6,4 +6,4 @@ import { UnumDto, VerifiedStatus } from '../types';

*/
export declare function verifySubjectCredentialRequests(authorization: string, issuerDid: string, subjectDid: string, credentialRequests: SubjectCredentialRequests): Promise<UnumDto<VerifiedStatus>>;
export declare function verifySubjectCredentialRequests(authorization: string, issuerDid: string, subjectDid: string, subjectCredentialRequests: SubjectCredentialRequests): Promise<UnumDto<VerifiedStatus>>;
export declare function verifySubjectCredentialRequestsHelper(authToken: string, issuerDid: string, subjectCredentialRequests: SubjectCredentialRequests): Promise<UnumDto<VerifiedStatus>>;
//# sourceMappingURL=verifySubjectCredentialRequests.d.ts.map

@@ -105,3 +105,3 @@ "use strict";

*/
function verifySubjectCredentialRequests(authorization, issuerDid, subjectDid, credentialRequests) {
function verifySubjectCredentialRequests(authorization, issuerDid, subjectDid, subjectCredentialRequests) {
return __awaiter(this, void 0, void 0, function () {

@@ -114,4 +114,4 @@ var result, authToken, _a, isVerified, message;

// validate credentialRequests input; and grab the subjectDid for reference later
validateSubjectCredentialRequests(credentialRequests, subjectDid);
return [4 /*yield*/, verifySubjectCredentialRequestsHelper(authorization, issuerDid, credentialRequests)];
validateSubjectCredentialRequests(subjectCredentialRequests, subjectDid);
return [4 /*yield*/, verifySubjectCredentialRequestsHelper(authorization, issuerDid, subjectCredentialRequests)];
case 1:

@@ -121,27 +121,4 @@ result = _b.sent();

_a = result.body, isVerified = _a.isVerified, message = _a.message;
return [4 /*yield*/, handleSubjectCredentialsRequestsVerificationReceipt(authToken, issuerDid, subjectDid, credentialRequests, isVerified, message)];
return [4 /*yield*/, handleSubjectCredentialsRequestsVerificationReceipt(authToken, issuerDid, subjectDid, subjectCredentialRequests, isVerified, message)];
case 2:
// let authToken = authorization;
// for (const credentialRequest of credentialRequests) {
// const result: UnumDto<VerifiedStatus> = await verifySubjectCredentialRequestsHelper(authToken, issuerDid, credentialRequest);
// const { isVerified, message } = result.body;
// authToken = result.authToken;
// // can stop here is not verified
// if (!result.body.isVerified) {
// // handle sending back the ReceiptSubjectCredentialRequestVerifiedData receipt with the verification failure reason
// authToken = await handleSubjectCredentialsRequestsVerificationReceipt(authToken, issuerDid, subjectDid, credentialRequests, isVerified, message);
// return {
// ...result,
// authToken
// };
// }
// }
// if (!result.body.isVerified) {
// // handle sending back the ReceiptSubjectCredentialRequestVerifiedData receipt with the verification failure reason
// authToken = await handleSubjectCredentialsRequestsVerificationReceipt(authToken, issuerDid, subjectDid, credentialRequests, isVerified, message);
// return {
// ...result,
// authToken
// };
// }
// handle sending back the ReceiptSubjectCredentialRequestVerifiedData receipt with the verification status

@@ -210,54 +187,2 @@ authToken = _b.sent();

exports.verifySubjectCredentialRequestsHelper = verifySubjectCredentialRequestsHelper;
// export async function verifySubjectCredentialRequestsHelper (authToken: string, issuerDid: string, credentialRequests: SubjectCredentialRequests): Promise<UnumDto<VerifiedStatus>> {
// const verificationMethod = credentialRequests.proof?.verificationMethod as string;
// const signatureValue = credentialRequests.proof?.signatureValue as string;
// // // validate that the issueDid is present in the request issuer array
// // if (!credentialRequests.issuers.includes(issuerDid)) {
// // return {
// // authToken,
// // body: {
// // isVerified: false,
// // message: `Issuer DID, ${issuerDid}, not found in credential request issuers ${credentialRequest.issuers}`
// // }
// // };
// // }
// const publicKeyInfoResponse: UnumDto<PublicKeyInfo[]> = await getDidDocPublicKeys(authToken, verificationMethod, 'secp256r1');
// const publicKeyInfoList: PublicKeyInfo[] = publicKeyInfoResponse.body;
// authToken = publicKeyInfoResponse.authToken;
// if (publicKeyInfoList.length === 0) {
// return {
// authToken,
// body: {
// isVerified: false,
// message: `Public key not found for the subject did ${verificationMethod}`
// }
// };
// }
// let isVerified = false;
// const unsignedCredentialRequest: CredentialRequestPb = omit(credentialRequest, 'proof');
// // convert to bytes
// const bytes: Uint8Array = CredentialRequestPb.encode(unsignedCredentialRequest).finish();
// // check all the public keys to see if any work, stop if one does
// for (const publicKeyInfo of publicKeyInfoList) {
// const { publicKey, encoding } = publicKeyInfo;
// // verify the signature
// isVerified = doVerify(signatureValue, bytes, publicKey, encoding);
// if (isVerified) break;
// }
// if (!isVerified) {
// return {
// authToken,
// body: {
// isVerified: false,
// message: 'SubjectCredentialRequest signature can not be verified.'
// }
// };
// }
// return {
// authToken,
// body: {
// isVerified: true
// }
// };
// }
/**

@@ -264,0 +189,0 @@ * Handle sending back the SubjectCredentialRequestVerified receipt

@@ -10,3 +10,3 @@ import { RegisteredVerifier, UnumDto } from '../types';

*/
export declare const registerVerifier: (customerUuid: string, url: string, apiKey: string, versionInfo?: VersionInfo[]) => Promise<UnumDto<RegisteredVerifier>>;
export declare const registerVerifier: (apiKey: string, url: string, versionInfo?: VersionInfo[]) => Promise<UnumDto<RegisteredVerifier>>;
//# sourceMappingURL=registerVerifier.d.ts.map

@@ -81,6 +81,3 @@ "use strict";

*/
var validateInParams = function (customerUuid, url, apiKey, versionInfo) {
if (!customerUuid) {
throw new __1.CustError(400, 'Invalid Verifier Options: customerUuid is required.');
}
var validateInParams = function (url, apiKey, versionInfo) {
if (!url) {

@@ -101,3 +98,3 @@ throw new __1.CustError(400, 'Invalid Verifier Options: url is required.');

*/
exports.registerVerifier = function (customerUuid, url, apiKey, versionInfo) {
exports.registerVerifier = function (apiKey, url, versionInfo) {
if (versionInfo === void 0) { versionInfo = [{ target: { version: '1.0.0' }, sdkVersion: '3.0.0' }]; }

@@ -110,7 +107,7 @@ return __awaiter(void 0, void 0, void 0, function () {

_a.trys.push([0, 3, , 4]);
validateInParams(customerUuid, url, apiKey, versionInfo);
validateInParams(url, apiKey, versionInfo);
return [4 /*yield*/, createKeyPairs_1.createKeyPairSet()];
case 1:
kpSet = _a.sent();
verifierOpt = { customerUuid: customerUuid, url: url, publicKeyInfo: constructKeyObjs(kpSet), versionInfo: versionInfo };
verifierOpt = { url: url, publicKeyInfo: constructKeyObjs(kpSet), versionInfo: versionInfo };
restData = {

@@ -117,0 +114,0 @@ method: 'POST',

{
"name": "@unumid/server-sdk",
"version": "3.19.0",
"version": "3.20.0",
"main": "build/index.js",

@@ -47,3 +47,3 @@ "repository": "git@github.com:UnumID/Server-SDK-TypeScript.git",

"@unumid/library-crypto": "https://github.com/UnumID/Library-Crypto-TypeScript.git#1.7.0",
"@unumid/types": "https://github.com/UnumID/types.git#3.34.0",
"@unumid/types": "https://github.com/UnumID/types.git#3.35.0",
"@unumid/types-v2": "npm:@unumid/types@2.1.3",

@@ -50,0 +50,0 @@ "dotenv": "^8.2.0",

@@ -66,6 +66,20 @@ # Unum ID Typescript Server-SDK

```typescript
export type TargetInfo = {
[key: string]: any, // To be able to handle generic HTTP header requirements, i.e. version, accept, appId, etc
url?: string // Versions denoted via a different url.
}
```
```typescript
export type VersionInfo = {
target: TargetInfo, // The information of how to target a customer's application to communication with the corresponding Server sdkVersion.
sdkVersion: string // Server sdk version. Ought to be in Semver notation however opting to keep a string type for simplicity.
}
Parameters:
```typescript
"customerUuid": string, // your customer UUID
"apiKey": string // your issuer API key
"url": string, // the url of which UnumID's SaaS will interface with
"versionInfo": VersionInfo[] // arrays of objects for how to contact specific version of your verifier and subsequently the sever sdk.
```

@@ -178,19 +192,25 @@

### verifySubjectCredentialRequest
Verify a Subject's request for credentials.
### verifySubjectCredentialRequests
Verify a Subject's requests for credentials.
You need to provide the your issuer's `did` along with the SubjectCredentialRequest array from your `/credentialRequest` [endpoint](https://gist.github.com/UnumIDAdmin/d76d9fe46e459e529d7f7b6f9319a0b6).
You need to provide the your issuer's `did` along with the SubjectCredentialRequest array from your `/userCredentialRequest` [endpoint](https://gist.github.com/UnumIDAdmin/fd75b174b33ff0c5b4de87118cb11188).
Each request is cryptographically signed by the subject's private key. This function verifies the signatures are valid. Furthermore, it validates that all requests are from the same subject and that requested Issuer requirements are met. After which, your application code will need to evaluate wether it can issue the requested credentials. An example implementation can be found [here](https://github.com/UnumID/demo-issuer-server/blob/main/src/services/api/credentialRequest/credentialRequest.class.ts).
The array of CredentialRequests are signed by the subject's private key. This function verifies the cryptographic signature is valid. Furthermore, it validates that all requests are from the same subject and that requested Issuer requirements are met. After which, your application code will need to evaluate wether it can issue the requested credentials. An example implementation can be found [here](https://github.com/UnumID/demo-issuer-server/blob/main/src/services/api/credentialRequest/credentialRequest.class.ts).
The main use case of this to allow bootstrapping users that just installed the Unum ID Wallet with credentials necessary to use across the network, i.e for instant sign ups with a partner.
_Note_: Despite this having "verify" in its name, this function only serves Issuers in determining whether a subject's request for credentials is valid. It is up to you application logic to determine whether you have the data relating to the the subject to issue the requested credentials.
_Note_: Despite this having "verify" in its name, this function serves Issuers in determining whether a subject's request for credentials is valid. It is up to your application logic to determine whether you have the data relating to the the subject to issue the requested credentials.
```typescript
export type SubjectCredentialRequest = {
export type CredentialRequest = {
type: string; // the string matching the desire credential type
issuers: string[]; //list of acceptable issuer DIDs that have issued the credential
required: boolean; // to denote wether this particular credential is required. Defaults behavior resolves this to true.
}
```
```typescript
export type SubjectCredentialRequests = {
credentialRequests: CredentialRequests[]; // the string matching the desire credential type
proof: Proof; // proof signed by the subject

@@ -205,11 +225,11 @@ }

"issuerDid": string // the did of your issuer
"credentialRequests: SubjectCredentialRequest[] // array of credential requests signed by the Subject
"subjectDid": string // the did of the subject
"subjectCredentialRequests: SubjectCredentialRequests // object containing list of CredentialRequests with a Proof signed by the Subject
}
```
Response Body: [**SubjectCredentialRequestVerifiedStatus**].
Response Body: [**VerifiedStatus**].
```typescript
export interface SubjectCredentialRequestVerifiedStatus {
subjectDid: string; // returns the subject DID that made and signed all the requests
isVerified: boolean; // returns true if all requests are verified and validation requirements are met
isVerified: boolean; // returns true if the requests are verified and validation requirements are met
message?: string; // (optional) only populated iff isVerified is false

@@ -227,7 +247,21 @@ }

```typescript
export type TargetInfo = {
[key: string]: any, // To be able to handle generic HTTP header requirements, i.e. version, accept, appId, etc
url?: string // Versions denoted via a different url.
}
```
```typescript
export type VersionInfo = {
target: TargetInfo, // The information of how to target a customer's application to communication with the corresponding Server sdkVersion.
sdkVersion: string // Server sdk version. Ought to be in Semver notation however opting to keep a string type for simplicity.
}
```
Parameters
```typescript
"customerUuid": string, // your customer UUID
"apiKey": string // your verifier API key
"url": string, // the url of which UnumID's SaaS will interface with
"apiKey": string // your verifier API key
"versionInfo": VersionInfo[] // arrays of objects for how to contact specific version of your verifier and subsequently the sever sdk.
```

@@ -234,0 +268,0 @@

@@ -46,7 +46,3 @@ import { configData } from '../config';

*/
const validateInParams = (customerUuid: string, apiKey: string, url: string, versionInfo: VersionInfo[]) => {
if (!customerUuid) {
throw new CustError(400, 'Invalid Issuer: customerUuid is required.');
}
const validateInParams = (apiKey: string, url: string, versionInfo: VersionInfo[]) => {
if (!apiKey) {

@@ -68,9 +64,8 @@ throw new CustError(401, 'Not authenticated: apiKey is required');

*/
export const registerIssuer = async (customerUuid: string, apiKey: string, url:string, versionInfo: VersionInfo[] = [{ target: { version: '1.0.0' }, sdkVersion: '3.0.0' }]): Promise<UnumDto<RegisteredIssuer>> => {
export const registerIssuer = async (apiKey: string, url:string, versionInfo: VersionInfo[] = [{ target: { version: '1.0.0' }, sdkVersion: '3.0.0' }]): Promise<UnumDto<RegisteredIssuer>> => {
try {
validateInParams(customerUuid, apiKey, url, versionInfo);
validateInParams(apiKey, url, versionInfo);
const kpSet: KeyPairSet = await createKeyPairSet();
const issuerOpt: IssuerOptions = {
customerUuid,
publicKeyInfo: constructKeyObjs(kpSet),

@@ -77,0 +72,0 @@ url,

@@ -65,42 +65,14 @@

*/
export async function verifySubjectCredentialRequests (authorization: string, issuerDid: string, subjectDid: string, credentialRequests: SubjectCredentialRequests): Promise<UnumDto<VerifiedStatus>> {
export async function verifySubjectCredentialRequests (authorization: string, issuerDid: string, subjectDid: string, subjectCredentialRequests: SubjectCredentialRequests): Promise<UnumDto<VerifiedStatus>> {
requireAuth(authorization);
// validate credentialRequests input; and grab the subjectDid for reference later
validateSubjectCredentialRequests(credentialRequests, subjectDid);
validateSubjectCredentialRequests(subjectCredentialRequests, subjectDid);
const result: UnumDto<VerifiedStatus> = await verifySubjectCredentialRequestsHelper(authorization, issuerDid, credentialRequests);
const result: UnumDto<VerifiedStatus> = await verifySubjectCredentialRequestsHelper(authorization, issuerDid, subjectCredentialRequests);
let authToken = result.authToken;
const { isVerified, message } = result.body;
// let authToken = authorization;
// for (const credentialRequest of credentialRequests) {
// const result: UnumDto<VerifiedStatus> = await verifySubjectCredentialRequestsHelper(authToken, issuerDid, credentialRequest);
// const { isVerified, message } = result.body;
// authToken = result.authToken;
// // can stop here is not verified
// if (!result.body.isVerified) {
// // handle sending back the ReceiptSubjectCredentialRequestVerifiedData receipt with the verification failure reason
// authToken = await handleSubjectCredentialsRequestsVerificationReceipt(authToken, issuerDid, subjectDid, credentialRequests, isVerified, message);
// return {
// ...result,
// authToken
// };
// }
// }
// if (!result.body.isVerified) {
// // handle sending back the ReceiptSubjectCredentialRequestVerifiedData receipt with the verification failure reason
// authToken = await handleSubjectCredentialsRequestsVerificationReceipt(authToken, issuerDid, subjectDid, credentialRequests, isVerified, message);
// return {
// ...result,
// authToken
// };
// }
// handle sending back the ReceiptSubjectCredentialRequestVerifiedData receipt with the verification status
authToken = await handleSubjectCredentialsRequestsVerificationReceipt(authToken, issuerDid, subjectDid, credentialRequests, isVerified, message);
authToken = await handleSubjectCredentialsRequestsVerificationReceipt(authToken, issuerDid, subjectDid, subjectCredentialRequests, isVerified, message);

@@ -117,13 +89,2 @@ return {

// // validate that the issueDid is present in the request issuer array
// if (!credentialRequests.issuers.includes(issuerDid)) {
// return {
// authToken,
// body: {
// isVerified: false,
// message: `Issuer DID, ${issuerDid}, not found in credential request issuers ${credentialRequest.issuers}`
// }
// };
// }
const publicKeyInfoResponse: UnumDto<PublicKeyInfo[]> = await getDidDocPublicKeys(authToken, verificationMethod, 'secp256r1');

@@ -177,65 +138,2 @@ const publicKeyInfoList: PublicKeyInfo[] = publicKeyInfoResponse.body;

// export async function verifySubjectCredentialRequestsHelper (authToken: string, issuerDid: string, credentialRequests: SubjectCredentialRequests): Promise<UnumDto<VerifiedStatus>> {
// const verificationMethod = credentialRequests.proof?.verificationMethod as string;
// const signatureValue = credentialRequests.proof?.signatureValue as string;
// // // validate that the issueDid is present in the request issuer array
// // if (!credentialRequests.issuers.includes(issuerDid)) {
// // return {
// // authToken,
// // body: {
// // isVerified: false,
// // message: `Issuer DID, ${issuerDid}, not found in credential request issuers ${credentialRequest.issuers}`
// // }
// // };
// // }
// const publicKeyInfoResponse: UnumDto<PublicKeyInfo[]> = await getDidDocPublicKeys(authToken, verificationMethod, 'secp256r1');
// const publicKeyInfoList: PublicKeyInfo[] = publicKeyInfoResponse.body;
// authToken = publicKeyInfoResponse.authToken;
// if (publicKeyInfoList.length === 0) {
// return {
// authToken,
// body: {
// isVerified: false,
// message: `Public key not found for the subject did ${verificationMethod}`
// }
// };
// }
// let isVerified = false;
// const unsignedCredentialRequest: CredentialRequestPb = omit(credentialRequest, 'proof');
// // convert to bytes
// const bytes: Uint8Array = CredentialRequestPb.encode(unsignedCredentialRequest).finish();
// // check all the public keys to see if any work, stop if one does
// for (const publicKeyInfo of publicKeyInfoList) {
// const { publicKey, encoding } = publicKeyInfo;
// // verify the signature
// isVerified = doVerify(signatureValue, bytes, publicKey, encoding);
// if (isVerified) break;
// }
// if (!isVerified) {
// return {
// authToken,
// body: {
// isVerified: false,
// message: 'SubjectCredentialRequest signature can not be verified.'
// }
// };
// }
// return {
// authToken,
// body: {
// isVerified: true
// }
// };
// }
/**

@@ -246,4 +144,2 @@ * Handle sending back the SubjectCredentialRequestVerified receipt

try {
// const requestInfo: CredentialRequest[] = subjectCredentialRequests.credentialRequests.map((request) => request);
// const requstInfo: CredentialRequest[] = flatten2DArray(subjectCredentialRequests.credentialRequests);
const requestInfo: CredentialRequest[] = subjectCredentialRequests.credentialRequests;

@@ -250,0 +146,0 @@

@@ -45,7 +45,3 @@ import { configData } from '../config';

*/
const validateInParams = (customerUuid: string, url: string, apiKey: string, versionInfo: VersionInfo[]): void => {
if (!customerUuid) {
throw new CustError(400, 'Invalid Verifier Options: customerUuid is required.');
}
const validateInParams = (url: string, apiKey: string, versionInfo: VersionInfo[]): void => {
if (!url) {

@@ -69,8 +65,8 @@ throw new CustError(400, 'Invalid Verifier Options: url is required.');

*/
export const registerVerifier = async (customerUuid: string, url: string, apiKey: string, versionInfo: VersionInfo[] = [{ target: { version: '1.0.0' }, sdkVersion: '3.0.0' }]): Promise<UnumDto<RegisteredVerifier>> => {
export const registerVerifier = async (apiKey: string, url: string, versionInfo: VersionInfo[] = [{ target: { version: '1.0.0' }, sdkVersion: '3.0.0' }]): Promise<UnumDto<RegisteredVerifier>> => {
try {
validateInParams(customerUuid, url, apiKey, versionInfo);
validateInParams(url, apiKey, versionInfo);
const kpSet: KeyPairSet = await createKeyPairSet();
const verifierOpt: VerifierOptions = { customerUuid, url, publicKeyInfo: constructKeyObjs(kpSet), versionInfo };
const verifierOpt: VerifierOptions = { url, publicKeyInfo: constructKeyObjs(kpSet), versionInfo };
const restData: RESTData = {

@@ -77,0 +73,0 @@ method: 'POST',

@@ -70,13 +70,2 @@

// export const makeDummySubjectCredentialRequest = async (request: CredentialRequestPb, subjectPrivateKey: string, subjectDid: string): Promise<SubjectCredentialRequest> => {
// // convert the protobuf to a byte array
// const bytes: Uint8Array = CredentialRequestPb.encode(request).finish();
// const proof = await createProofPb(bytes, subjectPrivateKey, subjectDid, undefined);
// return {
// ...dummyCredentialRequest,
// proof: proof
// };
// };
export const makeDummySignedDidDocument = async (didDoc: DidDocument, subjectPrivateKey: string, subjectDid: string): Promise<SignedDidDocument> => {

@@ -83,0 +72,0 @@ const proof = await createProof(didDoc, subjectPrivateKey, subjectDid, 'pem');

@@ -28,3 +28,3 @@ import { JSONObj, RegisteredIssuer, UnumDto } from '../../src/types';

responseDto = await registerIssuer(name, customerUuid, dummyIssuerApiKey);
responseDto = await registerIssuer(name, dummyIssuerApiKey);
response = responseDto.body;

@@ -69,16 +69,5 @@ responseAuthToken = responseDto.authToken;

it('returns a CustError with a descriptive error message if customerUuid is missing', async () => {
try {
await registerIssuer('', dummyIssuerApiKey, url);
fail();
} catch (e) {
expect(e).toEqual(new CustError(400, 'Invalid Issuer: customerUuid is required.'));
expect(e.code).toEqual(400);
expect(e.message).toEqual('Invalid Issuer: customerUuid is required.');
}
});
it('returns a CustError with a descriptive error message if apiKey is missing', async () => {
try {
await registerIssuer(customerUuid, '', url);
await registerIssuer('', url);
fail();

@@ -94,3 +83,3 @@ } catch (e) {

try {
await registerIssuer(customerUuid, dummyIssuerApiKey, undefined);
await registerIssuer(dummyIssuerApiKey, undefined);
fail();

@@ -108,3 +97,3 @@ } catch (e) {

try {
await registerIssuer(customerUuid, dummyIssuerApiKey, url, badVersionInfo);
await registerIssuer(dummyIssuerApiKey, url, badVersionInfo);
fail();

@@ -121,3 +110,3 @@ } catch (e) {

try {
await registerIssuer(customerUuid, dummyIssuerApiKey, url, badVersionInfo);
await registerIssuer(dummyIssuerApiKey, url, badVersionInfo);
fail();

@@ -134,3 +123,3 @@ } catch (e) {

try {
await registerIssuer(customerUuid, dummyIssuerApiKey, url, badVersionInfo);
await registerIssuer(dummyIssuerApiKey, url, badVersionInfo);
fail();

@@ -147,3 +136,3 @@ } catch (e) {

try {
await registerIssuer(customerUuid, dummyIssuerApiKey, url, badVersionInfo);
await registerIssuer(dummyIssuerApiKey, url, badVersionInfo);
fail();

@@ -163,11 +152,2 @@ } catch (e) {

it('Response code should be 403 when uuid is not valid', async () => {
mockMakeNetworkRequest.mockRejectedValueOnce(new CustError(403, 'Forbidden'));
try {
await registerIssuer('123', dummyIssuerApiKey, url);
} catch (e) {
expect(e.code).toBe(403);
}
});
it('Response code should be 403 when API Key is not valid', async () => {

@@ -177,3 +157,3 @@ mockMakeNetworkRequest.mockRejectedValueOnce(new CustError(403, 'Forbidden'));

try {
await registerIssuer(customerUuid, 'abc', url);
await registerIssuer('abc', url);
} catch (e) {

@@ -180,0 +160,0 @@ expect(e.code).toBe(403);

@@ -73,3 +73,2 @@

const signedDidDocument = await makeDummySignedDidDocument(unsignedDidDocument, keyPair.signing.privateKey, unsignedDidDocument.id);
// const subjectCredentialRequests = await makeDummySubjectCredentialRequests([dummyCredentialRequest], keyPair.signing.privateKey, dummySubjectDid);

@@ -84,3 +83,2 @@ const authHeader = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoidmVyaWZpZXIiLCJ1dWlkIjoiM2VjYzVlZDMtZjdhMC00OTU4LWJjOTgtYjc5NTQxMThmODUyIiwiZGlkIjoiZGlkOnVudW06ZWVhYmU0NGItNjcxMi00NTRkLWIzMWItNTM0NTg4NTlmMTFmIiwiZXhwIjoxNTk1NDcxNTc0LjQyMiwiaWF0IjoxNTk1NTI5NTExfQ.4iJn_a8fHnVsmegdR5uIsdCjXmyZ505x1nA8NVvTEBg';

credentialRequests,
// subjectCredentialRequests,
authHeader,

@@ -87,0 +85,0 @@ verifier,

@@ -48,3 +48,3 @@ import {

responseDto = await registerVerifier(customerUuid, url, dummyVerifierApiKey, versionInfo);
responseDto = await registerVerifier(dummyVerifierApiKey, url, versionInfo);
response = responseDto.body;

@@ -88,16 +88,5 @@ responseAuthToken = responseDto.authToken;

it('returns a CustError with a descriptive error message if customerUuid is missing', async () => {
try {
await registerVerifier('', url, dummyVerifierApiKey);
fail();
} catch (e) {
expect(e).toEqual(new CustError(400, 'Invalid Verifier Options: customerUuid is required.'));
expect(e.code).toEqual(400);
expect(e.message).toEqual('Invalid Verifier Options: customerUuid is required.');
}
});
it('returns a CustError with a descriptive error message if url is missing', async () => {
try {
await registerVerifier(customerUuid, '', dummyVerifierApiKey);
await registerVerifier(dummyVerifierApiKey, '');
fail();

@@ -113,3 +102,3 @@ } catch (e) {

try {
await registerVerifier(customerUuid, url, '');
await registerVerifier('', url);
fail();

@@ -127,3 +116,3 @@ } catch (e) {

try {
await registerVerifier(customerUuid, url, dummyVerifierApiKey, badVersionInfo);
await registerVerifier(dummyVerifierApiKey, url, badVersionInfo);
fail();

@@ -140,3 +129,3 @@ } catch (e) {

try {
await registerVerifier(customerUuid, url, dummyVerifierApiKey, badVersionInfo);
await registerVerifier(dummyVerifierApiKey, url, badVersionInfo);
fail();

@@ -153,3 +142,3 @@ } catch (e) {

try {
await registerVerifier(customerUuid, url, dummyVerifierApiKey, badVersionInfo);
await registerVerifier(dummyVerifierApiKey, url, badVersionInfo);
fail();

@@ -166,3 +155,3 @@ } catch (e) {

try {
await registerVerifier(customerUuid, url, dummyVerifierApiKey, badVersionInfo);
await registerVerifier(dummyVerifierApiKey, url, badVersionInfo);
fail();

@@ -182,11 +171,2 @@ } catch (e) {

it('Response code should be 403 when uuid is not valid', async () => {
mockMakeNetworkRequest.mockRejectedValueOnce(new CustError(403, 'Forbidden'));
try {
await registerVerifier('123', url, dummyVerifierApiKey);
} catch (e) {
expect(e.code).toBe(403);
}
});
it('Response code should be 403 when API Key is not valid', async () => {

@@ -196,3 +176,3 @@ mockMakeNetworkRequest.mockRejectedValueOnce(new CustError(403, 'Forbidden'));

try {
await registerVerifier(customerUuid, url, 'abc');
await registerVerifier('abc', url);
} catch (e) {

@@ -199,0 +179,0 @@ expect(e.code).toBe(403);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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