@nokinc-flur/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.
package/LICENSE CHANGED
@@ -1 +1,21 @@
1
- MIT
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NokInc Flur
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -22,3 +22,59 @@ npm run gen
22
22
  ```bash
23
23
  FLUR_BASE_URL=http://localhost:8080 RUN_E2E=1 npm test
24
24
  ```
25
+
26
+ ## Onboarding flow methods
27
+
28
+ ```ts
29
+ import { FlurClient } from "@nokinc-flur/sdk";
30
+
31
+ const client = new FlurClient({ baseUrl: "https://api.example.com" });
32
+
33
+ const started = await client.onboardingStart({ phoneE164: "+14155550123" });
34
+ // started: { requestId, checkUrl?, expiresInSec, fallback }
35
+
36
+ const completed = await client.onboardingComplete({
37
+ requestId: started.requestId,
38
+ code: "123456",
39
+ });
40
+ // completed: { sessionToken, userId, restricted, risk_reasons }
41
+ ```
42
+
43
+ ## Lean prod release workflow (one-person team)
44
+
45
+ PowerShell script (Windows):
46
+
47
+ ```powershell
48
+ # patch release (recommended for this onboarding addition)
49
+ ./scripts/release.ps1 -Bump patch
50
+
51
+ # exact version release (example: 1.0.1)
52
+ ./scripts/release.ps1 -Version 1.0.1
53
+
54
+ # include E2E run (uses default OCI API Gateway URL from release script)
55
+ ./scripts/release.ps1 -Version 1.0.1 -RunE2E
56
+
57
+ # include E2E run with override URL
58
+ ./scripts/release.ps1 -Version 1.0.1 -RunE2E -E2EBaseUrl https://your-api.example.com
59
+
60
+ # publish to npm after all checks pass
61
+ ./scripts/release.ps1 -Bump patch -Publish
62
+ ./scripts/release.ps1 -Version 1.0.1 -Publish
63
+ ```
64
+
65
+ What it does:
66
+ - verifies git working tree is clean
67
+ - runs `npm ci`
68
+ - runs `npm run lint`, `npm run typecheck`, `npm test`, `npm run build`
69
+ - creates tarball via `npm pack` and smoke-tests install in a temp project
70
+ - bumps version (`patch`/`minor`/`major`) and creates git tag
71
+ - pushes commit and tag (`git push`, `git push --tags`)
72
+ - optionally publishes to npm (`-Publish`)
73
+
74
+ NPM aliases:
75
+
76
+ ```bash
77
+ npm run release:patch
78
+ npm run release:minor
79
+ npm run release:major
80
+ ```
package/dist/index.d.ts CHANGED
@@ -3,6 +3,27 @@ type FlurClientOptions = {
3
3
  fetchImpl?: typeof fetch;
4
4
  timeoutMs?: number;
5
5
  };
6
+ type OnboardingFallback = "SILENT_AUTH" | "OTP";
7
+ type OnboardingStartInput = {
8
+ phoneE164: string;
9
+ };
10
+ type OnboardingStartResponse = {
11
+ requestId: string;
12
+ checkUrl?: string;
13
+ expiresInSec: number;
14
+ fallback: OnboardingFallback;
15
+ };
16
+ type OnboardingRiskReason = "SIM_SWAP_RECENT" | "ROAMING" | "CARRIER_CHANGED";
17
+ type OnboardingCompleteInput = {
18
+ requestId: string;
19
+ code: string;
20
+ };
21
+ type OnboardingCompleteResponse = {
22
+ sessionToken: string;
23
+ userId: string;
24
+ restricted: boolean;
25
+ risk_reasons: OnboardingRiskReason[];
26
+ };
6
27
  declare class FlurClient {
7
28
  private readonly baseUrl;
8
29
  private readonly fetchImpl;
@@ -14,6 +35,9 @@ declare class FlurClient {
14
35
  welcome(): Promise<{
15
36
  message: string;
16
37
  }>;
38
+ onboardingStart(input: OnboardingStartInput): Promise<OnboardingStartResponse>;
39
+ onboardingComplete(input: OnboardingCompleteInput): Promise<OnboardingCompleteResponse>;
40
+ private requestJson;
17
41
  }
18
42
 
19
43
  type FlurErrorCode = "NETWORK_ERROR" | "HTTP_ERROR" | "TIMEOUT" | "UNKNOWN";
@@ -27,4 +51,4 @@ declare class FlurError extends Error {
27
51
  });
28
52
  }
29
53
 
30
- export { FlurClient, type FlurClientOptions, FlurError };
54
+ export { FlurClient, type FlurClientOptions, FlurError, type OnboardingCompleteInput, type OnboardingCompleteResponse, type OnboardingFallback, type OnboardingRiskReason, type OnboardingStartInput, type OnboardingStartResponse };
package/dist/index.js CHANGED
@@ -32,29 +32,31 @@ var FlurClient = class {
32
32
  this.timeoutMs = opts.timeoutMs ?? 1e4;
33
33
  }
34
34
  async health() {
35
- const url = `${this.baseUrl}/health`;
36
- const controller = new AbortController();
37
- const t = setTimeout(() => controller.abort(), this.timeoutMs);
38
- try {
39
- const res = await this.fetchImpl(url, { method: "GET", signal: controller.signal });
40
- if (!res.ok) throw await mapToFlurError(res);
41
- return await res.json();
42
- } catch (err) {
43
- if (err instanceof Error && err.name === "AbortError") {
44
- throw new FlurError("Request timed out", "TIMEOUT");
45
- }
46
- if (err instanceof FlurError) throw err;
47
- throw new FlurError("Network error", "NETWORK_ERROR", { details: String(err) });
48
- } finally {
49
- clearTimeout(t);
50
- }
35
+ return this.requestJson("/health", { method: "GET" });
51
36
  }
52
37
  async welcome() {
53
- const url = `${this.baseUrl}/welcome`;
38
+ return this.requestJson("/welcome", { method: "GET" });
39
+ }
40
+ async onboardingStart(input) {
41
+ return this.requestJson("/v1/onboarding/start", {
42
+ method: "POST",
43
+ headers: { "content-type": "application/json" },
44
+ body: JSON.stringify(input)
45
+ });
46
+ }
47
+ async onboardingComplete(input) {
48
+ return this.requestJson("/v1/onboarding/complete", {
49
+ method: "POST",
50
+ headers: { "content-type": "application/json" },
51
+ body: JSON.stringify(input)
52
+ });
53
+ }
54
+ async requestJson(path, init) {
55
+ const url = `${this.baseUrl}${path}`;
54
56
  const controller = new AbortController();
55
57
  const t = setTimeout(() => controller.abort(), this.timeoutMs);
56
58
  try {
57
- const res = await this.fetchImpl(url, { method: "GET", signal: controller.signal });
59
+ const res = await this.fetchImpl(url, { ...init, signal: controller.signal });
58
60
  if (!res.ok) throw await mapToFlurError(res);
59
61
  return await res.json();
60
62
  } catch (err) {
@@ -53,6 +53,183 @@
53
53
  }
54
54
  }
55
55
  }
56
+ },
57
+ "/v1/onboarding/start": {
58
+ "post": {
59
+ "requestBody": {
60
+ "required": true,
61
+ "content": {
62
+ "application/json": {
63
+ "schema": {
64
+ "type": "object",
65
+ "properties": {
66
+ "phoneE164": {
67
+ "type": "string"
68
+ }
69
+ },
70
+ "required": [
71
+ "phoneE164"
72
+ ]
73
+ }
74
+ }
75
+ }
76
+ },
77
+ "responses": {
78
+ "200": {
79
+ "description": "Verification started",
80
+ "content": {
81
+ "application/json": {
82
+ "schema": {
83
+ "type": "object",
84
+ "properties": {
85
+ "requestId": {
86
+ "type": "string"
87
+ },
88
+ "checkUrl": {
89
+ "type": "string"
90
+ },
91
+ "expiresInSec": {
92
+ "type": "integer"
93
+ },
94
+ "fallback": {
95
+ "type": "string",
96
+ "enum": [
97
+ "SILENT_AUTH",
98
+ "OTP"
99
+ ]
100
+ }
101
+ },
102
+ "required": [
103
+ "requestId",
104
+ "expiresInSec",
105
+ "fallback"
106
+ ]
107
+ }
108
+ }
109
+ }
110
+ },
111
+ "400": {
112
+ "description": "Unable to start verification",
113
+ "content": {
114
+ "application/json": {
115
+ "schema": {
116
+ "type": "object",
117
+ "properties": {
118
+ "error": {
119
+ "type": "string"
120
+ }
121
+ },
122
+ "required": [
123
+ "error"
124
+ ]
125
+ }
126
+ }
127
+ }
128
+ },
129
+ "429": {
130
+ "description": "Rate limited",
131
+ "content": {
132
+ "application/json": {
133
+ "schema": {
134
+ "type": "object",
135
+ "properties": {
136
+ "error": {
137
+ "type": "string"
138
+ }
139
+ },
140
+ "required": [
141
+ "error"
142
+ ]
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ },
150
+ "/v1/onboarding/complete": {
151
+ "post": {
152
+ "requestBody": {
153
+ "required": true,
154
+ "content": {
155
+ "application/json": {
156
+ "schema": {
157
+ "type": "object",
158
+ "properties": {
159
+ "requestId": {
160
+ "type": "string"
161
+ },
162
+ "code": {
163
+ "type": "string"
164
+ }
165
+ },
166
+ "required": [
167
+ "requestId",
168
+ "code"
169
+ ]
170
+ }
171
+ }
172
+ }
173
+ },
174
+ "responses": {
175
+ "200": {
176
+ "description": "Verification completed",
177
+ "content": {
178
+ "application/json": {
179
+ "schema": {
180
+ "type": "object",
181
+ "properties": {
182
+ "sessionToken": {
183
+ "type": "string"
184
+ },
185
+ "userId": {
186
+ "type": "string"
187
+ },
188
+ "restricted": {
189
+ "type": "boolean"
190
+ },
191
+ "risk_reasons": {
192
+ "type": "array",
193
+ "items": {
194
+ "type": "string",
195
+ "enum": [
196
+ "SIM_SWAP_RECENT",
197
+ "ROAMING",
198
+ "CARRIER_CHANGED"
199
+ ]
200
+ }
201
+ }
202
+ },
203
+ "required": [
204
+ "sessionToken",
205
+ "userId",
206
+ "restricted",
207
+ "risk_reasons"
208
+ ]
209
+ }
210
+ }
211
+ }
212
+ },
213
+ "400": {
214
+ "description": "Verification failed",
215
+ "content": {
216
+ "application/json": {
217
+ "schema": {
218
+ "type": "object",
219
+ "properties": {
220
+ "error": {
221
+ "type": "string"
222
+ }
223
+ },
224
+ "required": [
225
+ "error"
226
+ ]
227
+ }
228
+ }
229
+ }
230
+ }
231
+ }
232
+ }
56
233
  }
57
234
  }
58
235
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nokinc-flur/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Flur Wallet SDK (sprint 1 scaffold)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,7 +23,10 @@
23
23
  "typecheck": "tsc -p tsconfig.json --noEmit",
24
24
  "test": "vitest run",
25
25
  "build": "tsup src/index.ts --format esm --dts",
26
- "gen": "openapi-typescript openapi/flur.openapi.json -o src/gen/openapi-types.ts"
26
+ "gen": "openapi-typescript openapi/flur.openapi.json -o src/gen/openapi-types.ts",
27
+ "release:patch": "pwsh -NoProfile -ExecutionPolicy Bypass -File ./scripts/release.ps1 -Bump patch",
28
+ "release:minor": "pwsh -NoProfile -ExecutionPolicy Bypass -File ./scripts/release.ps1 -Bump minor",
29
+ "release:major": "pwsh -NoProfile -ExecutionPolicy Bypass -File ./scripts/release.ps1 -Bump major"
27
30
  },
28
31
  "dependencies": {
29
32
  "zod": "^3.23.8"
@@ -40,4 +43,4 @@
40
43
  "typescript": "^5.4.5",
41
44
  "vitest": "^1.5.0"
42
45
  }
43
- }
46
+ }