@owlmeans/auth 0.1.0

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 (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +321 -0
  3. package/build/.gitkeep +0 -0
  4. package/build/allowance/index.d.ts +2 -0
  5. package/build/allowance/index.d.ts.map +1 -0
  6. package/build/allowance/index.js +2 -0
  7. package/build/allowance/index.js.map +1 -0
  8. package/build/allowance/model.d.ts +7 -0
  9. package/build/allowance/model.d.ts.map +1 -0
  10. package/build/allowance/model.js +57 -0
  11. package/build/allowance/model.js.map +1 -0
  12. package/build/auth/index.d.ts +2 -0
  13. package/build/auth/index.d.ts.map +1 -0
  14. package/build/auth/index.js +2 -0
  15. package/build/auth/index.js.map +1 -0
  16. package/build/auth/model.d.ts +8 -0
  17. package/build/auth/model.d.ts.map +1 -0
  18. package/build/auth/model.js +55 -0
  19. package/build/auth/model.js.map +1 -0
  20. package/build/consts.d.ts +69 -0
  21. package/build/consts.d.ts.map +1 -0
  22. package/build/consts.js +100 -0
  23. package/build/consts.js.map +1 -0
  24. package/build/entity/index.d.ts +2 -0
  25. package/build/entity/index.d.ts.map +1 -0
  26. package/build/entity/index.js +2 -0
  27. package/build/entity/index.js.map +1 -0
  28. package/build/entity/profile.d.ts +4 -0
  29. package/build/entity/profile.d.ts.map +1 -0
  30. package/build/entity/profile.js +21 -0
  31. package/build/entity/profile.js.map +1 -0
  32. package/build/errors.d.ts +54 -0
  33. package/build/errors.d.ts.map +1 -0
  34. package/build/errors.js +105 -0
  35. package/build/errors.js.map +1 -0
  36. package/build/helper.d.ts +7 -0
  37. package/build/helper.d.ts.map +1 -0
  38. package/build/helper.js +21 -0
  39. package/build/helper.js.map +1 -0
  40. package/build/index.d.ts +10 -0
  41. package/build/index.d.ts.map +1 -0
  42. package/build/index.js +9 -0
  43. package/build/index.js.map +1 -0
  44. package/build/permission/index.d.ts +2 -0
  45. package/build/permission/index.d.ts.map +1 -0
  46. package/build/permission/index.js +2 -0
  47. package/build/permission/index.js.map +1 -0
  48. package/build/permission/model.d.ts +6 -0
  49. package/build/permission/model.d.ts.map +1 -0
  50. package/build/permission/model.js +27 -0
  51. package/build/permission/model.js.map +1 -0
  52. package/build/rely/index.d.ts +3 -0
  53. package/build/rely/index.d.ts.map +1 -0
  54. package/build/rely/index.js +2 -0
  55. package/build/rely/index.js.map +1 -0
  56. package/build/rely/model.d.ts +4 -0
  57. package/build/rely/model.d.ts.map +1 -0
  58. package/build/rely/model.js +12 -0
  59. package/build/rely/model.js.map +1 -0
  60. package/build/rely/types.d.ts +7 -0
  61. package/build/rely/types.d.ts.map +1 -0
  62. package/build/rely/types.js +2 -0
  63. package/build/rely/types.js.map +1 -0
  64. package/build/types.d.ts +81 -0
  65. package/build/types.d.ts.map +1 -0
  66. package/build/types.js +2 -0
  67. package/build/types.js.map +1 -0
  68. package/package.json +38 -0
  69. package/src/allowance/index.ts +2 -0
  70. package/src/allowance/model.ts +65 -0
  71. package/src/auth/index.ts +2 -0
  72. package/src/auth/model.ts +64 -0
  73. package/src/consts.ts +121 -0
  74. package/src/entity/index.ts +2 -0
  75. package/src/entity/profile.ts +24 -0
  76. package/src/errors.ts +132 -0
  77. package/src/helper.ts +32 -0
  78. package/src/index.ts +10 -0
  79. package/src/permission/index.ts +2 -0
  80. package/src/permission/model.ts +31 -0
  81. package/src/rely/index.ts +3 -0
  82. package/src/rely/model.ts +14 -0
  83. package/src/rely/types.ts +7 -0
  84. package/src/types.ts +178 -0
  85. package/tsconfig.json +14 -0
  86. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,100 @@
1
+ export const INCLUDE = '+';
2
+ export const EXCLUDE = '-';
3
+ export const WILDCARD = '*';
4
+ export const DELIMITER = ':';
5
+ export const ALL_SCOPES = '*';
6
+ export const AUTH_SCOPE = '__auth';
7
+ export var AuthRole;
8
+ (function (AuthRole) {
9
+ AuthRole["User"] = "user";
10
+ AuthRole["Guest"] = "guest";
11
+ AuthRole["Service"] = "service";
12
+ AuthRole["System"] = "system";
13
+ AuthRole["Admin"] = "admin";
14
+ AuthRole["Superuser"] = "superuser";
15
+ AuthRole["Blocked"] = "blocked";
16
+ })(AuthRole || (AuthRole = {}));
17
+ export var AuthenticationType;
18
+ (function (AuthenticationType) {
19
+ AuthenticationType["BasicEd25519"] = "basic-ed25519";
20
+ AuthenticationType["OneTimeToken"] = "one-time-token";
21
+ AuthenticationType["ReCaptcha"] = "re-captcha";
22
+ // @TODO think if it should be moved from here
23
+ // - it's too implementation specific
24
+ // OwlMeans specific WalletProvider authentication type.
25
+ // It's used to establish connection between the wallet and the rely service for further
26
+ // providing a rely connection.
27
+ // 1. It exactly does the following: authenticate wallet in the rely endpoint to get
28
+ // an auth token that allows to open rely connection as provider.
29
+ AuthenticationType["WalletDid"] = "wallet-did";
30
+ // Doesn't have explicity plugin - is internal part of rely based plugins
31
+ // 2. It is exactly used by wallet consumer and provider inside rely connection
32
+ // to cross authenticate one another and establish connection.
33
+ AuthenticationType["RelyHandshake"] = "rely-handshake";
34
+ // 3. It's used by wallet consumer to authenticate in the rely endpoint.
35
+ // After this authorization - the client gets a connection object that is capable
36
+ // to RPC wallet methods.
37
+ // ! Actually this is an internal protocol that isn't used directly but is used inside
38
+ // some specific authorization plugin (e.g. for registration or login).
39
+ // So actually it's quite similar to 'wallet-did', but from the client side.
40
+ // The difference is that 'wallet-did' is used by itself to provide RPC wallet methods.
41
+ AuthenticationType["WalletConsumer"] = "wallet-consumer";
42
+ // Right now this authentication type is ephemeral cause there is no support of
43
+ // abstract non-owlmenas-backend-bound wallets
44
+ // 4p. Potentially it can be used by other wallets or some universal wallet protocol
45
+ // to fullfil the role of wallet provider.
46
+ // For OwlMeans Auth Manager Service (OwlMeans IAM) there is a propritary protocol
47
+ // that is used as provider type
48
+ AuthenticationType["WalletProvider"] = "wallet-provider";
49
+ })(AuthenticationType || (AuthenticationType = {}));
50
+ export var AuthroizationType;
51
+ (function (AuthroizationType) {
52
+ // Reserved to implement classic authentication token with ttled berear token.
53
+ AuthroizationType["AuthToken"] = "auth-token";
54
+ // Main authorization token type for OwlMeans. The authentication token 'one-time-token'
55
+ // is used to be exchanged to this one by auth service.
56
+ AuthroizationType["Ed25519BasicToken"] = "ed25519-basic-token";
57
+ // Implies that the request will contain signature of a known party to authorize request
58
+ // with authetnication header of this type.
59
+ AuthroizationType["Ed25519BasicSignature"] = "ed25519-basic-signature";
60
+ })(AuthroizationType || (AuthroizationType = {}));
61
+ export var AuthenticationStage;
62
+ (function (AuthenticationStage) {
63
+ AuthenticationStage["Error"] = "error";
64
+ AuthenticationStage["Init"] = "init";
65
+ AuthenticationStage["Allowence"] = "allowence";
66
+ AuthenticationStage["Authenticate"] = "authenticate";
67
+ AuthenticationStage["Authentication"] = "auhtentication";
68
+ AuthenticationStage["Authenticated"] = "authenticated";
69
+ })(AuthenticationStage || (AuthenticationStage = {}));
70
+ export const AUTHEN = 'authentication';
71
+ export const AUTHEN_INIT = `${AUTHEN}:init`;
72
+ export const AUTHEN_AUTHEN = `${AUTHEN}:authenticate`;
73
+ export const CAUTHEN = `client-${AUTHEN}`;
74
+ export const CAUTHEN_AUTHEN = `${CAUTHEN}:authentication`;
75
+ export const CAUTHEN_AUTHEN_DEFAULT = `${CAUTHEN}:authentication:default`;
76
+ export const CAUTHEN_AUTHEN_TYPED = `${CAUTHEN}:authentication:typed`;
77
+ export const CAUTHEN_FLOW_ENTER = `${CAUTHEN}:flow:enter`;
78
+ export const ScopeValueSchema = { type: 'string', minLength: 1, maxLength: 32 };
79
+ export const PermissionValueSchema = { type: 'string', minLength: 8, maxLength: 128 };
80
+ export const ResourceValueSchema = { type: 'string', minLength: 8, maxLength: 128 };
81
+ export const AttributeValueSchema = { type: 'string', minLength: 8, maxLength: 128 };
82
+ export const EntityValueSchema = { type: 'string', minLength: 3, maxLength: 256 };
83
+ export const GroupValueSchema = { type: 'string', minLength: 1, maxLength: 128 };
84
+ export const TypeNameSchema = { type: 'string', minLength: 1, maxLength: 64 };
85
+ export const EnumValueSchema = { type: 'string', minLength: 1, maxLength: 32 };
86
+ export const IdValueSchema = { type: 'string', minLength: 1, maxLength: 128 };
87
+ export const DateSchema = { type: 'object', format: 'date-time', required: [] };
88
+ export const AuthRoleSchema = { type: 'string', enum: Object.values(AuthRole) };
89
+ export const DISPATCHER = 'dispatcher';
90
+ export const DISPATCHER_AUTHEN = `${DISPATCHER}:authentication`;
91
+ export const AUTHEN_RELY = `${AUTHEN}-rely`;
92
+ export const AUTH_HEADER = 'authorization';
93
+ export const AUTH_QUERY = 'token';
94
+ export const ENTITY_QUERY = 'entity';
95
+ export const PROFILE_QUERY = 'profile';
96
+ export const MOD_RECAPTCHA = '_external:re-captcha';
97
+ export const CMOD_RECAPTCHA = `_client-${MOD_RECAPTCHA.slice(1)}`;
98
+ export const GUEST_ID = '__guest';
99
+ export const RELY_3RD = 'rely';
100
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAC1B,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAC1B,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAA;AAC3B,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;AAE5B,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAA;AAElC,MAAM,CAAN,IAAY,QAQX;AARD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;IACf,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;IACjB,2BAAe,CAAA;IACf,mCAAuB,CAAA;IACvB,+BAAmB,CAAA;AACrB,CAAC,EARW,QAAQ,KAAR,QAAQ,QAQnB;AAED,MAAM,CAAN,IAAY,kBA+BX;AA/BD,WA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E,SAAS,EAAE,EAAE,EAAE,CAAA;AAEtG,MAAM,CAAC,MAAM,aAAa,GAA2B,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAA;AAErG,MAAM,CAAC,MAAM,UAAU,GAAyB,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AAErG,MAAM,CAAC,MAAM,cAAc,GAA6B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;AAEzG,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAA;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,UAAU,iBAAiB,CAAA;AAE/D,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,MAAM,OAAO,CAAA;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAA;AAC1C,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAA;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAA;AACpC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAA;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG,sBAAsB,CAAA;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAA;AACjC,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './profile.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './profile.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+ import type { Profile } from '../types.js';
3
+ export declare const ProfileSchema: JSONSchemaType<Profile>;
4
+ //# sourceMappingURL=profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/entity/profile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,OAAO,CAiBjD,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { EntityValueSchema, IdValueSchema } from '../consts.js';
2
+ import { PermissionSetSchema, AttributeSetSchema } from '../permission/model.js';
3
+ export const ProfileSchema = {
4
+ type: 'object',
5
+ properties: {
6
+ id: IdValueSchema,
7
+ name: { type: 'string', minLength: 0, maxLength: 128 },
8
+ credential: { type: 'string', nullable: true },
9
+ secret: { type: 'string', nullable: true },
10
+ groups: { type: 'array', items: { type: 'string' }, nullable: true },
11
+ entityId: { ...EntityValueSchema, nullable: true },
12
+ scopes: { type: 'array', items: { type: 'string' } },
13
+ permissions: { type: 'array', items: PermissionSetSchema, nullable: true },
14
+ attributes: { type: 'array', items: AttributeSetSchema, nullable: true },
15
+ permissioned: { type: 'boolean', nullable: true },
16
+ denormalized: { type: 'boolean', nullable: true }
17
+ },
18
+ required: ['id', 'name', 'scopes'],
19
+ additionalProperties: false,
20
+ };
21
+ //# sourceMappingURL=profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/entity/profile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB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{ ResilientError } from '@owlmeans/error';
2
+ export declare class AuthError extends ResilientError {
3
+ static typeName: string;
4
+ constructor(message?: string);
5
+ }
6
+ export declare class AuthUnknown extends AuthError {
7
+ static typeName: string;
8
+ constructor(message?: string);
9
+ }
10
+ export declare class AuthManagerError extends AuthError {
11
+ static typeName: string;
12
+ constructor(message?: string);
13
+ }
14
+ export declare class AuthManagerUnsupported extends AuthManagerError {
15
+ static typeName: string;
16
+ constructor(message?: string);
17
+ }
18
+ export declare class AuthenFailed extends AuthManagerError {
19
+ static typeName: string;
20
+ constructor(message?: string);
21
+ }
22
+ export declare class AuthenExists extends AuthenFailed {
23
+ static typeName: string;
24
+ constructor(message?: string);
25
+ }
26
+ export declare class AuthenPayloadError extends AuthenFailed {
27
+ static typeName: string;
28
+ constructor(message?: string);
29
+ }
30
+ export declare class AuthPluginError extends AuthManagerError {
31
+ static typeName: string;
32
+ constructor(message?: string);
33
+ }
34
+ export declare class TypeMissmatchError extends AuthPluginError {
35
+ static typeName: string;
36
+ constructor(message?: string);
37
+ }
38
+ export declare class AuthorizationError extends AuthError {
39
+ static typeName: string;
40
+ constructor(message?: string);
41
+ }
42
+ export declare class AuthForbidden extends AuthorizationError {
43
+ static typeName: string;
44
+ constructor(message?: string);
45
+ }
46
+ export declare class ProfileError extends AuthError {
47
+ static typeName: string;
48
+ constructor(message?: string);
49
+ }
50
+ export declare class ProfileConsistencyError extends ProfileError {
51
+ static typeName: string;
52
+ constructor(message?: string);
53
+ }
54
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,qBAAa,SAAU,SAAQ,cAAc;IAC3C,OAAuB,QAAQ,EAAE,MAAM,CAAc;gBAEzC,OAAO,GAAE,MAAgB;CAGtC;AAED,qBAAa,WAAY,SAAQ,SAAS;IACxC,OAAuB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CAItC"}
@@ -0,0 +1,105 @@
1
+ import { ResilientError } from '@owlmeans/error';
2
+ export class AuthError extends ResilientError {
3
+ static typeName = 'AuthError';
4
+ constructor(message = 'error') {
5
+ super(AuthError.typeName, `auth:${message}`);
6
+ }
7
+ }
8
+ export class AuthUnknown extends AuthError {
9
+ static typeName = `${AuthError.typeName}Unknown`;
10
+ constructor(message = 'error') {
11
+ super(`unknown:${message}`);
12
+ this.type = AuthUnknown.typeName;
13
+ }
14
+ }
15
+ export class AuthManagerError extends AuthError {
16
+ static typeName = 'AuthManagerError';
17
+ constructor(message = 'error') {
18
+ super(`manager:${message}`);
19
+ this.type = AuthManagerError.typeName;
20
+ }
21
+ }
22
+ export class AuthManagerUnsupported extends AuthManagerError {
23
+ static typeName = `${AuthManagerError.typeName}Unsupported`;
24
+ constructor(message = 'error') {
25
+ super(`unsupported:${message}`);
26
+ this.type = AuthManagerUnsupported.typeName;
27
+ }
28
+ }
29
+ export class AuthenFailed extends AuthManagerError {
30
+ static typeName = `${AuthManagerError.typeName}AuthenFailed`;
31
+ constructor(message = 'error') {
32
+ super(`authen:${message}`);
33
+ this.type = AuthenFailed.typeName;
34
+ }
35
+ }
36
+ export class AuthenExists extends AuthenFailed {
37
+ static typeName = `${AuthenFailed.typeName}Exists`;
38
+ constructor(message = 'error') {
39
+ super(`exists:${message}`);
40
+ this.type = AuthenExists.typeName;
41
+ }
42
+ }
43
+ export class AuthenPayloadError extends AuthenFailed {
44
+ static typeName = `${AuthenFailed.typeName}Payload`;
45
+ constructor(message = 'error') {
46
+ super(`payload:${message}`);
47
+ this.type = AuthenPayloadError.typeName;
48
+ }
49
+ }
50
+ export class AuthPluginError extends AuthManagerError {
51
+ static typeName = `${AuthManagerError.typeName}Plugin`;
52
+ constructor(message = 'error') {
53
+ super(`plugin:${message}`);
54
+ this.type = AuthPluginError.typeName;
55
+ }
56
+ }
57
+ export class TypeMissmatchError extends AuthPluginError {
58
+ static typeName = `${AuthPluginError.typeName}TypeMissmatch`;
59
+ constructor(message = 'error') {
60
+ super(`missmatch:${message}`);
61
+ this.type = TypeMissmatchError.typeName;
62
+ }
63
+ }
64
+ export class AuthorizationError extends AuthError {
65
+ static typeName = 'AuthorizationError';
66
+ constructor(message = 'error') {
67
+ super(`authorization:${message}`);
68
+ this.type = AuthorizationError.typeName;
69
+ }
70
+ }
71
+ export class AuthForbidden extends AuthorizationError {
72
+ static typeName = `Forbidden${AuthorizationError.typeName}`;
73
+ constructor(message = 'error') {
74
+ super(`forbidden:${message}`);
75
+ this.type = AuthForbidden.typeName;
76
+ }
77
+ }
78
+ export class ProfileError extends AuthError {
79
+ static typeName = 'ProfileError';
80
+ constructor(message = 'error') {
81
+ super(`profile:${message}`);
82
+ this.type = ProfileError.typeName;
83
+ }
84
+ }
85
+ export class ProfileConsistencyError extends ProfileError {
86
+ static typeName = `${ProfileError.typeName}Consistency`;
87
+ constructor(message = 'error') {
88
+ super(`consistency:${message}`);
89
+ this.type = ProfileConsistencyError.typeName;
90
+ }
91
+ }
92
+ ResilientError.registerErrorClass(AuthError);
93
+ ResilientError.registerErrorClass(AuthUnknown);
94
+ ResilientError.registerErrorClass(AuthManagerError);
95
+ ResilientError.registerErrorClass(AuthManagerUnsupported);
96
+ ResilientError.registerErrorClass(AuthenFailed);
97
+ ResilientError.registerErrorClass(AuthenExists);
98
+ ResilientError.registerErrorClass(AuthenPayloadError);
99
+ ResilientError.registerErrorClass(AuthPluginError);
100
+ ResilientError.registerErrorClass(TypeMissmatchError);
101
+ ResilientError.registerErrorClass(AuthorizationError);
102
+ AuthForbidden.registerErrorClass(AuthForbidden);
103
+ ResilientError.registerErrorClass(ProfileError);
104
+ ResilientError.registerErrorClass(ProfileConsistencyError);
105
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,OAA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,aAAa,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { Auth, AuthCredentials, AuthToken } from './types.js';
2
+ export declare const verifyAuth: (auth: Auth) => boolean;
3
+ export declare const verifyAuthCredentials: (auth: AuthCredentials) => boolean;
4
+ export declare const isAuth: (auth: unknown) => auth is Auth;
5
+ export declare const isAuthCredentials: (auth: unknown) => auth is AuthCredentials;
6
+ export declare const isAuthToken: (auth: unknown) => auth is AuthToken;
7
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AASlE,eAAO,MAAM,UAAU,SAAU,IAAI,KAAG,OAIvC,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAU,eAAe,KAAG,OAI7D,CAAA;AAED,eAAO,MAAM,MAAM,SAAU,OAAO,KAAG,IAAI,IAAI,IAEH,CAAA;AAE5C,eAAO,MAAM,iBAAiB,SAAU,OAAO,KAAG,IAAI,IAAI,eAEN,CAAA;AAEpD,eAAO,MAAM,WAAW,SAAU,OAAO,KAAG,IAAI,IAAI,SAEI,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { Ajv } from 'ajv';
2
+ import formatsPlugin from 'ajv-formats';
3
+ import { AuthCredentialsSchema, AuthSchema } from './allowance/model.js';
4
+ const ajv = new Ajv({ strict: false });
5
+ // @TODO There is some serious type mismatch probably because of wrong versions resolution
6
+ formatsPlugin(ajv);
7
+ export const verifyAuth = (auth) => {
8
+ const validate = ajv.compile(AuthSchema);
9
+ return validate(auth);
10
+ };
11
+ export const verifyAuthCredentials = (auth) => {
12
+ const validate = ajv.compile(AuthCredentialsSchema);
13
+ return validate(auth);
14
+ };
15
+ export const isAuth = (auth) => typeof auth === 'object' && auth != null
16
+ && ("token" in auth) && ("isUser" in auth);
17
+ export const isAuthCredentials = (auth) => typeof auth === 'object' && auth != null
18
+ && ("challenge" in auth) && ("credential" in auth);
19
+ export const isAuthToken = (auth) => typeof auth === 'object' && auth != null
20
+ && ("token" in auth) && typeof auth.token === 'string';
21
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,aAAa,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAExE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;AACtC,0FAA0F;AAC1F,aAAa,CAAC,GAAU,CAAC,CAAA;AAEzB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAW,EAAE;IAChD,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAExC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAqB,EAAW,EAAE;IACtE,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAEnD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAa,EAAgB,EAAE,CACpD,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,IAAI;OACrC,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAA;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAa,EAA2B,EAAE,CAC1E,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,IAAI;OACrC,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,CAAA;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAa,EAAqB,EAAE,CAC9D,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,IAAI;OACrC,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAA"}
@@ -0,0 +1,10 @@
1
+ export type * from './types.js';
2
+ export * from './errors.js';
3
+ export * from './consts.js';
4
+ export * from './helper.js';
5
+ export * from './allowance/index.js';
6
+ export * from './auth/index.js';
7
+ export * from './permission/index.js';
8
+ export * from './rely/index.js';
9
+ export * from './entity/index.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
package/build/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export * from './errors.js';
2
+ export * from './consts.js';
3
+ export * from './helper.js';
4
+ export * from './allowance/index.js';
5
+ export * from './auth/index.js';
6
+ export * from './permission/index.js';
7
+ export * from './rely/index.js';
8
+ export * from './entity/index.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './model.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/permission/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './model.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/permission/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { JSONSchemaType } from 'ajv';
2
+ import { AttributeSet, Capabilties, PermissionSet } from '../types.js';
3
+ export declare const CapabiltiesSchema: JSONSchemaType<Capabilties>;
4
+ export declare const PermissionSetSchema: JSONSchemaType<PermissionSet>;
5
+ export declare const AttributeSetSchema: JSONSchemaType<AttributeSet>;
6
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/permission/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGtE,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAIzD,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAAC,aAAa,CAU7D,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,YAAY,CAQ3D,CAAA"}
@@ -0,0 +1,27 @@
1
+ import { AttributeValueSchema, ResourceValueSchema, ScopeValueSchema } from '../consts.js';
2
+ export const CapabiltiesSchema = {
3
+ type: 'object',
4
+ additionalProperties: { type: ['boolean', 'number'], nullable: true },
5
+ required: []
6
+ };
7
+ export const PermissionSetSchema = {
8
+ type: 'object',
9
+ properties: {
10
+ title: { type: 'string', nullable: true, minLength: 1, maxLength: 128 },
11
+ scope: ScopeValueSchema,
12
+ permissions: CapabiltiesSchema,
13
+ resources: { type: 'array', items: ResourceValueSchema, nullable: true }
14
+ },
15
+ required: ['scope', 'permissions'],
16
+ additionalProperties: false,
17
+ };
18
+ export const AttributeSetSchema = {
19
+ type: 'object',
20
+ properties: {
21
+ scope: ScopeValueSchema,
22
+ attributes: { type: 'array', items: AttributeValueSchema }
23
+ },
24
+ required: ['scope', 'attributes'],
25
+ additionalProperties: false,
26
+ };
27
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/permission/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE1F,MAAM,CAAC,MAAM,iBAAiB,GAAgC;IAC5D,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;IACrE,QAAQ,EAAE,EAAE;CACb,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAkC;IAChE,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE;QACvE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,iBAAiB;QAC9B,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;KACzE;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC;IAClC,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAiC;IAC9D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,gBAAgB;QACvB,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE;KAC3D;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC;IACjC,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
@@ -0,0 +1,3 @@
1
+ export type * from './types.js';
2
+ export * from './model.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rely/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './model.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rely/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+ import type { RelyToken } from './types.js';
3
+ export declare const RelyChallengeSchema: JSONSchemaType<RelyToken>;
4
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/rely/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAAC,SAAS,CAUzD,CAAA"}
@@ -0,0 +1,12 @@
1
+ export const RelyChallengeSchema = {
2
+ type: 'object',
3
+ properties: {
4
+ pin: { type: 'string', nullable: true, minLength: 4, maxLength: 12 },
5
+ token: { type: 'string', nullable: true, minLength: 8, maxLength: 16 },
6
+ check: { type: 'string', nullable: true, minLength: 2, maxLength: 8 },
7
+ nonce: { type: 'string', minLength: 8, maxLength: 32 }
8
+ },
9
+ required: ['nonce'],
10
+ additionalProperties: false,
11
+ };
12
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/rely/model.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,mBAAmB,GAA8B;IAC5D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;QACpE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;QACtE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;QACrE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;KACvD;IACD,QAAQ,EAAE,CAAC,OAAO,CAAC;IACnB,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
@@ -0,0 +1,7 @@
1
+ export interface RelyToken {
2
+ pin?: string;
3
+ token?: string;
4
+ check?: string;
5
+ nonce: string;
6
+ }
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/rely/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/rely/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,81 @@
1
+ import type { AuthRole } from './consts.js';
2
+ export interface AuthCredentials extends AuthPayload {
3
+ challenge: string;
4
+ credential: string;
5
+ publicKey?: string;
6
+ }
7
+ export interface AuthPayload extends ProfilePayload {
8
+ type: string;
9
+ role: AuthRole;
10
+ /**
11
+ * Account id - shouldn't be shared with the services
12
+ * - it's ok to share owner id for supervisor roles double check
13
+ * - ? it should contain derived did in case of cryptographic authentication
14
+ */
15
+ userId: string;
16
+ /**
17
+ * Previous challenge
18
+ */
19
+ source?: string;
20
+ /**
21
+ * Id of the user inside the service. Preferable generated by the service.
22
+ * @cardinality Service to profile (to user) - one to many.
23
+ */
24
+ profileId?: string;
25
+ expiresAt?: Date;
26
+ }
27
+ export interface Group extends Authorization {
28
+ id: string;
29
+ name: string;
30
+ }
31
+ export interface ProfilePayload extends Authorization {
32
+ groups?: string[];
33
+ }
34
+ export interface Authorization {
35
+ entityId?: string;
36
+ scopes: string[];
37
+ permissions?: PermissionSet[];
38
+ attributes?: AttributeSet[];
39
+ /**
40
+ * Whether authorization provides all necessary permissions
41
+ */
42
+ permissioned?: boolean;
43
+ /**
44
+ * Whether all permissions resolved
45
+ */
46
+ denormalized?: boolean;
47
+ }
48
+ export interface Profile extends ProfilePayload {
49
+ id: string;
50
+ name: string;
51
+ credential?: string;
52
+ secret?: string;
53
+ }
54
+ export interface Auth extends AuthPayload {
55
+ token: string;
56
+ isUser: boolean;
57
+ createdAt: Date;
58
+ }
59
+ export interface PermissionSet {
60
+ scope: string;
61
+ title?: string;
62
+ permissions: Capabilties;
63
+ resources?: string[];
64
+ }
65
+ export interface Capabilties {
66
+ [key: string]: boolean | number | null;
67
+ }
68
+ export interface AttributeSet {
69
+ scope: string;
70
+ attributes: string[];
71
+ }
72
+ export interface AllowanceRequest extends Partial<AuthPayload> {
73
+ type: string;
74
+ }
75
+ export interface AllowanceResponse {
76
+ challenge: string;
77
+ }
78
+ export interface AuthToken {
79
+ token: string;
80
+ }
81
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CAmBnB;AAED,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,CAAA;IACd;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,IAAI,CAAA;CAYjB;AAED,MAAM,WAAW,KAAM,SAAQ,aAAa;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAUlB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,WAAW,CAAC,EAAE,aAAa,EAAE,CAAA;IAC7B,UAAU,CAAC,EAAE,YAAY,EAAE,CAAA;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,OAAQ,SAAQ,cAAc;IAC7C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAYhB;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,IAAI,CAAA;CAmBhB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,WAAW,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;CACvC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,MAAM,WAAW,gBAAiB,SAAQ,OAAO,CAAC,WAAW,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAA;CAmBb;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;CACd"}
package/build/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}