@colixsystems/widget-sdk 0.320.0 → 0.321.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/contract.cjs +22 -11
- package/dist/contract.js +22 -11
- package/dist/hooks.js +11 -1
- package/dist/index.d.ts +11 -5
- package/dist/linter.cjs +63 -0
- package/dist/linter.js +63 -0
- package/package.json +1 -1
- package/src/contract.js +22 -11
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,15 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.321.1` — 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.1 (contract 1.261.0)
|
|
97
|
+
|
|
98
|
+
**A refused plan purchase now says why.** Buying a plan with `useAccessPlans().purchase` is refused with `ALREADY_OWNED` when the user already holds it, and with `PURCHASE_IN_PROGRESS` when their earlier checkout for it is still open (it goes stale after about 15 minutes). Both were reported as retryable, so a widget that follows the usual pattern (show `err.message` only when `retryable` is `false`) showed a generic "did not go through" with a Try again button. They are now non-retryable, so `err.message` ("You already have this plan.", "A payment for this plan is already in progress.") is what the widget shows. Widgets already built to that pattern change without a rebuild.
|
|
99
|
+
|
|
100
|
+
### What's new in 0.321.0 (contract 1.261.0)
|
|
101
|
+
|
|
102
|
+
**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
103
|
|
|
96
104
|
### What's new in 0.320.0 (contract 1.260.0)
|
|
97
105
|
|
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
|
|
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'
|
|
2992
|
-
"
|
|
2993
|
-
"(
|
|
2994
|
-
"
|
|
2995
|
-
"
|
|
2996
|
-
"
|
|
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 //
|
|
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
|
-
|
|
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
|
|
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'
|
|
2987
|
-
"
|
|
2988
|
-
"(
|
|
2989
|
-
"
|
|
2990
|
-
"
|
|
2991
|
-
"
|
|
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 //
|
|
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
|
-
|
|
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/hooks.js
CHANGED
|
@@ -7077,8 +7077,11 @@ export function useIdentification(options) {
|
|
|
7077
7077
|
// sc-4650 — the refusals that retrying the SAME charge can never clear: the
|
|
7078
7078
|
// workspace, the widget manifest, or the amount has to change first. Everything
|
|
7079
7079
|
// else (a decline, a provider blip, an unknown failure) is worth another
|
|
7080
|
-
// attempt. A widget reads this through `PaymentError.retryable`.
|
|
7080
|
+
// attempt. A widget reads this through `PaymentError.retryable`. The two plan
|
|
7081
|
+
// refusals are here so a widget shows their reason: an immediate retry cannot
|
|
7082
|
+
// clear them (a plan the user already holds; another open checkout for it).
|
|
7081
7083
|
const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
7084
|
+
"ALREADY_OWNED",
|
|
7082
7085
|
"AUTH_REQUIRED",
|
|
7083
7086
|
"AMOUNT_TOO_LARGE",
|
|
7084
7087
|
"BUSINESS_IDENTITY_REQUIRED",
|
|
@@ -7095,6 +7098,7 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7095
7098
|
"PAYMENTS_DISABLED",
|
|
7096
7099
|
"PAYMENTS_SCOPE_NOT_GRANTED",
|
|
7097
7100
|
"PAYMENTS_UNAVAILABLE",
|
|
7101
|
+
"PURCHASE_IN_PROGRESS",
|
|
7098
7102
|
"TRIAL_RESTRICTED",
|
|
7099
7103
|
"UNSUPPORTED_CURRENCY",
|
|
7100
7104
|
"VALIDATION",
|
|
@@ -7124,6 +7128,12 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7124
7128
|
* `order` is not one this user can pay for
|
|
7125
7129
|
* - "ORDER_PAYMENT_IN_PROGRESS" — another checkout for the order is open
|
|
7126
7130
|
* (retryable: it clears when that one ends)
|
|
7131
|
+
* - "ALREADY_OWNED" — `useAccessPlans().purchase` for a plan the
|
|
7132
|
+
* user already holds; show the message
|
|
7133
|
+
* - "PURCHASE_IN_PROGRESS" — `useAccessPlans().purchase` while the
|
|
7134
|
+
* user's earlier checkout for that plan is
|
|
7135
|
+
* still open (it goes stale after about 15
|
|
7136
|
+
* minutes); show the message, not a retry
|
|
7127
7137
|
* - "TRIAL_RESTRICTED" — a trial workspace takes no guest payments
|
|
7128
7138
|
* - "GUEST_CHECKOUT_LIMIT_REACHED" — the shop's guest budget is spent for now
|
|
7129
7139
|
* - "CAPTCHA_FAILED" / "CAPTCHA_UNAVAILABLE" — the guest's security check
|
package/dist/index.d.ts
CHANGED
|
@@ -1722,11 +1722,15 @@ export interface AppSubscriptionApi {
|
|
|
1722
1722
|
export function useAppSubscription(): AppSubscriptionApi;
|
|
1723
1723
|
|
|
1724
1724
|
/**
|
|
1725
|
-
* Rejection thrown by both `usePayments()` callbacks
|
|
1726
|
-
*
|
|
1727
|
-
* `
|
|
1728
|
-
*
|
|
1729
|
-
* "try again" that loops the payer
|
|
1725
|
+
* Rejection thrown by both `usePayments()` callbacks and by
|
|
1726
|
+
* `useAccessPlans().purchase`. `code` is the server's own reason when it sent
|
|
1727
|
+
* one; `message` is its user-safe sentence. Branch on `retryable`: false means
|
|
1728
|
+
* the same charge can never succeed until the workspace, the manifest, or the
|
|
1729
|
+
* amount changes — show the reason, not a "try again" that loops the payer
|
|
1730
|
+
* forever. Two plan refusals are also non-retryable so their reason shows:
|
|
1731
|
+
* `ALREADY_OWNED` (the user holds the plan) and `PURCHASE_IN_PROGRESS` (their
|
|
1732
|
+
* earlier checkout for the plan is still open; it goes stale after about 15
|
|
1733
|
+
* minutes).
|
|
1730
1734
|
*/
|
|
1731
1735
|
export class PaymentError extends Error {
|
|
1732
1736
|
code:
|
|
@@ -1746,6 +1750,8 @@ export class PaymentError extends Error {
|
|
|
1746
1750
|
| "ORDER_NOT_PAYABLE"
|
|
1747
1751
|
| "ORDER_ALREADY_PAID"
|
|
1748
1752
|
| "ORDER_PAYMENT_IN_PROGRESS"
|
|
1753
|
+
| "ALREADY_OWNED"
|
|
1754
|
+
| "PURCHASE_IN_PROGRESS"
|
|
1749
1755
|
| "TRIAL_RESTRICTED"
|
|
1750
1756
|
| "GUEST_CHECKOUT_LIMIT_REACHED"
|
|
1751
1757
|
| "CAPTCHA_FAILED"
|
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
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
|
|
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'
|
|
2987
|
-
"
|
|
2988
|
-
"(
|
|
2989
|
-
"
|
|
2990
|
-
"
|
|
2991
|
-
"
|
|
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 //
|
|
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
|
-
|
|
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,
|