Re: [community-group] How to define a token that references a local file? (#132)

`"$type": "file"` makes sense to me for a File token.

## My Concern
My biggest concern with the definition is that someone will eventually have a need to centralize assets on a public CDN or via an API.

### CDN
In the CDN case, the File token would be a [valid URL][url-spec], given that most of the time you _don't_ want to restrict access to files on a CDN.

```json
{
  "icons": {
    "$type": "file",
    "alert": {
      "$value": "https://cdn.foobar.com/icons/alert.svg"
    },
    "bookmark": {
      "$value": "https://cdn.foobar.com/icons/bookmark.svg"
    }
  }
}
```

### API
A file path _could_ be defined as an API path (e.g., `/icons/alert.svg`), which isn't technically a valid file path or URL, but for many cases this can be mitigated by defining File tokens as URLs to an API endpoint (e.g., `https://api.foobar.com/icons/alert.svg`).

It's possible that the API system may have access control strategies in place to restrict access to certain resources, but any access controls applied should be documented by the API itself (out of scope for the Design Tokens spec).

```json
{
  "icons": {
    "$type": "file",
    "alert": {
      "$value": "https://api.foobar.com/icons/alert.svg"
    },
    "bookmark": {
      "$value": "https://api.foobar.com/icons/bookmark.svg"
    }
  }
}
```



## My Recommendation
I'd recommend that File tokens be documented such that their value must satisfy one of the following conditions:

1. a relative path from the tokens JSON to a local asset (i.e., starts with `./` or `../`)
    * `"./foo.svg"`, `"../foo.svg"`, `"../foo/bar.svg"`
    * Best if providing design tokens as a package/bundle (e.g., ZIP, npm, etc.)
2. a valid URL (as defined by the [URL Living Standard][url-spec])
    * Best if providing design tokens as an API or if assets are provided via CDN.


[url-spec]: https://url.spec.whatwg.org/

-- 
GitHub Notification of comment by CITguy
Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/132#issuecomment-1185995569 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 15 July 2022 22:27:28 UTC