@opensecret/react 0.1.8 → 0.2.0

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.
package/dist/index.d.ts CHANGED
@@ -78,15 +78,15 @@ declare const AttestationDocumentSchema: z.ZodObject<{
78
78
  nonce: Uint8Array | null;
79
79
  }>;
80
80
 
81
- export declare function authenticate(attestationDocumentBase64: string, trustedRootCert: Uint8Array, nonce: string): Promise<AttestationDocument>;
81
+ declare function authenticate(attestationDocumentBase64: string, trustedRootCert: Uint8Array, nonce: string): Promise<AttestationDocument>;
82
82
 
83
- export declare const AWS_ROOT_CERT_DER: Uint8Array;
83
+ declare const AWS_ROOT_CERT_DER: Uint8Array;
84
84
 
85
85
  declare function changePassword(currentPassword: string, newPassword: string): Promise<void>;
86
86
 
87
87
  declare function confirmPasswordReset(email: string, alphanumericCode: string, plaintextSecret: string, newPassword: string): Promise<void>;
88
88
 
89
- export declare const EXPECTED_ROOT_CERT_HASH = "641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";
89
+ declare const EXPECTED_ROOT_CERT_HASH = "641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";
90
90
 
91
91
  declare function fetchAttestationDocument(nonce: string): Promise<string>;
92
92
 
@@ -112,7 +112,7 @@ declare function fetchUser(): Promise<UserResponse>;
112
112
 
113
113
  export declare function generateSecureSecret(): string;
114
114
 
115
- export declare function getAttestation(forceRefresh?: boolean): Promise<Attestation>;
115
+ declare function getAttestation(forceRefresh?: boolean): Promise<Attestation>;
116
116
 
117
117
  export declare type GithubAuthResponse = {
118
118
  auth_url: string;
@@ -315,6 +315,42 @@ export declare type OpenSecretContextType = {
315
315
  * @returns The current API URL
316
316
  */
317
317
  apiUrl: string;
318
+ /**
319
+ * Additional PCR0 hashes to validate against
320
+ */
321
+ pcrConfig: PcrConfig;
322
+ /**
323
+ * Gets attestation from the enclave
324
+ */
325
+ getAttestation: typeof getAttestation;
326
+ /**
327
+ * Authenticates an attestation document
328
+ */
329
+ authenticate: typeof authenticate;
330
+ /**
331
+ * Parses an attestation document for viewing
332
+ */
333
+ parseAttestationForView: (document: AttestationDocument, cabundle: Uint8Array[], pcrConfig?: PcrConfig) => Promise<ParsedAttestationView>;
334
+ /**
335
+ * AWS root certificate in DER format
336
+ */
337
+ awsRootCertDer: typeof AWS_ROOT_CERT_DER;
338
+ /**
339
+ * Expected hash of the AWS root certificate
340
+ */
341
+ expectedRootCertHash: typeof EXPECTED_ROOT_CERT_HASH;
342
+ /**
343
+ * Gets and verifies an attestation document from the enclave
344
+ * @returns A promise resolving to the parsed attestation document
345
+ * @throws {Error} If attestation fails or is invalid
346
+ *
347
+ * @description
348
+ * This is a convenience function that:
349
+ * 1. Fetches the attestation document with a random nonce
350
+ * 2. Authenticates the document
351
+ * 3. Parses it for viewing
352
+ */
353
+ getAttestationDocument: () => Promise<ParsedAttestationView>;
318
354
  };
319
355
 
320
356
  /**
@@ -337,13 +373,12 @@ export declare type OpenSecretContextType = {
337
373
  * </OpenSecretProvider>
338
374
  * ```
339
375
  */
340
- export declare function OpenSecretProvider({ children, apiUrl }: {
376
+ export declare function OpenSecretProvider({ children, apiUrl, pcrConfig }: {
341
377
  children: default_2.ReactNode;
342
378
  apiUrl: string;
379
+ pcrConfig?: PcrConfig;
343
380
  }): JSX_2.Element;
344
381
 
345
- export declare function parseAttestationForView(document: AttestationDocument, cabundle: Uint8Array[]): Promise<ParsedAttestationView>;
346
-
347
382
  export declare type ParsedAttestationView = {
348
383
  moduleId: string;
349
384
  publicKey: string | null;
@@ -363,6 +398,17 @@ export declare type ParsedAttestationView = {
363
398
  userData: string | null;
364
399
  nonce: string | null;
365
400
  cert0hash: string;
401
+ validatedPcr0Hash: Pcr0ValidationResult | null;
402
+ };
403
+
404
+ export declare type Pcr0ValidationResult = {
405
+ isMatch: boolean;
406
+ text: string;
407
+ };
408
+
409
+ export declare type PcrConfig = {
410
+ pcr0Values?: string[];
411
+ pcr0DevValues?: string[];
366
412
  };
367
413
 
368
414
  declare type PrivateKeyResponse = {
@@ -385,7 +431,7 @@ declare function requestNewVerificationCode(): Promise<void>;
385
431
 
386
432
  declare function requestPasswordReset(email: string, hashedSecret: string): Promise<void>;
387
433
 
388
- export declare function setApiUrl(url: string): void;
434
+ declare function setApiUrl(url: string): void;
389
435
 
390
436
  declare type SigningAlgorithm = "schnorr" | "ecdsa";
391
437
 
@@ -410,10 +456,6 @@ export declare type UserResponse = {
410
456
  };
411
457
  };
412
458
 
413
- export declare const VALID_PCR0_VALUES: string[];
414
-
415
- export declare const VALID_PCR0_VALUES_DEV: string[];
416
-
417
459
  declare function verifyEmail(code: string): Promise<void>;
418
460
 
419
461
  export { }