@colixsystems/widget-sdk 0.320.0 → 0.321.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.
package/README.md CHANGED
@@ -73,7 +73,7 @@ The data layer lives in **four separate domain-client packages**, each instantia
73
73
  | **DIRECTORY** | `useUsers(query)` (optional: query) | `{ users, loading, error, refetch, invite, deactivate, reactivate, remove, sendPasswordReset, update }` | `directory.users.*` — `users.read:*` plus the `users.read` (or `users.write`) capability, else `FORBIDDEN` (edits, incl. `sendPasswordReset()` and `update()`, also `users.write:*`; `remove()` also `users.delete:*`) |
74
74
  | **DIRECTORY** | `useGroups(query)` (optional: query) | `{ groups, loading, error, refetch, create, remove, addMember, removeMember }` | `directory.groups.*` — `groups.read:*` (mutations also `groups.write:*`) |
75
75
  | **DIRECTORY** | `useInvites(query)` (optional: query) | `{ invites, loading, error, refetch, resend, revoke }` | `directory.invites.*` — `users.write:*` + the SystemAcl `users.write` capability (the whole invite surface, list included). `query` is `{ status?, q?, app_user_id?, limit?, offset? }` with `status` ∈ `pending \| accepted \| revoked \| expired \| not_sent \| open \| all` (endpoint default `all`; `open` = `pending`, `not_sent` or `expired`); `q` matches the invite's name or email, `app_user_id` returns the invites reserving that user id. `resend(inviteId)` sends the invitation — the first send of a `not_sent` one included. |
76
- | **DIRECTORY** | `useBankIdLink()` | `{ linked, available, status, qr, message, startLink, refresh, cancel, unlink, refetchStatus, … }` | `directory.bankid.*` — no scope (JWT-gated self-service) |
76
+ | **DIRECTORY** | `useBankIdLink()` | `{ linked, available, status, qr, message, startLink, refresh, cancel, unlink, refetchStatus, … }` | `directory.bankid.*` — no scope (JWT-gated self-service). While `pending`, render `qr` in an `<Image>` (`bankid-order-not-shown` otherwise). |
77
77
  | **FILESTORE** (`ctx.filestore`) | `usePdfExport({ spaceType, folderId })` (optional: spaceType, folderId) | `{ openPdf, opening, canOpenPdf, exportToPdf, exporting, error, lastExported }` | `ctx.filestore.files.renderPdf` + `ctx.device.pdfViewer`, `ctx.filestore.files.exportPdf` — `files.write:*`. `openPdf(html, { fileName? })` renders the HTML to a PDF server-side and OPENS it (web: PDF tab; native: print / share sheet) without saving. `exportToPdf(html, { fileName?, folderId? })` renders it and saves it as a file (`application/pdf`). Same server-side renderer on web + native. |
78
78
  | **PAYMENTS** (`ctx.payments`) | `useAccessPlans()` | `{ plans, loading, error, purchaseAvailable, purchase, cancel, refresh }` | `ctx.payments.{listAccessPlans,purchaseAccessPlan,cancelAccessPlan}` — `payments.charge:appUser`. Plans selling access to restricted pages; `purchase(planId)` names only the plan, the server sets price and group. `purchaseAvailable` is `false` in an iOS / Android build (digital goods need store billing): show a visible not-available state. |
79
79
  | **PAYMENTS** (`ctx.payments`) | `useAppSubscription()` | `{ subscription, loading, error, cancel, refresh }` | `ctx.payments.{getAppSubscription,cancelAppSubscription}` — `payments.charge:appUser`. The signed-in user's subscription to a paid app (`{ active, renews, access_ends_at }`); `cancel()` stops it renewing, and access runs to `access_ends_at`. |
@@ -81,7 +81,7 @@ The data layer lives in **four separate domain-client packages**, each instantia
81
81
  | **NOTIFICATIONS** (`ctx.notifications`) | `useSendNotification()` | `{ send, sending, error }` | `ctx.notifications.send` — `notifications.send:appUser`. `send({ recipient_user_id, title, body, link?, payload? })` notifies one app user in the same workspace; call from an event handler (never render); rejects with `NotificationError`. |
82
82
  | **NOTIFICATIONS** (`ctx.notifications`) | `useRecordMutes(tableId)` | `{ isMuted, loading, error, refetch }` | `ctx.notifications.mutes` — no scope. Which records of one table the signed-in user has muted, in one request for a whole list; `isMuted(recordId)` turns false when a timed mute lapses, and a `useRecordMute` write shows at once. |
83
83
  | **NOTIFICATIONS** (`ctx.notifications`) | `useRecordMute(tableId, recordId)` | `{ muted, mutedUntil, loading, error, mute, unmute, refetch }` | `ctx.notifications.mutes` — no scope. Mutes one record's notifications for the signed-in user, `mute(until)` with an ISO time, a `Date`, or `null` for until unmuted. Needs read access to the record (`RECORD_NOT_FOUND` otherwise). |
84
- | **IDENTIFICATION** (`ctx.identification`) | `useIdentification({ provider, purpose, pollIntervalMs })` (optional: every key, and the whole argument) | `{ available, status, qr, autoStartToken, message, identity, identificationId, start, refresh, cancel, reset, … }` | `ctx.identification.*` — no scope (the visitor is deliberately NOT signed in). Gate the UI on `available`; `start()` opens the order and the hook polls to completion. `identity` carries `personal_number_masked` + a stable `subject_hash` — never a raw personal number. |
84
+ | **IDENTIFICATION** (`ctx.identification`) | `useIdentification({ provider, purpose, pollIntervalMs })` (optional: every key, and the whole argument) | `{ available, status, qr, autoStartToken, message, identity, identificationId, start, refresh, cancel, reset, … }` | `ctx.identification.*` — no scope (the visitor is deliberately NOT signed in). Gate the UI on `available`; `start()` opens the order and the hook polls to completion. The hook draws nothing: while `pending`, render `qr` in an `<Image>` and a button calling `Linking.openURL(bankIdAppUrl(autoStartToken))`, or the publish-blocking `bankid-order-not-shown` finding refuses the widget. `identity` carries `personal_number_masked` + a stable `subject_hash` — never a raw personal number. |
85
85
 
86
86
  All list calls return the `{ data, meta }` envelope; the read hooks unwrap `res.data` for you. There is no `useWorkspace()` or `useLogger()` hook — read the theme via `useTheme()` and the locale via `useI18n()`; the host logger lives on `ctx.logger` (`{ debug, info, warn, error }`).
87
87
 
@@ -91,7 +91,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
91
91
 
92
92
  ## Status
93
93
 
94
- `v0.320.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
94
+ `v0.321.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
95
+
96
+ ### What's new in 0.321.0 (contract 1.261.0)
97
+
98
+ **The linter refuses a BankID order nobody can open.** `useIdentification()`, `useFileSignature()` and `useBankIdLink()` draw nothing: the widget shows the order. A widget that called `start()`, `initiate()` or `startLink()` and rendered only a "waiting" text passed every check, and BankID then ended each order unopened (`startFailed`). Starting an order without reading `qr` is now the publish-blocking `bankid-order-not-shown` finding, in `appstudio-widget lint` and in the platform's publish gate alike; `useIdentification` and `useFileSignature` must also read `autoStartToken`. Fix: while `pending`, render `<Image source={{ uri: qr }} />` and a button calling `Linking.openURL(bankIdAppUrl(autoStartToken))`. A widget that only reads a signature's status is not affected.
95
99
 
96
100
  ### What's new in 0.320.0 (contract 1.260.0)
97
101
 
package/dist/contract.cjs CHANGED
@@ -2948,7 +2948,8 @@ const HOOKS = [
2948
2948
  "when BankID can't be used here (provider disabled or no platform cert) — " +
2949
2949
  "hide the Link affordance then. The link flow is an animated-QR poll like " +
2950
2950
  "useFileSignature: startLink() opens an order (status 'pending' + qr — a " +
2951
- "PNG data-URL, render with the Image primitive); refresh() polls (drive on " +
2951
+ "PNG data-URL the widget MUST render with the Image primitive while " +
2952
+ "pending, or the order cannot be opened); refresh() polls (drive on " +
2952
2953
  "a ~2s interval while pending; sets linked=true on complete); cancel() " +
2953
2954
  "aborts; unlink() removes the link (rejects DirectoryError LAST_AUTH_METHOD " +
2954
2955
  "when BankID is the only sign-in method). No requestedScopes entry needed.",
@@ -2956,7 +2957,7 @@ const HOOKS = [
2956
2957
  linked: "boolean | null // null until the status loads",
2957
2958
  available: "boolean // false → hide the Link affordance",
2958
2959
  status: "'pending' | 'complete' | 'failed' | 'cancelled' | null",
2959
- qr: "string | null // PNG data-URL of the animated BankID QR",
2960
+ qr: "string | null // PNG data-URL of the animated BankID QR; while pending the widget MUST render it in <Image source={{ uri: qr }} /> (the hook draws nothing)",
2960
2961
  message: "string | null",
2961
2962
  loading: "boolean",
2962
2963
  statusLoading: "boolean",
@@ -2988,12 +2989,18 @@ const HOOKS = [
2988
2989
  "to e-sign a file use useFileSignature(). On mount it reads provider " +
2989
2990
  "availability; `available` is false when identification can't be used here " +
2990
2991
  "(provider not configured) — render nothing rather than a dead button. " +
2991
- "start() opens an order (status 'pending' + qr, a PNG data-URL to render " +
2992
- "with the Image primitive) and the hook then POLLS to completion itself " +
2993
- "(pollIntervalMs, default 1000; pass 0 to drive refresh() yourself); " +
2994
- "cancel() aborts; reset() clears the flow. autoStartToken opens the " +
2995
- "provider app on the SAME device: Linking.openURL(bankIdAppUrl(" +
2996
- "autoStartToken)) opens bankid:///?autostarttoken=<token>&redirect=null. " +
2992
+ "start() opens an order (status 'pending') and the hook then POLLS to " +
2993
+ "completion itself (pollIntervalMs, default 1000; pass 0 to drive " +
2994
+ "refresh() yourself); cancel() aborts; reset() clears the flow. The hook " +
2995
+ "draws NOTHING: while status is 'pending' the widget MUST show both ways " +
2996
+ "to open the order, or BankID ends it unopened (hint startFailed) — " +
2997
+ "BankID on THIS device, the only way on a phone: a button, shown while " +
2998
+ "autoStartToken is set, whose onPress opens the app " +
2999
+ "(Linking.openURL(bankIdAppUrl(autoStartToken)) opens " +
3000
+ "bankid:///?autostarttoken=<token>&redirect=null); " +
3001
+ "BankID on ANOTHER device: qr (a PNG data-URL, a " +
3002
+ "new frame each poll) in <Image source={{ uri: qr }} />; plus message " +
3003
+ "beside them. The checker refuses a start() without both (bankid-order-not-shown). " +
2997
3004
  "On complete, `identity` is { provider, name, given_name, " +
2998
3005
  "surname, personal_number_masked, subject_hash, identified_at } — there is " +
2999
3006
  "NO raw personal number by design: write personal_number_masked " +
@@ -3005,8 +3012,8 @@ const HOOKS = [
3005
3012
  available: "boolean // false → don't offer the flow",
3006
3013
  availabilityLoading: "boolean",
3007
3014
  status: "'pending' | 'complete' | 'failed' | 'cancelled' | null",
3008
- qr: "string | null // PNG data-URL of the animated QR",
3009
- autoStartToken: "string | null // same-device deeplink token",
3015
+ qr: "string | null // PNG data-URL of the animated QR; while pending the widget MUST render it in <Image source={{ uri: qr }} /> (the hook draws nothing)",
3016
+ autoStartToken: "string | null // BankID on this device, the only way on a phone: while set the widget MUST show a button calling Linking.openURL(bankIdAppUrl(autoStartToken))",
3010
3017
  message: "string | null // display-ready instruction for this step",
3011
3018
  identity:
3012
3019
  "{ provider, name, given_name, surname, personal_number_masked, subject_hash, identified_at } | null",
@@ -7012,7 +7019,11 @@ const CONTRACT = deepFreeze({
7012
7019
  // the publish-blocking `payment-kind-required` finding.
7013
7020
  // 1.259.0: `useDirectory()` / `useUsers()` rows carry `photo_url`, the
7014
7021
  // person's profile photo as an absolute URL or null.
7015
- version: "1.260.0",
7022
+ // 1.261.0: stricter lint (sc-17199) — starting a BankID order with
7023
+ // useIdentification / useFileSignature / useBankIdLink without rendering
7024
+ // its qr (and, where it exists, the autoStartToken button) is the
7025
+ // publish-blocking `bankid-order-not-shown` finding.
7026
+ version: "1.261.0",
7016
7027
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7017
7028
  hooks: HOOKS,
7018
7029
  primitives: PRIMITIVES,
package/dist/contract.js CHANGED
@@ -2943,7 +2943,8 @@ const HOOKS = [
2943
2943
  "when BankID can't be used here (provider disabled or no platform cert) — " +
2944
2944
  "hide the Link affordance then. The link flow is an animated-QR poll like " +
2945
2945
  "useFileSignature: startLink() opens an order (status 'pending' + qr — a " +
2946
- "PNG data-URL, render with the Image primitive); refresh() polls (drive on " +
2946
+ "PNG data-URL the widget MUST render with the Image primitive while " +
2947
+ "pending, or the order cannot be opened); refresh() polls (drive on " +
2947
2948
  "a ~2s interval while pending; sets linked=true on complete); cancel() " +
2948
2949
  "aborts; unlink() removes the link (rejects DirectoryError LAST_AUTH_METHOD " +
2949
2950
  "when BankID is the only sign-in method). No requestedScopes entry needed.",
@@ -2951,7 +2952,7 @@ const HOOKS = [
2951
2952
  linked: "boolean | null // null until the status loads",
2952
2953
  available: "boolean // false → hide the Link affordance",
2953
2954
  status: "'pending' | 'complete' | 'failed' | 'cancelled' | null",
2954
- qr: "string | null // PNG data-URL of the animated BankID QR",
2955
+ qr: "string | null // PNG data-URL of the animated BankID QR; while pending the widget MUST render it in <Image source={{ uri: qr }} /> (the hook draws nothing)",
2955
2956
  message: "string | null",
2956
2957
  loading: "boolean",
2957
2958
  statusLoading: "boolean",
@@ -2983,12 +2984,18 @@ const HOOKS = [
2983
2984
  "to e-sign a file use useFileSignature(). On mount it reads provider " +
2984
2985
  "availability; `available` is false when identification can't be used here " +
2985
2986
  "(provider not configured) — render nothing rather than a dead button. " +
2986
- "start() opens an order (status 'pending' + qr, a PNG data-URL to render " +
2987
- "with the Image primitive) and the hook then POLLS to completion itself " +
2988
- "(pollIntervalMs, default 1000; pass 0 to drive refresh() yourself); " +
2989
- "cancel() aborts; reset() clears the flow. autoStartToken opens the " +
2990
- "provider app on the SAME device: Linking.openURL(bankIdAppUrl(" +
2991
- "autoStartToken)) opens bankid:///?autostarttoken=<token>&redirect=null. " +
2987
+ "start() opens an order (status 'pending') and the hook then POLLS to " +
2988
+ "completion itself (pollIntervalMs, default 1000; pass 0 to drive " +
2989
+ "refresh() yourself); cancel() aborts; reset() clears the flow. The hook " +
2990
+ "draws NOTHING: while status is 'pending' the widget MUST show both ways " +
2991
+ "to open the order, or BankID ends it unopened (hint startFailed) — " +
2992
+ "BankID on THIS device, the only way on a phone: a button, shown while " +
2993
+ "autoStartToken is set, whose onPress opens the app " +
2994
+ "(Linking.openURL(bankIdAppUrl(autoStartToken)) opens " +
2995
+ "bankid:///?autostarttoken=<token>&redirect=null); " +
2996
+ "BankID on ANOTHER device: qr (a PNG data-URL, a " +
2997
+ "new frame each poll) in <Image source={{ uri: qr }} />; plus message " +
2998
+ "beside them. The checker refuses a start() without both (bankid-order-not-shown). " +
2992
2999
  "On complete, `identity` is { provider, name, given_name, " +
2993
3000
  "surname, personal_number_masked, subject_hash, identified_at } — there is " +
2994
3001
  "NO raw personal number by design: write personal_number_masked " +
@@ -3000,8 +3007,8 @@ const HOOKS = [
3000
3007
  available: "boolean // false → don't offer the flow",
3001
3008
  availabilityLoading: "boolean",
3002
3009
  status: "'pending' | 'complete' | 'failed' | 'cancelled' | null",
3003
- qr: "string | null // PNG data-URL of the animated QR",
3004
- autoStartToken: "string | null // same-device deeplink token",
3010
+ qr: "string | null // PNG data-URL of the animated QR; while pending the widget MUST render it in <Image source={{ uri: qr }} /> (the hook draws nothing)",
3011
+ autoStartToken: "string | null // BankID on this device, the only way on a phone: while set the widget MUST show a button calling Linking.openURL(bankIdAppUrl(autoStartToken))",
3005
3012
  message: "string | null // display-ready instruction for this step",
3006
3013
  identity:
3007
3014
  "{ provider, name, given_name, surname, personal_number_masked, subject_hash, identified_at } | null",
@@ -7007,7 +7014,11 @@ const CONTRACT = deepFreeze({
7007
7014
  // the publish-blocking `payment-kind-required` finding.
7008
7015
  // 1.259.0: `useDirectory()` / `useUsers()` rows carry `photo_url`, the
7009
7016
  // person's profile photo as an absolute URL or null.
7010
- version: "1.260.0",
7017
+ // 1.261.0: stricter lint (sc-17199) — starting a BankID order with
7018
+ // useIdentification / useFileSignature / useBankIdLink without rendering
7019
+ // its qr (and, where it exists, the autoStartToken button) is the
7020
+ // publish-blocking `bankid-order-not-shown` finding.
7021
+ version: "1.261.0",
7011
7022
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7012
7023
  hooks: HOOKS,
7013
7024
  primitives: PRIMITIVES,
package/dist/linter.cjs CHANGED
@@ -1769,6 +1769,68 @@ function _datastoreErrorHandlingRules(source) {
1769
1769
  ];
1770
1770
  }
1771
1771
 
1772
+ // sc-17199 — a BankID order the user cannot open. The hooks draw nothing, so a
1773
+ // widget that starts one without its QR or same-device button shows only
1774
+ // "waiting" and BankID ends the order unopened (startFailed).
1775
+ const BANKID_ORDER_HOOKS = [
1776
+ { hook: "useIdentification", verb: "start", sameDevice: true },
1777
+ { hook: "useFileSignature", verb: "initiate", sameDevice: true },
1778
+ { hook: "useBankIdLink", verb: "startLink", sameDevice: false },
1779
+ ];
1780
+
1781
+ function _destructuredLocals(pattern) {
1782
+ const locals = {};
1783
+ for (const part of pattern.slice(1, -1).split(",")) {
1784
+ const m = /^\s*(\w+)\s*(?::\s*([\w$]+))?/.exec(part);
1785
+ if (m) locals[m[1]] = m[2] || m[1];
1786
+ }
1787
+ return locals;
1788
+ }
1789
+
1790
+ // Which reads of a binding count: `idn.qr` on an object, the local name on a destructure.
1791
+ function _bankIdOrderReads(binding) {
1792
+ const escaped = (name) => name.replace(/\$/g, "\\$");
1793
+ if (!binding.startsWith("{")) {
1794
+ const name = escaped(binding);
1795
+ const member = (field) => new RegExp(String.raw`(?<![\w$])${name}\s*\??\.\s*${field}(?![\w$])`);
1796
+ // Handed whole to a child component, which draws the order itself.
1797
+ const handedOn = new RegExp(String.raw`=\{\s*${name}\s*\}|\.\.\.\s*${name}(?![\w$])`);
1798
+ return { read: member, handedOn };
1799
+ }
1800
+ const locals = _destructuredLocals(binding);
1801
+ const word = (local) => new RegExp(String.raw`(?<![\w$.])${escaped(local)}(?![\w$])`);
1802
+ return { read: (field) => (locals[field] ? word(locals[field]) : null), handedOn: null };
1803
+ }
1804
+
1805
+ function _bankIdOrderRules(source) {
1806
+ const code = _stripNonCode(source);
1807
+ const findings = [];
1808
+ for (const { hook, verb, sameDevice } of BANKID_ORDER_HOOKS) {
1809
+ const bindings = new RegExp(String.raw`\b(?:const|let|var)\s+([\w$]+|\{[^{}]*\})\s*=\s*${hook}\s*\(`, "g");
1810
+ for (const call of code.matchAll(bindings)) {
1811
+ // The destructure itself names every field; only reads elsewhere count.
1812
+ const rest = code.slice(0, call.index) + " ".repeat(call[0].length) + code.slice(call.index + call[0].length);
1813
+ const { read, handedOn } = _bankIdOrderReads(call[1]);
1814
+ const reads = (field) => !!read(field) && read(field).test(rest);
1815
+ if (!reads(verb) || (handedOn && handedOn.test(rest))) continue;
1816
+ if (reads("qr") && (!sameDevice || reads("autoStartToken"))) continue;
1817
+ const line = code.slice(0, call.index).split(/\r?\n/).length;
1818
+ findings.push({
1819
+ rule: "bankid-order-not-shown",
1820
+ severity: "error",
1821
+ label:
1822
+ `${hook}().${verb}() opens a BankID order the widget never shows. While pending render ` +
1823
+ `<Image source={{ uri: qr }} />` +
1824
+ (sameDevice ? ` and a button calling Linking.openURL(bankIdAppUrl(autoStartToken))` : "") +
1825
+ `, or BankID ends it unopened.`,
1826
+ line,
1827
+ snippet: (source.split(/\r?\n/)[line - 1] || "").trim().slice(0, 200),
1828
+ });
1829
+ }
1830
+ }
1831
+ return findings;
1832
+ }
1833
+
1772
1834
  // sc-16511 — soft warning, the read twin of `datastore-error-not-branched`.
1773
1835
  // A read refused because the viewer may not see the table (a signed-out
1774
1836
  // visitor gets NOT_FOUND, a signed-in one FORBIDDEN) never clears on a retry,
@@ -3502,6 +3564,7 @@ function lintSource(source, options) {
3502
3564
  findings.push(..._paymentErrorHandlingRules(source));
3503
3565
  findings.push(..._datastoreErrorHandlingRules(source));
3504
3566
  findings.push(..._readErrorHandlingRules(source));
3567
+ findings.push(..._bankIdOrderRules(source));
3505
3568
  // sc-5206 — soft warnings steering a widget toward the two new hooks.
3506
3569
  findings.push(..._rawUseMemoIntoDatastoreQueryRules(source));
3507
3570
  findings.push(..._handRolledWriteGateRules(source));
package/dist/linter.js CHANGED
@@ -1764,6 +1764,68 @@ function _datastoreErrorHandlingRules(source) {
1764
1764
  ];
1765
1765
  }
1766
1766
 
1767
+ // sc-17199 — a BankID order the user cannot open. The hooks draw nothing, so a
1768
+ // widget that starts one without its QR or same-device button shows only
1769
+ // "waiting" and BankID ends the order unopened (startFailed).
1770
+ const BANKID_ORDER_HOOKS = [
1771
+ { hook: "useIdentification", verb: "start", sameDevice: true },
1772
+ { hook: "useFileSignature", verb: "initiate", sameDevice: true },
1773
+ { hook: "useBankIdLink", verb: "startLink", sameDevice: false },
1774
+ ];
1775
+
1776
+ function _destructuredLocals(pattern) {
1777
+ const locals = {};
1778
+ for (const part of pattern.slice(1, -1).split(",")) {
1779
+ const m = /^\s*(\w+)\s*(?::\s*([\w$]+))?/.exec(part);
1780
+ if (m) locals[m[1]] = m[2] || m[1];
1781
+ }
1782
+ return locals;
1783
+ }
1784
+
1785
+ // Which reads of a binding count: `idn.qr` on an object, the local name on a destructure.
1786
+ function _bankIdOrderReads(binding) {
1787
+ const escaped = (name) => name.replace(/\$/g, "\\$");
1788
+ if (!binding.startsWith("{")) {
1789
+ const name = escaped(binding);
1790
+ const member = (field) => new RegExp(String.raw`(?<![\w$])${name}\s*\??\.\s*${field}(?![\w$])`);
1791
+ // Handed whole to a child component, which draws the order itself.
1792
+ const handedOn = new RegExp(String.raw`=\{\s*${name}\s*\}|\.\.\.\s*${name}(?![\w$])`);
1793
+ return { read: member, handedOn };
1794
+ }
1795
+ const locals = _destructuredLocals(binding);
1796
+ const word = (local) => new RegExp(String.raw`(?<![\w$.])${escaped(local)}(?![\w$])`);
1797
+ return { read: (field) => (locals[field] ? word(locals[field]) : null), handedOn: null };
1798
+ }
1799
+
1800
+ function _bankIdOrderRules(source) {
1801
+ const code = _stripNonCode(source);
1802
+ const findings = [];
1803
+ for (const { hook, verb, sameDevice } of BANKID_ORDER_HOOKS) {
1804
+ const bindings = new RegExp(String.raw`\b(?:const|let|var)\s+([\w$]+|\{[^{}]*\})\s*=\s*${hook}\s*\(`, "g");
1805
+ for (const call of code.matchAll(bindings)) {
1806
+ // The destructure itself names every field; only reads elsewhere count.
1807
+ const rest = code.slice(0, call.index) + " ".repeat(call[0].length) + code.slice(call.index + call[0].length);
1808
+ const { read, handedOn } = _bankIdOrderReads(call[1]);
1809
+ const reads = (field) => !!read(field) && read(field).test(rest);
1810
+ if (!reads(verb) || (handedOn && handedOn.test(rest))) continue;
1811
+ if (reads("qr") && (!sameDevice || reads("autoStartToken"))) continue;
1812
+ const line = code.slice(0, call.index).split(/\r?\n/).length;
1813
+ findings.push({
1814
+ rule: "bankid-order-not-shown",
1815
+ severity: "error",
1816
+ label:
1817
+ `${hook}().${verb}() opens a BankID order the widget never shows. While pending render ` +
1818
+ `<Image source={{ uri: qr }} />` +
1819
+ (sameDevice ? ` and a button calling Linking.openURL(bankIdAppUrl(autoStartToken))` : "") +
1820
+ `, or BankID ends it unopened.`,
1821
+ line,
1822
+ snippet: (source.split(/\r?\n/)[line - 1] || "").trim().slice(0, 200),
1823
+ });
1824
+ }
1825
+ }
1826
+ return findings;
1827
+ }
1828
+
1767
1829
  // sc-16511 — soft warning, the read twin of `datastore-error-not-branched`.
1768
1830
  // A read refused because the viewer may not see the table (a signed-out
1769
1831
  // visitor gets NOT_FOUND, a signed-in one FORBIDDEN) never clears on a retry,
@@ -3497,6 +3559,7 @@ export function lintSource(source, options) {
3497
3559
  findings.push(..._paymentErrorHandlingRules(source));
3498
3560
  findings.push(..._datastoreErrorHandlingRules(source));
3499
3561
  findings.push(..._readErrorHandlingRules(source));
3562
+ findings.push(..._bankIdOrderRules(source));
3500
3563
  // sc-5206 — soft warnings steering a widget toward the two new hooks.
3501
3564
  findings.push(..._rawUseMemoIntoDatastoreQueryRules(source));
3502
3565
  findings.push(..._handRolledWriteGateRules(source));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.320.0",
3
+ "version": "0.321.0",
4
4
  "description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/contract.js CHANGED
@@ -2943,7 +2943,8 @@ const HOOKS = [
2943
2943
  "when BankID can't be used here (provider disabled or no platform cert) — " +
2944
2944
  "hide the Link affordance then. The link flow is an animated-QR poll like " +
2945
2945
  "useFileSignature: startLink() opens an order (status 'pending' + qr — a " +
2946
- "PNG data-URL, render with the Image primitive); refresh() polls (drive on " +
2946
+ "PNG data-URL the widget MUST render with the Image primitive while " +
2947
+ "pending, or the order cannot be opened); refresh() polls (drive on " +
2947
2948
  "a ~2s interval while pending; sets linked=true on complete); cancel() " +
2948
2949
  "aborts; unlink() removes the link (rejects DirectoryError LAST_AUTH_METHOD " +
2949
2950
  "when BankID is the only sign-in method). No requestedScopes entry needed.",
@@ -2951,7 +2952,7 @@ const HOOKS = [
2951
2952
  linked: "boolean | null // null until the status loads",
2952
2953
  available: "boolean // false → hide the Link affordance",
2953
2954
  status: "'pending' | 'complete' | 'failed' | 'cancelled' | null",
2954
- qr: "string | null // PNG data-URL of the animated BankID QR",
2955
+ qr: "string | null // PNG data-URL of the animated BankID QR; while pending the widget MUST render it in <Image source={{ uri: qr }} /> (the hook draws nothing)",
2955
2956
  message: "string | null",
2956
2957
  loading: "boolean",
2957
2958
  statusLoading: "boolean",
@@ -2983,12 +2984,18 @@ const HOOKS = [
2983
2984
  "to e-sign a file use useFileSignature(). On mount it reads provider " +
2984
2985
  "availability; `available` is false when identification can't be used here " +
2985
2986
  "(provider not configured) — render nothing rather than a dead button. " +
2986
- "start() opens an order (status 'pending' + qr, a PNG data-URL to render " +
2987
- "with the Image primitive) and the hook then POLLS to completion itself " +
2988
- "(pollIntervalMs, default 1000; pass 0 to drive refresh() yourself); " +
2989
- "cancel() aborts; reset() clears the flow. autoStartToken opens the " +
2990
- "provider app on the SAME device: Linking.openURL(bankIdAppUrl(" +
2991
- "autoStartToken)) opens bankid:///?autostarttoken=<token>&redirect=null. " +
2987
+ "start() opens an order (status 'pending') and the hook then POLLS to " +
2988
+ "completion itself (pollIntervalMs, default 1000; pass 0 to drive " +
2989
+ "refresh() yourself); cancel() aborts; reset() clears the flow. The hook " +
2990
+ "draws NOTHING: while status is 'pending' the widget MUST show both ways " +
2991
+ "to open the order, or BankID ends it unopened (hint startFailed) — " +
2992
+ "BankID on THIS device, the only way on a phone: a button, shown while " +
2993
+ "autoStartToken is set, whose onPress opens the app " +
2994
+ "(Linking.openURL(bankIdAppUrl(autoStartToken)) opens " +
2995
+ "bankid:///?autostarttoken=<token>&redirect=null); " +
2996
+ "BankID on ANOTHER device: qr (a PNG data-URL, a " +
2997
+ "new frame each poll) in <Image source={{ uri: qr }} />; plus message " +
2998
+ "beside them. The checker refuses a start() without both (bankid-order-not-shown). " +
2992
2999
  "On complete, `identity` is { provider, name, given_name, " +
2993
3000
  "surname, personal_number_masked, subject_hash, identified_at } — there is " +
2994
3001
  "NO raw personal number by design: write personal_number_masked " +
@@ -3000,8 +3007,8 @@ const HOOKS = [
3000
3007
  available: "boolean // false → don't offer the flow",
3001
3008
  availabilityLoading: "boolean",
3002
3009
  status: "'pending' | 'complete' | 'failed' | 'cancelled' | null",
3003
- qr: "string | null // PNG data-URL of the animated QR",
3004
- autoStartToken: "string | null // same-device deeplink token",
3010
+ qr: "string | null // PNG data-URL of the animated QR; while pending the widget MUST render it in <Image source={{ uri: qr }} /> (the hook draws nothing)",
3011
+ autoStartToken: "string | null // BankID on this device, the only way on a phone: while set the widget MUST show a button calling Linking.openURL(bankIdAppUrl(autoStartToken))",
3005
3012
  message: "string | null // display-ready instruction for this step",
3006
3013
  identity:
3007
3014
  "{ provider, name, given_name, surname, personal_number_masked, subject_hash, identified_at } | null",
@@ -7007,7 +7014,11 @@ const CONTRACT = deepFreeze({
7007
7014
  // the publish-blocking `payment-kind-required` finding.
7008
7015
  // 1.259.0: `useDirectory()` / `useUsers()` rows carry `photo_url`, the
7009
7016
  // person's profile photo as an absolute URL or null.
7010
- version: "1.260.0",
7017
+ // 1.261.0: stricter lint (sc-17199) — starting a BankID order with
7018
+ // useIdentification / useFileSignature / useBankIdLink without rendering
7019
+ // its qr (and, where it exists, the autoStartToken button) is the
7020
+ // publish-blocking `bankid-order-not-shown` finding.
7021
+ version: "1.261.0",
7011
7022
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7012
7023
  hooks: HOOKS,
7013
7024
  primitives: PRIMITIVES,