@andco/protocol 0.0.3 → 0.0.5

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 (113) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +51 -3
  3. package/dist/api-errors.d.ts +114 -0
  4. package/dist/api-errors.d.ts.map +1 -0
  5. package/dist/api-errors.js +116 -0
  6. package/dist/authorization-preparation.d.ts +52 -543
  7. package/dist/authorization-preparation.d.ts.map +1 -1
  8. package/dist/authorization-preparation.js +19 -42
  9. package/dist/authorization.d.ts +64 -22
  10. package/dist/authorization.d.ts.map +1 -1
  11. package/dist/authorization.js +136 -55
  12. package/dist/consent.d.ts +5 -8
  13. package/dist/consent.d.ts.map +1 -1
  14. package/dist/consent.js +5 -62
  15. package/dist/constants.d.ts +19 -3
  16. package/dist/constants.d.ts.map +1 -1
  17. package/dist/constants.js +19 -3
  18. package/dist/errors.d.ts +154 -58
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/errors.js +174 -57
  21. package/dist/index.d.ts +4 -4
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +4 -4
  24. package/dist/intent-input.d.ts +1022 -288
  25. package/dist/intent-input.d.ts.map +1 -1
  26. package/dist/intent-input.js +284 -40
  27. package/dist/messages/error.d.ts +1 -2
  28. package/dist/messages/error.d.ts.map +1 -1
  29. package/dist/messages/error.js +5 -2
  30. package/dist/messages/index.d.ts +1 -1
  31. package/dist/native-copy.d.ts +23 -2
  32. package/dist/native-copy.d.ts.map +1 -1
  33. package/dist/native-copy.js +65 -117
  34. package/dist/native-intent.d.ts +126 -75
  35. package/dist/native-intent.d.ts.map +1 -1
  36. package/dist/native-intent.js +140 -48
  37. package/dist/rar/account-matchers.d.ts +579 -0
  38. package/dist/rar/account-matchers.d.ts.map +1 -0
  39. package/dist/rar/account-matchers.js +480 -0
  40. package/dist/rar/bank.d.ts +1549 -0
  41. package/dist/rar/bank.d.ts.map +1 -0
  42. package/dist/rar/bank.js +379 -0
  43. package/dist/rar/catalog.d.ts +1155 -0
  44. package/dist/rar/catalog.d.ts.map +1 -0
  45. package/dist/rar/catalog.js +175 -0
  46. package/dist/rar/detail.d.ts +39 -0
  47. package/dist/rar/detail.d.ts.map +1 -0
  48. package/dist/rar/detail.js +44 -0
  49. package/dist/rar/index.d.ts +9 -0
  50. package/dist/rar/index.d.ts.map +1 -0
  51. package/dist/rar/index.js +8 -0
  52. package/dist/rar/money.d.ts +58 -0
  53. package/dist/rar/money.d.ts.map +1 -0
  54. package/dist/rar/money.js +61 -0
  55. package/dist/rar/project-users.d.ts +43 -0
  56. package/dist/rar/project-users.d.ts.map +1 -0
  57. package/dist/rar/project-users.js +63 -0
  58. package/dist/rar/subject-data.d.ts +170 -0
  59. package/dist/rar/subject-data.d.ts.map +1 -0
  60. package/dist/rar/subject-data.js +127 -0
  61. package/dist/rar/subject.d.ts +166 -0
  62. package/dist/rar/subject.d.ts.map +1 -0
  63. package/dist/rar/subject.js +119 -0
  64. package/dist/scopes.d.ts +5 -30
  65. package/dist/scopes.d.ts.map +1 -1
  66. package/dist/scopes.js +0 -13
  67. package/dist/service-grants.d.ts +44 -0
  68. package/dist/service-grants.d.ts.map +1 -0
  69. package/dist/service-grants.js +45 -0
  70. package/dist/signing.d.ts +56 -0
  71. package/dist/signing.d.ts.map +1 -0
  72. package/dist/signing.js +233 -0
  73. package/dist/transport/financial-events.d.ts +90 -35
  74. package/dist/transport/financial-events.d.ts.map +1 -1
  75. package/dist/transport/financial-events.js +7 -1
  76. package/dist/transport/generated/oauth-api.d.ts +932 -441
  77. package/dist/transport/generated/oauth-api.d.ts.map +1 -1
  78. package/dist/transport/index.d.ts +0 -1
  79. package/dist/transport/index.d.ts.map +1 -1
  80. package/dist/transport/index.js +0 -1
  81. package/dist/transport/intents.d.ts +155 -23
  82. package/dist/transport/intents.d.ts.map +1 -1
  83. package/dist/transport/intents.js +192 -59
  84. package/dist/transport/rest.d.ts +19 -8
  85. package/dist/transport/rest.d.ts.map +1 -1
  86. package/dist/transport/rest.js +1 -1
  87. package/dist/urls.d.ts.map +1 -1
  88. package/dist/urls.js +1 -1
  89. package/dist/userinfo.d.ts +10 -1
  90. package/dist/userinfo.d.ts.map +1 -1
  91. package/dist/userinfo.js +10 -1
  92. package/dist/utils.d.ts +15 -0
  93. package/dist/utils.d.ts.map +1 -1
  94. package/dist/utils.js +31 -0
  95. package/dist/webhooks.d.ts +154 -0
  96. package/dist/webhooks.d.ts.map +1 -0
  97. package/dist/webhooks.js +249 -0
  98. package/package.json +21 -2
  99. package/dist/automatic-charge.d.ts +0 -314
  100. package/dist/automatic-charge.d.ts.map +0 -1
  101. package/dist/automatic-charge.js +0 -126
  102. package/dist/bank-account-authorization.d.ts +0 -6
  103. package/dist/bank-account-authorization.d.ts.map +0 -1
  104. package/dist/bank-account-authorization.js +0 -13
  105. package/dist/transport/webhooks.d.ts +0 -27
  106. package/dist/transport/webhooks.d.ts.map +0 -1
  107. package/dist/transport/webhooks.js +0 -68
  108. package/dist/webhook-input.d.ts +0 -22
  109. package/dist/webhook-input.d.ts.map +0 -1
  110. package/dist/webhook-input.js +0 -11
  111. package/dist/webhook-signature.d.ts +0 -54
  112. package/dist/webhook-signature.d.ts.map +0 -1
  113. package/dist/webhook-signature.js +0 -74
@@ -0,0 +1,170 @@
1
+ import * as v from "valibot";
2
+ /** Reading the Subject's identity: `GET /profiles/{id}/identities` or `/organizations/{id}/identities`. */
3
+ export declare const IDENTITY_ACTIONS: readonly ["read"];
4
+ /** Managing the Subject's addresses under `/profiles/{id}/addresses` or `/organizations/{id}/addresses`. */
5
+ export declare const ADDRESS_ACTIONS: readonly ["read", "create", "update", "delete"];
6
+ /** Listing the signed-in person's Organizations: `GET /profiles/{id}/organizations`. */
7
+ export declare const ORGANIZATION_ACTIONS: readonly ["list"];
8
+ /** Editing the signed-in person's Profile. Replaces the former `profile:write` scope. */
9
+ export declare const PROFILE_ACTIONS: readonly ["update"];
10
+ /**
11
+ * `identity` Grant Request: read the identity of a Profile or an Organization.
12
+ *
13
+ * @example
14
+ * const kyb: IdentityGrantRequest = {
15
+ * type: "identity",
16
+ * actions: ["read"],
17
+ * locations: ["https://api.andco.com"],
18
+ * subject: { type: "organization" },
19
+ * };
20
+ */
21
+ export declare const IdentityGrantRequestSchema: v.StrictObjectSchema<{
22
+ readonly type: v.LiteralSchema<"identity", undefined>;
23
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.CheckAction<"read"[], "duplicate_action">]>;
24
+ readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
25
+ readonly subject: v.NullishSchema<v.VariantSchema<"type", [v.StrictObjectSchema<{
26
+ readonly type: v.LiteralSchema<"profile", undefined>;
27
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
28
+ }, undefined>, v.StrictObjectSchema<{
29
+ readonly type: v.LiteralSchema<"organization", undefined>;
30
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>, undefined>;
31
+ readonly editable: v.NullishSchema<v.BooleanSchema<undefined>, undefined>;
32
+ }, undefined>], undefined>, undefined>;
33
+ }, undefined>;
34
+ export type IdentityGrantRequest = v.InferInput<typeof IdentityGrantRequestSchema>;
35
+ /** `identity` Grant. */
36
+ export declare const IdentityGrantSchema: v.StrictObjectSchema<{
37
+ readonly type: v.LiteralSchema<"identity", undefined>;
38
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.CheckAction<"read"[], "duplicate_action">]>;
39
+ readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
40
+ readonly subject: v.VariantSchema<"type", [v.StrictObjectSchema<{
41
+ readonly type: v.LiteralSchema<"profile", undefined>;
42
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
43
+ }, undefined>, v.StrictObjectSchema<{
44
+ readonly type: v.LiteralSchema<"organization", undefined>;
45
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>;
46
+ }, undefined>], undefined>;
47
+ }, undefined>;
48
+ export type IdentityGrant = v.InferOutput<typeof IdentityGrantSchema>;
49
+ /**
50
+ * `address` Grant Request: read or manage the addresses of a Profile or an Organization.
51
+ *
52
+ * @example
53
+ * const shipping: AddressGrantRequest = {
54
+ * type: "address",
55
+ * actions: ["read", "create"],
56
+ * locations: ["https://api.andco.com"],
57
+ * subject: { type: "profile" },
58
+ * };
59
+ */
60
+ export declare const AddressGrantRequestSchema: v.StrictObjectSchema<{
61
+ readonly type: v.LiteralSchema<"address", undefined>;
62
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read", "create", "update", "delete"], undefined>, undefined>, v.MinLengthAction<("read" | "create" | "update" | "delete")[], 1, undefined>, v.CheckAction<("read" | "create" | "update" | "delete")[], "duplicate_action">]>;
63
+ readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
64
+ readonly subject: v.NullishSchema<v.VariantSchema<"type", [v.StrictObjectSchema<{
65
+ readonly type: v.LiteralSchema<"profile", undefined>;
66
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
67
+ }, undefined>, v.StrictObjectSchema<{
68
+ readonly type: v.LiteralSchema<"organization", undefined>;
69
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>, undefined>;
70
+ readonly editable: v.NullishSchema<v.BooleanSchema<undefined>, undefined>;
71
+ }, undefined>], undefined>, undefined>;
72
+ }, undefined>;
73
+ export type AddressGrantRequest = v.InferInput<typeof AddressGrantRequestSchema>;
74
+ /** `address` Grant. */
75
+ export declare const AddressGrantSchema: v.StrictObjectSchema<{
76
+ readonly type: v.LiteralSchema<"address", undefined>;
77
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read", "create", "update", "delete"], undefined>, undefined>, v.MinLengthAction<("read" | "create" | "update" | "delete")[], 1, undefined>, v.CheckAction<("read" | "create" | "update" | "delete")[], "duplicate_action">]>;
78
+ readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
79
+ readonly subject: v.VariantSchema<"type", [v.StrictObjectSchema<{
80
+ readonly type: v.LiteralSchema<"profile", undefined>;
81
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
82
+ }, undefined>, v.StrictObjectSchema<{
83
+ readonly type: v.LiteralSchema<"organization", undefined>;
84
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>;
85
+ }, undefined>], undefined>;
86
+ }, undefined>;
87
+ export type AddressGrant = v.InferOutput<typeof AddressGrantSchema>;
88
+ /**
89
+ * `organization` Grant Request: list the signed-in person's Organizations. The subject can only be
90
+ * the person's Profile.
91
+ *
92
+ * @example
93
+ * const list: OrganizationGrantRequest = {
94
+ * type: "organization",
95
+ * actions: ["list"],
96
+ * locations: ["https://api.andco.com"],
97
+ * subject: { type: "profile" },
98
+ * };
99
+ */
100
+ export declare const OrganizationGrantRequestSchema: v.StrictObjectSchema<{
101
+ readonly type: v.LiteralSchema<"organization", undefined>;
102
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["list"], undefined>, undefined>, v.MinLengthAction<"list"[], 1, undefined>, v.CheckAction<"list"[], "duplicate_action">]>;
103
+ readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
104
+ readonly subject: v.NullishSchema<v.StrictObjectSchema<{
105
+ readonly type: v.LiteralSchema<"profile", undefined>;
106
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
107
+ }, undefined>, undefined>;
108
+ }, undefined>;
109
+ export type OrganizationGrantRequest = v.InferInput<typeof OrganizationGrantRequestSchema>;
110
+ /** `organization` Grant. */
111
+ export declare const OrganizationGrantSchema: v.StrictObjectSchema<{
112
+ readonly type: v.LiteralSchema<"organization", undefined>;
113
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["list"], undefined>, undefined>, v.MinLengthAction<"list"[], 1, undefined>, v.CheckAction<"list"[], "duplicate_action">]>;
114
+ readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
115
+ readonly subject: v.StrictObjectSchema<{
116
+ readonly type: v.LiteralSchema<"profile", undefined>;
117
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
118
+ }, undefined>;
119
+ }, undefined>;
120
+ export type OrganizationGrant = v.InferOutput<typeof OrganizationGrantSchema>;
121
+ /**
122
+ * `profile` Grant Request: update the signed-in person's Profile. The subject can only be that
123
+ * Profile.
124
+ *
125
+ * @example
126
+ * const edit: ProfileGrantRequest = {
127
+ * type: "profile",
128
+ * actions: ["update"],
129
+ * locations: ["https://api.andco.com"],
130
+ * subject: { type: "profile" },
131
+ * };
132
+ */
133
+ export declare const ProfileGrantRequestSchema: v.StrictObjectSchema<{
134
+ readonly type: v.LiteralSchema<"profile", undefined>;
135
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["update"], undefined>, undefined>, v.MinLengthAction<"update"[], 1, undefined>, v.CheckAction<"update"[], "duplicate_action">]>;
136
+ readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
137
+ readonly subject: v.NullishSchema<v.StrictObjectSchema<{
138
+ readonly type: v.LiteralSchema<"profile", undefined>;
139
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
140
+ }, undefined>, undefined>;
141
+ }, undefined>;
142
+ export type ProfileGrantRequest = v.InferInput<typeof ProfileGrantRequestSchema>;
143
+ /** `profile` Grant. */
144
+ export declare const ProfileGrantSchema: v.StrictObjectSchema<{
145
+ readonly type: v.LiteralSchema<"profile", undefined>;
146
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["update"], undefined>, undefined>, v.MinLengthAction<"update"[], 1, undefined>, v.CheckAction<"update"[], "duplicate_action">]>;
147
+ readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
148
+ readonly subject: v.StrictObjectSchema<{
149
+ readonly type: v.LiteralSchema<"profile", undefined>;
150
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
151
+ }, undefined>;
152
+ }, undefined>;
153
+ export type ProfileGrant = v.InferOutput<typeof ProfileGrantSchema>;
154
+ /** JSON Schema mirror of {@link IdentityGrantRequestSchema}. */
155
+ export declare const IDENTITY_GRANT_REQUEST_JSON_SCHEMA: Record<string, unknown>;
156
+ /** JSON Schema mirror of {@link IdentityGrantSchema}. */
157
+ export declare const IDENTITY_GRANT_JSON_SCHEMA: Record<string, unknown>;
158
+ /** JSON Schema mirror of {@link AddressGrantRequestSchema}. */
159
+ export declare const ADDRESS_GRANT_REQUEST_JSON_SCHEMA: Record<string, unknown>;
160
+ /** JSON Schema mirror of {@link AddressGrantSchema}. */
161
+ export declare const ADDRESS_GRANT_JSON_SCHEMA: Record<string, unknown>;
162
+ /** JSON Schema mirror of {@link OrganizationGrantRequestSchema}. */
163
+ export declare const ORGANIZATION_GRANT_REQUEST_JSON_SCHEMA: Record<string, unknown>;
164
+ /** JSON Schema mirror of {@link OrganizationGrantSchema}. */
165
+ export declare const ORGANIZATION_GRANT_JSON_SCHEMA: Record<string, unknown>;
166
+ /** JSON Schema mirror of {@link ProfileGrantRequestSchema}. */
167
+ export declare const PROFILE_GRANT_REQUEST_JSON_SCHEMA: Record<string, unknown>;
168
+ /** JSON Schema mirror of {@link ProfileGrantSchema}. */
169
+ export declare const PROFILE_GRANT_JSON_SCHEMA: Record<string, unknown>;
170
+ //# sourceMappingURL=subject-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject-data.d.ts","sourceRoot":"","sources":["../../src/rar/subject-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAa7B,2GAA2G;AAC3G,eAAO,MAAM,gBAAgB,mBAAoB,CAAC;AAClD,4GAA4G;AAC5G,eAAO,MAAM,eAAe,iDAAkD,CAAC;AAC/E,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,mBAAoB,CAAC;AACtD,yFAAyF;AACzF,eAAO,MAAM,eAAe,qBAAsB,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;aAKrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;AACnF,wBAAwB;AACxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;aAK9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;aAKpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AACjF,uBAAuB;AACvB,eAAO,MAAM,kBAAkB;;;;;;;;;;;aAK7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;aAKzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAC3F,4BAA4B;AAC5B,eAAO,MAAM,uBAAuB;;;;;;;;aAKlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;aAKpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AACjF,uBAAuB;AACvB,eAAO,MAAM,kBAAkB;;;;;;;;aAK7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAOpE,gEAAgE;AAChE,eAAO,MAAM,kCAAkC,yBAI9C,CAAC;AACF,yDAAyD;AACzD,eAAO,MAAM,0BAA0B,yBAItC,CAAC;AACF,+DAA+D;AAC/D,eAAO,MAAM,iCAAiC,yBAI7C,CAAC;AACF,wDAAwD;AACxD,eAAO,MAAM,yBAAyB,yBAIrC,CAAC;AACF,oEAAoE;AACpE,eAAO,MAAM,sCAAsC,yBAIlD,CAAC;AACF,6DAA6D;AAC7D,eAAO,MAAM,8BAA8B,yBAI1C,CAAC;AACF,+DAA+D;AAC/D,eAAO,MAAM,iCAAiC,yBAI7C,CAAC;AACF,wDAAwD;AACxD,eAAO,MAAM,yBAAyB,yBAIrC,CAAC"}
@@ -0,0 +1,127 @@
1
+ import * as v from "valibot";
2
+ import { AndcoRarLocationsSchema, actionSet, actionSetJson, detailFormJson, detailTypeJson } from "./detail.js";
3
+ import { GRANTED_PROFILE_SUBJECT_JSON_SCHEMA, GRANTED_SUBJECT_JSON_SCHEMA, GrantedProfileSubjectSchema, GrantedSubjectSchema, PROFILE_ONLY_SUBJECT_PICKER_JSON_SCHEMA, ProfileOnlySubjectPickerSchema, SUBJECT_PICKER_JSON_SCHEMA, SubjectPickerSchema, } from "./subject.js";
4
+ /** Reading the Subject's identity: `GET /profiles/{id}/identities` or `/organizations/{id}/identities`. */
5
+ export const IDENTITY_ACTIONS = ["read"];
6
+ /** Managing the Subject's addresses under `/profiles/{id}/addresses` or `/organizations/{id}/addresses`. */
7
+ export const ADDRESS_ACTIONS = ["read", "create", "update", "delete"];
8
+ /** Listing the signed-in person's Organizations: `GET /profiles/{id}/organizations`. */
9
+ export const ORGANIZATION_ACTIONS = ["list"];
10
+ /** Editing the signed-in person's Profile. Replaces the former `profile:write` scope. */
11
+ export const PROFILE_ACTIONS = ["update"];
12
+ /**
13
+ * `identity` Grant Request: read the identity of a Profile or an Organization.
14
+ *
15
+ * @example
16
+ * const kyb: IdentityGrantRequest = {
17
+ * type: "identity",
18
+ * actions: ["read"],
19
+ * locations: ["https://api.andco.com"],
20
+ * subject: { type: "organization" },
21
+ * };
22
+ */
23
+ export const IdentityGrantRequestSchema = /* @__PURE__ */ v.strictObject({
24
+ type: v.literal("identity"),
25
+ actions: actionSet(IDENTITY_ACTIONS),
26
+ locations: AndcoRarLocationsSchema,
27
+ subject: SubjectPickerSchema,
28
+ });
29
+ /** `identity` Grant. */
30
+ export const IdentityGrantSchema = /* @__PURE__ */ v.strictObject({
31
+ type: v.literal("identity"),
32
+ actions: actionSet(IDENTITY_ACTIONS),
33
+ locations: AndcoRarLocationsSchema,
34
+ subject: GrantedSubjectSchema,
35
+ });
36
+ /**
37
+ * `address` Grant Request: read or manage the addresses of a Profile or an Organization.
38
+ *
39
+ * @example
40
+ * const shipping: AddressGrantRequest = {
41
+ * type: "address",
42
+ * actions: ["read", "create"],
43
+ * locations: ["https://api.andco.com"],
44
+ * subject: { type: "profile" },
45
+ * };
46
+ */
47
+ export const AddressGrantRequestSchema = /* @__PURE__ */ v.strictObject({
48
+ type: v.literal("address"),
49
+ actions: actionSet(ADDRESS_ACTIONS),
50
+ locations: AndcoRarLocationsSchema,
51
+ subject: SubjectPickerSchema,
52
+ });
53
+ /** `address` Grant. */
54
+ export const AddressGrantSchema = /* @__PURE__ */ v.strictObject({
55
+ type: v.literal("address"),
56
+ actions: actionSet(ADDRESS_ACTIONS),
57
+ locations: AndcoRarLocationsSchema,
58
+ subject: GrantedSubjectSchema,
59
+ });
60
+ /**
61
+ * `organization` Grant Request: list the signed-in person's Organizations. The subject can only be
62
+ * the person's Profile.
63
+ *
64
+ * @example
65
+ * const list: OrganizationGrantRequest = {
66
+ * type: "organization",
67
+ * actions: ["list"],
68
+ * locations: ["https://api.andco.com"],
69
+ * subject: { type: "profile" },
70
+ * };
71
+ */
72
+ export const OrganizationGrantRequestSchema = /* @__PURE__ */ v.strictObject({
73
+ type: v.literal("organization"),
74
+ actions: actionSet(ORGANIZATION_ACTIONS),
75
+ locations: AndcoRarLocationsSchema,
76
+ subject: ProfileOnlySubjectPickerSchema,
77
+ });
78
+ /** `organization` Grant. */
79
+ export const OrganizationGrantSchema = /* @__PURE__ */ v.strictObject({
80
+ type: v.literal("organization"),
81
+ actions: actionSet(ORGANIZATION_ACTIONS),
82
+ locations: AndcoRarLocationsSchema,
83
+ subject: GrantedProfileSubjectSchema,
84
+ });
85
+ /**
86
+ * `profile` Grant Request: update the signed-in person's Profile. The subject can only be that
87
+ * Profile.
88
+ *
89
+ * @example
90
+ * const edit: ProfileGrantRequest = {
91
+ * type: "profile",
92
+ * actions: ["update"],
93
+ * locations: ["https://api.andco.com"],
94
+ * subject: { type: "profile" },
95
+ * };
96
+ */
97
+ export const ProfileGrantRequestSchema = /* @__PURE__ */ v.strictObject({
98
+ type: v.literal("profile"),
99
+ actions: actionSet(PROFILE_ACTIONS),
100
+ locations: AndcoRarLocationsSchema,
101
+ subject: ProfileOnlySubjectPickerSchema,
102
+ });
103
+ /** `profile` Grant. */
104
+ export const ProfileGrantSchema = /* @__PURE__ */ v.strictObject({
105
+ type: v.literal("profile"),
106
+ actions: actionSet(PROFILE_ACTIONS),
107
+ locations: AndcoRarLocationsSchema,
108
+ subject: GrantedProfileSubjectSchema,
109
+ });
110
+ const requestJson = (type, actions, subject) => detailTypeJson([detailFormJson(type, actionSetJson(actions), { subject }, [])]);
111
+ const grantJson = (type, actions, subject) => detailTypeJson([detailFormJson(type, actionSetJson(actions), { subject }, ["subject"])]);
112
+ /** JSON Schema mirror of {@link IdentityGrantRequestSchema}. */
113
+ export const IDENTITY_GRANT_REQUEST_JSON_SCHEMA = /* @__PURE__ */ requestJson("identity", IDENTITY_ACTIONS, SUBJECT_PICKER_JSON_SCHEMA);
114
+ /** JSON Schema mirror of {@link IdentityGrantSchema}. */
115
+ export const IDENTITY_GRANT_JSON_SCHEMA = /* @__PURE__ */ grantJson("identity", IDENTITY_ACTIONS, GRANTED_SUBJECT_JSON_SCHEMA);
116
+ /** JSON Schema mirror of {@link AddressGrantRequestSchema}. */
117
+ export const ADDRESS_GRANT_REQUEST_JSON_SCHEMA = /* @__PURE__ */ requestJson("address", ADDRESS_ACTIONS, SUBJECT_PICKER_JSON_SCHEMA);
118
+ /** JSON Schema mirror of {@link AddressGrantSchema}. */
119
+ export const ADDRESS_GRANT_JSON_SCHEMA = /* @__PURE__ */ grantJson("address", ADDRESS_ACTIONS, GRANTED_SUBJECT_JSON_SCHEMA);
120
+ /** JSON Schema mirror of {@link OrganizationGrantRequestSchema}. */
121
+ export const ORGANIZATION_GRANT_REQUEST_JSON_SCHEMA = /* @__PURE__ */ requestJson("organization", ORGANIZATION_ACTIONS, PROFILE_ONLY_SUBJECT_PICKER_JSON_SCHEMA);
122
+ /** JSON Schema mirror of {@link OrganizationGrantSchema}. */
123
+ export const ORGANIZATION_GRANT_JSON_SCHEMA = /* @__PURE__ */ grantJson("organization", ORGANIZATION_ACTIONS, GRANTED_PROFILE_SUBJECT_JSON_SCHEMA);
124
+ /** JSON Schema mirror of {@link ProfileGrantRequestSchema}. */
125
+ export const PROFILE_GRANT_REQUEST_JSON_SCHEMA = /* @__PURE__ */ requestJson("profile", PROFILE_ACTIONS, PROFILE_ONLY_SUBJECT_PICKER_JSON_SCHEMA);
126
+ /** JSON Schema mirror of {@link ProfileGrantSchema}. */
127
+ export const PROFILE_GRANT_JSON_SCHEMA = /* @__PURE__ */ grantJson("profile", PROFILE_ACTIONS, GRANTED_PROFILE_SUBJECT_JSON_SCHEMA);
@@ -0,0 +1,166 @@
1
+ import * as v from "valibot";
2
+ /**
3
+ * Syntax of a Profile identifier: the Supabase Auth user id, any UUID-shaped value. No version or
4
+ * variant digit is checked, because Auth stores whatever id a user was created with (seeded users
5
+ * included) and a stricter pattern would refuse a real Profile.
6
+ */
7
+ export declare const PROFILE_IDENTIFIER_PATTERN = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$";
8
+ /**
9
+ * Syntax of an Organization identifier: a positive decimal integer of at most ten digits.
10
+ *
11
+ * The regex alone admits values above the `int4` ceiling of `organizations.organization_id`; the
12
+ * valibot schema adds the numeric check against {@link ANDCO_MAX_ORGANIZATION_ID}. JSON Schema has no
13
+ * numeric comparison over strings, so the mirror stays at the digit count and the gate's join on the
14
+ * Organization does the rest.
15
+ */
16
+ export declare const ORGANIZATION_IDENTIFIER_PATTERN = "^[1-9][0-9]{0,9}$";
17
+ /**
18
+ * A Profile subject in a Grant Request. Without `identifier` it resolves to the signed-in person's
19
+ * Profile at consent; with one, the consent only applies when the signed-in person is that Profile.
20
+ *
21
+ * There is no `editable`: a person cannot consent on behalf of another person.
22
+ */
23
+ export declare const ProfileSubjectPickerSchema: v.StrictObjectSchema<{
24
+ readonly type: v.LiteralSchema<"profile", undefined>;
25
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
26
+ }, undefined>;
27
+ /**
28
+ * An Organization subject in a Grant Request. Without `identifier` the person picks one of their
29
+ * Organizations at consent; with one, the consent only applies to that Organization. `editable`
30
+ * lets the person change a fixed identifier to another of their Organizations.
31
+ */
32
+ export declare const OrganizationSubjectPickerSchema: v.StrictObjectSchema<{
33
+ readonly type: v.LiteralSchema<"organization", undefined>;
34
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>, undefined>;
35
+ readonly editable: v.NullishSchema<v.BooleanSchema<undefined>, undefined>;
36
+ }, undefined>;
37
+ /**
38
+ * Whose resources a Grant Request asks for. `null` or absent takes the type's default (the
39
+ * signed-in Profile for every Andco type that has a subject). `attr?`, `undefined` and `null` mean
40
+ * the same in a Grant Request.
41
+ *
42
+ * @example
43
+ * const mine: SubjectPicker = { type: "profile" };
44
+ * const pickOrganization: SubjectPicker = { type: "organization" };
45
+ * const fixed: SubjectPicker = { type: "organization", identifier: "42" };
46
+ */
47
+ export declare const SubjectPickerSchema: v.NullishSchema<v.VariantSchema<"type", [v.StrictObjectSchema<{
48
+ readonly type: v.LiteralSchema<"profile", undefined>;
49
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
50
+ }, undefined>, v.StrictObjectSchema<{
51
+ readonly type: v.LiteralSchema<"organization", undefined>;
52
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>, undefined>;
53
+ readonly editable: v.NullishSchema<v.BooleanSchema<undefined>, undefined>;
54
+ }, undefined>], undefined>, undefined>;
55
+ export type SubjectPicker = v.InferInput<typeof SubjectPickerSchema>;
56
+ /** A Profile subject restricted to the Profile form, for the types that only act on a person. */
57
+ export declare const ProfileOnlySubjectPickerSchema: v.NullishSchema<v.StrictObjectSchema<{
58
+ readonly type: v.LiteralSchema<"profile", undefined>;
59
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
60
+ }, undefined>, undefined>;
61
+ export type ProfileOnlySubjectPicker = v.InferInput<typeof ProfileOnlySubjectPickerSchema>;
62
+ /**
63
+ * The Organization form of {@link GrantedSubjectSchema}: the only subject a Service acts for.
64
+ *
65
+ * @example
66
+ * const subject: GrantedOrganizationSubject = { type: "organization", identifier: "42" };
67
+ */
68
+ export declare const GrantedOrganizationSubjectSchema: v.StrictObjectSchema<{
69
+ readonly type: v.LiteralSchema<"organization", undefined>;
70
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>;
71
+ }, undefined>;
72
+ export type GrantedOrganizationSubject = v.InferOutput<typeof GrantedOrganizationSubjectSchema>;
73
+ /** The subject of a Grant: always resolved to an identifier, never editable. */
74
+ export declare const GrantedSubjectSchema: v.VariantSchema<"type", [v.StrictObjectSchema<{
75
+ readonly type: v.LiteralSchema<"profile", undefined>;
76
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
77
+ }, undefined>, v.StrictObjectSchema<{
78
+ readonly type: v.LiteralSchema<"organization", undefined>;
79
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>;
80
+ }, undefined>], undefined>;
81
+ export type GrantedSubject = v.InferOutput<typeof GrantedSubjectSchema>;
82
+ /** The Profile form of {@link GrantedSubjectSchema}. */
83
+ export declare const GrantedProfileSubjectSchema: v.StrictObjectSchema<{
84
+ readonly type: v.LiteralSchema<"profile", undefined>;
85
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
86
+ }, undefined>;
87
+ export type GrantedProfileSubject = v.InferOutput<typeof GrantedProfileSubjectSchema>;
88
+ /** JSON Schema mirror of {@link SubjectPickerSchema}. */
89
+ export declare const SUBJECT_PICKER_JSON_SCHEMA: {
90
+ anyOf: ({
91
+ type: string;
92
+ additionalProperties: boolean;
93
+ required: string[];
94
+ properties: {
95
+ type: {
96
+ const: string;
97
+ };
98
+ identifier: {
99
+ anyOf: ({
100
+ type: string;
101
+ pattern: string;
102
+ } | {
103
+ type: string;
104
+ })[];
105
+ };
106
+ };
107
+ } | {
108
+ type: string;
109
+ })[];
110
+ };
111
+ /** JSON Schema mirror of {@link ProfileOnlySubjectPickerSchema}. */
112
+ export declare const PROFILE_ONLY_SUBJECT_PICKER_JSON_SCHEMA: {
113
+ anyOf: ({
114
+ type: string;
115
+ additionalProperties: boolean;
116
+ required: string[];
117
+ properties: {
118
+ type: {
119
+ const: string;
120
+ };
121
+ identifier: {
122
+ anyOf: ({
123
+ type: string;
124
+ pattern: string;
125
+ } | {
126
+ type: string;
127
+ })[];
128
+ };
129
+ };
130
+ } | {
131
+ type: string;
132
+ })[];
133
+ };
134
+ /** JSON Schema mirror of {@link GrantedSubjectSchema}. */
135
+ export declare const GRANTED_SUBJECT_JSON_SCHEMA: {
136
+ anyOf: {
137
+ type: string;
138
+ additionalProperties: boolean;
139
+ required: string[];
140
+ properties: {
141
+ type: {
142
+ const: string;
143
+ };
144
+ identifier: {
145
+ type: string;
146
+ pattern: string;
147
+ };
148
+ };
149
+ }[];
150
+ };
151
+ /** JSON Schema mirror of {@link GrantedProfileSubjectSchema}. */
152
+ export declare const GRANTED_PROFILE_SUBJECT_JSON_SCHEMA: {
153
+ type: string;
154
+ additionalProperties: boolean;
155
+ required: string[];
156
+ properties: {
157
+ type: {
158
+ const: string;
159
+ };
160
+ identifier: {
161
+ type: string;
162
+ pattern: string;
163
+ };
164
+ };
165
+ };
166
+ //# sourceMappingURL=subject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject.d.ts","sourceRoot":"","sources":["../../src/rar/subject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,kFAC0C,CAAC;AAElF;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,sBAAsB,CAAC;AASnE;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B;;;aAGrC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,+BAA+B;;;;aAI1C,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB;;;;;;;sCAE/B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,iGAAiG;AACjG,eAAO,MAAM,8BAA8B;;;yBAAwD,CAAC;AACpG,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAE3F;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC;;;aAG3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAEhG,gFAAgF;AAChF,eAAO,MAAM,oBAAoB;;;;;;0BAG/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,wDAAwD;AACxD,eAAO,MAAM,2BAA2B;;;aAGtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAwBtF,yDAAyD;AACzD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;CAA2E,CAAC;AACnH,oEAAoE;AACpE,eAAO,MAAM,uCAAuC;;;;;;;;;;;;;;;;;;;;;CAAmD,CAAC;AASxG,0DAA0D;AAC1D,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;CAavC,CAAC;AACF,iEAAiE;AACjE,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;CAAqB,CAAC"}
@@ -0,0 +1,119 @@
1
+ import * as v from "valibot";
2
+ import { ANDCO_MAX_ORGANIZATION_ID } from "../authorization.js";
3
+ /**
4
+ * Syntax of a Profile identifier: the Supabase Auth user id, any UUID-shaped value. No version or
5
+ * variant digit is checked, because Auth stores whatever id a user was created with (seeded users
6
+ * included) and a stricter pattern would refuse a real Profile.
7
+ */
8
+ export const PROFILE_IDENTIFIER_PATTERN = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$";
9
+ /**
10
+ * Syntax of an Organization identifier: a positive decimal integer of at most ten digits.
11
+ *
12
+ * The regex alone admits values above the `int4` ceiling of `organizations.organization_id`; the
13
+ * valibot schema adds the numeric check against {@link ANDCO_MAX_ORGANIZATION_ID}. JSON Schema has no
14
+ * numeric comparison over strings, so the mirror stays at the digit count and the gate's join on the
15
+ * Organization does the rest.
16
+ */
17
+ export const ORGANIZATION_IDENTIFIER_PATTERN = "^[1-9][0-9]{0,9}$";
18
+ const profileIdentifier = /* @__PURE__ */ v.pipe(v.string(), v.regex(new RegExp(PROFILE_IDENTIFIER_PATTERN)));
19
+ const organizationIdentifier = /* @__PURE__ */ v.pipe(v.string(), v.regex(new RegExp(ORGANIZATION_IDENTIFIER_PATTERN)), v.check((value) => Number(value) <= ANDCO_MAX_ORGANIZATION_ID, "identifier_exceeds_organization_id"));
20
+ /**
21
+ * A Profile subject in a Grant Request. Without `identifier` it resolves to the signed-in person's
22
+ * Profile at consent; with one, the consent only applies when the signed-in person is that Profile.
23
+ *
24
+ * There is no `editable`: a person cannot consent on behalf of another person.
25
+ */
26
+ export const ProfileSubjectPickerSchema = /* @__PURE__ */ v.strictObject({
27
+ type: v.literal("profile"),
28
+ identifier: v.nullish(profileIdentifier),
29
+ });
30
+ /**
31
+ * An Organization subject in a Grant Request. Without `identifier` the person picks one of their
32
+ * Organizations at consent; with one, the consent only applies to that Organization. `editable`
33
+ * lets the person change a fixed identifier to another of their Organizations.
34
+ */
35
+ export const OrganizationSubjectPickerSchema = /* @__PURE__ */ v.strictObject({
36
+ type: v.literal("organization"),
37
+ identifier: v.nullish(organizationIdentifier),
38
+ editable: v.nullish(v.boolean()),
39
+ });
40
+ /**
41
+ * Whose resources a Grant Request asks for. `null` or absent takes the type's default (the
42
+ * signed-in Profile for every Andco type that has a subject). `attr?`, `undefined` and `null` mean
43
+ * the same in a Grant Request.
44
+ *
45
+ * @example
46
+ * const mine: SubjectPicker = { type: "profile" };
47
+ * const pickOrganization: SubjectPicker = { type: "organization" };
48
+ * const fixed: SubjectPicker = { type: "organization", identifier: "42" };
49
+ */
50
+ export const SubjectPickerSchema = /* @__PURE__ */ v.nullish(v.variant("type", [ProfileSubjectPickerSchema, OrganizationSubjectPickerSchema]));
51
+ /** A Profile subject restricted to the Profile form, for the types that only act on a person. */
52
+ export const ProfileOnlySubjectPickerSchema = /* @__PURE__ */ v.nullish(ProfileSubjectPickerSchema);
53
+ /**
54
+ * The Organization form of {@link GrantedSubjectSchema}: the only subject a Service acts for.
55
+ *
56
+ * @example
57
+ * const subject: GrantedOrganizationSubject = { type: "organization", identifier: "42" };
58
+ */
59
+ export const GrantedOrganizationSubjectSchema = /* @__PURE__ */ v.strictObject({
60
+ type: v.literal("organization"),
61
+ identifier: organizationIdentifier,
62
+ });
63
+ /** The subject of a Grant: always resolved to an identifier, never editable. */
64
+ export const GrantedSubjectSchema = /* @__PURE__ */ v.variant("type", [
65
+ v.strictObject({ type: v.literal("profile"), identifier: profileIdentifier }),
66
+ GrantedOrganizationSubjectSchema,
67
+ ]);
68
+ /** The Profile form of {@link GrantedSubjectSchema}. */
69
+ export const GrantedProfileSubjectSchema = /* @__PURE__ */ v.strictObject({
70
+ type: v.literal("profile"),
71
+ identifier: profileIdentifier,
72
+ });
73
+ const nullable = (schema) => ({ anyOf: [{ type: "null" }, schema] });
74
+ const profilePickerJson = {
75
+ type: "object",
76
+ additionalProperties: false,
77
+ required: ["type"],
78
+ properties: {
79
+ type: { const: "profile" },
80
+ identifier: nullable({ type: "string", pattern: PROFILE_IDENTIFIER_PATTERN }),
81
+ },
82
+ };
83
+ const organizationPickerJson = {
84
+ type: "object",
85
+ additionalProperties: false,
86
+ required: ["type"],
87
+ properties: {
88
+ type: { const: "organization" },
89
+ identifier: nullable({ type: "string", pattern: ORGANIZATION_IDENTIFIER_PATTERN }),
90
+ editable: nullable({ type: "boolean" }),
91
+ },
92
+ };
93
+ /** JSON Schema mirror of {@link SubjectPickerSchema}. */
94
+ export const SUBJECT_PICKER_JSON_SCHEMA = { anyOf: [{ type: "null" }, profilePickerJson, organizationPickerJson] };
95
+ /** JSON Schema mirror of {@link ProfileOnlySubjectPickerSchema}. */
96
+ export const PROFILE_ONLY_SUBJECT_PICKER_JSON_SCHEMA = { anyOf: [{ type: "null" }, profilePickerJson] };
97
+ const grantedProfileJson = {
98
+ type: "object",
99
+ additionalProperties: false,
100
+ required: ["type", "identifier"],
101
+ properties: { type: { const: "profile" }, identifier: { type: "string", pattern: PROFILE_IDENTIFIER_PATTERN } },
102
+ };
103
+ /** JSON Schema mirror of {@link GrantedSubjectSchema}. */
104
+ export const GRANTED_SUBJECT_JSON_SCHEMA = {
105
+ anyOf: [
106
+ grantedProfileJson,
107
+ {
108
+ type: "object",
109
+ additionalProperties: false,
110
+ required: ["type", "identifier"],
111
+ properties: {
112
+ type: { const: "organization" },
113
+ identifier: { type: "string", pattern: ORGANIZATION_IDENTIFIER_PATTERN },
114
+ },
115
+ },
116
+ ],
117
+ };
118
+ /** JSON Schema mirror of {@link GrantedProfileSubjectSchema}. */
119
+ export const GRANTED_PROFILE_SUBJECT_JSON_SCHEMA = grantedProfileJson;
package/dist/scopes.d.ts CHANGED
@@ -1,35 +1,10 @@
1
- /** OAuth scopes currently supported by AndCo and suggested by TypeScript editors. */
2
- export type AndCoKnownScope = "openid" | "email" | "profile" | "profile:write" | "phone" | "offline_access" | "identities:read" | "addresses:read" | "addresses:write" | "organizations:list" | "bank_accounts:read" | "bank_accounts.movements:read";
1
+ /**
2
+ * OAuth scopes Andco supports, suggested by TypeScript editors: OpenID Connect and session concerns
3
+ * only. Every resource permission is an authorization detail (`identity`, `address`, `bank_account`…).
4
+ */
5
+ export type AndCoKnownScope = "openid" | "email" | "profile" | "phone" | "offline_access";
3
6
  /** OAuth scope forwarded to AndCo without transformations. Known scopes are suggested, while custom future scopes remain valid. */
4
7
  export type AndCoScope = AndCoKnownScope | (string & {});
5
8
  /** Valid OAuth scope token: printable ASCII except space, double quote, and backslash. */
6
9
  export declare const ANDCO_SCOPE_REGEX: RegExp;
7
- /** Available modes for starting the authorization flow. */
8
- export declare enum ANDCO_AUTH_MODES {
9
- AUTO = "auto",
10
- SIGNUP = "signup",
11
- LOGIN = "login"
12
- }
13
- /** Union of supported authorization modes. */
14
- export type AndCoAuthMode = ANDCO_AUTH_MODES;
15
- /** Available presentations for the authorization flow. */
16
- export declare enum ANDCO_PRESENTATIONS {
17
- REDIRECT = "redirect",
18
- POPUP = "popup"
19
- }
20
- /** Union of supported authorization presentations. */
21
- export type AndCoPresentation = ANDCO_PRESENTATIONS;
22
- /** Options that control the AndCo authorization flow. */
23
- export type AndCoAuthorizationOptions = {
24
- /** Opens OAuth in the current page by default, or in a user-initiated popup. */
25
- presentation?: AndCoPresentation;
26
- /** Public OAuth client that is requesting access. */
27
- clientId?: string;
28
- /** Scopes requested for this authorization. Required project scopes are added by the server. */
29
- scopes?: AndCoScope[];
30
- /** Selects automatic discovery, signup-only or login-only behavior. */
31
- authMode?: AndCoAuthMode;
32
- /** Registered OAuth `redirect_uri` that receives `code` and `state` in a public PKCE flow. */
33
- redirectTo?: string;
34
- };
35
10
  //# sourceMappingURL=scopes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,OAAO,GACP,SAAS,GACT,eAAe,GACf,OAAO,GACP,gBAAgB,GAChB,iBAAiB,GACjB,gBAAgB,GAChB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,GACpB,8BAA8B,CAAC;AAEnC,mIAAmI;AACnI,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEzD,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,QAAsC,CAAC;AAErE,2DAA2D;AAC3D,oBAAY,gBAAgB;IAC1B,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;CAChB;AAED,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAE7C,0DAA0D;AAC1D,oBAAY,mBAAmB;IAC7B,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AAED,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAEpD,yDAAyD;AACzD,MAAM,MAAM,yBAAyB,GAAG;IACtC,gFAAgF;IAChF,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC"}
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,gBAAgB,CAAC;AAE1F,mIAAmI;AACnI,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEzD,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,QAAsC,CAAC"}