@terminal3/t3n-sdk 3.10.0 → 3.11.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
@@ -156,6 +156,18 @@ try {
156
156
  For tests that "just want it to work", `runOtpThenUserInput` chains the three
157
157
  calls behind a single `getOtpCode` callback.
158
158
 
159
+ ### Email-OTP login: skip the user-layer OTP
160
+
161
+ The example above is for a **wallet / OIDC** session proving an email for the
162
+ first time. If the session instead logged in via email-OTP
163
+ (`authenticate(createEmailOtpAuthInput(...))`), the node already proved that
164
+ email during login and sent the only OTP code. For that email,
165
+ `submitUserInput` passes the verified-email gate on the session authenticator
166
+ alone and the node auto-stamps `verified_contacts.email` — so call it directly,
167
+ with **no** `otpRequest` / `otpVerify` in between (those would send a redundant
168
+ second OTP email). Use the user-layer OTP only to verify a contact the session
169
+ has not already proven — a phone, or an email on a wallet/OIDC session.
170
+
159
171
  ## License
160
172
 
161
173
  MIT
package/dist/index.d.ts CHANGED
@@ -1708,6 +1708,28 @@ declare class T3nClient {
1708
1708
  * @throws {ContractResponseError} when the response is not valid JSON
1709
1709
  */
1710
1710
  executeAndDecode<T = unknown>(payload: unknown, schema?: ContractResponseSchema<T>): Promise<T>;
1711
+ /**
1712
+ * Create a new organisation owned by the authenticated caller.
1713
+ *
1714
+ * Dispatches `organisation-create-self` on `tee:organisation/contracts`
1715
+ * over the standard authenticated `action.execute` path. The node
1716
+ * injects the caller's DID into the contract call context, and the
1717
+ * contract forces the new organisation's sole initial admin to that
1718
+ * caller — the caller cannot nominate a different admin, and the
1719
+ * organisation is always created as a root. The caller must already be
1720
+ * a registered user, and the call is metered against the caller's own
1721
+ * credits.
1722
+ *
1723
+ * The returned DID is the org identifier the org-data and payroll
1724
+ * surfaces expect (e.g. `OrgDataClient.setGrants({ orgDid, … })`).
1725
+ *
1726
+ * @param name - human-readable organisation name (1..=128 bytes)
1727
+ * @returns the new organisation's DID (`did:t3n:<40-hex>`)
1728
+ * @throws if the session is not authenticated, or if the contract
1729
+ * refuses (e.g. the caller is not a registered user, or the name is
1730
+ * empty / too long)
1731
+ */
1732
+ createOrganisation(name: string): Promise<Did>;
1711
1733
  /**
1712
1734
  * Build the canonical `ExecuteActionRequest` shape the server
1713
1735
  * expects (`script_name`, `script_version`, `function_name`, `input`,
@@ -1840,6 +1862,14 @@ declare class T3nClient {
1840
1862
  * when the node is configured with `skip_otp = true`). The next
1841
1863
  * step is {@link otpVerify} with the code the user typed.
1842
1864
  *
1865
+ * Do NOT call this to re-verify the email a session already
1866
+ * authenticated with via email-OTP: that email is
1867
+ * already proven by the login authenticator, so this call only
1868
+ * dispatches a redundant SECOND OTP email. For an email-OTP login,
1869
+ * go straight to {@link submitUserInput}. Use `otpRequest` to
1870
+ * verify a contact the session has NOT already proven — a phone, or
1871
+ * an email on a wallet/OIDC session.
1872
+ *
1843
1873
  * Behaviour notes:
1844
1874
  *
1845
1875
  * - Contact is a discriminated object: `emailChannel` or
@@ -1923,10 +1953,18 @@ declare class T3nClient {
1923
1953
  * verified email — either because {@link otpVerify} bound one or
1924
1954
  * because the session carries a proving authenticator (OIDC /
1925
1955
  * Email auth). Calls without proof are rejected with
1926
- * {@link UserUpsertError} `kind = "EmailNotVerified"`. The
1927
- * recommended UX is "request OTP -> verify OTP -> submit user
1928
- * input" (or use {@link runOtpThenUserInput} which chains all
1929
- * three).
1956
+ * {@link UserUpsertError} `kind = "EmailNotVerified"`.
1957
+ *
1958
+ * Two recommended flows depending on how the session logged in:
1959
+ * - **Email-OTP login** ({@link createEmailOtpAuthInput}): the
1960
+ * login already proved the email (and sent the only OTP email),
1961
+ * so call `submitUserInput` DIRECTLY — the gate passes on the
1962
+ * session authenticator and `verified_contacts.email` is
1963
+ * auto-stamped. Do NOT call {@link otpRequest} first; that sends
1964
+ * a redundant second OTP email.
1965
+ * - **Wallet / OIDC login** (no proven email yet): "request OTP ->
1966
+ * verify OTP -> submit user input" (or use
1967
+ * {@link runOtpThenUserInput} which chains all three).
1930
1968
  *
1931
1969
  * The KYC webhook orphan-attestation flow stays here: when
1932
1970
  * `requireExistingUser` is set, the contract identifies the user
@@ -1956,6 +1994,14 @@ declare class T3nClient {
1956
1994
  * {@link otpRequest}, {@link otpVerify}, and
1957
1995
  * {@link submitUserInput} explicitly so the application owns the
1958
1996
  * flow.
1997
+ *
1998
+ * Do NOT use this for the email a session authenticated with via
1999
+ * email-OTP login: it always runs {@link otpRequest},
2000
+ * which dispatches a redundant second OTP email for an
2001
+ * already-proven email. For an email-OTP login, call
2002
+ * {@link submitUserInput} directly. This helper is for sessions
2003
+ * that still need to prove the contact (phone, or an email on a
2004
+ * wallet/OIDC session).
1959
2005
  */
1960
2006
  runOtpThenUserInput(args: {
1961
2007
  channel: OtpChannel;