@microsoft/ccf-app 4.0.0-dev3 → 4.0.0-dev5

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/crypto.d.ts CHANGED
@@ -57,9 +57,33 @@ export declare const rsaPemToJwk: (pem: string, kid?: string | undefined) => imp
57
57
  /**
58
58
  * @inheritDoc global!CCFCrypto.pubEddsaPemToJwk
59
59
  */
60
- export declare const pubEddsaPemToJwk: (pem: string, kid?: string | undefined) => import("./global.js").JsonWebKeyEdDSAPrivate;
60
+ export declare const pubEddsaPemToJwk: (pem: string, kid?: string | undefined) => import("./global.js").JsonWebKeyEdDSAPublic;
61
61
  /**
62
62
  * @inheritDoc global!CCFCrypto.eddsaPemToJwk
63
63
  */
64
64
  export declare const eddsaPemToJwk: (pem: string, kid?: string | undefined) => import("./global.js").JsonWebKeyEdDSAPrivate;
65
+ /**
66
+ * @inheritDoc global!CCFCrypto.pubJwkToPem
67
+ */
68
+ export declare const pubJwkToPem: (jwk: import("./global.js").JsonWebKeyECPublic) => string;
69
+ /**
70
+ * @inheritDoc global!CCFCrypto.JwkToPem
71
+ */
72
+ export declare const jwkToPem: (jwk: import("./global.js").JsonWebKeyECPrivate) => string;
73
+ /**
74
+ * @inheritDoc global!CCFCrypto.pubRsaJwkToPem
75
+ */
76
+ export declare const pubRsaJwkToPem: (jwk: import("./global.js").JsonWebKeyRSAPublic) => string;
77
+ /**
78
+ * @inheritDoc global!CCFCrypto.rsaJwkToPem
79
+ */
80
+ export declare const rsaJwkToPem: (jwk: import("./global.js").JsonWebKeyRSAPrivate) => string;
81
+ /**
82
+ * @inheritDoc global!CCFCrypto.pubEddsaJwkToPem
83
+ */
84
+ export declare const pubEddsaJwkToPem: (jwk: import("./global.js").JsonWebKeyEdDSAPublic) => string;
85
+ /**
86
+ * @inheritDoc global!CCFCrypto.eddsaJwkToPem
87
+ */
88
+ export declare const eddsaJwkToPem: (jwk: import("./global.js").JsonWebKeyEdDSAPrivate) => string;
65
89
  export { WrapAlgoParams, AesKwpParams, RsaOaepParams, RsaOaepAesKwpParams, CryptoKeyPair, DigestAlgorithm, SigningAlgorithm, } from "./global";
package/crypto.js CHANGED
@@ -78,3 +78,27 @@ export const pubEddsaPemToJwk = ccf.crypto.pubEddsaPemToJwk;
78
78
  * @inheritDoc global!CCFCrypto.eddsaPemToJwk
79
79
  */
80
80
  export const eddsaPemToJwk = ccf.crypto.eddsaPemToJwk;
81
+ /**
82
+ * @inheritDoc global!CCFCrypto.pubJwkToPem
83
+ */
84
+ export const pubJwkToPem = ccf.crypto.pubJwkToPem;
85
+ /**
86
+ * @inheritDoc global!CCFCrypto.JwkToPem
87
+ */
88
+ export const jwkToPem = ccf.crypto.jwkToPem;
89
+ /**
90
+ * @inheritDoc global!CCFCrypto.pubRsaJwkToPem
91
+ */
92
+ export const pubRsaJwkToPem = ccf.crypto.pubRsaJwkToPem;
93
+ /**
94
+ * @inheritDoc global!CCFCrypto.rsaJwkToPem
95
+ */
96
+ export const rsaJwkToPem = ccf.crypto.rsaJwkToPem;
97
+ /**
98
+ * @inheritDoc global!CCFCrypto.pubEddsaJwkToPem
99
+ */
100
+ export const pubEddsaJwkToPem = ccf.crypto.pubEddsaJwkToPem;
101
+ /**
102
+ * @inheritDoc global!CCFCrypto.eddsaJwkToPem
103
+ */
104
+ export const eddsaJwkToPem = ccf.crypto.eddsaJwkToPem;
package/global.d.ts CHANGED
@@ -360,7 +360,7 @@ export interface CCFCrypto {
360
360
  * @param pem EdDSA public key as PEM
361
361
  * @param kid Key identifier (optional)
362
362
  */
363
- pubEddsaPemToJwk(pem: string, kid?: string): JsonWebKeyEdDSAPrivate;
363
+ pubEddsaPemToJwk(pem: string, kid?: string): JsonWebKeyEdDSAPublic;
364
364
  /**
365
365
  * Converts an EdDSA private key as PEM to JSON Web Key (JWK) object.
366
366
  * Currently only Curve25519 is supported.
@@ -369,6 +369,44 @@ export interface CCFCrypto {
369
369
  * @param kid Key identifier (optional)
370
370
  */
371
371
  eddsaPemToJwk(pem: string, kid?: string): JsonWebKeyEdDSAPrivate;
372
+ /**
373
+ * Converts an elliptic curve public key as JSON Web Key (JWK) object to PEM.
374
+ *
375
+ * @param jwk Elliptic curve public key as JWK
376
+ */
377
+ pubJwkToPem(jwk: JsonWebKeyECPublic): string;
378
+ /**
379
+ * Converts an elliptic curve private key as JSON Web Key (JWK) object to PEM.
380
+ *
381
+ * @param pem Elliptic curve private key as JWK
382
+ */
383
+ jwkToPem(jwk: JsonWebKeyECPrivate): string;
384
+ /**
385
+ * Converts an RSA public key as JSON Web Key (JWK) object to PEM.
386
+ *
387
+ * @param pem RSA public key as JWK
388
+ */
389
+ pubRsaJwkToPem(jwk: JsonWebKeyRSAPublic): string;
390
+ /**
391
+ * Converts an RSA private key as JSON Web Key (JWK) object to PEM.
392
+ *
393
+ * @param pem RSA private key as JWK
394
+ */
395
+ rsaJwkToPem(jwk: JsonWebKeyRSAPrivate): string;
396
+ /**
397
+ * Converts an EdDSA public key as JSON Web Key (JWK) object to PEM.
398
+ * Currently only Curve25519 is supported.
399
+ *
400
+ * @param pem EdDSA public key as JWK
401
+ */
402
+ pubEddsaJwkToPem(jwk: JsonWebKeyEdDSAPublic): string;
403
+ /**
404
+ * Converts an EdDSA private key as JSON Web Key (JWK) object to PEM.
405
+ * Currently only Curve25519 is supported.
406
+ *
407
+ * @param pem EdDSA private key as JWK
408
+ */
409
+ eddsaJwkToPem(jwk: JsonWebKeyEdDSAPrivate): string;
372
410
  }
373
411
  export interface CCFRpc {
374
412
  /**
@@ -521,6 +559,16 @@ export interface CCF {
521
559
  */
522
560
  historicalState?: HistoricalState;
523
561
  historical: CCFHistorical;
562
+ /**
563
+ * Toggles implementation of Date global API between using untrusted host time
564
+ * and returning 0 (default).
565
+ *
566
+ * Returns previous value, allowing a global default to be maintained.
567
+ *
568
+ * @param enable If true, then subsequent calls to Date.now() will return untrusted
569
+ * host time
570
+ */
571
+ enableUntrustedDateTime(enable: boolean): boolean;
524
572
  }
525
573
  export declare const openenclave: OpenEnclave;
526
574
  export interface EvidenceClaims {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/ccf-app",
3
- "version": "4.0.0-dev3",
3
+ "version": "4.0.0-dev5",
4
4
  "description": "CCF app support package",
5
5
  "main": "index.js",
6
6
  "files": [
package/polyfill.js CHANGED
@@ -325,13 +325,8 @@ class CCFPolyfill {
325
325
  const jwk = key.export({
326
326
  format: "jwk",
327
327
  });
328
- return {
329
- crv: jwk.crv,
330
- x: jwk.x,
331
- y: jwk.y,
332
- kty: jwk.kty,
333
- kid: kid,
334
- };
328
+ jwk.kid = kid;
329
+ return jwk;
335
330
  },
336
331
  pemToJwk(pem, kid) {
337
332
  const key = jscrypto.createPrivateKey({
@@ -340,14 +335,8 @@ class CCFPolyfill {
340
335
  const jwk = key.export({
341
336
  format: "jwk",
342
337
  });
343
- return {
344
- d: jwk.d,
345
- crv: jwk.crv,
346
- x: jwk.x,
347
- y: jwk.y,
348
- kty: jwk.kty,
349
- kid: kid,
350
- };
338
+ jwk.kid = kid;
339
+ return jwk;
351
340
  },
352
341
  pubRsaPemToJwk(pem, kid) {
353
342
  const key = jscrypto.createPublicKey({
@@ -356,12 +345,8 @@ class CCFPolyfill {
356
345
  const jwk = key.export({
357
346
  format: "jwk",
358
347
  });
359
- return {
360
- n: jwk.n,
361
- e: jwk.e,
362
- kty: jwk.kty,
363
- kid: kid,
364
- };
348
+ jwk.kid = kid;
349
+ return jwk;
365
350
  },
366
351
  rsaPemToJwk(pem, kid) {
367
352
  const key = jscrypto.createPrivateKey({
@@ -370,18 +355,8 @@ class CCFPolyfill {
370
355
  const jwk = key.export({
371
356
  format: "jwk",
372
357
  });
373
- return {
374
- d: jwk.d,
375
- p: jwk.p,
376
- q: jwk.d,
377
- dp: jwk.dp,
378
- dq: jwk.dq,
379
- qi: jwk.qi,
380
- n: jwk.n,
381
- e: jwk.e,
382
- kty: jwk.kty,
383
- kid: kid,
384
- };
358
+ jwk.kid = kid;
359
+ return jwk;
385
360
  },
386
361
  pubEddsaPemToJwk(pem, kid) {
387
362
  const key = jscrypto.createPublicKey({
@@ -390,12 +365,8 @@ class CCFPolyfill {
390
365
  const jwk = key.export({
391
366
  format: "jwk",
392
367
  });
393
- return {
394
- crv: jwk.crv,
395
- x: jwk.x,
396
- kty: jwk.kty,
397
- kid: kid,
398
- };
368
+ jwk.kid = kid;
369
+ return jwk;
399
370
  },
400
371
  eddsaPemToJwk(pem, kid) {
401
372
  const key = jscrypto.createPrivateKey({
@@ -404,13 +375,50 @@ class CCFPolyfill {
404
375
  const jwk = key.export({
405
376
  format: "jwk",
406
377
  });
407
- return {
408
- crv: jwk.crv,
409
- x: jwk.x,
410
- d: jwk.d,
411
- kty: jwk.kty,
412
- kid: kid,
413
- };
378
+ jwk.kid = kid;
379
+ return jwk;
380
+ },
381
+ pubJwkToPem(jwk) {
382
+ const key = jscrypto.createPublicKey({
383
+ key: jwk,
384
+ format: "jwk",
385
+ });
386
+ return key.export({ type: "spki", format: "pem" }).toString();
387
+ },
388
+ jwkToPem(jwk) {
389
+ const key = jscrypto.createPrivateKey({
390
+ key: jwk,
391
+ format: "jwk",
392
+ });
393
+ return key.export({ type: "pkcs8", format: "pem" }).toString();
394
+ },
395
+ pubRsaJwkToPem(jwk) {
396
+ const key = jscrypto.createPublicKey({
397
+ key: jwk,
398
+ format: "jwk",
399
+ });
400
+ return key.export({ type: "spki", format: "pem" }).toString();
401
+ },
402
+ rsaJwkToPem(jwk) {
403
+ const key = jscrypto.createPrivateKey({
404
+ key: jwk,
405
+ format: "jwk",
406
+ });
407
+ return key.export({ type: "pkcs8", format: "pem" }).toString();
408
+ },
409
+ pubEddsaJwkToPem(jwk) {
410
+ const key = jscrypto.createPublicKey({
411
+ key: jwk,
412
+ format: "jwk",
413
+ });
414
+ return key.export({ type: "spki", format: "pem" }).toString();
415
+ },
416
+ eddsaJwkToPem(jwk) {
417
+ const key = jscrypto.createPrivateKey({
418
+ key: jwk,
419
+ format: "jwk",
420
+ });
421
+ return key.export({ type: "pkcs8", format: "pem" }).toString();
414
422
  },
415
423
  };
416
424
  }
@@ -447,6 +455,9 @@ class CCFPolyfill {
447
455
  isValidX509CertChain(chain, trusted) {
448
456
  return this.crypto.isValidX509CertChain(chain, trusted);
449
457
  }
458
+ enableUntrustedDateTime(enable) {
459
+ throw new Error("Not implemented");
460
+ }
450
461
  }
451
462
  globalThis.ccf = new CCFPolyfill();
452
463
  class OpenEnclavePolyfill {