@mattrglobal/verifier-sdk-web 1.1.1-unstable.159 → 1.1.1-unstable.160

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { Result } from "neverthrow";
2
2
  import { BaseError } from "../common";
3
- import { ExchangeSessionResultResponse, RequestCredentialsErrorType, RequestCredentialsWithDcApiOptions } from "./types";
4
- export declare const requestCredentialsWithDigitalCredentialsApi: (options: RequestCredentialsWithDcApiOptions) => Promise<Result<ExchangeSessionResultResponse, BaseError<RequestCredentialsErrorType.RequestCredentialsFailed>>>;
3
+ import { RequestCredentialsErrorType, RequestCredentialsResponse, RequestCredentialsWithDcApiOptions } from "./types";
4
+ export declare const requestCredentialsWithDigitalCredentialsApi: (options: RequestCredentialsWithDcApiOptions) => Promise<Result<RequestCredentialsResponse, BaseError<RequestCredentialsErrorType.RequestCredentialsFailed>>>;
5
5
  /**
6
6
  * TypeScript does not know that window.DigitalCredential is a valid property,
7
7
  * even though it might exist at runtime, because the feature is experimental
@@ -283,6 +283,33 @@ export type PresentationHiddenResult = {
283
283
  sessionId: string;
284
284
  };
285
285
  export type PresentationSessionResult = PresentationSuccessResult | PresentationFailureResult;
286
+ export declare const PresentationSessionResultValidator: v.UnionSchema<[v.ObjectSchema<{
287
+ readonly sessionId: v.StringSchema<undefined>;
288
+ readonly challenge: v.StringSchema<undefined>;
289
+ readonly credentialQuery: v.ArraySchema<v.ObjectSchema<{
290
+ readonly profile: v.PicklistSchema<[OpenidPresentationCredentialProfileSupported], undefined>;
291
+ readonly docType: v.StringSchema<undefined>;
292
+ readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
293
+ readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
294
+ }, undefined>, undefined>, undefined>;
295
+ }, undefined>, undefined>;
296
+ readonly credentials: v.OptionalSchema<v.ArraySchema<v.AnySchema, undefined>, never>;
297
+ readonly credentialErrors: v.OptionalSchema<v.ArraySchema<v.AnySchema, undefined>, never>;
298
+ }, undefined>, v.ObjectSchema<{
299
+ readonly sessionId: v.StringSchema<undefined>;
300
+ readonly challenge: v.StringSchema<undefined>;
301
+ readonly credentialQuery: v.ArraySchema<v.ObjectSchema<{
302
+ readonly profile: v.PicklistSchema<[OpenidPresentationCredentialProfileSupported], undefined>;
303
+ readonly docType: v.StringSchema<undefined>;
304
+ readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
305
+ readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
306
+ }, undefined>, undefined>, undefined>;
307
+ }, undefined>, undefined>;
308
+ readonly error: v.ObjectSchema<{
309
+ readonly type: v.PicklistSchema<PresentationErrorType[], undefined>;
310
+ readonly message: v.StringSchema<undefined>;
311
+ }, undefined>;
312
+ }, undefined>], undefined>;
286
313
  export type ExchangeSessionResultParams = {
287
314
  readonly sessionId: string;
288
315
  };
@@ -1324,6 +1324,13 @@
1324
1324
  PresentationErrorType["WalletUnavailable"] = "WalletUnavailable";
1325
1325
  PresentationErrorType["Unknown"] = "Unknown";
1326
1326
  })(PresentationErrorType || (PresentationErrorType = {}));
1327
+ const PresentationSuccessResultValidator = object({
1328
+ sessionId: string(),
1329
+ challenge: string(),
1330
+ credentialQuery: array(CredentialQueryValidator),
1331
+ credentials: optional(array(any())),
1332
+ credentialErrors: optional(array(any()))
1333
+ });
1327
1334
  const PresentationResultRelaxValidator = object({
1328
1335
  sessionId: string(),
1329
1336
  challenge: optional(string()),
@@ -1332,6 +1339,16 @@
1332
1339
  credentialErrors: optional(unknown()),
1333
1340
  error: optional(unknown())
1334
1341
  });
1342
+ const PresentationFailureResultValidator = object({
1343
+ sessionId: string(),
1344
+ challenge: string(),
1345
+ credentialQuery: array(CredentialQueryValidator),
1346
+ error: object({
1347
+ type: picklist(Object.values(PresentationErrorType)),
1348
+ message: string()
1349
+ })
1350
+ });
1351
+ const PresentationSessionResultValidator = union([ PresentationSuccessResultValidator, PresentationFailureResultValidator ]);
1335
1352
  exports.Mode = void 0;
1336
1353
  (function(Mode) {
1337
1354
  Mode["SameDevice"] = "sameDevice";
@@ -1714,7 +1731,7 @@
1714
1731
  return;
1715
1732
  }
1716
1733
  onComplete({
1717
- result: "challenge" in result.value ? result.value : undefined,
1734
+ result: isType(PresentationSessionResultValidator)(result.value) ? result.value : undefined,
1718
1735
  sessionId: result.value.sessionId,
1719
1736
  sessionCompletedInRedirect: false
1720
1737
  });
@@ -1851,7 +1868,11 @@
1851
1868
  cause: credentialVerificationResult.error
1852
1869
  });
1853
1870
  }
1854
- return ok(credentialVerificationResult.value);
1871
+ const verificationResult = credentialVerificationResult.value;
1872
+ return ok({
1873
+ result: isType(PresentationSessionResultValidator)(verificationResult) ? verificationResult : undefined,
1874
+ sessionId: sessionId
1875
+ });
1855
1876
  };
1856
1877
  const getCredentials = async (request, abortController) => {
1857
1878
  try {