@xescure/keeta-utils 0.0.0-stage → 0.1.1

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.
Files changed (59) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +6 -2
  3. package/dist/identity/account.d.ts +22 -0
  4. package/dist/identity/account.d.ts.map +1 -0
  5. package/dist/identity/account.js +64 -0
  6. package/dist/identity/account.js.map +1 -0
  7. package/dist/identity/assert-never.d.ts +2 -0
  8. package/dist/identity/assert-never.d.ts.map +1 -0
  9. package/dist/identity/assert-never.js +4 -0
  10. package/dist/identity/assert-never.js.map +1 -0
  11. package/dist/identity/drivers.d.ts +99 -0
  12. package/dist/identity/drivers.d.ts.map +1 -0
  13. package/dist/identity/drivers.js +65 -0
  14. package/dist/identity/drivers.js.map +1 -0
  15. package/dist/identity/env.d.ts +7 -0
  16. package/dist/identity/env.d.ts.map +1 -0
  17. package/dist/identity/env.js +29 -0
  18. package/dist/identity/env.js.map +1 -0
  19. package/dist/identity/environment.d.ts +14 -0
  20. package/dist/identity/environment.d.ts.map +1 -0
  21. package/dist/identity/environment.js +31 -0
  22. package/dist/identity/environment.js.map +1 -0
  23. package/dist/identity/error.d.ts +35 -0
  24. package/dist/identity/error.d.ts.map +1 -0
  25. package/dist/identity/error.js +65 -0
  26. package/dist/identity/error.js.map +1 -0
  27. package/dist/identity/files.d.ts +13 -0
  28. package/dist/identity/files.d.ts.map +1 -0
  29. package/dist/identity/files.js +93 -0
  30. package/dist/identity/files.js.map +1 -0
  31. package/dist/identity/index.d.ts +17 -0
  32. package/dist/identity/index.d.ts.map +1 -0
  33. package/dist/identity/index.js +11 -0
  34. package/dist/identity/index.js.map +1 -0
  35. package/dist/identity/keyref.d.ts +55 -0
  36. package/dist/identity/keyref.d.ts.map +1 -0
  37. package/dist/identity/keyref.js +213 -0
  38. package/dist/identity/keyref.js.map +1 -0
  39. package/dist/identity/load.d.ts +38 -0
  40. package/dist/identity/load.d.ts.map +1 -0
  41. package/dist/identity/load.js +167 -0
  42. package/dist/identity/load.js.map +1 -0
  43. package/dist/identity/material.d.ts +19 -0
  44. package/dist/identity/material.d.ts.map +1 -0
  45. package/dist/identity/material.js +34 -0
  46. package/dist/identity/material.js.map +1 -0
  47. package/dist/identity/rules.d.ts +56 -0
  48. package/dist/identity/rules.d.ts.map +1 -0
  49. package/dist/identity/rules.js +184 -0
  50. package/dist/identity/rules.js.map +1 -0
  51. package/dist/identity/schema.d.ts +131 -0
  52. package/dist/identity/schema.d.ts.map +1 -0
  53. package/dist/identity/schema.js +117 -0
  54. package/dist/identity/schema.js.map +1 -0
  55. package/dist/index.d.ts +2 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +2 -0
  58. package/dist/index.js.map +1 -0
  59. package/package.json +46 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drivers.js","sourceRoot":"","sources":["../../src/identity/drivers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAInD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAU,CAAC;AAmFrE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAU,CAAC;AAGpE,MAAM,CAAC,MAAM,gBAAgB,GAAc,MAAM,CAAC;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAiB,WAAW,CAAC;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAE9B;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAyD;IACjF,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC;IAChC,UAAU,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC;IACtC,MAAM,EAAE,CAAC,QAAQ,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,iBAA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AC,MAAM,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,QAAQ,EAAE,kCAAkC,CAAC,CAAC,CAAC;YACrF,SAAS;QACV,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IACD,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAElC,OAAM,CAAC;QACN,MAAM,EAAE,UAAS,MAAM;YACtB,OAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,EAAE;YACR,OAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACrC,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { SourceDriver } from './drivers.js';
2
+ /**
3
+ * `env:NAME`: the key bytes are the value of the variable `NAME` in the
4
+ * environment given to the loader. An empty variable is unset.
5
+ */
6
+ export declare function environmentSource(): SourceDriver;
7
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/identity/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,cAAc,CAAC;AAMhE;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,CAqBhD"}
@@ -0,0 +1,29 @@
1
+ import { issue, KeyConfigError } from './error.js';
2
+ const variableNamePattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
3
+ /**
4
+ * `env:NAME`: the key bytes are the value of the variable `NAME` in the
5
+ * environment given to the loader. An empty variable is unset.
6
+ */
7
+ export function environmentSource() {
8
+ return ({
9
+ kind: 'source',
10
+ scheme: 'env',
11
+ checkBody: function (body) {
12
+ if (!variableNamePattern.test(body)) {
13
+ return ('the body must be an environment variable name, [A-Za-z_][A-Za-z0-9_]*');
14
+ }
15
+ return (undefined);
16
+ },
17
+ readsVariables: function (ref) {
18
+ return ([ref.body]);
19
+ },
20
+ read: async function (ref, context) {
21
+ const value = context.env[ref.body];
22
+ if (value === undefined || value === '') {
23
+ throw (new KeyConfigError([issue('READ_FAILED', `env:${ref.body}`, `${ref.body} is not set`)]));
24
+ }
25
+ return (new TextEncoder().encode(value));
26
+ }
27
+ });
28
+ }
29
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/identity/env.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGnD,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAChC,OAAM,CAAC;QACN,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,UAAS,IAAY;YAC/B,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrC,OAAM,CAAC,uEAAuE,CAAC,CAAC;YACjF,CAAC;YACD,OAAM,CAAC,SAAS,CAAC,CAAC;QACnB,CAAC;QACD,cAAc,EAAE,UAAS,GAAiB;YACzC,OAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACpB,CAAC;QACD,IAAI,EAAE,KAAK,WAAU,GAAiB,EAAE,OAAsB;YAC7D,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;gBACzC,MAAK,CAAC,IAAI,cAAc,CAAC,CAAC,KAAK,CAAC,aAAa,EAAE,OAAO,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,GAAG,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;YAChG,CAAC;YACD,OAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACzC,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Environment } from './drivers.js';
2
+ import type { ConfigText, KeySpec } from './schema.js';
3
+ /**
4
+ * An actor `anchor` reads `ANCHOR_SIGNER`, `ANCHOR_ACCOUNT`,
5
+ * `ANCHOR_FEE_PAYER`, `ANCHOR_FEE_ACCOUNT` and `ANCHOR_NETWORK`, as far as it
6
+ * declares them; any other role reads its prefix alone. Only declared
7
+ * variables are read, and an empty one is unset.
8
+ */
9
+ export declare function decodeEnvironment(spec: KeySpec, env: Environment): ConfigText;
10
+ /**
11
+ * The inverse of `decodeEnvironment`.
12
+ */
13
+ export declare function encodeEnvironment(spec: KeySpec, config: ConfigText): Record<string, string>;
14
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/identity/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,UAAU,CAS7E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAS3F"}
@@ -0,0 +1,31 @@
1
+ import { fieldsOf } from './schema.js';
2
+ /**
3
+ * An actor `anchor` reads `ANCHOR_SIGNER`, `ANCHOR_ACCOUNT`,
4
+ * `ANCHOR_FEE_PAYER`, `ANCHOR_FEE_ACCOUNT` and `ANCHOR_NETWORK`, as far as it
5
+ * declares them; any other role reads its prefix alone. Only declared
6
+ * variables are read, and an empty one is unset.
7
+ */
8
+ export function decodeEnvironment(spec, env) {
9
+ const config = {};
10
+ for (const field of fieldsOf(spec)) {
11
+ const value = env[field.variable];
12
+ if (value !== undefined && value !== '') {
13
+ config[field.path] = value;
14
+ }
15
+ }
16
+ return (config);
17
+ }
18
+ /**
19
+ * The inverse of `decodeEnvironment`.
20
+ */
21
+ export function encodeEnvironment(spec, config) {
22
+ const env = {};
23
+ for (const field of fieldsOf(spec)) {
24
+ const value = config[field.path];
25
+ if (value !== undefined) {
26
+ env[field.variable] = value;
27
+ }
28
+ }
29
+ return (env);
30
+ }
31
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/identity/environment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa,EAAE,GAAgB;IAChE,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;YACzC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC5B,CAAC;IACF,CAAC;IACD,OAAM,CAAC,MAAM,CAAC,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa,EAAE,MAAkB;IAClE,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAC7B,CAAC;IACF,CAAC;IACD,OAAM,CAAC,GAAG,CAAC,CAAC;AACb,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The base of the library's errors. Errors are recognized by a type ID rather
3
+ * than by `instanceof`, which fails when two copies of the library are loaded.
4
+ */
5
+ export declare abstract class TypedError extends Error {
6
+ protected constructor(typeID: string, message: string);
7
+ protected static hasTypeID(value: unknown, typeID: string): boolean;
8
+ }
9
+ export type KeyConfigIssueCode = 'KEYREF_SYNTAX' | 'UNKNOWN_SCHEME' | 'UNKNOWN_PARAM' | 'REPEATED_PARAM' | 'INVALID_PARAM' | 'PARAM_NOT_ALLOWED' | 'INVALID_BODY' | 'INVALID_ADDRESS' | 'KEY_MATERIAL_AS_REF' | 'DUPLICATE_DRIVER' | 'INVALID_DRIVER' | 'INVALID_SCHEMA' | 'SIGNER_IN_PUBLIC_POSITION' | 'MATERIAL_IN_PUBLIC_POSITION' | 'SIGNER_REQUIRED' | 'EXPECT_REQUIRED' | 'INTERACTIVE_FORBIDDEN' | 'PURPOSE_UNSUPPORTED' | 'ALGORITHM_UNSUPPORTED' | 'EXPECT_MISMATCH' | 'UNKNOWN_VARIABLE' | 'MISSING_KEY' | 'INVALID_NETWORK' | 'INVALID_CONTENT' | 'READ_FAILED' | 'NO_CREDENTIALS_DIRECTORY';
10
+ export type KeyConfigErrorCode = KeyConfigIssueCode | 'INVALID_KEY_CONFIGURATION';
11
+ /**
12
+ * One problem with a key configuration. `location` is the variable (or ref)
13
+ * the value came from and `role` the schema path, such as `anchor.signer`.
14
+ * No field ever contains a value that failed to parse or any key material.
15
+ */
16
+ export interface KeyConfigIssue {
17
+ readonly code: KeyConfigIssueCode;
18
+ readonly location: string;
19
+ readonly role?: string;
20
+ readonly message: string;
21
+ }
22
+ export declare class KeyConfigError extends TypedError {
23
+ #private;
24
+ readonly name = "KeyConfigError";
25
+ readonly code: KeyConfigErrorCode;
26
+ readonly issues: readonly KeyConfigIssue[];
27
+ constructor(issues: readonly [KeyConfigIssue, ...KeyConfigIssue[]]);
28
+ static isInstance(value: unknown): value is KeyConfigError;
29
+ /**
30
+ * Throws one error that carries every issue, if there are any.
31
+ */
32
+ static throwIfAny(issues: readonly KeyConfigIssue[]): void;
33
+ }
34
+ export declare function issue(code: KeyConfigIssueCode, location: string, message: string, role?: string): KeyConfigIssue;
35
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/identity/error.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,8BAAsB,UAAW,SAAQ,KAAK;IAC7C,SAAS,aAAa,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAGpD;IAED,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKlE;CACD;AAED,MAAM,MAAM,kBAAkB,GAC3B,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,mBAAmB,GACnB,cAAc,GACd,iBAAiB,GACjB,qBAAqB,GACrB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,2BAA2B,GAC3B,6BAA6B,GAC7B,iBAAiB,GACjB,iBAAiB,GACjB,uBAAuB,GACvB,qBAAqB,GACrB,uBAAuB,GACvB,iBAAiB,GACjB,kBAAkB,GAClB,aAAa,GACb,iBAAiB,GACjB,iBAAiB,GACjB,aAAa,GACb,0BAA0B,CAAC;AAE9B,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG,2BAA2B,CAAC;AAElF;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,cAAe,SAAQ,UAAU;;IAG7C,SAAkB,IAAI,oBAAoB;IAC1C,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAE3C,YAAY,MAAM,EAAE,SAAS,CAAC,cAAc,EAAE,GAAG,cAAc,EAAE,CAAC,EAQjE;IAED,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAEzD;IAED;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,IAAI,CAKzD;CAeD;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAKhH"}
@@ -0,0 +1,65 @@
1
+ const typeIDProperty = Symbol.for('@xescure/keeta-utils/typeID');
2
+ /**
3
+ * The base of the library's errors. Errors are recognized by a type ID rather
4
+ * than by `instanceof`, which fails when two copies of the library are loaded.
5
+ */
6
+ export class TypedError extends Error {
7
+ constructor(typeID, message) {
8
+ super(message);
9
+ Object.defineProperty(this, typeIDProperty, { value: typeID });
10
+ }
11
+ static hasTypeID(value, typeID) {
12
+ if (typeof value !== 'object' || value === null) {
13
+ return (false);
14
+ }
15
+ return (Reflect.get(value, typeIDProperty) === typeID);
16
+ }
17
+ }
18
+ export class KeyConfigError extends TypedError {
19
+ static #typeID = 'KeyConfigError:2b0f6c1e-4f7a-4d1b-9a0e-6f3c8d5e7a21';
20
+ name = 'KeyConfigError';
21
+ code;
22
+ issues;
23
+ constructor(issues) {
24
+ super(KeyConfigError.#typeID, KeyConfigError.#describe(issues));
25
+ this.issues = issues;
26
+ if (issues.length === 1) {
27
+ this.code = issues[0].code;
28
+ }
29
+ else {
30
+ this.code = 'INVALID_KEY_CONFIGURATION';
31
+ }
32
+ }
33
+ static isInstance(value) {
34
+ return (TypedError.hasTypeID(value, KeyConfigError.#typeID));
35
+ }
36
+ /**
37
+ * Throws one error that carries every issue, if there are any.
38
+ */
39
+ static throwIfAny(issues) {
40
+ const [first, ...rest] = issues;
41
+ if (first !== undefined) {
42
+ throw (new KeyConfigError([first, ...rest]));
43
+ }
44
+ }
45
+ static #describe(issues) {
46
+ const lines = issues.map(function (found) {
47
+ let where = found.location;
48
+ if (found.role !== undefined) {
49
+ where = `${found.location} (${found.role})`;
50
+ }
51
+ return (`${where}: ${found.message} [${found.code}]`);
52
+ });
53
+ if (lines.length === 1) {
54
+ return (lines.join(''));
55
+ }
56
+ return (`${lines.length} key configuration errors:\n${lines.join('\n')}`);
57
+ }
58
+ }
59
+ export function issue(code, location, message, role) {
60
+ if (role === undefined) {
61
+ return ({ code, location, message });
62
+ }
63
+ return ({ code, location, role, message });
64
+ }
65
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/identity/error.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAkB,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAEhF;;;GAGG;AACH,MAAM,OAAgB,UAAW,SAAQ,KAAK;IAC7C,YAAsB,MAAc,EAAE,OAAe;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;IAES,MAAM,CAAC,SAAS,CAAC,KAAc,EAAE,MAAc;QACxD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACj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YAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC9B,KAAK,GAAG,GAAG,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,IAAI,GAAG,CAAC;YAC7C,CAAC;YACD,OAAM,CAAC,GAAG,KAAK,KAAK,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;QACH,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACxB,CAAC;QACD,OAAM,CAAC,GAAG,KAAK,CAAC,MAAM,+BAA+B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;CACD;AAED,MAAM,UAAU,KAAK,CAAC,IAAwB,EAAE,QAAgB,EAAE,OAAe,EAAE,IAAa;IAC/F,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;IACD,OAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { SourceDriver } from './drivers.js';
2
+ /**
3
+ * `file:/absolute/path`: the key bytes are the contents of a file, such as a
4
+ * Docker or Kubernetes secret. `file:///x` is accepted and written `file:/x`.
5
+ */
6
+ export declare function fileSource(): SourceDriver;
7
+ /**
8
+ * `cred:NAME`: the key bytes are the systemd credential `NAME`, the file
9
+ * `$CREDENTIALS_DIRECTORY/NAME` that `LoadCredential=` provides. Without
10
+ * that directory there is no fallback.
11
+ */
12
+ export declare function credentialSource(): SourceDriver;
13
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/identity/files.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,cAAc,CAAC;AA0ChE;;;GAGG;AACH,wBAAgB,UAAU,IAAI,YAAY,CAuBzC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAsB/C"}
@@ -0,0 +1,93 @@
1
+ import { join } from 'node:path';
2
+ import { issue, KeyConfigError } from './error.js';
3
+ const credentialNamePattern = /^[A-Za-z0-9_-][A-Za-z0-9_.-]*$/;
4
+ const credentialsDirectory = 'CREDENTIALS_DIRECTORY';
5
+ function fail(location, message, code = 'READ_FAILED') {
6
+ throw (new KeyConfigError([issue(code, location, message)]));
7
+ }
8
+ /**
9
+ * Reads a whole file; a failure names the location and the file, never its
10
+ * content.
11
+ */
12
+ async function readKeyFile(path, location, context) {
13
+ let bytes;
14
+ try {
15
+ bytes = await context.readFile(path);
16
+ }
17
+ catch (error) {
18
+ if (typeof error === 'object' && error !== null && Reflect.get(error, 'code') === 'ENOENT') {
19
+ return (fail(location, `${path} does not exist`));
20
+ }
21
+ return (fail(location, `${path} cannot be read`));
22
+ }
23
+ if (bytes.length === 0) {
24
+ return (fail(location, `${path} is empty`));
25
+ }
26
+ return (bytes);
27
+ }
28
+ /**
29
+ * The absolute path of a `file:` body: `/x`, or `///x` with an empty host.
30
+ */
31
+ function filePath(body) {
32
+ if (body.startsWith('///')) {
33
+ return (body.slice(2));
34
+ }
35
+ return (body);
36
+ }
37
+ /**
38
+ * `file:/absolute/path`: the key bytes are the contents of a file, such as a
39
+ * Docker or Kubernetes secret. `file:///x` is accepted and written `file:/x`.
40
+ */
41
+ export function fileSource() {
42
+ return ({
43
+ kind: 'source',
44
+ scheme: 'file',
45
+ checkBody: function (body) {
46
+ const path = filePath(body);
47
+ if (!path.startsWith('/') || path.startsWith('//')) {
48
+ return ('the body must be an absolute path, /x or ///x');
49
+ }
50
+ const segments = path.slice(1).split('/');
51
+ const plain = segments.every(function (segment) {
52
+ return (segment !== '' && segment !== '.' && segment !== '..');
53
+ });
54
+ if (!plain) {
55
+ return ('the path must not have empty, "." or ".." segments, or a trailing "/"');
56
+ }
57
+ return (undefined);
58
+ },
59
+ canonicalBody: filePath,
60
+ read: async function (ref, context) {
61
+ return (readKeyFile(ref.body, `file:${ref.body}`, context));
62
+ }
63
+ });
64
+ }
65
+ /**
66
+ * `cred:NAME`: the key bytes are the systemd credential `NAME`, the file
67
+ * `$CREDENTIALS_DIRECTORY/NAME` that `LoadCredential=` provides. Without
68
+ * that directory there is no fallback.
69
+ */
70
+ export function credentialSource() {
71
+ return ({
72
+ kind: 'source',
73
+ scheme: 'cred',
74
+ checkBody: function (body) {
75
+ if (body.length > 255 || !credentialNamePattern.test(body) || body.includes('..')) {
76
+ return ('the body must be a credential file name, [A-Za-z0-9_.-]+, without a leading "." or "..", at most 255 characters');
77
+ }
78
+ return (undefined);
79
+ },
80
+ readsVariables: function () {
81
+ return ([credentialsDirectory]);
82
+ },
83
+ read: async function (ref, context) {
84
+ const location = `cred:${ref.body}`;
85
+ const directory = context.env[credentialsDirectory];
86
+ if (directory === undefined || directory === '') {
87
+ return (fail(location, `${credentialsDirectory} is not set: the process is not running with systemd credentials`, 'NO_CREDENTIALS_DIRECTORY'));
88
+ }
89
+ return (readKeyFile(join(directory, ref.body), location, context));
90
+ }
91
+ });
92
+ }
93
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/identity/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAInD,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AAC/D,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAErD,SAAS,IAAI,CAAC,QAAgB,EAAE,OAAe,EAAE,IAAI,GAAuB,aAAa;IACxF,MAAK,C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B,CAAC;QACD,cAAc,EAAE;YACf,OAAM,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,EAAE,KAAK,WAAU,GAAiB,EAAE,OAAsB;YAC7D,MAAM,QAAQ,GAAG,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;YACpC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YACpD,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC;gBACjD,OAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,oBAAoB,kEAAkE,EAAE,0BAA0B,CAAC,CAAC,CAAC;YAC/I,CAAC;YACD,OAAM,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QACnE,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ export { isNetwork, keyAlgorithms, parseAddress } from './account.js';
2
+ export type { Account, GenericAccount, KeyAlgorithm, Network } from './account.js';
3
+ export { assertNever } from './assert-never.js';
4
+ export { createDriverRegistry, defaultIndex, defaultKeyAlgorithm, defaultKeyFormat, formatParams, keyFormats, localCapabilities, purposes } from './drivers.js';
5
+ export type { Driver, DriverContext, DriverRegistry, Environment, KeyFormat, KeyParamName, ParamSchema, ParamValidator, Purpose, SignerCapabilities, SignerDriver, SourceDriver } from './drivers.js';
6
+ export { environmentSource } from './env.js';
7
+ export { credentialSource, fileSource } from './files.js';
8
+ export { decodeEnvironment, encodeEnvironment } from './environment.js';
9
+ export { KeyConfigError, TypedError } from './error.js';
10
+ export type { KeyConfigErrorCode, KeyConfigIssue, KeyConfigIssueCode } from './error.js';
11
+ export { formatKeyRef, maximumIndex, parseKeyRef, sharedParamNames } from './keyref.js';
12
+ export type { AddressKeyRef, DriverKeyRef, KeyRef } from './keyref.js';
13
+ export { createFeeBlockGenerator, loadKeys } from './load.js';
14
+ export type { FeeBlockClient, GenerateFeeBlock, LoadKeysOptions } from './load.js';
15
+ export { actor, defineKeys, network, publicAccount, screamingSnakeCase, signer } from './schema.js';
16
+ export type { ActorBlock, ActorOptions, Block, ConfigText, DefineKeysOptions, FeePayer, KeySpec, Loaded, LoadedActor, LoadedBlock, NetworkBlock, PublicAccountBlock, Roles, SignerBlock, SignerConstraints, SignerOptions } from './schema.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACtE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAChK,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACtM,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxF,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9D,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACpG,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ export { isNetwork, keyAlgorithms, parseAddress } from './account.js';
2
+ export { assertNever } from './assert-never.js';
3
+ export { createDriverRegistry, defaultIndex, defaultKeyAlgorithm, defaultKeyFormat, formatParams, keyFormats, localCapabilities, purposes } from './drivers.js';
4
+ export { environmentSource } from './env.js';
5
+ export { credentialSource, fileSource } from './files.js';
6
+ export { decodeEnvironment, encodeEnvironment } from './environment.js';
7
+ export { KeyConfigError, TypedError } from './error.js';
8
+ export { formatKeyRef, maximumIndex, parseKeyRef, sharedParamNames } from './keyref.js';
9
+ export { createFeeBlockGenerator, loadKeys } from './load.js';
10
+ export { actor, defineKeys, network, publicAccount, screamingSnakeCase, signer } from './schema.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEhK,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExF,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { KeyAlgorithm } from './account.js';
2
+ import type { DriverRegistry, KeyFormat } from './drivers.js';
3
+ import type { KeyConfigIssue } from './error.js';
4
+ /**
5
+ * A `keeta_` address: a public key or an identifier, never a signer.
6
+ */
7
+ export interface AddressKeyRef {
8
+ readonly kind: 'address';
9
+ readonly address: string;
10
+ }
11
+ /**
12
+ * `scheme:body#params`. Only the params written in the ref are present; a
13
+ * missing one takes its default when the key is loaded.
14
+ */
15
+ export interface DriverKeyRef {
16
+ readonly kind: 'driver';
17
+ readonly scheme: string;
18
+ readonly body: string;
19
+ readonly format?: KeyFormat;
20
+ readonly index?: number;
21
+ readonly alg?: KeyAlgorithm;
22
+ readonly expect?: string;
23
+ /**
24
+ * The driver's own params.
25
+ */
26
+ readonly params: Readonly<Record<string, string>>;
27
+ }
28
+ export type KeyRef = AddressKeyRef | DriverKeyRef;
29
+ export declare const sharedParamNames: readonly ['format', 'index', 'alg', 'expect'];
30
+ export declare const maximumIndex: number;
31
+ type Issues = readonly [KeyConfigIssue, ...KeyConfigIssue[]];
32
+ export type KeyRefReading = {
33
+ readonly ref: KeyRef;
34
+ readonly issues: readonly [];
35
+ } | {
36
+ readonly ref: undefined;
37
+ readonly issues: Issues;
38
+ };
39
+ /**
40
+ * Parses a ref and reports every problem with it. No issue ever contains the
41
+ * text, or any part of it: a value that fails to parse may be a secret.
42
+ */
43
+ export declare function readKeyRef(text: string, registry: DriverRegistry, location: string, role?: string): KeyRefReading;
44
+ /**
45
+ * Parses a ref, throwing a `KeyConfigError` with every problem found.
46
+ */
47
+ export declare function parseKeyRef(text: string, registry: DriverRegistry, location?: string): KeyRef;
48
+ /**
49
+ * The canonical form: the body as written, then the params present in the
50
+ * order format, index, alg, expect, then the driver's own params by name,
51
+ * encoded by `URLSearchParams`.
52
+ */
53
+ export declare function formatKeyRef(ref: KeyRef): string;
54
+ export {};
55
+ //# sourceMappingURL=keyref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyref.d.ts","sourceRoot":"","sources":["../../src/identity/keyref.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAU,cAAc,EAAE,SAAS,EAAgB,MAAM,cAAc,CAAC;AAEpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,Q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