@koralabs/kora-labs-common 6.4.20 → 6.4.22

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.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadAfterHydratingKmsEnvironment = exports.hydrateKmsEnvironment = exports.decryptKmsCiphertext = void 0;
4
4
  const client_kms_1 = require("@aws-sdk/client-kms");
5
+ const KMS_ENV_BUNDLE_KEY = 'KMS_ENV_BUNDLE_ENC';
5
6
  async function decryptKmsCiphertext(ciphertext, client = new client_kms_1.KMSClient({})) {
6
7
  const response = await client.send(new client_kms_1.DecryptCommand({
7
8
  CiphertextBlob: Buffer.from(ciphertext, 'base64')
@@ -13,10 +14,35 @@ async function decryptKmsCiphertext(ciphertext, client = new client_kms_1.KMSCli
13
14
  }
14
15
  exports.decryptKmsCiphertext = decryptKmsCiphertext;
15
16
  async function hydrateKmsEnvironment({ env = process.env, client = new client_kms_1.KMSClient({}), keys } = {}) {
17
+ const hydratedKeys = [];
18
+ const bundleCiphertext = env[KMS_ENV_BUNDLE_KEY];
19
+ if (bundleCiphertext) {
20
+ const plaintext = await decryptKmsCiphertext(bundleCiphertext, client);
21
+ let bundle;
22
+ try {
23
+ bundle = JSON.parse(plaintext);
24
+ }
25
+ catch (_a) {
26
+ throw new Error('KMS env bundle plaintext must be a JSON object');
27
+ }
28
+ if (!bundle || typeof bundle !== 'object' || Array.isArray(bundle)) {
29
+ throw new Error('KMS env bundle plaintext must be a JSON object');
30
+ }
31
+ for (const key of Object.keys(bundle).sort()) {
32
+ if (env[key]) {
33
+ continue;
34
+ }
35
+ const value = bundle[key];
36
+ if (typeof value !== 'string') {
37
+ throw new Error(`KMS env bundle value for ${key} must be a string`);
38
+ }
39
+ env[key] = value;
40
+ hydratedKeys.push(key);
41
+ }
42
+ }
16
43
  const candidateKeys = (keys !== null && keys !== void 0 ? keys : Object.keys(env)
17
- .filter((key) => key.endsWith('_ENC'))
44
+ .filter((key) => key.endsWith('_ENC') && key !== KMS_ENV_BUNDLE_KEY)
18
45
  .map((key) => key.slice(0, -4))).sort();
19
- const hydratedKeys = [];
20
46
  for (const key of candidateKeys) {
21
47
  if (env[key]) {
22
48
  continue;
@@ -1,5 +1,6 @@
1
1
  import { BoolInt, FeaturedItemType, HexString, HexStringOrEmpty } from '../../types';
2
- import { UTxO, UTxOWithTxInfo } from '../UTxO';
2
+ import type { ScriptDetails } from './ScriptDetails';
3
+ import { UTxOWithTxInfo } from '../UTxO';
3
4
  export declare enum Rarity {
4
5
  basic = "basic",
5
6
  common = "common",
@@ -11,6 +12,20 @@ export interface SocialItem {
11
12
  display: string;
12
13
  url: string;
13
14
  }
15
+ export interface IUTxO {
16
+ id?: string;
17
+ tx_id: string;
18
+ index: number;
19
+ lovelace: number;
20
+ datum?: string;
21
+ address: string;
22
+ blockHash?: string;
23
+ blockNum?: number;
24
+ slot?: number;
25
+ script?: ScriptDetails;
26
+ }
27
+ export interface IReferenceToken extends IUTxO {
28
+ }
14
29
  interface ISharedPzDesigner {
15
30
  pfp_border_color?: HexStringOrEmpty;
16
31
  qr_inner_eye?: string;
@@ -123,7 +138,7 @@ export interface IHandle {
123
138
  pz_enabled?: boolean;
124
139
  }
125
140
  export interface ICip68Handle extends IHandle {
126
- reference_token?: UTxO;
141
+ reference_token?: IReferenceToken;
127
142
  reference_utxo?: string;
128
143
  }
129
144
  export interface IPersonalizedHandle extends ICip68Handle {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koralabs/kora-labs-common",
3
- "version": "6.4.20",
3
+ "version": "6.4.22",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",