@octap/browser-sdk 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +23 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,6 +6,10 @@ Firebase Auth. You never handle OAuth nonces, ephemeral keys, ZK proofs or Enoki
6
6
  This package holds no merchant credential. Balance, history, voucher lists and claims need your API
7
7
  key, so they stay on your backend through `@octap/sdk`.
8
8
 
9
+ ```bash
10
+ npm install @octap/browser-sdk
11
+ ```
12
+
9
13
  ## Sign a customer in
10
14
 
11
15
  ```ts
@@ -59,6 +63,23 @@ Follow these rules, whatever your interface looks like:
59
63
  key. `status` and `body` carry what the server answered, if anything.
60
64
  - Use a new idempotency key only after the claim is CANCELLED.
61
65
 
66
+ ## Use a voucher
67
+
68
+ Your backend calls `prepareVoucherUse` from `@octap/sdk` and returns the result. Show the customer
69
+ which voucher they are using, then have their device sign it:
70
+
71
+ ```ts
72
+ const use = await response.json();
73
+ const used = await auth.signAndFinalizeVoucherUse(use);
74
+ // used.status is REDEEMED; deliver the benefit on the voucher.redeemed webhook.
75
+ ```
76
+
77
+ The signature is the only thing that can mark a customer's voucher used: your API key cannot.
78
+ `signAndFinalizeVoucherUse` never retries by itself. On `outcome-unknown`, read the voucher from your
79
+ backend before you try again.
80
+
81
+ ## Lower-level signing
82
+
62
83
  `auth.signTransaction(transactionBytes)` is the lower-level call: it returns the zkLogin signature
63
84
  and sends nothing. It refuses bytes whose sender is not the signed-in customer.
64
85
 
@@ -105,4 +126,5 @@ share this client for now, so moving to per-merchant clients later would change
105
126
 
106
127
  ## Local example
107
128
 
108
- See [the browser auth example](../../examples/README.md#browser-auth-example) for a runnable page.
129
+ See [the browser auth example](https://github.com/OctaPointees/octap-core/tree/dev/ts-sdks/examples/browser-auth)
130
+ in the octap-core repository for a runnable page.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octap/browser-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Firebase-style customer sign-in and transaction signing for OctaP loyalty programs.",
5
5
  "license": "MIT",
6
6
  "type": "module",