@fabrika/auth-core 0.9.0-dev.16 → 0.9.0-dev.18

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/auth-core",
3
- "version": "0.9.0-dev.16",
3
+ "version": "0.9.0-dev.18",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
package/src/locale.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // it shows. The contract declares both; IAM's catalog covers every locale here, so adding one fails its typecheck.
3
3
 
4
4
  /** The languages IAM renders its pages and its own e-mails in. */
5
- export const LOCALES = ['en', 'cs'] as const
5
+ export const LOCALES = ['en', 'cs', 'uk'] as const
6
6
 
7
7
  export type Locale = (typeof LOCALES)[number]
8
8
 
package/src/membership.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  // and a platform component that implements `IamRpc` does not have to.
7
7
 
8
8
  import type { ContractArtifact, DimensionArtifact, EndpointRow } from './contract'
9
+ import { isLocale, type Locale, LOCALES } from './locale'
9
10
  import type { PrincipalAffiliation, Scope } from './types'
10
11
 
11
12
  /**
@@ -174,17 +175,24 @@ export const MAX_INVITATION_MESSAGE_LENGTH = 1000
174
175
  * What an invitation by address carries besides its role. `label` is the invited person's company as the application
175
176
  * names it, `message` the inviter's personal note; both are plain text IAM escapes wherever it inserts them. `resend`
176
177
  * rotates the open invitation's link, restarts its lifetime and sends it again; without it, repeating an invitation
177
- * answers the open one and sends nothing.
178
+ * answers the open one and sends nothing. `locale` is the invited person's language, when the application knows it: IAM
179
+ * writes the invitation and the pages its link opens in it, and its acceptance keeps it as the person's, so IAM's later
180
+ * e-mails (a password reset) and pages speak it too. Without one, IAM speaks the language the person already has, else the
181
+ * application's. A resend that names one replaces the stored one.
178
182
  */
179
183
  export interface InvitationOptions {
180
184
  readonly label?: string
181
185
  readonly message?: string
182
186
  readonly resend?: boolean
187
+ readonly locale?: Locale
183
188
  }
184
189
 
185
- /** Why IAM refuses an invitation's label or message, or `null`. A message may break lines; nothing else is a control character. */
190
+ /** Why IAM refuses an invitation's label, message or locale, or `null`. A message may break lines; nothing else is a control character. */
186
191
  export function invitationOptionsProblem(options: InvitationOptions): string | null {
187
- const { label, message } = options
192
+ const { label, message, locale } = options
193
+ if (locale !== undefined && !isLocale(locale)) {
194
+ return `an invitation locale is one of ${LOCALES.map((value) => `'${value}'`).join(', ')}`
195
+ }
188
196
  if (label !== undefined && (label.length > MAX_INVITATION_LABEL_LENGTH || /\p{Cc}/u.test(label))) {
189
197
  return `an invitation label is at most ${MAX_INVITATION_LABEL_LENGTH} characters on one line`
190
198
  }
@@ -233,7 +241,7 @@ export interface AssignMemberInput extends MembershipCaller {
233
241
  scope: Scope
234
242
  role: string
235
243
  member: MemberTarget
236
- /** Only with an address: the invitation's label, message and resend (`InvitationOptions`). */
244
+ /** Only with an address: the invitation's label, message, resend and locale (`InvitationOptions`). */
237
245
  invitation?: InvitationOptions
238
246
  }
239
247
 
@@ -1,5 +1,5 @@
1
1
  /** The languages IAM renders its pages and its own e-mails in. */
2
- export declare const LOCALES: readonly ["en", "cs"];
2
+ export declare const LOCALES: readonly ["en", "cs", "uk"];
3
3
  export type Locale = (typeof LOCALES)[number];
4
4
  /** IAM's language for a request that names no application, or one that declares none. */
5
5
  export declare const DEFAULT_LOCALE: Locale;
@@ -1,4 +1,5 @@
1
1
  import type { ContractArtifact, EndpointRow } from './contract';
2
+ import { type Locale } from './locale';
2
3
  import type { PrincipalAffiliation, Scope } from './types';
3
4
  /**
4
5
  * What an endpoint may ask IAM about the members of its own target (`ctx.members`): `manage` where its action is the
@@ -98,14 +99,18 @@ export declare const MAX_INVITATION_MESSAGE_LENGTH = 1000;
98
99
  * What an invitation by address carries besides its role. `label` is the invited person's company as the application
99
100
  * names it, `message` the inviter's personal note; both are plain text IAM escapes wherever it inserts them. `resend`
100
101
  * rotates the open invitation's link, restarts its lifetime and sends it again; without it, repeating an invitation
101
- * answers the open one and sends nothing.
102
+ * answers the open one and sends nothing. `locale` is the invited person's language, when the application knows it: IAM
103
+ * writes the invitation and the pages its link opens in it, and its acceptance keeps it as the person's, so IAM's later
104
+ * e-mails (a password reset) and pages speak it too. Without one, IAM speaks the language the person already has, else the
105
+ * application's. A resend that names one replaces the stored one.
102
106
  */
103
107
  export interface InvitationOptions {
104
108
  readonly label?: string;
105
109
  readonly message?: string;
106
110
  readonly resend?: boolean;
111
+ readonly locale?: Locale;
107
112
  }
108
- /** Why IAM refuses an invitation's label or message, or `null`. A message may break lines; nothing else is a control character. */
113
+ /** Why IAM refuses an invitation's label, message or locale, or `null`. A message may break lines; nothing else is a control character. */
109
114
  export declare function invitationOptionsProblem(options: InvitationOptions): string | null;
110
115
  /** How long a delegation grant may be held before it is spent. One request, so seconds. */
111
116
  export declare const DELEGATION_GRANT_TTL_SECONDS = 120;
@@ -152,7 +157,7 @@ export interface AssignMemberInput extends MembershipCaller {
152
157
  scope: Scope;
153
158
  role: string;
154
159
  member: MemberTarget;
155
- /** Only with an address: the invitation's label, message and resend (`InvitationOptions`). */
160
+ /** Only with an address: the invitation's label, message, resend and locale (`InvitationOptions`). */
156
161
  invitation?: InvitationOptions;
157
162
  }
158
163
  export type AssignMemberResult = {