Skip to content

Replace deprecated Dictionary with ConfigStore and SecretStore in context.env #80

@trieloff

Description

@trieloff

Background

PR #77 introduced unified environment/geo/device APIs. Comment #77 (comment) identified that context.env uses the deprecated Dictionary API.

Current Implementation

src/template/fastly-adapter.js:74 creates context.env using:

context.env: new Proxy(new Dictionary('secrets'), {
  get: (target, prop) => {
    try {
      return target.get(prop);
    } catch {
      // fallback to package params fetch
    }
  }
})

Required Changes

Replace Dictionary with modern Fastly APIs:

For secrets:

import { SecretStore } from 'fastly:secret-store';
const secrets = new SecretStore('secrets');
const value = await secrets.get('key');
const plaintext = value.plaintext();

For config:

import { ConfigStore } from 'fastly:config-store';
const config = new ConfigStore('config');
const value = config.get('key');

Implementation Notes

  • SecretStore.get() is async, returns object with plaintext() method
  • ConfigStore.get() is sync, returns string directly
  • Update Proxy handler to handle async secret retrieval
  • Both require resource link names matching Fastly service config
  • Only available during request processing, not at build-time

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions