@proveanything/smartlinks 2.1.46 → 2.1.47

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/docs/dpp.md ADDED
@@ -0,0 +1,99 @@
1
+ # EU Digital Product Passports
2
+
3
+ SmartLinks hosts a brand's **EU Digital Product Passports** (ESPR) and registers them in the **EU registry** for
4
+ the brand. Each passport has its own permanent address, which is the identifier the EU registers. The public view
5
+ there is open to anyone; the restricted views (dismantling details, test reports, battery state of health) are served
6
+ only to the EU registry, for that brand.
7
+
8
+ Batteries come first (mandatory from 18 February 2027). Fields are named as in the Commission's own schemas
9
+ (`batteryChemistry`, `manufacturerIdentification`, …): `dpp.groups()` lists them, with what's required.
10
+
11
+ ## Connecting a brand to the EU registry
12
+
13
+ The EU only lets an organisation register its own passports, so the **brand enrols itself**: an EU Login, and a
14
+ declaration sealed with the brand's own **qualified e-seal** (from a provider on the EU trusted list). That happens
15
+ on the EU's site. Nobody sends SmartLinks a seal, certificate or private key.
16
+
17
+ Then, once per environment (`acc` = the EU test registry, `prod` = the live one):
18
+
19
+ ```ts
20
+ import { dpp } from "@proveanything/smartlinks"
21
+
22
+ // 1. SmartLinks makes the key; the brand adds the PUBLIC key to a Service Account ("Register DPPs" role).
23
+ const reg = await dpp.registry.makeKey(collectionId, "acc")
24
+ showToAdmin(reg.publicPem) // also reg.publicJwk; reg.portal is the registry's address
25
+
26
+ // 2. The brand pastes back three values from the registry.
27
+ await dpp.registry.set(collectionId, "acc", {
28
+ clientId: "…", // the Service Account's Client ID
29
+ kid: "…", // the key ID the registry gave our key
30
+ orgIdentifier: "…", // Organisation > Verification > Organisation ID, copied exactly
31
+ })
32
+
33
+ // 3. Check: signs in and reads the registry's product groups.
34
+ const { registry } = await dpp.registry.check(collectionId, "acc")
35
+ registry.lastCheck // { ok: true, … } or { ok: false, message: "…plain words…" }
36
+ ```
37
+
38
+ `dpp.registry.list(collectionId)` gives both environments, each with `nextStep`
39
+ (`make-key` → `enter-service-account` → `enter-organisation-id` → `check` → `null` when connected). Show them as
40
+ numbered steps.
41
+
42
+ ## Publishing passports
43
+
44
+ Say what a passport is for (a product, a batch or one item) and its granularity. SmartLinks updates that passport
45
+ or makes it:
46
+
47
+ ```ts
48
+ const { passport, created, changed } = await dpp.passports.upsert(collectionId, {
49
+ productId, // and/or batchId, proofId (one battery = a proof)
50
+ productGroup: "BATTERIES",
51
+ productSubGroup: "EV", // EV, LMT or IND
52
+ granularity: "item", // item | batch | model
53
+ modelIdentifier: "IC-75-LFP",
54
+ public: { batteryChemistry: ["https://repository.product-passport.ec.europa.eu/product/batteries/vocabs/battery-chemistry#lithiumIonLFP"], /* … */ },
55
+ restricted: { dismantlingInformation: [/* … */], batteryStatus: "…" },
56
+ })
57
+
58
+ passport.url // its address — what goes on the QR code and to the registry
59
+ passport.check // { ready, missing: { pub: [...], res1: [...], res2: [...], res3: [...] } }
60
+ passport.version // goes up by one each time what it says changes
61
+ ```
62
+
63
+ - **Publishing replaces**: the fields you send are the whole passport (`{ merge: true }` merges instead).
64
+ Publishing the same content again changes nothing (`changed: false`).
65
+ - **Many at once** (one per battery): `dpp.passports.upsertMany(collectionId, items)` — up to 500, each answering
66
+ on its own.
67
+ - **Versions**: `dpp.passports.versions(collectionId, id)`; read an earlier one with
68
+ `dpp.read(collectionId, id, { version: 2 })` (also `?version=2` on its address).
69
+ - **Withdraw / restore**: a withdrawn passport stays at its address, marked invalid.
70
+ - Never put restricted fields in `public`: anyone can read the public view.
71
+
72
+ `dpp.read(collectionId, passportId)` returns the public document exactly as served — use it for a public page,
73
+ so restricted data never reaches the browser.
74
+
75
+ ## Registering
76
+
77
+ ```ts
78
+ const { tasks, skipped } = await dpp.register(collectionId, "acc", passportIds, { wait: true })
79
+ // skipped: not found, withdrawn, already registered, or missing required fields (with the list)
80
+ // tasks[i].passports: each one's outcome — registered (with registryId) | rejected (problems) | not-sent
81
+ ```
82
+
83
+ The registry reads each passport at its address while validating it, and one bad passport rejects the whole
84
+ request — so passports still missing required fields are never sent. Without `wait`, follow up with
85
+ `dpp.tasks.refresh(collectionId, "acc", taskId)`; `dpp.tasks.list(collectionId, "acc")` lists past requests. Each
86
+ passport's `registration.acc` / `registration.prod` holds its status.
87
+
88
+ ## Reference
89
+
90
+ | Call | Does |
91
+ |---|---|
92
+ | `dpp.groups(collectionId)` | product groups, kinds, every field and the required ones per view |
93
+ | `dpp.read(collectionId, id, { version? })` | the public document at its address (no sign-in) |
94
+ | `dpp.registry.list / get / makeKey / set / check` | the brand's registry connection |
95
+ | `dpp.passports.list / get / create / update / upsert / upsertMany / versions / withdraw / restore` | passports |
96
+ | `dpp.register(collectionId, env, ids, { wait? })` | send to the registry |
97
+ | `dpp.tasks.list / refresh` | registry requests and their outcomes |
98
+
99
+ Admin calls need a collection admin. Platform design: prove `server/docs/design/eu-dpp.md`.
package/docs/overview.md CHANGED
@@ -78,6 +78,7 @@ The SmartLinks SDK (`@proveanything/smartlinks`) includes comprehensive document
78
78
  | **AI Guide Template** | `docs/ai-guide-template.md` | Template for creating `public/ai-guide.md` — customise per app |
79
79
  | **Forms** | `docs/forms.md` | Form definitions, schema-driven rendering, submission patterns |
80
80
  | **Auth Kit** | `docs/auth-kit.md` | End-user sign-in: email/password, magic links, phone OTP, Google OAuth |
81
+ | **EU Digital Product Passports** | `docs/dpp.md` | Passports hosted at their own address in the EU format (public + restricted views, versions), the brand's EU registry connection, and registering them (`dpp.*`) |
81
82
  | **Service accounts** | `docs/service-accounts.md` | Identities for other systems (an ERP, a warehouse system) to work with one collection: own key, own access level, made and removed by the collection's admins |
82
83
  | **Members** | `docs/members.md` | Signed-in members with a level (clubs, leagues, members' areas): the level field, members-only functions, joining rules |
83
84
  | **Portal Request Login** | `docs/portal-request-login.md` | How sub-apps ask the portal to authenticate the user; hook and iframe postMessage contracts |
package/openapi.yaml CHANGED
@@ -80,6 +80,8 @@ tags:
80
80
  description: Container and item tracking.
81
81
  - name: crate
82
82
  description: Crate packaging and logistics.
83
+ - name: dpp
84
+ description: dpp API
83
85
  - name: facets
84
86
  description: Product facet querying and aggregation.
85
87
  - name: form
@@ -15028,6 +15030,37 @@ paths:
15028
15030
  description: Unauthorized
15029
15031
  404:
15030
15032
  description: Not found
15033
+ /public/dpp/{collectionId}/{passportId}:
15034
+ get:
15035
+ tags:
15036
+ - dpp
15037
+ summary: Read a passport as the public sees it, at its address (the EU JSON document), or an earlier version of it.
15038
+ operationId: dpp_read
15039
+ security: []
15040
+ parameters:
15041
+ - name: collectionId
15042
+ in: path
15043
+ required: true
15044
+ schema:
15045
+ type: string
15046
+ - name: passportId
15047
+ in: path
15048
+ required: true
15049
+ schema:
15050
+ type: string
15051
+ responses:
15052
+ 200:
15053
+ description: Success
15054
+ content:
15055
+ application/json:
15056
+ schema:
15057
+ $ref: "#/components/schemas/DppDocument"
15058
+ 400:
15059
+ description: Bad request
15060
+ 401:
15061
+ description: Unauthorized
15062
+ 404:
15063
+ description: Not found
15031
15064
  /public/location/{locationId}:
15032
15065
  get:
15033
15066
  tags:
@@ -30171,6 +30204,476 @@ components:
30171
30204
  type: boolean
30172
30205
  required:
30173
30206
  - success
30207
+ DppRegistry:
30208
+ type: object
30209
+ properties:
30210
+ environment:
30211
+ $ref: "#/components/schemas/DppEnvironment"
30212
+ label:
30213
+ type: string
30214
+ portal:
30215
+ type: string
30216
+ clientId:
30217
+ type: string
30218
+ kid:
30219
+ type: string
30220
+ alg:
30221
+ type: string
30222
+ orgIdentifier:
30223
+ type: string
30224
+ hasKey:
30225
+ type: boolean
30226
+ publicPem:
30227
+ type: string
30228
+ publicJwk:
30229
+ type: object
30230
+ additionalProperties: true
30231
+ thumbprint:
30232
+ type: string
30233
+ keyCreatedAt:
30234
+ type: string
30235
+ lastCheck:
30236
+ type: object
30237
+ additionalProperties: true
30238
+ ready:
30239
+ type: boolean
30240
+ nextStep:
30241
+ $ref: "#/components/schemas/DppRegistryNextStep"
30242
+ required:
30243
+ - environment
30244
+ - label
30245
+ - portal
30246
+ - clientId
30247
+ - kid
30248
+ - alg
30249
+ - orgIdentifier
30250
+ - hasKey
30251
+ - publicPem
30252
+ - publicJwk
30253
+ - thumbprint
30254
+ - keyCreatedAt
30255
+ - lastCheck
30256
+ - ready
30257
+ - nextStep
30258
+ SetDppRegistryInput:
30259
+ type: object
30260
+ properties:
30261
+ clientId:
30262
+ type: string
30263
+ kid:
30264
+ type: string
30265
+ orgIdentifier:
30266
+ type: string
30267
+ DppRegistryProductGroup:
30268
+ type: object
30269
+ properties:
30270
+ code:
30271
+ type: string
30272
+ label:
30273
+ type: string
30274
+ productSubGroups:
30275
+ type: array
30276
+ items:
30277
+ type: object
30278
+ additionalProperties: true
30279
+ required:
30280
+ - code
30281
+ - label
30282
+ - productSubGroups
30283
+ DppRegistryCheckResult:
30284
+ type: object
30285
+ properties:
30286
+ registry:
30287
+ $ref: "#/components/schemas/DppRegistry"
30288
+ productGroups:
30289
+ type: array
30290
+ items:
30291
+ $ref: "#/components/schemas/DppRegistryProductGroup"
30292
+ required:
30293
+ - registry
30294
+ - productGroups
30295
+ DppViewFields:
30296
+ type: object
30297
+ properties:
30298
+ pub:
30299
+ type: array
30300
+ items:
30301
+ type: string
30302
+ res1:
30303
+ type: array
30304
+ items:
30305
+ type: string
30306
+ res2:
30307
+ type: array
30308
+ items:
30309
+ type: string
30310
+ res3:
30311
+ type: array
30312
+ items:
30313
+ type: string
30314
+ required:
30315
+ - pub
30316
+ - res1
30317
+ - res2
30318
+ - res3
30319
+ DppGroup:
30320
+ type: object
30321
+ properties:
30322
+ productGroup:
30323
+ type: string
30324
+ label:
30325
+ type: string
30326
+ subGroups:
30327
+ type: object
30328
+ additionalProperties: true
30329
+ productSubGroup:
30330
+ type: string
30331
+ fields:
30332
+ $ref: "#/components/schemas/DppViewFields"
30333
+ required:
30334
+ $ref: "#/components/schemas/DppViewFields"
30335
+ required:
30336
+ - productGroup
30337
+ - label
30338
+ - subGroups
30339
+ - productSubGroup
30340
+ - label
30341
+ - fields
30342
+ - required
30343
+ DppPassportCheck:
30344
+ type: object
30345
+ properties:
30346
+ ready:
30347
+ type: boolean
30348
+ missing:
30349
+ $ref: "#/components/schemas/DppViewFields"
30350
+ problem:
30351
+ type: string
30352
+ required:
30353
+ - ready
30354
+ - missing
30355
+ DppRegistration:
30356
+ type: object
30357
+ properties:
30358
+ status:
30359
+ type: object
30360
+ additionalProperties: true
30361
+ taskId:
30362
+ type: string
30363
+ submittedAt:
30364
+ type: string
30365
+ correlationId:
30366
+ type: string
30367
+ registryId:
30368
+ type: string
30369
+ registeredAt:
30370
+ type: string
30371
+ problems:
30372
+ type: object
30373
+ additionalProperties: true
30374
+ checkedAt:
30375
+ type: string
30376
+ required:
30377
+ - status
30378
+ DppPassport:
30379
+ type: object
30380
+ properties:
30381
+ id:
30382
+ type: string
30383
+ url:
30384
+ type: string
30385
+ status:
30386
+ type: object
30387
+ additionalProperties: true
30388
+ productGroup:
30389
+ type: string
30390
+ productSubGroup:
30391
+ type: string
30392
+ granularity:
30393
+ $ref: "#/components/schemas/DppGranularity"
30394
+ modelIdentifier:
30395
+ type: string
30396
+ batchIdentifier:
30397
+ type: string
30398
+ productId:
30399
+ type: string
30400
+ batchId:
30401
+ type: string
30402
+ proofId:
30403
+ type: string
30404
+ public:
30405
+ $ref: "#/components/schemas/DppFields"
30406
+ restricted:
30407
+ $ref: "#/components/schemas/DppFields"
30408
+ version:
30409
+ type: number
30410
+ contentUpdatedAt:
30411
+ type: string
30412
+ registration:
30413
+ $ref: "#/components/schemas/DppEnvironment"
30414
+ check:
30415
+ $ref: "#/components/schemas/DppPassportCheck"
30416
+ createdAt:
30417
+ type: string
30418
+ updatedAt:
30419
+ type: string
30420
+ required:
30421
+ - id
30422
+ - url
30423
+ - status
30424
+ - productGroup
30425
+ - productSubGroup
30426
+ - granularity
30427
+ - modelIdentifier
30428
+ - batchIdentifier
30429
+ - productId
30430
+ - batchId
30431
+ - proofId
30432
+ - public
30433
+ - restricted
30434
+ - version
30435
+ - contentUpdatedAt
30436
+ - registration
30437
+ - check
30438
+ - createdAt
30439
+ - updatedAt
30440
+ DppPassportInput:
30441
+ type: object
30442
+ properties:
30443
+ productGroup:
30444
+ type: string
30445
+ productSubGroup:
30446
+ type: string
30447
+ granularity:
30448
+ $ref: "#/components/schemas/DppGranularity"
30449
+ modelIdentifier:
30450
+ type: string
30451
+ batchIdentifier:
30452
+ type: string
30453
+ productId:
30454
+ type: string
30455
+ batchId:
30456
+ type: string
30457
+ proofId:
30458
+ type: string
30459
+ public:
30460
+ $ref: "#/components/schemas/DppFields"
30461
+ restricted:
30462
+ $ref: "#/components/schemas/DppFields"
30463
+ DppPassportUpsertInput:
30464
+ type: object
30465
+ properties:
30466
+ productGroup:
30467
+ type: string
30468
+ granularity:
30469
+ $ref: "#/components/schemas/DppGranularity"
30470
+ required:
30471
+ - productGroup
30472
+ - granularity
30473
+ DppPassportSaveResult:
30474
+ type: object
30475
+ properties:
30476
+ passport:
30477
+ $ref: "#/components/schemas/DppPassport"
30478
+ changed:
30479
+ type: boolean
30480
+ required:
30481
+ - passport
30482
+ - changed
30483
+ DppPassportUpsertResult:
30484
+ type: object
30485
+ properties:
30486
+ created:
30487
+ type: boolean
30488
+ required:
30489
+ - created
30490
+ DppPassportBulkResult:
30491
+ type: object
30492
+ properties:
30493
+ results:
30494
+ type: object
30495
+ additionalProperties: true
30496
+ created:
30497
+ type: number
30498
+ changed:
30499
+ type: number
30500
+ unchanged:
30501
+ type: number
30502
+ failed:
30503
+ type: number
30504
+ required:
30505
+ - results
30506
+ - created
30507
+ - changed
30508
+ - unchanged
30509
+ - failed
30510
+ DppPassportVersion:
30511
+ type: object
30512
+ properties:
30513
+ version:
30514
+ type: number
30515
+ savedAt:
30516
+ type: string
30517
+ savedBy:
30518
+ type: string
30519
+ required:
30520
+ - version
30521
+ - savedAt
30522
+ - savedBy
30523
+ DppPassportListQuery:
30524
+ type: object
30525
+ properties:
30526
+ productId:
30527
+ type: string
30528
+ batchId:
30529
+ type: string
30530
+ proofId:
30531
+ type: string
30532
+ status:
30533
+ type: object
30534
+ additionalProperties: true
30535
+ limit:
30536
+ type: number
30537
+ offset:
30538
+ type: number
30539
+ DppRegisterResult:
30540
+ type: object
30541
+ properties:
30542
+ tasks:
30543
+ type: object
30544
+ additionalProperties: true
30545
+ taskId:
30546
+ type: string
30547
+ environment:
30548
+ $ref: "#/components/schemas/DppEnvironment"
30549
+ productGroup:
30550
+ type: string
30551
+ productSubGroup:
30552
+ type: string
30553
+ passportIds:
30554
+ type: array
30555
+ items:
30556
+ type: string
30557
+ estimated:
30558
+ type: string
30559
+ status:
30560
+ type: string
30561
+ outcome:
30562
+ $ref: "#/components/schemas/DppTaskOutcome"
30563
+ passports:
30564
+ type: array
30565
+ items:
30566
+ $ref: "#/components/schemas/DppRegistration"
30567
+ skipped:
30568
+ type: array
30569
+ items:
30570
+ type: object
30571
+ additionalProperties: true
30572
+ required:
30573
+ - tasks
30574
+ - taskId
30575
+ - environment
30576
+ - productGroup
30577
+ - productSubGroup
30578
+ - passportIds
30579
+ - estimated
30580
+ - skipped
30581
+ DppTaskOutcome:
30582
+ type: object
30583
+ properties:
30584
+ outcomeResult:
30585
+ type: object
30586
+ additionalProperties: true
30587
+ outcomeMessage:
30588
+ type: object
30589
+ additionalProperties: true
30590
+ required:
30591
+ - outcomeResult
30592
+ DppTask:
30593
+ type: object
30594
+ properties:
30595
+ taskId:
30596
+ type: string
30597
+ environment:
30598
+ $ref: "#/components/schemas/DppEnvironment"
30599
+ status:
30600
+ type: string
30601
+ outcome:
30602
+ $ref: "#/components/schemas/DppTaskOutcome"
30603
+ passportIds:
30604
+ type: array
30605
+ items:
30606
+ type: string
30607
+ createdAt:
30608
+ type: string
30609
+ checkedAt:
30610
+ type: string
30611
+ required:
30612
+ - taskId
30613
+ - environment
30614
+ - status
30615
+ - outcome
30616
+ - passportIds
30617
+ - createdAt
30618
+ - checkedAt
30619
+ DppTaskRefreshResult:
30620
+ type: object
30621
+ properties:
30622
+ taskId:
30623
+ type: string
30624
+ status:
30625
+ type: string
30626
+ outcome:
30627
+ $ref: "#/components/schemas/DppTaskOutcome"
30628
+ processingInfo:
30629
+ type: object
30630
+ additionalProperties: true
30631
+ passports:
30632
+ type: array
30633
+ items:
30634
+ $ref: "#/components/schemas/DppRegistration"
30635
+ required:
30636
+ - taskId
30637
+ - status
30638
+ - outcome
30639
+ - processingInfo
30640
+ - passports
30641
+ DppDocument:
30642
+ type: object
30643
+ properties:
30644
+ digitalProductPassportId:
30645
+ type: string
30646
+ uniqueProductIdentifier:
30647
+ type: string
30648
+ granularity:
30649
+ type: string
30650
+ dppStatus:
30651
+ type: string
30652
+ lastUpdate:
30653
+ type: string
30654
+ contentSpecificationIds:
30655
+ type: array
30656
+ items:
30657
+ type: string
30658
+ required:
30659
+ - digitalProductPassportId
30660
+ - uniqueProductIdentifier
30661
+ - granularity
30662
+ - dppStatus
30663
+ - lastUpdate
30664
+ - contentSpecificationIds
30665
+ DppEnvironment:
30666
+ type: object
30667
+ additionalProperties: true
30668
+ DppGranularity:
30669
+ type: object
30670
+ additionalProperties: true
30671
+ DppRegistryNextStep:
30672
+ type: object
30673
+ additionalProperties: true
30674
+ DppFields:
30675
+ type: object
30676
+ additionalProperties: true
30174
30677
  ErrorResponse:
30175
30678
  type: object
30176
30679
  properties:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "2.1.46",
3
+ "version": "2.1.47",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",