Sha256: e28969631451c3bdb4160d55b811aa78994c4f8c30472d717f09f7e5fdfa33e5

Contents?: true

Size: 613 Bytes

Versions: 1

Compression:

Stored size: 613 Bytes

Contents

'use strict';

let gcpMetadata = null;
/** @ignore */
async function loadGCPCredentials(kmsProviders) {
  if (gcpMetadata == null) {
    try {
      // Ensure you always wrap an optional require in the try block NODE-3199
      gcpMetadata = require('gcp-metadata');
      // eslint-disable-next-line no-empty
    } catch {}
  }

  if (gcpMetadata != null) {
    const { access_token: accessToken } = await gcpMetadata.instance({
      property: 'service-accounts/default/token'
    });
    return { ...kmsProviders, gcp: { accessToken } };
  }

  return kmsProviders;
}

module.exports = { loadGCPCredentials };

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
libmongocrypt-helper-1.8.0.0.1001 ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js